updates on file list

Mon, 15 Jul 2013 22:07:49 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 15 Jul 2013 22:07:49 +0300
changeset 384
f4622b79133d
parent 383
10e60ae9ed58
child 385
b136331072a0

updates on file list

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/gldraw.cpp file | annotate | diff | comparison | revisions
src/gui.cpp file | annotate | diff | comparison | revisions
src/gui.h file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Mon Jul 15 20:45:26 2013 +0300
+++ b/src/addObjectDialog.cpp	Mon Jul 15 22:07:49 2013 +0300
@@ -48,9 +48,7 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) :
-	QDialog (parent)
-{
+AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : QDialog (parent) {
 	setlocale (LC_ALL, "C");
 	
 	short coordCount = 0;
@@ -102,7 +100,7 @@
 				;
 			
 			tw_subfileList = new QTreeWidget ();
-			tw_subfileList->setHeaderLabel ("Primitives");
+			tw_subfileList->setHeaderLabel (tr ("Primitives"));
 			
 			for (PrimitiveCategory& cat : g_PrimitiveCategories) {
 				SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null);
@@ -231,9 +229,12 @@
 		layout->addLayout (qCoordLayout, 0, 1, (coordCount / 3), 3);
 	}
 	
-	layout->addWidget( makeButtonBox( *this ), 5, 0, 1, 4 );
-	setLayout( layout );
-	setWindowTitle( fmt( tr( "Edit %1" ), typeName ));
+	QDialogButtonBox* bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+	QWidget::connect (bbx_buttons, SIGNAL (accepted()), this, SLOT (accept()));
+	QWidget::connect (bbx_buttons, SIGNAL (rejected()), this, SLOT (reject()));
+	layout->addWidget (bbx_buttons, 5, 0, 1, 4);
+	setLayout (layout);
+	setWindowTitle (fmt (tr ("Edit %1"), typeName));
 	
 	setWindowIcon (icon);
 	delete defaults;
--- a/src/gldraw.cpp	Mon Jul 15 20:45:26 2013 +0300
+++ b/src/gldraw.cpp	Mon Jul 15 22:07:49 2013 +0300
@@ -1287,11 +1287,11 @@
 	}
 	
 	if (obj) {
-		file()->openHistory();
+		g_win->beginAction (null);
 		file()->addObject (obj);
 		compileObject (obj);
 		g_win->fullRefresh();
-		file()->closeHistory();
+		g_win->endAction();
 	}
 	
 	m_drawedVerts.clear();
@@ -1598,10 +1598,10 @@
 	if (g_win->sel().size() == 0)
 		return;
 	
-	file()->openHistory();
+	g_win->beginAction (null);
 	LDObject* obj = g_win->sel()[0];
 	AddObjectDialog::staticDialog (obj->getType(), obj);
-	file()->closeHistory();
+	g_win->endAction();
 	ev->accept();
 }
 
--- 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();
--- a/src/gui.h	Mon Jul 15 20:45:26 2013 +0300
+++ b/src/gui.h	Mon Jul 15 22:07:49 2013 +0300
@@ -119,6 +119,9 @@
 	void addMessage (str msg);
 	Ui_LDForgeUI* interface() const;
 	
+	void beginAction(QAction* act);
+	void endAction();
+	
 #define act(N) QAction* action##N();
 #include "actions.h"
 	
@@ -171,7 +174,6 @@
 void critical (str msg);
 QIcon makeColorIcon (LDColor* colinfo, const ushort size);
 void makeColorSelector (QComboBox* box);
-QDialogButtonBox* makeButtonBox (QDialog& dlg);
 CheckBoxGroup* makeAxesBox();
 QImage imageFromScreencap (uchar* data, ushort w, ushort h);
 

mercurial