1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 18:33:16 +02:00

hooked up TagCloud again

made the input fields works
This commit is contained in:
Michael Zanetti
2012-12-02 22:51:47 +01:00
parent 3f7f1df61f
commit af05ce243d
10 changed files with 134 additions and 46 deletions

View File

@@ -6,8 +6,8 @@ Item {
id: root id: root
property int margins: defaultFontHeight * 2 property int margins: defaultFontHeight * 2
property alias content: contentLoader.source property alias content: contentLoader.source
property bool nextEnabled: false
signal back() signal back()
signal next() signal next()
@@ -41,4 +41,18 @@ Item {
onClicked: root.back() onClicked: root.back()
} }
RoundedButton {
id: nextButton
text: ">"
height: defaultFontHeight * 4
visible: root.nextEnabled
anchors {
right: parent.right
bottom: parent.bottom
margins: root.margins
}
onClicked: root.next()
}
} }

View File

@@ -11,34 +11,10 @@ Rectangle {
ListModel { ListModel {
id: modeModel id: modeModel
ListElement { label: "By Artist"; image: "../images/artist-placeholder-grid.png"; creatorContent: "stations/CreateByArtist.qml" } 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 Genre"; image: "../images/album-placeholder-grid.png"; creatorContent: "stations/CreateByGenre.qml" }
ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorContent: "year" } ListElement { label: "By Year"; image: "image://albumart/foobar"; creatorContent: "year" }
} }
ListModel {
id: styleModel
ListElement { modelData: "acoustic" }
ListElement { modelData: "alternative" }
ListElement { modelData: "alternative rock" }
ListElement { modelData: "classic" }
ListElement { modelData: "folk" }
ListElement { modelData: "indie" }
ListElement { modelData: "pop" }
ListElement { modelData: "rock" }
ListElement { modelData: "hip-hop" }
ListElement { modelData: "punk" }
ListElement { modelData: "grunge" }
ListElement { modelData: "indie" }
ListElement { modelData: "electronic" }
ListElement { modelData: "country" }
ListElement { modelData: "jazz" }
ListElement { modelData: "psychodelic" }
ListElement { modelData: "soundtrack" }
ListElement { modelData: "reggae" }
ListElement { modelData: "house" }
ListElement { modelData: "drum and base" }
}
VisualItemModel { VisualItemModel {
id: stationVisualModel id: stationVisualModel
@@ -57,6 +33,7 @@ Rectangle {
id: stationCreator id: stationCreator
height: scene.height height: scene.height
width: scene.width width: scene.width
nextEnabled: rootView.configured
onBack: stationListView.decrementCurrentIndex() onBack: stationListView.decrementCurrentIndex()

View File

@@ -8,16 +8,9 @@ Item {
signal done() signal done()
ListModel { function createStation(artist) {
id: dummyArtistModel mainView.startStationFromArtist(artist)
ListElement { modelData: "Pink Floyd" } root.done()
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 { Column {
@@ -39,12 +32,16 @@ Item {
InputField { InputField {
id: artistInputField id: artistInputField
width: parent.width - createFromInputButton.width - parent.spacing width: parent.width - createFromInputButton.width - parent.spacing
onAccepted: createStation(text)
} }
RoundedButton { RoundedButton {
id: createFromInputButton id: createFromInputButton
text: ">" text: ">"
height: artistInputField.height height: artistInputField.height
enabled: artistInputField.text.length > 2
onClicked: createStation(artistInputField.text)
} }
} }
@@ -56,8 +53,7 @@ Item {
delegateHeight: defaultFontHeight * 6 delegateHeight: defaultFontHeight * 6
onItemClicked: { onItemClicked: {
mainView.startStationFromArtist(artistChartsModel.itemFromIndex(index).artistName) createStation(artistChartsModel.itemFromIndex(index).artistName);
root.done()
} }
} }
} }

View File

@@ -0,0 +1,86 @@
import QtQuick 1.1
import tomahawk 1.0
import "../tomahawkimports"
Item {
id: root
anchors.fill: parent
signal done()
function createStation(genre) {
mainView.startStationFromArtist(genre)
root.done()
}
ListModel {
id: styleModel
ListElement { modelData: "acoustic" }
ListElement { modelData: "alternative" }
ListElement { modelData: "alternative rock" }
ListElement { modelData: "classic" }
ListElement { modelData: "folk" }
ListElement { modelData: "indie" }
ListElement { modelData: "pop" }
ListElement { modelData: "rock" }
ListElement { modelData: "hip-hop" }
ListElement { modelData: "punk" }
ListElement { modelData: "grunge" }
ListElement { modelData: "indie" }
ListElement { modelData: "electronic" }
ListElement { modelData: "country" }
ListElement { modelData: "jazz" }
ListElement { modelData: "psychodelic" }
ListElement { modelData: "soundtrack" }
ListElement { modelData: "reggae" }
ListElement { modelData: "house" }
ListElement { modelData: "drum and base" }
}
Column {
id: upperColumn
anchors.fill: parent
anchors.bottomMargin: defaultFontHeight
spacing: defaultFontHeight
HeaderLabel {
id: headerText
text: "Create station by genre..."
}
Row {
width: defaultFontHeight * 30
height: artistInputField.height
spacing: defaultFontHeight
InputField {
id: genreInputField
width: parent.width - createFromInputButton.width - parent.spacing
onAccepted: createStation(text);
}
RoundedButton {
id: createFromInputButton
text: ">"
height: genreInputField.height
enabled: genreInputField.text.length > 2
onClicked: createStation(genreInputField.text)
}
}
Item {
height: parent.height - headerText.height - genreInputField.height
width: parent.width
TagCloud {
anchors.fill: parent
anchors.margins: parent.width / 6
model: styleModel
onTagClicked: {
root.createStation(tag);
}
}
}
}
}

View File

@@ -6,7 +6,7 @@ Rectangle {
border.color: "black" border.color: "black"
border.width: 2 border.width: 2
height: textInput.height + 4 height: textInput.height * 1.2
width: 300 width: 300
property alias text: textInput.text property alias text: textInput.text
@@ -15,7 +15,7 @@ Rectangle {
TextInput { TextInput {
id: textInput id: textInput
width: parent.width width: parent.width - defaultFontHeight
anchors.centerIn: parent anchors.centerIn: parent
onAccepted: root.accepted( text ); onAccepted: root.accepted( text );

View File

@@ -2,15 +2,17 @@ import QtQuick 1.1
import tomahawk 1.0 import tomahawk 1.0
Rectangle { Rectangle {
id: root
border.width: 4 border.width: 4
border.color: "white" border.color: enabled ? "white" : "grey"
radius: height / 2 radius: height / 2
color: buttonMouseArea.containsMouse ? "#22ffffff" : "black" color: (buttonMouseArea.containsMouse && enabled) ? "#22ffffff" : "black"
height: defaultFontHeight * 2 height: defaultFontHeight * 2
width: height width: height
property string text property string text
property bool enabled: true
signal clicked() signal clicked()
@@ -21,7 +23,7 @@ Rectangle {
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
text: parent.text text: parent.text
color: "white" color: root.border.color
font.pixelSize: parent.height * .75 font.pixelSize: parent.height * .75
font.bold: true font.bold: true
} }
@@ -29,6 +31,7 @@ Rectangle {
id: buttonMouseArea id: buttonMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
enabled: root.enabled
onClicked: parent.clicked() onClicked: parent.clicked()
} }
} }

View File

@@ -6,7 +6,7 @@ Item {
property variant model: 10 property variant model: 10
signal tagClicked( string item ) signal tagClicked( string tag )
function randomNumber(min, max) { function randomNumber(min, max) {
var date = new Date(); var date = new Date();

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/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>
<file>data/qml/tomahawkimports/InputField.qml</file> <file>data/qml/tomahawkimports/InputField.qml</file>
@@ -180,5 +179,7 @@
<file>data/qml/tomahawkimports/CoverImage.qml</file> <file>data/qml/tomahawkimports/CoverImage.qml</file>
<file>data/qml/tomahawkimports/ArtistView.qml</file> <file>data/qml/tomahawkimports/ArtistView.qml</file>
<file>data/qml/tomahawkimports/HeaderLabel.qml</file> <file>data/qml/tomahawkimports/HeaderLabel.qml</file>
<file>data/qml/stations/CreateByGenre.qml</file>
<file>data/qml/tomahawkimports/TagCloud.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -112,6 +112,11 @@ bool DynamicQmlWidget::loading()
return m_model->isLoading(); return m_model->isLoading();
} }
bool DynamicQmlWidget::configured()
{
return !m_playlist->generator()->controls().isEmpty();
}
void DynamicQmlWidget::playItem(int index) void DynamicQmlWidget::playItem(int index)
{ {
tDebug() << "playItem called for cover" << index; tDebug() << "playItem called for cover" << index;
@@ -125,7 +130,9 @@ void DynamicQmlWidget::pause()
void DynamicQmlWidget::startStationFromArtist(const QString &artist) void DynamicQmlWidget::startStationFromArtist(const QString &artist)
{ {
m_model->clear();
m_playlist->generator()->startFromArtist(Artist::get(artist)); m_playlist->generator()->startFromArtist(Artist::get(artist));
emit configuredChanged();
} }
void DynamicQmlWidget::startStationFromGenre(const QString &genre) void DynamicQmlWidget::startStationFromGenre(const QString &genre)
@@ -133,6 +140,7 @@ void DynamicQmlWidget::startStationFromGenre(const QString &genre)
tDebug() << "should start startion from genre" << genre; tDebug() << "should start startion from genre" << genre;
m_model->clear(); m_model->clear();
m_playlist->generator()->startFromGenre( genre ); m_playlist->generator()->startFromGenre( genre );
emit configuredChanged();
} }
void DynamicQmlWidget::currentIndexChanged( const QPersistentModelIndex &currentIndex ) void DynamicQmlWidget::currentIndexChanged( const QPersistentModelIndex &currentIndex )

View File

@@ -39,6 +39,7 @@ class DynamicQmlWidget : public DeclarativeView, public Tomahawk::ViewPage
Q_PROPERTY(QString title READ title) Q_PROPERTY(QString title READ title)
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
Q_PROPERTY(bool configured READ configured NOTIFY configuredChanged)
public: public:
explicit DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0 ); explicit DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* parent = 0 );
@@ -60,9 +61,11 @@ public:
playlist_ptr playlist() const; playlist_ptr playlist() const;
bool loading(); bool loading();
bool configured();
signals: signals:
void loadingChanged(); void loadingChanged();
void configuredChanged();
public slots: public slots:
void playItem(int index); void playItem(int index);