VirtualBox

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

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

FE/Qt: bugref:9996: Move progress-related slots of UINativeWizard to protected area, they can be used from wizard sub-classes directly, s.a. r146352.

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