diff --git a/data/qml/StationConfig.qml b/data/qml/StationConfig.qml index cd75e99f0..fd62e333a 100644 --- a/data/qml/StationConfig.qml +++ b/data/qml/StationConfig.qml @@ -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 } } diff --git a/data/qml/StationView.qml b/data/qml/StationView.qml index c1ee5cd2f..5f4677c1d 100644 --- a/data/qml/StationView.qml +++ b/data/qml/StationView.qml @@ -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 diff --git a/data/qml/tomahawkimports/DoubleSlider.qml b/data/qml/tomahawkimports/DoubleSlider.qml index 78615879e..f03f66898 100644 --- a/data/qml/tomahawkimports/DoubleSlider.qml +++ b/data/qml/tomahawkimports/DoubleSlider.qml @@ -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" + } } } diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp index ec4c4a438..4551e994b 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp @@ -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() ); + } } }