aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2013-09-23 15:40:40 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2013-09-23 17:06:51 +0200
commit3fe920463b4c6a43f66a7b7c51d71184703d30ba (patch)
tree60a8dc4b4686864c9be75c8221bd8290e83a38bf /examples
parentbe414dfaa02bc15933e35745022126daca373e44 (diff)
Add example of JNI API
This example adds a custom class to the project and calls into it with JNI to set a notification message in the status area. Change-Id: I74d7a87c0511b98608422788c1c282e9af57c074 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/androidextras/androidextras.pro5
-rw-r--r--examples/androidextras/notification/android-sources/AndroidManifest.xml38
-rw-r--r--examples/androidextras/notification/android-sources/src/org/qtproject/example/notification/NotificationClient.java71
-rw-r--r--examples/androidextras/notification/androidjnibindings.cpp68
-rw-r--r--examples/androidextras/notification/androidjnibindings.h61
-rw-r--r--examples/androidextras/notification/images/happy.pngbin0 -> 2804 bytes
-rw-r--r--examples/androidextras/notification/images/sad.pngbin0 -> 2447 bytes
-rw-r--r--examples/androidextras/notification/main.cpp62
-rw-r--r--examples/androidextras/notification/main.qrc7
-rw-r--r--examples/androidextras/notification/notification.pro24
-rw-r--r--examples/androidextras/notification/notificationclient.cpp74
-rw-r--r--examples/androidextras/notification/notificationclient.h67
-rw-r--r--examples/androidextras/notification/qml/main.qml106
-rw-r--r--examples/examples.pro2
14 files changed, 585 insertions, 0 deletions
diff --git a/examples/androidextras/androidextras.pro b/examples/androidextras/androidextras.pro
new file mode 100644
index 0000000..31640ad
--- /dev/null
+++ b/examples/androidextras/androidextras.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+android {
+ SUBDIRS += notification
+ EXAMPLE_FILES += notification
+}
diff --git a/examples/androidextras/notification/android-sources/AndroidManifest.xml b/examples/androidextras/notification/android-sources/AndroidManifest.xml
new file mode 100644
index 0000000..a7f10eb
--- /dev/null
+++ b/examples/androidextras/notification/android-sources/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?xml version='1.0' encoding='utf-8'?>
+<manifest android:versionCode="1" package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0">
+ <application android:icon="@drawable/icon" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/app_name">
+ <activity android:name="org.qtproject.example.notification.NotificationClient" android:label="@string/app_name" android:screenOrientation="unspecified" android:configChanges="orientation|locale|fontScale|keyboard|keyboardHidden|navigation">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
+ <meta-data android:name="android.app.repository" android:value="@string/repository"/>
+ <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
+ <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
+ <meta-data android:name="android.app.lib_name" android:value="@string/app_lib_name"/>
+ <!-- Deploy Qt libs as part of package -->
+ <meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
+ <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
+ <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
+ <!-- Run with local libs -->
+ <meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
+ <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
+ <meta-data android:name="android.app.load_local_libs" android:value="@string/local_libs"/>
+ <meta-data android:name="android.app.load_local_jars" android:value="@string/local_jars"/>
+ <meta-data android:name="android.app.static_init_classes" android:value="@string/init_classes"/>
+ <!-- Messages maps -->
+ <meta-data android:name="android.app.ministro_not_found_msg" android:value="@string/ministro_not_found_msg"/>
+ <meta-data android:name="android.app.ministro_needed_msg" android:value="@string/ministro_needed_msg"/>
+ <meta-data android:name="android.app.fatal_error_msg" android:value="@string/fatal_error_msg"/>
+ <!-- Messages maps -->
+ <!-- Splash screen -->
+ <meta-data android:name="android.app.splash_screen" android:resource="@layout/splash"/>
+ <!-- Splash screen -->
+ </activity>
+ </application>
+ <!-- %%INSERT_USES_SDK%% -->
+ <supports-screens android:normalScreens="true" android:anyDensity="true" android:smallScreens="true" android:largeScreens="true"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+</manifest>
diff --git a/examples/androidextras/notification/android-sources/src/org/qtproject/example/notification/NotificationClient.java b/examples/androidextras/notification/android-sources/src/org/qtproject/example/notification/NotificationClient.java
new file mode 100644
index 0000000..9901fda
--- /dev/null
+++ b/examples/androidextras/notification/android-sources/src/org/qtproject/example/notification/NotificationClient.java
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+package org.qtproject.example.notification;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.content.Context;
+
+public class NotificationClient extends org.qtproject.qt5.android.bindings.QtActivity
+{
+ private static NotificationManager m_notificationManager;
+ private static Notification.Builder m_builder;
+ private static NotificationClient m_instance;
+
+ public NotificationClient()
+ {
+ m_instance = this;
+ }
+
+ public static void notify(String s)
+ {
+ if (m_notificationManager == null) {
+ m_notificationManager = (NotificationManager)m_instance.getSystemService(Context.NOTIFICATION_SERVICE);
+ m_builder = new Notification.Builder(m_instance);
+ m_builder.setSmallIcon(R.drawable.icon);
+ m_builder.setContentTitle("A message from Qt!");
+ }
+
+ m_builder.setContentText(s);
+ m_notificationManager.notify(1, m_builder.build());
+ }
+}
diff --git a/examples/androidextras/notification/androidjnibindings.cpp b/examples/androidextras/notification/androidjnibindings.cpp
new file mode 100644
index 0000000..98280c2
--- /dev/null
+++ b/examples/androidextras/notification/androidjnibindings.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "androidjnibindings.h"
+
+jint JNICALL JNI_OnLoad(JavaVM *vm, void *)
+{
+ JNIEnv *env;
+ if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_4) != JNI_OK) {
+ qFatal("Couldn't initialize environment!");
+ return -1;
+ }
+
+ AndroidJNIBindings::detectNotificationClientClass(env);
+
+ return JNI_VERSION_1_4;
+}
+
+jclass AndroidJNIBindings::m_notificationClientClass = 0;
+void AndroidJNIBindings::detectNotificationClientClass(JNIEnv *environment)
+{
+ jclass clazz = environment->FindClass("org/qtproject/example/notification/NotificationClient");
+ if (clazz == 0) {
+ environment->ExceptionDescribe();
+ environment->ExceptionClear();
+ return;
+ }
+
+ m_notificationClientClass = reinterpret_cast<jclass>(environment->NewGlobalRef(clazz));
+}
diff --git a/examples/androidextras/notification/androidjnibindings.h b/examples/androidextras/notification/androidjnibindings.h
new file mode 100644
index 0000000..64cca54
--- /dev/null
+++ b/examples/androidextras/notification/androidjnibindings.h
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANDROIDJNIBINDINGS_H
+#define ANDROIDJNIBINDINGS_H
+
+#include <QtAndroidExtras/QJNIObject>
+
+class AndroidJNIBindings
+{
+public:
+ static jclass notificationClientClass()
+ {
+ return m_notificationClientClass;
+ }
+
+ static void detectNotificationClientClass(JNIEnv *environment);
+
+private:
+ static jclass m_notificationClientClass;
+};
+
+#endif // ANDROIDJNIBINDINGS_H
diff --git a/examples/androidextras/notification/images/happy.png b/examples/androidextras/notification/images/happy.png
new file mode 100644
index 0000000..d1c1460
--- /dev/null
+++ b/examples/androidextras/notification/images/happy.png
Binary files differ
diff --git a/examples/androidextras/notification/images/sad.png b/examples/androidextras/notification/images/sad.png
new file mode 100644
index 0000000..00026bd
--- /dev/null
+++ b/examples/androidextras/notification/images/sad.png
Binary files differ
diff --git a/examples/androidextras/notification/main.cpp b/examples/androidextras/notification/main.cpp
new file mode 100644
index 0000000..8ed8d30
--- /dev/null
+++ b/examples/androidextras/notification/main.cpp
@@ -0,0 +1,62 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtQuick>
+
+#include "notificationclient.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ QQuickView view;
+
+ NotificationClient *notificationClient = new NotificationClient(&view);
+ view.engine()->rootContext()->setContextProperty(QLatin1String("notificationClient"),
+ notificationClient);
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl(QStringLiteral("qrc:/qml/main.qml")));
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/androidextras/notification/main.qrc b/examples/androidextras/notification/main.qrc
new file mode 100644
index 0000000..10190c9
--- /dev/null
+++ b/examples/androidextras/notification/main.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/main.qml</file>
+ <file>images/happy.png</file>
+ <file>images/sad.png</file>
+ </qresource>
+</RCC>
diff --git a/examples/androidextras/notification/notification.pro b/examples/androidextras/notification/notification.pro
new file mode 100644
index 0000000..9d57ca3
--- /dev/null
+++ b/examples/androidextras/notification/notification.pro
@@ -0,0 +1,24 @@
+QT += quick androidextras
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources
+ANDROID_PACKAGE = org.qtproject.example.notification
+ANDROID_MINIMUM_VERSION = 16
+ANDROID_TARGET_VERSION = 16
+ANDROID_APP_NAME = Qt Notifier
+
+SOURCES += \
+ main.cpp \
+ notificationclient.cpp \
+ androidjnibindings.cpp
+
+OTHER_FILES += \
+ qml/main.qml \
+ android-sources/src/org/qtproject/example/notification/NotificationClient.java \
+ android-sources/AndroidManifest.xml
+
+RESOURCES += \
+ main.qrc
+
+HEADERS += \
+ notificationclient.h \
+ androidjnibindings.h
diff --git a/examples/androidextras/notification/notificationclient.cpp b/examples/androidextras/notification/notificationclient.cpp
new file mode 100644
index 0000000..d9cbf84
--- /dev/null
+++ b/examples/androidextras/notification/notificationclient.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "notificationclient.h"
+#include "androidjnibindings.h"
+
+#include <QtAndroidExtras/QJNIObject>
+
+NotificationClient::NotificationClient(QObject *parent)
+ : QObject(parent)
+{
+ connect(this, SIGNAL(notificationChanged()), this, SLOT(updateAndroidNotification()));
+}
+
+void NotificationClient::setNotification(const QString &notification)
+{
+ if (m_notification == notification)
+ return;
+
+ m_notification = notification;
+ emit notificationChanged();
+}
+
+QString NotificationClient::notification() const
+{
+ return m_notification;
+}
+
+void NotificationClient::updateAndroidNotification()
+{
+ QJNIObject javaNotification = QJNIObject::fromString(m_notification);
+ QJNIObject::callStaticMethod<void>(AndroidJNIBindings::notificationClientClass(),
+ "notify",
+ "(Ljava/lang/String;)V",
+ javaNotification.object<jstring>());
+}
diff --git a/examples/androidextras/notification/notificationclient.h b/examples/androidextras/notification/notificationclient.h
new file mode 100644
index 0000000..6b48fc7
--- /dev/null
+++ b/examples/androidextras/notification/notificationclient.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef NOTIFICATIONCLIENT_H
+#define NOTIFICATIONCLIENT_H
+
+#include <QObject>
+
+class NotificationClient : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString notification READ notification WRITE setNotification NOTIFY notificationChanged)
+public:
+ explicit NotificationClient(QObject *parent = 0);
+
+ void setNotification(const QString &notification);
+ QString notification() const;
+
+signals:
+ void notificationChanged();
+
+private slots:
+ void updateAndroidNotification();
+
+private:
+ QString m_notification;
+};
+
+#endif // NOTIFICATIONCLIENT_H
diff --git a/examples/androidextras/notification/qml/main.qml b/examples/androidextras/notification/qml/main.qml
new file mode 100644
index 0000000..e265f1b
--- /dev/null
+++ b/examples/androidextras/notification/qml/main.qml
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWinExtras module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 500
+ height: 500
+ color: "white"
+
+ Column {
+ anchors.fill: parent
+ spacing: (height - happyButton.height - sadButton.height - title.height) / 3
+
+ Text {
+ id: title
+ color: "black"
+ font.pixelSize: parent.width / 20
+ text: "How are you feeling?"
+ width: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ }
+
+ Image {
+ id: happyButton
+ height: parent.height / 5
+ fillMode: Image.PreserveAspectFit
+ source: "../images/happy.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ smooth: true
+
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: notificationClient.notification = "User is happy!"
+ onPressed: happyButton.scale = 0.9
+ onReleased: happyButton.scale = 1.0
+ }
+ }
+
+ Image {
+ id: sadButton
+ height: parent.height / 5
+ fillMode: Image.PreserveAspectFit
+ source: "../images/sad.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ smooth: true
+
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: notificationClient.notification = "User is sad :("
+ onPressed: sadButton.scale = 0.9
+ onReleased: sadButton.scale = 1.0
+ }
+ }
+ }
+}
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 0000000..467ccc4
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+android:SUBDIRS += androidextras