1 | /* $Id: UIIndicatorsPool.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIIndicatorsPool class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-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 FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h
|
---|
19 | #define FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QWidget>
|
---|
26 | #include <QList>
|
---|
27 | #include <QMap>
|
---|
28 |
|
---|
29 | /* GUI includes: */
|
---|
30 | #include "UIExtraDataDefs.h"
|
---|
31 |
|
---|
32 | /* COM includes: */
|
---|
33 | #include "COMEnums.h"
|
---|
34 |
|
---|
35 | /* Forward declarations: */
|
---|
36 | class UISession;
|
---|
37 | class CSession;
|
---|
38 | class QIStatusBarIndicator;
|
---|
39 | class QHBoxLayout;
|
---|
40 | class QTimer;
|
---|
41 |
|
---|
42 | /** QWidget extension
|
---|
43 | * providing Runtime UI with status-bar indicators. */
|
---|
44 | class UIIndicatorsPool : public QWidget
|
---|
45 | {
|
---|
46 | Q_OBJECT;
|
---|
47 |
|
---|
48 | signals:
|
---|
49 |
|
---|
50 | /** Notifies about context menu request.
|
---|
51 | * @param indicatorType reflects which type of indicator it is,
|
---|
52 | * @param position reflects contex-menu position. */
|
---|
53 | void sigContextMenuRequest(IndicatorType indicatorType, const QPoint &position);
|
---|
54 |
|
---|
55 | public:
|
---|
56 |
|
---|
57 | /** Constructor, passes @a pParent to the QWidget constructor.
|
---|
58 | * @param pSession is used to retrieve appearance information. */
|
---|
59 | UIIndicatorsPool(UISession *pSession, QWidget *pParent = 0);
|
---|
60 | /** Destructor. */
|
---|
61 | ~UIIndicatorsPool();
|
---|
62 |
|
---|
63 | /** Updates appearance for passed @a indicatorType. */
|
---|
64 | void updateAppearance(IndicatorType indicatorType);
|
---|
65 |
|
---|
66 | /** Defines whether indicator-states auto-update is @a fEnabled. */
|
---|
67 | void setAutoUpdateIndicatorStates(bool fEnabled);
|
---|
68 |
|
---|
69 | /** Returns global screen position corresponding to @a indicatorPosition inside indicator of @a enmIndicatorType. */
|
---|
70 | QPoint mapIndicatorPositionToGlobal(IndicatorType enmIndicatorType, const QPoint &indicatorPosition);
|
---|
71 |
|
---|
72 | private slots:
|
---|
73 |
|
---|
74 | /** Handles configuration change. */
|
---|
75 | void sltHandleConfigurationChange(const QUuid &uMachineID);
|
---|
76 |
|
---|
77 | /** Handles indicator-states auto-update. */
|
---|
78 | void sltAutoUpdateIndicatorStates();
|
---|
79 |
|
---|
80 | /** Handles context-menu request. */
|
---|
81 | void sltContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent);
|
---|
82 |
|
---|
83 | private:
|
---|
84 |
|
---|
85 | /** Prepare routine. */
|
---|
86 | void prepare();
|
---|
87 | /** Prepare connections routine: */
|
---|
88 | void prepareConnections();
|
---|
89 | /** Prepare contents routine. */
|
---|
90 | void prepareContents();
|
---|
91 | /** Prepare update-timer routine: */
|
---|
92 | void prepareUpdateTimer();
|
---|
93 |
|
---|
94 | /** Update pool routine. */
|
---|
95 | void updatePool();
|
---|
96 |
|
---|
97 | /** Cleanup update-timer routine: */
|
---|
98 | void cleanupUpdateTimer();
|
---|
99 | /** Cleanup contents routine. */
|
---|
100 | void cleanupContents();
|
---|
101 | /** Cleanup routine. */
|
---|
102 | void cleanup();
|
---|
103 |
|
---|
104 | /** Context-menu event handler. */
|
---|
105 | void contextMenuEvent(QContextMenuEvent *pEvent);
|
---|
106 |
|
---|
107 | /** Returns position for passed @a indicatorType. */
|
---|
108 | int indicatorPosition(IndicatorType indicatorType) const;
|
---|
109 |
|
---|
110 | /** Updates passed @a pIndicator with current @a state value. */
|
---|
111 | void updateIndicatorStateForDevice(QIStatusBarIndicator *pIndicator, KDeviceActivity state);
|
---|
112 |
|
---|
113 | /** Holds the UI session reference. */
|
---|
114 | UISession *m_pSession;
|
---|
115 | /** Holds whether status-bar is enabled. */
|
---|
116 | bool m_fEnabled;
|
---|
117 | /** Holds the cached restrictions. */
|
---|
118 | QList<IndicatorType> m_restrictions;
|
---|
119 | /** Holds the cached order. */
|
---|
120 | QList<IndicatorType> m_order;
|
---|
121 | /** Holds cached indicator instances. */
|
---|
122 | QMap<IndicatorType, QIStatusBarIndicator*> m_pool;
|
---|
123 | /** Holds the main-layout instance. */
|
---|
124 | QHBoxLayout *m_pMainLayout;
|
---|
125 | /** Holds the auto-update timer instance. */
|
---|
126 | QTimer *m_pTimerAutoUpdate;
|
---|
127 | };
|
---|
128 |
|
---|
129 | #endif /* !FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h */
|
---|
130 |
|
---|