diff --git a/data/qml/CoverImage.qml b/data/qml/CoverImage.qml
index c6da8b7f3..587171619 100644
--- a/data/qml/CoverImage.qml
+++ b/data/qml/CoverImage.qml
@@ -137,7 +137,7 @@ Item {
id: itemShadow
color: backgroundColor
anchors.fill: parent
- anchors.bottomMargin: - parent.height
+ //anchors.bottomMargin: - parent.height
// scaling might be off a pixel... make sure that the shadow is at least as large as the image
anchors.leftMargin: -2
@@ -158,6 +158,7 @@ Item {
width: parent.width + 4
anchors.centerIn: parent
anchors.verticalCenterOffset: parent.height
+ visible: showMirror
gradient: Gradient {
// TODO: no clue how to get the RGB component of the container rectangle color
diff --git a/data/qml/GridView.qml b/data/qml/GridView.qml
new file mode 100644
index 000000000..a1a4e7508
--- /dev/null
+++ b/data/qml/GridView.qml
@@ -0,0 +1,54 @@
+import QtQuick 1.1
+//import tomahawk 1.0
+//import "tomahawkimports"
+
+Rectangle {
+ anchors.fill: parent
+ color: "black"
+
+ Text {
+ id: fontMetrics
+ text: "Here's some sample text"
+ opacity: 0
+ }
+
+ GridView {
+ id: gridView
+ anchors.fill: parent
+
+ cellHeight: cellWidth
+ cellWidth: calculateCoverSize(gridView.width - 3)
+
+ function calculateCoverSize(rectWidth) {
+ var itemWidth = fontMetrics.width;
+ var itemsPerRow = Math.max( 1, Math.floor( rectWidth / itemWidth ) );
+
+ var remSpace = rectWidth - ( itemsPerRow * itemWidth );
+ var extraSpace = remSpace / itemsPerRow;
+ return itemWidth + extraSpace;
+
+ }
+
+ model: mainModel
+
+ delegate: CoverImage {
+ height: gridView.cellHeight// * 0.95
+ width: gridView.cellWidth// * 0.95
+
+ showLabels: true
+ showMirror: false
+ artistName: model.artistName
+ trackName: model.trackName
+ artworkId: model.coverID
+ showPlayButton: true
+ currentlyPlaying: isPlaying
+
+ onClicked: {
+ rootView.onItemClicked(index)
+ }
+ onPlayClicked: {
+ rootView.onItemPlayClicked(index)
+ }
+ }
+ }
+}
diff --git a/resources.qrc b/resources.qrc
index 08c1ed37f..86bfefb5a 100644
--- a/resources.qrc
+++ b/resources.qrc
@@ -175,5 +175,6 @@
data/qml/tomahawkimports/RoundedButton.qml
data/qml/StationCreator.qml
data/qml/StationCreatorPage1.qml
+ data/qml/GridView.qml
diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt
index 47e0d2e64..4586c9b89 100644
--- a/src/libtomahawk/CMakeLists.txt
+++ b/src/libtomahawk/CMakeLists.txt
@@ -72,6 +72,7 @@ set( libGuiSources
playlist/AlbumModel.cpp
playlist/GridItemDelegate.cpp
playlist/GridView.cpp
+ playlist/QmlGridView.cpp
playlist/TreeView.cpp
playlist/ViewHeader.cpp
playlist/LovedTracksModel.cpp
diff --git a/src/libtomahawk/ViewManager.cpp b/src/libtomahawk/ViewManager.cpp
index 52430a785..f6d4da347 100644
--- a/src/libtomahawk/ViewManager.cpp
+++ b/src/libtomahawk/ViewManager.cpp
@@ -31,7 +31,6 @@
#include "playlist/PlayableProxyModel.h"
#include "playlist/PlayableModel.h"
#include "playlist/TreeView.h"
-#include "playlist/GridView.h"
#include "playlist/AlbumModel.h"
#include "SourceList.h"
#include "TomahawkSettings.h"
diff --git a/src/libtomahawk/playlist/QmlGridView.cpp b/src/libtomahawk/playlist/QmlGridView.cpp
new file mode 100644
index 000000000..6860224e3
--- /dev/null
+++ b/src/libtomahawk/playlist/QmlGridView.cpp
@@ -0,0 +1,107 @@
+#include "QmlGridView.h"
+#include "widgets/DeclarativeCoverArtProvider.h"
+#include "PlayableProxyModelPlaylistInterface.h"
+#include "ViewManager.h"
+#include "audio/AudioEngine.h"
+
+#include
+#include
+
+using namespace Tomahawk;
+
+class QmlGridPlaylistInterface : public PlayableProxyModelPlaylistInterface
+{
+ Q_OBJECT
+public:
+ explicit QmlGridPlaylistInterface( PlayableProxyModel* proxy, QmlGridView* view ) : PlayableProxyModelPlaylistInterface( proxy ), m_view( view ) {}
+
+ virtual bool hasChildInterface( playlistinterface_ptr playlistInterface )
+ {
+// if ( m_view.isNull() || !m_view.data()->m_playing.isValid() )
+// {
+// return false;
+// }
+
+// PlayableItem* item = m_view.data()->model()->itemFromIndex( m_view.data()->proxyModel()->mapToSource( m_view.data()->m_playing ) );
+// if ( item )
+// {
+// if ( !item->album().isNull() )
+// return item->album()->playlistInterface( Tomahawk::Mixed ) == playlistInterface;
+// else if ( !item->artist().isNull() )
+// return item->artist()->playlistInterface( Tomahawk::Mixed ) == playlistInterface;
+// else if ( !item->query().isNull() && !playlistInterface.dynamicCast< SingleTrackPlaylistInterface >().isNull() )
+// return item->query() == playlistInterface.dynamicCast< SingleTrackPlaylistInterface >()->track();
+// }
+
+ return false;
+ }
+private:
+ QWeakPointer m_view;
+};
+
+QmlGridView::QmlGridView(QWidget *parent) : QDeclarativeView(parent)
+{
+ m_proxyModel = new PlayableProxyModel( this );
+ m_playlistInterface = playlistinterface_ptr( new QmlGridPlaylistInterface( m_proxyModel, this ) );
+
+ setResizeMode( QDeclarativeView::SizeRootObjectToView );
+
+ // QML image providers will be deleted by the view
+ engine()->addImageProvider( "albumart", new DeclarativeCoverArtProvider( m_proxyModel ) );
+
+ rootContext()->setContextProperty( "mainModel", m_proxyModel );
+ rootContext()->setContextProperty( "rootView", this );
+ setSource( QUrl( "qrc" RESPATH "qml/GridView.qml" ) );
+
+}
+
+QmlGridView::~QmlGridView()
+{
+
+}
+
+void QmlGridView::setPlayableModel(PlayableModel *model)
+{
+// m_inited = false;
+ m_model = model;
+
+ if ( m_proxyModel )
+ {
+ m_proxyModel->setSourcePlayableModel( m_model );
+ m_proxyModel->sort( 0 );
+ }
+
+ emit modelChanged();
+
+}
+
+
+void
+QmlGridView::onItemClicked( int index )
+{
+ PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( m_proxyModel->index( index, 0) ) );
+ if ( item )
+ {
+ if ( !item->album().isNull() )
+ ViewManager::instance()->show( item->album() );
+ else if ( !item->artist().isNull() )
+ ViewManager::instance()->show( item->artist() );
+ else if ( !item->query().isNull() )
+ ViewManager::instance()->show( item->query() );
+ }
+}
+
+void QmlGridView::onItemPlayClicked(int index)
+{
+ PlayableItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( m_proxyModel->index( index, 0) ) );
+ if ( item )
+ {
+ if ( !item->query().isNull() )
+ AudioEngine::instance()->playItem( Tomahawk::playlistinterface_ptr(), item->query() );
+ else if ( !item->album().isNull() )
+ AudioEngine::instance()->playItem( item->album() );
+ else if ( !item->artist().isNull() )
+ AudioEngine::instance()->playItem( item->artist() );
+ }
+}
+#include "QmlGridView.moc"
diff --git a/src/libtomahawk/playlist/QmlGridView.h b/src/libtomahawk/playlist/QmlGridView.h
new file mode 100644
index 000000000..0b05cc75a
--- /dev/null
+++ b/src/libtomahawk/playlist/QmlGridView.h
@@ -0,0 +1,73 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2010-2011, Christian Muehlhaeuser
+ * Copyright 2010-2012, Jeff Mitchell
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef QMLGRIDVIEW_H
+#define QMLGRIDVIEW_H
+
+#include
+#include
+#include
+
+#include "ViewPage.h"
+#include "PlayableProxyModel.h"
+#include "widgets/OverlayWidget.h"
+#include "DllMacro.h"
+
+namespace Tomahawk
+{
+ class ContextMenu;
+};
+
+class AnimatedSpinner;
+class GridItemDelegate;
+class PlayableModel;
+class GridPlaylistInterface;
+
+class DLLEXPORT QmlGridView : public QDeclarativeView, public Tomahawk::ViewPage
+{
+Q_OBJECT
+public:
+ QmlGridView( QWidget *parent = 0);
+ ~QmlGridView();
+
+ void setPlayableModel( PlayableModel* model );
+// void setModel( QAbstractItemModel* model );
+ PlayableProxyModel* proxyModel() const { return m_proxyModel; }
+
+
+ QWidget *widget() { return this; }
+ virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return m_playlistInterface; }
+ virtual QString title() const { return m_model->title(); }
+ virtual QString description() const { return m_model->description(); }
+ virtual bool jumpToCurrentTrack() { return false; }
+
+ Q_INVOKABLE void onItemClicked( int index );
+ Q_INVOKABLE void onItemPlayClicked( int index );
+
+private:
+ PlayableModel* m_model;
+ PlayableProxyModel* m_proxyModel;
+ Tomahawk::playlistinterface_ptr m_playlistInterface;
+
+signals:
+ void modelChanged();
+
+};
+
+#endif
diff --git a/src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp b/src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp
index 68acbcd28..1ee55abbb 100644
--- a/src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp
+++ b/src/libtomahawk/widgets/DeclarativeCoverArtProvider.cpp
@@ -26,6 +26,7 @@ DeclarativeCoverArtProvider::~DeclarativeCoverArtProvider()
QPixmap DeclarativeCoverArtProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
+ tDebug() << "requresting albumart" << id;
// We always can generate it in the requested size
int width = requestedSize.width() > 0 ? requestedSize.width() : 230;
int height = requestedSize.height() > 0 ? requestedSize.height() : 230;
diff --git a/src/libtomahawk/widgets/WelcomeWidget.ui b/src/libtomahawk/widgets/WelcomeWidget.ui
index f420a1a96..18570ca9d 100644
--- a/src/libtomahawk/widgets/WelcomeWidget.ui
+++ b/src/libtomahawk/widgets/WelcomeWidget.ui
@@ -36,14 +36,7 @@
-
-
-
- true
-
-
- QAbstractItemView::ExtendedSelection
-
-
+
@@ -87,9 +80,9 @@
- GridView
+ QmlGridView
QListView
-
+
PlaylistView