mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-01 18:04:05 +02:00
rework StationCreator page2
make use of artistchartsmodel
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import QtQuick 1.1
|
||||
//import tomahawk 1.0
|
||||
//import "tomahawkimports"
|
||||
import "tomahawkimports"
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
@@ -10,13 +10,12 @@ Item {
|
||||
|
||||
signal itemClicked(int index)
|
||||
|
||||
Text {
|
||||
HeaderLabel {
|
||||
text: "Listen to radio..."
|
||||
color: "white"
|
||||
anchors {
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
margins: height * 2
|
||||
margins: defaultFontHeight * 2
|
||||
}
|
||||
}
|
||||
|
||||
|
44
data/qml/StationCreatorPage2.qml
Normal file
44
data/qml/StationCreatorPage2.qml
Normal 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()
|
||||
}
|
||||
}
|
@@ -10,9 +10,9 @@ Rectangle {
|
||||
|
||||
ListModel {
|
||||
id: modeModel
|
||||
ListElement { label: "By Artist"; image: "../images/artist-placeholder-grid.png"; creatorState: "artist" }
|
||||
ListElement { label: "By Genre"; image: "../images/album-placeholder-grid.png"; creatorState: "genre" }
|
||||
ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorState: "year" }
|
||||
ListElement { label: "By Artist"; image: "../images/artist-placeholder-grid.png"; creatorContent: "stations/CreateByArtist.qml" }
|
||||
ListElement { label: "By Genre"; image: "../images/album-placeholder-grid.png"; creatorContent: "genre" }
|
||||
ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorContent: "year" }
|
||||
}
|
||||
|
||||
ListModel {
|
||||
@@ -39,18 +39,6 @@ Rectangle {
|
||||
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 {
|
||||
id: stationVisualModel
|
||||
|
||||
@@ -60,12 +48,12 @@ Rectangle {
|
||||
model: modeModel
|
||||
|
||||
onItemClicked: {
|
||||
stationCreator.state = modeModel.get(index).creatorState
|
||||
stationCreator.content = modeModel.get(index).creatorContent
|
||||
stationListView.incrementCurrentIndex()
|
||||
}
|
||||
}
|
||||
|
||||
StationCreator {
|
||||
StationCreatorPage2 {
|
||||
id: stationCreator
|
||||
height: scene.height
|
||||
width: scene.width
|
||||
|
63
data/qml/stations/CreateByArtist.qml
Normal file
63
data/qml/stations/CreateByArtist.qml
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
data/qml/tomahawkimports/ArtistView.qml
Normal file
44
data/qml/tomahawkimports/ArtistView.qml
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
@@ -171,7 +171,7 @@ Item {
|
||||
Image {
|
||||
id: playButton
|
||||
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
|
||||
height: mirroredCover.height / 5
|
||||
width: height
|
7
data/qml/tomahawkimports/HeaderLabel.qml
Normal file
7
data/qml/tomahawkimports/HeaderLabel.qml
Normal file
@@ -0,0 +1,7 @@
|
||||
import QtQuick 1.1
|
||||
|
||||
Text {
|
||||
color: "white"
|
||||
font.pointSize: defaultFontSize + 5
|
||||
font.bold: true
|
||||
}
|
@@ -7,6 +7,9 @@ Rectangle {
|
||||
radius: height / 2
|
||||
color: buttonMouseArea.containsMouse ? "#22ffffff" : "black"
|
||||
|
||||
height: defaultFontHeight * 2
|
||||
width: height
|
||||
|
||||
property string text
|
||||
|
||||
signal clicked()
|
||||
|
@@ -164,7 +164,6 @@
|
||||
<file>data/images/delete.png</file>
|
||||
<file>data/images/ok.png</file>
|
||||
<file>data/qml/StationScene.qml</file>
|
||||
<file>data/qml/CoverImage.qml</file>
|
||||
<file>data/qml/TagCloud.qml</file>
|
||||
<file>data/qml/StationConfig.qml</file>
|
||||
<file>data/qml/StationView.qml</file>
|
||||
@@ -176,5 +175,10 @@
|
||||
<file>data/qml/StationCreator.qml</file>
|
||||
<file>data/qml/StationCreatorPage1.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>
|
||||
</RCC>
|
||||
|
@@ -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");
|
||||
|
||||
rootContext()->setContextProperty( "dynamicModel", m_proxyModel );
|
||||
rootContext()->setContextProperty( "artistChartsModel", m_artistChartsModel );
|
||||
rootContext()->setContextProperty( "generator", m_playlist->generator().data() );
|
||||
|
||||
setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) );
|
||||
@@ -238,11 +239,5 @@ DynamicQmlWidget::onArtistCharts( const QList< Tomahawk::artist_ptr >& artists )
|
||||
m_artistChartsModel->clear();
|
||||
m_artistChartsModel->appendArtists( artists );
|
||||
|
||||
int i = 0;
|
||||
foreach ( const artist_ptr& artist, artists )
|
||||
{
|
||||
tDebug() << "Found artist in chart:" << artist->name() << QString::number( ++i );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "DeclarativeView.h"
|
||||
#include "playlist/PlayableItem.h"
|
||||
#include "DeclarativeCoverArtProvider.h"
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
|
||||
#include <qdeclarative.h>
|
||||
#include <QDeclarativeEngine>
|
||||
@@ -35,13 +36,16 @@ DeclarativeView::DeclarativeView( QWidget *parent ):
|
||||
setResizeMode( QDeclarativeView::SizeRootObjectToView );
|
||||
|
||||
// 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
|
||||
engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider() );
|
||||
|
||||
// Register the view itself to make it easy to invoke the view's slots from QML
|
||||
rootContext()->setContextProperty( "mainView", this );
|
||||
|
||||
rootContext()->setContextProperty( "defaultFontSize", TomahawkUtils::defaultFontSize() );
|
||||
rootContext()->setContextProperty( "defaultFontHeight", TomahawkUtils::defaultFontHeight() );
|
||||
}
|
||||
|
||||
DeclarativeView::~DeclarativeView()
|
||||
|
@@ -35,6 +35,8 @@ class QAbstractItemModel;
|
||||
*
|
||||
* Set context properties:
|
||||
* - 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
|
||||
* in QML with the source url "image://albumart/<coverid>".
|
||||
|
Reference in New Issue
Block a user