VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStatusBarIndicator.h

Last change on this file was 103977, checked in by vboxsync, 2 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use