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 | /* Other includes */
|
---|
27 | #include "QIWithRetranslateUI.h"
|
---|
28 | #include "COMDefs.h"
|
---|
29 | #include "UISettingsDefs.h"
|
---|
30 | #include "VBoxGlobalSettings.h"
|
---|
31 |
|
---|
32 | /* Forward declarations */
|
---|
33 | class QIWidgetValidator;
|
---|
34 | class QShowEvent;
|
---|
35 |
|
---|
36 | /* Using declarations: */
|
---|
37 | using namespace UISettingsDefs;
|
---|
38 |
|
---|
39 | /* Settings page types: */
|
---|
40 | enum UISettingsPageType
|
---|
41 | {
|
---|
42 | UISettingsPageType_Global,
|
---|
43 | UISettingsPageType_Machine
|
---|
44 | };
|
---|
45 |
|
---|
46 | /* Global settings data wrapper: */
|
---|
47 | struct UISettingsDataGlobal
|
---|
48 | {
|
---|
49 | UISettingsDataGlobal() {}
|
---|
50 | UISettingsDataGlobal(const CSystemProperties &properties, const VBoxGlobalSettings &settings)
|
---|
51 | : m_properties(properties), m_settings(settings) {}
|
---|
52 | CSystemProperties m_properties;
|
---|
53 | VBoxGlobalSettings m_settings;
|
---|
54 | };
|
---|
55 | Q_DECLARE_METATYPE(UISettingsDataGlobal);
|
---|
56 |
|
---|
57 | /* Machine settings data wrapper: */
|
---|
58 | struct UISettingsDataMachine
|
---|
59 | {
|
---|
60 | UISettingsDataMachine() {}
|
---|
61 | UISettingsDataMachine(const CMachine &machine, const CConsole &console)
|
---|
62 | : m_machine(machine), m_console(console) {}
|
---|
63 | CMachine m_machine;
|
---|
64 | CConsole m_console;
|
---|
65 | };
|
---|
66 | Q_DECLARE_METATYPE(UISettingsDataMachine);
|
---|
67 |
|
---|
68 | /* Settings page base class: */
|
---|
69 | class UISettingsPage : public QIWithRetranslateUI<QWidget>
|
---|
70 | {
|
---|
71 | Q_OBJECT;
|
---|
72 |
|
---|
73 | public:
|
---|
74 |
|
---|
75 | /* Load data to cashe from corresponding external object(s),
|
---|
76 | * this task COULD be performed in other than GUI thread: */
|
---|
77 | virtual void loadToCacheFrom(QVariant &data) = 0;
|
---|
78 | /* Load data to corresponding widgets from cache,
|
---|
79 | * this task SHOULD be performed in GUI thread only: */
|
---|
80 | virtual void getFromCache() = 0;
|
---|
81 |
|
---|
82 | /* Save data from corresponding widgets to cache,
|
---|
83 | * this task SHOULD be performed in GUI thread only: */
|
---|
84 | virtual void putToCache() = 0;
|
---|
85 | /* Save data from cache to corresponding external object(s),
|
---|
86 | * this task COULD be performed in other than GUI thread: */
|
---|
87 | virtual void saveFromCacheTo(QVariant &data) = 0;
|
---|
88 |
|
---|
89 | /* Validation stuff: */
|
---|
90 | virtual void setValidator(QIWidgetValidator* /* pValidator */) {}
|
---|
91 | virtual bool revalidate(QString& /* strWarningText */, QString& /* strTitle */) { return true; }
|
---|
92 |
|
---|
93 | /* Navigation stuff: */
|
---|
94 | QWidget* firstWidget() const { return m_pFirstWidget; }
|
---|
95 | virtual void setOrderAfter(QWidget *pWidget) { m_pFirstWidget = pWidget; }
|
---|
96 |
|
---|
97 | /* Settings page type stuff: */
|
---|
98 | UISettingsPageType pageType() const { return m_pageType; }
|
---|
99 |
|
---|
100 | /* Settings dialog type stuff: */
|
---|
101 | SettingsDialogType dialogType() const { return m_dialogType; }
|
---|
102 | virtual void setDialogType(SettingsDialogType settingsDialogType) { m_dialogType = settingsDialogType; polishPage(); }
|
---|
103 | bool isMachineOffline() const { return dialogType() == SettingsDialogType_Offline; }
|
---|
104 | bool isMachineSaved() const { return dialogType() == SettingsDialogType_Saved; }
|
---|
105 | bool isMachineOnline() const { return dialogType() == SettingsDialogType_Online; }
|
---|
106 | bool isMachineInValidMode() const { return isMachineOffline() || isMachineSaved() || isMachineOnline(); }
|
---|
107 |
|
---|
108 | /* Page 'ID' stuff: */
|
---|
109 | int id() const { return m_cId; }
|
---|
110 | void setId(int cId) { m_cId = cId; }
|
---|
111 |
|
---|
112 | /* Page 'processed' stuff: */
|
---|
113 | bool processed() const { return m_fProcessed; }
|
---|
114 | void setProcessed(bool fProcessed) { m_fProcessed = fProcessed; }
|
---|
115 |
|
---|
116 | /* Page 'failed' stuff: */
|
---|
117 | bool failed() const { return m_fFailed; }
|
---|
118 | void setFailed(bool fFailed) { m_fFailed = fFailed; }
|
---|
119 |
|
---|
120 | /* Virtual function to polish page content: */
|
---|
121 | virtual void polishPage() {}
|
---|
122 |
|
---|
123 | protected:
|
---|
124 |
|
---|
125 | /* Settings page constructor, hidden: */
|
---|
126 | UISettingsPage(UISettingsPageType type);
|
---|
127 |
|
---|
128 | private:
|
---|
129 |
|
---|
130 | /* Private variables: */
|
---|
131 | UISettingsPageType m_pageType;
|
---|
132 | SettingsDialogType m_dialogType;
|
---|
133 | int m_cId;
|
---|
134 | bool m_fProcessed;
|
---|
135 | bool m_fFailed;
|
---|
136 | QWidget *m_pFirstWidget;
|
---|
137 | };
|
---|
138 |
|
---|
139 | /* Global settings page class: */
|
---|
140 | class UISettingsPageGlobal : public UISettingsPage
|
---|
141 | {
|
---|
142 | Q_OBJECT;
|
---|
143 |
|
---|
144 | protected:
|
---|
145 |
|
---|
146 | /* Global settings page constructor, hidden: */
|
---|
147 | UISettingsPageGlobal();
|
---|
148 |
|
---|
149 | /* Fetch data to m_properties & m_settings: */
|
---|
150 | void fetchData(const QVariant &data);
|
---|
151 |
|
---|
152 | /* Upload m_properties & m_settings to data: */
|
---|
153 | void uploadData(QVariant &data) const;
|
---|
154 |
|
---|
155 | /* Global data source: */
|
---|
156 | CSystemProperties m_properties;
|
---|
157 | VBoxGlobalSettings m_settings;
|
---|
158 | };
|
---|
159 |
|
---|
160 | /* Machine settings page class: */
|
---|
161 | class UISettingsPageMachine : public UISettingsPage
|
---|
162 | {
|
---|
163 | Q_OBJECT;
|
---|
164 |
|
---|
165 | protected:
|
---|
166 |
|
---|
167 | /* Machine settings page constructor, hidden: */
|
---|
168 | UISettingsPageMachine();
|
---|
169 |
|
---|
170 | /* Fetch data to m_machine: */
|
---|
171 | void fetchData(const QVariant &data);
|
---|
172 |
|
---|
173 | /* Upload m_machine to data: */
|
---|
174 | void uploadData(QVariant &data) const;
|
---|
175 |
|
---|
176 | /* Machine data source: */
|
---|
177 | CMachine m_machine;
|
---|
178 | CConsole m_console;
|
---|
179 | };
|
---|
180 |
|
---|
181 | #endif // __UISettingsPage_h__
|
---|
182 |
|
---|