r17663 by craig - #10820: Apply patch to show key information in warning. Also add in translation of keys and platform specific names
scribus-commit
scribus-commit at lists.scribus.net
Sun Jul 1 19:47:58 UTC 2012
Author: craig
Date: Sun Jul 1 19:47:58 2012
New Revision: 17663
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17663
Log:
#10820: Apply patch to show key information in warning. Also add in translation of keys and platform specific names
Modified:
trunk/Scribus/scribus/commonstrings.cpp
trunk/Scribus/scribus/commonstrings.h
trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.h
Modified: trunk/Scribus/scribus/commonstrings.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17663&path=/trunk/Scribus/scribus/commonstrings.cpp
==============================================================================
--- trunk/Scribus/scribus/commonstrings.cpp (original)
+++ trunk/Scribus/scribus/commonstrings.cpp Sun Jul 1 19:47:58 2012
@@ -181,6 +181,11 @@
QString CommonStrings::strP = "";
QString CommonStrings::strCM = "";
QString CommonStrings::strC = "";
+
+QString CommonStrings::controlModifier = "";
+QString CommonStrings::altModifier = "";
+QString CommonStrings::shiftModifier = "";
+QString CommonStrings::metaModifier = "";
CommonStrings::CommonStrings()
{
@@ -432,6 +437,23 @@
CommonStrings::strP =unitGetUntranslatedStrFromIndex(SC_P);
CommonStrings::strCM=unitGetUntranslatedStrFromIndex(SC_CM);
CommonStrings::strC =unitGetUntranslatedStrFromIndex(SC_C);
+
+ //Keyboard Modifiers
+ CommonStrings::altModifier=tr("Alt");
+ CommonStrings::shiftModifier=tr("Shift");
+
+#ifdef Q_OS_MAC
+ CommonStrings::controlModifier=tr("Cmd");
+ CommonStrings::metaModifier=tr("Ctrl");
+#endif
+#ifdef Q_OS_WIN32
+ CommonStrings::metaModifier=tr("Windows");
+#endif
+#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
+ CommonStrings::controlModifier=tr("Ctrl");
+ CommonStrings::metaModifier=tr("Meta");
+#endif
+
}
const QString & CommonStrings::translatePenStyleName( Qt::PenStyle ps )
Modified: trunk/Scribus/scribus/commonstrings.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17663&path=/trunk/Scribus/scribus/commonstrings.h
==============================================================================
--- trunk/Scribus/scribus/commonstrings.h (original)
+++ trunk/Scribus/scribus/commonstrings.h Sun Jul 1 19:47:58 2012
@@ -271,6 +271,12 @@
static QString strP;
static QString strCM;
static QString strC;
+
+ //Keyboard Modifiers
+ static QString controlModifier;
+ static QString altModifier;
+ static QString shiftModifier;
+ static QString metaModifier;
};
#endif
Modified: trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17663&path=/trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp (original)
+++ trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp Sun Jul 1 19:47:58 2012
@@ -296,13 +296,13 @@
// we prefer plain English
QString res;
if ((KeyC & Qt::META) != 0)
- res += "Meta+";
+ res += CommonStrings::metaModifier + "+";
if ((KeyC & Qt::CTRL) != 0)
- res += "Ctrl+";
+ res += CommonStrings::controlModifier + "+";
if ((KeyC & Qt::ALT) != 0)
- res += "Alt+";
+ res += CommonStrings::altModifier + "+";
if ((KeyC & Qt::SHIFT) != 0)
- res += "Shift+";
+ res += CommonStrings::shiftModifier + "+";
return res + QString(QKeySequence(KeyC & ~(Qt::META | Qt::CTRL | Qt::ALT | Qt::SHIFT)));
}
@@ -472,26 +472,30 @@
if (tl.count() > 0)
{
Part4 = tl.last();
- if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
+ if (Part4 == CommonStrings::altModifier ||
+ Part4 == CommonStrings::ctrlModifier ||
+ Part4 == CommonStrings::shiftModifier ||
+ Part4 == CommonStrings::metaModifier
+ )
Part4 = "";
}
}
switch (k->key())
{
case Qt::Key_Meta:
- Part0 = tr("Meta+");
+ Part0 = CommonStrings::metaModifier+"+";
keyCode |= Qt::META;
break;
case Qt::Key_Shift:
- Part3 = tr("Shift+");
+ Part3 = CommonStrings::shiftModifier+"+";
keyCode |= Qt::SHIFT;
break;
case Qt::Key_Alt:
- Part2 = tr("Alt+");
+ Part2 = CommonStrings::altModifier+"+";
keyCode |= Qt::ALT;
break;
case Qt::Key_Control:
- Part1 = tr("Ctrl+");
+ Part1 = CommonStrings::controlModifier+"+";
keyCode |= Qt::CTRL;
break;
default:
@@ -501,7 +505,9 @@
if (checkKey(keyCode))
{
QMessageBox::information(this, CommonStrings::trWarning,
- tr("This key sequence is already in use"),
+ tr("The %1 key sequence is already in use by \"%2\"")
+ .arg(getKeyText(keyCode))
+ .arg(getAction(keyCode)),
CommonStrings::tr_OK);
selectedLVI->setText(1,keyMap[lviToActionMap[selectedLVI]].keySequence);
keyDisplay->setText(keyMap[lviToActionMap[selectedLVI]].keySequence);
@@ -532,7 +538,11 @@
if (tl.count() > 0)
{
Part4 = tl.last();
- if (Part4 == tr("Alt") || Part4 == tr("Ctrl") || Part4 == tr("Shift") || Part4 == tr("Meta"))
+ if (Part4 == CommonStrings::altModifier ||
+ Part4 == CommonStrings::ctrlModifier ||
+ Part4 == CommonStrings::shiftModifier ||
+ Part4 == CommonStrings::metaModifier
+ )
Part4 = "";
}
}
@@ -558,6 +568,21 @@
}
keyDisplay->setText(Part0+Part1+Part2+Part3+Part4);
}
+}
+
+QString Prefs_KeyboardShortcuts::getAction(int code)
+{
+ QString ret = "";
+ QKeySequence key = QKeySequence(code);
+ for (QMap<QString,Keys>::Iterator it=keyMap.begin(); it!=keyMap.end(); ++it)
+ {
+ if (key.matches(it.value().keySequence) != QKeySequence::NoMatch)
+ {
+ ret = it->cleanMenuText;
+ break;
+ }
+ }
+ return ret;
}
bool Prefs_KeyboardShortcuts::checkKey(int code)
Modified: trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17663&path=/trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.h
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.h (original)
+++ trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.h Sun Jul 1 19:47:58 2012
@@ -59,7 +59,8 @@
void importKeySet(QString);
bool exportKeySet(QString);
QStringList scanForSets();
- bool checkKey(int Code);
+ bool checkKey(int code);
+ QString getAction(int code);
protected slots:
void setKeyText();
More information about the scribus-commit
mailing list