VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.h@ 103977

Last change on this file since 103977 was 103977, checked in by vboxsync, 9 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.3 KB
Line 
1/* $Id: UINotificationObject.h 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINotificationObject 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_UINotificationObject_h
29#define FEQT_INCLUDED_SRC_notificationcenter_UINotificationObject_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36
37/* GUI includes: */
38#include "UILibraryDefs.h"
39
40/* COM includes: */
41#include "CProgress.h"
42
43/* Forward declarations: */
44class UINotificationProgressTask;
45#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
46class UIDownloader;
47class UINewVersionChecker;
48#endif
49
50/** QObject-based notification-object. */
51class SHARED_LIBRARY_STUFF UINotificationObject : public QObject
52{
53 Q_OBJECT;
54
55signals:
56
57 /** Notifies model about closing.
58 * @param fDismiss Brings whether message closed as dismissed. */
59 void sigAboutToClose(bool fDismiss);
60
61public:
62
63 /** Constructs notification-object. */
64 UINotificationObject();
65
66 /** Returns whether object is critical. */
67 virtual bool isCritical() const = 0;
68 /** Returns whether object is done. */
69 virtual bool isDone() const = 0;
70 /** Returns object name. */
71 virtual QString name() const = 0;
72 /** Returns object details. */
73 virtual QString details() const = 0;
74 /** Returns object internal name. */
75 virtual QString internalName() const = 0;
76 /** Returns object help keyword. */
77 virtual QString helpKeyword() const = 0;
78 /** Handles notification-object being added. */
79 virtual void handle() = 0;
80
81public slots:
82
83 /** Notifies model about dismissing. */
84 virtual void dismiss();
85 /** Notifies model about closing. */
86 virtual void close();
87};
88
89/** UINotificationObject extension for notification-simple. */
90class SHARED_LIBRARY_STUFF UINotificationSimple : public UINotificationObject
91{
92 Q_OBJECT;
93
94protected:
95
96 /** Constructs notification-simple.
97 * @param strName Brings the message name.
98 * @param strDetails Brings the message details.
99 * @param strInternalName Brings the message internal name.
100 * @param strHelpKeyword Brings the message help keyword.
101 * @param fCritical Brings whether message is critical. */
102 UINotificationSimple(const QString &strName,
103 const QString &strDetails,
104 const QString &strInternalName,
105 const QString &strHelpKeyword,
106 bool fCritical = true);
107
108 /** Returns whether object is critical. */
109 virtual bool isCritical() const RT_OVERRIDE;
110 /** Returns whether object is done. */
111 virtual bool isDone() const RT_OVERRIDE;
112 /** Returns object name. */
113 virtual QString name() const RT_OVERRIDE RT_FINAL;
114 /** Returns object details. */
115 virtual QString details() const RT_OVERRIDE RT_FINAL;
116 /** Returns object internal name. */
117 virtual QString internalName() const RT_OVERRIDE RT_FINAL;
118 /** Returns object help keyword. */
119 virtual QString helpKeyword() const RT_OVERRIDE RT_FINAL;
120 /** Handles notification-object being added. */
121 virtual void handle() RT_OVERRIDE RT_FINAL;
122
123 /** Returns whether message with passed @a strInternalName is suppressed. */
124 static bool isSuppressed(const QString &strInternalName);
125
126private:
127
128 /** Holds the message name. */
129 QString m_strName;
130 /** Holds the message details. */
131 QString m_strDetails;
132 /** Holds the message internal name. */
133 QString m_strInternalName;
134 /** Holds the message help keyword. */
135 QString m_strHelpKeyword;
136 /** Holds whether message is critical. */
137 bool m_fCritical;
138};
139
140/** UINotificationObject extension for notification-progress. */
141class SHARED_LIBRARY_STUFF UINotificationProgress : public UINotificationObject
142{
143 Q_OBJECT;
144
145signals:
146
147 /** Notifies listeners about progress started. */
148 void sigProgressStarted();
149 /** Notifies listeners about progress changed.
150 * @param uPercent Brings new progress percentage value. */
151 void sigProgressChange(ulong uPercent);
152 /** Notifies listeners about progress finished. */
153 void sigProgressFinished();
154
155public:
156
157 /** Constructs notification-progress. */
158 UINotificationProgress();
159 /** Destructs notification-progress. */
160 virtual ~UINotificationProgress() /* override final */;
161
162 /** Creates and returns started progress-wrapper. */
163 virtual CProgress createProgress(COMResult &comResult) = 0;
164
165 /** Returns current progress percentage value. */
166 ulong percent() const;
167 /** Returns whether progress is cancelable. */
168 bool isCancelable() const;
169 /** Returns error-message if any. */
170 QString error() const;
171
172 /** Returns whether object is critical. */
173 virtual bool isCritical() const RT_OVERRIDE;
174 /** Returns whether object is done. */
175 virtual bool isDone() const RT_OVERRIDE;
176 /** Returns object internal name. */
177 virtual QString internalName() const RT_OVERRIDE RT_FINAL;
178 /** Returns object help keyword. */
179 virtual QString helpKeyword() const RT_OVERRIDE RT_FINAL;
180 /** Handles notification-object being added. */
181 virtual void handle() RT_OVERRIDE RT_FINAL;
182
183public slots:
184
185 /** Stops the progress and notifies model about closing. */
186 virtual void close() RT_OVERRIDE RT_FINAL;
187
188private slots:
189
190 /** Handles signal about progress changed.
191 * @param uPercent Brings new progress percentage value. */
192 void sltHandleProgressChange(ulong uPercent);
193 /** Handles signal about progress finished. */
194 void sltHandleProgressFinished();
195
196private:
197
198 /** Holds the instance of progress-task being wrapped by this notification-progress. */
199 UINotificationProgressTask *m_pTask;
200
201 /** Holds the last cached progress percentage value. */
202 ulong m_uPercent;
203 /** Holds whether current progress is done. */
204 bool m_fDone;
205};
206
207#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
208/** UINotificationObject extension for notification-downloader. */
209class SHARED_LIBRARY_STUFF UINotificationDownloader : public UINotificationObject
210{
211 Q_OBJECT;
212
213signals:
214
215 /** Notifies listeners about progress started. */
216 void sigProgressStarted();
217 /** Notifies listeners about progress changed.
218 * @param uPercent Brings new progress percentage value. */
219 void sigProgressChange(ulong uPercent);
220 /** Notifies listeners about progress failed. */
221 void sigProgressFailed();
222 /** Notifies listeners about progress canceled. */
223 void sigProgressCanceled();
224 /** Notifies listeners about progress finished. */
225 void sigProgressFinished();
226
227public:
228
229 /** Constructs notification-downloader. */
230 UINotificationDownloader();
231 /** Destructs notification-downloader. */
232 virtual ~UINotificationDownloader() /* override final */;
233
234 /** Creates and returns started downloader-wrapper. */
235 virtual UIDownloader *createDownloader() = 0;
236
237 /** Returns current progress percentage value. */
238 ulong percent() const;
239 /** Returns error-message if any. */
240 QString error() const;
241
242 /** Returns whether object is critical. */
243 virtual bool isCritical() const RT_OVERRIDE;
244 /** Returns whether object is done. */
245 virtual bool isDone() const RT_OVERRIDE;
246 /** Returns object internal name. */
247 virtual QString internalName() const RT_OVERRIDE RT_FINAL;
248 /** Returns object help keyword. */
249 virtual QString helpKeyword() const RT_OVERRIDE RT_FINAL;
250 /** Handles notification-object being added. */
251 virtual void handle() RT_OVERRIDE RT_FINAL;
252
253public slots:
254
255 /** Stops the downloader and notifies model about closing. */
256 virtual void close() RT_OVERRIDE RT_FINAL;
257
258private slots:
259
260 /** Handles signal about progress changed.
261 * @param uPercent Brings new progress percentage value. */
262 void sltHandleProgressChange(ulong uPercent);
263 /** Handles signal about progress failed.
264 * @param strError Brings error message if any. */
265 void sltHandleProgressFailed(const QString &strError);
266 /** Handles signal about progress canceled. */
267 void sltHandleProgressCanceled();
268 /** Handles signal about progress finished. */
269 void sltHandleProgressFinished();
270
271private:
272
273 /** Holds the instance of downloader being wrapped by this notification-downloader. */
274 UIDownloader *m_pDownloader;
275
276 /** Holds the last cached progress percentage value. */
277 ulong m_uPercent;
278 /** Holds the error message is any. */
279 QString m_strError;
280 /** Holds whether current progress is done. */
281 bool m_fDone;
282};
283#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
284
285#endif /* !FEQT_INCLUDED_SRC_notificationcenter_UINotificationObject_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