r14124 by cbradney - #7798: Better fix that detects the unicode output from the keypress

scribus-commit scribus-commit at lists.scribus.net
Thu Oct 8 23:45:16 CEST 2009


Revision: 14124
Author: cbradney
Date: 2009-10-08T21:10:30.484233Z
Commit message: #7798: Better fix that detects the unicode output from the keypress

Changeset: 
M  /trunk/Scribus/scribus/pageitem_textframe.cpp
M  /trunk/Scribus/scribus/pageitem_textframe.h

Diffs:
Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(revision 14123)
+++ scribus/pageitem_textframe.cpp	(revision 14124)
@@ -3155,10 +3155,20 @@
 		break;
 	default:
 		bool doUpdate = false;
-		if ((itemText.lengthOfSelection() > 0) && (kk < 0x1000 && keyModifiers==0))
+		if (itemText.lengthOfSelection() > 0) //(kk < 0x1000)
 		{
-			deleteSelectedTextFromFrame();
-			doUpdate = true;
+			if (!k->text().isEmpty())
+			{
+				deleteSelectedTextFromFrame();
+				doUpdate = true;
+			}
+			/*
+			qDebug()<<"Text:"<<k->text();
+			qDebug()<<"Modifiers:"<<k->modifiers();
+			qDebug()<<"Native Modifiers:"<<k->nativeModifiers();
+			qDebug()<<"Native Scan Code:"<<k->nativeScanCode();
+			qDebug()<<"Native Virtual Key:"<<k->nativeVirtualKey();
+			*/
 		}
 		//if ((kk == Qt::Key_Tab) || ((kk == Qt::Key_Return) && (buttonState & Qt::ShiftButton)))
 		if (kk == Qt::Key_Tab)
@@ -3283,8 +3293,34 @@
 	cursorBiasBackward = (dir < 0);
 }
 
+bool PageItem_TextFrame::checkKeyIsShortcut(QKeyEvent *k)
+{
+	QMap<QString, Keys> keyMap=PrefsManager::instance()->appPrefs.keyShortcutPrefs.KeyActions;
 
+	bool ret = false;
+	int keyCode =0;
+	if (k->modifiers() & Qt::ShiftModifier)
+		keyCode |= Qt::SHIFT;
+	if (k->modifiers() & Qt::ControlModifier)
+		keyCode |= Qt::CTRL;
+	if (k->modifiers() & Qt::AltModifier)
+		keyCode |= Qt::ALT;
+	keyCode|=k->key();
 
+	QKeySequence key = QKeySequence(keyCode);
+	for (QMap<QString,Keys>::Iterator it=keyMap.begin(); it!=keyMap.end(); ++it)
+	{
+		if (key.matches(it.value().keySequence) != QKeySequence::NoMatch)
+		{
+			ret = true;
+			break;
+		}
+	}
+	return ret;
+
+}
+
+
 // jjsa added on 15-mar-2004 expand / decrease selection
 
 // jjsa added on 14-mar-2004 text selection with pressed
Index: scribus/pageitem_textframe.h
===================================================================
--- scribus/pageitem_textframe.h	(revision 14123)
+++ scribus/pageitem_textframe.h	(revision 14124)
@@ -103,6 +103,7 @@
 	void setShadow();
 	QString currentShadow;
 	QMap<QString,StoryText> shadows;
+	bool checkKeyIsShortcut(QKeyEvent *k);
 	
 private slots:
 	void slotInvalidateLayout();




More information about the scribus-commit mailing list