1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-31 17:42:13 +02:00

reworked buttons

This commit is contained in:
Michael Zanetti
2012-12-16 17:25:19 +01:00
parent 37996178b7
commit 1486a6a200
5 changed files with 77 additions and 20 deletions

View File

@@ -22,14 +22,13 @@ Rectangle {
subtitle: generator.summary
showSearchField: false
showBackButton: stationListView.currentIndex > 0
showNextButton: dynamicModel.rowCount() > 0 && stationListView.currentIndex < 2
showSaveButton: stationListView.currentIndex === 2
showNextButton: stationListView.currentIndex == 2
nextButtonText: "Save"
z: 1 //cover albumcovers that may leave their area
onBackPressed: stationListView.decrementCurrentIndex()
onNextPressed: stationListView.incrementCurrentIndex()
onSavePressed: print("should save station now")
}
ListModel {

View File

@@ -29,7 +29,9 @@ Rectangle {
property bool showBackButton: false
property bool showNextButton: false
property bool showSaveButton: false
property string backButtonText: "Back"
property string nextButtonText: "Next"
// Layout spacing
property int spacing: defaultFontHeight * 0.5
@@ -139,34 +141,51 @@ Rectangle {
anchors {
top: parent.top
right: parent.right
rightMargin: -backButton.width - root.spacing - nextButton.width - root.spacing
bottom: parent.bottom
margins: root.spacing
onRightMarginChanged: print("#+#+#+#+", anchors.rightMargin)
}
states: [
State {
name: "oneVisible"; when: root.showBackButton && !root.showNextButton
PropertyChanges {
target: rightRow
anchors.rightMargin: -nextButton.width
}
},
State {
name: "bothVisible"; when: root.showBackButton && root.showNextButton
PropertyChanges {
target: rightRow
anchors.rightMargin: root.spacing
}
}
]
width: childrenRect.width
spacing: root.spacing
layoutDirection: Qt.RightToLeft
RoundedButton {
height: parent.height * 0.8
anchors.verticalCenter: parent.verticalCenter
text: "+"
visible: root.showSaveButton
onClicked: root.saveClicked()
Behavior on anchors.rightMargin {
NumberAnimation { duration: 200 }
}
RoundedButton {
height: parent.height * 0.8
PushButton {
id: nextButton
anchors.verticalCenter: parent.verticalCenter
text: ">"
visible: root.showNextButton
text: root.nextButtonText
// visible: root.showNextButton
onClicked: root.nextPressed();
}
RoundedButton {
PushButton {
id: backButton
anchors.verticalCenter: parent.verticalCenter
height: parent.height * 0.8
text: "<"
visible: root.showBackButton
text: root.backButtonText
// visible: root.showBackButton
onClicked: root.backPressed();
}
InputField {

View File

@@ -38,11 +38,13 @@ Rectangle {
anchors.rightMargin: root.spacing
height: textInput.height
anchors.verticalCenter: parent.verticalCenter
TextInput {
id: textInput
width: parent.width
anchors.centerIn: parent
text: root.text
font.pointSize: defaultFontSize
onAccepted: root.accepted( text );
onTextChanged: root.text = text;
@@ -52,6 +54,7 @@ Rectangle {
anchors.centerIn: parent
text: root.text.length === 0 ? root.placeholderText : ""
color: "lightgray"
font.pointSize: defaultFontSize
}
}

View File

@@ -0,0 +1,35 @@
import QtQuick 1.1
//import tomahawk 1.0
Rectangle {
id: root
height: buttonText.height * 1.4
width: childrenRect.width + (spacing * 2)
radius: defaultFontHeight * 0.25
border.width: defaultFontHeight * 0.05
border.color: "#a7a7a7"
gradient: Gradient {
GradientStop { position: 0.0; color: mouseArea.pressed ? "#040404" : "#fbfbfb" }
GradientStop { position: 1.0; color: mouseArea.pressed ? "#8e8f8e" : "#787878" }
}
property int spacing: defaultFontHeight * 0.5
property alias text: buttonText.text
signal clicked()
Text {
id: buttonText
anchors.centerIn: root
font.pointSize: defaultFontSize
text: root.text
color: mouseArea.pressed ? "white" : "black"
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: root.clicked()
}
}