VirtualBox

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

Last change on this file since 43138 was 41587, checked in by vboxsync, 12 years ago

FE/Qt: 6227: Decrease GUI build time: Rework COM wrappers generator to create one header per each COM interface. Update all GUI files to use newly generated headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 5.5 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt4 GUI ("VirtualBox"):
4 * UISettingsPage class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __UISettingsPage_h__
20#define __UISettingsPage_h__
21
22/* Qt includes: */
23#include <QWidget>
24#include <QVariant>
25
26/* GUI includes: */
27#include "QIWithRetranslateUI.h"
28#include "UISettingsDefs.h"
29#include "VBoxGlobalSettings.h"
30
31/* COM includes: */
32#include "COMEnums.h"
33#include "CMachine.h"
34#include "CConsole.h"
35#include "CSystemProperties.h"
36
37/* Forward declarations: */
38class QIWidgetValidator;
39class QShowEvent;
40
41/* Using declarations: */
42using namespace UISettingsDefs;
43
44/* Settings page types: */
45enum UISettingsPageType
46{
47 UISettingsPageType_Global,
48 UISettingsPageType_Machine
49};
50
51/* Global settings data wrapper: */
52struct UISettingsDataGlobal
53{
54 UISettingsDataGlobal() {}
55 UISettingsDataGlobal(const CSystemProperties &properties, const VBoxGlobalSettings &settings)
56 : m_properties(properties), m_settings(settings) {}
57 CSystemProperties m_properties;
58 VBoxGlobalSettings m_settings;
59};
60Q_DECLARE_METATYPE(UISettingsDataGlobal);
61
62/* Machine settings data wrapper: */
63struct UISettingsDataMachine
64{
65 UISettingsDataMachine() {}
66 UISettingsDataMachine(const CMachine &machine, const CConsole &console)
67 : m_machine(machine), m_console(console) {}
68 CMachine m_machine;
69 CConsole m_console;
70};
71Q_DECLARE_METATYPE(UISettingsDataMachine);
72
73/* Settings page base class: */
74class UISettingsPage : public QIWithRetranslateUI<QWidget>
75{
76 Q_OBJECT;
77
78public:
79
80 /* Load data to cashe from corresponding external object(s),
81 * this task COULD be performed in other than GUI thread: */
82 virtual void loadToCacheFrom(QVariant &data) = 0;
83 /* Load data to corresponding widgets from cache,
84 * this task SHOULD be performed in GUI thread only: */
85 virtual void getFromCache() = 0;
86
87 /* Save data from corresponding widgets to cache,
88 * this task SHOULD be performed in GUI thread only: */
89 virtual void putToCache() = 0;
90 /* Save data from cache to corresponding external object(s),
91 * this task COULD be performed in other than GUI thread: */
92 virtual void saveFromCacheTo(QVariant &data) = 0;
93
94 /* Validation stuff: */
95 virtual void setValidator(QIWidgetValidator* /* pValidator */) {}
96 virtual bool revalidate(QString& /* strWarningText */, QString& /* strTitle */) { return true; }
97
98 /* Navigation stuff: */
99 QWidget* firstWidget() const { return m_pFirstWidget; }
100 virtual void setOrderAfter(QWidget *pWidget) { m_pFirstWidget = pWidget; }
101
102 /* Settings page type stuff: */
103 UISettingsPageType pageType() const { return m_pageType; }
104
105 /* Settings dialog type stuff: */
106 SettingsDialogType dialogType() const { return m_dialogType; }
107 virtual void setDialogType(SettingsDialogType settingsDialogType) { m_dialogType = settingsDialogType; polishPage(); }
108 bool isMachineOffline() const { return dialogType() == SettingsDialogType_Offline; }
109 bool isMachineSaved() const { return dialogType() == SettingsDialogType_Saved; }
110 bool isMachineOnline() const { return dialogType() == SettingsDialogType_Online; }
111 bool isMachineInValidMode() const { return isMachineOffline() || isMachineSaved() || isMachineOnline(); }
112
113 /* Page changed: */
114 virtual bool changed() const = 0;
115
116 /* Page 'ID' stuff: */
117 int id() const { return m_cId; }
118 void setId(int cId) { m_cId = cId; }
119
120 /* Page 'processed' stuff: */
121 bool processed() const { return m_fProcessed; }
122 void setProcessed(bool fProcessed) { m_fProcessed = fProcessed; }
123
124 /* Page 'failed' stuff: */
125 bool failed() const { return m_fFailed; }
126 void setFailed(bool fFailed) { m_fFailed = fFailed; }
127
128 /* Virtual function to polish page content: */
129 virtual void polishPage() {}
130
131protected:
132
133 /* Settings page constructor, hidden: */
134 UISettingsPage(UISettingsPageType type);
135
136private:
137
138 /* Private variables: */
139 UISettingsPageType m_pageType;
140 SettingsDialogType m_dialogType;
141 int m_cId;
142 bool m_fProcessed;
143 bool m_fFailed;
144 QWidget *m_pFirstWidget;
145};
146
147/* Global settings page class: */
148class UISettingsPageGlobal : public UISettingsPage
149{
150 Q_OBJECT;
151
152protected:
153
154 /* Global settings page constructor, hidden: */
155 UISettingsPageGlobal();
156
157 /* Fetch data to m_properties & m_settings: */
158 void fetchData(const QVariant &data);
159
160 /* Upload m_properties & m_settings to data: */
161 void uploadData(QVariant &data) const;
162
163 /* Page changed: */
164 bool changed() const { return false; }
165
166 /* Global data source: */
167 CSystemProperties m_properties;
168 VBoxGlobalSettings m_settings;
169};
170
171/* Machine settings page class: */
172class UISettingsPageMachine : public UISettingsPage
173{
174 Q_OBJECT;
175
176protected:
177
178 /* Machine settings page constructor, hidden: */
179 UISettingsPageMachine();
180
181 /* Fetch data to m_machine: */
182 void fetchData(const QVariant &data);
183
184 /* Upload m_machine to data: */
185 void uploadData(QVariant &data) const;
186
187 /* Machine data source: */
188 CMachine m_machine;
189 CConsole m_console;
190};
191
192#endif // __UISettingsPage_h__
193
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use