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);
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);
}
}
}
#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"
*
*/
+#include "config-host.h"
+
#include "xmllayoutparser.h"
#include "xmllayoutkeyword.h"
#include "skinpainter.h"
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();
}
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<QString, QKeySequence> &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();
}
int parseFactorList(QXmlStreamReader &xml,
const int depth, QMap<int, QString> &map, int *defaultFactor);
+ QKeySequence parseShortcut(QXmlStreamReader &xml, const int depth);
int parseShortcuts(QXmlStreamReader &xml,
const int depth, QMap<QString, QKeySequence> &map);
AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml, const int depth);