Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Meego:Tablet
libmeegotouch
BMC13246_0005-Changed-MStyleSheetAttribute-cons...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File BMC13246_0005-Changed-MStyleSheetAttribute-consider-device-s-nativ.patch of Package libmeegotouch
From 23445365cf982a77df64037be21ace39d31ca2ef Mon Sep 17 00:00:00 2001 From: Shane Bryan <shane.bryan@linux.intel.com> Date: Mon, 14 Mar 2011 16:35:20 -0700 Subject: [PATCH 5/9] Changed: MStyleSheetAttribute - consider device's native orientation Details: When converting attributes from percentages to int or float values, base result on device's native orientation, not just the specified orientation that the attribute applies to. Part of fix for BMC#13264. --- src/corelib/style/mstylesheetattribute.cpp | 72 +++++++++++++++++----------- src/corelib/style/mstylesheetattribute.h | 1 + 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/corelib/style/mstylesheetattribute.cpp b/src/corelib/style/mstylesheetattribute.cpp index 22045d6..9376ccf 100644 --- a/src/corelib/style/mstylesheetattribute.cpp +++ b/src/corelib/style/mstylesheetattribute.cpp @@ -302,6 +302,46 @@ qint64 MStyleSheetAttribute::getPosition() const return position; } +int MStyleSheetAttribute::maxValueForDevice(SizeAttributeType type, M::Orientation orientation) +{ + // Percentages must be based on the devices native orientation, so + // here we are returning the correct sizes based on the device AND the + // requested orientation. + // + // Another way of putting is, for portrait native devices: + // M::landscape == MDeviceProfile::instance()->resolution().height() + // While, for landscape native devices: + // M::landscape == MDeviceProfile::instance()->resolution().width() + + if (MDeviceProfile::instance()->orientationFromAngle(M::Angle0) == M::Landscape) { + // native display orientation is landscape + if (orientation == M::Landscape) { + if (type == WidthAttribute) + return MDeviceProfile::instance()->resolution().width(); + else + return MDeviceProfile::instance()->resolution().height(); + } else { + if (type == WidthAttribute) + return MDeviceProfile::instance()->resolution().height(); + else + return MDeviceProfile::instance()->resolution().width(); + } + } else { + // native display orientation is portrait + if (orientation == M::Landscape) { + if (type == WidthAttribute) + return MDeviceProfile::instance()->resolution().height(); + else + return MDeviceProfile::instance()->resolution().width(); + } else { + if (type == WidthAttribute) + return MDeviceProfile::instance()->resolution().width(); + else + return MDeviceProfile::instance()->resolution().height(); + } + } +} + int MStyleSheetAttribute::attributeToInt(const QByteArray &attribute, bool *conversionOk) { QByteArray value = attribute.trimmed(); @@ -334,21 +374,9 @@ int MStyleSheetAttribute::attributeToInt(const QByteArray &attribute, bool *conv QByteArray value = attribute.trimmed(); if (attribute.endsWith(units[PERCENT_UNIT])) { - int maximumValue = 0; + int maximumValue = maxValueForDevice(type, orientation); - if (orientation == M::Landscape) { - *cacheOrientation = LandscapeFlag; - if (type == WidthAttribute) - maximumValue = MDeviceProfile::instance()->resolution().width(); - else - maximumValue = MDeviceProfile::instance()->resolution().height(); - } else { - *cacheOrientation = PortraitFlag; - if (type == WidthAttribute) - maximumValue = MDeviceProfile::instance()->resolution().height(); - else - maximumValue = MDeviceProfile::instance()->resolution().width(); - } + *cacheOrientation = (orientation==M::Landscape) ? LandscapeFlag : PortraitFlag; value.truncate(value.length() - 1); @@ -392,21 +419,9 @@ qreal MStyleSheetAttribute::attributeToFloat(const QByteArray &attribute, bool * QByteArray value = attribute.trimmed(); if (attribute.endsWith(units[PERCENT_UNIT])) { - int maximumValue = 0; + int maximumValue = maxValueForDevice(type, orientation); - if (orientation == M::Landscape) { - *cacheOrientation = LandscapeFlag; - if (type == WidthAttribute) - maximumValue = MDeviceProfile::instance()->resolution().width(); - else - maximumValue = MDeviceProfile::instance()->resolution().height(); - } else { - *cacheOrientation = PortraitFlag; - if (type == WidthAttribute) - maximumValue = MDeviceProfile::instance()->resolution().height(); - else - maximumValue = MDeviceProfile::instance()->resolution().width(); - } + *cacheOrientation = (orientation==M::Landscape) ? LandscapeFlag : PortraitFlag; value.truncate(value.length() - 1); diff --git a/src/corelib/style/mstylesheetattribute.h b/src/corelib/style/mstylesheetattribute.h index e1147bb..c6e0720 100644 --- a/src/corelib/style/mstylesheetattribute.h +++ b/src/corelib/style/mstylesheetattribute.h @@ -54,6 +54,7 @@ public: MUniqueStringCache::Index getValueID() const; qint64 getPosition() const; + static int maxValueForDevice(SizeAttributeType type, M::Orientation orientation); static int attributeToInt(const QByteArray &attribute, bool *conversionOk); static int attributeToInt(const QByteArray &attribute, bool *conversionOk, SizeAttributeType type, M::Orientation orientation, CacheOrientationFlags *cacheOrientation); static qreal attributeToFloat(const QByteArray &attribute, bool *conversionOk); -- 1.7.2.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor