changed calenders columnlayout to column and tried to add theme colors to combobpx but failed with it

This commit is contained in:
Max Grützner 2018-12-29 20:23:17 +01:00
parent c642b012b5
commit 03ec3b9c58
5 changed files with 147 additions and 41 deletions

View file

@ -138,7 +138,7 @@ Page {
id: startButton id: startButton
text: "start" text: "start"
height: parent.width * 0.1 height: parent.width * 0.1
font.pixelSize: parent.width * 0.075 font.pixelSize: parent.width * 0.0625
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right

View file

@ -1,6 +1,7 @@
import QtQuick 2.11 import QtQuick 2.11
import QtQuick.Controls 2.4 import QtQuick.Controls 2.4
import "./" import "./"
import "../components"
Page { Page {
id: root id: root
@ -34,20 +35,18 @@ Page {
width: childrenRect.width width: childrenRect.width
spacing: parent.width * 0.1 spacing: parent.width * 0.1
RoundButton { GameButton {
id: homeButton id: homeButton
height: root.width * 0.2 height: root.width * 0.2
width: height
text: "home" text: "home"
onClicked: { onClicked: {
game.start() game.start()
} }
} }
RoundButton { GameButton {
id: startButtons id: startButtons
height: root.width * 0.2 height: root.width * 0.2
width: height
text: "start" text: "start"
onClicked: { onClicked: {
calender.start() calender.start()

View file

@ -14,7 +14,7 @@ Page {
Label { Label {
id: date id: date
anchors.centerIn: parent anchors.centerIn: parent
font.pixelSize: parent.height * 0.2 font.pixelSize: parent.width * 0.2
text: calender.nextDate text: calender.nextDate
visible: calender.runningPageState ? true:false visible: calender.runningPageState ? true:false
color: settings.theme("PageTextColor") color: settings.theme("PageTextColor")
@ -91,10 +91,88 @@ Page {
} }
ComboBox { ComboBox {
id: comboBox id: dateBox
model: ["None", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"] model: ["None", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
anchors.centerIn: parent anchors.centerIn: parent
visible: calender.runningPageState ? false:true 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: { onCurrentTextChanged: {
if (currentIndex !== 0) { if (currentIndex !== 0) {
if (currentIndex === calender.weekDay) { if (currentIndex === calender.weekDay) {
@ -131,7 +209,7 @@ Page {
onTriggered: { onTriggered: {
calender.runningPageState = false calender.runningPageState = false
comboBox.currentIndex = 0 dateBox.currentIndex = 0
} }
onRunningChanged: { onRunningChanged: {

View file

@ -2,6 +2,7 @@ import QtQuick 2.11
import QtQuick.Controls 2.4 import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "./" import "./"
import "../components"
Page { Page {
id: root id: root
@ -12,9 +13,12 @@ Page {
color: settings.theme("PageBackgroundColor") 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 id: column
//spacing: height / 40 spacing: (column.height - itemHeight) / columnItems
width: parent.width width: parent.width
anchors.fill: parent anchors.fill: parent
anchors.topMargin: parent.height * 0.02 anchors.topMargin: parent.height * 0.02
@ -22,20 +26,22 @@ Page {
Label { Label {
id: heading id: heading
font.pixelSize: parent.width * 0.075 font.pixelSize: parent.width * 0.125
text: "Calender" text: "Calender"
color: settings.theme("PageTextColor") color: settings.theme("PageTextColor")
Layout.fillWidth: true anchors {
Layout.leftMargin: parent.width * 0.5 - width * 0.5 horizontalCenter: parent.horizontalCenter
Layout.rightMargin: parent.width * 0.5 - width * 0.5 }
} }
Label { Label {
id: tickIntervalInfo id: tickIntervalInfo
text: "Interval:" text: "Interval:"
font.pixelSize: parent.height * 0.05
color: settings.theme("PageTextColor") 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" placeholderText: "interval"
validator: IntValidator {bottom: 1; top: 1000000;} validator: IntValidator {bottom: 1; top: 1000000;}
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
Layout.fillWidth: true anchors {
Layout.leftMargin: parent.width * 0.05 left: parent.left
Layout.rightMargin: parent.width * 0.05 right: parent.right
leftMargin: parent.width * 0.05
rightMargin: parent.width * 0.05
}
Keys.onReturnPressed: root.start() Keys.onReturnPressed: root.start()
} }
Label { Label {
id: dateCountInfo id: dateCountInfo
text: "Dates:" text: "Dates:"
font.pixelSize: parent.height * 0.05
color: settings.theme("PageTextColor") color: settings.theme("PageTextColor")
Layout.leftMargin: parent.width * 0.05 font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
} }
TextField { TextField {
@ -64,20 +75,24 @@ Page {
text: calender.dateCount text: calender.dateCount
placeholderText: "dates" placeholderText: "dates"
validator: IntValidator {bottom: 1; top: 100000;} validator: IntValidator {bottom: 1; top: 100000;}
color: settings.theme("PageTextColor")
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
Layout.fillWidth: true anchors {
Layout.leftMargin: parent.width * 0.05 left: parent.left
Layout.rightMargin: parent.width * 0.05 right: parent.right
leftMargin: parent.width * 0.05
rightMargin: parent.width * 0.05
}
Keys.onReturnPressed: root.start() Keys.onReturnPressed: root.start()
} }
Label { Label {
id: minInfo id: minInfo
text: "Minimum:" text: "Minimum:"
font.pixelSize: parent.height * 0.05
color: settings.theme("PageTextColor") color: settings.theme("PageTextColor")
Layout.leftMargin: parent.width * 0.05 font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
} }
TextField { TextField {
@ -86,18 +101,23 @@ Page {
placeholderText: "minimum" placeholderText: "minimum"
validator: IntValidator {bottom: 1800; top: 10000;} validator: IntValidator {bottom: 1800; top: 10000;}
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
Layout.fillWidth: true anchors {
Layout.leftMargin: parent.width * 0.05 left: parent.left
Layout.rightMargin: parent.width * 0.05 right: parent.right
leftMargin: parent.width * 0.05
rightMargin: parent.width * 0.05
}
Keys.onReturnPressed: root.start() Keys.onReturnPressed: root.start()
} }
Label { Label {
id: maxInfo id: maxInfo
text: "Maximum:" text: "Maximum:"
font.pixelSize: parent.height * 0.05
color: settings.theme("PageTextColor") color: settings.theme("PageTextColor")
Layout.leftMargin: parent.width * 0.05 font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
} }
TextField { TextField {
@ -106,21 +126,26 @@ Page {
placeholderText: "maximum" placeholderText: "maximum"
validator: IntValidator {bottom: 1800; top: 10000;} validator: IntValidator {bottom: 1800; top: 10000;}
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
Layout.fillWidth: true anchors {
Layout.leftMargin: parent.width * 0.05 left: parent.left
Layout.rightMargin: parent.width * 0.05 right: parent.right
leftMargin: parent.width * 0.05
rightMargin: parent.width * 0.05
}
Keys.onReturnPressed: root.start() Keys.onReturnPressed: root.start()
} }
RoundButton { GameButton {
id: startButton id: startButton
text: "start" text: "start"
height: parent.width * 0.1 height: parent.width * 0.1
width: height font.pixelSize: parent.width * 0.0625
//font.pixelSize: parent.width * 0.03 anchors {
Layout.fillWidth: true left: parent.left
Layout.leftMargin: parent.width * 0.05 right: parent.right
Layout.rightMargin: parent.width * 0.05 leftMargin: parent.width * 0.05
rightMargin: parent.width * 0.05
}
onClicked: { onClicked: {
root.start() root.start()
} }

View file

@ -6,3 +6,7 @@ ButtonBackgroundColor=black
ButtonTextColor=white ButtonTextColor=white
ButtonBorderWidth=0 ButtonBorderWidth=0
ButtonBorderColor= ButtonBorderColor=
ComboBoxBorderColor=black
ComboBoxBorderWidth=1
ComboBoxRadius=0