1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt4 GUI ("VirtualBox"):
|
---|
4 | * UISettingsPage class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2010 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 | /* Global includes */
|
---|
23 | #include <QWidget>
|
---|
24 | #include <QVariant>
|
---|
25 |
|
---|
26 | /* Local includes */
|
---|
27 | #include "QIWithRetranslateUI.h"
|
---|
28 | #include "COMDefs.h"
|
---|
29 | #include "VBoxGlobalSettings.h"
|
---|
30 |
|
---|
31 | /* Forward declarations */
|
---|
32 | class QIWidgetValidator;
|
---|
33 |
|
---|
34 | /* Settings page types: */
|
---|
35 | enum UISettingsPageType
|
---|
36 | {
|
---|
37 | UISettingsPageType_Global,
|
---|
38 | UISettingsPageType_Machine
|
---|
39 | };
|
---|
40 |
|
---|
41 | /* Global settings data wrapper: */
|
---|
42 | struct UISettingsDataGlobal
|
---|
43 | {
|
---|
44 | UISettingsDataGlobal() {}
|
---|
45 | UISettingsDataGlobal(const CSystemProperties &properties, const VBoxGlobalSettings &settings)
|
---|
46 | : m_properties(properties), m_settings(settings) {}
|
---|
47 | CSystemProperties m_properties;
|
---|
48 | VBoxGlobalSettings m_settings;
|
---|
49 | };
|
---|
50 | Q_DECLARE_METATYPE(UISettingsDataGlobal);
|
---|
51 |
|
---|
52 | /* Machine settings data wrapper: */
|
---|
53 | struct UISettingsDataMachine
|
---|
54 | {
|
---|
55 | UISettingsDataMachine() {}
|
---|
56 | UISettingsDataMachine(const CMachine &machine)
|
---|
57 | : m_machine(machine) {}
|
---|
58 | CMachine m_machine;
|
---|
59 | };
|
---|
60 | Q_DECLARE_METATYPE(UISettingsDataMachine);
|
---|
61 |
|
---|
62 | /* Settings page base class: */
|
---|
63 | class UISettingsPage : public QIWithRetranslateUI<QWidget>
|
---|
64 | {
|
---|
65 | Q_OBJECT;
|
---|
66 |
|
---|
67 | public:
|
---|
68 |
|
---|
69 | /* Load data to cashe from corresponding external object(s),
|
---|
70 | * this task COULD be performed in other than GUI thread: */
|
---|
71 | virtual void loadToCacheFrom(QVariant &data) = 0;
|
---|
72 | /* Load data to corresponding widgets from cache,
|
---|
73 | * this task SHOULD be performed in GUI thread only: */
|
---|
74 | virtual void getFromCache() = 0;
|
---|
75 |
|
---|
76 | /* Save data from corresponding widgets to cache,
|
---|
77 | * this task SHOULD be performed in GUI thread only: */
|
---|
78 | virtual void putToCache() = 0;
|
---|
79 | /* Save data from cache to corresponding external object(s),
|
---|
80 | * this task COULD be performed in other than GUI thread: */
|
---|
81 | virtual void saveFromCacheTo(QVariant &data) = 0;
|
---|
82 |
|
---|
83 | /* Returns settings page type: */
|
---|
84 | virtual UISettingsPageType type() const;
|
---|
85 |
|
---|
86 | /* Validation stuff: */
|
---|
87 | virtual void setValidator(QIWidgetValidator *pValidator);
|
---|
88 | virtual bool revalidate(QString &strWarningText, QString &strTitle);
|
---|
89 |
|
---|
90 | /* Navigation stuff: */
|
---|
91 | virtual void setOrderAfter(QWidget *pWidget);
|
---|
92 |
|
---|
93 | /* Page 'ID' stuff: */
|
---|
94 | int id() const;
|
---|
95 | void setId(int cId);
|
---|
96 |
|
---|
97 | /* Page 'processed' stuff: */
|
---|
98 | bool processed() const;
|
---|
99 | void setProcessed(bool fProcessed);
|
---|
100 |
|
---|
101 | /* Page 'failed' stuff: */
|
---|
102 | bool failed() const;
|
---|
103 | void setFailed(bool fFailed);
|
---|
104 |
|
---|
105 | protected:
|
---|
106 |
|
---|
107 | /* Settings page constructor, hidden: */
|
---|
108 | UISettingsPage(UISettingsPageType type, QWidget *pParent = 0);
|
---|
109 |
|
---|
110 | /* Variables: */
|
---|
111 | UISettingsPageType m_type;
|
---|
112 | int m_cId;
|
---|
113 | bool m_fProcessed;
|
---|
114 | bool m_fFailed;
|
---|
115 | QWidget *m_pFirstWidget;
|
---|
116 | };
|
---|
117 |
|
---|
118 | /* Global settings page class: */
|
---|
119 | class UISettingsPageGlobal : public UISettingsPage
|
---|
120 | {
|
---|
121 | Q_OBJECT;
|
---|
122 |
|
---|
123 | protected:
|
---|
124 |
|
---|
125 | /* Fetch data to m_properties & m_settings: */
|
---|
126 | void fetchData(const QVariant &data);
|
---|
127 |
|
---|
128 | /* Upload m_properties & m_settings to data: */
|
---|
129 | void uploadData(QVariant &data) const;
|
---|
130 |
|
---|
131 | /* Global settings page constructor, hidden: */
|
---|
132 | UISettingsPageGlobal(QWidget *pParent = 0);
|
---|
133 |
|
---|
134 | /* Global data source: */
|
---|
135 | CSystemProperties m_properties;
|
---|
136 | VBoxGlobalSettings m_settings;
|
---|
137 | };
|
---|
138 |
|
---|
139 | /* Machine settings page class: */
|
---|
140 | class UISettingsPageMachine : public UISettingsPage
|
---|
141 | {
|
---|
142 | Q_OBJECT;
|
---|
143 |
|
---|
144 | protected:
|
---|
145 |
|
---|
146 | /* Fetch data to m_machine: */
|
---|
147 | void fetchData(const QVariant &data);
|
---|
148 |
|
---|
149 | /* Upload m_machine to data: */
|
---|
150 | void uploadData(QVariant &data) const;
|
---|
151 |
|
---|
152 | /* Machine settings page constructor, hidden: */
|
---|
153 | UISettingsPageMachine(QWidget *pParent = 0);
|
---|
154 |
|
---|
155 | /* Machine data source: */
|
---|
156 | CMachine m_machine;
|
---|
157 | };
|
---|
158 |
|
---|
159 | #endif // __UISettingsPage_h__
|
---|
160 |
|
---|