- Timestamp:
- Apr 19, 2018 1:09:04 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71905 r71921 557 557 src/widgets/UIApplianceImportEditorWidget.h \ 558 558 src/widgets/UIEmptyFilePathSelector.h \ 559 src/widgets/UIHotKeyEditor.h \560 559 src/widgets/UILineTextEdit.h \ 561 560 src/widgets/UIMediumSizeEditor.h \ … … 686 685 src/widgets/UIFilmContainer.h \ 687 686 src/widgets/UIHostComboEditor.h \ 687 src/widgets/UIHotKeyEditor.h \ 688 688 src/widgets/UIPopupBox.h \ 689 689 src/widgets/UIPopupPane.h \ … … 777 777 src/widgets/UIFilmContainer.h \ 778 778 src/widgets/UIHostComboEditor.h \ 779 src/widgets/UIHotKeyEditor.h \ 779 780 src/widgets/UIPopupBox.h \ 780 781 src/widgets/UIPopupPane.h \ … … 834 835 src/settings/machine/UIMachineSettingsStorage.cpp \ 835 836 src/settings/machine/UIMachineSettingsUSB.cpp \ 836 src/widgets/UIHotKeyEditor.cpp \837 837 src/widgets/UIMenuToolBar.cpp \ 838 838 src/widgets/UIMiniToolBar.cpp \ … … 858 858 src/selector/UIVirtualBoxEventHandler.cpp \ 859 859 src/widgets/UIFilmContainer.cpp \ 860 src/widgets/UIHotKeyEditor.cpp \ 860 861 src/widgets/UIProgressDialog.cpp 861 862 … … 897 898 src/selector/UIVirtualBoxEventHandler.cpp \ 898 899 src/widgets/UIFilmContainer.cpp \ 900 src/widgets/UIHotKeyEditor.cpp \ 899 901 src/widgets/UIProgressDialog.cpp 900 902 … … 1045 1047 src/widgets/UIApplianceImportEditorWidget.cpp \ 1046 1048 src/widgets/UIEmptyFilePathSelector.cpp \ 1047 src/widgets/UIHotKeyEditor.cpp \1048 1049 src/widgets/UILineTextEdit.cpp \ 1049 1050 src/widgets/UIMediumSizeEditor.cpp \ … … 1214 1215 src/widgets/UIFilmContainer.cpp \ 1215 1216 src/widgets/UIHostComboEditor.cpp \ 1217 src/widgets/UIHotKeyEditor.cpp \ 1216 1218 src/widgets/UIPopupBox.cpp \ 1217 1219 src/widgets/UIPopupPane.cpp \ … … 1331 1333 src/widgets/UIFilmContainer.cpp \ 1332 1334 src/widgets/UIHostComboEditor.cpp \ 1335 src/widgets/UIHotKeyEditor.cpp \ 1333 1336 src/widgets/UIPopupBox.cpp \ 1334 1337 src/widgets/UIPopupPane.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.cpp
r70523 r71921 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VirtualBox Qt extensions:UIHotKeyEditor class implementation.3 * VBox Qt GUI - UIHotKeyEditor class implementation. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 29 29 /* GUI includes; */ 30 # include "UIHostComboEditor.h" 30 31 # include "UIHotKeyEditor.h" 31 32 # include "UIIconPool.h" 32 # include "UIHostComboEditor.h"33 33 # include "QIToolButton.h" 34 34 … … 36 36 37 37 38 /* A line-edit representing hot-key editor:*/38 /** QLineEdit extension representing hot-key editor. */ 39 39 class UIHotKeyLineEdit : public QLineEdit 40 40 { … … 43 43 public: 44 44 45 /* Constructor:*/45 /** Constructs hot-key editor passing @a pParent to the base-class. */ 46 46 UIHotKeyLineEdit(QWidget *pParent); 47 47 48 pr ivateslots:49 50 /* Handler: Selection preserver stuff:*/48 protected slots: 49 50 /** Deselects the hot-key editor text. */ 51 51 void sltDeselect() { deselect(); } 52 52 53 protected: 54 55 /** Handles key-press @a pEvent. */ 56 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 57 /** Handles key-release @a pEvent. */ 58 virtual void keyReleaseEvent(QKeyEvent *pEvent) /* override */; 59 53 60 private: 54 61 55 /* Handlers: Key event processing stuff: */ 56 void keyPressEvent(QKeyEvent *pEvent); 57 void keyReleaseEvent(QKeyEvent *pEvent); 62 /** Returns whether the passed @a pevent should be ignored. */ 58 63 bool isKeyEventIgnored(QKeyEvent *pEvent); 59 64 }; 65 66 67 /********************************************************************************************************************************* 68 * Class UIHotKeyLineEdit implementation. * 69 *********************************************************************************************************************************/ 60 70 61 71 UIHotKeyLineEdit::UIHotKeyLineEdit(QWidget *pParent) … … 107 117 } 108 118 119 120 /********************************************************************************************************************************* 121 * Class UIHotKeyEditor implementation. * 122 *********************************************************************************************************************************/ 109 123 110 124 UIHotKeyEditor::UIHotKeyEditor(QWidget *pParent) … … 178 192 } 179 193 180 void UIHotKeyEditor::retranslateUi()181 {182 m_pResetButton->setToolTip(tr("Reset shortcut to default"));183 m_pClearButton->setToolTip(tr("Unset shortcut"));184 }185 186 194 bool UIHotKeyEditor::eventFilter(QObject *pWatched, QEvent *pEvent) 187 195 { … … 221 229 /* Prevent further key event handling: */ 222 230 return true; 231 } 232 233 void UIHotKeyEditor::retranslateUi() 234 { 235 m_pResetButton->setToolTip(tr("Reset shortcut to default")); 236 m_pClearButton->setToolTip(tr("Unset shortcut")); 237 } 238 239 void UIHotKeyEditor::keyPressEvent(QKeyEvent *pEvent) 240 { 241 /* Is this event ignored? */ 242 if (isKeyEventIgnored(pEvent)) 243 return; 244 /* Call to base-class: */ 245 return QWidget::keyPressEvent(pEvent); 246 } 247 248 void UIHotKeyEditor::keyReleaseEvent(QKeyEvent *pEvent) 249 { 250 /* Is this event ignored? */ 251 if (isKeyEventIgnored(pEvent)) 252 return; 253 /* Call to base-class: */ 254 return QWidget::keyReleaseEvent(pEvent); 223 255 } 224 256 … … 243 275 /* Do not skip by default: */ 244 276 return false; 245 }246 247 void UIHotKeyEditor::keyPressEvent(QKeyEvent *pEvent)248 {249 /* Is this event ignored? */250 if (isKeyEventIgnored(pEvent))251 return;252 /* Call to base-class: */253 return QWidget::keyPressEvent(pEvent);254 }255 256 void UIHotKeyEditor::keyReleaseEvent(QKeyEvent *pEvent)257 {258 /* Is this event ignored? */259 if (isKeyEventIgnored(pEvent))260 return;261 /* Call to base-class: */262 return QWidget::keyReleaseEvent(pEvent);263 277 } 264 278 … … 482 496 } 483 497 498 484 499 #include "UIHotKeyEditor.moc" 485 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h
r69500 r71921 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VirtualBox Qt extensions:UIHotKeyEditor class declaration.3 * VBox Qt GUI - UIHotKeyEditor class declaration. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 /* Qt includes: */ 22 22 #include <QMetaType> 23 #include <QSet> 23 24 #include <QWidget> 24 #include <QSet>25 25 26 26 /* GUI includes: */ 27 27 #include "QIWithRetranslateUI.h" 28 #include "UILibraryDefs.h" 28 29 29 30 /* Forward declarations: */ … … 32 33 class UIHotKeyLineEdit; 33 34 34 /* Host key type enumerator: */ 35 36 /** Hot key types. */ 35 37 enum UIHotKeyType 36 38 { … … 39 41 }; 40 42 41 /* A string pair wrapper for hot-key sequence: */ 43 44 /** A string pair wrapper for hot-key sequence. */ 42 45 class UIHotKey 43 46 { 44 47 public: 45 48 46 /* Constructors:*/49 /** Constructs null hot-key sequence. */ 47 50 UIHotKey() 48 : m_ type(UIHotKeyType_Simple)51 : m_enmType(UIHotKeyType_Simple) 49 52 {} 50 UIHotKey(UIHotKeyType type, 51 const QString &strSequence, 52 const QString &strDefaultSequence) 53 : m_type(type) 53 /** Constructs hot-key sequence on the basis of passed @a enmType, @a strSequence and @a strDefaultSequence. */ 54 UIHotKey(UIHotKeyType enmType, const QString &strSequence, const QString &strDefaultSequence) 55 : m_enmType(enmType) 54 56 , m_strSequence(strSequence) 55 57 , m_strDefaultSequence(strDefaultSequence) 56 58 {} 59 /** Constructs hot-key sequence on the basis of @a other hot-key sequence. */ 57 60 UIHotKey(const UIHotKey &other) 58 : m_ type(other.type())61 : m_enmType(other.type()) 59 62 , m_strSequence(other.sequence()) 60 63 , m_strDefaultSequence(other.defaultSequence()) 61 64 {} 62 65 63 /* API: Operators stuff:*/64 UIHotKey &operator=(const UIHotKey &other)66 /** Makes a copy of the given other hot-key sequence and assigns it to this one. */ 67 UIHotKey &operator=(const UIHotKey &other) 65 68 { 66 m_ type = other.type();69 m_enmType = other.type(); 67 70 m_strSequence = other.sequence(); 68 71 m_strDefaultSequence = other.defaultSequence(); … … 70 73 } 71 74 72 /* API: Type access stuff:*/73 UIHotKeyType type() const { return m_ type; }75 /** Returns the type of this hot-key sequence. */ 76 UIHotKeyType type() const { return m_enmType; } 74 77 75 /* API: Sequence access stuff: */ 76 const QString& sequence() const { return m_strSequence; } 77 const QString& defaultSequence() const { return m_strDefaultSequence; } 78 /** Returns hot-key sequence. */ 79 const QString &sequence() const { return m_strSequence; } 80 /** Returns default hot-key sequence. */ 81 const QString &defaultSequence() const { return m_strDefaultSequence; } 82 /** Defines hot-key @a strSequence. */ 78 83 void setSequence(const QString &strSequence) { m_strSequence = strSequence; } 79 84 80 85 private: 81 86 82 /* Variables: */ 83 UIHotKeyType m_type; 87 /** Holds the type of this hot-key sequence. */ 88 UIHotKeyType m_enmType; 89 /** Holds the hot-key sequence. */ 84 90 QString m_strSequence; 91 /** Holds the default hot-key sequence. */ 85 92 QString m_strDefaultSequence; 86 93 }; 87 94 Q_DECLARE_METATYPE(UIHotKey); 88 95 89 /* A widget wrapper for real hot-key editor: */ 90 class UIHotKeyEditor : public QIWithRetranslateUI<QWidget> 96 97 /** QWidget subclass wrapping real hot-key editor. */ 98 class SHARED_LIBRARY_STUFF UIHotKeyEditor : public QIWithRetranslateUI<QWidget> 91 99 { 92 100 Q_OBJECT; … … 100 108 public: 101 109 102 /* Constructor:*/110 /** Constructs hot-key editor passing @a pParent to the base-class. */ 103 111 UIHotKeyEditor(QWidget *pParent); 104 112 105 113 private slots: 106 114 107 /* Handlers: Tool-button stuff:*/115 /** Resets hot-key sequence to default. */ 108 116 void sltReset(); 117 /** Clears hot-key sequence. */ 109 118 void sltClear(); 119 120 protected: 121 122 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 123 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 124 125 /** Handles translation event. */ 126 virtual void retranslateUi() /* override */; 127 128 /** Handles key-press @a pEvent. */ 129 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */; 130 /** Handles key-release @a pEvent. */ 131 virtual void keyReleaseEvent(QKeyEvent *pEvent) /* override */; 110 132 111 133 private: 112 134 113 /* Helper: Translate stuff: */ 114 void retranslateUi(); 115 116 /* Handlers: Line-edit key event pre-processing stuff: */ 117 bool eventFilter(QObject *pWatched, QEvent *pEvent); 135 /** Returns whether we hould skip key-event to line-edit. */ 118 136 bool shouldWeSkipKeyEventToLineEdit(QKeyEvent *pEvent); 119 137 120 /* Handlers: Key event processing stuff: */ 121 void keyPressEvent(QKeyEvent *pEvent); 122 void keyReleaseEvent(QKeyEvent *pEvent); 138 /** Returns whether key @a pEvent is ignored. */ 123 139 bool isKeyEventIgnored(QKeyEvent *pEvent); 124 140 125 /* Helpers: Modifier stuff:*/141 /** Fetches actual modifier states. */ 126 142 void fetchModifiersState(); 143 /** Returns whether Host+ modifier is required. */ 127 144 void checkIfHostModifierNeeded(); 128 145 129 /* Handlers: Sequence stuff: */ 130 bool approvedKeyPressed(QKeyEvent *pKeyEvent); 131 void handleKeyPress(QKeyEvent *pKeyEvent); 132 void handleKeyRelease(QKeyEvent *pKeyEvent); 146 /** Handles approved key-press @a pEvent. */ 147 bool approvedKeyPressed(QKeyEvent *pEvent); 148 /** Handles key-press @a pEvent. */ 149 void handleKeyPress(QKeyEvent *pEvent); 150 /** Handles key-release @a pEvent. */ 151 void handleKeyRelease(QKeyEvent *pEvent); 152 /** Reflects recorded sequence in editor. */ 133 153 void reflectSequence(); 154 /** Draws recorded sequence in editor. */ 134 155 void drawSequence(); 135 156 136 /* API: Editor stuff:*/157 /** Returns hot-key. */ 137 158 UIHotKey hotKey() const; 159 /** Defines @a hotKey. */ 138 160 void setHotKey(const UIHotKey &hotKey); 139 161 140 /* Variables: */ 141 UIHotKey m_hotKey; 142 bool m_fIsModifiersAllowed; 143 QHBoxLayout *m_pMainLayout; 144 QHBoxLayout *m_pButtonLayout; 162 /** Holds the hot-key. */ 163 UIHotKey m_hotKey; 164 165 /** Holds whether the modifiers are allowed. */ 166 bool m_fIsModifiersAllowed; 167 168 /** Holds the main-layout instance. */ 169 QHBoxLayout *m_pMainLayout; 170 /** Holds the button-layout instance. */ 171 QHBoxLayout *m_pButtonLayout; 172 /** Holds the line-edit instance. */ 145 173 UIHotKeyLineEdit *m_pLineEdit; 146 QIToolButton *m_pResetButton; 147 QIToolButton *m_pClearButton; 148 QSet<int> m_takenModifiers; 149 int m_iTakenKey; 150 bool m_fSequenceTaken; 174 /** Holds the reset-button instance. */ 175 QIToolButton *m_pResetButton; 176 /** Holds the clear-button instance. */ 177 QIToolButton *m_pClearButton; 178 179 /** Holds the taken modifiers. */ 180 QSet<int> m_takenModifiers; 181 /** Holds the taken key. */ 182 int m_iTakenKey; 183 /** Holds whether sequence is taken. */ 184 bool m_fSequenceTaken; 151 185 }; 152 186 187 153 188 #endif /* !___UIHotKeyEditor_h___ */ 154
Note:
See TracChangeset
for help on using the changeset viewer.