Permalink
Browse files

New function to revert agf for current revision

So that we can revert only that revision as agf instead of all revisions
by that user
  • Loading branch information...
benapetr committed Aug 27, 2014
1 parent e52f7f6 commit cc42f9a57c313b0b0044ca0a286ad063451c782c
Showing with 41 additions and 16 deletions.
  1. +3 −0 huggle/configuration.cpp
  2. +1 −0 huggle/configuration.hpp
  3. +29 −16 huggle/mainwindow.cpp
  4. +2 −0 huggle/mainwindow.hpp
  5. +6 −0 huggle/mainwindow.ui
View
@@ -92,6 +92,7 @@ Configuration::Configuration()
this->MakeShortcut("main-watch", "shortcut-watch", "Alt+X");
this->MakeShortcut("main-unwatch", "shortcut-unwatch", "Alt+C");
this->MakeShortcut("main-open", "shortcut-open-in-huggle", "Alt+O");
this->MakeShortcut("main-revert-agf-one-only", "shortcut-revert-agf-1");
}
Configuration::~Configuration()
@@ -784,6 +785,8 @@ Shortcut::Shortcut(QString name, QString description)
this->ID = HUGGLE_ACCEL_MAIN_OPEN;
else if (name == "main-mytalk")
this->ID = HUGGLE_ACCEL_MAIN_MYTALK_PAGE;
else if (name == "main-revert-agf-one-only")
this->ID = HUGGLE_ACCEL_MAIN_REVERT_AGF_ONE_REV;
else if (name == "main-talk")
this->ID = HUGGLE_ACCEL_MAIN_TALK;
else if (name.startsWith("main-revert-and-warn-"))
View
@@ -65,6 +65,7 @@ class QXmlStreamWriter;
#define HUGGLE_ACCEL_MAIN_OPEN_IN_BROWSER 40
#define HUGGLE_ACCEL_MAIN_GOOD 41
#define HUGGLE_ACCEL_MAIN_MYTALK_PAGE 42
#define HUGGLE_ACCEL_MAIN_REVERT_AGF_ONE_REV 44
#define HUGGLE_ACCEL_MAIN_WATCH 45
#define HUGGLE_ACCEL_MAIN_UNWATCH 46
#define HUGGLE_ACCEL_MAIN_OPEN 48
View
@@ -502,6 +502,26 @@ void MainWindow::RequestPD()
this->fSpeedyDelete->show();
}
void MainWindow::RevertAgf(bool only)
{
if (this->CurrentEdit == nullptr || !this->CheckExit() || !this->CheckEditableBrowserPage())
return;
if (Configuration::HuggleConfiguration->Restricted)
{
Generic::DeveloperError();
return;
}
bool ok;
QString reason = QInputDialog::getText(this, _l("reason"), _l("main-revert-custom-reson"), QLineEdit::Normal,
"No reason was provided / custom revert", &ok);
if (!ok)
return;
QString summary = this->GetCurrentWikiSite()->GetProjectConfig()->AgfRevert;
summary.replace("$2", this->CurrentEdit->User->Username);
summary.replace("$1", reason);
this->Revert(summary, true, only);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if (this->ShuttingDown)
@@ -785,6 +805,9 @@ void MainWindow::ReloadShort(QString id)
q = this->ui->actionWarn_the_user;
tip = this->ui->actionWarn;
break;
case HUGGLE_ACCEL_MAIN_REVERT_AGF_ONE_REV:
q = this->ui->actionRevert_only_this_revision_assuming_good_faith;
break;
case HUGGLE_ACCEL_MAIN_GOOD:
q = this->ui->actionFlag_as_a_good_edit;
break;
@@ -2339,22 +2362,7 @@ void Huggle::MainWindow::on_actionShow_list_of_score_words_triggered()
void Huggle::MainWindow::on_actionRevert_AGF_triggered()
{
if (this->CurrentEdit == nullptr || !this->CheckExit() || !this->CheckEditableBrowserPage())
return;
if (Configuration::HuggleConfiguration->Restricted)
{
Generic::DeveloperError();
return;
}
bool ok;
QString reason = QInputDialog::getText(this, _l("reason"), _l("main-revert-custom-reson"), QLineEdit::Normal,
"No reason was provided / custom revert", &ok);
if (!ok)
return;
QString summary = this->GetCurrentWikiSite()->GetProjectConfig()->AgfRevert;
summary.replace("$2", this->CurrentEdit->User->Username);
summary.replace("$1", reason);
this->Revert(summary);
this->RevertAgf(false);
}
void Huggle::MainWindow::on_actionDisplay_a_session_data_triggered()
@@ -2737,3 +2745,8 @@ void MainWindow::Go()
QAction *action = (QAction*)QObject::sender();
QDesktopServices::openUrl(QString(Configuration::GetProjectWikiURL() + action->toolTip()));
}
void Huggle::MainWindow::on_actionRevert_only_this_revision_assuming_good_faith_triggered()
{
this->RevertAgf(true);
}
View
@@ -294,6 +294,7 @@ namespace Huggle
void on_actionMy_talk_page_triggered();
void on_actionMy_Contributions_triggered();
void Go();
void on_actionRevert_only_this_revision_assuming_good_faith_triggered();
private:
//! Check if huggle is shutting down or not, in case it is, message box is shown as well
//! this function should be called before every action user can trigger
@@ -312,6 +313,7 @@ namespace Huggle
void Render();
//! Request a page deletion csd or afd and so on
void RequestPD();
void RevertAgf(bool only);
//! This function is called by main thread and is used to remove edits that were already reverted
void TruncateReverts();
void closeEvent(QCloseEvent *event);
View
@@ -123,6 +123,7 @@
<addaction name="actionRevert_currently_displayed_edit_warn_user_and_stay_on_page"/>
<addaction name="actionRevert_AGF"/>
<addaction name="actionRevert_only_this_revision"/>
<addaction name="actionRevert_only_this_revision_assuming_good_faith"/>
<addaction name="actionWarn_the_user"/>
<addaction name="separator"/>
<addaction name="actionDisplay_this_page_in_browser"/>
@@ -991,6 +992,11 @@
<string>My Contributions</string>
</property>
</action>
<action name="actionRevert_only_this_revision_assuming_good_faith">
<property name="text">
<string>Revert only this revision assuming good faith</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>

0 comments on commit cc42f9a

Please sign in to comment.