VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.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: 5.6 KB
Line 
1/* $Id: UIPopupBox.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIPopupBox/UIPopupBoxGroup classes declaration.
4 */
5
6/*
7 * Copyright (C) 2010-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_widgets_UIPopupBox_h
19#define FEQT_INCLUDED_SRC_widgets_UIPopupBox_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QIcon>
26#include <QWidget>
27
28/* GUI includes: */
29#include "UILibraryDefs.h"
30
31/* Forward declarations: */
32class QEvent;
33class QIcon;
34class QLabel;
35class QMouseEvent;
36class QObject;
37class QPainterPath;
38class QPaintEvent;
39class QResizeEvent;
40class QString;
41class QWidget;
42
43
44/** QWidget extension,
45 * wrapping content-widget with nice collapsable frame. */
46class SHARED_LIBRARY_STUFF UIPopupBox : public QWidget
47{
48 Q_OBJECT;
49
50signals:
51
52 /** Notifies about title with @a strLink was clicked. */
53 void sigTitleClicked(const QString &strLink);
54
55 /** Notifies box was toggled and currently @a fOpened. */
56 void sigToggled(bool fOpened);
57
58 /** Asks to update contents widget. */
59 void sigUpdateContentWidget();
60
61 /** Notify about box is hovered. */
62 void sigGotHover();
63
64public:
65
66 /** Construct popup-box passing @a pParent to the base-class. */
67 UIPopupBox(QWidget *pParent);
68 /** Destruct popup-box. */
69 virtual ~UIPopupBox() /* override */;
70
71 /** Defines title @a icon. */
72 void setTitleIcon(const QIcon &icon);
73 /** Returns title icon. */
74 QIcon titleIcon() const;
75
76 /** Defines warning @a icon. */
77 void setWarningIcon(const QIcon &icon);
78 /** Returns warnings icon. */
79 QIcon warningIcon() const;
80
81 /** Defines @a strTitle. */
82 void setTitle(const QString &strTitle);
83 /** Returns title. */
84 QString title() const;
85
86 /** Defines title @a strLink. */
87 void setTitleLink(const QString &strLink);
88 /** Returns title link. */
89 QString titleLink() const;
90 /** Defines whether title link is @a fEnabled. */
91 void setTitleLinkEnabled(bool fEnabled);
92 /** Returns whether title link is enabled. */
93 bool isTitleLinkEnabled() const;
94
95 /** Defines content @a pWidget. */
96 void setContentWidget(QWidget *pWidget);
97 /** Returns content widget. */
98 QWidget *contentWidget() const;
99
100 /** Defines whether box is @a fOpened. */
101 void setOpen(bool fOpened);
102 /** Toggles current opened state. */
103 void toggleOpen();
104 /** Returns whether box is opened. */
105 bool isOpen() const;
106
107 /** Calls for content iwdget update. */
108 void callForUpdateContentWidget() { emit sigUpdateContentWidget(); }
109
110protected:
111
112 /** Handles any Qt @a pEvent. */
113 virtual bool event(QEvent *pEvent) /* override */;
114
115 /** Pre-handles standard Qt @a pEvent for passed @a pObject. */
116 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
117
118 /** Handles resize @a pEvent. */
119 virtual void resizeEvent(QResizeEvent *pEvent) /* override */;
120
121 /** Handles paint @a pEvent. */
122 virtual void paintEvent(QPaintEvent *pEvent) /* override */;
123
124 /** Handles mouse double-click @a pEvent. */
125 virtual void mouseDoubleClickEvent(QMouseEvent *pEvent) /* override */;
126
127private:
128
129 /** Updates title icon. */
130 void updateTitleIcon();
131 /** Updates warning icon. */
132 void updateWarningIcon();
133 /** Updates title. */
134 void updateTitle();
135 /** Updates hovered state. */
136 void updateHover();
137 /** Revokes hovered state. */
138 void revokeHover();
139 /** Toggles hovered state to @a fHeaderHover. */
140 void toggleHover(bool fHeaderHover);
141 /** Recalculates geometry. */
142 void recalc();
143
144 /** Holds the title icon label. */
145 QLabel *m_pTitleIcon;
146 /** Holds the warning icon label. */
147 QLabel *m_pWarningIcon;
148 /** Holds the title label. */
149 QLabel *m_pTitleLabel;
150
151 /** Holds the title icon. */
152 QIcon m_titleIcon;
153 /** Holds the warning icon. */
154 QIcon m_warningIcon;
155 /** Holds the title text. */
156 QString m_strTitle;
157 /** Holds the link icon. */
158 QString m_strLink;
159
160 /** Holds whether the link is enabled. */
161 bool m_fLinkEnabled : 1;
162 /** Holds whether box is opened. */
163 bool m_fOpened : 1;
164 /** Holds whether header is hovered. */
165 bool m_fHovered : 1;
166
167 /** Holds the content widget. */
168 QWidget *m_pContentWidget;
169
170 /** Holds the label painter path. */
171 QPainterPath *m_pLabelPath;
172
173 /** Holds the arrow width. */
174 const int m_iArrowWidth;
175 /** Holds the arrow painter-path. */
176 QPainterPath m_arrowPath;
177
178 /** Allow popup-box group to access private API. */
179 friend class UIPopupBoxGroup;
180};
181
182
183/** QObject extension,
184 * provides a container to organize groups of popup-boxes. */
185class SHARED_LIBRARY_STUFF UIPopupBoxGroup : public QObject
186{
187 Q_OBJECT;
188
189public:
190
191 /** Construct popup-box passing @a pParent to the base-class. */
192 UIPopupBoxGroup(QObject *pParent);
193 /** Destruct popup-box. */
194 virtual ~UIPopupBoxGroup() /* override */;
195
196 /** Adds @a pPopupBox into group. */
197 void addPopupBox(UIPopupBox *pPopupBox);
198
199private slots:
200
201 /** Handles group hovering. */
202 void sltHoverChanged();
203
204private:
205
206 /** Holds the list of popup-boxes. */
207 QList<UIPopupBox*> m_list;
208};
209
210
211#endif /* !FEQT_INCLUDED_SRC_widgets_UIPopupBox_h */
212
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use