summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Olszak <olszak.tomasz@gmail.com>2013-08-11 16:07:09 +0000
committerTomasz Olszak <olszak.tomasz@gmail.com>2013-08-11 21:49:56 +0200
commita7463f4beadd406ae9b672e0c190c5116ecf723c (patch)
tree241d917ee6b83afab698c3b9ef6627cc13251e67
parent54f3de8fe38d0a1340466525955c6a9ba8ff1426 (diff)
Added TizenControls singleton in Controls.Tizen plugin.
There should be no QtQUick.Controls.Styles.Tizen import in applications. QtQuick.Controls.Tizen should be just enough. Fixed examples Change-Id: I298fc8b7b2a250392faf001d5ccde89c139ab180 Reviewed-by: Jarosław Staniek <staniek@kde.org>
-rw-r--r--examples/sensor-checker/content/SensorInformationItem.qml9
-rw-r--r--examples/sensor-checker/main.qml1
-rw-r--r--examples/touch/content/AndroidDelegate.qml6
-rw-r--r--examples/touch/content/ConfigurationPage.qml20
-rw-r--r--examples/touch/content/ContextMenuPage.qml3
-rw-r--r--examples/touch/content/DateTimeEditPage.qml6
-rw-r--r--examples/touch/main.qml13
-rw-r--r--examples/twitter/content/ListDelegate.qml6
-rw-r--r--src/controls/controls.pro20
-rw-r--r--src/controls/internal_resources.qrc5
-rw-r--r--src/controls/private/TizenControls.qml44
-rw-r--r--src/controls/qmldir2
-rw-r--r--src/controls/qquicktizencontrolsextensionplugin.cpp55
-rw-r--r--src/controls/qquicktizencontrolsextensionplugin.h36
-rw-r--r--src/styles/private/TizenStyleConfig.qml3
-rw-r--r--src/styles/qmldir1
-rw-r--r--src/styles/qquicktizenstyleextensionplugin.cpp4
-rw-r--r--src/styles/styles.pro7
18 files changed, 197 insertions, 44 deletions
diff --git a/examples/sensor-checker/content/SensorInformationItem.qml b/examples/sensor-checker/content/SensorInformationItem.qml
index 7393921..4c14dd6 100644
--- a/examples/sensor-checker/content/SensorInformationItem.qml
+++ b/examples/sensor-checker/content/SensorInformationItem.qml
@@ -28,7 +28,6 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Tizen 1.0
-import QtQuick.Controls.Styles.Tizen 1.0
import QtQuick.Layouts 1.0
Panel {
@@ -49,13 +48,13 @@ Panel {
anchors.right: parent.right
Label {
id: switchLabel
- color: TizenConfig.colors.foreground
+ color: TizenControls.palette.foreground
text: "Compass"
height: 50
Layout.fillWidth: true
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
- font.family: TizenConfig.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
font.pixelSize: parent.height/2
fontSizeMode: Text.Fit
}
@@ -67,7 +66,7 @@ Panel {
Label {
id: compassLabel
anchors.margins: 10
- color: TizenConfig.colors.foreground
+ color: TizenControls.palette.foreground
text: "Sensor inactive"
anchors.top: switchRow.bottom
anchors.left: parent.left
@@ -76,7 +75,7 @@ Panel {
Layout.fillWidth: true
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
- font.family: TizenConfig.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
font.pixelSize: parent.height/2
fontSizeMode: Text.Fit
}
diff --git a/examples/sensor-checker/main.qml b/examples/sensor-checker/main.qml
index e159afe..bb0fd9f 100644
--- a/examples/sensor-checker/main.qml
+++ b/examples/sensor-checker/main.qml
@@ -41,7 +41,6 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Tizen 1.0
-import QtQuick.Controls.Styles.Tizen 1.0
import QtQuick.Window 2.0
import QtQuick.Layouts 1.0
import QtSensors 5.1
diff --git a/examples/touch/content/AndroidDelegate.qml b/examples/touch/content/AndroidDelegate.qml
index e40da1d..f4dd8a6 100644
--- a/examples/touch/content/AndroidDelegate.qml
+++ b/examples/touch/content/AndroidDelegate.qml
@@ -39,7 +39,6 @@
****************************************************************************/
import QtQuick 2.1
-import QtQuick.Controls.Styles.Tizen 1.0
import QtQuick.Controls.Tizen 1.0
import QtQuick.Controls 1.0
@@ -59,9 +58,9 @@ Item {
Label {
id: textitem
- color: TizenConfig.colors.foreground
+ color: TizenControls.palette.foreground
font.pixelSize: 32
- font.family: TizenConfig.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 30
@@ -81,7 +80,6 @@ Item {
onClicked: root.clicked()
}
-
DetailButton {
id:detailButton
anchors.right: parent.right
diff --git a/examples/touch/content/ConfigurationPage.qml b/examples/touch/content/ConfigurationPage.qml
index 7a74285..83f3106 100644
--- a/examples/touch/content/ConfigurationPage.qml
+++ b/examples/touch/content/ConfigurationPage.qml
@@ -49,10 +49,10 @@ Item {
anchors.bottom: parent.bottom
anchors.right: pageEffectSwitch.left
text: "Page effect "+ ((pageEffectSwitch.checked) ? "on" : "off")
- color: TizenConfig.colors.foreground
+ color: TizenControls.palette.foreground
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
- font.family: TizenConfig.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
font.pixelSize: parent.height/2
fontSizeMode: Text.Fit
}
@@ -82,11 +82,11 @@ Item {
anchors.left: parent.left
anchors.right: parent.right
height:parent.implicitHeight
- text: "Theme: "+ TizenConfig.theme
- color: TizenConfig.colors.foreground
+ text: "Theme: "+ TizenControls.currentTheme
+ color: TizenControls.palette.foreground
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
- font.family: TizenConfig.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
font.pixelSize: parent.height/2
fontSizeMode: Text.Fit
MouseArea {
@@ -131,24 +131,24 @@ Item {
state = ""
}
- property string theme: TizenConfig.theme
+ property string theme: TizenControls.currentTheme
onThemeChanged: {
- checkBoxWhite.checked = TizenConfig.theme === "white"
- checkBoxBlack.checked = TizenConfig.theme === "black"
+ checkBoxWhite.checked = TizenControls.currentTheme === "white"
+ checkBoxBlack.checked = TizenControls.currentTheme === "black"
}
CheckBox {
id: checkBoxWhite
Layout.fillWidth: true
Layout.fillHeight: true
text: "White"
- onClicked: TizenConfig.theme = "white"
+ onClicked: TizenControls.changeTheme("white")
}
CheckBox {
id: checkBoxBlack
Layout.fillWidth: true
Layout.fillHeight: true
text: "Black"
- onClicked: TizenConfig.theme = "black"
+ onClicked: TizenControls.changeTheme("black")
}
}
}
diff --git a/examples/touch/content/ContextMenuPage.qml b/examples/touch/content/ContextMenuPage.qml
index b356d8f..39e2fc5 100644
--- a/examples/touch/content/ContextMenuPage.qml
+++ b/examples/touch/content/ContextMenuPage.qml
@@ -29,7 +29,6 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Tizen 1.0
-import QtQuick.Controls.Styles.Tizen 1.0
Item {
id:root
@@ -73,7 +72,7 @@ Item {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
- color: TizenConfig.colors.foreground
+ color: TizenControls.palette.foreground
Rectangle {
anchors.fill: parent
border.width: 1
diff --git a/examples/touch/content/DateTimeEditPage.qml b/examples/touch/content/DateTimeEditPage.qml
index 8046604..05fefe9 100644
--- a/examples/touch/content/DateTimeEditPage.qml
+++ b/examples/touch/content/DateTimeEditPage.qml
@@ -39,7 +39,7 @@ Item {
spacing: 50
Column {
Label {
-
+ color: TizenControls.palette.foreground
text:"Today"
}
DateEdit {
@@ -48,6 +48,7 @@ Item {
}
Column {
Label {
+ color: TizenControls.palette.foreground
text:"Tomorrow"
}
@@ -58,6 +59,7 @@ Item {
}
Column {
Label {
+ color: TizenControls.palette.foreground
text:"Disabled"
}
@@ -67,6 +69,7 @@ Item {
}
Column {
Label {
+ color: TizenControls.palette.foreground
text:"Time"
}
@@ -74,6 +77,7 @@ Item {
}
Column {
Label {
+ color: TizenControls.palette.foreground
text:"Time AM/PM"
}
diff --git a/examples/touch/main.qml b/examples/touch/main.qml
index 59f0a11..1f6b799 100644
--- a/examples/touch/main.qml
+++ b/examples/touch/main.qml
@@ -41,7 +41,6 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Tizen 1.0
-import QtQuick.Controls.Styles.Tizen 1.0
import QtQuick.Window 2.0
import "content"
@@ -64,7 +63,7 @@ ApplicationWindow {
id: content
anchors.fill: parent
- titleBar.text: "Controls Gallery (Theme: " + TizenConfig.theme+")"
+ titleBar.text: "Controls Gallery (Theme: " + TizenControls.currentTheme+")"
titleBar.subText: pageStack.depth > 1 ? pageStack.currentItem: "Main Page"
backAction.onTriggered: pageStack.depth > 1 ? pageStack.pop() : Qt.quit()
@@ -139,7 +138,7 @@ ApplicationWindow {
Rectangle {
id: backgroundRect
visible: appWindow.pageCurlEffectEnabled
- color: (TizenConfig.theme === "black") ? "white" : " black"
+ color: (TizenControls.currentTheme === "black") ? "white" : " black"
width: 300
height: 130
anchors.right: parent.right
@@ -227,11 +226,13 @@ ApplicationWindow {
}
}
function flipTheme() {
- if (TizenConfig.theme === "white") {
- TizenConfig.theme = "black"
+ var theme
+ if (TizenControls.currentTheme === "white") {
+ theme = "black"
} else {
- TizenConfig.theme = "white"
+ theme = "white"
}
+ TizenControls.changeTheme(theme)
backgroundRect.visible = false
}
}
diff --git a/examples/twitter/content/ListDelegate.qml b/examples/twitter/content/ListDelegate.qml
index 7c0f702..931f40c 100644
--- a/examples/twitter/content/ListDelegate.qml
+++ b/examples/twitter/content/ListDelegate.qml
@@ -38,7 +38,6 @@
import QtQuick 2.1
import QtQuick.Controls.Tizen 1.0
-import QtQuick.Controls.Styles.Tizen 1.0 // tmp
import "utils.js" as Utils
Item {
@@ -89,7 +88,7 @@ Item {
+ Utils.prettyDate(model.date)
+ '</span><br/>'
+ '<span style="color:'
- + (mouse.pressed ? 'white' : 'black')
+ + (mouse.pressed ? 'white' : TizenControls.palette.foreground)
+ ';">'
+ richStatus(model.statusText)
+ '</span></body></html>'
@@ -98,12 +97,11 @@ Item {
x: 30
y: 40
z: 2
-
anchors.rightMargin: 30
anchors.bottomMargin: 40
wrapMode: Text.Wrap
textFormat: Text.RichText
- font.family: Theme.fonts.defaultFamily
+ font.family: TizenControls.defaultFontFamily
font.pixelSize: 36
elide: Text.ElideLeft
MouseArea {
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index 22c0720..792cc10 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -1,3 +1,7 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += qml quick
+TARGET=tizencontrolsplugin
TARGETPATH = QtQuick/Controls/Tizen
@@ -17,6 +21,20 @@ QML_FILES += \
CONFIG += force_independent
-OTHER_FILES += qmldir
+OTHER_FILES += qmldir \
+ private/TizenControls.qml
load(qml_module)
+
+target.base = $$_PRO_FILE_PWD_
+target.path = $$instbase/$$TARGETPATH
+
+HEADERS += \
+ qquicktizencontrolsextensionplugin.h
+
+SOURCES += \
+ qquicktizencontrolsextensionplugin.cpp
+INSTALLS += target
+
+RESOURCES += \
+ internal_resources.qrc
diff --git a/src/controls/internal_resources.qrc b/src/controls/internal_resources.qrc
new file mode 100644
index 0000000..28ef38b
--- /dev/null
+++ b/src/controls/internal_resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/QtQuick/Controls/Tizen">
+ <file>private/TizenControls.qml</file>
+ </qresource>
+</RCC>
diff --git a/src/controls/private/TizenControls.qml b/src/controls/private/TizenControls.qml
new file mode 100644
index 0000000..6aa8e96
--- /dev/null
+++ b/src/controls/private/TizenControls.qml
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+import QtQml 2.1
+import QtQuick.Controls.Styles.Tizen 1.0
+
+QtObject {
+ readonly property var availableThemes: ["black","white"]
+ readonly property string currentTheme: TizenConfig.theme
+ function changeTheme(theme) {
+ if (availableThemes.indexOf(theme) >= 0) {
+ if (currentTheme !== theme)
+ TizenConfig.theme = theme;
+ } else {
+ console.log("Theme:" + theme + " is not handled");
+ }
+ }
+ readonly property alias palette: __prv.pal
+
+ property QtObject __prvProp: QtObject {
+ id: __prv
+ property QtObject pal: QtObject {
+ readonly property color foreground: TizenConfig.colors.foreground
+ readonly property color background: TizenConfig.colors.background
+ }
+ }
+
+ readonly property string defaultFontFamily: TizenConfig.fontLoader.name
+}
diff --git a/src/controls/qmldir b/src/controls/qmldir
index 245c1e1..03e779d 100644
--- a/src/controls/qmldir
+++ b/src/controls/qmldir
@@ -1,5 +1,7 @@
module QtQuick.Controls.Tizen
+plugin tizencontrolsplugin
+
Switch 1.0 Switch.qml
DetailButton 1.0 DetailButton.qml
ContextMenu 1.0 ContextMenu.qml
diff --git a/src/controls/qquicktizencontrolsextensionplugin.cpp b/src/controls/qquicktizencontrolsextensionplugin.cpp
new file mode 100644
index 0000000..e956de1
--- /dev/null
+++ b/src/controls/qquicktizencontrolsextensionplugin.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "qquicktizencontrolsextensionplugin.h"
+#include <QtQml>
+
+QQuickTizenControlsExtensionPlugin::QQuickTizenControlsExtensionPlugin(QObject *parent) :
+ QQmlExtensionPlugin(parent)
+{
+}
+
+
+static QObject *tizen_controls_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/)
+{
+ QObject *ret = 0;
+
+ QQmlComponent c(engine,QUrl("qrc:///QtQuick/Controls/Tizen/private/TizenControls.qml"),QQmlComponent::PreferSynchronous);
+ if (c.status() == QQmlComponent::Ready) {
+ ret = c.create();
+ if (!ret) {
+ qWarning() << "Can't create TizenControls Singleton Object:"<<c.errorString();
+ }
+ } else {
+ qWarning() << "TizenControls Singleton Component not Ready:"<<c.errorString();
+ }
+
+ return ret;
+}
+
+void QQuickTizenControlsExtensionPlugin::registerTypes(const char *uri)
+{
+ Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Tizen"));
+ qmlRegisterSingletonType<QObject>(uri,1,0,"TizenControls",tizen_controls_singletontype_provider);
+}
+
+void QQuickTizenControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
+{
+ QQmlExtensionPlugin::initializeEngine(engine,uri);
+}
diff --git a/src/controls/qquicktizencontrolsextensionplugin.h b/src/controls/qquicktizencontrolsextensionplugin.h
new file mode 100644
index 0000000..380bfe4
--- /dev/null
+++ b/src/controls/qquicktizencontrolsextensionplugin.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef QQUICKTIZENCONTROLSEXTENSIONPLUGIN_H
+#define QQUICKTIZENCONTROLSEXTENSIONPLUGIN_H
+
+#include <QQmlExtensionPlugin>
+
+class QQuickTizenControlsExtensionPlugin : public QQmlExtensionPlugin
+{
+public:
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
+public:
+ explicit QQuickTizenControlsExtensionPlugin(QObject *parent = 0);
+ void registerTypes(const char *uri);
+ void initializeEngine(QQmlEngine *engine, const char *uri);
+};
+
+#endif // QQUICKTIZENCONTROLSEXTENSIONPLUGIN_H
diff --git a/src/styles/private/TizenStyleConfig.qml b/src/styles/private/TizenStyleConfig.qml
index 6b42f60..f325853 100644
--- a/src/styles/private/TizenStyleConfig.qml
+++ b/src/styles/private/TizenStyleConfig.qml
@@ -17,9 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-import QtQml 2.0
import QtQuick 2.0
-import QtQuick.Controls.Styles.Tizen 1.0
+import "../DefaultSettings.js" as Theme
QtObject {
property string theme: "black"
diff --git a/src/styles/qmldir b/src/styles/qmldir
index b12affa..0b7f32d 100644
--- a/src/styles/qmldir
+++ b/src/styles/qmldir
@@ -17,7 +17,6 @@ PopupStyle 1.0 PopupStyle.qml
BusyIndicatorStyle 1.0 BusyIndicatorStyle.qml
DateEditStyle 1.0 DateEditStyle.qml
TimeEditStyle 1.0 TimeEditStyle.qml
-Theme 1.0 DefaultSettings.js
TitleBarStyle 1.0 TitleBarStyle.qml
ToolBarStyle 1.0 ToolBarStyle.qml
ToolBarButton 1.0 ToolBarButton.qml
diff --git a/src/styles/qquicktizenstyleextensionplugin.cpp b/src/styles/qquicktizenstyleextensionplugin.cpp
index 8ba04c0..50f2aac 100644
--- a/src/styles/qquicktizenstyleextensionplugin.cpp
+++ b/src/styles/qquicktizenstyleextensionplugin.cpp
@@ -26,10 +26,8 @@ QQuickTizenStyleExtensionPlugin::QQuickTizenStyleExtensionPlugin(QObject *parent
}
-static QObject *tizen_style_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
+static QObject *tizen_style_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/)
{
- Q_UNUSED(scriptEngine)
-
QObject *ret = 0;
QQmlComponent c(engine,QUrl("qrc:///QtQuick/Controls/Styles/Tizen/private/TizenStyleConfig.qml"),QQmlComponent::PreferSynchronous);
diff --git a/src/styles/styles.pro b/src/styles/styles.pro
index a5ee8a4..6bd0785 100644
--- a/src/styles/styles.pro
+++ b/src/styles/styles.pro
@@ -17,7 +17,6 @@ QML_FILES = \
Floater.qml \
SwitchStyle.qml\
DetailButtonStyle.qml\
- DefaultSettings.js\
ScrollDecoratorStyle.qml\
ContextMenuStyle.qml\
PopupStyle.qml\
@@ -29,9 +28,6 @@ QML_FILES = \
ToolBarStyle.qml \
ToolBarButton.qml
-QML_FILES += themes/Colors.js \
- Images.js
-
QML_FILES += \
private/DateEditField.qml\
private/DateEditBarPicker.qml
@@ -50,6 +46,9 @@ CONFIG += force_independent
OTHER_FILES += qmldir \
private/TizenStyleConfig.qml \
TizenSansRegular.ttf \
+ themes/Colors.js \
+ Images.js \
+ DefaultSettings.js \
$$QML_FILES
load(qml_module)