From: GiWoong Kim Date: Tue, 15 Dec 2015 11:01:07 +0000 (+0900) Subject: shortcut: make default shortcut keys with "Control key" on MacOS X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~131 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=957b11ee3720a0161ad5e79abe2382f154be78ac;p=sdk%2Femulator%2Fqemu.git shortcut: make default shortcut keys with "Control key" on MacOS QKeySequence Note - On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control and Qt::ControlModifier correspond to the Command keys on the Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and Qt::MetaModifier correspond to the Control keys. Developers on Mac OS X can use the same shortcut descriptions across all platforms, and their applications will automatically work as expected on Mac OS X. According to Qt note, "Ctrl" will be treated as command key. This is not what we want. To be recognized as control key on MacOS, XML Parser should replace "Ctrl" with "Meta" text. Change-Id: Id26972ba7236df1b33d7d2409fcf58115ebf163c Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 41d57bb810..19ec13de0f 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -277,7 +277,7 @@ void DetailedInfoDialog::insertMenuShortcutInfo(QList &list) QString keySequence = iter.value().toString(); #ifdef CONFIG_DARWIN - keySequence.replace("Ctrl", "Cmd"); + keySequence.replace(XML_QT_METAKEY_STRING, XML_QT_CTRLKEY_STRING); #endif insertTableRow(menuShortcutTable, function, keySequence); @@ -296,8 +296,13 @@ void DetailedInfoDialog::insertHwKeyShortcutInfo( hwKey = list.at(i); if (hwKey && hwKey->getKeySequence().isEmpty() == false && hwKey->getName().isEmpty() == false) { - insertTableRow(keyShortcutTable, - hwKey->getName() + source, hwKey->getKeySequence().toString()); + + QString keySequence = hwKey->getKeySequence().toString(); +#ifdef CONFIG_DARWIN + keySequence.replace(XML_QT_METAKEY_STRING, XML_QT_CTRLKEY_STRING); +#endif + + insertTableRow(keyShortcutTable, hwKey->getName() + source, keySequence); } } } diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index fde5c69fce..691bd13e6c 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -131,6 +131,10 @@ #define STYLE_TOOLTIP "QToolTip {"\ "color: black; background-color: white; border: 1px solid black; }" +/* ETC */ +#define XML_QT_CTRLKEY_STRING "Ctrl" +#define XML_QT_METAKEY_STRING "Meta" + /* messages */ #define MSG_SDB_NOT_READY "SDB is not ready.\nPlease wait until the emulator is completely boot up." #define MSG_SDB_NOT_EXIST "SDB file does not exist in the following path.\n" diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index bceb6414cc..224b9fba1a 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -28,6 +28,8 @@ * */ +#include "config-host.h" + #include "xmllayoutparser.h" #include "xmllayoutkeyword.h" #include "skinpainter.h" @@ -242,7 +244,7 @@ HardwareKey *XmlLayoutParser::parseKey(QXmlStreamReader &xml, const int depth) keyTooptip = xml.readElementText(); } else if (xml.name() == SHORTCUT_KEYWORD) { /* shortcut */ - keySequence = QKeySequence::fromString(xml.readElementText()); + keySequence = parseShortcut(xml, depth + 1); } else { QWARN_INDENT(depth + 1) << "undefined element: " << xml.name(); } @@ -421,11 +423,33 @@ int XmlLayoutParser::parseFactorList(QXmlStreamReader &xml, return map.count(); } +QKeySequence XmlLayoutParser::parseShortcut(QXmlStreamReader &xml, const int depth) +{ + QString keyString = xml.readElementText(); + +#ifdef CONFIG_DARWIN + /* QKeySequence Note: On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control and + * Qt::ControlModifier correspond to the Command keys on the Macintosh keyboard, + * and references to "Meta", Qt::META, Qt::Meta and Qt::MetaModifier correspond to + * the Control keys. Developers on Mac OS X can use the same shortcut descriptions + * across all platforms, and their applications will automatically work as expected + * on Mac OS X. */ + + /* According to Qt note, "Ctrl" will be treated as command key. This is not what we + * want. To be recognized as control key on MacOS, XML Parser should replace "Ctrl" + * with "Meta" text. */ + + keyString.replace(XML_QT_CTRLKEY_STRING, XML_QT_METAKEY_STRING); +#endif + + return QKeySequence::fromString(keyString); +} + int XmlLayoutParser::parseShortcuts(QXmlStreamReader &xml, const int depth, QMap &map) { QString key = xml.attributes().value(PROP_ATTR_KEYWORD).toString(); - map.insert(key, QKeySequence::fromString(xml.readElementText())); + map.insert(key, parseShortcut(xml, depth + 1)); return map.count(); } diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h index e6bcf80b94..6ad579ae49 100644 --- a/tizen/src/ui/xmllayoutparser.h +++ b/tizen/src/ui/xmllayoutparser.h @@ -66,6 +66,7 @@ private: int parseFactorList(QXmlStreamReader &xml, const int depth, QMap &map, int *defaultFactor); + QKeySequence parseShortcut(QXmlStreamReader &xml, const int depth); int parseShortcuts(QXmlStreamReader &xml, const int depth, QMap &map); AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml, const int depth);