r19388 by jghali - #12546: Undo button might be disabled closing Nodes window

scribus-commit scribus-commit at lists.scribus.net
Wed Jul 30 21:25:41 UTC 2014


Author: jghali
Date: Wed Jul 30 21:25:41 2014
New Revision: 19388

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19388
Log:
#12546: Undo button might be disabled closing Nodes window

Modified:
    trunk/Scribus/scribus/appmodehelper.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/nodeeditpalette.cpp
    trunk/Scribus/scribus/ui/nodeeditpalette.h

Modified: trunk/Scribus/scribus/appmodehelper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19388&path=/trunk/Scribus/scribus/appmodehelper.cpp
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.cpp (original)
+++ trunk/Scribus/scribus/appmodehelper.cpp Wed Jul 30 21:25:41 2014
@@ -17,6 +17,7 @@
 #include "appmodehelper.h"
 #include "scribusdoc.h"
 #include "scribuscore.h"
+#include "undomanager.h"
 
 AppModeHelper::AppModeHelper(QObject *parent) :
     QObject(parent)
@@ -34,6 +35,21 @@
 void AppModeHelper::setFrameEditMode(bool b)
 {
 	bool b2=!b;
+
+	(*scrActions)["itemShapeEdit"]->setChecked(b);
+
+	//CB Enable/Disable undo in frame edit mode
+	if (b2)
+	{
+		(*scrActions)["editUndoAction"]->setEnabled(UndoManager::instance()->hasUndoActions());
+		(*scrActions)["editRedoAction"]->setEnabled(UndoManager::instance()->hasRedoActions());
+	}
+	else
+	{
+		(*scrActions)["editUndoAction"]->setEnabled(false);
+		(*scrActions)["editRedoAction"]->setEnabled(false);
+	}
+
 	(*scrActions)["insertFrame"]->setEnabled(b2);
 	(*scrActions)["toolsSelect"]->setEnabled(b2);
 	(*scrActions)["toolsRotate"]->setEnabled(b2);

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19388&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed Jul 30 21:25:41 2014
@@ -6243,70 +6243,65 @@
 {
 	if (!doc)
 		return;
+
 	if (doc->appMode == modeEditClip)
+	{
 		NoFrameEdit();
-	else
-	{
-		//CB Enable/Disable undo in frame edit mode
-// 		undoManager->setUndoEnabled(false);
-		scrActions["editUndoAction"]->setEnabled(false);
-		scrActions["editRedoAction"]->setEnabled(false);
-//done elsewhere now		slotSelect();
-		nodePalette->setDoc(doc, view);
-		nodePalette->MoveN();
-		nodePalette->HaveNode(false, false);
-		nodePalette->MoveNode->setChecked(true);
-		nodePalette->show();
-//		qDebug() << "nodepalette show:" << nodePalette->geometry();
-		connect(view, SIGNAL(HavePoint(bool, bool)), nodePalette, SLOT(HaveNode(bool, bool)));
-		connect(view, SIGNAL(PolyStatus(int, uint)), nodePalette, SLOT(PolyStatus(int, uint)));
-		doc->nodeEdit.reset();
-//done elsewhere now		doc->appMode = modeEditClip;
-		appModeHelper.setFrameEditMode(true);
-		layerPalette->setEnabled(false);
-		outlinePalette->setEnabled(false);
-		guidePalette->setEnabled(false);
-		scrapbookPalette->setEnabled(false);
-		pagePalette->setEnabled(false);
-		bookmarkPalette->setEnabled(false);
-		docCheckerPalette->setEnabled(false);
-		inlinePalette->setEnabled(false);
-		symbolPalette->setEnabled(false);
-		styleManager->setEnabled(false);
-		alignDistributePalette->setEnabled(false);
-		pageSelector->setEnabled(false);
-		layerMenu->setEnabled(false);
-		if (!doc->m_Selection->isEmpty())
-		{
-			PageItem *currItem = doc->m_Selection->itemAt(0);
+		return;
+	}
+
+	nodePalette->setDoc(doc, view);
+	nodePalette->MoveN();
+	nodePalette->HaveNode(false, false);
+	nodePalette->MoveNode->setChecked(true);
+	nodePalette->show();
+//	qDebug() << "nodepalette show:" << nodePalette->geometry();
+	connect(view, SIGNAL(HavePoint(bool, bool)), nodePalette, SLOT(HaveNode(bool, bool)));
+	connect(view, SIGNAL(PolyStatus(int, uint)), nodePalette, SLOT(PolyStatus(int, uint)));
+	doc->nodeEdit.reset();
+	appModeHelper.setFrameEditMode(true);
+	layerPalette->setEnabled(false);
+	outlinePalette->setEnabled(false);
+	guidePalette->setEnabled(false);
+	scrapbookPalette->setEnabled(false);
+	pagePalette->setEnabled(false);
+	bookmarkPalette->setEnabled(false);
+	docCheckerPalette->setEnabled(false);
+	inlinePalette->setEnabled(false);
+	symbolPalette->setEnabled(false);
+	styleManager->setEnabled(false);
+	alignDistributePalette->setEnabled(false);
+	pageSelector->setEnabled(false);
+	layerMenu->setEnabled(false);
+	if (!doc->m_Selection->isEmpty())
+	{
+		PageItem *currItem = doc->m_Selection->itemAt(0);
 //			view->MarkClip(currItem, currItem->PoLine, true);
-			nodePalette->EditCont->setEnabled(currItem->ContourLine.size() != 0);
-			nodePalette->ResetCont->setEnabled(false);
-			nodePalette->ResetContClip->setEnabled(false);
-			nodePalette->PolyStatus(currItem->itemType(), currItem->PoLine.size());
-			nodePalette->setDefaults(currItem);
-			if ((currItem->asImageFrame()) && (currItem->imageClip.size() != 0))
-			{
-				nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
-				nodePalette->ResetContClip->show();
-				nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
-				nodePalette->ResetShape2Clip->show();
-				nodePalette->layout()->activate();
-				nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
-			}
-			else
-			{
-				nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
-				nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
-				nodePalette->layout()->activate();
-				nodePalette->ResetContClip->hide();
-				nodePalette->ResetShape2Clip->hide();
-				nodePalette->layout()->activate();
-				nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
-			}
-		}
-	}
-	scrActions["itemShapeEdit"]->setChecked(doc->appMode == modeEditClip);
+		nodePalette->EditCont->setEnabled(currItem->ContourLine.size() != 0);
+		nodePalette->ResetCont->setEnabled(false);
+		nodePalette->ResetContClip->setEnabled(false);
+		nodePalette->PolyStatus(currItem->itemType(), currItem->PoLine.size());
+		nodePalette->setDefaults(currItem);
+		if ((currItem->asImageFrame()) && (currItem->imageClip.size() != 0))
+		{
+			nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
+			nodePalette->ResetContClip->show();
+			nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(3), static_cast<QSizePolicy::Policy>(3)));
+			nodePalette->ResetShape2Clip->show();
+			nodePalette->layout()->activate();
+			nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
+		}
+		else
+		{
+			nodePalette->ResetContClip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
+			nodePalette->ResetShape2Clip->setSizePolicy(QSizePolicy(static_cast<QSizePolicy::Policy>(6), static_cast<QSizePolicy::Policy>(6)));
+			nodePalette->layout()->activate();
+			nodePalette->ResetContClip->hide();
+			nodePalette->ResetShape2Clip->hide();
+			nodePalette->layout()->activate();
+			nodePalette->resize(QSize(170, 380).expandedTo(nodePalette->minimumSizeHint()));
+		}
+	}
 }
 
 void ScribusMainWindow::NoFrameEdit()
