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