1 | /* $Id: QIStatusBarIndicator.h 105327 2024-07-15 14:48:33Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - Qt extensions: QIStatusBarIndicator interface declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_extensions_QIStatusBarIndicator_h
|
---|
29 | #define FEQT_INCLUDED_SRC_extensions_QIStatusBarIndicator_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QIcon>
|
---|
36 | #include <QMap>
|
---|
37 | #include <QSize>
|
---|
38 | #include <QWidget>
|
---|
39 |
|
---|
40 | /* GUI includes: */
|
---|
41 | #include "UILibraryDefs.h"
|
---|
42 |
|
---|
43 | /* Forward declarations: */
|
---|
44 | class QLabel;
|
---|
45 |
|
---|
46 |
|
---|
47 | /** QWidget extension used as status-bar indicator. */
|
---|
48 | class SHARED_LIBRARY_STUFF QIStatusBarIndicator : public QWidget
|
---|
49 | {
|
---|
50 | Q_OBJECT;
|
---|
51 |
|
---|
52 | signals:
|
---|
53 |
|
---|
54 | /** Notifies about mouse-double-click-event: */
|
---|
55 | void sigMouseDoubleClick(QIStatusBarIndicator *pIndicator, QMouseEvent *pEvent);
|
---|
56 | /** Notifies about context-menu-request-event: */
|
---|
57 | void sigContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent);
|
---|
58 |
|
---|
59 | public:
|
---|
60 |
|
---|
61 | /** Constructs status-bar indicator passing @a pParent to the base-class. */
|
---|
62 | QIStatusBarIndicator(QWidget *pParent = 0);
|
---|
63 |
|
---|
64 | /** Returns size-hint. */
|
---|
65 | virtual QSize sizeHint() const RT_OVERRIDE { return m_size.isValid() ? m_size : QWidget::sizeHint(); }
|
---|
66 |
|
---|
67 | protected:
|
---|
68 |
|
---|
69 | #ifdef VBOX_WS_MAC
|
---|
70 | /** Handles mouse-press @a pEvent. */
|
---|
71 | virtual void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
72 | #endif /* VBOX_WS_MAC */
|
---|
73 | /** Handles mouse-double-click @a pEvent. */
|
---|
74 | virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) RT_OVERRIDE;
|
---|
75 |
|
---|
76 | /** Handles context-menu @a pEvent. */
|
---|
77 | virtual void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
|
---|
78 |
|
---|
79 | /** Holds currently cached size. */
|
---|
80 | QSize m_size;
|
---|
81 | };
|
---|
82 |
|
---|
83 |
|
---|
84 | /** QIStatusBarIndicator extension used as status-bar state indicator. */
|
---|
85 | class SHARED_LIBRARY_STUFF QIStateStatusBarIndicator : public QIStatusBarIndicator
|
---|
86 | {
|
---|
87 | Q_OBJECT;
|
---|
88 |
|
---|
89 | public:
|
---|
90 |
|
---|
91 | /** Constructs state status-bar indicator passing @a pParent to the base-class. */
|
---|
92 | QIStateStatusBarIndicator(QWidget *pParent = 0);
|
---|
93 |
|
---|
94 | /** Returns current state. */
|
---|
95 | int state() const { return m_iState; }
|
---|
96 |
|
---|
97 | /** Returns state-icon for passed @a iState. */
|
---|
98 | QIcon stateIcon(int iState) const;
|
---|
99 | /** Defines state-icon for passed @a iState as @a icon. */
|
---|
100 | void setStateIcon(int iState, const QIcon &icon);
|
---|
101 |
|
---|
102 | public slots:
|
---|
103 |
|
---|
104 | /** Defines int @a iState. */
|
---|
105 | virtual void setState(int iState) { m_iState = iState; repaint(); }
|
---|
106 |
|
---|
107 | protected:
|
---|
108 |
|
---|
109 | /** Handles paint @a pEvent. */
|
---|
110 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
|
---|
111 |
|
---|
112 | /** Draws contents using passed @a pPainter. */
|
---|
113 | virtual void drawContents(QPainter *pPainter);
|
---|
114 |
|
---|
115 | private:
|
---|
116 |
|
---|
117 | /** Holds current state. */
|
---|
118 | int m_iState;
|
---|
119 | /** Holds cached state icons. */
|
---|
120 | QMap<int, QIcon> m_icons;
|
---|
121 | };
|
---|
122 |
|
---|
123 |
|
---|
124 | /** QIStatusBarIndicator extension used as status-bar text indicator. */
|
---|
125 | class SHARED_LIBRARY_STUFF QITextStatusBarIndicator : public QIStatusBarIndicator
|
---|
126 | {
|
---|
127 | Q_OBJECT;
|
---|
128 |
|
---|
129 | public:
|
---|
130 |
|
---|
131 | /** Constructs text status-bar indicator passing @a pParent to the base-class. */
|
---|
132 | QITextStatusBarIndicator(QWidget *pParent = 0);
|
---|
133 |
|
---|
134 | /** Returns text. */
|
---|
135 | QString text() const;
|
---|
136 | /** Defines @a strText. */
|
---|
137 | void setText(const QString &strText);
|
---|
138 |
|
---|
139 | private:
|
---|
140 |
|
---|
141 | /** Holds the label instance. */
|
---|
142 | QLabel *m_pLabel;
|
---|
143 | };
|
---|
144 |
|
---|
145 |
|
---|
146 | #endif /* !FEQT_INCLUDED_SRC_extensions_QIStatusBarIndicator_h */
|
---|