1 | /* $Id: UINotificationObjectItem.h 103704 2024-03-06 15:15:36Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINotificationObjectItem class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-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_notificationcenter_UINotificationObjectItem_h
|
---|
29 | #define FEQT_INCLUDED_SRC_notificationcenter_UINotificationObjectItem_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QWidget>
|
---|
36 |
|
---|
37 | /* VBox includes: */
|
---|
38 | #include <iprt/cdefs.h> // for RT_OVERRIDE stuff
|
---|
39 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class QHBoxLayout;
|
---|
42 | class QLabel;
|
---|
43 | class QProgressBar;
|
---|
44 | class QVBoxLayout;
|
---|
45 | class QIRichTextLabel;
|
---|
46 | class QIToolButton;
|
---|
47 | class UINotificationObject;
|
---|
48 | class UINotificationProgress;
|
---|
49 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
50 | class UINotificationDownloader;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | /** QWidget-based notification-object item. */
|
---|
54 | class UINotificationObjectItem : public QWidget
|
---|
55 | {
|
---|
56 | Q_OBJECT;
|
---|
57 |
|
---|
58 | public:
|
---|
59 |
|
---|
60 | /** Constructs notification-object item, passing @a pParent to the base-class.
|
---|
61 | * @param pObject Brings the notification-object this item created for. */
|
---|
62 | UINotificationObjectItem(QWidget *pParent, UINotificationObject *pObject = 0);
|
---|
63 |
|
---|
64 | protected:
|
---|
65 |
|
---|
66 | /** Handles any Qt @a pEvent. */
|
---|
67 | virtual bool event(QEvent *pEvent) RT_OVERRIDE;
|
---|
68 |
|
---|
69 | /** Handles paint @a pEvent. */
|
---|
70 | virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
|
---|
71 |
|
---|
72 | /** Holds the notification-object this item created for. */
|
---|
73 | UINotificationObject *m_pObject;
|
---|
74 |
|
---|
75 | /** Holds the main layout instance. */
|
---|
76 | QVBoxLayout *m_pLayoutMain;
|
---|
77 | /** Holds the upper layout instance. */
|
---|
78 | QHBoxLayout *m_pLayoutUpper;
|
---|
79 | /** Holds the name label instance. */
|
---|
80 | QLabel *m_pLabelName;
|
---|
81 | /** Holds the help button instance. */
|
---|
82 | QIToolButton *m_pButtonHelp;
|
---|
83 | /** Holds the forget button instance. */
|
---|
84 | QIToolButton *m_pButtonForget;
|
---|
85 | /** Holds the close button instance. */
|
---|
86 | QIToolButton *m_pButtonClose;
|
---|
87 | /** Holds the details label instance. */
|
---|
88 | QIRichTextLabel *m_pLabelDetails;
|
---|
89 |
|
---|
90 | /** Holds whether item is hovered. */
|
---|
91 | bool m_fHovered;
|
---|
92 | /** Holds whether item is toggled. */
|
---|
93 | bool m_fToggled;
|
---|
94 |
|
---|
95 | private slots:
|
---|
96 |
|
---|
97 | /** Handles help request. */
|
---|
98 | void sltHandleHelpRequest();
|
---|
99 | };
|
---|
100 |
|
---|
101 | /** UINotificationObjectItem extension for notification-progress. */
|
---|
102 | class UINotificationProgressItem : public UINotificationObjectItem
|
---|
103 | {
|
---|
104 | Q_OBJECT;
|
---|
105 |
|
---|
106 | public:
|
---|
107 |
|
---|
108 | /** Constructs notification-progress item, passing @a pParent to the base-class.
|
---|
109 | * @param pProgress Brings the notification-progress this item created for. */
|
---|
110 | UINotificationProgressItem(QWidget *pParent, UINotificationProgress *pProgress = 0);
|
---|
111 |
|
---|
112 | private slots:
|
---|
113 |
|
---|
114 | /** Handles signal about progress started. */
|
---|
115 | void sltHandleProgressStarted();
|
---|
116 | /** Handles signal about progress changed.
|
---|
117 | * @param uPercent Brings new progress percentage value. */
|
---|
118 | void sltHandleProgressChange(ulong uPercent);
|
---|
119 | /** Handles signal about progress finished. */
|
---|
120 | void sltHandleProgressFinished();
|
---|
121 |
|
---|
122 | private:
|
---|
123 |
|
---|
124 | /** Holds the notification-progress this item created for. */
|
---|
125 | UINotificationProgress *progress() const;
|
---|
126 |
|
---|
127 | /** Updates details. */
|
---|
128 | void updateDetails();
|
---|
129 |
|
---|
130 | /** Holds the progress-bar instance. */
|
---|
131 | QProgressBar *m_pProgressBar;
|
---|
132 | };
|
---|
133 |
|
---|
134 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
135 | /** UINotificationObjectItem extension for notification-downloader. */
|
---|
136 | class UINotificationDownloaderItem : public UINotificationObjectItem
|
---|
137 | {
|
---|
138 | Q_OBJECT;
|
---|
139 |
|
---|
140 | public:
|
---|
141 |
|
---|
142 | /** Constructs notification-downloader item, passing @a pParent to the base-class.
|
---|
143 | * @param pDownloader Brings the notification-downloader this item created for. */
|
---|
144 | UINotificationDownloaderItem(QWidget *pParent, UINotificationDownloader *pDownloader = 0);
|
---|
145 |
|
---|
146 | private slots:
|
---|
147 |
|
---|
148 | /** Handles signal about progress started. */
|
---|
149 | void sltHandleProgressStarted();
|
---|
150 | /** Handles signal about progress changed.
|
---|
151 | * @param uPercent Brings new progress percentage value. */
|
---|
152 | void sltHandleProgressChange(ulong uPercent);
|
---|
153 | /** Handles signal about progress finished. */
|
---|
154 | void sltHandleProgressFinished();
|
---|
155 |
|
---|
156 | private:
|
---|
157 |
|
---|
158 | /** Holds the notification-downloader this item created for. */
|
---|
159 | UINotificationDownloader *downloader() const;
|
---|
160 |
|
---|
161 | /** Updates details. */
|
---|
162 | void updateDetails();
|
---|
163 |
|
---|
164 | /** Holds the progress-bar instance. */
|
---|
165 | QProgressBar *m_pProgressBar;
|
---|
166 | };
|
---|
167 | #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
|
---|
168 |
|
---|
169 | /** Notification-object factory. */
|
---|
170 | namespace UINotificationItem
|
---|
171 | {
|
---|
172 | /** Creates notification-object of required type.
|
---|
173 | * @param pParent Brings the parent constructed item being attached to.
|
---|
174 | * @param pObject Brings the notification-object item being constructed for. */
|
---|
175 | UINotificationObjectItem *create(QWidget *pParent, UINotificationObject *pObject);
|
---|
176 | }
|
---|
177 |
|
---|
178 | #endif /* !FEQT_INCLUDED_SRC_notificationcenter_UINotificationObjectItem_h */
|
---|