Changeset 71525 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 27, 2018 3:26:40 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121501
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.cpp
r69500 r71525 5 5 6 6 /* 7 * Copyright (C) 2011-201 7Oracle Corporation7 * Copyright (C) 2011-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* GUI includes: */ 23 # include " UIShortcutPool.h"23 # include "VBoxGlobal.h" 24 24 # include "UIActionPool.h" 25 25 # include "UIExtraDataManager.h" 26 # include "UIShortcutPool.h" 26 27 27 28 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 32 33 33 34 35 /********************************************************************************************************************************* 36 * Class UIShortcut implementation. * 37 *********************************************************************************************************************************/ 38 34 39 void UIShortcut::setDescription(const QString &strDescription) 35 40 { … … 37 42 } 38 43 39 const QString &UIShortcut::description() const44 const QString &UIShortcut::description() const 40 45 { 41 46 return m_strDescription; … … 47 52 } 48 53 49 const QKeySequence &UIShortcut::sequence() const54 const QKeySequence &UIShortcut::sequence() const 50 55 { 51 56 return m_sequence; … … 57 62 } 58 63 59 const QKeySequence &UIShortcut::defaultSequence() const64 const QKeySequence &UIShortcut::defaultSequence() const 60 65 { 61 66 return m_defaultSequence; … … 67 72 } 68 73 69 UIShortcutPool* UIShortcutPool::m_pInstance = 0; 70 71 const QString UIShortcutPool::m_sstrShortcutKeyTemplate = QString("%1/%2"); 72 const QString UIShortcutPool::m_sstrShortcutKeyTemplateRuntime = m_sstrShortcutKeyTemplate.arg(GUI_Input_MachineShortcuts); 73 74 UIShortcutPool* UIShortcutPool::instance() 75 { 76 return m_pInstance;77 } 74 75 /********************************************************************************************************************************* 76 * Class UIShortcutPool implementation. * 77 *********************************************************************************************************************************/ 78 79 /* static */ 80 UIShortcutPool *UIShortcutPool::s_pInstance = 0; 81 const QString UIShortcutPool::s_strShortcutKeyTemplate = QString("%1/%2"); 82 const QString UIShortcutPool::s_strShortcutKeyTemplateRuntime = s_strShortcutKeyTemplate.arg(GUI_Input_MachineShortcuts); 78 83 79 84 void UIShortcutPool::create() 80 85 { 81 86 /* Check that instance do NOT exists: */ 82 if ( m_pInstance)87 if (s_pInstance) 83 88 return; 84 89 … … 87 92 88 93 /* Prepare instance: */ 89 m_pInstance->prepare();94 s_pInstance->prepare(); 90 95 } 91 96 … … 93 98 { 94 99 /* Check that instance exists: */ 95 if (! m_pInstance)100 if (!s_pInstance) 96 101 return; 97 102 98 103 /* Cleanup instance: */ 99 m_pInstance->cleanup();104 s_pInstance->cleanup(); 100 105 101 106 /* Delete instance: */ 102 delete m_pInstance;103 } 104 105 UIShortcut &UIShortcutPool::shortcut(UIActionPool *pActionPool, UIAction *pAction)107 delete s_pInstance; 108 } 109 110 UIShortcut &UIShortcutPool::shortcut(UIActionPool *pActionPool, UIAction *pAction) 106 111 { 107 112 /* Compose shortcut key: */ 108 const QString strShortcutKey( m_sstrShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(),109 113 const QString strShortcutKey(s_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(), 114 pAction->shortcutExtraDataID())); 110 115 /* Return existing if any: */ 111 116 if (m_shortcuts.contains(strShortcutKey)) … … 119 124 } 120 125 121 UIShortcut &UIShortcutPool::shortcut(const QString &strPoolID, const QString &strActionID)126 UIShortcut &UIShortcutPool::shortcut(const QString &strPoolID, const QString &strActionID) 122 127 { 123 128 /* Return if present, autocreate if necessary: */ 124 return shortcut( m_sstrShortcutKeyTemplate.arg(strPoolID, strActionID));129 return shortcut(s_strShortcutKeyTemplate.arg(strPoolID, strActionID)); 125 130 } 126 131 … … 151 156 152 157 /* Compose shortcut key: */ 153 const QString strShortcutKey = m_sstrShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(),154 158 const QString strShortcutKey = s_strShortcutKeyTemplate.arg(pActionPool->shortcutsExtraDataID(), 159 pAction->shortcutExtraDataID()); 155 160 /* If shortcut key is already known: */ 156 161 if (m_shortcuts.contains(strShortcutKey)) … … 180 185 } 181 186 187 void UIShortcutPool::retranslateUi() 188 { 189 /* Translate own defaults: */ 190 m_shortcuts[s_strShortcutKeyTemplateRuntime.arg("PopupMenu")] 191 .setDescription(QApplication::translate("UIActionPool", "Popup Menu")); 192 } 193 182 194 void UIShortcutPool::sltReloadSelectorShortcuts() 183 195 { … … 217 229 { 218 230 /* Prepare instance: */ 219 if (! m_pInstance)220 m_pInstance = this;231 if (!s_pInstance) 232 s_pInstance = this; 221 233 } 222 234 … … 224 236 { 225 237 /* Cleanup instance: */ 226 if ( m_pInstance == this)227 m_pInstance = 0;238 if (s_pInstance == this) 239 s_pInstance = 0; 228 240 } 229 241 … … 247 259 } 248 260 249 void UIShortcutPool::retranslateUi()250 {251 /* Translate own defaults: */252 m_shortcuts[m_sstrShortcutKeyTemplateRuntime.arg("PopupMenu")]253 .setDescription(QApplication::translate("UIActionPool", "Popup Menu"));254 }255 256 261 void UIShortcutPool::loadDefaults() 257 262 { … … 273 278 { 274 279 /* Default shortcut for the Runtime Popup Menu: */ 275 m_shortcuts.insert( m_sstrShortcutKeyTemplateRuntime.arg("PopupMenu"),280 m_shortcuts.insert(s_strShortcutKeyTemplateRuntime.arg("PopupMenu"), 276 281 UIShortcut(QApplication::translate("UIActionPool", "Popup Menu"), 277 282 QString("Home"), QString("Home"))); … … 290 295 { 291 296 /* Compose shortcut key template: */ 292 const QString strShortcutKeyTemplate( m_sstrShortcutKeyTemplate.arg(strPoolExtraDataID));297 const QString strShortcutKeyTemplate(s_strShortcutKeyTemplate.arg(strPoolExtraDataID)); 293 298 /* Iterate over all the overrides: */ 294 299 const QStringList overrides = gEDataManager->shortcutOverrides(strPoolExtraDataID); … … 342 347 { 343 348 /* Compose shortcut prefix: */ 344 const QString strShortcutPrefix( m_sstrShortcutKeyTemplate.arg(strPoolExtraDataID, QString()));349 const QString strShortcutPrefix(s_strShortcutKeyTemplate.arg(strPoolExtraDataID, QString())); 345 350 /* Populate the list of all the known overrides: */ 346 351 QStringList overrides; … … 364 369 } 365 370 366 UIShortcut &UIShortcutPool::shortcut(const QString &strShortcutKey)371 UIShortcut &UIShortcutPool::shortcut(const QString &strShortcutKey) 367 372 { 368 373 return m_shortcuts[strShortcutKey]; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIShortcutPool.h
r69500 r71525 5 5 6 6 /* 7 * Copyright (C) 2011-201 7Oracle Corporation7 * Copyright (C) 2011-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIShortcutPool_h__19 #define __ UIShortcutPool_h__18 #ifndef ___UIShortcutPool_h___ 19 #define ___UIShortcutPool_h___ 20 20 21 21 /* Qt includes: */ … … 23 23 24 24 /* GUI includes: */ 25 #include "VBoxGlobal.h"26 25 #include "QIWithRetranslateUI.h" 27 26 28 27 /* Forward declarations: */ 28 class QKeySequence; 29 class QString; 29 30 class UIActionPool; 30 31 class UIAction; 31 32 32 /* Shortcut descriptor: */ 33 34 /** Shortcut descriptor prototype. */ 33 35 class UIShortcut 34 36 { 35 37 public: 36 38 37 /* Constructors:*/39 /** Constructs empty shortcut descriptor. */ 38 40 UIShortcut() 39 41 : m_strDescription(QString()) … … 41 43 , m_defaultSequence(QKeySequence()) 42 44 {} 45 /** Constructs shortcut descriptor. 46 * @param strDescription Brings the shortcut description. 47 * @param sequence Brings the shortcut sequence. 48 * @param defaultSequence Brings the default shortcut sequence. */ 43 49 UIShortcut(const QString &strDescription, 44 50 const QKeySequence &sequence, … … 49 55 {} 50 56 51 /* API: Description stuff:*/57 /** Defines the shortcut @a strDescription. */ 52 58 void setDescription(const QString &strDescription); 53 const QString& description() const; 59 /** Returns the shortcut description. */ 60 const QString &description() const; 54 61 55 /* API: Sequence stuff:*/62 /** Defines the shortcut @a sequence. */ 56 63 void setSequence(const QKeySequence &sequence); 57 const QKeySequence& sequence() const; 64 /** Returns the shortcut sequence. */ 65 const QKeySequence &sequence() const; 58 66 59 /* API: Default sequence stuff: */ 60 void setDefaultSequence(const QKeySequence &defaultSequence); 61 const QKeySequence& defaultSequence() const; 67 /** Defines the default shortcut @a sequence. */ 68 void setDefaultSequence(const QKeySequence &sequence); 69 /** Returns the default shortcut sequence. */ 70 const QKeySequence &defaultSequence() const; 62 71 63 /* API: Conversion stuff:*/72 /** Converts shortcut sequence to string. */ 64 73 QString toString() const; 65 74 66 75 private: 67 76 68 /* Variables: */ 69 QString m_strDescription; 77 /** Holds the shortcut description. */ 78 QString m_strDescription; 79 /** Holds the shortcut sequence. */ 70 80 QKeySequence m_sequence; 81 /** Holds the default shortcut sequence. */ 71 82 QKeySequence m_defaultSequence; 72 83 }; 73 84 74 /* Singleton shortcut pool: */ 85 86 /** QObject extension used as shortcut pool singleton. */ 75 87 class UIShortcutPool : public QIWithRetranslateUI3<QObject> 76 88 { … … 79 91 signals: 80 92 81 /* Notifiers: Extra-data stuff:*/93 /** Notifies about Selector UI shortcuts changed. */ 82 94 void sigSelectorShortcutsReloaded(); 95 /** Notifies about Runtime UI shortcuts changed. */ 83 96 void sigMachineShortcutsReloaded(); 84 97 85 98 public: 86 99 87 /* API: Singleton stuff: */ 88 static UIShortcutPool* instance(); 100 /** Returns singleton instance. */ 101 static UIShortcutPool *instance() { return s_pInstance; } 102 /** Creates singleton instance. */ 89 103 static void create(); 104 /** Destroys singleton instance. */ 90 105 static void destroy(); 91 106 92 /* API: Shortcut stuff: */ 93 UIShortcut& shortcut(UIActionPool *pActionPool, UIAction *pAction); 94 UIShortcut& shortcut(const QString &strPoolID, const QString &strActionID); 95 const QMap<QString, UIShortcut>& shortcuts() const { return m_shortcuts; } 107 /** Returns shortcuts of particular @a pActionPool for specified @a pAction. */ 108 UIShortcut &shortcut(UIActionPool *pActionPool, UIAction *pAction); 109 /** Returns shortcuts of action-pool with @a strPoolID for action with @a strActionID. */ 110 UIShortcut &shortcut(const QString &strPoolID, const QString &strActionID); 111 /** Returns all the shortcuts. */ 112 const QMap<QString, UIShortcut> &shortcuts() const { return m_shortcuts; } 113 /** Defines shortcut overrides. */ 96 114 void setOverrides(const QMap<QString, QString> &overrides); 97 115 98 /* API: Action-pool stuff:*/116 /** Applies shortcuts for specified @a pActionPool. */ 99 117 void applyShortcuts(UIActionPool *pActionPool); 118 119 protected: 120 121 /** Handles translation event. */ 122 virtual void retranslateUi() /* override */; 100 123 101 124 private slots: 102 125 103 /* Handlers: Extra-data stuff:*/126 /** Reloads Selector UI shortcuts. */ 104 127 void sltReloadSelectorShortcuts(); 128 /** Reloads Runtime UI shortcuts. */ 105 129 void sltReloadMachineShortcuts(); 106 130 107 131 private: 108 132 109 /* Constructor/destructor:*/133 /** Constructs shortcut pool. */ 110 134 UIShortcutPool(); 135 /** Destructs shortcut pool. */ 111 136 ~UIShortcutPool(); 112 137 113 /* Helpers: Prepare stuff:*/138 /** Prepares all. */ 114 139 void prepare(); 140 /** Prepares connections. */ 115 141 void prepareConnections(); 116 142 117 /* Helper: Cleanup stuff:*/143 /** Cleanups all. */ 118 144 void cleanup() {} 119 145 120 /** Translation handler. */ 121 void retranslateUi(); 122 123 /* Helpers: Shortcuts stuff: */ 146 /** Loads defaults. */ 124 147 void loadDefaults(); 148 /** Loads defaults for pool with specified @a strPoolExtraDataID. */ 125 149 void loadDefaultsFor(const QString &strPoolExtraDataID); 150 /** Loads overrides. */ 126 151 void loadOverrides(); 152 /** Loads overrides for pool with specified @a strPoolExtraDataID. */ 127 153 void loadOverridesFor(const QString &strPoolExtraDataID); 154 /** Saves overrides. */ 128 155 void saveOverrides(); 156 /** Saves overrides for pool with specified @a strPoolExtraDataID. */ 129 157 void saveOverridesFor(const QString &strPoolExtraDataID); 130 158 131 /* Helper: Shortcut stuff:*/132 UIShortcut &shortcut(const QString &strShortcutKey);159 /** Returns shortcut with specified @a strShortcutKey. */ 160 UIShortcut &shortcut(const QString &strShortcutKey); 133 161 134 /* Variables:*/135 static UIShortcutPool * m_pInstance;162 /** Holds the singleton instance. */ 163 static UIShortcutPool *s_pInstance; 136 164 /** Shortcut key template. */ 137 static const QString m_sstrShortcutKeyTemplate;165 static const QString s_strShortcutKeyTemplate; 138 166 /** Shortcut key template for Runtime UI. */ 139 static const QString m_sstrShortcutKeyTemplateRuntime; 167 static const QString s_strShortcutKeyTemplateRuntime; 168 169 /** Holds the pool shortcuts. */ 140 170 QMap<QString, UIShortcut> m_shortcuts; 141 171 }; 142 172 173 /** Singleton Shortcut Pool 'official' name. */ 143 174 #define gShortcutPool UIShortcutPool::instance() 144 175 145 #endif /* __UIShortcutPool_h__ */146 176 177 #endif /* !___UIShortcutPool_h___ */ 178 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp
r71027 r71525 30 30 # include "QITableView.h" 31 31 # include "QIWidgetValidator.h" 32 # include "VBoxGlobal.h" 32 33 # include "UIActionPool.h" 33 34 # include "UIGlobalSettingsInput.h" … … 898 899 AssertPtr(pParent); 899 900 oldInputData.shortcuts() << UIDataShortcutRow(pParent, strShortcutKey, VBoxGlobal::removeAccelMark(shortcut.description()), 900 shortcut.sequence().toString(QKeySequence::NativeText),901 shortcut.defaultSequence().toString(QKeySequence::NativeText));901 shortcut.sequence().toString(QKeySequence::NativeText), 902 shortcut.defaultSequence().toString(QKeySequence::NativeText)); 902 903 } 903 904 oldInputData.setAutoCapture(gEDataManager->autoCaptureEnabled());
Note:
See TracChangeset
for help on using the changeset viewer.