VirtualBox

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

Last change on this file since 69500 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: QIStatusBarIndicator.h 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - QIStatusBarIndicator interface declaration.
4 */
5
6/*
7 * Copyright (C) 2006-2017 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 <QWidget>
23#include <QMap>
24#include <QIcon>
25
26/* Forward declarations: */
27class QLabel;
28
29/** QWidget extension used as status-bar indicator. */
30class QIStatusBarIndicator : public QWidget
31{
32 Q_OBJECT;
33
34signals:
35
36 /** Notifies about mouse-double-click-event: */
37 void sigMouseDoubleClick(QIStatusBarIndicator *pIndicator, QMouseEvent *pEvent);
38 /** Notifies about context-menu-request-event: */
39 void sigContextMenuRequest(QIStatusBarIndicator *pIndicator, QContextMenuEvent *pEvent);
40
41public:
42
43 /** Constructor, passes @a pParent to the QWidget constructor. */
44 QIStatusBarIndicator(QWidget *pParent = 0);
45
46 /** Returns size-hint. */
47 virtual QSize sizeHint() const { return m_size.isValid() ? m_size : QWidget::sizeHint(); }
48
49protected:
50
51#ifdef VBOX_WS_MAC
52 /** Mac OS X: Mouse-press-event handler.
53 * Make the left button also show the context-menu to make things
54 * simpler for users with single mouse button mice (laptops++). */
55 virtual void mousePressEvent(QMouseEvent *pEvent);
56#endif /* VBOX_WS_MAC */
57 /** Mouse-double-click-event handler. */
58 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent);
59 /** Context-menu-event handler. */
60 virtual void contextMenuEvent(QContextMenuEvent *pEvent);
61
62 /** Holds currently cached size. */
63 QSize m_size;
64};
65
66/** QIStatusBarIndicator extension used as status-bar state indicator. */
67class QIStateStatusBarIndicator : public QIStatusBarIndicator
68{
69 Q_OBJECT;
70
71public:
72
73 /** Constructor, passes @a pParent to the QIStatusBarIndicator constructor. */
74 QIStateStatusBarIndicator(QWidget *pParent = 0);
75
76 /** Returns current state. */
77 int state() const { return m_iState; }
78
79 /** Returns state-icon for passed @a iState. */
80 QIcon stateIcon(int iState) const;
81 /** Defines state-icon for passed @a iState as @a icon. */
82 void setStateIcon(int iState, const QIcon &icon);
83
84public slots:
85
86 /** Defines int @a state. */
87 virtual void setState(int iState) { m_iState = iState; repaint(); }
88 /** Defines bool @a state. */
89 void setState(bool fState) { setState((int)fState); }
90
91protected:
92
93 /** Paint-event handler. */
94 virtual void paintEvent(QPaintEvent *pEvent);
95
96 /** Draw-contents routine. */
97 virtual void drawContents(QPainter *pPainter);
98
99private:
100
101 /** Holds current state. */
102 int m_iState;
103 /** Holds cached state icons. */
104 QMap<int, QIcon> m_icons;
105};
106
107/** QIStatusBarIndicator extension used as status-bar state indicator. */
108class QITextStatusBarIndicator : public QIStatusBarIndicator
109{
110 Q_OBJECT;
111
112public:
113
114 /** Constructor, passes @a pParent to the QIStatusBarIndicator constructor. */
115 QITextStatusBarIndicator(QWidget *pParent = 0);
116
117 /** Returns text. */
118 QString text() const;
119 /** Defines @a strText. */
120 void setText(const QString &strText);
121
122private:
123
124 /** Holds the label instance. */
125 QLabel *m_pLabel;
126};
127
128#endif /* !___QIStatusBarIndicators_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