[android-qt/experimental] src: QPlatformDesktopService implementation for Android

BogDan Vatra bog_dan_ro at yahoo.com
Mon Jun 20 16:47:39 CEST 2011


Git commit 92265248f286372226e42f14d2206bcd67b646a9 by BogDan Vatra.
Committed on 20/06/2011 at 14:17.
Pushed by vatra into branch 'experimental'.

QPlatformDesktopService implementation for Android

FEATURE: 276127
CCMAIL: necessitas-devel at kde.org

M  +5    -3    src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java     
M  +9    -0    src/android/java/src/eu/licentia/necessitas/industrius/QtApplication.java     
M  +9    -7    src/gui/kernel/kernel.pri     
A  +32   -0    src/gui/kernel/qplatformdesktopservice_qpa.cpp         [License: Public Domain]
A  +34   -0    src/gui/kernel/qplatformdesktopservice_qpa.h         [License: Public Domain]
M  +12   -1    src/gui/kernel/qplatformintegration_qpa.cpp     
M  +5    -0    src/gui/kernel/qplatformintegration_qpa.h     
M  +9    -3    src/gui/util/qdesktopservices.cpp     
M  +6    -1    src/plugins/platforms/android/common/sw/androidjnimain.cpp     
M  +4    -1    src/plugins/platforms/android/common/sw/androidjnimain.h     
A  +104  -0    src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.cpp         [License: BSD]
A  +47   -0    src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.h         [License: BSD]
M  +33   -26   src/plugins/platforms/android/common/sw/qandroidplatformintegration.cpp     
M  +10   -6    src/plugins/platforms/android/common/sw/qandroidplatformintegration.h     
M  +2    -0    src/plugins/platforms/android/common/sw/sw.pri     

http://commits.kde.org/android-qt/92265248f286372226e42f14d2206bcd67b646a9

diff --git a/src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java b/src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java
index de666d2..b4e92b4 100644
--- a/src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java
+++ b/src/android/java/src/eu/licentia/necessitas/industrius/QtActivity.java
@@ -123,11 +123,13 @@ public class QtActivity extends Activity {
                 params += ai.metaData.getString("android.app.application_startup_params");
             }
 
-            final String homePath="HOME="+getFilesDir().getAbsolutePath()+"\tTMPDIR="+getFilesDir().getAbsolutePath();
+            final String envPaths="HOME="+getFilesDir().getAbsolutePath()+
+                                "\tTMPDIR="+getFilesDir().getAbsolutePath()+
+                                "\tCACHE_PATH="+getCacheDir().getAbsolutePath();
             if (environment != null && environment.length()>0)
-                environment=homePath+"\t"+environment;
+                environment=envPaths+"\t"+environment;
             else
-                environment=homePath;
+                environment=envPaths;
 
             QtApplication.startApplication(params, environment);
             m_surface.applicationStared();
diff --git a/src/android/java/src/eu/licentia/necessitas/industrius/QtApplication.java b/src/android/java/src/eu/licentia/necessitas/industrius/QtApplication.java
index 3445e11..74a815b 100644
--- a/src/android/java/src/eu/licentia/necessitas/industrius/QtApplication.java
+++ b/src/android/java/src/eu/licentia/necessitas/industrius/QtApplication.java
@@ -31,6 +31,8 @@ import java.io.File;
 import java.util.ArrayList;
 
 import android.app.Application;
+import android.content.Intent;
+import android.net.Uri;
 import android.util.Log;
 import android.view.MotionEvent;
 
@@ -62,6 +64,13 @@ public class QtApplication extends Application
         return m_mainView;
     }
 
+    public static void openURL(String url)
+    {
+        Uri uri = Uri.parse(url);
+        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+        mainActivity().startActivity(intent);
+    }
+
     // this method loads full path libs
     public static void loadQtLibraries(String[] libraries)
     {
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 3c57368..cde76ce 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -7,7 +7,7 @@ PRECOMPILED_HEADER = kernel/qt_gui_pch.h
 KERNEL_P= kernel
 HEADERS += \
 	kernel/qaction.h \
-    kernel/qaction_p.h \
+        kernel/qaction_p.h \
 	kernel/qactiongroup.h \
 	kernel/qapplication.h \
 	kernel/qapplication_p.h \
@@ -35,8 +35,8 @@ HEADERS += \
 	kernel/qstackedlayout.h \
 	kernel/qtooltip.h \
 	kernel/qwhatsthis.h \
-    kernel/qwidget.h \
-    kernel/qwidget_p.h \
+        kernel/qwidget.h \
+        kernel/qwidget_p.h \
 	kernel/qwidgetaction.h \
 	kernel/qwidgetaction_p.h \
 	kernel/qwindowdefs.h \
@@ -47,7 +47,7 @@ HEADERS += \
 	kernel/qgesturerecognizer.h \
 	kernel/qgesturemanager_p.h \
 	kernel/qsoftkeymanager_p.h \
-    kernel/qsoftkeymanager_common_p.h \
+        kernel/qsoftkeymanager_common_p.h \
 	kernel/qguiplatformplugin_p.h \
 
 SOURCES += \
@@ -82,7 +82,7 @@ SOURCES += \
 	kernel/qgesturerecognizer.cpp \
 	kernel/qgesturemanager.cpp \
 	kernel/qsoftkeymanager.cpp \
-    kernel/qdesktopwidget.cpp \
+        kernel/qdesktopwidget.cpp \
 	kernel/qguiplatformplugin.cpp
 
 win32 {
@@ -101,8 +101,8 @@ win32 {
 		kernel/qsound_win.cpp \
 		kernel/qwidget_win.cpp \
 		kernel/qole_win.cpp \
-        kernel/qkeymapper_win.cpp \
-        kernel/qwinnativepangesturerecognizer_win.cpp
+                kernel/qkeymapper_win.cpp \
+                kernel/qwinnativepangesturerecognizer_win.cpp
 
     !contains(DEFINES, QT_NO_DIRECTDRAW):LIBS += ddraw.lib
 }
@@ -215,6 +215,7 @@ qpa {
                 kernel/qeventdispatcher_qpa_p.h \
                 kernel/qwindowsysteminterface_qpa.h \
                 kernel/qwindowsysteminterface_qpa_p.h \
+                kernel/qplatformdesktopservice_qpa.h \
                 kernel/qplatformintegration_qpa.h \
                 kernel/qplatformscreen_qpa.h \
                 kernel/qplatformintegrationfactory_qpa_p.h \
@@ -240,6 +241,7 @@ qpa {
                 kernel/qwidget_qpa.cpp \
                 kernel/qeventdispatcher_qpa.cpp \
                 kernel/qwindowsysteminterface_qpa.cpp \
+                kernel/qplatformdesktopservice_qpa.cpp \
                 kernel/qplatformintegration_qpa.cpp \
                 kernel/qplatformscreen_qpa.cpp \
                 kernel/qplatformintegrationfactory_qpa.cpp \
diff --git a/src/gui/kernel/qplatformdesktopservice_qpa.cpp b/src/gui/kernel/qplatformdesktopservice_qpa.cpp
new file mode 100644
index 0000000..3453eeb
--- /dev/null
+++ b/src/gui/kernel/qplatformdesktopservice_qpa.cpp
@@ -0,0 +1,32 @@
+/*
+I BogDan Vatra < bog_dan_ro at yahoo.com >, the copyright holder of this work,
+hereby release it into the public domain. This applies worldwide.
+
+In case this is not legally possible, I grant any entity the right to use
+this work for any purpose, without any conditions, unless such conditions
+are required by law.
+*/
+
+#include "qplatformdesktopservice_qpa.h"
+
+/*!
+Documentation needed
+*/
+
+QString QPlatformDesktopService::storageLocation ( QDesktopServices::StandardLocation /*type*/ )
+{
+    return QString();
+}
+
+/*!
+Documentation needed
+*/
+QString QPlatformDesktopService::displayName ( QDesktopServices::StandardLocation /*type*/ )
+{
+    return QString();
+}
+
+bool QPlatformDesktopService::openUrl ( const QUrl & /*url */)
+{
+    return false;
+}
diff --git a/src/gui/kernel/qplatformdesktopservice_qpa.h b/src/gui/kernel/qplatformdesktopservice_qpa.h
new file mode 100644
index 0000000..1b2b6c7
--- /dev/null
+++ b/src/gui/kernel/qplatformdesktopservice_qpa.h
@@ -0,0 +1,34 @@
+/*
+I BogDan Vatra < bog_dan_ro at yahoo.com >, the copyright holder of this work,
+hereby release it into the public domain. This applies worldwide.
+
+In case this is not legally possible, I grant any entity the right to use
+this work for any purpose, without any conditions, unless such conditions
+are required by law.
+*/
+
+#ifndef QPLATFORMDESKTOPSERVICE_QPA_H
+#define QPLATFORMDESKTOPSERVICE_QPA_H
+
+#include <QDesktopServices>
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformDesktopService
+{
+public:
+    virtual ~QPlatformDesktopService() { }
+    virtual QString displayName ( QDesktopServices::StandardLocation type );
+    virtual bool openUrl ( const QUrl & url );
+    virtual QString storageLocation ( QDesktopServices::StandardLocation type );
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QPLATFORMDESKTOPSERVICE_QPA_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
index 8ff12eb..1918b36 100644
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -43,6 +43,7 @@
 
 #include <QtGui/QPlatformFontDatabase>
 #include <QtGui/QPlatformClipboard>
+#include <QtGui/QPlatformDesktopService>
 
 QT_BEGIN_NAMESPACE
 
@@ -218,7 +219,17 @@ bool QPlatformIntegration::hasCapability(Capability cap) const
     return false;
 }
 
-
+/*!
+  Documentation needed
+*/
+QPlatformDesktopService * QPlatformIntegration::platformDesktopService()
+{
+    static QPlatformDesktopService *ds = 0;
+    if (!ds) {
+        ds = new QPlatformDesktopService;
+    }
+    return ds;
+}
 
 
 
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
index d06272c..2c4cd77 100644
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -61,6 +61,7 @@ class QPlatformEventLoopIntegration;
 class QPlatformFontDatabase;
 class QPlatformClipboard;
 class QPlatformNativeInterface;
+class QPlatformDesktopService;
 
 class Q_GUI_EXPORT QPlatformIntegration
 {
@@ -98,6 +99,10 @@ public:
 
 // Access native handles. The window handle is already available from Wid;
     virtual QPlatformNativeInterface *nativeInterface() const;
+
+// System hooks
+    virtual QPlatformDesktopService * platformDesktopService();
+
 };
 
 QT_END_NAMESPACE
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index cb5a3ef..69a3abe 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -45,7 +45,9 @@
 
 #include <qdebug.h>
 
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+#if defined(Q_WS_QPA)
+#include "qdesktopservices_qpa.cpp"
+#elif defined(Q_WS_QWS)
 #include "qdesktopservices_qws.cpp"
 #elif defined(Q_WS_X11)
 #include "qdesktopservices_x11.cpp"
@@ -194,13 +196,17 @@ bool QDesktopServices::openUrl(const QUrl &url)
             return result; // ### support bool slot return type
         }
     }
-
     bool result;
+#if defined(Q_WS_QPA)
+    qDebug()<<"#if defined(Q_WS_QPA)";
+    result = QApplicationPrivate::platformIntegration()->platformDesktopService()->openUrl(url);
+#else
+    qDebug()<<"#else defined(Q_WS_QPA)";
     if (url.scheme() == QLatin1String("file"))
         result = openDocument(url);
     else
         result = launchWebBrowser(url);
-
+#endif
     return result;
 }
 
diff --git a/src/plugins/platforms/android/common/sw/androidjnimain.cpp b/src/plugins/platforms/android/common/sw/androidjnimain.cpp
index 0cf5b36..d115e77 100644
--- a/src/plugins/platforms/android/common/sw/androidjnimain.cpp
+++ b/src/plugins/platforms/android/common/sw/androidjnimain.cpp
@@ -211,11 +211,16 @@ namespace QtAndroid
         m_javaVM->DetachCurrentThread();
     }
 
-    void * javaVM()
+    JavaVM * javaVM()
     {
         return m_javaVM;
     }
 
+    jclass applicationClass()
+    {
+        return m_applicationClass;
+    }
+
 }
 
 static void startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*/)
diff --git a/src/plugins/platforms/android/common/sw/androidjnimain.h b/src/plugins/platforms/android/common/sw/androidjnimain.h
index 4f53cda..099b007 100644
--- a/src/plugins/platforms/android/common/sw/androidjnimain.h
+++ b/src/plugins/platforms/android/common/sw/androidjnimain.h
@@ -28,6 +28,8 @@
 #ifndef ANDROID_APP_H
 #define ANDROID_APP_H
 
+#include<jni.h>
+
 class QImage;
 class QRect;
 class QPoint;
@@ -46,6 +48,7 @@ namespace QtAndroid
     void hideSoftwareKeyboard();
     // Software keyboard support
 
-    void * javaVM();
+    JavaVM * javaVM();
+    jclass applicationClass();
 }
 #endif // ANDROID_APP_H
diff --git a/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.cpp b/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.cpp
new file mode 100644
index 0000000..2746b03
--- /dev/null
+++ b/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.cpp
@@ -0,0 +1,104 @@
+/*
+    Copyright (c) 2009-2011, BogDan Vatra <bog_dan_ro at yahoo.com>
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+        * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+        * Neither the name of the  BogDan Vatra <bog_dan_ro at yahoo.com> nor the
+        names of its contributors may be used to endorse or promote products
+        derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY BogDan Vatra <bog_dan_ro at yahoo.com> ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL BogDan Vatra <bog_dan_ro at yahoo.com> BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "qandroidplatformdesktopservice.h"
+#include <QUrl>
+#include <QDir>
+#include <QDebug>
+
+QAndroidPlatformDesktopService::QAndroidPlatformDesktopService()
+{
+    JNIEnv* env;
+    if (QtAndroid::javaVM()->AttachCurrentThread(&env, NULL)<0)
+    {
+        qCritical()<<"AttachCurrentThread failed";
+        return;
+    }
+    m_openURIMethodID=env->GetStaticMethodID(QtAndroid::applicationClass(), "openURL", "(Ljava/lang/String;)V");
+}
+
+bool QAndroidPlatformDesktopService::openUrl ( const QUrl & url )
+{
+    JNIEnv* env;
+    if (QtAndroid::javaVM()->AttachCurrentThread(&env, NULL)<0)
+    {
+        qCritical()<<"AttachCurrentThread failed";
+        return false;
+    }
+    jstring string = env->NewString((const jchar*)url.toString().constData(), url.toString().length());
+    env->CallStaticVoidMethod(QtAndroid::applicationClass(), m_openURIMethodID,string);
+    env->DeleteLocalRef(string);
+    return true;
+}
+
+QString QAndroidPlatformDesktopService::displayName ( QDesktopServices::StandardLocation type )
+{
+    Q_UNUSED(type);
+    return QString();
+}
+
+static QByteArray getPath(const char * envVar)
+{
+    QByteArray path=qgetenv(envVar);
+    return path.length()?path:QDir::homePath().toUtf8();
+}
+
+static QByteArray getPath(const char * envVar, const QByteArray & defaultValue)
+{
+    QByteArray path=qgetenv(envVar);
+    return path.length()?path:defaultValue;
+}
+
+QString QAndroidPlatformDesktopService::storageLocation ( QDesktopServices::StandardLocation type )
+{
+    switch (type)
+    {
+        case QDesktopServices::DesktopLocation:
+            return getPath("DESKTOP_PATH");
+        case QDesktopServices::DocumentsLocation:
+            return getPath("DOCUMENTS_PATH");
+        case QDesktopServices::FontsLocation:
+            return getPath("FONTS_PATH", "/system/fonts");
+        case QDesktopServices::ApplicationsLocation:
+            return getPath("APPLICATIONS_PATH", "/data/data");
+        case QDesktopServices::MusicLocation:
+            return getPath("MUSIC_PATH");
+        case QDesktopServices::MoviesLocation:
+            return getPath("MOVIES_PATH");
+        case QDesktopServices::PicturesLocation:
+            return getPath("PICTURES_PATH");
+        case QDesktopServices::TempLocation:
+            return QDir::tempPath();
+        case QDesktopServices::HomeLocation:
+            return QDir::homePath();
+        case QDesktopServices::DataLocation:
+            return getPath("DATA_PATH");
+        case QDesktopServices::CacheLocation:
+            return getPath("CACHE_PATH");
+    }
+    return QString();
+}
diff --git a/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.h b/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.h
new file mode 100644
index 0000000..021d015
--- /dev/null
+++ b/src/plugins/platforms/android/common/sw/qandroidplatformdesktopservice.h
@@ -0,0 +1,47 @@
+/*
+    Copyright (c) 2009-2011, BogDan Vatra <bog_dan_ro at yahoo.com>
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+        * Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+        * Neither the name of the  BogDan Vatra <bog_dan_ro at yahoo.com> nor the
+        names of its contributors may be used to endorse or promote products
+        derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY BogDan Vatra <bog_dan_ro at yahoo.com> ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL BogDan Vatra <bog_dan_ro at yahoo.com> BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef ANDROIDPLATFORMDESKTOPSERVICE_H
+#define ANDROIDPLATFORMDESKTOPSERVICE_H
+
+#include <QPlatformDesktopService>
+#include <androidjnimain.h>
+#include <jni.h>
+
+class QAndroidPlatformDesktopService: public QPlatformDesktopService
+{
+public:
+    QAndroidPlatformDesktopService();
+    virtual QString displayName ( QDesktopServices::StandardLocation type );
+    virtual bool openUrl ( const QUrl & url );
+    virtual QString storageLocation ( QDesktopServices::StandardLocation type );
+private:
+    jmethodID m_openURIMethodID;
+
+};
+
+#endif // ANDROIDPLATFORMDESKTOPSERVICE_H
diff --git a/src/plugins/platforms/android/common/sw/qandroidplatformintegration.cpp b/src/plugins/platforms/android/common/sw/qandroidplatformintegration.cpp
index deee078..3db0bde 100644
--- a/src/plugins/platforms/android/common/sw/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/common/sw/qandroidplatformintegration.cpp
@@ -37,13 +37,14 @@
 #include <QDir>
 #include <QApplication>
 #include "qdesktopwidget.h"
+#include "qandroidplatformdesktopservice.h"
 
 QT_BEGIN_NAMESPACE
 
-int QAndroidPlatformIntegration::mDefaultGeometryWidth=320;
-int QAndroidPlatformIntegration::mDefaultGeometryHeight=455;
-int QAndroidPlatformIntegration::mDefaultPhysicalSizeWidth=50;
-int QAndroidPlatformIntegration::mDefaultPhysicalSizeHeight=71;
+int QAndroidPlatformIntegration::m_defaultGeometryWidth=320;
+int QAndroidPlatformIntegration::m_defaultGeometryHeight=455;
+int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth=50;
+int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight=71;
 
 class QAndroidPlatformFontDatabase: public QBasicUnixFontDatabase
 {
@@ -73,13 +74,13 @@ class QAndroidPlatformFontDatabase: public QBasicUnixFontDatabase
 
 QAndroidPlatformScreen::QAndroidPlatformScreen():QFbScreen()
 {
-    mGeometry = QRect(0, 0, QAndroidPlatformIntegration::mDefaultGeometryWidth, QAndroidPlatformIntegration::mDefaultGeometryHeight);
+    mGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight);
     mFormat = QImage::Format_RGB16;
     mDepth = 16;
-    setPhysicalSize(QSize(QAndroidPlatformIntegration::mDefaultPhysicalSizeWidth,
-                          QAndroidPlatformIntegration::mDefaultPhysicalSizeHeight));
-    setGeometry(QRect(0,0,QAndroidPlatformIntegration::mDefaultGeometryWidth
-                      ,QAndroidPlatformIntegration::mDefaultGeometryHeight));
+    setPhysicalSize(QSize(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth,
+                          QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight));
+    setGeometry(QRect(0,0,QAndroidPlatformIntegration::m_defaultGeometryWidth
+                      ,QAndroidPlatformIntegration::m_defaultGeometryHeight));
     setFormat(mFormat);
     qDebug()<<"QAndroidPlatformScreen::QAndroidPlatformScreen():QFbScreen()";
 }
@@ -106,24 +107,25 @@ void *QAndroidPlatformNativeInterface::nativeResourceForWidget(const QByteArray
 QAndroidPlatformIntegration::QAndroidPlatformIntegration()
 {
     m_androidPlatformNativeInterface =  new QAndroidPlatformNativeInterface();
-    mPrimaryScreen = new QAndroidPlatformScreen();
-    mScreens.append(mPrimaryScreen);
+    m_primaryScreen = new QAndroidPlatformScreen();
+    m_screens.append(m_primaryScreen);
     m_mainThread=QThread::currentThread();
     QtAndroid::setAndroidPlatformIntegration(this);
     qApp->setInputContext( new QAndroidInputContext() );
-    mAndroidFDB = new QAndroidPlatformFontDatabase();
+    m_androidFDB = new QAndroidPlatformFontDatabase();
+    m_androidPlatformDesktopService = new QAndroidPlatformDesktopService();
 }
 
 QAndroidPlatformIntegration::~QAndroidPlatformIntegration()
 {
     delete m_androidPlatformNativeInterface;
-    delete mAndroidFDB;
+    delete m_androidFDB;
     QtAndroid::setAndroidPlatformIntegration(NULL);
 }
 
 QPlatformFontDatabase *QAndroidPlatformIntegration::fontDatabase() const
 {
-    return mAndroidFDB;
+    return m_androidFDB;
 }
 
 QPlatformNativeInterface *QAndroidPlatformIntegration::nativeInterface() const
@@ -131,18 +133,23 @@ QPlatformNativeInterface *QAndroidPlatformIntegration::nativeInterface() const
     return m_androidPlatformNativeInterface;
 }
 
+QPlatformDesktopService * QAndroidPlatformIntegration::platformDesktopService()
+{
+    return m_androidPlatformDesktopService;
+}
+
 void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh)
 {
-    mDefaultGeometryWidth=gw;
-    mDefaultGeometryHeight=gh;
-    mDefaultPhysicalSizeWidth=sw;
-    mDefaultPhysicalSizeHeight=sh;
+    m_defaultGeometryWidth=gw;
+    m_defaultGeometryHeight=gh;
+    m_defaultPhysicalSizeWidth=sw;
+    m_defaultPhysicalSizeHeight=sh;
 }
 
 void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh)
 {
-    mDefaultGeometryWidth=gw;
-    mDefaultGeometryHeight=gh;
+    m_defaultGeometryWidth=gw;
+    m_defaultGeometryHeight=gh;
 }
 
 QPixmapData *QAndroidPlatformIntegration::createPixmapData(QPixmapData::PixelType type) const
@@ -152,13 +159,13 @@ QPixmapData *QAndroidPlatformIntegration::createPixmapData(QPixmapData::PixelTyp
 
 QWindowSurface *QAndroidPlatformIntegration::createWindowSurface(QWidget *widget, WId /*winId*/) const
 {
-    return new QFbWindowSurface(mPrimaryScreen, widget);
+    return new QFbWindowSurface(m_primaryScreen, widget);
 }
 
 QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWidget *widget, WId /*winId*/) const
 {
     QFbWindow *w = new QFbWindow(widget);
-    mPrimaryScreen->addWindow(w);
+    m_primaryScreen->addWindow(w);
     qDebug()<<"createPlatformWindow"<<widget->isFullScreen();
     if (widget->isFullScreen())
         QtAndroid::setFullScreen(true);
@@ -170,16 +177,16 @@ QPlatformWindow *QAndroidPlatformIntegration::createPlatformWindow(QWidget *widg
 void QAndroidPlatformIntegration::setDesktopSize(int width, int height)
 {
     qDebug()<<"setDesktopSize";
-    if (mPrimaryScreen)
-        QMetaObject::invokeMethod(mPrimaryScreen, "setGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height)));
+    if (m_primaryScreen)
+        QMetaObject::invokeMethod(m_primaryScreen, "setGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height)));
     qDebug()<<"setDesktopSize done";
 }
 
 void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height)
 {
     qDebug()<<"setDisplayMetrics";
-    if (mPrimaryScreen)
-        QMetaObject::invokeMethod(mPrimaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height)));
+    if (m_primaryScreen)
+        QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height)));
     qDebug()<<"setDisplayMetrics done";
 }
 
