VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/UINativeWizard.h@ 104158

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

FE/Qt: Fixing build (oone more place as in r162426).

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