Changeset 82186 in vbox
- Timestamp:
- Nov 25, 2019 5:02:40 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134999
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp
r80479 r82186 150 150 } 151 151 152 void UIAction::setShortcut (const QKeySequence &shortcut)152 void UIAction::setShortcuts(const QList<QKeySequence> &shortcuts) 153 153 { 154 154 /* Only for manager's action-pool: */ 155 155 if (m_enmActionPoolType == UIActionPoolType_Manager) 156 156 { 157 /* If shortcut isvisible: */157 /* If primary shortcut should be visible: */ 158 158 if (!m_fShortcutHidden) 159 159 /* Call to base-class: */ 160 QAction::setShortcut (shortcut);161 /* Remember shortcut : */162 m_shortcut = shortcut;163 } 164 /* Update text according newshortcut: */160 QAction::setShortcuts(shortcuts); 161 /* Remember shortcuts: */ 162 m_shortcuts = shortcuts; 163 } 164 /* Update text according to new primary shortcut: */ 165 165 updateText(); 166 166 } … … 169 169 { 170 170 m_fShortcutHidden = false; 171 if (!m_shortcut .isEmpty())172 QAction::setShortcut (m_shortcut);171 if (!m_shortcuts.isEmpty()) 172 QAction::setShortcuts(m_shortcuts); 173 173 } 174 174 … … 177 177 m_fShortcutHidden = true; 178 178 if (!shortcut().isEmpty()) 179 QAction::setShortcut (QKeySequence());179 QAction::setShortcuts(QList<QKeySequence>()); 180 180 } 181 181 … … 215 215 if (machineMenuAction()) 216 216 setText(uiCommon().insertKeyToActionText(nameInMenu(), 217 gShortcutPool->shortcut(actionPool(), this).toString()));217 gShortcutPool->shortcut(actionPool(), this).primaryToPortableText())); 218 218 else 219 219 setText(nameInMenu()); … … 2578 2578 continue; 2579 2579 /* Get the hot-key of the current action: */ 2580 const QString strHotKey = gShortcutPool->shortcut(this, pAction). toString();2580 const QString strHotKey = gShortcutPool->shortcut(this, pAction).primaryToPortableText(); 2581 2581 if (pAction->isEnabled() && pAction->isAllowed() && !strHotKey.isEmpty()) 2582 2582 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
r80479 r82186 248 248 virtual QKeySequence defaultShortcut(UIActionPoolType) const { return QKeySequence(); } 249 249 250 /** Defines current keyboard shortcut for this action. */251 void setShortcut (const QKeySequence &shortcut);250 /** Defines current keyboard shortcuts for this action. */ 251 void setShortcuts(const QList<QKeySequence> &shortcuts); 252 252 /** Make action show keyboard shortcut. */ 253 253 void showShortcut(); … … 292 292 293 293 /** Holds current action state. */ 294 int m_iState;294 int m_iState; 295 295 /** Holds action icons. */ 296 QVector<QIcon> m_icons;296 QVector<QIcon> m_icons; 297 297 /** Holds the action name. */ 298 QString m_strName;298 QString m_strName; 299 299 /** Holds the action shortcut scope. */ 300 QString m_strShortcutScope;301 /** Holds the action shortcut . */302 Q KeySequence m_shortcut;300 QString m_strShortcutScope; 301 /** Holds the action shortcuts. */ 302 QList<QKeySequence> m_shortcuts; 303 303 /** Holds whether action shortcut hidden. */ 304 bool m_fShortcutHidden;304 bool m_fShortcutHidden; 305 305 }; 306 306 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.cpp
r79365 r82186 51 51 } 52 52 53 void UIShortcut::setSequence (const QKeySequence &sequence)54 { 55 m_sequence = sequence;56 } 57 58 const Q KeySequence &UIShortcut::sequence() const59 { 60 return m_sequence ;53 void UIShortcut::setSequences(const QList<QKeySequence> &sequences) 54 { 55 m_sequences = sequences; 56 } 57 58 const QList<QKeySequence> &UIShortcut::sequences() const 59 { 60 return m_sequences; 61 61 } 62 62 … … 71 71 } 72 72 73 QString UIShortcut::toString() const 74 { 75 return m_sequence.toString(); 73 QString UIShortcut::primaryToNativeText() const 74 { 75 return m_sequences.isEmpty() ? QString() : m_sequences.first().toString(QKeySequence::NativeText); 76 } 77 78 QString UIShortcut::primaryToPortableText() const 79 { 80 return m_sequences.isEmpty() ? QString() : m_sequences.first().toString(QKeySequence::PortableText); 76 81 } 77 82 … … 124 129 newShortcut.setScope(pAction->shortcutScope()); 125 130 newShortcut.setDescription(pAction->name()); 126 newShortcut.setSequence(pAction->defaultShortcut(pActionPool->type())); 127 newShortcut.setDefaultSequence(pAction->defaultShortcut(pActionPool->type())); 131 const QKeySequence &defaultSequence = pAction->defaultShortcut(pActionPool->type()); 132 newShortcut.setSequences(QList<QKeySequence>() << defaultSequence); 133 newShortcut.setDefaultSequence(defaultSequence); 128 134 return newShortcut; 129 135 } … … 144 150 if (!m_shortcuts.contains(strShortcutKey)) 145 151 continue; 146 /* Assign overridden sequence to the shortcut: */147 m_shortcuts[strShortcutKey].setSequence (overrides[strShortcutKey]);152 /* Assign overridden sequences to the shortcut: */ 153 m_shortcuts[strShortcutKey].setSequences(QList<QKeySequence>() << overrides[strShortcutKey]); 148 154 } 149 155 /* Save overrides: */ … … 172 178 /* Copy the description from the action to the shortcut: */ 173 179 existingShortcut.setDescription(pAction->name()); 174 /* Copy the sequence from the shortcut to the action: */175 pAction->setShortcut (existingShortcut.sequence());180 /* Copy the sequences from the shortcut to the action: */ 181 pAction->setShortcuts(existingShortcut.sequences()); 176 182 pAction->retranslateUi(); 177 /* Copy thedefault sequence from the action to the shortcut: */183 /* Copy default sequence from the action to the shortcut: */ 178 184 existingShortcut.setDefaultSequence(pAction->defaultShortcut(pActionPool->type())); 179 185 } … … 183 189 /* Create corresponding shortcut: */ 184 190 UIShortcut &newShortcut = m_shortcuts[strShortcutKey]; 185 /* Copy the action's default to both the shortcut & the action: */ 186 newShortcut.setSequence(pAction->defaultShortcut(pActionPool->type())); 187 newShortcut.setDefaultSequence(pAction->defaultShortcut(pActionPool->type())); 188 pAction->setShortcut(newShortcut.sequence()); 191 /* Copy the action's default sequence to both the shortcut & the action: */ 192 const QKeySequence &defaultSequence = pAction->defaultShortcut(pActionPool->type()); 193 newShortcut.setSequences(QList<QKeySequence>() << defaultSequence); 194 newShortcut.setDefaultSequence(defaultSequence); 195 pAction->setShortcuts(newShortcut.sequences()); 189 196 pAction->retranslateUi(); 190 197 /* Copy the description from the action to the shortcut: */ … … 291 298 UIShortcut(QString(), 292 299 QApplication::translate("UIActionPool", "Popup Menu"), 293 QString("Home"), QString("Home"))); 300 QList<QKeySequence>() << QString("Home"), 301 QString("Home"))); 294 302 } 295 303 } … … 328 336 /* Modify map with composed key/value: */ 329 337 if (!m_shortcuts.contains(strShortcutKey)) 330 m_shortcuts.insert(strShortcutKey, UIShortcut(QString(), QString(), strShortcutSequence, QString())); 338 m_shortcuts.insert(strShortcutKey, 339 UIShortcut(QString(), 340 QString(), 341 QList<QKeySequence>() << strShortcutSequence, 342 QString())); 331 343 else 332 344 { … … 334 346 UIShortcut &shortcut = m_shortcuts[strShortcutKey]; 335 347 /* Check if corresponding shortcut overridden by value: */ 336 if (shortcut. toString().compare(strShortcutSequence, Qt::CaseInsensitive) != 0)348 if (shortcut.primaryToPortableText().compare(strShortcutSequence, Qt::CaseInsensitive) != 0) 337 349 { 338 350 /* Shortcut unassigned? */ 339 351 if (strShortcutSequence.compare("None", Qt::CaseInsensitive) == 0) 340 shortcut.setSequence (QKeySequence());352 shortcut.setSequences(QList<QKeySequence>()); 341 353 /* Or reassigned? */ 342 354 else 343 shortcut.setSequence (QKeySequence(strShortcutSequence));355 shortcut.setSequences(QList<QKeySequence>() << strShortcutSequence); 344 356 } 345 357 } … … 370 382 const UIShortcut &shortcut = m_shortcuts[strShortcutKey]; 371 383 /* Check if the sequence for that shortcut differs from default: */ 372 if (shortcut.sequence () == shortcut.defaultSequence())384 if (shortcut.sequences().contains(shortcut.defaultSequence())) 373 385 continue; 374 386 /* Add the shortcut sequence into overrides list: */ 375 387 overrides << QString("%1=%2").arg(QString(strShortcutKey).remove(strShortcutPrefix), 376 shortcut. sequence().toString());388 shortcut.primaryToPortableText()); 377 389 } 378 390 /* Save overrides into the extra-data: */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.h
r76581 r82186 45 45 : m_strScope(QString()) 46 46 , m_strDescription(QString()) 47 , m_sequence (QKeySequence())47 , m_sequences(QList<QKeySequence>()) 48 48 , m_defaultSequence(QKeySequence()) 49 49 {} 50 50 /** Constructs shortcut descriptor. 51 * @param strScope Brings the shortcut scope.52 * @param strDescription Brings the shortcut description.53 * @param sequence Brings the shortcut sequence.54 * @param defaultSequence Brings the default shortcut sequence. */51 * @param strScope Brings the shortcut scope. 52 * @param strDescription Brings the shortcut description. 53 * @param sequences Brings the shortcut sequences. 54 * @param defaultSequence Brings the default shortcut sequence. */ 55 55 UIShortcut(const QString &strScope, 56 56 const QString &strDescription, 57 const Q KeySequence &sequence,57 const QList<QKeySequence> &sequences, 58 58 const QKeySequence &defaultSequence) 59 59 : m_strScope(strScope) 60 60 , m_strDescription(strDescription) 61 , m_sequence (sequence)61 , m_sequences(sequences) 62 62 , m_defaultSequence(defaultSequence) 63 63 {} … … 73 73 const QString &description() const; 74 74 75 /** Defines the shortcut @a sequence . */76 void setSequence (const QKeySequence &sequence);77 /** Returns the shortcut sequence . */78 const Q KeySequence &sequence() const;75 /** Defines the shortcut @a sequences. */ 76 void setSequences(const QList<QKeySequence> &sequences); 77 /** Returns the shortcut sequences. */ 78 const QList<QKeySequence> &sequences() const; 79 79 80 80 /** Defines the default shortcut @a sequence. */ … … 83 83 const QKeySequence &defaultSequence() const; 84 84 85 /** Converts shortcut sequence to string. */ 86 QString toString() const; 85 /** Converts primary shortcut sequence to native text. */ 86 QString primaryToNativeText() const; 87 /** Converts primary shortcut sequence to portable text. */ 88 QString primaryToPortableText() const; 87 89 88 90 private: 89 91 90 92 /** Holds the shortcut scope. */ 91 QString m_strScope;93 QString m_strScope; 92 94 /** Holds the shortcut description. */ 93 QString m_strDescription;94 /** Holds the shortcut sequence . */95 Q KeySequence m_sequence;95 QString m_strDescription; 96 /** Holds the shortcut sequences. */ 97 QList<QKeySequence> m_sequences; 96 98 /** Holds the default shortcut sequence. */ 97 QKeySequence m_defaultSequence;99 QKeySequence m_defaultSequence; 98 100 }; 99 101 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIKeyboardHandlerFullscreen.cpp
r76606 r82186 54 54 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 55 55 /* Process Host+Home for menu popup: */ 56 if (isHostKeyPressed() && QKeySequence(pKeyEvent->key()) == gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequence()) 56 if ( isHostKeyPressed() 57 && gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequences().contains(QKeySequence(pKeyEvent->key()))) 57 58 { 58 59 /* Post request to show popup-menu: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
r81964 r82186 78 78 gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(), 79 79 actionPool()->action(UIActionIndexRT_M_View_T_Fullscreen)->shortcutExtraDataID()); 80 const QString strHotKey = QString("Host+%1").arg(shortcut. toString());80 const QString strHotKey = QString("Host+%1").arg(shortcut.primaryToPortableText()); 81 81 if (!msgCenter().confirmGoingFullscreen(strHotKey)) 82 82 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIKeyboardHandlerNormal.cpp
r76606 r82186 66 66 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 67 67 /* Process Host+Home as menu-bar activator: */ 68 if (isHostKeyPressed() && QKeySequence(pKeyEvent->key()) == gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequence()) 68 if ( isHostKeyPressed() 69 && gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequences().contains(QKeySequence(pKeyEvent->key()))) 69 70 { 70 71 /* Trying to get menu-bar: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIKeyboardHandlerScale.cpp
r76606 r82186 61 61 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 62 62 /* Process Host+Home for menu popup: */ 63 if (isHostKeyPressed() && QKeySequence(pKeyEvent->key()) == gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequence()) 63 if ( isHostKeyPressed() 64 && gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequences().contains(QKeySequence(pKeyEvent->key()))) 64 65 { 65 66 /* Post request to show popup-menu: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp
r82008 r82186 54 54 gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(), 55 55 actionPool()->action(UIActionIndexRT_M_View_T_Scale)->shortcutExtraDataID()); 56 const QString strHotKey = QString("Host+%1").arg(shortcut. toString());56 const QString strHotKey = QString("Host+%1").arg(shortcut.primaryToPortableText()); 57 57 if (!msgCenter().confirmGoingScale(strHotKey)) 58 58 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIKeyboardHandlerSeamless.cpp
r76606 r82186 61 61 QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent); 62 62 /* Process Host+Home for menu popup: */ 63 if (isHostKeyPressed() && QKeySequence(pKeyEvent->key()) == gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequence()) 63 if ( isHostKeyPressed() 64 && gShortcutPool->shortcut(GUI_Input_MachineShortcuts, QString("PopupMenu")).sequences().contains(QKeySequence(pKeyEvent->key()))) 64 65 { 65 66 /* Post request to show popup-menu: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
r82008 r82186 76 76 gShortcutPool->shortcut(actionPool()->shortcutsExtraDataID(), 77 77 actionPool()->action(UIActionIndexRT_M_View_T_Seamless)->shortcutExtraDataID()); 78 const QString strHotKey = QString("Host+%1").arg(shortcut. toString());78 const QString strHotKey = QString("Host+%1").arg(shortcut.primaryToPortableText()); 79 79 if (!msgCenter().confirmGoingSeamless(strHotKey)) 80 80 return false; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r80881 r82186 927 927 shortcut.scope(), 928 928 UICommon::removeAccelMark(shortcut.description()), 929 shortcut. sequence().toString(QKeySequence::NativeText),929 shortcut.primaryToNativeText(), 930 930 shortcut.defaultSequence().toString(QKeySequence::NativeText)); 931 931 }
Note:
See TracChangeset
for help on using the changeset viewer.