Skip to content

Commit

Permalink
Added a Revert command to the File menu - fixes #2040
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 15, 2015
1 parent d0cfe4b commit 1749ff2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/Gui/CommandDoc.cpp
Expand Up @@ -538,6 +538,39 @@ bool StdCmdSaveAs::isActive(void)
return getGuiApplication()->sendHasMsgToActiveView("SaveAs");
}

//===========================================================================
// Std_Revert
//===========================================================================
DEF_STD_CMD_A(StdCmdRevert);

StdCmdRevert::StdCmdRevert()
:Command("Std_Revert")
{
sGroup = QT_TR_NOOP("File");
sMenuText = QT_TR_NOOP("Revert");
sToolTipText = QT_TR_NOOP("Reverts to the saved version of this file");
sWhatsThis = "Std_Revert";
sStatusTip = QT_TR_NOOP("Reverts to the saved version of this file");
}

void StdCmdRevert::activated(int iMsg)
{
App::Document* doc = App::GetApplication().getActiveDocument();
QMessageBox msgBox;
msgBox.setText(qApp->translate("Std_Revert","This will discard all the changes since last file save."));
msgBox.setInformativeText(qApp->translate("Std_Revert","Are you sure?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
doCommand(Command::App,"App.ActiveDocument.restore()");
}

bool StdCmdRevert::isActive(void)
{
return ( getActiveGuiDocument() ? true : false );
}

//===========================================================================
// Std_ProjectInfo
//===========================================================================
Expand Down Expand Up @@ -1357,6 +1390,7 @@ void CreateDocCommands(void)

rcCmdMgr.addCommand(new StdCmdSave());
rcCmdMgr.addCommand(new StdCmdSaveAs());
rcCmdMgr.addCommand(new StdCmdRevert());
rcCmdMgr.addCommand(new StdCmdProjectInfo());
rcCmdMgr.addCommand(new StdCmdProjectUtil());
rcCmdMgr.addCommand(new StdCmdUndo());
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Workbench.cpp
Expand Up @@ -464,7 +464,7 @@ MenuItem* StdWorkbench::setupMenuBar() const
file->setCommand("&File");
*file << "Std_New" << "Std_Open" << "Separator" << "Std_CloseActiveWindow"
<< "Std_CloseAllWindows" << "Separator" << "Std_Save" << "Std_SaveAs"
<< "Separator" << "Std_Import" << "Std_Export"
<< "Std_Revert" << "Separator" << "Std_Import" << "Std_Export"
<< "Std_MergeProjects" << "Std_ProjectInfo"
<< "Separator" << "Std_Print" << "Std_PrintPreview" << "Std_PrintPdf"
<< "Separator" << "Std_RecentFiles" << "Separator" << "Std_Quit";
Expand Down

0 comments on commit 1749ff2

Please sign in to comment.