diff --git a/src/plugins/platforms/android/common/sw/qandroidplatformintegration.h b/src/plugins/platforms/android/common/sw/qandroidplatformintegration.h
index 15dcf3f..424d15d 100644
--- a/src/plugins/platforms/android/common/sw/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/common/sw/qandroidplatformintegration.h
@@ -28,6 +28,7 @@
 #ifndef QGRAPHICSSYSTEM_MINIMAL_H
 #define QGRAPHICSSYSTEM_MINIMAL_H
 
+#include <QPlatformDesktopService>
 #include <QPlatformIntegration>
 #include <QPlatformNativeInterface>
 #include "../../fb_base/fb_base.h"
@@ -36,6 +37,7 @@
 QT_BEGIN_NAMESPACE
 
 class QDesktopWidget;
+class QAndroidPlatformDesktopService;
 
 class QAndroidPlatformScreen : public QFbScreen
 {
@@ -64,14 +66,15 @@ public:
     QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
     QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const;
 
-    QList<QPlatformScreen *> screens() const { return mScreens; }
+    QList<QPlatformScreen *> screens() const { return m_screens; }
 
-    QAndroidPlatformScreen * getPrimaryScreen(){return mPrimaryScreen;}
+    QAndroidPlatformScreen * getPrimaryScreen(){return m_primaryScreen;}
     bool isVirtualDesktop() { return true; }
     virtual void setDesktopSize(int width, int height);
     virtual void setDisplayMetrics(int width, int height);
     QPlatformFontDatabase *fontDatabase() const;
     virtual QPlatformNativeInterface *nativeInterface() const;
+    virtual QPlatformDesktopService * platformDesktopService();
 
     void pauseApp();
     void resumeApp();
@@ -80,14 +83,15 @@ public:
 
 private:
     QThread * m_mainThread;
-    QAndroidPlatformScreen *mPrimaryScreen;
-    QList<QPlatformScreen *> mScreens;
-    static int mDefaultGeometryWidth,mDefaultGeometryHeight,mDefaultPhysicalSizeWidth,mDefaultPhysicalSizeHeight;
+    QAndroidPlatformScreen *m_primaryScreen;
+    QList<QPlatformScreen *> m_screens;
+    static int m_defaultGeometryWidth,m_defaultGeometryHeight,m_defaultPhysicalSizeWidth,m_defaultPhysicalSizeHeight;
     friend class QAndroidPlatformScreen;
-    QPlatformFontDatabase *mAndroidFDB;
+    QPlatformFontDatabase *m_androidFDB;
     QImage * mFbScreenImage;
     QPainter *compositePainter;
     QAndroidPlatformNativeInterface * m_androidPlatformNativeInterface;
+    QAndroidPlatformDesktopService * m_androidPlatformDesktopService;
 };
 
 QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/common/sw/sw.pri b/src/plugins/platforms/android/common/sw/sw.pri
index 8c335f9..ade5368 100644
--- a/src/plugins/platforms/android/common/sw/sw.pri
+++ b/src/plugins/platforms/android/common/sw/sw.pri
@@ -9,9 +9,11 @@ INCLUDEPATH += $$PWD $$PWD/..
 SOURCES += $$PWD/androidplatformplugin.cpp \
            $$PWD/androidjnimain.cpp \
            $$PWD/qandroidplatformintegration.cpp \
+           $$PWD/qandroidplatformdesktopservice.cpp \
            $$PWD/../qandroidinputcontext.cpp
 
 HEADERS += $$PWD/qandroidplatformintegration.h \
+           $$PWD/qandroidplatformdesktopservice.h \
            $$PWD/../qandroidinputcontext.h
 
 include($$QT_SOURCE_TREE/src/plugins/platforms/fb_base/fb_base.pri)


More information about the Necessitas-devel mailing list