--- a/src/gui.cpp Mon Jul 15 20:45:26 2013 +0300 +++ b/src/gui.cpp Mon Jul 15 22:07:49 2013 +0300 @@ -127,16 +127,9 @@ } void ForgeWindow::invokeAction (QAction* act, void (*func) ()) { - // Open the history so we can record the edits done during this action. - if (act != ACTION (Undo) && act != ACTION (Redo) && act != ACTION (Open)) - currentFile()->openHistory(); - - // Invoke the function + beginAction (act); (*func) (); - - // Close the history now. - currentFile()->closeHistory(); - updateFileListItem (currentFile()); + endAction(); } // ============================================================================= @@ -816,14 +809,6 @@ } } -// ============================================================================= -QDialogButtonBox* makeButtonBox (QDialog& dlg) { - QDialogButtonBox* bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - QWidget::connect (bbx_buttons, SIGNAL (accepted()), &dlg, SLOT (accept())); - QWidget::connect (bbx_buttons, SIGNAL (rejected()), &dlg, SLOT (reject())); - return bbx_buttons; -} - CheckBoxGroup* makeAxesBox() { CheckBoxGroup* cbg_axes = new CheckBoxGroup ("Axes", Qt::Horizontal); cbg_axes->addCheckBox ("X", X); @@ -876,6 +861,18 @@ f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); } +void ForgeWindow::beginAction (QAction* act) { + // Open the history so we can record the edits done during this action. + if (act != ACTION (Undo) && act != ACTION (Redo) && act != ACTION (Open)) + currentFile()->openHistory(); +} + +void ForgeWindow::endAction() { + // Close the history now. + currentFile()->closeHistory(); + updateFileListItem (currentFile()); +} + QImage imageFromScreencap (uchar* data, ushort w, ushort h) { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored();