From 03ec3b9c5862e620c53850f8a7f236c7c14cd76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Gr=C3=BCtzner?= Date: Sat, 29 Dec 2018 20:23:17 +0100 Subject: [PATCH] changed calenders columnlayout to column and tried to add theme colors to combobpx but failed with it --- qml/calculator/CalculatorStartPage.qml | 2 +- qml/calender/CalenderGameOverPage.qml | 7 +- qml/calender/CalenderRunningPage.qml | 84 +++++++++++++++++++++++- qml/calender/CalenderStartPage.qml | 91 ++++++++++++++++---------- shared/themes/default.ini | 4 ++ 5 files changed, 147 insertions(+), 41 deletions(-) diff --git a/qml/calculator/CalculatorStartPage.qml b/qml/calculator/CalculatorStartPage.qml index 7eb0185..08c3d1e 100644 --- a/qml/calculator/CalculatorStartPage.qml +++ b/qml/calculator/CalculatorStartPage.qml @@ -138,7 +138,7 @@ Page { id: startButton text: "start" height: parent.width * 0.1 - font.pixelSize: parent.width * 0.075 + font.pixelSize: parent.width * 0.0625 anchors { left: parent.left right: parent.right diff --git a/qml/calender/CalenderGameOverPage.qml b/qml/calender/CalenderGameOverPage.qml index cc90446..44dde53 100644 --- a/qml/calender/CalenderGameOverPage.qml +++ b/qml/calender/CalenderGameOverPage.qml @@ -1,6 +1,7 @@ import QtQuick 2.11 import QtQuick.Controls 2.4 import "./" +import "../components" Page { id: root @@ -34,20 +35,18 @@ Page { width: childrenRect.width spacing: parent.width * 0.1 - RoundButton { + GameButton { id: homeButton height: root.width * 0.2 - width: height text: "home" onClicked: { game.start() } } - RoundButton { + GameButton { id: startButtons height: root.width * 0.2 - width: height text: "start" onClicked: { calender.start() diff --git a/qml/calender/CalenderRunningPage.qml b/qml/calender/CalenderRunningPage.qml index 75039b0..5c2406b 100644 --- a/qml/calender/CalenderRunningPage.qml +++ b/qml/calender/CalenderRunningPage.qml @@ -14,7 +14,7 @@ Page { Label { id: date anchors.centerIn: parent - font.pixelSize: parent.height * 0.2 + font.pixelSize: parent.width * 0.2 text: calender.nextDate visible: calender.runningPageState ? true:false color: settings.theme("PageTextColor") @@ -91,10 +91,88 @@ Page { } ComboBox { - id: comboBox + id: dateBox model: ["None", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] anchors.centerIn: parent visible: calender.runningPageState ? false:true + + indicator: Canvas { + id: canvas + x: dateBox.width - width - dateBox.rightPadding + y: dateBox.topPadding + (dateBox.availableHeight - height) / 2 + width: 12 + height: 8 + contextType: "2d" + + Connections { + target: dateBox + onPressedChanged: canvas.requestPaint() + } + + onPaint: { + context.reset(); + context.moveTo(0, 0); + context.lineTo(width, 0); + context.lineTo(width / 2, height); + context.closePath(); + context.fillStyle = dateBox.pressed ? "#17a81a" : "#21be2b"; + context.fill(); + } + } + + delegate: ItemDelegate { + width: dateBox.width + contentItem: Text { + text: modelData + color: "green" + font: dateBox.font + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + highlighted: dateBox.highlightedIndex === index + } + + contentItem: Text { + leftPadding: 10 // should be in reference to width + rightPadding: dateBox.indicator.width + dateBox.spacing + + text: dateBox.displayText + font: dateBox.font + color: "red" + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + border.color: settings.theme("ComboBoxBorderColor") + border.width: settings.theme("ComboBoxBorderWidth") + radius: settings.theme("ComboBoxRadius") + } + + popup: Popup { + y: dateBox.height - 1 + width: dateBox.width + implicitHeight: contentItem.implicitHeight + padding: 1 + + contentItem: ListView { + clip: true + implicitHeight: contentHeight + model: dateBox.popup.visible ? dateBox.delegateModel : null + currentIndex: dateBox.highlightedIndex + + ScrollIndicator.vertical: ScrollIndicator { } + } + + background: Rectangle { + border.color: "blue" + border.width: 10 + color: "yellow" + radius: 0 + } + } + + onCurrentTextChanged: { if (currentIndex !== 0) { if (currentIndex === calender.weekDay) { @@ -131,7 +209,7 @@ Page { onTriggered: { calender.runningPageState = false - comboBox.currentIndex = 0 + dateBox.currentIndex = 0 } onRunningChanged: { diff --git a/qml/calender/CalenderStartPage.qml b/qml/calender/CalenderStartPage.qml index 8abd8ac..e20d31c 100644 --- a/qml/calender/CalenderStartPage.qml +++ b/qml/calender/CalenderStartPage.qml @@ -2,6 +2,7 @@ import QtQuick 2.11 import QtQuick.Controls 2.4 import QtQuick.Layouts 1.3 import "./" +import "../components" Page { id: root @@ -12,9 +13,12 @@ Page { color: settings.theme("PageBackgroundColor") } - ColumnLayout { + property int itemHeight: heading.height + tickIntervalInfo.height + tickInterval.height + numCountInfo.height + numCount.height + minInfo.height + min.height + maxInfo.height + max.height + startButton.height + property int columnItems: 10 + + Column { id: column - //spacing: height / 40 + spacing: (column.height - itemHeight) / columnItems width: parent.width anchors.fill: parent anchors.topMargin: parent.height * 0.02 @@ -22,20 +26,22 @@ Page { Label { id: heading - font.pixelSize: parent.width * 0.075 + font.pixelSize: parent.width * 0.125 text: "Calender" color: settings.theme("PageTextColor") - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.5 - width * 0.5 - Layout.rightMargin: parent.width * 0.5 - width * 0.5 + anchors { + horizontalCenter: parent.horizontalCenter + } } Label { id: tickIntervalInfo text: "Interval:" - font.pixelSize: parent.height * 0.05 color: settings.theme("PageTextColor") - Layout.leftMargin: parent.width * 0.05 + font.pixelSize: parent.height * 0.05 + anchors { + horizontalCenter: parent.horizontalCenter + } } @@ -45,18 +51,23 @@ Page { placeholderText: "interval" validator: IntValidator {bottom: 1; top: 1000000;} horizontalAlignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.05 - Layout.rightMargin: parent.width * 0.05 + anchors { + left: parent.left + right: parent.right + leftMargin: parent.width * 0.05 + rightMargin: parent.width * 0.05 + } Keys.onReturnPressed: root.start() } Label { id: dateCountInfo text: "Dates:" - font.pixelSize: parent.height * 0.05 color: settings.theme("PageTextColor") - Layout.leftMargin: parent.width * 0.05 + font.pixelSize: parent.height * 0.05 + anchors { + horizontalCenter: parent.horizontalCenter + } } TextField { @@ -64,20 +75,24 @@ Page { text: calender.dateCount placeholderText: "dates" validator: IntValidator {bottom: 1; top: 100000;} - color: settings.theme("PageTextColor") horizontalAlignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.05 - Layout.rightMargin: parent.width * 0.05 + anchors { + left: parent.left + right: parent.right + leftMargin: parent.width * 0.05 + rightMargin: parent.width * 0.05 + } Keys.onReturnPressed: root.start() } Label { id: minInfo text: "Minimum:" - font.pixelSize: parent.height * 0.05 color: settings.theme("PageTextColor") - Layout.leftMargin: parent.width * 0.05 + font.pixelSize: parent.height * 0.05 + anchors { + horizontalCenter: parent.horizontalCenter + } } TextField { @@ -86,18 +101,23 @@ Page { placeholderText: "minimum" validator: IntValidator {bottom: 1800; top: 10000;} horizontalAlignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.05 - Layout.rightMargin: parent.width * 0.05 + anchors { + left: parent.left + right: parent.right + leftMargin: parent.width * 0.05 + rightMargin: parent.width * 0.05 + } Keys.onReturnPressed: root.start() } Label { id: maxInfo text: "Maximum:" - font.pixelSize: parent.height * 0.05 color: settings.theme("PageTextColor") - Layout.leftMargin: parent.width * 0.05 + font.pixelSize: parent.height * 0.05 + anchors { + horizontalCenter: parent.horizontalCenter + } } TextField { @@ -106,21 +126,26 @@ Page { placeholderText: "maximum" validator: IntValidator {bottom: 1800; top: 10000;} horizontalAlignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.05 - Layout.rightMargin: parent.width * 0.05 + anchors { + left: parent.left + right: parent.right + leftMargin: parent.width * 0.05 + rightMargin: parent.width * 0.05 + } Keys.onReturnPressed: root.start() } - RoundButton { + GameButton { id: startButton text: "start" height: parent.width * 0.1 - width: height - //font.pixelSize: parent.width * 0.03 - Layout.fillWidth: true - Layout.leftMargin: parent.width * 0.05 - Layout.rightMargin: parent.width * 0.05 + font.pixelSize: parent.width * 0.0625 + anchors { + left: parent.left + right: parent.right + leftMargin: parent.width * 0.05 + rightMargin: parent.width * 0.05 + } onClicked: { root.start() } diff --git a/shared/themes/default.ini b/shared/themes/default.ini index dd494be..4d1a12e 100644 --- a/shared/themes/default.ini +++ b/shared/themes/default.ini @@ -6,3 +6,7 @@ ButtonBackgroundColor=black ButtonTextColor=white ButtonBorderWidth=0 ButtonBorderColor= + +ComboBoxBorderColor=black +ComboBoxBorderWidth=1 +ComboBoxRadius=0