summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2016-10-04 02:40:01 (GMT)
committerAleix Pol <aleixpol@kde.org>2016-10-04 02:40:01 (GMT)
commiteacb5bdaf852ffc744c3d12554bc21e28863617e (patch)
treecbe924e4e0a09dcf565664fd9199ade1e8a33c3a
parentec4e94bded544196196c68a0c9b0094b2eff34e4 (diff)
Port to QtQuick.Controls 2.0
Hopefully will allow us to drop the material version, at least.
-rw-r--r--mobile/plugins/widgets/qtcontrols/AddButton.qml8
-rw-r--r--mobile/plugins/widgets/qtcontrols/Button.qml8
-rw-r--r--mobile/plugins/widgets/qtcontrols/ComboBox.qml2
-rw-r--r--mobile/plugins/widgets/qtcontrols/Dialog.qml11
-rw-r--r--mobile/plugins/widgets/qtcontrols/ExpressionInput.qml2
-rw-r--r--mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml106
-rw-r--r--mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml4
-rw-r--r--mobile/plugins/widgets/qtcontrols/Label.qml2
-rw-r--r--mobile/plugins/widgets/qtcontrols/RealInput.qml48
-rw-r--r--mobile/plugins/widgets/qtcontrols/SimpleListView.qml44
10 files changed, 91 insertions, 144 deletions
diff --git a/mobile/plugins/widgets/qtcontrols/AddButton.qml b/mobile/plugins/widgets/qtcontrols/AddButton.qml
index fe98048..c221086 100644
--- a/mobile/plugins/widgets/qtcontrols/AddButton.qml
+++ b/mobile/plugins/widgets/qtcontrols/AddButton.qml
@@ -1,14 +1,14 @@
-import QtQuick.Controls 1.1
+import QtQuick.Controls 2.1
-Button
+RoundButton
{
id: root
+ text: "+"
+
anchors {
right: parent.right
bottom: parent.bottom
margins: 20
}
-
- iconName: "list-add"
}
diff --git a/mobile/plugins/widgets/qtcontrols/Button.qml b/mobile/plugins/widgets/qtcontrols/Button.qml
index e39a24b..1d4f20d 100644
--- a/mobile/plugins/widgets/qtcontrols/Button.qml
+++ b/mobile/plugins/widgets/qtcontrols/Button.qml
@@ -1,4 +1,10 @@
-import QtQuick.Controls 1.0
+import QtQuick.Controls 2.0
Button {
+ readonly property var iconDictionary: {
+ "list-add": "+"
+ }
+
+ property var iconName: "" //TODO
+ text: iconDictionary[iconName]
}
diff --git a/mobile/plugins/widgets/qtcontrols/ComboBox.qml b/mobile/plugins/widgets/qtcontrols/ComboBox.qml
index 030ebfb..493d53a 100644
--- a/mobile/plugins/widgets/qtcontrols/ComboBox.qml
+++ b/mobile/plugins/widgets/qtcontrols/ComboBox.qml
@@ -1,4 +1,4 @@
-import QtQuick.Controls 1.3
+import QtQuick.Controls 2.1
ComboBox
{}
diff --git a/mobile/plugins/widgets/qtcontrols/Dialog.qml b/mobile/plugins/widgets/qtcontrols/Dialog.qml
index c981c80..f34dc0b 100644
--- a/mobile/plugins/widgets/qtcontrols/Dialog.qml
+++ b/mobile/plugins/widgets/qtcontrols/Dialog.qml
@@ -1,10 +1,7 @@
-import QtQuick 2.1
-import QtQuick.Dialogs 1.2
+import QtQuick.Controls 2.1
-Dialog {
- width: 100
+Drawer {
+ edge: Qt.BottomEdge
+ width: parent.width
height: 100
-
- default property Item fu
- contentItem: fu
}
diff --git a/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml b/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml
index 632115f..cae7a3c 100644
--- a/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml
+++ b/mobile/plugins/widgets/qtcontrols/ExpressionInput.qml
@@ -1,4 +1,4 @@
-import QtQuick.Controls 1.0
+import QtQuick.Controls 2.0
TextField
{
diff --git a/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml b/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml
index db4b8c4..69c7d59 100644
--- a/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml
+++ b/mobile/plugins/widgets/qtcontrols/KAlgebraMobile.qml
@@ -1,5 +1,6 @@
-import QtQuick 2.0
-import QtQuick.Controls 1.0
+import QtQuick 2.2
+import QtQuick.Layouts 1.2
+import QtQuick.Controls 2.1
import org.kde.analitza 1.0
import org.kde.kalgebra.mobile 1.0
@@ -9,67 +10,70 @@ ApplicationWindow
height: 600
width: 600
visible: true
-
- function goToPage(path, deco) {
+
+ header: ToolBar {
+ RowLayout {
+ anchors.fill: parent
+ ToolButton {
+ text: "\u2630"
+ onClicked: drawer.open()
+ }
+ Label {
+ text: "KAlgebra"
+ }
+ Item {
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ property string currentPath: pluginsModel.pluginPath(0)
+ onCurrentPathChanged: {
+ var component = Qt.createComponent(currentPath);
+ if (component.status == Component.Error) {
+ console.log("error", component.errorString());
+ return;
+ }
+
try {
- var component = Qt.createComponent(path)
- if (component.status == Component.Ready)
- pageStack.push(component);
- else
- console.log("Error loading component:", component.errorString());
- } catch (e) {
- console.log("error: "+e)
+ stack.replace(component)
+ } catch(e) {
+ console.log("error", e)
}
+ drawer.position = 0
}
-
- Component {
- id: pluginsView
- ListView {
- spacing: 10
- header: Image {
- source: "qrc:/kalgebra.png"
- anchors.horizontalCenter: parent.horizontalCenter
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.openUrlExternally("http://edu.kde.org/applications/mathematics/kalgebra/")
- }
- }
- footer: Image {
- source: "qrc:/kde-edu-logo.png"
- anchors.horizontalCenter: parent.horizontalCenter
+ Drawer {
+ id: drawer
+ edge: Qt.LeftEdge
+ width: parent.width - 56 * 1
+ height: parent.height
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.openUrlExternally("http://edu.kde.org")
- }
- }
- delegate:
- Button {
+ ColumnLayout {
+ anchors.fill: parent
+ Repeater {
+ delegate: ItemDelegate {
+ Layout.fillWidth: true
text: title
- onClicked: goToPage(model.path)
- anchors.horizontalCenter: parent.horizontalCenter
+ highlighted: model.path == rootItem.currentPath
+ onClicked: {
+ rootItem.currentPath = model.path
+ }
}
- model: PluginsModel { id: plugins }
- }
- }
+ model: PluginsModel {
+ id: pluginsModel
+ }
+ }
- Action {
- id: backAction
- text: "Back"
- shortcut: "Back"
- tooltip: "Go back"
- onTriggered: {
- if (pageStack.depth==1)
- Qt.quit();
- else
- pageStack.pop();
+ Item {
+ width: 5
+ Layout.fillHeight: true
+ }
}
}
StackView {
- id: pageStack
- initialItem: pluginsView
+ id: stack
anchors.fill: parent
}
}
diff --git a/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml b/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml
index 53fe127..8c6e86b 100644
--- a/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml
+++ b/mobile/plugins/widgets/qtcontrols/KAlgebraPage.qml
@@ -1,6 +1,6 @@
-import QtQuick 2.0
+import QtQuick.Controls 2.0
-Item
+Page
{
property real dp: 1
}
diff --git a/mobile/plugins/widgets/qtcontrols/Label.qml b/mobile/plugins/widgets/qtcontrols/Label.qml
index f34d588..83e1208 100644
--- a/mobile/plugins/widgets/qtcontrols/Label.qml
+++ b/mobile/plugins/widgets/qtcontrols/Label.qml
@@ -1,4 +1,4 @@
-import QtQuick.Controls 1.0
+import QtQuick.Controls 2.0
Label {
}
diff --git a/mobile/plugins/widgets/qtcontrols/RealInput.qml b/mobile/plugins/widgets/qtcontrols/RealInput.qml
index c68de44..ba0f33e 100644
--- a/mobile/plugins/widgets/qtcontrols/RealInput.qml
+++ b/mobile/plugins/widgets/qtcontrols/RealInput.qml
@@ -1,46 +1,12 @@
-import QtQuick.Controls 1.0
-import QtQuick 2.0
+import QtQuick.Controls 2.0
-TextField
+SpinBox
{
id: input
- property alias minimumValue: realvalidator.bottom
- property alias maximumValue: realvalidator.top
+ property alias minimumValue: input.from
+ property alias maximumValue: input.to
+ property string text
+ value: valueFromText(text)
- property double value: parseFloat(text)
- inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
-
- validator: DoubleValidator { id: realvalidator }
-
- onTextChanged: value=parseFloat(text)
-
- Component.onCompleted: text=value
-
- Row {
- anchors {
- right: parent.right
- rightMargin: 2
- }
- spacing: 2
- height: parent.height-4
- y:2
- Button {
- text: "+"
- height: parent.height
- onClicked: {
- if(input.value+1<maximumValue) {
- input.text=(input.value+1)
- }
- }
- }
- Button {
- text: "-"
- onClicked: {
- if(input.value-1>minimumValue) {
- input.text=(input.value-1)
- }
- }
- height: parent.height
- }
- }
+ signal accepted()
}
diff --git a/mobile/plugins/widgets/qtcontrols/SimpleListView.qml b/mobile/plugins/widgets/qtcontrols/SimpleListView.qml
index a5db36e..bfc7ddc 100644
--- a/mobile/plugins/widgets/qtcontrols/SimpleListView.qml
+++ b/mobile/plugins/widgets/qtcontrols/SimpleListView.qml
@@ -1,43 +1,17 @@
+import QtQuick.Controls 2.1
import QtQuick 2.0
-import QtQuick.Controls 1.0
-import QtQuick.Layouts 1.1
-ColumnLayout
+ListView
{
- id: viewItem
+ id: scrollList
property string role: ""
property string title: ""
- property alias currentIndex: table.currentRow
- property alias model: table.model
- property Component delegate
- property Component header
- property Component footer
-
- Loader {
- Layout.fillWidth: true
- sourceComponent: parent.header
- }
-
- TableView
- {
- id: table
- Layout.fillWidth: true
- Layout.fillHeight: true
-
- TableViewColumn {
- role: viewItem.role
- title: viewItem.title
- }
-
- itemDelegate: Item {
- Label {
- anchors.verticalCenter: parent.verticalCenter
- text: styleData.value
- }
+ delegate: ItemDelegate {
+ Label {
+ text: model[role]
}
}
- Loader {
- Layout.fillWidth: true
- sourceComponent: parent.footer
- }
+ header: Label { visible: ListView.view.title!=""; text: ListView.view.title }
+ clip: true
}
+