VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.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: 7.3 KB
Line 
1/* $Id: UINativeWizard.h 103977 2024-03-21 02:04:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINativeWizard class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-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_wizards_UINativeWizard_h
29#define FEQT_INCLUDED_SRC_wizards_UINativeWizard_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QDialog>
36#include <QMap>
37#include <QPointer>
38
39/* GUI includes: */
40#include "UIExtraDataDefs.h"
41#include "UILibraryDefs.h"
42
43/* Forward declarations: */
44class QLabel;
45class QPushButton;
46class QStackedWidget;
47class QVBoxLayout;
48class UINativeWizardPage;
49class UINotificationCenter;
50class UINotificationProgress;
51
52/** Native wizard buttons. */
53enum WizardButtonType
54{
55 WizardButtonType_Invalid,
56 WizardButtonType_Help,
57 WizardButtonType_Expert,
58 WizardButtonType_Back,
59 WizardButtonType_Next,
60 WizardButtonType_Cancel,
61 WizardButtonType_Max,
62};
63Q_DECLARE_METATYPE(WizardButtonType);
64
65#ifdef VBOX_WS_MAC
66/** QWidget-based QFrame analog with one particular purpose to
67 * simulate macOS wizard frame without influencing palette hierarchy. */
68class SHARED_LIBRARY_STUFF UIFrame : public QWidget
69{
70 Q_OBJECT;
71
72public:
73
74 /** Constructs UIFrame passing @a pParent to the base-class. */
75 UIFrame(QWidget *pParent);
76
77protected:
78
79 /** Handles paint @a pEvent. */
80 virtual void paintEvent(QPaintEvent *pEvent) /* final */;
81};
82#endif /* VBOX_WS_MAC */
83
84/** QDialog extension with advanced functionality emulating QWizard behavior. */
85class SHARED_LIBRARY_STUFF UINativeWizard : public QDialog
86{
87 Q_OBJECT;
88
89signals:
90
91 /** Notifies listeners about dialog should be closed. */
92 void sigClose(WizardType enmType);
93
94public:
95
96 /** Constructs wizard passing @a pParent to the base-class.
97 * @param enmType Brings the wizard type.
98 * @param enmMode Brings the wizard mode.
99 * @param strHelpKeyword Brings the wizard help keyword. */
100 UINativeWizard(QWidget *pParent,
101 WizardType enmType,
102 WizardMode enmMode = WizardMode_Auto,
103 const QString &strHelpKeyword = QString());
104 /** Destructs wizard. */
105 virtual ~UINativeWizard() RT_OVERRIDE;
106
107 /** Returns local notification-center reference. */
108 UINotificationCenter *notificationCenter() const;
109 /** Immediately handles notification @a pProgress object. */
110 bool handleNotificationProgressNow(UINotificationProgress *pProgress);
111
112 /** Returns wizard button of specified @a enmType. */
113 QPushButton *wizardButton(const WizardButtonType &enmType) const;
114
115public slots:
116
117 /** Executes wizard in window modal mode.
118 * @note You shouldn't have to override it! */
119 virtual int exec() RT_OVERRIDE RT_FINAL;
120 /** Shows wizard in non-mode.
121 * @note You shouldn't have to override it! */
122 virtual void show() /* final */;
123
124protected:
125
126 /** Returns wizard type. */
127 WizardType type() const { return m_enmType; }
128 /** Returns wizard mode. */
129 WizardMode mode() const { return m_enmMode; }
130 /** Defines @a strName for wizard button of specified @a enmType. */
131 void setWizardButtonName(const WizardButtonType &enmType, const QString &strName);
132
133 /** Defines pixmap @a strName. */
134 void setPixmapName(const QString &strName);
135
136 /** Returns whether the page with certain @a iIndex is visible. */
137 bool isPageVisible(int iIndex) const;
138 /** Defines whether the page with certain @a iIndex is @a fVisible. */
139 void setPageVisible(int iIndex, bool fVisible);
140
141 /** Appends wizard @a pPage.
142 * @returns assigned page index. */
143 int addPage(UINativeWizardPage *pPage);
144 /** Populates pages.
145 * @note In your subclasses you should add
146 * pages via addPage declared above. */
147 virtual void populatePages() = 0;
148
149 /** Handles key-press @a pEvent. */
150 virtual void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
151 /** Handles close @a pEvent. */
152 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
153
154 /** Performs wizard-specific cleanup in case of wizard-mode change
155 * such as folder deletion in New VM wizard etc. */
156 virtual void cleanWizard() {}
157
158protected slots:
159 /** Handles translation event. */
160 virtual void sltRetranslateUI();
161
162private slots:
163
164 /** Handles current-page change to page with @a iIndex. */
165 void sltCurrentIndexChanged(int iIndex = -1);
166 /** Handles page validity changes. */
167 void sltCompleteChanged();
168
169 /** Toggles between basic and expert modes. */
170 void sltExpert();
171 /** Switches to previous page. */
172 void sltPrevious();
173 /** Switches to next page. */
174 void sltNext();
175
176 /** Handle help request*/
177 void sltHandleHelpRequest();
178
179private:
180
181 /** Prepares all. */
182 void prepare();
183 /** Cleanups all. */
184 void cleanup();
185 /** Inits all. */
186 void init();
187 /** Deinits all. */
188 void deinit();
189
190 /** Performs pages translation. */
191 void retranslatePages();
192
193 /** Resizes wizard to golden ratio. */
194 void resizeToGoldenRatio();
195#ifdef VBOX_WS_MAC
196 /** Assigns wizard background. */
197 void assignBackground();
198#else
199 /** Assigns wizard watermark. */
200 void assignWatermark();
201#endif
202 /** Checks if the pages coming after the page with iPageIndex is visible or not. Returns true if
203 * page with iPageIndex is the last visible page of the wizard. Returns false otherwise. */
204 bool isLastVisiblePage(int iPageIndex) const;
205
206 /** Holds the wizard type. */
207 WizardType m_enmType;
208 /** Holds the wizard mode. */
209 WizardMode m_enmMode;
210 /** Holds the wizard help keyword. */
211 QString m_strHelpKeyword;
212 /** Holds the pixmap name. */
213 QString m_strPixmapName;
214 /** Holds the last entered page index. */
215 int m_iLastIndex;
216 /** Holds the set of invisible pages. */
217 QSet<int> m_invisiblePages;
218 /** Holds whether the dialod had emitted signal to be closed. */
219 bool m_fClosed;
220
221 /** Holds the pixmap label instance. */
222 QLabel *m_pLabelPixmap;
223 /** Holds the right layout instance. */
224 QVBoxLayout *m_pLayoutRight;
225 /** Holds the title label instance. */
226 QLabel *m_pLabelPageTitle;
227 /** Holds the widget-stack instance. */
228 QStackedWidget *m_pWidgetStack;
229 /** Holds button instance map. */
230 QMap<WizardButtonType, QPushButton*> m_buttons;
231
232 /** Holds the local notification-center instance. */
233 UINotificationCenter *m_pNotificationCenter;
234};
235
236/** Native wizard interface pointer. */
237typedef QPointer<UINativeWizard> UINativeWizardPointer;
238
239#endif /* !FEQT_INCLUDED_SRC_wizards_UINativeWizard_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