|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * cxesettings.h |
|
19 * |
|
20 * Created on: Dec 30, 2008 |
|
21 * |
|
22 */ |
|
23 #ifndef CXESETTINGS_H_ |
|
24 #define CXESETTINGS_H_ |
|
25 |
|
26 #include <QObject> |
|
27 #include <QString> |
|
28 #include <QVariant> |
|
29 |
|
30 #include "cxenamespace.h" |
|
31 #include "cxeerror.h" |
|
32 |
|
33 |
|
34 // forward declaration |
|
35 class CxeSettingsModel; |
|
36 |
|
37 |
|
38 |
|
39 /* |
|
40 * Class to access all kind of Camera Settings |
|
41 */ |
|
42 class CxeSettings : public QObject |
|
43 { |
|
44 |
|
45 Q_OBJECT |
|
46 |
|
47 public: |
|
48 |
|
49 /* |
|
50 * returns the current integer setting value for the given key |
|
51 */ |
|
52 virtual CxeError::Id get(const QString &key, int &value) const = 0; |
|
53 |
|
54 /* |
|
55 * returns the current real setting value for the given key |
|
56 */ |
|
57 virtual CxeError::Id get(const QString &key, qreal &value) const = 0; |
|
58 |
|
59 /* |
|
60 * returns the current string setting value for the given key |
|
61 */ |
|
62 virtual CxeError::Id get(const QString &key, QString &stringValue) const = 0; |
|
63 |
|
64 /* |
|
65 * Returns value of external setting item which is not owned by camera |
|
66 */ |
|
67 virtual void get(long int uid, |
|
68 unsigned long int key, |
|
69 Cxe::SettingKeyType type, |
|
70 QVariant &value) const = 0; |
|
71 |
|
72 /** |
|
73 * Get a value of a certain setting. A convenience method with a template |
|
74 * parameter to be used with enumerations. |
|
75 * |
|
76 * An example: |
|
77 * \code |
|
78 * Cxe::Whitebalance wb = Cxe::WhitebalanceAutomatic; |
|
79 * if (settings.get<Cxe::Whitebalance>(CxeSettingIds::WHITE_BALANCE, wb)) { |
|
80 * CX_DEBUG(("Error getting white balance - using default")); |
|
81 * } |
|
82 * \endcode |
|
83 * @param settingId Setting key |
|
84 * @param value Reference to a variable where to put the setting value |
|
85 * @return Error code |
|
86 */ |
|
87 template<typename T> |
|
88 inline CxeError::Id get(const QString &key, T &value) const { |
|
89 int intValue = value; // This will not compile if T cannot be converted to an int |
|
90 CxeError::Id err = get(key, intValue); |
|
91 value = static_cast<T>(intValue); // Convert to enum |
|
92 return err; |
|
93 } |
|
94 |
|
95 /* |
|
96 * Set new values for the given key |
|
97 */ |
|
98 virtual CxeError::Id set(const QString &key, int newValue) = 0; |
|
99 |
|
100 /* |
|
101 * Set new values for the given key |
|
102 */ |
|
103 virtual CxeError::Id set(const QString &key, qreal newValue) = 0; |
|
104 |
|
105 /* |
|
106 * Set new values for the given key |
|
107 */ |
|
108 virtual CxeError::Id set(const QString &key, const QString &newValue) = 0; |
|
109 |
|
110 /* |
|
111 * Resets only virtual settings( persistent settings ) |
|
112 */ |
|
113 virtual void reset() = 0; |
|
114 |
|
115 signals: |
|
116 /* |
|
117 * to notify engine and ui components for a change in a setting value |
|
118 */ |
|
119 void settingValueChanged(const QString &key, QVariant newValue); |
|
120 |
|
121 /* |
|
122 * to notify engine and ui components for a change in a setting value |
|
123 */ |
|
124 void settingValueChanged(long int uid, unsigned long int key, QVariant value); |
|
125 |
|
126 /* |
|
127 * to update engine and ui components of new image scene |
|
128 */ |
|
129 void sceneChanged(CxeScene &scene); |
|
130 |
|
131 protected: |
|
132 CxeSettings() {} |
|
133 |
|
134 private: |
|
135 Q_DISABLE_COPY( CxeSettings ) |
|
136 }; |
|
137 |
|
138 #endif /*CXESETTINGS_H_*/ |
|
139 |
|
140 // end of file |