VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupBox.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use