VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h@ 103977

Last change on this file since 103977 was 102262, checked in by vboxsync, 13 months ago

FE/Qt: bugref:10513: Make sure selector of UIAdvancedSettingsDialog is properly synchronized with actual scroll-area position.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1/* $Id: UIAdvancedSettingsDialog.h 102262 2023-11-22 15:19:20Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIAdvancedSettingsDialog class declaration.
4 */
5
6/*
7 * Copyright (C) 2006-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_settings_UIAdvancedSettingsDialog_h
29#define FEQT_INCLUDED_SRC_settings_UIAdvancedSettingsDialog_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMainWindow>
36
37/* GUI includes: */
38#include "QIWithRetranslateUI.h"
39#include "UISettingsDefs.h"
40
41/* Forward declarations: */
42class QGridLayout;
43class QProgressBar;
44class QShowEvent;
45class QStackedWidget;
46class QTimer;
47class QVariant;
48class QIDialogButtonBox;
49class UIFilterEditor;
50class UIModeCheckBox;
51class UISettingsPage;
52class UISettingsPageFrame;
53class UISettingsPageValidator;
54class UISettingsSelector;
55class UISettingsSerializer;
56class UISettingsWarningPane;
57class UIVerticalScrollArea;
58
59/* Using declarations: */
60using namespace UISettingsDefs;
61
62/** QMainWindow subclass used as
63 * base dialog class for both Global Preferences & Machine Settings
64 * dialogs, which encapsulates most of their common functionality. */
65class SHARED_LIBRARY_STUFF UIAdvancedSettingsDialog : public QIWithRetranslateUI<QMainWindow>
66{
67 Q_OBJECT;
68
69signals:
70
71 /** Notifies listeners about dialog should be closed. */
72 void sigClose();
73
74public:
75
76 /** Dialog types. */
77 enum DialogType { Type_Global, Type_Machine };
78
79 /** Constructs settings dialog passing @a pParent to the base-class.
80 * @param strCategory Brings the name of category to be opened.
81 * @param strControl Brings the name of control to be focused. */
82 UIAdvancedSettingsDialog(QWidget *pParent,
83 const QString &strCategory,
84 const QString &strControl);
85 /** Destructs settings dialog. */
86 virtual ~UIAdvancedSettingsDialog() RT_OVERRIDE;
87
88 /** Loads the dialog data. */
89 virtual bool load() = 0;
90 /** Saves the dialog data. */
91 virtual void save() = 0;
92
93protected slots:
94
95 /** Hides the modal dialog and sets the result code to Accepted. */
96 virtual void accept();
97 /** Hides the modal dialog and sets the result code to Rejected. */
98 virtual void reject();
99
100 /** Handles category change to @a cId. */
101 virtual void sltCategoryChanged(int cId);
102 /** Repeats handling for category change to cached @a m_iPageId. */
103 virtual void sltCategoryChangedRepeat() { sltCategoryChanged(m_iPageId); }
104
105 /** Handles serializartion start. */
106 virtual void sltHandleSerializationStarted();
107 /** Handles serializartion progress change to @a iValue. */
108 virtual void sltHandleSerializationProgressChange(int iValue);
109 /** Handle serializartion finished. */
110 virtual void sltHandleSerializationFinished();
111
112protected:
113
114 /** Preprocesses Qt @a pEvent for passed @a pObject. */
115 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
116
117 /** Handles translation event. */
118 virtual void retranslateUi() RT_OVERRIDE;
119 /** Handles show @a pEvent. */
120 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
121 /** Handles first show event. */
122 virtual void polishEvent();
123 /** Handles close @a pEvent. */
124 virtual void closeEvent(QCloseEvent *pEvent) RT_OVERRIDE;
125
126 /** Selects page and tab.
127 * @param fKeepPreviousByDefault Brings whether we should keep current page/tab by default. */
128 void choosePageAndTab(bool fKeepPreviousByDefault = false);
129
130 /** Loads the dialog @a data. */
131 void loadData(QVariant &data);
132 /** Saves the dialog @a data. */
133 void saveData(QVariant &data);
134
135 /** Returns configuration access level. */
136 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; }
137 /** Defines configuration access level. */
138 void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel);
139
140 /** Returns the serialize process instance. */
141 UISettingsSerializer *serializeProcess() const { return m_pSerializeProcess; }
142 /** Returns whether the serialization is in progress. */
143 bool isSerializationInProgress() const { return m_fSerializationIsInProgress; }
144
145 /** Returns dialog optional flags. */
146 QMap<QString, QVariant> optionalFlags() const { return m_flags; }
147 /** Defines dialog optional @a flags. */
148 void setOptionalFlags(const QMap<QString, QVariant> &flags);
149
150 /** Returns the dialog title extension. */
151 virtual QString titleExtension() const = 0;
152 /** Returns the dialog title. */
153 virtual QString title() const = 0;
154
155 /** Adds an item (page).
156 * @param strBigIcon Brings the big icon.
157 * @param strMediumIcon Brings the medium icon.
158 * @param strSmallIcon Brings the small icon.
159 * @param cId Brings the page ID.
160 * @param strLink Brings the page link.
161 * @param pSettingsPage Brings the page reference.
162 * @param iParentId Brings the page parent ID. */
163 void addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon,
164 int cId, const QString &strLink,
165 UISettingsPage* pSettingsPage = 0, int iParentId = -1);
166
167 /** Verifies data integrity between certain @a pSettingsPage and other pages. */
168 virtual void recorrelate(UISettingsPage *pSettingsPage) { Q_UNUSED(pSettingsPage); }
169
170 /** Inserts an item to the map m_pageHelpKeywords. */
171 void addPageHelpKeyword(int iPageType, const QString &strHelpKeyword);
172
173 /** Validates data correctness. */
174 void revalidate();
175
176 /** Returns whether settings were changed. */
177 bool isSettingsChanged();
178
179 /** Holds the name of category to be opened. */
180 QString m_strCategory;
181 /** Holds the name of control to be focused. */
182 QString m_strControl;
183
184 /** Holds the page selector instance. */
185 UISettingsSelector *m_pSelector;
186
187private slots:
188
189 /** Handles request to close dialog as QWidget, not QWindow.
190 * No need for QWindow destruction functionality.
191 * Parent will handle destruction itself. */
192 void sltClose();
193
194 /** Handles validity change for certain @a pValidator. */
195 void sltHandleValidityChange(UISettingsPageValidator *pValidator);
196
197 /** Handles hover enter for warning pane specified by @a pValidator. */
198 void sltHandleWarningPaneHovered(UISettingsPageValidator *pValidator);
199 /** Handles hover leave for warning pane specified by @a pValidator. */
200 void sltHandleWarningPaneUnhovered(UISettingsPageValidator *pValidator);
201
202 /** Handles experience mode checkbox change. */
203 void sltHandleExperienceModeCheckBoxChanged();
204 /** Handles experience mode change. */
205 void sltHandleExperienceModeChanged();
206
207 /** Applies filtering rules, which can be changed as
208 * a result of changes in experience mode and filter editor. */
209 void sltApplyFilteringRules();
210 /** Handles frame visivility changes. */
211 void sltHandleFrameVisibilityChange(bool fVisible);
212
213 /** Handles signal about vertical scroll-area wheel-event. */
214 void sltHandleVerticalScrollAreaWheelEvent();
215
216private:
217
218 /** @name Prepare/cleanup cascade.
219 * @{ */
220 /** Prepares all. */
221 void prepare();
222 /** Prepares selector. */
223 void prepareSelector();
224 /** Prepare scroll-area. */
225 void prepareScrollArea();
226 /** Prepare button-box. */
227 void prepareButtonBox();
228
229 /** Cleanups all. */
230 void cleanup();
231 /** @} */
232
233 /** Holds configuration access level. */
234 ConfigurationAccessLevel m_enmConfigurationAccessLevel;
235
236 /** Holds the serialize process instance. */
237 UISettingsSerializer *m_pSerializeProcess;
238
239 /** Holds whether dialog is polished. */
240 bool m_fPolished;
241 /** Holds whether the serialization is in progress. */
242 bool m_fSerializationIsInProgress;
243 /** Holds whether there were no serialization errors. */
244 bool m_fSerializationClean;
245 /** Holds whether the dialod had emitted signal to be closed. */
246 bool m_fClosed;
247
248 /** Holds the current page ID. */
249 int m_iPageId;
250
251 /** Holds the dialog optional flags. */
252 QMap<QString, QVariant> m_flags;
253
254 /** Holds the status-bar widget instance. */
255 QStackedWidget *m_pStatusBar;
256 /** Holds the process-bar widget instance. */
257 QProgressBar *m_pProcessBar;
258 /** Holds the warning-pane instance. */
259 UISettingsWarningPane *m_pWarningPane;
260
261 /** Holds whether settings dialog is valid (no errors, can be warnings). */
262 bool m_fValid;
263 /** Holds whether settings dialog is silent (no errors and no warnings). */
264 bool m_fSilent;
265
266 /** Holds the warning hint. */
267 QString m_strWarningHint;
268
269 /** Holds the map of settings page frames. */
270 QMap<int, UISettingsPageFrame*> m_frames;
271
272 /** Stores the help tag per page. */
273 QMap<int, QString> m_pageHelpKeywords;
274
275 /** Holds the 'sticky scrolling timer' instance. */
276 QTimer *m_pScrollingTimer;
277
278 /** @name Widgets
279 * @{ */
280 /** Holds the main layout instance. */
281 QGridLayout *m_pLayoutMain;
282
283 /** Holds the mode checkbox instance. */
284 UIModeCheckBox *m_pCheckBoxMode;
285
286 /** Holds the filter editor instance. */
287 UIFilterEditor *m_pEditorFilter;
288
289 /** Holds the scroll-area instance. */
290 UIVerticalScrollArea *m_pScrollArea;
291 /** Holds the scroll-viewport instance. */
292 QWidget *m_pScrollViewport;
293
294 /** Holds the button-box instance. */
295 QIDialogButtonBox *m_pButtonBox;
296 /** @} */
297};
298
299#endif /* !FEQT_INCLUDED_SRC_settings_UIAdvancedSettingsDialog_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