equal
deleted
inserted
replaced
26 #include "hbdeviceprofile.h" |
26 #include "hbdeviceprofile.h" |
27 #include "hbdeviceprofiledatabase_p.h" |
27 #include "hbdeviceprofiledatabase_p.h" |
28 #include "hbinstance_p.h" |
28 #include "hbinstance_p.h" |
29 #include "hbmemorymanager_p.h" |
29 #include "hbmemorymanager_p.h" |
30 #include "hbtheme_p.h" |
30 #include "hbtheme_p.h" |
|
31 #include "hbthemeclient_p.h" |
31 #include <hbmainwindow.h> |
32 #include <hbmainwindow.h> |
32 #include "hbmainwindow_p.h" |
33 #include "hbmainwindow_p.h" |
33 |
34 |
|
35 #include <QDebug> |
|
36 |
34 // To store the pointer to the deviceProfiles at the client side. |
37 // To store the pointer to the deviceProfiles at the client side. |
35 static HbDeviceProfileList *deviceProfilesList = NULL; |
38 static HbDeviceProfileList *deviceProfilesList = NULL; |
|
39 |
|
40 #define MM_PER_INCH 25.4 |
36 |
41 |
37 /*! |
42 /*! |
38 @stable |
43 @stable |
39 @hbcore |
44 @hbcore |
40 \class HbDeviceProfile |
45 \class HbDeviceProfile |
72 */ |
77 */ |
73 HbDeviceProfile::HbDeviceProfile(const QString &name) : d_ptr(new HbDeviceProfilePrivate) |
78 HbDeviceProfile::HbDeviceProfile(const QString &name) : d_ptr(new HbDeviceProfilePrivate) |
74 { |
79 { |
75 if (d_ptr->deviceProfiles()) { |
80 if (d_ptr->deviceProfiles()) { |
76 int count = deviceProfilesList->count(); |
81 int count = deviceProfilesList->count(); |
77 for (int i = 0; i < count; i++) { |
82 bool found( false ); |
|
83 for (int i = 0; !found && i < count; i++) { |
78 if (deviceProfilesList->at(i).mName == name) { |
84 if (deviceProfilesList->at(i).mName == name) { |
79 d_ptr->mProfile = deviceProfilesList->at(i); |
85 d_ptr->mProfile = deviceProfilesList->at(i); |
80 break; |
86 found = true; |
81 } |
87 } |
|
88 } |
|
89 if (!found) { |
|
90 qWarning() << "Device profile" << name << "not found!"; |
82 } |
91 } |
83 } |
92 } |
84 } |
93 } |
85 |
94 |
86 |
95 |
132 /*! |
141 /*! |
133 Returns physical screen size in mm. |
142 Returns physical screen size in mm. |
134 */ |
143 */ |
135 QSizeF HbDeviceProfile::physicalSize() const |
144 QSizeF HbDeviceProfile::physicalSize() const |
136 { |
145 { |
137 return d_ptr->mProfile.mPhysicalSize; |
146 QSizeF physicalSize(d_ptr->mProfile.mLogicalSize); |
|
147 physicalSize /= ppmValue(); |
|
148 return physicalSize; |
138 } |
149 } |
139 |
150 |
140 /*! |
151 /*! |
141 Returns logical orientation (\c Qt::Vertical for portrait, \c Qt::Horizontal for landscape). |
152 Returns logical orientation (\c Qt::Vertical for portrait, \c Qt::Horizontal for landscape). |
142 */ |
153 */ |
143 Qt::Orientation HbDeviceProfile::orientation() const |
154 Qt::Orientation HbDeviceProfile::orientation() const |
144 { |
155 { |
145 return d_ptr->mProfile.mOrientation; |
156 QSize s = d_ptr->mProfile.mLogicalSize; |
|
157 return (s.width() > s.height()) ? Qt::Horizontal : Qt::Vertical; |
146 } |
158 } |
147 |
159 |
148 /*! |
160 /*! |
149 Returns the amount of rotation in degrees for the transformed orientation. |
161 Returns the amount of rotation in degrees for the transformed orientation. |
150 Supported ones are 0 (no rotate transform), 90 and 270. |
162 Supported ones are 0 (no rotate transform), 90 and 270. |
190 /*! |
202 /*! |
191 Returns pixels per millimeter value. |
203 Returns pixels per millimeter value. |
192 */ |
204 */ |
193 qreal HbDeviceProfile::ppmValue() const |
205 qreal HbDeviceProfile::ppmValue() const |
194 { |
206 { |
195 // Assuming square pixels |
207 return d_ptr->mProfile.mPpiValue / MM_PER_INCH; |
196 if (d_ptr->mProfile.mPhysicalSize.width() != 0) { |
|
197 return d_ptr->mProfile.mLogicalSize.width() / d_ptr->mProfile.mPhysicalSize.width(); |
|
198 } |
|
199 return 0.0; |
|
200 } |
208 } |
201 |
209 |
202 /*! |
210 /*! |
203 Returns current global profile reflecting properties of primary display. |
211 Returns current global profile reflecting properties of primary display. |
204 |
212 |