1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-01 09:53:57 +02:00

rework StationCreator page2

make use of artistchartsmodel
This commit is contained in:
Michael Zanetti
2012-12-02 21:11:57 +01:00
parent 25a9d21e8f
commit 73b5e977c8
13 changed files with 183 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
import QtQuick 1.1 import QtQuick 1.1
//import tomahawk 1.0 //import tomahawk 1.0
//import "tomahawkimports" import "tomahawkimports"
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent

View File

@@ -10,13 +10,12 @@ Item {
signal itemClicked(int index) signal itemClicked(int index)
Text { HeaderLabel {
text: "Listen to radio..." text: "Listen to radio..."
color: "white"
anchors { anchors {
left: parent.left left: parent.left
top: parent.top top: parent.top
margins: height * 2 margins: defaultFontHeight * 2
} }
} }

View File

@@ -0,0 +1,44 @@
import QtQuick 1.1
import tomahawk 1.0
import "tomahawkimports"
Item {
id: root
property int margins: defaultFontHeight * 2
property alias content: contentLoader.source
signal back()
signal next()
Loader {
id: contentLoader
anchors {
left: parent.left
top: parent.top
right: parent.right
bottom: backButton.top
margins: root.margins
}
}
Connections {
target: contentLoader.item
onDone: root.next()
}
RoundedButton {
id: backButton
text: "<"
height: defaultFontHeight * 4
anchors {
left:parent.left
bottom: parent.bottom
margins: root.margins
}
onClicked: root.back()
}
}

View File

@@ -10,9 +10,9 @@ Rectangle {
ListModel { ListModel {
id: modeModel id: modeModel
ListElement { label: "By Artist"; image: "../images/artist-placeholder-grid.png"; creatorState: "artist" } ListElement { label: "By Artist"; image: "../images/artist-placeholder-grid.png"; creatorContent: "stations/CreateByArtist.qml" }
ListElement { label: "By Genre"; image: "../images/album-placeholder-grid.png"; creatorState: "genre" } ListElement { label: "By Genre"; image: "../images/album-placeholder-grid.png"; creatorContent: "genre" }
ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorState: "year" } ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorContent: "year" }
} }
ListModel { ListModel {
@@ -39,18 +39,6 @@ Rectangle {
ListElement { modelData: "drum and base" } ListElement { modelData: "drum and base" }
} }
ListModel {
id: dummyArtistModel
ListElement { modelData: "Pink Floyd" }
ListElement { modelData: "Tool" }
ListElement { modelData: "Cake" }
ListElement { modelData: "Metallica" }
ListElement { modelData: "Red Hot Chili Peppers" }
ListElement { modelData: "Korn" }
ListElement { modelData: "Prodigy" }
ListElement { modelData: "Otto Waalkes" }
}
VisualItemModel { VisualItemModel {
id: stationVisualModel id: stationVisualModel
@@ -60,12 +48,12 @@ Rectangle {
model: modeModel model: modeModel
onItemClicked: { onItemClicked: {
stationCreator.state = modeModel.get(index).creatorState stationCreator.content = modeModel.get(index).creatorContent
stationListView.incrementCurrentIndex() stationListView.incrementCurrentIndex()
} }
} }
StationCreator { StationCreatorPage2 {
id: stationCreator id: stationCreator
height: scene.height height: scene.height
width: scene.width width: scene.width

View File

@@ -0,0 +1,63 @@
import QtQuick 1.1
import tomahawk 1.0
import "../tomahawkimports"
Item {
id: root
anchors.fill: parent
signal done()
ListModel {
id: dummyArtistModel
ListElement { modelData: "Pink Floyd" }
ListElement { modelData: "Tool" }
ListElement { modelData: "Cake" }
ListElement { modelData: "Metallica" }
ListElement { modelData: "Red Hot Chili Peppers" }
ListElement { modelData: "Korn" }
ListElement { modelData: "Prodigy" }
ListElement { modelData: "Otto Waalkes" }
}
Column {
id: upperColumn
anchors.fill: parent
anchors.bottomMargin: defaultFontHeight
spacing: defaultFontHeight
HeaderLabel {
id: headerText
text: "Create station by artist..."
}
Row {
width: defaultFontHeight * 15
height: artistInputField.height
spacing: defaultFontHeight
InputField {
id: artistInputField
width: parent.width - createFromInputButton.width - parent.spacing
}
RoundedButton {
id: createFromInputButton
text: ">"
height: artistInputField.height
}
}
ArtistView {
height: parent.height - headerText.height - artistInputField.height
width: defaultFontHeight * 15
model: artistChartsModel
clip: true
onItemClicked: {
mainView.startStationFromArtist(artistChartsModel.itemFromIndex(index).artistName)
root.done()
}
}
}
}

View File

@@ -0,0 +1,44 @@
import QtQuick 1.1
import tomahawk 1.0
ListView {
id: root
signal itemClicked(int index)
delegate: Item {
width: parent.width
height: defaultFontHeight * 3
Rectangle {
anchors.fill: parent
radius: defaultFontHeight / 2
gradient: Gradient {
GradientStop { position: 0.0; color: "#00FFFFFF" }
GradientStop { position: 1.0; color: "#55FFFFFF" }
}
}
Row {
anchors.fill: parent
spacing: defaultFontHeight
CoverImage {
height: parent.height
width: height
showLabels: false
artworkId: model.coverID
}
Text {
text: model.artistName
color: "white"
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
anchors.fill: parent
onClicked: root.itemClicked(index)
}
}
}

View File

@@ -171,7 +171,7 @@ Item {
Image { Image {
id: playButton id: playButton
visible: showPlayButton ? (mouseArea.containsMouse || currentlyPlaying) : false visible: showPlayButton ? (mouseArea.containsMouse || currentlyPlaying) : false
source: currentlyPlaying ? "../images/pause-rest.png" : "../images/play-rest.png" source: currentlyPlaying ? "../../images/pause-rest.png" : "../../images/play-rest.png"
anchors.centerIn: parent anchors.centerIn: parent
height: mirroredCover.height / 5 height: mirroredCover.height / 5
width: height width: height

View File

@@ -0,0 +1,7 @@
import QtQuick 1.1
Text {
color: "white"
font.pointSize: defaultFontSize + 5
font.bold: true
}

View File

@@ -7,6 +7,9 @@ Rectangle {
radius: height / 2 radius: height / 2
color: buttonMouseArea.containsMouse ? "#22ffffff" : "black" color: buttonMouseArea.containsMouse ? "#22ffffff" : "black"
height: defaultFontHeight * 2
width: height
property string text property string text
signal clicked() signal clicked()

View File

@@ -164,7 +164,6 @@
<file>data/images/delete.png</file> <file>data/images/delete.png</file>
<file>data/images/ok.png</file> <file>data/images/ok.png</file>
<file>data/qml/StationScene.qml</file> <file>data/qml/StationScene.qml</file>
<file>data/qml/CoverImage.qml</file>
<file>data/qml/TagCloud.qml</file> <file>data/qml/TagCloud.qml</file>
<file>data/qml/StationConfig.qml</file> <file>data/qml/StationConfig.qml</file>
<file>data/qml/StationView.qml</file> <file>data/qml/StationView.qml</file>
@@ -176,5 +175,10 @@
<file>data/qml/StationCreator.qml</file> <file>data/qml/StationCreator.qml</file>
<file>data/qml/StationCreatorPage1.qml</file> <file>data/qml/StationCreatorPage1.qml</file>
<file>data/qml/GridView.qml</file> <file>data/qml/GridView.qml</file>
<file>data/qml/StationCreatorPage2.qml</file>
<file>data/qml/stations/CreateByArtist.qml</file>
<file>data/qml/tomahawkimports/CoverImage.qml</file>
<file>data/qml/tomahawkimports/ArtistView.qml</file>
<file>data/qml/tomahawkimports/HeaderLabel.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -42,6 +42,7 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa
qmlRegisterUncreatableType<GeneratorInterface>("tomahawk", 1, 0, "Generator", "you cannot create it on your own - should be set in context"); qmlRegisterUncreatableType<GeneratorInterface>("tomahawk", 1, 0, "Generator", "you cannot create it on your own - should be set in context");
rootContext()->setContextProperty( "dynamicModel", m_proxyModel ); rootContext()->setContextProperty( "dynamicModel", m_proxyModel );
rootContext()->setContextProperty( "artistChartsModel", m_artistChartsModel );
rootContext()->setContextProperty( "generator", m_playlist->generator().data() ); rootContext()->setContextProperty( "generator", m_playlist->generator().data() );
setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) ); setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
@@ -238,11 +239,5 @@ DynamicQmlWidget::onArtistCharts( const QList< Tomahawk::artist_ptr >& artists )
m_artistChartsModel->clear(); m_artistChartsModel->clear();
m_artistChartsModel->appendArtists( artists ); m_artistChartsModel->appendArtists( artists );
int i = 0;
foreach ( const artist_ptr& artist, artists )
{
tDebug() << "Found artist in chart:" << artist->name() << QString::number( ++i );
}
} }
} }

View File

@@ -19,6 +19,7 @@
#include "DeclarativeView.h" #include "DeclarativeView.h"
#include "playlist/PlayableItem.h" #include "playlist/PlayableItem.h"
#include "DeclarativeCoverArtProvider.h" #include "DeclarativeCoverArtProvider.h"
#include "utils/TomahawkUtilsGui.h"
#include <qdeclarative.h> #include <qdeclarative.h>
#include <QDeclarativeEngine> #include <QDeclarativeEngine>
@@ -35,13 +36,16 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
setResizeMode( QDeclarativeView::SizeRootObjectToView ); setResizeMode( QDeclarativeView::SizeRootObjectToView );
// This types seem to be needed everywhere anyways, lets the register here // This types seem to be needed everywhere anyways, lets the register here
qmlRegisterUncreatableType<PlayableItem>( "tomahawk", 1, 0, "PlayableItem", "bla" ); qmlRegisterType<PlayableItem>( "tomahawk", 1, 0, "PlayableItem");
// QML image providers will be deleted by the view // QML image providers will be deleted by the view
engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() ); engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() );
// Register the view itself to make it easy to invoke the view's slots from QML // Register the view itself to make it easy to invoke the view's slots from QML
rootContext()->setContextProperty( "mainView", this ); rootContext()->setContextProperty( "mainView", this );
rootContext()->setContextProperty( "defaultFontSize", TomahawkUtils::defaultFontSize() );
rootContext()->setContextProperty( "defaultFontHeight", TomahawkUtils::defaultFontHeight() );
} }
DeclarativeView::~DeclarativeView() DeclarativeView::~DeclarativeView()

View File

@@ -35,6 +35,8 @@ class QAbstractItemModel;
* *
* Set context properties: * Set context properties:
* - mainView: This view, so you can invoke this view's slots from QML * - mainView: This view, so you can invoke this view's slots from QML
* - defaultFontSize: system default font point size
* - defaultFontHeight: system default font pixel height
* *
* It also registers an albumart image provider. You can access album art * It also registers an albumart image provider. You can access album art
* in QML with the source url "image://albumart/<coverid>". * in QML with the source url "image://albumart/<coverid>".