1 | /* $Id: UISettingsDialog.h 76581 2019-01-01 06:24:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UISettingsDialog class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 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_settings_UISettingsDialog_h
|
---|
19 | #define FEQT_INCLUDED_SRC_settings_UISettingsDialog_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QPointer>
|
---|
26 | #include <QVariant>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIMainDialog.h"
|
---|
30 | #include "QIWithRetranslateUI.h"
|
---|
31 | #include "UISettingsDefs.h"
|
---|
32 | #include "UISettingsDialog.gen.h"
|
---|
33 |
|
---|
34 | /* Forward declarations: */
|
---|
35 | class QEvent;
|
---|
36 | class QObject;
|
---|
37 | class QProgressBar;
|
---|
38 | class QShowEvent;
|
---|
39 | class QStackedWidget;
|
---|
40 | class QTimer;
|
---|
41 | class UIPageValidator;
|
---|
42 | class UISettingsPage;
|
---|
43 | class UISettingsSelector;
|
---|
44 | class UISettingsSerializer;
|
---|
45 | class UIWarningPane;
|
---|
46 |
|
---|
47 | /* Using declarations: */
|
---|
48 | using namespace UISettingsDefs;
|
---|
49 |
|
---|
50 | /** QIMainDialog aubclass used as
|
---|
51 | * base dialog class for both Global & VM settings which encapsulates most of their common functionality. */
|
---|
52 | class SHARED_LIBRARY_STUFF UISettingsDialog : public QIWithRetranslateUI<QIMainDialog>, public Ui::UISettingsDialog
|
---|
53 | {
|
---|
54 | Q_OBJECT;
|
---|
55 |
|
---|
56 | public:
|
---|
57 |
|
---|
58 | /** Constructs settings dialog passing @a pParent to the base-class. */
|
---|
59 | UISettingsDialog(QWidget *pParent);
|
---|
60 | /** Destructs settings dialog. */
|
---|
61 | virtual ~UISettingsDialog() /* override */;
|
---|
62 |
|
---|
63 | /** Performs modal dialog call. */
|
---|
64 | void execute();
|
---|
65 |
|
---|
66 | protected slots:
|
---|
67 |
|
---|
68 | /** Hides the modal dialog and sets the result code to Accepted. */
|
---|
69 | virtual void accept() /* override */;
|
---|
70 | /** Hides the modal dialog and sets the result code to Rejected. */
|
---|
71 | virtual void reject() /* override */;
|
---|
72 |
|
---|
73 | /** Handles category change to @a cId. */
|
---|
74 | virtual void sltCategoryChanged(int cId);
|
---|
75 |
|
---|
76 | /** Marks dialog loaded. */
|
---|
77 | virtual void sltMarkLoaded();
|
---|
78 | /** Marks dialog saved. */
|
---|
79 | virtual void sltMarkSaved();
|
---|
80 |
|
---|
81 | /** Handles process start. */
|
---|
82 | void sltHandleProcessStarted();
|
---|
83 | /** Handles process progress change to @a iValue. */
|
---|
84 | void sltHandleProcessProgressChange(int iValue);
|
---|
85 |
|
---|
86 | protected:
|
---|
87 |
|
---|
88 | /** Preprocesses any Qt @a pEvent for passed @a pObject. */
|
---|
89 | virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
|
---|
90 | /** Handles translation event. */
|
---|
91 | virtual void retranslateUi() /* override */;
|
---|
92 | /** Handles show @a pEvent. */
|
---|
93 | virtual void showEvent(QShowEvent *pEvent) /* override */;
|
---|
94 |
|
---|
95 | /** Returns the serialize process instance. */
|
---|
96 | UISettingsSerializer *serializeProcess() const { return m_pSerializeProcess; }
|
---|
97 | /** Returns whether the serialization is in progress. */
|
---|
98 | bool isSerializationInProgress() const { return m_fSerializationIsInProgress; }
|
---|
99 |
|
---|
100 | /** Loads the @a data. */
|
---|
101 | void loadData(QVariant &data);
|
---|
102 | /** Wrapper for the method above.
|
---|
103 | * Loads the data from the corresponding source. */
|
---|
104 | virtual void loadOwnData() = 0;
|
---|
105 |
|
---|
106 | /** Saves the @a data. */
|
---|
107 | void saveData(QVariant &data);
|
---|
108 | /** Wrapper for the method above.
|
---|
109 | * Saves the data to the corresponding source. */
|
---|
110 | virtual void saveOwnData() = 0;
|
---|
111 |
|
---|
112 | /** Returns configuration access level. */
|
---|
113 | ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; }
|
---|
114 | /** Defines configuration access level. */
|
---|
115 | void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel);
|
---|
116 |
|
---|
117 | /** Returns the dialog title extension. */
|
---|
118 | virtual QString titleExtension() const = 0;
|
---|
119 | /** Returns the dialog title. */
|
---|
120 | virtual QString title() const = 0;
|
---|
121 |
|
---|
122 | /** Adds an item (page).
|
---|
123 | * @param strBigIcon Brings the big icon.
|
---|
124 | * @param strMediumIcon Brings the medium icon.
|
---|
125 | * @param strSmallIcon Brings the small icon.
|
---|
126 | * @param cId Brings the page ID.
|
---|
127 | * @param strLink Brings the page link.
|
---|
128 | * @param pSettingsPage Brings the page reference.
|
---|
129 | * @param iParentId Brings the page parent ID. */
|
---|
130 | void addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
|
---|
131 | int cId, const QString &strLink,
|
---|
132 | UISettingsPage* pSettingsPage = 0, int iParentId = -1);
|
---|
133 |
|
---|
134 | /** Verifies data integrity between certain @a pSettingsPage and other pages. */
|
---|
135 | virtual void recorrelate(UISettingsPage *pSettingsPage) { Q_UNUSED(pSettingsPage); }
|
---|
136 |
|
---|
137 | /** Validates data correctness using certain @a pValidator. */
|
---|
138 | void revalidate(UIPageValidator *pValidator);
|
---|
139 | /** Validates data correctness. */
|
---|
140 | void revalidate();
|
---|
141 |
|
---|
142 | /** Holds the page selector instance. */
|
---|
143 | UISettingsSelector *m_pSelector;
|
---|
144 | /** Holds the page stack instance. */
|
---|
145 | QStackedWidget *m_pStack;
|
---|
146 |
|
---|
147 | private slots:
|
---|
148 |
|
---|
149 | /** Handles validity change for certain @a pValidator. */
|
---|
150 | void sltHandleValidityChange(UIPageValidator *pValidator);
|
---|
151 |
|
---|
152 | /** Handles hover enter for warning pane specified by @a pValidator. */
|
---|
153 | void sltHandleWarningPaneHovered(UIPageValidator *pValidator);
|
---|
154 | /** Handles hover leave for warning pane specified by @a pValidator. */
|
---|
155 | void sltHandleWarningPaneUnhovered(UIPageValidator *pValidator);
|
---|
156 |
|
---|
157 | /** Updates watch this information depending on whether we have @a fGotFocus. */
|
---|
158 | void sltUpdateWhatsThis(bool fGotFocus);
|
---|
159 | /** Updates watch this information. */
|
---|
160 | void sltUpdateWhatsThisNoFocus() { sltUpdateWhatsThis(false); }
|
---|
161 |
|
---|
162 | private:
|
---|
163 |
|
---|
164 | /** Prepares all. */
|
---|
165 | void prepare();
|
---|
166 |
|
---|
167 | /** Assigns validater for passed @a pPage. */
|
---|
168 | void assignValidator(UISettingsPage *pPage);
|
---|
169 |
|
---|
170 | /** Holds whether the dialog is polished. */
|
---|
171 | bool m_fPolished;
|
---|
172 |
|
---|
173 | /** Holds configuration access level. */
|
---|
174 | ConfigurationAccessLevel m_enmConfigurationAccessLevel;
|
---|
175 |
|
---|
176 | /** Holds the serialize process instance. */
|
---|
177 | UISettingsSerializer *m_pSerializeProcess;
|
---|
178 |
|
---|
179 | /** Holds whether the serialization is in progress. */
|
---|
180 | bool m_fSerializationIsInProgress;
|
---|
181 | /** Holds whether there were no serialization errors. */
|
---|
182 | bool m_fSerializationClean;
|
---|
183 |
|
---|
184 | /** Holds the status-bar widget instance. */
|
---|
185 | QStackedWidget *m_pStatusBar;
|
---|
186 | /** Holds the process-bar widget instance. */
|
---|
187 | QProgressBar *m_pProcessBar;
|
---|
188 | /** Holds the warning-pane instance. */
|
---|
189 | UIWarningPane *m_pWarningPane;
|
---|
190 |
|
---|
191 | /** Holds whether settings dialog is valid (no errors, can be warnings). */
|
---|
192 | bool m_fValid;
|
---|
193 | /** Holds whether settings dialog is silent (no errors and no warnings). */
|
---|
194 | bool m_fSilent;
|
---|
195 |
|
---|
196 | /** Holds the warning hint. */
|
---|
197 | QString m_strWarningHint;
|
---|
198 |
|
---|
199 | /** Holds the what's this hover timer instance. */
|
---|
200 | QTimer *m_pWhatsThisTimer;
|
---|
201 | /** Holds the what's this hover timer instance. */
|
---|
202 | QPointer<QWidget> m_pWhatsThisCandidate;
|
---|
203 |
|
---|
204 | /** Holds the map of settings pages. */
|
---|
205 | QMap<int, int> m_pages;
|
---|
206 |
|
---|
207 | #ifdef VBOX_WS_MAC
|
---|
208 | /** Holds the list of settings page sizes for animation purposes. */
|
---|
209 | QList<QSize> m_sizeList;
|
---|
210 | #endif
|
---|
211 | };
|
---|
212 |
|
---|
213 | #endif /* !FEQT_INCLUDED_SRC_settings_UISettingsDialog_h */
|
---|