Gui: [skip ci] add option to automatically close task dialog if undo/redo was pressed
This commit is contained in:
@@ -38,7 +38,9 @@ using namespace Gui::TaskView;
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDialog::TaskDialog()
|
||||
: QObject(0), pos(North), escapeButton(true)
|
||||
: QObject(nullptr), pos(North)
|
||||
, escapeButton(true)
|
||||
, autoCloseTransaction(false)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -84,6 +86,11 @@ void TaskDialog::closed()
|
||||
|
||||
}
|
||||
|
||||
void TaskDialog::autoClosedOnTransactionChange()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDialog::clicked(int)
|
||||
{
|
||||
|
||||
|
||||
@@ -75,6 +75,15 @@ public:
|
||||
return escapeButton;
|
||||
}
|
||||
|
||||
/// Defines whether a task dialog must be closed if the document changed the
|
||||
/// active transaction.
|
||||
void setAutoCloseOnTransactionChange(bool on) {
|
||||
autoCloseTransaction = on;
|
||||
}
|
||||
bool isAutoCloseOnTransactionChange() const {
|
||||
return autoCloseTransaction;
|
||||
}
|
||||
|
||||
const std::string& getDocumentName() const
|
||||
{ return documentName; }
|
||||
void setDocumentName(const std::string& doc)
|
||||
@@ -105,6 +114,9 @@ public:
|
||||
virtual void open();
|
||||
/// is called by the framework when the dialog is closed
|
||||
virtual void closed();
|
||||
/// is called by the framework when the dialog is automatically closed due to
|
||||
/// changing the active transaction
|
||||
virtual void autoClosedOnTransactionChange();
|
||||
/// is called by the framework if a button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
@@ -129,6 +141,7 @@ protected:
|
||||
private:
|
||||
std::string documentName;
|
||||
bool escapeButton;
|
||||
bool autoCloseTransaction;
|
||||
};
|
||||
|
||||
} //namespace TaskView
|
||||
|
||||
@@ -532,12 +532,22 @@ void TaskView::slotDeletedDocument()
|
||||
|
||||
void TaskView::slotUndoDocument(const App::Document&)
|
||||
{
|
||||
if (ActiveDialog && ActiveDialog->isAutoCloseOnTransactionChange()) {
|
||||
ActiveDialog->autoClosedOnTransactionChange();
|
||||
removeDialog();
|
||||
}
|
||||
|
||||
if (!ActiveDialog)
|
||||
updateWatcher();
|
||||
}
|
||||
|
||||
void TaskView::slotRedoDocument(const App::Document&)
|
||||
{
|
||||
if (ActiveDialog && ActiveDialog->isAutoCloseOnTransactionChange()) {
|
||||
ActiveDialog->autoClosedOnTransactionChange();
|
||||
removeDialog();
|
||||
}
|
||||
|
||||
if (!ActiveDialog)
|
||||
updateWatcher();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user