src/gui.cpp

changeset 384
f4622b79133d
parent 383
10e60ae9ed58
child 385
b136331072a0
equal deleted inserted replaced
383:10e60ae9ed58 384:f4622b79133d
125 #define act(N) if (sender() == ui->action##N) invokeAction (ui->action##N, &actiondef_##N); 125 #define act(N) if (sender() == ui->action##N) invokeAction (ui->action##N, &actiondef_##N);
126 #include "actions.h" 126 #include "actions.h"
127 } 127 }
128 128
129 void ForgeWindow::invokeAction (QAction* act, void (*func) ()) { 129 void ForgeWindow::invokeAction (QAction* act, void (*func) ()) {
130 // Open the history so we can record the edits done during this action. 130 beginAction (act);
131 if (act != ACTION (Undo) && act != ACTION (Redo) && act != ACTION (Open))
132 currentFile()->openHistory();
133
134 // Invoke the function
135 (*func) (); 131 (*func) ();
136 132 endAction();
137 // Close the history now.
138 currentFile()->closeHistory();
139 updateFileListItem (currentFile());
140 } 133 }
141 134
142 // ============================================================================= 135 // =============================================================================
143 void ForgeWindow::slot_lastSecondCleanup() { 136 void ForgeWindow::slot_lastSecondCleanup() {
144 delete m_renderer; 137 delete m_renderer;
814 807
815 ++row; 808 ++row;
816 } 809 }
817 } 810 }
818 811
819 // =============================================================================
820 QDialogButtonBox* makeButtonBox (QDialog& dlg) {
821 QDialogButtonBox* bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
822 QWidget::connect (bbx_buttons, SIGNAL (accepted()), &dlg, SLOT (accept()));
823 QWidget::connect (bbx_buttons, SIGNAL (rejected()), &dlg, SLOT (reject()));
824 return bbx_buttons;
825 }
826
827 CheckBoxGroup* makeAxesBox() { 812 CheckBoxGroup* makeAxesBox() {
828 CheckBoxGroup* cbg_axes = new CheckBoxGroup ("Axes", Qt::Horizontal); 813 CheckBoxGroup* cbg_axes = new CheckBoxGroup ("Axes", Qt::Horizontal);
829 cbg_axes->addCheckBox ("X", X); 814 cbg_axes->addCheckBox ("X", X);
830 cbg_axes->addCheckBox ("Y", Y); 815 cbg_axes->addCheckBox ("Y", Y);
831 cbg_axes->addCheckBox ("Z", Z); 816 cbg_axes->addCheckBox ("Z", Z);
874 859
875 f->listItem()->setText (name); 860 f->listItem()->setText (name);
876 f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); 861 f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon());
877 } 862 }
878 863
864 void ForgeWindow::beginAction (QAction* act) {
865 // Open the history so we can record the edits done during this action.
866 if (act != ACTION (Undo) && act != ACTION (Redo) && act != ACTION (Open))
867 currentFile()->openHistory();
868 }
869
870 void ForgeWindow::endAction() {
871 // Close the history now.
872 currentFile()->closeHistory();
873 updateFileListItem (currentFile());
874 }
875
879 QImage imageFromScreencap (uchar* data, ushort w, ushort h) { 876 QImage imageFromScreencap (uchar* data, ushort w, ushort h) {
880 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. 877 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well.
881 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); 878 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored();
882 } 879 }

mercurial