@@ -6320,7 +6315,6 @@
 	scrActions["toolsSelect"]->setChecked(true);
 	scrActions["toolsEditContents"]->setChecked(false);
 	scrActions["toolsEditWithStoryEditor"]->setChecked(false);
-	scrActions["itemShapeEdit"]->setChecked(false);
 	layerPalette->setEnabled(true);
 	outlinePalette->setEnabled(true);
 	guidePalette->setEnabled(true);
@@ -6334,10 +6328,8 @@
 	inlinePalette->setEnabled(true);
 	pageSelector->setEnabled(true);
 	layerMenu->setEnabled(true);
-// 	bool tmpClip = doc->EditClip; // for enabling undo if exiting shape edit mode
 	if (HaveDoc)
 	{
-// done elsewhere now:		doc->appMode = modeNormal;
 		doc->nodeEdit.reset();
 		HaveNewSel();
 		if (!doc->m_Selection->isEmpty())
@@ -6347,8 +6339,6 @@
 		}
 	}
 	actionManager->connectModeActions();
-// 	if (tmpClip)
-// 		undoManager->setUndoEnabled(true);
 }
 
 /** This is the safest method to return to modeNormal

Modified: trunk/Scribus/scribus/ui/nodeeditpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19388&path=/trunk/Scribus/scribus/ui/nodeeditpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/nodeeditpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/nodeeditpalette.cpp Wed Jul 30 21:25:41 2014
@@ -973,6 +973,12 @@
 	}
 	else
 		QWidget::changeEvent(e);
+}
+
+void NodePalette::reject()
+{
+	EndEdit();
+	ScrPaletteBase::reject();
 }
 
 void NodePalette::setDefaults(PageItem* currItem)

Modified: trunk/Scribus/scribus/ui/nodeeditpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19388&path=/trunk/Scribus/scribus/ui/nodeeditpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/nodeeditpalette.h (original)
+++ trunk/Scribus/scribus/ui/nodeeditpalette.h Wed Jul 30 21:25:41 2014
@@ -38,8 +38,6 @@
 	NodePalette( QWidget* parent);
 	~NodePalette() {};
 	void setDefaults(PageItem* currItem);
-	
-	virtual void changeEvent(QEvent *e);
 
 	QToolButton* MoveNode;
 	QToolButton* MoveControl;
@@ -84,7 +82,6 @@
 	ScribusDoc* currentDocument() const;
 
 private slots:
-	void closeEvent(QCloseEvent *);
 	void MoveK();
 	void AddN();
 	void DelN();
@@ -125,9 +122,16 @@
 	void CancelEdit();
 	void ResetToEditDefaults();
 
+protected slots:
+	virtual void reject();
+
 protected:
 	void connectSignals();
 	void disconnectSignals();
+
+	virtual void changeEvent(QEvent *e);
+	virtual void closeEvent(QCloseEvent *);
+
 	QVBoxLayout *vboxLayout;
 	QVBoxLayout *vboxLayout1;
 	QGridLayout *gridLayout;




More information about the scribus-commit mailing list