VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h@ 76553

Last change on this file since 76553 was 76553, checked in by vboxsync, 5 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VBoxHeadless/VirtualBox/src/widgets/UIHostComboEditor.h82454
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h74233,​78414,​78691,​81841,​82127
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHotKeyEditor.h91223
    /branches/andy/guestctrl20/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h78916,​78930
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h79224,​79228,​79233,​79235,​79258,​79262-79263,​79273,​79341,​79345,​79354,​79357,​79387-79388,​79559-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h79645-79692
File size: 5.6 KB
Line 
1/* $Id: UIHotKeyEditor.h 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIHotKeyEditor class declaration.
4 */
5
6/*
7 * Copyright (C) 2013-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___UIHotKeyEditor_h___
19#define ___UIHotKeyEditor_h___
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QMetaType>
26#include <QSet>
27#include <QWidget>
28
29/* GUI includes: */
30#include "QIWithRetranslateUI.h"
31#include "UILibraryDefs.h"
32
33/* Forward declarations: */
34class QHBoxLayout;
35class QIToolButton;
36class UIHotKeyLineEdit;
37
38
39/** Hot key types. */
40enum UIHotKeyType
41{
42 UIHotKeyType_Simple,
43 UIHotKeyType_WithModifiers
44};
45
46
47/** A string pair wrapper for hot-key sequence. */
48class UIHotKey
49{
50public:
51
52 /** Constructs null hot-key sequence. */
53 UIHotKey()
54 : m_enmType(UIHotKeyType_Simple)
55 {}
56 /** Constructs hot-key sequence on the basis of passed @a enmType, @a strSequence and @a strDefaultSequence. */
57 UIHotKey(UIHotKeyType enmType, const QString &strSequence, const QString &strDefaultSequence)
58 : m_enmType(enmType)
59 , m_strSequence(strSequence)
60 , m_strDefaultSequence(strDefaultSequence)
61 {}
62 /** Constructs hot-key sequence on the basis of @a other hot-key sequence. */
63 UIHotKey(const UIHotKey &other)
64 : m_enmType(other.type())
65 , m_strSequence(other.sequence())
66 , m_strDefaultSequence(other.defaultSequence())
67 {}
68
69 /** Makes a copy of the given other hot-key sequence and assigns it to this one. */
70 UIHotKey &operator=(const UIHotKey &other)
71 {
72 m_enmType = other.type();
73 m_strSequence = other.sequence();
74 m_strDefaultSequence = other.defaultSequence();
75 return *this;
76 }
77
78 /** Returns the type of this hot-key sequence. */
79 UIHotKeyType type() const { return m_enmType; }
80
81 /** Returns hot-key sequence. */
82 const QString &sequence() const { return m_strSequence; }
83 /** Returns default hot-key sequence. */
84 const QString &defaultSequence() const { return m_strDefaultSequence; }
85 /** Defines hot-key @a strSequence. */
86 void setSequence(const QString &strSequence) { m_strSequence = strSequence; }
87
88private:
89
90 /** Holds the type of this hot-key sequence. */
91 UIHotKeyType m_enmType;
92 /** Holds the hot-key sequence. */
93 QString m_strSequence;
94 /** Holds the default hot-key sequence. */
95 QString m_strDefaultSequence;
96};
97Q_DECLARE_METATYPE(UIHotKey);
98
99
100/** QWidget subclass wrapping real hot-key editor. */
101class SHARED_LIBRARY_STUFF UIHotKeyEditor : public QIWithRetranslateUI<QWidget>
102{
103 Q_OBJECT;
104 Q_PROPERTY(UIHotKey hotKey READ hotKey WRITE setHotKey USER true);
105
106signals:
107
108 /** Notifies listener about data should be committed. */
109 void sigCommitData(QWidget *pThis);
110
111public:
112
113 /** Constructs hot-key editor passing @a pParent to the base-class. */
114 UIHotKeyEditor(QWidget *pParent);
115
116private slots:
117
118 /** Resets hot-key sequence to default. */
119 void sltReset();
120 /** Clears hot-key sequence. */
121 void sltClear();
122
123protected:
124
125 /** Preprocesses any Qt @a pEvent for passed @a pObject. */
126 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
127
128 /** Handles translation event. */
129 virtual void retranslateUi() /* override */;
130
131 /** Handles key-press @a pEvent. */
132 virtual void keyPressEvent(QKeyEvent *pEvent) /* override */;
133 /** Handles key-release @a pEvent. */
134 virtual void keyReleaseEvent(QKeyEvent *pEvent) /* override */;
135
136private:
137
138 /** Returns whether we hould skip key-event to line-edit. */
139 bool shouldWeSkipKeyEventToLineEdit(QKeyEvent *pEvent);
140
141 /** Returns whether key @a pEvent is ignored. */
142 bool isKeyEventIgnored(QKeyEvent *pEvent);
143
144 /** Fetches actual modifier states. */
145 void fetchModifiersState();
146 /** Returns whether Host+ modifier is required. */
147 void checkIfHostModifierNeeded();
148
149 /** Handles approved key-press @a pEvent. */
150 bool approvedKeyPressed(QKeyEvent *pEvent);
151 /** Handles key-press @a pEvent. */
152 void handleKeyPress(QKeyEvent *pEvent);
153 /** Handles key-release @a pEvent. */
154 void handleKeyRelease(QKeyEvent *pEvent);
155 /** Reflects recorded sequence in editor. */
156 void reflectSequence();
157 /** Draws recorded sequence in editor. */
158 void drawSequence();
159
160 /** Returns hot-key. */
161 UIHotKey hotKey() const;
162 /** Defines @a hotKey. */
163 void setHotKey(const UIHotKey &hotKey);
164
165 /** Holds the hot-key. */
166 UIHotKey m_hotKey;
167
168 /** Holds whether the modifiers are allowed. */
169 bool m_fIsModifiersAllowed;
170
171 /** Holds the main-layout instance. */
172 QHBoxLayout *m_pMainLayout;
173 /** Holds the button-layout instance. */
174 QHBoxLayout *m_pButtonLayout;
175 /** Holds the line-edit instance. */
176 UIHotKeyLineEdit *m_pLineEdit;
177 /** Holds the reset-button instance. */
178 QIToolButton *m_pResetButton;
179 /** Holds the clear-button instance. */
180 QIToolButton *m_pClearButton;
181
182 /** Holds the taken modifiers. */
183 QSet<int> m_takenModifiers;
184 /** Holds the taken key. */
185 int m_iTakenKey;
186 /** Holds whether sequence is taken. */
187 bool m_fSequenceTaken;
188};
189
190
191#endif /* !___UIHotKeyEditor_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use