From 87966d56360a3f65f740c8c992b1d294ef373d30 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Thu, 19 Jul 2012 21:37:27 +0200 Subject: [PATCH] - make the station stuff adapt to high DPIs - more work on the config dialog --- data/qml/StationConfig.qml | 61 +++++++++++-------- data/qml/StationScene.qml | 2 +- data/qml/StationView.qml | 48 ++++++--------- data/qml/tomahawkimports/Button.qml | 29 +++++++++ data/qml/tomahawkimports/DoubleSlider.qml | 36 +++++++++++ data/qml/tomahawkimports/InputField.qml | 23 +++++++ resources.qrc | 3 + .../dynamic/echonest/EchonestStation.cpp | 15 ++--- .../dynamic/echonest/EchonestStation.h | 4 +- .../dynamic/widgets/DynamicQmlWidget.cpp | 6 +- 10 files changed, 155 insertions(+), 72 deletions(-) create mode 100644 data/qml/tomahawkimports/Button.qml create mode 100644 data/qml/tomahawkimports/DoubleSlider.qml create mode 100644 data/qml/tomahawkimports/InputField.qml diff --git a/data/qml/StationConfig.qml b/data/qml/StationConfig.qml index 4311ce468..cd75e99f0 100644 --- a/data/qml/StationConfig.qml +++ b/data/qml/StationConfig.qml @@ -1,5 +1,6 @@ import QtQuick 1.1 import tomahawk 1.0 +import "tomahawkimports" Item { id: fineTuneView @@ -9,45 +10,53 @@ Item { signal done(); Grid { - anchors.fill: parent + anchors.top: parent.top + anchors.bottom: parent.bottom anchors.margins: 50 + anchors.horizontalCenter: parent.horizontalCenter + width: scene.width / 2 + spacing: 50 + columns: 2 + Text { color: fineTuneView.textColor - text: "Name" + text: "Name:" } - TextInput { - id: stationName - width: 200 + InputField { text: echonestStation.name - //onTextChanged: echonestStation. + + onAccepted: { + print("text changed!!!") + echonestStation.name = text; + } + } + + Text { + text: "Tempo:" + color: "white" + } + DoubleSlider { + width: 500 + } + + Text { + text: "Hotness:" + color: "white" + } + DoubleSlider { + width: 500 } } - Rectangle { + + Button { id: configureButton + onClicked: fineTuneView.done(); + text: "configure" anchors.bottom: parent.bottom anchors.bottomMargin: 20 anchors.horizontalCenter: parent.horizontalCenter - color: "gray" - height: 20 - width: 150 - radius: 10 - //opacity: 0 - - Text { - anchors.centerIn: parent - text: "configure" - color: "white" - } - - MouseArea { - anchors.fill: parent - onClicked: { - fineTuneView.done(); - } - } } - } diff --git a/data/qml/StationScene.qml b/data/qml/StationScene.qml index 9753e67b0..dcee6688a 100644 --- a/data/qml/StationScene.qml +++ b/data/qml/StationScene.qml @@ -28,7 +28,7 @@ Rectangle { } StationView { - coverSize: 250 + coverSize: Math.min(scene.height, scene.width) / 2 height: scene.height width: scene.width diff --git a/data/qml/StationView.qml b/data/qml/StationView.qml index d0a038d3a..c1ee5cd2f 100644 --- a/data/qml/StationView.qml +++ b/data/qml/StationView.qml @@ -1,5 +1,6 @@ import QtQuick 1.1 import tomahawk 1.0 +import "tomahawkimports" Item { id: root @@ -84,14 +85,14 @@ Item { anchors { left: parent.left; top: parent.top; right: parent.right } Text { color: "white" - font.pixelSize: 16 + font.pointSize: 12 width: parent.width elide: Text.ElideRight text: "Station:" } Text { color: "white" - font.pixelSize: 24 + font.pointSize: 14 font.bold: true width: parent.width elide: Text.ElideRight @@ -108,16 +109,16 @@ Item { Text { color: "white" - font.pixelSize: 16 + font.pointSize: 12 width: parent.width elide: Text.ElideRight text: "Now Playing:" visible: currentlyPlayedIndex !== -1 } Rectangle { - height: 64 - width: parent.width - radius: 32 + height: image.height + image.height / 5 + width: image.width + startPlayingText.width * 1.2 + radius: height / 2 border.width: 2 border.color: "white" color: startPlayingMouseArea.containsMouse ? "blue" : "gray" @@ -131,12 +132,13 @@ Item { } Text { + id: startPlayingText color: "white" - font.pixelSize: 24 + font.pointSize: 20 anchors.left: image.right - anchors.margins: 10 + anchors.margins: height / 5 anchors.verticalCenter: parent.verticalCenter - width: parent.width - 30 - image.width + //width: parent.width - 30 - image.width elide: Text.ElideRight text: "Start playing" } @@ -150,21 +152,21 @@ Item { Text { color: "white" - font.pixelSize: 24 + font.pointSize: 16 width: parent.width elide: Text.ElideRight text: coverView.model.itemFromIndex( currentlyPlayedIndex ).name } Text { color: "white" - font.pixelSize: 20 + font.pointSize: 14 width: parent.width elide: Text.ElideRight text: coverView.model.itemFromIndex( currentlyPlayedIndex ).artistName } Text { color: "white" - font.pixelSize: 20 + font.pointSize: 14 width: parent.width elide: Text.ElideRight text: coverView.model.itemFromIndex( currentlyPlayedIndex ).albumName @@ -172,29 +174,13 @@ Item { } } - Rectangle { + Button { id: configureButton anchors.bottom: parent.bottom anchors.bottomMargin: 20 anchors.horizontalCenter: parent.horizontalCenter - color: "gray" - height: 20 - width: 150 - radius: 10 - //opacity: 0 - - Text { - anchors.centerIn: parent - text: "configure" - color: "white" - } - - MouseArea { - anchors.fill: parent - onClicked: { - root.configure(); - } - } + text: "configure" + onClicked: root.configure(); } } diff --git a/data/qml/tomahawkimports/Button.qml b/data/qml/tomahawkimports/Button.qml new file mode 100644 index 000000000..1c73d7c8c --- /dev/null +++ b/data/qml/tomahawkimports/Button.qml @@ -0,0 +1,29 @@ +import QtQuick 1.1 + +Rectangle { + id: root + color: buttonMouseArea.containsMouse ? "blue" : "gray" + border.width: 2 + border.color: "white" + radius: height/2 + height: buttonText.height * 1.2 + width: buttonText.width * 1.5 + + property alias text: buttonText.text + property color textColor: "white" + + signal clicked() + + Text { + id: buttonText + anchors.centerIn: parent + color: root.textColor + } + + MouseArea { + id: buttonMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: root.clicked(); + } +} diff --git a/data/qml/tomahawkimports/DoubleSlider.qml b/data/qml/tomahawkimports/DoubleSlider.qml new file mode 100644 index 000000000..78615879e --- /dev/null +++ b/data/qml/tomahawkimports/DoubleSlider.qml @@ -0,0 +1,36 @@ +import QtQuick 1.1 + +Item { + width: 500 + height: 10 + + property int min: 0 + property int max: 100 + + property int lowerSliderPos: 25 + property int upperSliderPos: 75 + + Rectangle { + id: lowerSlider + height: parent.height + width: height + anchors.top: parent.top + x: 10 + } + + Rectangle { + id: upperSlider + height: parent.height + width: height + anchors.top: parent.top + x: 50 + } + + Rectangle { + height: 4 + color: "white" + radius: height / 2 + width: parent.width + anchors.centerIn: parent + } +} diff --git a/data/qml/tomahawkimports/InputField.qml b/data/qml/tomahawkimports/InputField.qml new file mode 100644 index 000000000..c50843639 --- /dev/null +++ b/data/qml/tomahawkimports/InputField.qml @@ -0,0 +1,23 @@ +import QtQuick 1.1 + +Rectangle { + id: root + color: "white" + border.color: "black" + border.width: 2 + + height: textInput.height + 4 + width: 300 + + property alias text: textInput.text + + signal accepted( string text ) + + TextInput { + id: textInput + width: parent.width + anchors.centerIn: parent + + onAccepted: root.accepted( text ); + } +} diff --git a/resources.qrc b/resources.qrc index cdb0a8fcf..4e39e93b0 100644 --- a/resources.qrc +++ b/resources.qrc @@ -152,5 +152,8 @@ data/qml/TagCloud.qml data/qml/StationConfig.qml data/qml/StationView.qml + data/qml/tomahawkimports/InputField.qml + data/qml/tomahawkimports/Button.qml + data/qml/tomahawkimports/DoubleSlider.qml diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp index eb5beb6ba..ec4c4a438 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.cpp @@ -1,4 +1,5 @@ #include "EchonestStation.h" +#include "dynamic/DynamicPlaylist.h" #include "PlayableItem.h" #include "audio/AudioEngine.h" @@ -6,28 +7,28 @@ namespace Tomahawk { -EchonestStation::EchonestStation( PlayableProxyModel *model, geninterface_ptr generator, QObject *parent ) +EchonestStation::EchonestStation( PlayableProxyModel *model, dynplaylist_ptr playlist, QObject *parent ) : QObject( parent ) , m_name( model->sourceModel()->title() ) , m_model( model ) - , m_generator( generator ) + , m_playlist( playlist ) { } QString EchonestStation::name() const { - return m_name; + return m_playlist->title(); } void EchonestStation::setName(const QString &name) { - m_name = name; + m_playlist->setTitle( name ); emit nameChanged(); } Tomahawk::DynamicControl* EchonestStation::mainControl() { - foreach(dyncontrol_ptr control, m_generator->controls()) { + foreach(dyncontrol_ptr control, m_playlist->generator()->controls()) { qDebug() << "got control" << control->selectedType(); if(control->selectedType() == "Artist" || control->selectedType() == "Style") { return control.data(); @@ -54,12 +55,12 @@ void EchonestStation::playItem(int row) void EchonestStation::setMainControl(const QString &type) { - dyncontrol_ptr control = m_generator->createControl("echonest"); + dyncontrol_ptr control = m_playlist->generator()->createControl("echonest"); control->setSelectedType("Style"); control->setMatch("1"); control->setInput(type); qDebug() << "created control" << control->type() << control->selectedType() << control->match(); - m_generator->generate(20); + m_playlist->generator()->generate(20); emit configuredChanged(); } diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h index 519f42a84..753972413 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestStation.h @@ -14,7 +14,7 @@ class EchonestStation: public QObject Q_PROPERTY( Tomahawk::DynamicControl* mainControl READ mainControl ) public: - EchonestStation( PlayableProxyModel *model, geninterface_ptr generator, QObject *parent = 0); + EchonestStation( PlayableProxyModel *model, dynplaylist_ptr playlist, QObject *parent = 0); QString name() const; void setName( const QString &name ); @@ -34,7 +34,7 @@ signals: private: QString m_name; PlayableProxyModel *m_model; - geninterface_ptr m_generator; + dynplaylist_ptr m_playlist; }; } diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp index 22967dd24..2e7399a0d 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp @@ -71,7 +71,7 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa ControlModel *controls = new ControlModel(m_playlist->generator(), this); - EchonestStation *station = new EchonestStation( m_proxyModel, m_playlist->generator(), this); + EchonestStation *station = new EchonestStation( m_proxyModel, m_playlist, this); rootContext()->setContextProperty( "echonestStation", station); rootContext()->setContextProperty( "controlModel", controls ); rootContext()->setContextProperty( "dynamicModel", m_proxyModel ); @@ -134,7 +134,6 @@ DynamicQmlWidget::jumpToCurrentTrack() void DynamicQmlWidget::currentItemChanged( const QPersistentModelIndex ¤tIndex ) { rootContext()->setContextProperty( "currentlyPlayedIndex", m_proxyModel->mapFromSource( currentIndex ).row() ); - m_playlist->generator()->fetchNext(); } void @@ -143,9 +142,6 @@ DynamicQmlWidget::tracksGenerated( const QList< query_ptr >& queries ) qDebug() << queries.count() << "tracks generated"; m_model->tracksGenerated( queries, queries.count() ); m_playlist->resolve(); - - // Ok... we have some intial stuff, switch to dynamic mode - //m_model->startOnDemand(); } void DynamicQmlWidget::nextTrackGenerated(const query_ptr &track)