VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsPage.h

Last change on this file was 104313, checked in by vboxsync, 5 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in the settings related GUI classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.0 KB
Line 
1/* $Id: UISettingsPage.h 104313 2024-04-12 13:10:30Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UISettingsPage 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_UISettingsPage_h
29#define FEQT_INCLUDED_SRC_settings_UISettingsPage_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* GUI includes: */
35#include "UIEditor.h"
36#include "UIExtraDataDefs.h"
37#include "UISettingsDefs.h"
38
39/* COM includes: */
40#include "CConsole.h"
41#include "CHost.h"
42#include "CMachine.h"
43#include "CSystemProperties.h"
44
45/* Forward declarations: */
46class QLabel;
47class QLayout;
48class QVariant;
49class QWidget;
50class UISettingsPageValidator;
51
52/* Using declarations: */
53using namespace UISettingsDefs;
54
55
56/** Global settings data wrapper. */
57struct UISettingsDataGlobal
58{
59 /** Constructs NULL global settings data struct. */
60 UISettingsDataGlobal() {}
61 /** Constructs global settings data struct on the basis of @a comHost and @a comProperties. */
62 UISettingsDataGlobal(const CHost &comHost, const CSystemProperties &comProperties)
63 : m_host(comHost), m_properties(comProperties) {}
64 /** Holds the host reference. */
65 CHost m_host;
66 /** Holds the properties reference. */
67 CSystemProperties m_properties;
68};
69Q_DECLARE_METATYPE(UISettingsDataGlobal);
70
71
72/** Machine settings data wrapper. */
73struct UISettingsDataMachine
74{
75 /** Constructs NULL machine settings data struct. */
76 UISettingsDataMachine() {}
77 /** Constructs machine settings data struct on the basis of @a comMachine and @a comConsole. */
78 UISettingsDataMachine(const CMachine &comMachine, const CConsole &comConsole)
79 : m_machine(comMachine), m_console(comConsole) {}
80 /** Holds the machine reference. */
81 CMachine m_machine;
82 /** Holds the console reference. */
83 CConsole m_console;
84};
85Q_DECLARE_METATYPE(UISettingsDataMachine);
86
87
88/** Validation message. */
89typedef QPair<QString, QStringList> UIValidationMessage;
90
91
92/** UIEditor sub-class used as settings page interface. */
93class UISettingsPage : public UIEditor
94{
95 Q_OBJECT;
96
97signals:
98
99 /** Notifies listeners about particular operation progress change.
100 * @param iOperations holds the number of operations CProgress have,
101 * @param strOperation holds the description of the current CProgress operation,
102 * @param iOperation holds the index of the current CProgress operation,
103 * @param iPercent holds the percentage of the current CProgress operation. */
104 void sigOperationProgressChange(ulong iOperations, QString strOperation,
105 ulong iOperation, ulong iPercent);
106
107 /** Notifies listeners about particular COM error.
108 * @param strErrorInfo holds the details of the error happened. */
109 void sigOperationProgressError(QString strErrorInfo);
110
111public:
112
113 /** Loads settings from external object(s) packed inside @a data to cache.
114 * @note This task WILL be performed in other than the GUI thread, no widget interactions! */
115 virtual void loadToCacheFrom(QVariant &data) = 0;
116 /** Loads data from cache to corresponding widgets.
117 * @note This task WILL be performed in the GUI thread only, all widget interactions here! */
118 virtual void getFromCache() = 0;
119
120 /** Saves data from corresponding widgets to cache.
121 * @note This task WILL be performed in the GUI thread only, all widget interactions here! */
122 virtual void putToCache() = 0;
123 /** Saves settings from cache to external object(s) packed inside @a data.
124 * @note This task WILL be performed in other than the GUI thread, no widget interactions! */
125 virtual void saveFromCacheTo(QVariant &data) = 0;
126
127 /** Notifies listeners about particular COM error.
128 * @param strErrorInfo Brings the details of the error happened. */
129 void notifyOperationProgressError(const QString &strErrorInfo);
130
131 /** Defines @a pValidator. */
132 void setValidator(UISettingsPageValidator *pValidator);
133 /** Defines whether @a fIsValidatorBlocked which means not used at all. */
134 void setValidatorBlocked(bool fIsValidatorBlocked) { m_fIsValidatorBlocked = fIsValidatorBlocked; }
135 /** Performs page validation composing a list of @a messages. */
136 virtual bool validate(QList<UIValidationMessage> &messages) { Q_UNUSED(messages); return true; }
137
138 /** Returns first navigation widget. */
139 QWidget *firstWidget() const { return m_pFirstWidget; }
140 /** Defines the first navigation widget for TAB-order. */
141 virtual void setOrderAfter(QWidget *pWidget) { m_pFirstWidget = pWidget; }
142
143 /** Defines @a enmConfigurationAccessLevel. */
144 virtual void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel);
145 /** Returns configuration access level. */
146 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; }
147 /** Returns whether configuration access level is Full. */
148 bool isMachineOffline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Full; }
149 /** Returns whether configuration access level corresponds to machine in Powered Off state. */
150 bool isMachinePoweredOff() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_PoweredOff; }
151 /** Returns whether configuration access level corresponds to machine in Saved state. */
152 bool isMachineSaved() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_Saved; }
153 /** Returns whether configuration access level corresponds to machine in one of Running states. */
154 bool isMachineOnline() const { return configurationAccessLevel() == ConfigurationAccessLevel_Partial_Running; }
155 /** Returns whether configuration access level corresponds to machine in one of allowed states. */
156 bool isMachineInValidMode() const { return isMachineOffline() || isMachinePoweredOff() || isMachineSaved() || isMachineOnline(); }
157
158 /** Returns whether the page content was changed. */
159 virtual bool changed() const = 0;
160
161 /** Defines page @a cId. */
162 void setId(int cId) { m_cId = cId; }
163 /** Returns page ID. */
164 int id() const { return m_cId; }
165
166 /** Returns page internal name. */
167 virtual QString internalName() const = 0;
168
169 /** Returns page warning pixmap. */
170 virtual QPixmap warningPixmap() const = 0;
171
172 /** Defines whether page is @a fProcessed. */
173 void setProcessed(bool fProcessed) { m_fProcessed = fProcessed; }
174 /** Returns whether page is processed. */
175 bool processed() const { return m_fProcessed; }
176
177 /** Defines whether page processing is @a fFailed. */
178 void setFailed(bool fFailed) { m_fFailed = fFailed; }
179 /** Returns whether page processing is failed. */
180 bool failed() const { return m_fFailed; }
181
182 /** Performs page polishing. */
183 virtual void polishPage() {}
184
185public slots:
186
187 /** Performs validation. */
188 void revalidate();
189
190protected:
191
192 /** Constructs settings page. */
193 UISettingsPage();
194
195private:
196
197 /** Holds the configuration access level. */
198 ConfigurationAccessLevel m_enmConfigurationAccessLevel;
199
200 /** Holds the page ID. */
201 int m_cId;
202
203 /** Holds the first TAB-orer widget reference. */
204 QWidget *m_pFirstWidget;
205 /** Holds the page validator. */
206 UISettingsPageValidator *m_pValidator;
207
208 /** Holds whether page validation is blocked. */
209 bool m_fIsValidatorBlocked : 1;
210 /** Holds whether page is processed. */
211 bool m_fProcessed : 1;
212 /** Holds whether page processing is failed. */
213 bool m_fFailed : 1;
214};
215
216
217/** UISettingsPage extension used as Global Preferences page interface. */
218class UISettingsPageGlobal : public UISettingsPage
219{
220 Q_OBJECT;
221
222protected:
223
224 /** Constructs global preferences page. */
225 UISettingsPageGlobal();
226
227 /** Returns internal page ID. */
228 GlobalSettingsPageType internalID() const;
229
230 /** Returns page internal name. */
231 virtual QString internalName() const RT_OVERRIDE;
232
233 /** Returns page warning pixmap. */
234 virtual QPixmap warningPixmap() const RT_OVERRIDE;
235
236 /** Returns whether the page content was changed. */
237 virtual bool changed() const RT_OVERRIDE { return false; }
238
239 /** Fetches data to m_properties & m_settings. */
240 void fetchData(const QVariant &data);
241 /** Uploads m_properties & m_settings to data. */
242 void uploadData(QVariant &data) const;
243
244 /** Holds the source of host preferences. */
245 CHost m_host;
246 /** Holds the source of global preferences. */
247 CSystemProperties m_properties;
248};
249
250
251/** UISettingsPage extension used as Machine Settings page interface. */
252class UISettingsPageMachine : public UISettingsPage
253{
254 Q_OBJECT;
255
256protected:
257
258 /** Constructs machine settings page. */
259 UISettingsPageMachine();
260
261 /** Returns internal page ID. */
262 MachineSettingsPageType internalID() const;
263
264 /** Returns page internal name. */
265 virtual QString internalName() const RT_OVERRIDE;
266
267 /** Returns page warning pixmap. */
268 virtual QPixmap warningPixmap() const RT_OVERRIDE;
269
270 /** Fetches data to m_machine & m_console. */
271 void fetchData(const QVariant &data);
272 /** Uploads m_machine & m_console to data. */
273 void uploadData(QVariant &data) const;
274
275 /** Holds the source of machine settings. */
276 CMachine m_machine;
277 /** Holds the source of console settings. */
278 CConsole m_console;
279};
280
281
282/** UIEditor sub-class, used as settings page frame. */
283class UISettingsPageFrame : public UIEditor
284{
285 Q_OBJECT;
286
287public:
288
289 /** Constructs details element passing @a pParent to the base-class.
290 * @param pPage Brings the page to wrap with frame. */
291 UISettingsPageFrame(UISettingsPage *pPage, QWidget *pParent = 0);
292
293 /** Defines @a strName. */
294 void setName(const QString &strName);
295
296protected:
297
298 /** Handles paint @a pEvent. */
299 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE;
300
301private slots:
302
303 /** Handles translation event. */
304 virtual void sltRetranslateUI() RT_OVERRIDE RT_FINAL;
305
306private:
307
308 /** Prepares all. */
309 void prepare();
310
311 /** Holds the page reference. */
312 UISettingsPage *m_pPage;
313
314 /** Holds the element name.*/
315 QString m_strName;
316
317 /** Holds the name label instance. */
318 QLabel *m_pLabelName;
319 /** Holds the contents widget instance. */
320 QWidget *m_pWidget;
321 /** Holds the contents layout instance. */
322 QLayout *m_pLayout;
323};
324
325
326#endif /* !FEQT_INCLUDED_SRC_settings_UISettingsPage_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use