1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * VMGlobalSettingsData, VMGlobalSettings class declarations
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __VMGlobalSettings_h__
|
---|
24 | #define __VMGlobalSettings_h__
|
---|
25 |
|
---|
26 | #include "CIShared.h"
|
---|
27 |
|
---|
28 | #include <qobject.h>
|
---|
29 |
|
---|
30 | class CVirtualBox;
|
---|
31 |
|
---|
32 | class VMGlobalSettingsData
|
---|
33 | {
|
---|
34 | public:
|
---|
35 |
|
---|
36 | VMGlobalSettingsData();
|
---|
37 | VMGlobalSettingsData( const VMGlobalSettingsData &that );
|
---|
38 | virtual ~VMGlobalSettingsData();
|
---|
39 | bool operator==( const VMGlobalSettingsData &that ) const;
|
---|
40 |
|
---|
41 | private:
|
---|
42 |
|
---|
43 | int hostkey;
|
---|
44 | bool autoCapture;
|
---|
45 | QString guiFeatures;
|
---|
46 |
|
---|
47 | friend class VMGlobalSettings;
|
---|
48 | };
|
---|
49 |
|
---|
50 | /////////////////////////////////////////////////////////////////////////////
|
---|
51 |
|
---|
52 | class VMGlobalSettings : public QObject, public CIShared <VMGlobalSettingsData>
|
---|
53 | {
|
---|
54 | Q_OBJECT
|
---|
55 | Q_PROPERTY (int hostKey READ hostKey WRITE setHostKey)
|
---|
56 | Q_PROPERTY (bool autoCapture READ autoCapture WRITE setAutoCapture)
|
---|
57 | Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures)
|
---|
58 |
|
---|
59 | public:
|
---|
60 |
|
---|
61 | VMGlobalSettings (bool null = true)
|
---|
62 | : CIShared <VMGlobalSettingsData> (null) {}
|
---|
63 | VMGlobalSettings (const VMGlobalSettings &that)
|
---|
64 | : QObject(), CIShared <VMGlobalSettingsData> (that) {}
|
---|
65 | VMGlobalSettings &operator= (const VMGlobalSettings &that) {
|
---|
66 | CIShared <VMGlobalSettingsData>::operator= (that);
|
---|
67 | return *this;
|
---|
68 | }
|
---|
69 |
|
---|
70 | // Properties
|
---|
71 |
|
---|
72 | int hostKey() const { return data()->hostkey; }
|
---|
73 | void setHostKey (int key);
|
---|
74 |
|
---|
75 | bool autoCapture() const { return data()->autoCapture; }
|
---|
76 | void setAutoCapture (bool autoCapture) {
|
---|
77 | mData()->autoCapture = autoCapture;
|
---|
78 | resetError();
|
---|
79 | }
|
---|
80 |
|
---|
81 | QString guiFeatures() const { return data()->guiFeatures; }
|
---|
82 | void setGuiFeatures (const QString &aFeatures)
|
---|
83 | {
|
---|
84 | mData()->guiFeatures = aFeatures;
|
---|
85 | }
|
---|
86 | bool isFeatureActivated (const char*) const;
|
---|
87 |
|
---|
88 | //
|
---|
89 |
|
---|
90 | void load (CVirtualBox &vbox);
|
---|
91 | void save (CVirtualBox &vbox) const;
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * Returns true if the last setter or #load() operation has been failed
|
---|
95 | * and false otherwise.
|
---|
96 | */
|
---|
97 | bool operator !() const { return !last_err.isEmpty(); }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Returns the description of the error set by the last setter or #load()
|
---|
101 | * operation, or an empty (or null) string if the last operation was
|
---|
102 | * successful.
|
---|
103 | */
|
---|
104 | QString lastError() const { return last_err; }
|
---|
105 |
|
---|
106 | QString publicProperty (const QString &publicName) const;
|
---|
107 | bool setPublicProperty (const QString &publicName, const QString &value);
|
---|
108 |
|
---|
109 | signals:
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * This sighal is emitted only when #setPublicProperty() or #load() is called.
|
---|
113 | * Direct modification of properties through individual setters or through
|
---|
114 | * QObject::setProperty() currently cannot be tracked.
|
---|
115 | */
|
---|
116 | void propertyChanged (const char *publicName, const char *name);
|
---|
117 |
|
---|
118 | private:
|
---|
119 |
|
---|
120 | void setPropertyPrivate (int index, const QString &value);
|
---|
121 | void resetError() { last_err = QString::null; }
|
---|
122 |
|
---|
123 | QString last_err;
|
---|
124 | };
|
---|
125 |
|
---|
126 | #endif // __VMGlobalSettings_h__
|
---|