VirtualBox

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

Last change on this file since 91877 was 91877, checked in by vboxsync, 3 years ago

FE/Qt: bugref:10067: UINotificationCenter: Make handleNow() return result value.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/* $Id: UINativeWizard.h 91877 2021-10-20 11:26:48Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINativeWizard class declaration.
4 */
5
6/*
7 * Copyright (C) 2009-2021 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: */
34class QLabel;
35class QProgressBar;
36class QPushButton;
37class QStackedWidget;
38class QVBoxLayout;
39class UINativeWizardPage;
40class UINotificationCenter;
41class UINotificationProgress;
42
43/** Native wizard buttons. */
44enum WizardButtonType
45{
46 WizardButtonType_Invalid,
47 WizardButtonType_Help,
48 WizardButtonType_Expert,
49 WizardButtonType_Back,
50 WizardButtonType_Next,
51 WizardButtonType_Cancel,
52 WizardButtonType_Max,
53};
54Q_DECLARE_METATYPE(WizardButtonType);
55
56#ifdef VBOX_WS_MAC
57/** QWidget-based QFrame analog with one particular purpose to
58 * simulate macOS wizard frame without influencing palette hierarchy. */
59class SHARED_LIBRARY_STUFF UIFrame : public QWidget
60{
61 Q_OBJECT;
62
63public:
64
65 /** Constructs UIFrame passing @a pParent to the base-class. */
66 UIFrame(QWidget *pParent);
67
68protected:
69
70 /** Handles paint @a pEvent. */
71 virtual void paintEvent(QPaintEvent *pEvent) /* final */;
72};
73#endif /* VBOX_WS_MAC */
74
75/** QDialog extension with advanced functionality emulating QWizard behavior. */
76class SHARED_LIBRARY_STUFF UINativeWizard : public QIWithRetranslateUI<QDialog>
77{
78 Q_OBJECT;
79
80public:
81
82 /** Immediately handles notification @a pProgress object. */
83 bool handleNotificationProgressNow(UINotificationProgress *pProgress);
84
85public slots:
86
87 /** Executes wizard in window modal mode.
88 * @note You shouldn't have to override it! */
89 virtual int exec() /* final */;
90
91protected:
92
93 /** Constructs wizard passing @a pParent to the base-class.
94 * @param enmType Brings the wizard type.
95 * @param enmMode Brings the wizard mode.
96 * @param strHelpHashtag Brings the wizard help hashtag. */
97 UINativeWizard(QWidget *pParent,
98 WizardType enmType,
99 WizardMode enmMode = WizardMode_Auto,
100 const QString &strHelpHashtag = QString());
101
102 /** Returns wizard type. */
103 WizardType type() const { return m_enmType; }
104 /** Returns wizard mode. */
105 WizardMode mode() const { return m_enmMode; }
106
107 /** Returns wizard button of specified @a enmType. */
108 QPushButton *wizardButton(const WizardButtonType &enmType) const;
109 /** Defines @a strName for wizard button of specified @a enmType. */
110 void setWizardButtonName(const WizardButtonType &enmType, const QString &strName);
111
112 /** Defines pixmap @a strName. */
113 void setPixmapName(const QString &strName);
114
115 /** Returns whether the page with certain @a iIndex is visible. */
116 bool isPageVisible(int iIndex) const;
117 /** Defines whether the page with certain @a iIndex is @a fVisible. */
118 void setPageVisible(int iIndex, bool fVisible);
119
120 /** Appends wizard @a pPage.
121 * @returns assigned page index. */
122 int addPage(UINativeWizardPage *pPage);
123 /** Populates pages.
124 * @note In your subclasses you should add
125 * pages via addPage declared above. */
126 virtual void populatePages() = 0;
127
128 /** Handles translation event. */
129 virtual void retranslateUi() /* override */;
130
131 /** Wizard specific cleaning such as folder deletion in case of wizard mode change in new vm wizard etc. */
132 virtual void wizardClean();
133
134protected slots:
135
136 /** Handles signal about progress has started. */
137 void sltHandleProgressStarted();
138 /** Handles signal about progress changed.
139 * @param uPercent Brings the progress percentage. */
140 void sltHandleProgressChange(ulong uPercent);
141 /** Handles signal about progress has finished. */
142 void sltHandleProgressFinished();
143
144private slots:
145
146 /** Handles current-page change to page with @a iIndex. */
147 void sltCurrentIndexChanged(int iIndex = -1);
148 /** Handles page validity changes. */
149 void sltCompleteChanged();
150
151 /** Toggles between basic and expert modes. */
152 void sltExpert();
153 /** Switches to previous page. */
154 void sltPrevious();
155 /** Switches to next page. */
156 void sltNext();
157
158private:
159
160 /** Prepares all. */
161 void prepare();
162 /** Cleanups all. */
163 void cleanup();
164 /** Inits all. */
165 void init();
166
167 /** Performs pages translation. */
168 void retranslatePages();
169
170 /** Resizes wizard to golden ratio. */
171 void resizeToGoldenRatio();
172#ifdef VBOX_WS_MAC
173 /** Assigns wizard background. */
174 void assignBackground();
175#else
176 /** Assigns wizard watermark. */
177 void assignWatermark();
178#endif
179
180 /** Holds the wizard type. */
181 WizardType m_enmType;
182 /** Holds the wizard mode. */
183 WizardMode m_enmMode;
184 /** Holds the wizard help hashtag. */
185 QString m_strHelpHashtag;
186 /** Holds the pixmap name. */
187 QString m_strPixmapName;
188 /** Holds the last entered page index. */
189 int m_iLastIndex;
190 /** Holds the set of invisible pages. */
191 QSet<int> m_invisiblePages;
192
193 /** Holds the pixmap label instance. */
194 QLabel *m_pLabelPixmap;
195 /** Holds the right layout instance. */
196 QVBoxLayout *m_pLayoutRight;
197 /** Holds the title label instance. */
198 QLabel *m_pLabelPageTitle;
199 /** Holds the widget-stack instance. */
200 QStackedWidget *m_pWidgetStack;
201 /** Holds the progress-stack instance. */
202 QStackedWidget *m_pProgressStack;
203 /** Holds the progress-bar instance. */
204 QProgressBar *m_pProgressBar;
205 /** Holds button instance map. */
206 QMap<WizardButtonType, QPushButton*> m_buttons;
207
208 /** Holds the local notification-center instance. */
209 UINotificationCenter *m_pNotificationCenter;
210};
211
212/** Native wizard interface pointer. */
213typedef QPointer<UINativeWizard> UINativeWizardPointer;
214
215#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