VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.h

Last change on this file was 106061, checked in by vboxsync, 4 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UIIndicatorsPool.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIIndicatorsPool class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h
29#define FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QWidget>
36#include <QMap>
37
38/* GUI includes: */
39#include "UIExtraDataDefs.h"
40
41/* COM includes: */
42#include "KDeviceActivity.h"
43
44/* Forward declarations: */
45class QTimer;
46class QHBoxLayout;
47class QIStatusBarIndicator;
48class UIMachine;
49
50/** QWidget extension
51 * providing Runtime UI with status-bar indicators. */
52class UIIndicatorsPool : public QWidget
53{
54 Q_OBJECT;
55
56signals:
57
58 /** Notifies about context menu request.
59 * @param indicatorType reflects which type of indicator it is,
60 * @param position reflects contex-menu position. */
61 void sigContextMenuRequest(IndicatorType indicatorType, const QPoint &position);
62
63public:
64
65 /** Constructs indicator-pool passing @a pParent to the base-class.
66 * @param pMachine Brings the machine UI reference. */
67 UIIndicatorsPool(UIMachine *pMachine, QWidget *pParent = 0);
68 /** Destructs indicator-pool. */
69 virtual ~UIIndicatorsPool() RT_OVERRIDE;
70
71 /** Updates appearance for passed @a indicatorType. */
72 void updateAppearance(IndicatorType indicatorType);
73
74 /** Defines whether indicator-states auto-update is @a fEnabled. */
75 void setAutoUpdateIndicatorStates(bool fEnabled);
76
77 /** Returns global screen position corresponding to @a indicatorPosition inside indicator of @a enmIndicatorType. */
78 QPoint mapIndicatorPositionToGlobal(IndicatorType enmIndicatorType, const QPoint &indicatorPosition);
79
80private slots:
81
82 /** Handles configuration change. */
83 void sltHandleConfigurationChange(const QUuid &uMachineID);
84
85 /** Handles indicator-states auto-update. */
86 void sltAutoUpdateIndicatorStates();
87
88 /** Handles context-menu request. */
89 void sltContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent);
90
91private:
92
93 /** Prepare routine. */
94 void prepare();
95 /** Prepare connections routine: */
96 void prepareConnections();
97 /** Prepare contents routine. */
98 void prepareContents();
99 /** Prepare update-timer routine: */
100 void prepareUpdateTimer();
101
102 /** Update pool routine. */
103 void updatePool();
104
105 /** Cleanup update-timer routine: */
106 void cleanupUpdateTimer();
107 /** Cleanup contents routine. */
108 void cleanupContents();
109 /** Cleanup routine. */
110 void cleanup();
111
112 /** Context-menu event handler. */
113 void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
114
115 /** Returns position for passed @a indicatorType. */
116 int indicatorPosition(IndicatorType indicatorType) const;
117
118 /** Updates passed @a pIndicator with current @a state value. */
119 void updateIndicatorStateForDevice(QIStatusBarIndicator *pIndicator, KDeviceActivity state);
120
121 /** Holds the machine UI reference. */
122 UIMachine *m_pMachine;
123
124 /** Holds whether status-bar is enabled. */
125 bool m_fEnabled;
126
127 /** Holds the cached restrictions. */
128 QList<IndicatorType> m_restrictions;
129 /** Holds the cached order. */
130 QList<IndicatorType> m_order;
131
132 /** Holds cached indicator instances. */
133 QMap<IndicatorType, QIStatusBarIndicator*> m_pool;
134
135 /** Holds the main-layout instance. */
136 QHBoxLayout *m_pMainLayout;
137
138 /** Holds the auto-update timer instance. */
139 QTimer *m_pTimerAutoUpdate;
140};
141
142#endif /* !FEQT_INCLUDED_SRC_runtime_UIIndicatorsPool_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette