diff options
-rw-r--r-- | debian/libmeegotouch-bin.install | 2 | ||||
-rw-r--r-- | mkspecs/common.pri | 3 | ||||
-rw-r--r-- | mkspecs/features/meegotouch_defines.prf.in | 4 | ||||
-rw-r--r-- | projects.pro | 4 | ||||
-rw-r--r-- | src/corelib/workspace/mdeviceprofile.cpp | 157 | ||||
-rw-r--r-- | src/corelib/workspace/mdeviceprofile_p.h | 3 | ||||
-rw-r--r-- | src/data/devices.conf | 62 | ||||
-rw-r--r-- | src/data/meegotouch.schemas | 11 | ||||
-rw-r--r-- | src/data/targets/Default.conf | 12 | ||||
-rw-r--r-- | src/data/targets/N900.conf | 12 | ||||
-rw-r--r-- | src/data/targets/N95.conf | 12 | ||||
-rw-r--r-- | src/data/targets/N95i.conf | 12 | ||||
-rw-r--r-- | src/data/targets/N97.conf | 12 | ||||
-rw-r--r-- | src/data/targets/Pineapple.conf | 12 | ||||
-rw-r--r-- | src/data/targets/QVGAL.conf | 12 | ||||
-rw-r--r-- | src/data/targets/autodetect.conf | 11 | ||||
-rw-r--r-- | src/src.pro | 4 |
17 files changed, 238 insertions, 107 deletions
diff --git a/debian/libmeegotouch-bin.install b/debian/libmeegotouch-bin.install index a167e33c..340097da 100644 --- a/debian/libmeegotouch-bin.install +++ b/debian/libmeegotouch-bin.install @@ -3,6 +3,6 @@ usr/bin/mservicemapper usr/share/dbus-1/services/com.nokia.mservicefw.service usr/share/meegotouch/shaders/* usr/share/meegotouch/imtoolbars/RichTextEditorToolbar1.xml +usr/share/meegotouch/targets/*.conf usr/lib/meegotouch/applets/mappletrunner -etc/meegotouch/devices.conf etc/gconf/schemas/meegotouch.schemas diff --git a/mkspecs/common.pri b/mkspecs/common.pri index e68b3e7e..2f1eb472 100644 --- a/mkspecs/common.pri +++ b/mkspecs/common.pri @@ -77,6 +77,9 @@ include($${M_BUILD_TREE}/mkspecs/features/meegotouch_defines.prf) # M_BINARY_SHADERS_DIR defines the location of precompiled shader programs DEFINES += M_SHADER_SOURCE_DIR=\\\"\"$$M_SHADER_SOURCE_DIR\"\\\" DEFINES += M_SHADER_BINARY_DIR=\\\"\"$$M_SHADER_BINARY_DIR\"\\\" + + # M_TARGETS_CONF_DIR defines the location of target device config files + DEFINES += M_TARGETS_CONF_DIR=\\\"\"$$M_TARGETS_CONF_DIR\"\\\" } unix { diff --git a/mkspecs/features/meegotouch_defines.prf.in b/mkspecs/features/meegotouch_defines.prf.in index 4a4e8e18..d6005b08 100644 --- a/mkspecs/features/meegotouch_defines.prf.in +++ b/mkspecs/features/meegotouch_defines.prf.in @@ -58,6 +58,8 @@ unix|win32 { M_SHADER_SOURCE_DIR = $$M_INSTALL_DATA/meegotouch/shaders M_SHADER_BINARY_DIR = $$M_INSTALL_LOCALSTATE/cache/meegotouch/shaders + + M_TARGETS_CONF_DIR = $$M_INSTALL_DATA/meegotouch/targets } mac { @@ -83,6 +85,8 @@ mac { M_SHADER_SOURCE_DIR = $$M_INSTALL_DATA/meegotouch/shaders M_SHADER_BINARY_DIR = $$M_INSTALL_LOCALSTATE/cache/meegotouch/shaders + + M_TARGETS_CONF_DIR = $$M_INSTALL_DATA/meegotouch/targets } win32 { diff --git a/projects.pro b/projects.pro index e4d195f5..34bc76e7 100644 --- a/projects.pro +++ b/projects.pro @@ -107,7 +107,7 @@ QMAKE_EXTRA_TARGETS += check-xml # MeeGo Touch demo applications inside the build tree. setup.target = setup setup.CONFIG += no_check_exist -setup.commands = mkdir -p $$M_INSTALL_SYSCONF/meegotouch -setup.commands += && cp src/data/devices.conf $$M_INSTALL_SYSCONF/meegotouch +setup.commands = mkdir -p $$M_TARGETS_CONF_DIR +setup.commands += && cp src/data/targets/*.conf $$M_TARGETS_CONF_DIR setup.commands += && GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-install-rule src/data/meegotouch.schemas QMAKE_EXTRA_TARGETS += setup diff --git a/src/corelib/workspace/mdeviceprofile.cpp b/src/corelib/workspace/mdeviceprofile.cpp index 4d3bcbac..37e97fea 100644 --- a/src/corelib/workspace/mdeviceprofile.cpp +++ b/src/corelib/workspace/mdeviceprofile.cpp @@ -22,6 +22,12 @@ #include <QSettings> #include <QFile> #include <QDir> +#include <QDesktopWidget> + +#ifdef HAVE_DBUS +#include <QDBusConnection> +#include <QDBusConnectionInterface> +#endif #include "mdebug.h" #include "mdeviceprofile.h" @@ -30,22 +36,47 @@ #include "mapplication.h" #include "mcomponentdata.h" #include "mcomponentdata_p.h" +#include "mgconfitem.h" + +namespace{ +#ifdef HAVE_DBUS + const QString PIXMAP_PROVIDER_DBUS_SERVICE = "com.meego.core.MStatusBar"; +#endif +} + MDeviceProfilePrivate::MDeviceProfilePrivate() : q_ptr(0) { - QString filename = M_INSTALL_SYSCONFDIR "/meegotouch/devices.conf"; - + QString filename; + QString deviceName = MApplication::deviceName(); #ifdef Q_OS_WIN QDir appDir(QCoreApplication::applicationDirPath()); appDir.cdUp(); - appDir.cd("etc"); + appDir.cd("usr"); + appDir.cd("share"); appDir.cd("meegotouch"); - filename = appDir.path().append("/devices.conf" ); -#endif + appDir.cd("targets"); + if(deviceName.isEmpty()) + filename = appDir.path().append("Default.conf"); + else + filename = appDir.path().append(deviceName).append(".conf"); +#else //!Q_OS_WIN + if (!deviceName.isEmpty()){ + filename = M_TARGETS_CONF_DIR + QString("/") + deviceName + ".conf"; + + } else { +#ifdef HAVE_GCONF + const QString defaultTarget("/meegotouch/target/name"); + MGConfItem filenameItem(defaultTarget); + filename = M_TARGETS_CONF_DIR + QString("/") + filenameItem.value().toString() + ".conf"; +#endif //HAVE_GCONF + } +#endif //Q_OS_WIN - if(!load(filename)) { - qFatal("Failed to load device profile '%s'", qPrintable(filename)); + if (!load(filename)) { + qCritical("Failed to load device profile '%s'", qPrintable(filename)); + autodetection(); } } @@ -55,44 +86,67 @@ MDeviceProfilePrivate::~MDeviceProfilePrivate() bool MDeviceProfilePrivate::load(const QString& filename) { - QString device = MApplication::deviceName(); - if(device.isEmpty()) - device = "Default"; - - if(!QFile::exists(filename)) + if (!QFile::exists(filename)) return false; QSettings settings(filename, QSettings::IniFormat); - if(settings.status() != QSettings::NoError) + if (settings.status() != QSettings::NoError) return false; - resolution.setWidth(settings.value(device + "/resolutionX", 0).toInt()); - resolution.setHeight(settings.value(device + "/resolutionY", 0).toInt()); - pixelsPerInch.setWidth(settings.value(device + "/ppiX", 0).toInt()); - pixelsPerInch.setHeight(settings.value(device + "/ppiY", 0).toInt()); - showStatusBar=settings.value(device+"/showStatusBar",false).toBool(); - - QStringList orientationsForDevOpen = settings.value(device + "/allowedOrientationsOnKeyboardOpen", - QStringList()).toStringList(); - if (orientationsForDevOpen.contains("0")) - supportedOrientationsForKeyboardOpen << M::Angle0; - if (orientationsForDevOpen.contains("90")) - supportedOrientationsForKeyboardOpen << M::Angle90; - if (orientationsForDevOpen.contains("180")) - supportedOrientationsForKeyboardOpen << M::Angle180; - if (orientationsForDevOpen.contains("270")) - supportedOrientationsForKeyboardOpen << M::Angle270; - - QStringList orientationsForDevClosed = settings.value(device + "/allowedOrientationsOnKeyboardClosed", - QStringList()).toStringList(); - if (orientationsForDevClosed.contains("0")) - supportedOrientationsForKeyboardClosed << M::Angle0; - if (orientationsForDevClosed.contains("90")) - supportedOrientationsForKeyboardClosed << M::Angle90; - if (orientationsForDevClosed.contains("180")) - supportedOrientationsForKeyboardClosed << M::Angle180; - if (orientationsForDevClosed.contains("270")) - supportedOrientationsForKeyboardClosed << M::Angle270; + if (settings.value("/resolution/X").toString() == "autodetect") + resolution.setWidth(QApplication::desktop()->screenGeometry().size().width()); + else + resolution.setWidth(settings.value("/resolution/X", 0).toInt()); + + if (settings.value("/resolution/Y").toString() == "autodetect") + resolution.setHeight(QApplication::desktop()->screenGeometry().size().height()); + else + resolution.setHeight(settings.value("/resolution/Y", 0).toInt()); + + if (settings.value("/ppi/X").toString() == "autodetect") + pixelsPerInch.setWidth(QApplication::desktop()->physicalDpiX()); + else + pixelsPerInch.setWidth(settings.value("/ppi/X", 0).toInt()); + + if (settings.value("/ppi/Y") == "autodetect") + pixelsPerInch.setHeight(QApplication::desktop()->physicalDpiY()); + else + pixelsPerInch.setHeight(settings.value("/ppi/Y", 0).toInt()); + + if (settings.value("/other/showStatusBar").toString() == "autodetect") + showStatusBar = hasStatusbarProvider(); + else + showStatusBar=settings.value("/other/showStatusBar",false).toBool(); + + if (settings.value("/allowedOrientations/keyboardOpen").toString() == "autodetect"){ + supportedOrientationsForKeyboardClosed << M::Angle0 << M::Angle90 << M::Angle180 << M::Angle270; + } else { + QStringList orientationsForDevOpen = settings.value("/allowedOrientations/keyboardOpen", + QStringList()).toStringList(); + if (orientationsForDevOpen.contains("0")) + supportedOrientationsForKeyboardOpen << M::Angle0; + if (orientationsForDevOpen.contains("90")) + supportedOrientationsForKeyboardOpen << M::Angle90; + if (orientationsForDevOpen.contains("180")) + supportedOrientationsForKeyboardOpen << M::Angle180; + if (orientationsForDevOpen.contains("270")) + supportedOrientationsForKeyboardOpen << M::Angle270; + } + + if (settings.value("/allowedOrientations/keyboardOpen", "").toString() == "autodetect"){ + supportedOrientationsForKeyboardOpen << M::Angle0 << M::Angle90 << M::Angle180 << M::Angle270; + } else { + QStringList orientationsForDevClosed = settings.value("/allowedOrientations/keyboardClosed", + QStringList()).toStringList(); + if (orientationsForDevClosed.contains("0")) + supportedOrientationsForKeyboardClosed << M::Angle0; + if (orientationsForDevClosed.contains("90")) + supportedOrientationsForKeyboardClosed << M::Angle90; + if (orientationsForDevClosed.contains("180")) + supportedOrientationsForKeyboardClosed << M::Angle180; + if (orientationsForDevClosed.contains("270")) + supportedOrientationsForKeyboardClosed << M::Angle270; + } return true; } @@ -158,3 +212,26 @@ bool MDeviceProfile::orientationAngleIsSupported(M::OrientationAngle angle, bool else return d->supportedOrientationsForKeyboardClosed.contains(angle); } + +void MDeviceProfilePrivate::autodetection() +{ + QRect screenRect = QApplication::desktop()->screenGeometry(); + resolution = screenRect.size(); + + pixelsPerInch.setHeight(QApplication::desktop()->physicalDpiY()); + pixelsPerInch.setWidth(QApplication::desktop()->physicalDpiX()); + + showStatusBar = hasStatusbarProvider(); + + supportedOrientationsForKeyboardClosed << M::Angle0 << M::Angle90 << M::Angle180 << M::Angle270; + supportedOrientationsForKeyboardOpen << M::Angle0 << M::Angle90 << M::Angle180 << M::Angle270; +} + +bool MDeviceProfilePrivate::hasStatusbarProvider() +{ +#ifdef HAVE_DBUS + if (QDBusConnection::sessionBus().interface()->isServiceRegistered(PIXMAP_PROVIDER_DBUS_SERVICE)) + return true; +#endif + return false; +} diff --git a/src/corelib/workspace/mdeviceprofile_p.h b/src/corelib/workspace/mdeviceprofile_p.h index e9248ec9..c0815d72 100644 --- a/src/corelib/workspace/mdeviceprofile_p.h +++ b/src/corelib/workspace/mdeviceprofile_p.h @@ -34,6 +34,9 @@ public: bool load(const QString& filename); + void autodetection(); + bool hasStatusbarProvider(); + QSize resolution; QSize pixelsPerInch; bool showStatusBar; diff --git a/src/data/devices.conf b/src/data/devices.conf deleted file mode 100644 index 6e626878..00000000 --- a/src/data/devices.conf +++ /dev/null @@ -1,62 +0,0 @@ -[Default] -resolutionX=864 -resolutionY=480 -ppiX=261 -ppiY=261 -showStatusBar=true -allowedOrientationsOnKeyboardOpen = 0 -allowedOrientationsOnKeyboardClosed = 0,180,270 - -[N900] -resolutionX=800 -resolutionY=480 -ppiX=261 -ppiY=261 -showStatusBar=false -allowedOrientationsOnKeyboardOpen= 0 -allowedOrientationsOnKeyboardClosed = 0,180,270 - -[N95] -resolutionX=240 -resolutionY=320 -ppiX=153 -ppiY=153 -showStatusBar=false -allowedOrientationsOnKeyboardOpen = 270 -allowedOrientationsOnKeyboardClosed = 0 - -[N95i] -resolutionX=240 -resolutionY=800 -ppiX=152 -ppiY=152 -showStatusBar=false -allowedOrientationsOnKeyboardOpen = 270 -allowedOrientationsOnKeyboardClosed = 0 - -[Pineapple] -resolutionX=480 -resolutionY=320 -ppiX=163 -ppiY=163 -showStatusBar=false -allowedOrientationsOnKeyboardOpen = 0 -allowedOrientationsOnKeyboardClosed = 0,180,270 - -[QVGAL] -resolutionX=320 -resolutionY=240 -ppiX=152 -ppiY=152 -showStatusBar=true -allowedOrientationsOnKeyboardOpen= 0 -allowedOrientationsOnKeyboardClosed = 0,180,270 - -[N97] -resolutionX=640 -resolutionY=360 -ppiX=209 -ppiY=209 -showStatusBar=false -allowedOrientationsOnKeyboardOpen= 0 -allowedOrientationsOnKeyboardClosed = 0,180,270 diff --git a/src/data/meegotouch.schemas b/src/data/meegotouch.schemas index 53298dd8..b4ca92df 100644 --- a/src/data/meegotouch.schemas +++ b/src/data/meegotouch.schemas @@ -99,5 +99,16 @@ <long></long> </locale> </schema> + <schema> + <key>/schemas/meegotouch/target/name</key> + <applyto>/meegotouch/target/name</applyto> + <owner>libmeegotouch</owner> + <type>string</type> + <default>Default</default> + <locale name="C"> + <short>Is used to select target configuration file by Meego Touch applications</short> + <long></long> + </locale> + </schema> </schemalist> </gconfschemafile> diff --git a/src/data/targets/Default.conf b/src/data/targets/Default.conf new file mode 100644 index 00000000..c3b92adf --- /dev/null +++ b/src/data/targets/Default.conf @@ -0,0 +1,12 @@ +[resolution] +X=864 +Y=480 +[ppi] +X=261 +Y=261 +[allowedOrientations] +keyboardOpen = 0 +keyboardClosed = 0,180,270 +[other] +showStatusBar=true + diff --git a/src/data/targets/N900.conf b/src/data/targets/N900.conf new file mode 100644 index 00000000..fa61edc7 --- /dev/null +++ b/src/data/targets/N900.conf @@ -0,0 +1,12 @@ +[resolution] +X=800 +Y=480 +[ppi] +X=261 +Y=261 +[allowedOrientations] +keyboardOpen = 0 +keyboardClosed = 0,180,270 +[other] +showStatusBar=false + diff --git a/src/data/targets/N95.conf b/src/data/targets/N95.conf new file mode 100644 index 00000000..f0b02f41 --- /dev/null +++ b/src/data/targets/N95.conf @@ -0,0 +1,12 @@ +[resolution] +X=240 +Y=320 +[ppi] +X=153 +Y=153 +[allowedOrientations] +keyboardOpen = 270 +keyboardClosed = 0 +[other] +showStatusBar=false + diff --git a/src/data/targets/N95i.conf b/src/data/targets/N95i.conf new file mode 100644 index 00000000..b87f70d3 --- /dev/null +++ b/src/data/targets/N95i.conf @@ -0,0 +1,12 @@ +[resolution] +X=240 +Y=320 +[ppi] +X=152 +Y=152 +[allowedOrientations] +keyboardOpen = 270 +keyboardClosed = 0 +[other] +showStatusBar=false + diff --git a/src/data/targets/N97.conf b/src/data/targets/N97.conf new file mode 100644 index 00000000..b73295f0 --- /dev/null +++ b/src/data/targets/N97.conf @@ -0,0 +1,12 @@ +[resolution] +X=640 +Y=360 +[ppi] +X=209 +Y=209 +[allowedOrientations] +keyboardOpen = 0 +keyboardClosed = 0,180,270 +[other] +showStatusBar=false + diff --git a/src/data/targets/Pineapple.conf b/src/data/targets/Pineapple.conf new file mode 100644 index 00000000..4fc265db --- /dev/null +++ b/src/data/targets/Pineapple.conf @@ -0,0 +1,12 @@ +[resolution] +X=480 +Y=320 +[ppi] +X=163 +Y=163 +[allowedOrientations] +keyboardOpen = 0 +keyboardClosed = 0,180,270 +[other] +showStatusBar=false + diff --git a/src/data/targets/QVGAL.conf b/src/data/targets/QVGAL.conf new file mode 100644 index 00000000..eff07c2d --- /dev/null +++ b/src/data/targets/QVGAL.conf @@ -0,0 +1,12 @@ +[resolution] +X=320 +Y=240 +[ppi] +X=152 +Y=152 +[allowedOrientations] +keyboardOpen = 0 +keyboardClosed = 270 +[other] +showStatusBar=false + diff --git a/src/data/targets/autodetect.conf b/src/data/targets/autodetect.conf new file mode 100644 index 00000000..403093be --- /dev/null +++ b/src/data/targets/autodetect.conf @@ -0,0 +1,11 @@ +[resolution] +X=autodetect +Y=autodetect +[ppi] +X=autodetect +Y=autodetect +[allowedOrientations] +keyboardOpen = autodetect +keyboardClosed = autodetect +[other] +showStatusBar=autodetect diff --git a/src/src.pro b/src/src.pro index f60a9dc3..b67d4aeb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -22,8 +22,8 @@ contains(DEFINES, HAVE_GCONF) { #install device configuration file devices.CONFIG += no_check_exist -devices.files = $${IN_PWD}/data/devices.conf -devices.path = $$M_INSTALL_SYSCONF/meegotouch +devices.files = $${IN_PWD}/data/targets/*.conf +devices.path = $${M_TARGETS_CONF_DIR} INSTALLS += devices # install MeeGo Touch feature files |