From 25f889bef86738b50ab78dc7c0011375709af2ab Mon Sep 17 00:00:00 2001 From: Oscar Andreasson Date: Mon, 16 Nov 2015 09:27:06 +0100 Subject: [PATCH] A lot of changes and additions... --- Calendar.qml | 18 +++++-- Clock.qml | 11 ++--- MirrorText.qml | 10 ++++ MirrorWindow.qml | 12 +++++ QmlMirror.pro | 16 ++++--- TaskWarrior.qml | 31 ++++++++++++ lala.qml | 119 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 201 insertions(+), 16 deletions(-) create mode 100644 MirrorText.qml create mode 100644 MirrorWindow.qml create mode 100644 TaskWarrior.qml create mode 100644 lala.qml diff --git a/Calendar.qml b/Calendar.qml index 3f82110..52b84aa 100644 --- a/Calendar.qml +++ b/Calendar.qml @@ -6,10 +6,11 @@ import QtQuick.Controls.Styles 1.2 Rectangle { id: root - width: 360 +// width: 360 // height: 700 color: "black" anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter ListView { anchors.fill: parent @@ -58,12 +59,21 @@ Rectangle { width: root.width Text { + id: textElement anchors.verticalCenter: parent.verticalCenter - x: 15 + x: 5 font.pixelSize: 24 color: "white" text: owner } + Rectangle { + anchors.top: textElement.bottom + width: textElement.width + height: 2 + x: 5 + color: "white" + } + Component.onCompleted: { calendarEntryModel.setProperty(index, "collapsed", !collapsed) } @@ -98,10 +108,10 @@ Rectangle { Text { anchors.verticalCenter: parent.verticalCenter - x: 30 + x: 0 font.pixelSize: 18 color: "white" - text: time + " " + heading + text: time + "\t" + heading } } } diff --git a/Clock.qml b/Clock.qml index 8577b1d..79a511f 100644 --- a/Clock.qml +++ b/Clock.qml @@ -11,10 +11,7 @@ import QtQuick.Layouts 1.1 import QtQuick.Controls 1.1 import QtQuick.Window 2.0 -Rectangle { - width: 360 - height: 160 - color: "#000000" +MirrorWindow { property date currDate: new Date() Timer { @@ -32,13 +29,15 @@ Rectangle { font.pointSize: 48 font.family: "Helvetica" color: "#ffffff" - anchors.horizontalCenter: parent.horizontalCenter + //anchors.horizontalCenter: parent.horizontalCenter + x: 5 } Text { id: datum anchors.top: time.bottom - anchors.horizontalCenter: parent.horizontalCenter + //anchors.horizontalCenter: parent.horizontalCenter + x: 5 font.pointSize: 24 color: "#ffffff" font.family: "Helvetica" diff --git a/MirrorText.qml b/MirrorText.qml new file mode 100644 index 0000000..0674700 --- /dev/null +++ b/MirrorText.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Text { + id: time + anchors.top: parent.top + font.pointSize: 48 + font.family: "Helvetica" + color: "#ffffff" + //anchors.horizontalCenter: parent.horizontalCenter +} diff --git a/MirrorWindow.qml b/MirrorWindow.qml new file mode 100644 index 0000000..7152013 --- /dev/null +++ b/MirrorWindow.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 360*windowWidth + height: 160*windowHeight + color: "#000000" + + property int windowHeight: 1 + property int windowWidth: 1 + + +} diff --git a/QmlMirror.pro b/QmlMirror.pro index 735d22e..b3ab271 100644 --- a/QmlMirror.pro +++ b/QmlMirror.pro @@ -6,18 +6,22 @@ # Copyright (c) 2015 Oscar Andreasson # -TEMPLATE = subdirs +TEMPLATE = app SUBDIRS = weatherinfo +OTHER_FILES = \ + LICENSE -SOURCES = QmlMirror.qml \ +DISTFILES += \ + TaskWarrior.qml \ + QmlMirror.qml \ Clock.qml \ Weather.qml \ Transport.qml \ Position.qml \ Main.qml \ - Calendar.qml - -OTHER_FILES = \ - LICENSE + Calendar.qml \ + lala.qml \ + MirrorText.qml \ + MirrorWindow.qml diff --git a/TaskWarrior.qml b/TaskWarrior.qml new file mode 100644 index 0000000..e79dcd1 --- /dev/null +++ b/TaskWarrior.qml @@ -0,0 +1,31 @@ +import QtQuick 2.2 + +//import net.frozentux.qmlcomponents 1.0 + +Rectangle { + id: root + anchors.fill: parent + color: "white" + + property string fileName: "jsondata.txt" + + JSONListModel { + id: jsonModel + source: "jsondata.txt" + } + + + ListView { + id: jsonView + anchors.fill: parent + + model: jsonModel.model + + delegate: Text { + text: model.description + Component.onCompleted: { + console.log("Text: " + text) + } + } + } +} diff --git a/lala.qml b/lala.qml new file mode 100644 index 0000000..015bb61 --- /dev/null +++ b/lala.qml @@ -0,0 +1,119 @@ + +import QtQuick 2.0 + +Item { +// width: 200 +// height: 700 + + ListView { + anchors.fill: parent + model: nestedModel + delegate: categoryDelegate + } + + ListModel { + id: nestedModel + ListElement { + categoryName: "Veggies" + collapsed: true + + // A ListElement can't contain child elements, but it can contain + // a list of elements. A list of ListElements can be used as a model + // just like any other model type. + subItems: [ + ListElement { itemName: "Tomato" }, + ListElement { itemName: "Cucumber" }, + ListElement { itemName: "Onion" }, + ListElement { itemName: "Brains" } + ] + } + + ListElement { + categoryName: "Fruits" + collapsed: true + subItems: [ + ListElement { itemName: "Orange" }, + ListElement { itemName: "Apple" }, + ListElement { itemName: "Pear" }, + ListElement { itemName: "Lemon" } + ] + } + + ListElement { + categoryName: "Cars" + collapsed: true + subItems: [ + ListElement { itemName: "Nissan" }, + ListElement { itemName: "Toyota" }, + ListElement { itemName: "Chevy" }, + ListElement { itemName: "Audi" } + ] + } + } + + Component { + id: categoryDelegate + Column { + width: 200 + + Rectangle { + id: categoryItem + border.color: "black" + border.width: 5 + color: "white" + height: 50 + width: 200 + + Text { + anchors.verticalCenter: parent.verticalCenter + x: 15 + font.pixelSize: 24 + text: categoryName + + Component.onCompleted: { + nestedModel.setProperty(index, "collapsed", !collapsed) + } + } + + } + + Loader { + id: subItemLoader + + // This is a workaround for a bug/feature in the Loader element. If sourceComponent is set to null + // the Loader element retains the same height it had when sourceComponent was set. Setting visible + // to false makes the parent Column treat it as if it's height was 0. + visible: !collapsed + property variant subItemModel : subItems + sourceComponent: collapsed ? null : subItemColumnDelegate + onStatusChanged: if (status == Loader.Ready) item.model = subItemModel + } + } + + } + + Component { + id: subItemColumnDelegate + Column { + property alias model : subItemRepeater.model + width: 200 + Repeater { + id: subItemRepeater + delegate: Rectangle { + color: "#cccccc" + height: 40 + width: 200 + border.color: "black" + border.width: 2 + + Text { + anchors.verticalCenter: parent.verticalCenter + x: 30 + font.pixelSize: 18 + text: itemName + } + } + } + } + } +}