Changeset 44584 in vbox
- Timestamp:
- Feb 7, 2013 1:33:21 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.cpp
r44559 r44584 85 85 { 86 86 /* Compose shortcut key: */ 87 QString strShortcutKey(m_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(),88 pAction->shortcutExtraDataID()));87 const QString strShortcutKey(m_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(), 88 pAction->shortcutExtraDataID())); 89 89 /* Return existing if any: */ 90 90 if (m_shortcuts.contains(strShortcutKey)) … … 112 112 continue; 113 113 114 /* Compose fullshortcut key: */115 QString strShortcutKey = m_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(),116 pAction->shortcutExtraDataID());114 /* Compose shortcut key: */ 115 const QString strShortcutKey = m_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(), 116 pAction->shortcutExtraDataID()); 117 117 /* If shortcut key is already known: */ 118 118 if (m_shortcuts.contains(strShortcutKey)) … … 120 120 /* Get corresponding shortcut: */ 121 121 UIShortcut &existingShortcut = m_shortcuts[strShortcutKey]; 122 /* Copy the description from the action to the shortcut: */ 123 existingShortcut.setDescription(pAction->name()); 122 124 /* Copy the sequence from the shortcut to the action: */ 123 125 pAction->setShortcut(existingShortcut.sequence()); 124 /* Copy the description from the action to the shortcut if necessary: */125 if (existingShortcut.description().isNull())126 existingShortcut.setDescription(pAction->name());127 126 } 128 127 /* If shortcut key is NOT known yet: */ … … 143 142 { 144 143 /* Clear selector shortcuts first: */ 145 QList<QString> shortcutKeyList = m_shortcuts.keys();144 const QList<QString> shortcutKeyList = m_shortcuts.keys(); 146 145 foreach (const QString &strShortcutKey, shortcutKeyList) 147 146 if (strShortcutKey.startsWith(GUI_Input_SelectorShortcuts)) … … 156 155 { 157 156 /* Clear machine shortcuts first: */ 158 QList<QString> shortcutKeyList = m_shortcuts.keys();157 const QList<QString> shortcutKeyList = m_shortcuts.keys(); 159 158 foreach (const QString &strShortcutKey, shortcutKeyList) 160 159 if (strShortcutKey.startsWith(GUI_Input_MachineShortcuts)) … … 200 199 { 201 200 /* Runtime shortcut key template: */ 202 QString strRuntimeShortcutKeyTemplate(m_strShortcutKeyTemplate.arg(GUI_Input_MachineShortcuts));201 const QString strRuntimeShortcutKeyTemplate(m_strShortcutKeyTemplate.arg(GUI_Input_MachineShortcuts)); 203 202 /* Default shortcut for the Runtime Popup Menu invokation: */ 204 203 m_shortcuts.insert(strRuntimeShortcutKeyTemplate.arg("PopupMenu"), … … 214 213 } 215 214 216 void UIShortcutPool::loadOverridesFor(const QString &strExtraDataID) 217 { 218 /* Shortcut prefix: */ 219 QString strShortcutPrefix(strExtraDataID); 220 /* Shortcut key template: */ 221 QString strShortcutKeyTemplate(m_strShortcutKeyTemplate.arg(strShortcutPrefix)); 222 /* Iterate over all the records: */ 223 parseOverrides(vboxGlobal().virtualBox().GetExtraDataStringList(strShortcutPrefix), strShortcutKeyTemplate); 224 } 225 226 void UIShortcutPool::parseOverrides(const QStringList &overrides, const QString &strTemplate) 227 { 228 /* Iterate over all the selector records: */ 215 void UIShortcutPool::loadOverridesFor(const QString &strPoolExtraDataID) 216 { 217 /* Compose shortcut key template: */ 218 const QString strShortcutKeyTemplate(m_strShortcutKeyTemplate.arg(strPoolExtraDataID)); 219 /* Iterate over all the overrides: */ 220 const QStringList overrides = vboxGlobal().virtualBox().GetExtraDataStringList(strPoolExtraDataID); 229 221 foreach (const QString &strKeyValuePair, overrides) 230 222 { 231 /* Make sure recordstructure is valid: */223 /* Make sure override structure is valid: */ 232 224 int iDelimiterPosition = strKeyValuePair.indexOf('='); 233 225 if (iDelimiterPosition < 0) 234 226 continue; 235 227 236 /* Get shortcut ID/ value: */237 QString strShortcutID = strKeyValuePair.left(iDelimiterPosition);238 QString strShortcutValue = strKeyValuePair.right(strKeyValuePair.length() - iDelimiterPosition - 1);228 /* Get shortcut ID/sequence: */ 229 const QString strShortcutExtraDataID = strKeyValuePair.left(iDelimiterPosition); 230 const QString strShortcutSequence = strKeyValuePair.right(strKeyValuePair.length() - iDelimiterPosition - 1); 239 231 240 232 /* Compose corresponding shortcut key: */ 241 QString strShortcutKey(strTemplate.arg(strShortcutID));233 const QString strShortcutKey(strShortcutKeyTemplate.arg(strShortcutExtraDataID)); 242 234 /* Modify map with composed key/value: */ 243 235 if (!m_shortcuts.contains(strShortcutKey)) 244 m_shortcuts.insert(strShortcutKey, UIShortcut(QString(), strShortcut Value));236 m_shortcuts.insert(strShortcutKey, UIShortcut(QString(), strShortcutSequence)); 245 237 else 246 238 { … … 248 240 UIShortcut &shortcut = m_shortcuts[strShortcutKey]; 249 241 /* Check if corresponding shortcut overriden by value: */ 250 if (shortcut.toString().compare(strShortcut Value, Qt::CaseInsensitive) != 0)242 if (shortcut.toString().compare(strShortcutSequence, Qt::CaseInsensitive) != 0) 251 243 { 252 244 /* Shortcut unassigned? */ 253 if (strShortcut Value.compare("None", Qt::CaseInsensitive) == 0)245 if (strShortcutSequence.compare("None", Qt::CaseInsensitive) == 0) 254 246 shortcut.setSequence(QKeySequence()); 255 247 /* Or reassigned? */ 256 248 else 257 shortcut.setSequence(QKeySequence(strShortcut Value));249 shortcut.setSequence(QKeySequence(strShortcutSequence)); 258 250 } 259 251 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.h
r44559 r44584 107 107 void loadOverrides(); 108 108 void loadOverridesFor(const QString &strExtraDataID); 109 void parseOverrides(const QStringList &overrides, const QString &strTemplate);110 109 111 110 /* Helper: Shortcut stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.