[qet] [3541] Save icon is disable when undo stack is empty

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3541
Author:   blacksun
Date:     2014-12-10 18:00:08 +0100 (Wed, 10 Dec 2014)
Log Message:
-----------
Save icon is disable when undo stack is empty

Modified Paths:
--------------
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2014-12-08 20:18:30 UTC (rev 3540)
+++ trunk/sources/qetdiagrameditor.cpp	2014-12-10 17:00:08 UTC (rev 3541)
@@ -95,9 +95,10 @@
 	setWindowState(Qt::WindowMaximized);
 	
 	// connexions signaux / slots pour une interface sensee
-	connect(&workspace,                SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateWindowsMenu()));
-	connect(&workspace,                SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateUndoStack()));
-	connect(QApplication::clipboard(), SIGNAL(dataChanged()),              this, SLOT(slot_updatePasteAction()));
+	connect (&workspace,                SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateWindowsMenu()));
+	connect (&workspace,                SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(slot_updateUndoStack()));
+	connect (QApplication::clipboard(), SIGNAL(dataChanged()),                       this, SLOT(slot_updatePasteAction()));
+	connect (&undo_group,               SIGNAL(cleanChanged(bool)),                  this, SLOT(activeUndoStackCleanChanged(bool)));
 	
 	// lecture des parametres
 	readSettings();
@@ -630,6 +631,7 @@
 	if (ProjectView *project_view = currentProject()) {
 		QETResult saved = project_view -> save();
 		if (saved.isOk()) {
+			save_file->setDisabled(true);
 			QETApp::projectsRecentFiles() -> fileWasOpened(project_view -> project() -> filePath());
 			//fake progressbar
 			progressBar = new QProgressBar;
@@ -1176,7 +1178,7 @@
 	
 	// actions ayant juste besoin d'un document ouvert
 	close_file        -> setEnabled(opened_project);
-	save_file         -> setEnabled(editable_project);
+	save_file         -> setEnabled(editable_project && undo_group.activeStack()->count());
 	save_file_as      -> setEnabled(opened_project);
 	prj_edit_prop     -> setEnabled(opened_project);
 	prj_add_diagram   -> setEnabled(editable_project);
@@ -1210,6 +1212,7 @@
 		undo_group.setActiveStack(pv->project()->undoStack());
 		undo      -> setEnabled (undo_group.canUndo());
 		redo      -> setEnabled (undo_group.canRedo());
+		save_file -> setEnabled (undo_group.activeStack()->count() && !pv -> project() -> isReadOnly());
 	}
 }
 
@@ -1979,3 +1982,15 @@
 void QETDiagramEditor::addItemFinish() {
 	m_add_item_actions_group.checkedAction()->setChecked(false);
 }
+
+/**
+ * @brief QETDiagramEditor::activeUndoStackCleanChanged
+ * Enable the QAction save_file when @clean is set to false
+ * @clean at true do nothing;
+ * @param clean
+ */
+void QETDiagramEditor::activeUndoStackCleanChanged(bool clean) {
+	if (!clean) {
+		save_file -> setEnabled(true);
+	}
+}

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2014-12-08 20:18:30 UTC (rev 3540)
+++ trunk/sources/qetdiagrameditor.h	2014-12-10 17:00:08 UTC (rev 3541)
@@ -156,6 +156,9 @@
 	void showError(const QETResult &);
 	void showError(const QString &);
 	void addItemFinish();
+
+	private slots:
+	void activeUndoStackCleanChanged (bool clean);
 	
 	// attributes
 	public:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/