r19304 by craig - Add in utility function for comparing QKeyEvent keys to ScrAction shortcuts. Another fix for #12254

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 1 19:12:50 UTC 2014


Author: craig
Date: Tue Jul  1 19:12:50 2014
New Revision: 19304

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19304
Log:
Add in utility function for comparing QKeyEvent keys to ScrAction shortcuts. Another fix for #12254

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/actionmanager.h
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Tue Jul  1 19:12:50 2014
@@ -76,6 +76,20 @@
 	createDefaultNonMenuActions();
 	languageChange();
 	setActionTooltips(scrActions);
+}
+
+bool ActionManager::compareKeySeqToShortcut(QKeySequence ks, QString actionName)
+{
+	if (!scrActions->contains(actionName))
+		return false;
+	if (ks.matches((*scrActions)[actionName]->shortcut())==QKeySequence::ExactMatch)
+		return true;
+	return false;
+}
+
+bool ActionManager::compareKeySeqToShortcut(int k, Qt::KeyboardModifiers km, QString actionName)
+{
+	return compareKeySeqToShortcut(QKeySequence(k | km), actionName);
 }
 
 void ActionManager::createActions()

Modified: trunk/Scribus/scribus/actionmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/actionmanager.h
==============================================================================
--- trunk/Scribus/scribus/actionmanager.h (original)
+++ trunk/Scribus/scribus/actionmanager.h Tue Jul  1 19:12:50 2014
@@ -58,6 +58,8 @@
 		virtual void changeEvent(QEvent *e);
 		
 		void init(ScribusMainWindow *);
+		bool compareKeySeqToShortcut(QKeySequence ks, QString actionName);
+		bool compareKeySeqToShortcut(int k, Qt::KeyboardModifiers km, QString actionName);
 		static void createDefaultShortcuts();
 		static QMap<QString, QKeySequence>* defaultShortcuts() {return &defKeys;};
 		static void createDefaultMenus();

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Tue Jul  1 19:12:50 2014
@@ -16,6 +16,7 @@
 
 #include "canvasmode.h"
 
+#include "actionmanager.h"
 #include "appmodes.h"
 #include "canvas.h"
 #include "canvasgesture_pan.h"
@@ -1192,8 +1193,7 @@
 	if ((!m_view->m_ScMW->zoomSpinBox->hasFocus()) && (!m_view->m_ScMW->pageSelector->hasFocus()))
 	{
 		//Show our context menu
-		QKeySequence currKeySeq = QKeySequence(kk | keyMod);
-		if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
+		if (m_view->m_ScMW->actionManager->compareKeySeqToShortcut(kk, e->modifiers(), "viewShowContextMenu"))
 		{
 			ContextMenu* cmen=NULL;
 			m_view->setCursor(QCursor(Qt::ArrowCursor));
@@ -1395,8 +1395,7 @@
 						m_doc->itemSelection_DeleteItem();
 					else
 					{
-						QKeySequence currKeySeq = QKeySequence(kk | buttonModifiers);
-						if (currKeySeq.matches(scrActions["editClearContents"]->shortcut())==QKeySequence::ExactMatch)
+						if (m_view->m_ScMW->actionManager->compareKeySeqToShortcut(kk, buttonModifiers, "editClearContents"))
 							scrActions["editClearContents"]->trigger();
 					}
 				break;

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Tue Jul  1 19:12:50 2014
@@ -4127,10 +4127,11 @@
 	if (k->modifiers() & Qt::AltModifier)
 		keyModifiers |= Qt::ALT;
 
+	ScribusView* view = m_Doc->view();
+
 	//<< ISO 14755
 	//Check if we are trying to enter Unicode sequence mode first
-	QKeySequence currKeySeq = QKeySequence(k->key() | keyModifiers);
-	if (currKeySeq.matches(doc()->scMW()->scrActions["specialUnicodeSequenceBegin"]->shortcut())==QKeySequence::ExactMatch)
+	if (view->m_ScMW->actionManager->compareKeySeqToShortcut(k->key(), buttonModifiers, "specialUnicodeSequenceBegin"))
 	{
 		unicodeTextEditMode = true;
 		unicodeInputCount = 0;
@@ -4140,7 +4141,7 @@
 	}
 	//>>
 
-	ScribusView* view = m_Doc->view();
+
 	switch (kk)
 	{
 	case Qt::Key_PageDown:

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Jul  1 19:12:50 2014
@@ -1270,7 +1270,7 @@
 	statusBar()->addPermanentWidget(zoomOutToolbarButton,1);
 	statusBar()->addPermanentWidget(zoomDefaultToolbarButton,1);
 	statusBar()->addPermanentWidget(zoomInToolbarButton,1);
-	statusBar()->addPermanentWidget(pageSelector,1);
+	statusBar()->addPermanentWidget(pageSelector,2);
 	statusBar()->addPermanentWidget(layerMenu,1);
 	statusBar()->addPermanentWidget(s2,2);
 	statusBar()->addPermanentWidget(mainWindowXPosLabel, 0);
@@ -1492,10 +1492,10 @@
 			return false;
 		retVal=true;
 		//Palette actions
-		if (currKeySeq == scrActions["specialToggleAllPalettes"]->shortcut())
+		if (actionManager->compareKeySeqToShortcut(currKeySeq, "specialToggleAllPalettes"))
 			scrActions["specialToggleAllPalettes"]->activate(QAction::Trigger);
 		else
-		if (currKeySeq == scrActions["specialToggleAllGuides"]->shortcut())
+		if (actionManager->compareKeySeqToShortcut(currKeySeq, "specialToggleAllGuides"))
 			scrActions["specialToggleAllGuides"]->activate(QAction::Trigger);
 		else
 			retVal=false;
@@ -1626,8 +1626,7 @@
 	if ((HaveDoc) && (!zoomSpinBox->hasFocus()) && (!pageSelector->hasFocus()))
 	{
 		//Show our context menu
-		QKeySequence currKeySeq = QKeySequence(kk | keyMod);
-		if (currKeySeq.matches(scrActions["viewShowContextMenu"]->shortcut()) == QKeySequence::ExactMatch)
+		if (actionManager->compareKeySeqToShortcut(kk, buttonModifiers, "viewShowContextMenu"))
 		{
 			ContextMenu* cmen=NULL;
 			if (doc->m_Selection->isEmpty())

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19304&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp (original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp Tue Jul  1 19:12:50 2014
@@ -339,9 +339,7 @@
 	if (k->modifiers() & Qt::AltModifier)
 		keyMod |= Qt::ALT;
 
-	QKeySequence currKeySeq = QKeySequence(k->key() | keyMod);
-	QKeySequence uniKeySeq  = doc->scMW()->scrActions["specialUnicodeSequenceBegin"]->shortcut();
-	if(currKeySeq.matches(uniKeySeq)==QKeySequence::ExactMatch)
+	if(ScCore->primaryMainWindow()->actionManager->compareKeySeqToShortcut(k->key(), k->modifiers(), "specialUnicodeSequenceBegin"))
 	{
 		unicodeTextEditMode = true;
 		unicodeInputCount = 0;




More information about the scribus-commit mailing list