1 | /* $Id: UINativeWizard.h 93990 2022-02-28 15:34:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UINativeWizard class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef FEQT_INCLUDED_SRC_wizards_UINativeWizard_h
|
---|
19 | #define FEQT_INCLUDED_SRC_wizards_UINativeWizard_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QMap>
|
---|
26 | #include <QPointer>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIWithRetranslateUI.h"
|
---|
30 | #include "UIExtraDataDefs.h"
|
---|
31 | #include "UILibraryDefs.h"
|
---|
32 |
|
---|
33 | /* Forward declarations: */
|
---|
34 | class QLabel;
|
---|
35 | class QPushButton;
|
---|
36 | class QStackedWidget;
|
---|
37 | class QVBoxLayout;
|
---|
38 | class UINativeWizardPage;
|
---|
39 | class UINotificationCenter;
|
---|
40 | class UINotificationProgress;
|
---|
41 |
|
---|
42 | /** Native wizard buttons. */
|
---|
43 | enum WizardButtonType
|
---|
44 | {
|
---|
45 | WizardButtonType_Invalid,
|
---|
46 | WizardButtonType_Help,
|
---|
47 | WizardButtonType_Expert,
|
---|
48 | WizardButtonType_Back,
|
---|
49 | WizardButtonType_Next,
|
---|
50 | WizardButtonType_Cancel,
|
---|
51 | WizardButtonType_Max,
|
---|
52 | };
|
---|
53 | Q_DECLARE_METATYPE(WizardButtonType);
|
---|
54 |
|
---|
55 | #ifdef VBOX_WS_MAC
|
---|
56 | /** QWidget-based QFrame analog with one particular purpose to
|
---|
57 | * simulate macOS wizard frame without influencing palette hierarchy. */
|
---|
58 | class SHARED_LIBRARY_STUFF UIFrame : public QWidget
|
---|
59 | {
|
---|
60 | Q_OBJECT;
|
---|
61 |
|
---|
62 | public:
|
---|
63 |
|
---|
64 | /** Constructs UIFrame passing @a pParent to the base-class. */
|
---|
65 | UIFrame(QWidget *pParent);
|
---|
66 |
|
---|
67 | protected:
|
---|
68 |
|
---|
69 | /** Handles paint @a pEvent. */
|
---|
70 | virtual void paintEvent(QPaintEvent *pEvent) /* final */;
|
---|
71 | };
|
---|
72 | #endif /* VBOX_WS_MAC */
|
---|
73 |
|
---|
74 | /** QDialog extension with advanced functionality emulating QWizard behavior. */
|
---|
75 | class SHARED_LIBRARY_STUFF UINativeWizard : public QIWithRetranslateUI<QDialog>
|
---|
76 | {
|
---|
77 | Q_OBJECT;
|
---|
78 |
|
---|
79 | public:
|
---|
80 |
|
---|
81 | /** Constructs wizard passing @a pParent to the base-class.
|
---|
82 | * @param enmType Brings the wizard type.
|
---|
83 | * @param enmMode Brings the wizard mode.
|
---|
84 | * @param strHelpHashtag Brings the wizard help hashtag. */
|
---|
85 | UINativeWizard(QWidget *pParent,
|
---|
86 | WizardType enmType,
|
---|
87 | WizardMode enmMode = WizardMode_Auto,
|
---|
88 | const QString &strHelpHashtag = QString());
|
---|
89 | /** Destructs wizard. */
|
---|
90 | virtual ~UINativeWizard() RT_OVERRIDE;
|
---|
91 |
|
---|
92 | /** Returns local notification-center reference. */
|
---|
93 | UINotificationCenter *notificationCenter() const;
|
---|
94 | /** Immediately handles notification @a pProgress object. */
|
---|
95 | bool handleNotificationProgressNow(UINotificationProgress *pProgress);
|
---|
96 |
|
---|
97 | public slots:
|
---|
98 |
|
---|
99 | /** Executes wizard in window modal mode.
|
---|
100 | * @note You shouldn't have to override it! */
|
---|
101 | virtual int exec() /* final */;
|
---|
102 |
|
---|
103 | protected:
|
---|
104 |
|
---|
105 | /** Returns wizard type. */
|
---|
106 | WizardType type() const { return m_enmType; }
|
---|
107 | /** Returns wizard mode. */
|
---|
108 | WizardMode mode() const { return m_enmMode; }
|
---|
109 |
|
---|
110 | /** Returns wizard button of specified @a enmType. */
|
---|
111 | QPushButton *wizardButton(const WizardButtonType &enmType) const;
|
---|
112 | /** Defines @a strName for wizard button of specified @a enmType. */
|
---|
113 | void setWizardButtonName(const WizardButtonType &enmType, const QString &strName);
|
---|
114 |
|
---|
115 | /** Defines pixmap @a strName. */
|
---|
116 | void setPixmapName(const QString &strName);
|
---|
117 |
|
---|
118 | /** Returns whether the page with certain @a iIndex is visible. */
|
---|
119 | bool isPageVisible(int iIndex) const;
|
---|
120 | /** Defines whether the page with certain @a iIndex is @a fVisible. */
|
---|
121 | void setPageVisible(int iIndex, bool fVisible);
|
---|
122 |
|
---|
123 | /** Appends wizard @a pPage.
|
---|
124 | * @returns assigned page index. */
|
---|
125 | int addPage(UINativeWizardPage *pPage);
|
---|
126 | /** Populates pages.
|
---|
127 | * @note In your subclasses you should add
|
---|
128 | * pages via addPage declared above. */
|
---|
129 | virtual void populatePages() = 0;
|
---|
130 |
|
---|
131 | /** Handles translation event. */
|
---|
132 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
133 |
|
---|
134 | /** Performs wizard-specific cleanup in case of wizard-mode change
|
---|
135 | * such as folder deletion in New VM wizard etc. */
|
---|
136 | virtual void cleanWizard() {}
|
---|
137 |
|
---|
138 | private slots:
|
---|
139 |
|
---|
140 | /** Handles current-page change to page with @a iIndex. */
|
---|
141 | void sltCurrentIndexChanged(int iIndex = -1);
|
---|
142 | /** Handles page validity changes. */
|
---|
143 | void sltCompleteChanged();
|
---|
144 |
|
---|
145 | /** Toggles between basic and expert modes. */
|
---|
146 | void sltExpert();
|
---|
147 | /** Switches to previous page. */
|
---|
148 | void sltPrevious();
|
---|
149 | /** Switches to next page. */
|
---|
150 | void sltNext();
|
---|
151 |
|
---|
152 | private:
|
---|
153 |
|
---|
154 | /** Prepares all. */
|
---|
155 | void prepare();
|
---|
156 | /** Cleanups all. */
|
---|
157 | void cleanup();
|
---|
158 | /** Inits all. */
|
---|
159 | void init();
|
---|
160 | /** Deinits all. */
|
---|
161 | void deinit();
|
---|
162 |
|
---|
163 | /** Performs pages translation. */
|
---|
164 | void retranslatePages();
|
---|
165 |
|
---|
166 | /** Resizes wizard to golden ratio. */
|
---|
167 | void resizeToGoldenRatio();
|
---|
168 | #ifdef VBOX_WS_MAC
|
---|
169 | /** Assigns wizard background. */
|
---|
170 | void assignBackground();
|
---|
171 | #else
|
---|
172 | /** Assigns wizard watermark. */
|
---|
173 | void assignWatermark();
|
---|
174 | #endif
|
---|
175 | /** Checks if the pages coming after the page with iPageIndex is visible or not. Returns true if
|
---|
176 | * page with iPageIndex is the last visible page of the wizard. Returns false otherwise. */
|
---|
177 | bool isLastVisiblePage(int iPageIndex) const;
|
---|
178 |
|
---|
179 | /** Holds the wizard type. */
|
---|
180 | WizardType m_enmType;
|
---|
181 | /** Holds the wizard mode. */
|
---|
182 | WizardMode m_enmMode;
|
---|
183 | /** Holds the wizard help hashtag. */
|
---|
184 | QString m_strHelpHashtag;
|
---|
185 | /** Holds the pixmap name. */
|
---|
186 | QString m_strPixmapName;
|
---|
187 | /** Holds the last entered page index. */
|
---|
188 | int m_iLastIndex;
|
---|
189 | /** Holds the set of invisible pages. */
|
---|
190 | QSet<int> m_invisiblePages;
|
---|
191 |
|
---|
192 | /** Holds the pixmap label instance. */
|
---|
193 | QLabel *m_pLabelPixmap;
|
---|
194 | /** Holds the right layout instance. */
|
---|
195 | QVBoxLayout *m_pLayoutRight;
|
---|
196 | /** Holds the title label instance. */
|
---|
197 | QLabel *m_pLabelPageTitle;
|
---|
198 | /** Holds the widget-stack instance. */
|
---|
199 | QStackedWidget *m_pWidgetStack;
|
---|
200 | /** Holds button instance map. */
|
---|
201 | QMap<WizardButtonType, QPushButton*> m_buttons;
|
---|
202 |
|
---|
203 | /** Holds the local notification-center instance. */
|
---|
204 | UINotificationCenter *m_pNotificationCenter;
|
---|
205 | };
|
---|
206 |
|
---|
207 | /** Native wizard interface pointer. */
|
---|
208 | typedef QPointer<UINativeWizard> UINativeWizardPointer;
|
---|
209 |
|
---|
210 | #endif /* !FEQT_INCLUDED_SRC_wizards_UINativeWizard_h */
|
---|