VirtualBox

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

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use