VirtualBox

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

Last change on this file since 35740 was 35730, checked in by vboxsync, 13 years ago

FE/Qt: 5245: GUI support for complex host-key combinations. Initial build for Win/X11.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VirtualBox Qt extensions: UIHotKeyEditor class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___UIHotKeyEditor_h___
20#define ___UIHotKeyEditor_h___
21
22/* Global includes */
23#include <QLabel>
24#include <QMap>
25#include <QSet>
26
27/* Hot-key namespace to unify
28 * all the related hot-key processing stuff: */
29namespace UIHotKey
30{
31 QString toString(int iKeyCode);
32 bool isValidKey(int iKeyCode);
33#ifdef Q_WS_WIN
34 int distinguishModifierVKey(int wParam);
35#endif /* Q_WS_WIN */
36#ifdef Q_WS_X11
37 void retranslateKeyNames();
38#endif /* Q_WS_X11 */
39}
40
41/* Hot-combo namespace to unify
42 * all the related hot-combo processing stuff: */
43namespace UIHotKeyCombination
44{
45 QString toReadableString(const QString &strKeyCombo);
46 QList<int> toKeyCodeList(const QString &strKeyCombo);
47 bool isValidKeyCombo(const QString &strKeyCombo);
48}
49
50class UIHotKeyEditor : public QLabel
51{
52 Q_OBJECT;
53
54public:
55
56 UIHotKeyEditor(QWidget *pParent);
57 virtual ~UIHotKeyEditor();
58
59 void setCombo(const QString &strKeyCombo);
60 QString combo() const;
61
62 QSize sizeHint() const;
63 QSize minimumSizeHint() const;
64
65protected:
66
67#ifdef Q_WS_WIN
68 bool winEvent(MSG *pMsg, long *pResult);
69#endif /* Q_WS_WIN */
70#ifdef Q_WS_X11
71 bool x11Event(XEvent *pEvent);
72#endif /* Q_WS_X11 */
73#ifdef Q_WS_MAC
74 static bool darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
75 bool darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent);
76#endif /* Q_WS_MAC */
77
78 void keyPressEvent(QKeyEvent *pEvent);
79 void focusInEvent(QFocusEvent *pEvent);
80 void focusOutEvent(QFocusEvent *pEvent);
81 void paintEvent(QPaintEvent *pEvent);
82
83private:
84
85 void updateText();
86
87 QSet<int> m_pressedKeys;
88 QMap<int, QString> m_shownKeys;
89
90 bool m_fStartNewSequence;
91
92#ifdef Q_WS_MAC
93 /* The current modifier key mask. Used to figure out which modifier
94 * key was pressed when we get a kEventRawKeyModifiersChanged event. */
95 uint32_t m_uDarwinKeyModifiers;
96#endif /* Q_WS_MAC */
97};
98
99#endif // !___UIHotKeyEditor_h___
100
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use