summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-12-19 09:34:40 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-12-19 09:20:17 +0000
commit5b401df343da32e3a1e858963e76c5bb33350b46 (patch)
tree9ba8f0466765ea0e4009173efecbd290bae921de
parent4d73360a5198fa035b94a517a3db01c1cc0dff52 (diff)
Pimplify drawable classes
Change-Id: If1413ec32b2fcb7c247467dde6fb8920af42596d Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
-rw-r--r--src/android/graphics/drawable/drawable.pri3
-rw-r--r--src/android/graphics/drawable/qnativeandroidcolordrawable.cpp28
-rw-r--r--src/android/graphics/drawable/qnativeandroidcolordrawable_p.h5
-rw-r--r--src/android/graphics/drawable/qnativeandroiddrawable.cpp10
-rw-r--r--src/android/graphics/drawable/qnativeandroiddrawable_p.h8
-rw-r--r--src/android/graphics/drawable/qnativeandroiddrawable_p_p.h62
6 files changed, 104 insertions, 12 deletions
diff --git a/src/android/graphics/drawable/drawable.pri b/src/android/graphics/drawable/drawable.pri
index 51e4845..1b86dca 100644
--- a/src/android/graphics/drawable/drawable.pri
+++ b/src/android/graphics/drawable/drawable.pri
@@ -2,7 +2,8 @@ INCLUDEPATH += $$PWD
HEADERS += \
$$PWD/qnativeandroidcolordrawable_p.h \
- $$PWD/qnativeandroiddrawable_p.h
+ $$PWD/qnativeandroiddrawable_p.h \
+ $$PWD/qnativeandroiddrawable_p_p.h
SOURCES += \
$$PWD/qnativeandroidcolordrawable.cpp \
diff --git a/src/android/graphics/drawable/qnativeandroidcolordrawable.cpp b/src/android/graphics/drawable/qnativeandroidcolordrawable.cpp
index 9b3d93a..4323a66 100644
--- a/src/android/graphics/drawable/qnativeandroidcolordrawable.cpp
+++ b/src/android/graphics/drawable/qnativeandroidcolordrawable.cpp
@@ -35,29 +35,40 @@
****************************************************************************/
#include "qnativeandroidcolordrawable_p.h"
+#include "qnativeandroiddrawable_p_p.h"
#include "qtnativeandroidfunctions_p.h"
QT_BEGIN_NAMESPACE
-QNativeAndroidColorDrawable::QNativeAndroidColorDrawable(QObject *parent) :
- QNativeAndroidDrawable(parent), m_color(0)
+class QNativeAndroidColorDrawablePrivate : public QNativeAndroidDrawablePrivate
+{
+public:
+ int color = 0;
+};
+
+QNativeAndroidColorDrawable::QNativeAndroidColorDrawable(QObject *parent)
+ : QNativeAndroidDrawable(*(new QNativeAndroidColorDrawablePrivate), parent)
{
}
-QNativeAndroidColorDrawable::QNativeAndroidColorDrawable(int color, QObject *parent) :
- QNativeAndroidDrawable(parent), m_color(color)
+QNativeAndroidColorDrawable::QNativeAndroidColorDrawable(int color, QObject *parent)
+ : QNativeAndroidDrawable(*(new QNativeAndroidColorDrawablePrivate), parent)
{
+ Q_D(QNativeAndroidColorDrawable);
+ d->color = color;
}
int QNativeAndroidColorDrawable::color() const
{
- return m_color;
+ Q_D(const QNativeAndroidColorDrawable);
+ return d->color;
}
void QNativeAndroidColorDrawable::setColor(int color)
{
- if (m_color != color) {
- m_color = color;
+ Q_D(QNativeAndroidColorDrawable);
+ if (d->color != color) {
+ d->color = color;
QtNativeAndroid::callIntMethod(instance(), "setColor", color);
emit colorChanged();
}
@@ -70,9 +81,10 @@ QAndroidJniObject QNativeAndroidColorDrawable::onCreate()
void QNativeAndroidColorDrawable::onInflate(QAndroidJniObject &instance)
{
+ Q_D(QNativeAndroidColorDrawable);
QNativeAndroidDrawable::onInflate(instance);
- instance.callMethod<void>("setColor", "(I)V", m_color);
+ instance.callMethod<void>("setColor", "(I)V", d->color);
}
QT_END_NAMESPACE
diff --git a/src/android/graphics/drawable/qnativeandroidcolordrawable_p.h b/src/android/graphics/drawable/qnativeandroidcolordrawable_p.h
index 13f2ad9..7b9d593 100644
--- a/src/android/graphics/drawable/qnativeandroidcolordrawable_p.h
+++ b/src/android/graphics/drawable/qnativeandroidcolordrawable_p.h
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+class QNativeAndroidColorDrawablePrivate;
+
class Q_NATIVEANDROID_EXPORT QNativeAndroidColorDrawable : public QNativeAndroidDrawable
{
Q_OBJECT
@@ -72,7 +74,8 @@ protected:
void onInflate(QAndroidJniObject &instance) override;
private:
- int m_color;
+ Q_DISABLE_COPY(QNativeAndroidColorDrawable)
+ Q_DECLARE_PRIVATE(QNativeAndroidColorDrawable)
};
QT_END_NAMESPACE
diff --git a/src/android/graphics/drawable/qnativeandroiddrawable.cpp b/src/android/graphics/drawable/qnativeandroiddrawable.cpp
index 42740b9..44c957e 100644
--- a/src/android/graphics/drawable/qnativeandroiddrawable.cpp
+++ b/src/android/graphics/drawable/qnativeandroiddrawable.cpp
@@ -35,11 +35,17 @@
****************************************************************************/
#include "qnativeandroiddrawable_p.h"
+#include "qnativeandroiddrawable_p_p.h"
QT_BEGIN_NAMESPACE
-QNativeAndroidDrawable::QNativeAndroidDrawable(QObject *parent) :
- QNativeAndroidObject(parent)
+QNativeAndroidDrawable::QNativeAndroidDrawable(QObject *parent)
+ : QNativeAndroidObject(*(new QNativeAndroidDrawablePrivate), parent)
+{
+}
+
+QNativeAndroidDrawable::QNativeAndroidDrawable(QNativeAndroidDrawablePrivate &dd, QObject *parent)
+ : QNativeAndroidObject(dd, parent)
{
}
diff --git a/src/android/graphics/drawable/qnativeandroiddrawable_p.h b/src/android/graphics/drawable/qnativeandroiddrawable_p.h
index 8db4fe5..0059e2f 100644
--- a/src/android/graphics/drawable/qnativeandroiddrawable_p.h
+++ b/src/android/graphics/drawable/qnativeandroiddrawable_p.h
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+class QNativeAndroidDrawablePrivate;
+
class Q_NATIVEANDROID_EXPORT QNativeAndroidDrawable : public QNativeAndroidObject
{
Q_OBJECT
@@ -60,8 +62,14 @@ public:
explicit QNativeAndroidDrawable(QObject *parent = nullptr);
protected:
+ QNativeAndroidDrawable(QNativeAndroidDrawablePrivate &dd, QObject *parent = nullptr);
+
QAndroidJniObject onCreate() override;
void onInflate(QAndroidJniObject &instance) override;
+
+private:
+ Q_DISABLE_COPY(QNativeAndroidDrawable)
+ Q_DECLARE_PRIVATE(QNativeAndroidDrawable)
};
QT_END_NAMESPACE
diff --git a/src/android/graphics/drawable/qnativeandroiddrawable_p_p.h b/src/android/graphics/drawable/qnativeandroiddrawable_p_p.h
new file mode 100644
index 0000000..f9058ea
--- /dev/null
+++ b/src/android/graphics/drawable/qnativeandroiddrawable_p_p.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt QML Android module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNATIVEANDROIDDRAWABLE_P_P_H
+#define QNATIVEANDROIDDRAWABLE_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNativeAndroid/private/qnativeandroidobject_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QNativeAndroidDrawablePrivate : public QNativeAndroidObjectPrivate
+{
+public:
+};
+
+QT_END_NAMESPACE
+
+#endif // QNATIVEANDROIDDRAWABLE_P_P_H