1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 00:54:20 +02:00

some more work on the station config

This commit is contained in:
Michael Zanetti
2012-07-21 15:37:08 +02:00
parent 95b43964df
commit d5935b632f
4 changed files with 127 additions and 26 deletions

View File

@@ -33,19 +33,23 @@ Item {
}
Text {
id: tempoText
text: "Tempo:"
color: "white"
}
DoubleSlider {
width: 500
height: tempoText.height
}
Text {
id: hotnessText
text: "Hotness:"
color: "white"
}
DoubleSlider {
width: 500
height: hotnessText.height
}
}

View File

@@ -19,7 +19,7 @@ Item {
//highlightMoveDuration: 500
model: dynamicModel
currentIndex: currentlyPlayedIndex
currentIndex: currentlyPlayedIndex >= 0 ? currentlyPlayedIndex : 0
property int pathStartX: width / 2
property int pathStartY: height / 2

View File

@@ -1,6 +1,7 @@
import QtQuick 1.1
Item {
id: root
width: 500
height: 10
@@ -10,27 +11,121 @@ Item {
property int lowerSliderPos: 25
property int upperSliderPos: 75
Rectangle {
id: lowerSlider
height: parent.height
width: height
anchors.top: parent.top
x: 10
}
Row {
anchors.fill: parent
spacing: 10
Rectangle {
id: upperSlider
height: parent.height
width: height
anchors.top: parent.top
x: 50
}
Text {
id: minText
text: min
color: "white"
}
Rectangle {
height: 4
color: "white"
radius: height / 2
width: parent.width
anchors.centerIn: parent
Item {
id: sliderRect
height: root.height
width: parent.width - minText.width - maxText.width - parent.spacing * 2
function sliderPosToValue( sliderPos ) {
var percent = sliderPos * 100 / (sliderRect.width - lowerSlider.width);
return Math.floor(percent * (root.max - root.min) / 100) + root.min
}
function valueToSloderPos( value ) {
var percent = (value - root.min) * 100 / (root.max - root.min)
return percent * (sliderRect.width - lowerSlider.width) / 100
}
Rectangle {
id: sliderBase
height: root.height / 5
width: parent.width
color: "white"
radius: height / 2
anchors.centerIn: parent
}
Rectangle {
id: lowerSlider
height: root.height
width: height
anchors.top: root.top
radius: height/2
border.color: "black"
border.width: 2
x: sliderRect.valueToSloderPos(root.lowerSliderPos)
Rectangle {
id: lowerFloatingRect
color: "white"
anchors.bottom: lowerSlider.top
anchors.bottomMargin: 10
visible: lowerSliderMouseArea.pressed
width: lowerFloatingText.width * 1.2
height: lowerFloatingText.height + height * 1.2
x: -(width - lowerSlider.width) / 2
radius: height / 4
Text {
id: lowerFloatingText
anchors.centerIn: parent
text: sliderRect.sliderPosToValue(lowerSlider.x)
}
}
}
MouseArea {
id: lowerSliderMouseArea
anchors.fill: lowerSlider
drag.target: lowerSlider
drag.axis: "XAxis"
drag.minimumX: 0
drag.maximumX: upperSlider.x - lowerSlider.width
}
Rectangle {
id: upperSlider
height: root.height
width: height
anchors.top: root.top
radius: height/2
border.color: "black"
border.width: 2
x: sliderRect.valueToSloderPos(root.upperSliderPos)
Rectangle {
id: upperFloatingRect
color: "white"
anchors.bottom: upperSlider.top
anchors.bottomMargin: 10
visible: upperSliderMouseArea.pressed
width: upperFloatingText.width * 1.2
height: upperFloatingText.height + height * 1.2
radius: height / 4
x: -(width - upperSlider.width) / 2
Text {
id: upperFloatingText
anchors.centerIn: parent
text: sliderRect.sliderPosToValue(upperSlider.x)
}
}
}
MouseArea {
id: upperSliderMouseArea
anchors.fill: upperSlider
onClicked: print("button pressed")
drag.target: upperSlider
drag.axis: "XAxis"
drag.minimumX: lowerSlider.x + lowerSlider.width
drag.maximumX: parent.width - upperSlider.width
}
}
Text {
id: maxText
text: max
color: "white"
}
}
}

View File

@@ -45,11 +45,13 @@ bool EchonestStation::configured()
void EchonestStation::playItem(int row)
{
QModelIndex index( m_model->index( row, 0) );
PlayableItem* item = m_model->itemFromIndex( index );
if ( item && !item->query().isNull() )
{
m_model->setCurrentIndex( index );
AudioEngine::instance()->playItem( m_model->playlistInterface(), item->query() );
if( index.isValid() ) {
PlayableItem* item = m_model->itemFromIndex( index );
if ( item && !item->query().isNull() )
{
m_model->setCurrentIndex( index );
AudioEngine::instance()->playItem( m_model->playlistInterface(), item->query() );
}
}
}