1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-31 17:42:13 +02:00

Say hello to DeclarativeHeader

This commit is contained in:
Michael Zanetti
2012-12-16 00:19:51 +01:00
parent 21c494ba91
commit 74d375bc50
35 changed files with 465 additions and 385 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="38px" height="38px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<title>view-toggle-pressed-left</title>
<title>view-toggle-pressed-right</title>
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
<defs>
<radialGradient cx="50%" cy="50%" fx="50%" fy="50%" r="57.2162807%" id="radialGradient-1">
@@ -9,6 +9,6 @@
</radialGradient>
</defs>
<g id="Page 1" fill="rgb(215,215,215)" fill-rule="evenodd">
<path d="M0,0 L0,38 L29.9992049,38 C34.417922,38 38,34.4250523 38,29.9992049 L38,8.00079513 C38,3.582078 34.4250523,0 29.9992049,0 L0,0 Z M0,0" id="Rectangle 1" stroke="rgb(150,150,150)" stroke-width="1" fill="url(#radialGradient-1)"></path>
<path d="M8.00079513,0 C3.582078,0 0,3.57494774 0,8.00079513 L0,29.9992049 C0,34.417922 3.57494774,38 8.00079513,38 L38,38 L38,0 L8.00079513,0 Z M8.00079513,0" id="Rectangle 1" stroke="rgb(150,150,150)" stroke-width="1" fill="url(#radialGradient-1)"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 975 B

After

Width:  |  Height:  |  Size: 992 B

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="38px" height="38px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<title>view-toggle-pressed-right</title>
<title>view-toggle-pressed-left</title>
<description>Created with Sketch (http://www.bohemiancoding.com/sketch)</description>
<defs>
<radialGradient cx="50%" cy="50%" fx="50%" fy="50%" r="57.2162807%" id="radialGradient-1">
@@ -9,6 +9,6 @@
</radialGradient>
</defs>
<g id="Page 1" fill="rgb(215,215,215)" fill-rule="evenodd">
<path d="M8.00079513,0 C3.582078,0 0,3.57494774 0,8.00079513 L0,29.9992049 C0,34.417922 3.57494774,38 8.00079513,38 L38,38 L38,0 L8.00079513,0 Z M8.00079513,0" id="Rectangle 1" stroke="rgb(150,150,150)" stroke-width="1" fill="url(#radialGradient-1)"></path>
<path d="M0,0 L0,38 L29.9992049,38 C34.417922,38 38,34.4250523 38,29.9992049 L38,8.00079513 C38,3.582078 34.4250523,0 29.9992049,0 L0,0 Z M0,0" id="Rectangle 1" stroke="rgb(150,150,150)" stroke-width="1" fill="url(#radialGradient-1)"></path>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 992 B

After

Width:  |  Height:  |  Size: 975 B

View File

@@ -0,0 +1,122 @@
import QtQuick 1.1
import tomahawk 1.0
Rectangle {
id: root
anchors.fill: parent
property bool showSearchField: true
property int spacing: defaultFontHeight / 2
gradient: Gradient {
GradientStop { position: 0.0; color: "#615858" }
GradientStop { position: 1.0; color: "#231F1F" }
}
Row {
anchors.fill: parent
anchors.margins: root.spacing
spacing: root.spacing
Image {
id: iconImage
source: iconSource
height: parent.height * 0.8
width: height
anchors.verticalCenter: parent.verticalCenter
}
Column {
height: parent.height
width: parent.width - iconImage.width - toggleViewButtons.width - searchField.width - parent.spacing * 5
Item {
id: titleItem
height: captionText1.height
width: parent.width
clip: true
property string titleText: caption
onTitleTextChanged: {
if(captionText1.text.length > 0) {
captionText2.text = caption;
renewTitleAnimation.start();
} else {
captionText1.text = titleText;
}
}
ParallelAnimation {
id: renewTitleAnimation
property int duration: 500
property variant easingType: Easing.OutBounce;
NumberAnimation { target: captionText2; property: "anchors.topMargin"; to: 0; duration: renewTitleAnimation.duration; easing.type: renewTitleAnimation.easingType }
NumberAnimation { target: captionText1; property: "anchors.topMargin"; to: captionText1.height * 2; duration: renewTitleAnimation.duration; easing.type: renewTitleAnimation.easingType }
onCompleted: {
captionText1.text = titleItem.titleText
captionText2.anchors.topMargin = -captionText2.height * 2
captionText1.anchors.topMargin = 0
}
}
Text {
id: captionText1
color: "white"
anchors.left: parent.left
anchors.top: parent.top
font.pointSize: defaultFontSize + 4
font.bold: true
width: parent.width
elide: Text.ElideRight
}
Text {
id: captionText2
color: "white"
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: -height * 2
font.pointSize: defaultFontSize + 4
font.bold: true
width: parent.width
elide: Text.ElideRight
}
}
Text {
text: description
color: "white"
font.pointSize: defaultFontSize + 1
width: parent.width
elide: Text.ElideRight
}
}
ToggleViewButtons {
id: toggleViewButtons
anchors.verticalCenter: parent.verticalCenter
height: defaultFontHeight * 1.5
model: toggleViewButtonModel
onCurrentIndexChanged: mainView.viewModeSelected(currentIndex)
}
SearchField {
id: searchField
opacity: root.showSearchField ? 1 : 0
anchors {
right: parent.right
verticalCenter: parent.verticalCenter
rightMargin: root.spacing
}
onTextChanged: mainView.setFilterText(text)
}
}
}

View File

@@ -0,0 +1,34 @@
import QtQuick 1.1
import tomahawk 1.0
Row {
id: root
width: repeater.width
property alias model: repeater.model
property int currentIndex: 0
Repeater {
id: repeater
height: root.height
width: count * height
delegate: Image {
height: repeater.height
width: height
source: "../../images/view-toggle-" + (index === root.currentIndex ? "pressed-" : "inactive-" ) + (index === 0 ? "left" : ( index === repeater.count - 1 ? "right" : "centre" )) + ".svg"
smooth: true
Image {
anchors.fill: parent
source: "../../images/" + modelData + (index === root.currentIndex ? "-active.svg" : "-inactive.svg")
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: root.currentIndex = index
}
}
}
}

View File

@@ -35,21 +35,21 @@
<file>data/images/skip-pressed.svg</file>
<file>data/images/skip-rest.svg</file>
<file>data/images/user-avatar.svg</file>
<file>data/images/view-toggle-active-centre.png</file>
<file>data/images/view-toggle-active-left.png</file>
<file>data/images/view-toggle-active-right.png</file>
<file>data/images/view-toggle-active-centre.svg</file>
<file>data/images/view-toggle-active-left.svg</file>
<file>data/images/view-toggle-active-right.svg</file>
<file>data/images/view-toggle-icon-artist-active.svg</file>
<file>data/images/view-toggle-icon-artist-inactive.svg</file>
<file>data/images/view-toggle-icon-grid-active.svg</file>
<file>data/images/view-toggle-icon-grid-inactive.svg</file>
<file>data/images/view-toggle-icon-list-active.svg</file>
<file>data/images/view-toggle-icon-list-inactive.svg</file>
<file>data/images/view-toggle-inactive-centre.png</file>
<file>data/images/view-toggle-inactive-left.png</file>
<file>data/images/view-toggle-inactive-right.png</file>
<file>data/images/view-toggle-pressed-centre.png</file>
<file>data/images/view-toggle-pressed-left.png</file>
<file>data/images/view-toggle-pressed-right.png</file>
<file>data/images/view-toggle-inactive-centre.svg</file>
<file>data/images/view-toggle-inactive-left.svg</file>
<file>data/images/view-toggle-inactive-right.svg</file>
<file>data/images/view-toggle-pressed-centre.svg</file>
<file>data/images/view-toggle-pressed-left.svg</file>
<file>data/images/view-toggle-pressed-right.svg</file>
<file>data/images/list-add.svg</file>
<file>data/images/list-remove.svg</file>
<file>data/images/arrow-up-double.svg</file>
@@ -166,5 +166,7 @@
<file>data/images/cancel.svg</file>
<file>data/images/delete.svg</file>
<file>data/images/ok.svg</file>
<file>data/qml/tomahawkimports/FlexibleHeader.qml</file>
<file>data/qml/tomahawkimports/ToggleViewButtons.qml</file>
</qresource>
</RCC>

View File

@@ -55,7 +55,6 @@ set( libGuiSources
infobar/InfoBar.cpp
playlist/FlexibleHeader.cpp
playlist/FlexibleView.cpp
playlist/TreeModel.cpp
playlist/TreeProxyModel.cpp
@@ -124,6 +123,7 @@ set( libGuiSources
widgets/AnimatedCounterLabel.cpp
widgets/BasicHeader.cpp
widgets/DeclarativeHeader.cpp
widgets/Breadcrumb.cpp
widgets/BreadcrumbButton.cpp
widgets/CheckDirTree.cpp

View File

@@ -137,7 +137,7 @@ ViewManager::createPageForPlaylist( const playlist_ptr& playlist )
PlaylistView* pv = new PlaylistView();
view->setDetailedView( pv );
view->setPixmap( pv->pixmap() );
view->setHeaderIconSource( pv->iconSource() );
view->setEmptyTip( tr( "This playlist is empty!" ) );
// We need to set the model on the view before loading the playlist, so spinners & co are connected
@@ -392,7 +392,7 @@ ViewManager::showRecentPlaysPage()
if ( !m_recentPlaysWidget )
{
FlexibleView* pv = new FlexibleView( m_widget );
pv->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RecentlyPlayed ) );
pv->setHeaderIconSource( TomahawkUtils::defaultImagePath( TomahawkUtils::RecentlyPlayed ) );
RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv );
raModel->setTitle( tr( "Recently Played Tracks" ) );
@@ -568,8 +568,8 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
if( obj->metaObject()->indexOfSignal( "nameChanged(QString)" ) > -1 )
connect( obj, SIGNAL( nameChanged( QString ) ), m_infobar, SLOT( setCaption( QString ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "pixmapChanged(QPixmap)" ) > -1 )
connect( obj, SIGNAL( pixmapChanged( QPixmap ) ), m_infobar, SLOT( setPixmap( QPixmap ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "iconSourceChanged(QString)" ) > -1 )
connect( obj, SIGNAL( iconSourceChanged( QString ) ), m_infobar, SLOT( setPixmap( QPixmap ) ), Qt::UniqueConnection );
if( obj->metaObject()->indexOfSignal( "destroyed(QWidget*)" ) > -1 )
connect( obj, SIGNAL( destroyed( QWidget* ) ), SLOT( onWidgetDestroyed( QWidget* ) ), Qt::UniqueConnection );
@@ -646,7 +646,7 @@ ViewManager::updateView()
}
m_infobar->setLongDescription( currentPage()->longDescription() );
m_infobar->setPixmap( currentPage()->pixmap() );
m_infobar->setIconSource( currentPage()->iconSource() );
}

View File

@@ -56,7 +56,7 @@ public:
virtual Tomahawk::album_ptr descriptionAlbum() const { return Tomahawk::album_ptr(); }
virtual QString longDescription() const { return QString(); }
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
virtual QString iconSource() const { return QLatin1String(RESPATH "icons/tomahawk-icon.svg"); }
virtual bool showInfoBar() const { return true; }
virtual bool showFilter() const { return false; }

View File

@@ -184,9 +184,9 @@ InfoBar::setLongDescription( const QString& s )
void
InfoBar::setPixmap( const QPixmap& p )
InfoBar::setIconSource( const QString& iconSource )
{
ui->imageLabel->setPixmap( p.scaledToHeight( IMAGE_HEIGHT, Qt::SmoothTransformation ) );
ui->imageLabel->setPixmap( QPixmap( iconSource ).scaledToHeight( IMAGE_HEIGHT, Qt::SmoothTransformation ) );
}

View File

@@ -58,7 +58,7 @@ public slots:
void setDescription( const Tomahawk::album_ptr& album_ptr );
void setLongDescription( const QString& s );
void setPixmap( const QPixmap& p );
void setIconSource( const QString& iconSource );
void setFilter( const QString& filter );
void setFilterAvailable( bool b );

View File

@@ -1,145 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "FlexibleHeader.h"
#include <QBoxLayout>
#include <QLabel>
#include <QPixmap>
#include <QCheckBox>
#include <QPaintEvent>
#include <QPainter>
#include <QRadioButton>
#include "playlist/FlexibleView.h"
#include "ViewManager.h"
#include "thirdparty/Qocoa/qsearchfield.h"
#include "utils/Closure.h"
#include "utils/TomahawkUtilsGui.h"
#include "utils/Logger.h"
#include "widgets/QueryLabel.h"
#include "Source.h"
using namespace Tomahawk;
FlexibleHeader::FlexibleHeader( FlexibleView* parent )
: BasicHeader( parent )
, m_parent( parent )
{
QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" );
f.open( QFile::ReadOnly );
QString css = QString::fromAscii( f.readAll() );
f.close();
QHBoxLayout* outerModeLayout = new QHBoxLayout;
m_verticalLayout->addLayout( outerModeLayout );
outerModeLayout->addSpacing( 156 );
outerModeLayout->addStretch();
QWidget* modeWidget = new QWidget( this );
QHBoxLayout* modeLayout = new QHBoxLayout;
modeWidget->setLayout( modeLayout );
modeWidget->setStyleSheet( css );
m_radioNormal = new QRadioButton( modeWidget );
m_radioDetailed = new QRadioButton( modeWidget );
m_radioCloud = new QRadioButton( modeWidget );
//for the CSS:
m_radioNormal->setObjectName( "radioNormal" );
m_radioCloud->setObjectName( "radioCloud" );
m_radioNormal->setFocusPolicy( Qt::NoFocus );
m_radioDetailed->setFocusPolicy( Qt::NoFocus );
m_radioCloud->setFocusPolicy( Qt::NoFocus );
modeLayout->addWidget( m_radioNormal );
modeLayout->addWidget( m_radioDetailed );
modeLayout->addWidget( m_radioCloud );
modeWidget->setFixedSize( 87, 30 );
m_radioNormal->setChecked( true );
outerModeLayout->addWidget( modeWidget );
outerModeLayout->addStretch();
m_filterField = new QSearchField( this );
m_filterField->setPlaceholderText( tr( "Filter..." ) );
m_filterField->setFixedWidth( 220 );
m_mainLayout->addWidget( m_filterField );
TomahawkUtils::unmarginLayout( outerModeLayout );
TomahawkUtils::unmarginLayout( modeLayout );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
connect( m_filterField, SIGNAL( textChanged( QString ) ), SLOT( onFilterEdited() ) );
NewClosure( m_radioNormal, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Flat )->setAutoDelete( false );
NewClosure( m_radioDetailed, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Detailed )->setAutoDelete( false );
NewClosure( m_radioCloud, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Grid )->setAutoDelete( false );
}
FlexibleHeader::~FlexibleHeader()
{
}
void
FlexibleHeader::setFilter( const QString& filter )
{
m_filterField->setText( filter );
}
void
FlexibleHeader::onFilterEdited()
{
m_filter = m_filterField->text();
m_filterTimer.stop();
m_filterTimer.setInterval( 280 );
m_filterTimer.setSingleShot( true );
m_filterTimer.start();
}
void
FlexibleHeader::applyFilter()
{
emit filterTextChanged( m_filterField->text() );
}
void
FlexibleHeader::changeEvent( QEvent* e )
{
QWidget::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
// ui->retranslateUi( this );
break;
default:
break;
}
}

View File

@@ -1,68 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef FLEXIBLEHEADER_H
#define FLEXIBLEHEADER_H
#include <QTimer>
#include "widgets/BasicHeader.h"
#include "DllMacro.h"
#include "Artist.h"
class QPaintEvent;
class FlexibleView;
class QRadioButton;
class QSearchField;
class DLLEXPORT FlexibleHeader : public BasicHeader
{
Q_OBJECT
public:
FlexibleHeader( FlexibleView* parent );
~FlexibleHeader();
public slots:
void setFilter( const QString& filter );
signals:
void filterTextChanged( const QString& filter );
protected:
void changeEvent( QEvent* e );
private slots:
void onFilterEdited();
void applyFilter();
private:
FlexibleView* m_parent;
QString m_filter;
QTimer m_filterTimer;
QRadioButton* m_radioCloud;
QRadioButton* m_radioDetailed;
QRadioButton* m_radioNormal;
QSearchField* m_filterField;
};
#endif

View File

@@ -22,7 +22,7 @@
#include <QStackedWidget>
#include <QVBoxLayout>
#include "playlist/FlexibleHeader.h"
#include "widgets/DeclarativeHeader.h"
#include "playlist/PlayableModel.h"
#include "playlist/PlaylistModel.h"
#include "playlist/TrackView.h"
@@ -37,13 +37,13 @@ using namespace Tomahawk;
FlexibleView::FlexibleView( QWidget* parent )
: QWidget( parent )
, m_header( new FlexibleHeader( this ) )
, m_header( new DeclarativeHeader( this ) )
, m_trackView( new TrackView() )
, m_detailedView( new TrackView() )
, m_gridView( new GridView() )
, m_model( 0 )
{
qRegisterMetaType< FlexibleViewMode >( "FlexibleViewMode" );
qRegisterMetaType< TomahawkUtils::ViewMode >( "TomahawkUtils::ViewMode" );
// m_trackView->setPlaylistInterface( m_playlistInterface );
m_detailedView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() );
@@ -69,9 +69,10 @@ FlexibleView::FlexibleView( QWidget* parent )
m_stack->addWidget( m_detailedView );
m_stack->addWidget( m_gridView );
setCurrentMode( Flat );
setCurrentMode( TomahawkUtils::ViewModeFlat );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
connect( m_header, SIGNAL(viewModeChanged(TomahawkUtils::ViewMode)), SLOT(setCurrentMode(TomahawkUtils::ViewMode)));
}
@@ -178,26 +179,26 @@ FlexibleView::setPlaylistModel( PlaylistModel* model )
void
FlexibleView::setCurrentMode( FlexibleViewMode mode )
FlexibleView::setCurrentMode( TomahawkUtils::ViewMode mode )
{
m_mode = mode;
switch ( mode )
{
case Flat:
case TomahawkUtils::ViewModeFlat:
{
tDebug() << "m_trackView:" << m_trackView << m_stack->indexOf( m_trackView );
m_stack->setCurrentWidget( m_trackView );
break;
}
case Detailed:
case TomahawkUtils::ViewModeDetailed:
{
m_stack->setCurrentWidget( m_detailedView );
break;
}
case Grid:
case TomahawkUtils::ViewModeGrid:
{
m_stack->setCurrentWidget( m_gridView );
break;
@@ -229,10 +230,10 @@ FlexibleView::description() const
}
QPixmap
FlexibleView::pixmap() const
QString
FlexibleView::headerIconSource() const
{
return m_pixmap;
return m_headerIconSource;
}
@@ -275,17 +276,17 @@ FlexibleView::setEmptyTip( const QString& tip )
void
FlexibleView::setPixmap( const QPixmap& pixmap )
FlexibleView::setHeaderIconSource( const QString& headerIconSource )
{
m_pixmap = pixmap;
m_header->setPixmap( pixmap );
m_headerIconSource = headerIconSource;
m_header->setIconSource( headerIconSource );
}
void
FlexibleView::onModelChanged()
{
m_header->setPixmap( m_pixmap );
m_header->setIconSource( m_headerIconSource );
m_header->setCaption( m_model->title() );
m_header->setDescription( m_model->description() );

View File

@@ -29,16 +29,19 @@ class GridView;
class TrackView;
class PlayableModel;
class PlaylistModel;
class FlexibleHeader;
namespace Tomahawk
{
class DeclarativeHeader;
}
using namespace Tomahawk;
class DLLEXPORT FlexibleView : public QWidget, public Tomahawk::ViewPage
{
Q_OBJECT
public:
enum FlexibleViewMode
{ Flat = 0, Detailed = 1, Grid = 2 };
explicit FlexibleView( QWidget* parent = 0 );
~FlexibleView();
@@ -47,7 +50,7 @@ public:
virtual QString title() const;
virtual QString description() const;
virtual QPixmap pixmap() const;
virtual QString headerIconSource() const;
virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack();
@@ -65,15 +68,15 @@ public:
void setPlayableModel( PlayableModel* model );
void setPlaylistModel( PlaylistModel* model );
void setPixmap( const QPixmap& pixmap );
void setHeaderIconSource( const QString& headerIconSource );
void setEmptyTip( const QString& tip );
public slots:
void setCurrentMode( FlexibleViewMode mode );
void setCurrentMode( TomahawkUtils::ViewMode mode );
virtual bool setFilter( const QString& pattern );
signals:
void modeChanged( FlexibleViewMode mode );
void modeChanged( TomahawkUtils::ViewMode mode );
void destroyed( QWidget* widget );
private slots:
@@ -81,8 +84,8 @@ private slots:
void onWidgetDestroyed( QWidget* widget );
private:
FlexibleHeader* m_header;
QPixmap m_pixmap;
DeclarativeHeader* m_header;
QString m_headerIconSource;
TrackView* m_trackView;
TrackView* m_detailedView;
@@ -91,9 +94,7 @@ private:
PlayableModel* m_model;
QStackedWidget* m_stack;
FlexibleViewMode m_mode;
TomahawkUtils::ViewMode m_mode;
};
Q_DECLARE_METATYPE( FlexibleView::FlexibleViewMode );
#endif // FLEXIBLEVIEW_H

View File

@@ -163,8 +163,8 @@ PlaylistView::onMenuTriggered( int action )
}
QPixmap
PlaylistView::pixmap() const
QString
PlaylistView::iconSource() const
{
return TomahawkUtils::defaultPixmap( TomahawkUtils::Playlist );
return TomahawkUtils::defaultImagePath( TomahawkUtils::Playlist );
}

View File

@@ -40,7 +40,7 @@ public:
virtual QList<Tomahawk::PlaylistUpdaterInterface*> updaters() const;
virtual QPixmap pixmap() const;
virtual QString iconSource() const;
virtual bool isTemporaryPage() const;
signals:

View File

@@ -90,10 +90,10 @@ DynamicQmlWidget::description() const
}
QPixmap
DynamicQmlWidget::pixmap() const
QString
DynamicQmlWidget::iconSource() const
{
return QPixmap( RESPATH "images/station.png" );
return QLatin1String( RESPATH "images/station.png" );
}

View File

@@ -50,7 +50,7 @@ public:
virtual QString title() const;
virtual QString description() const;
virtual QPixmap pixmap() const;
virtual QString iconSource() const;
virtual bool showInfoBar() const { return false; }
virtual bool showModes() const { return false; }

View File

@@ -56,12 +56,14 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent)
lineEdit->setStyleSheet( "QLineEdit { border: 1px solid gray; border-radius: 6px; }" );
lineEdit->setMinimumHeight(27);
setFixedHeight(27);
QFontMetrics fm(lineEdit->font());
setFixedHeight(fm.height() + fm.xHeight() * 2);
#ifdef Q_WS_MAC
lineEdit->setContentsMargins(0, 0, 0, 0);
#else
lineEdit->setContentsMargins(2, 2, 2, 2);
const int margins = fm.xHeight() / 2;
lineEdit->setContentsMargins(margins, margins, margins, margins);
#endif
}

View File

@@ -133,6 +133,12 @@ namespace TomahawkUtils
RoundedCorners
};
enum ViewMode
{
ViewModeFlat = 0,
ViewModeDetailed = 1,
ViewModeGrid = 2
};
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{
@@ -214,5 +220,6 @@ namespace TomahawkUtils
DLLEXPORT void crash();
}
Q_DECLARE_METATYPE( TomahawkUtils::ViewMode );
#endif // TOMAHAWKUTILS_H

View File

@@ -413,297 +413,304 @@ alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity )
}
QPixmap
defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
QString
defaultImagePath( ImageType type, ImageMode mode )
{
QPixmap pixmap;
switch ( type )
{
case DefaultAlbumCover:
if ( mode == CoverInCase )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/no-album-art-placeholder.svg", size );
return QLatin1String( RESPATH "images/no-album-art-placeholder.svg" );
else if ( mode == Grid )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/album-placeholder-grid.svg", size );
return QLatin1String( RESPATH "images/album-placeholder-grid.svg" );
else
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/album-icon.svg", size );
return QLatin1String( RESPATH "images/album-icon.svg" );
break;
case DefaultArtistImage:
if ( mode == Grid )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/artist-placeholder-grid.svg", size );
return QLatin1String( RESPATH "images/artist-placeholder-grid.svg" );
else
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/artist-icon.svg", size );
return QLatin1String( RESPATH "images/artist-icon.svg" );
break;
case DefaultTrackImage:
if ( mode == Grid )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/track-placeholder-grid.svg", size );
return QLatin1String( RESPATH "images/track-placeholder-grid.svg" );
else
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/track-icon.svg", size );
return QLatin1String( RESPATH "images/track-icon.svg" );
break;
case DefaultSourceAvatar:
if ( mode == RoundedCorners )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/user-avatar.svg", size, TomahawkUtils::RoundedCorners );
else
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/user-avatar.svg", size );
return QLatin1String( RESPATH "images/user-avatar.svg" );
break;
case DefaultResolver:
if ( mode == RoundedCorners )
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/resolver-default.svg", size, TomahawkUtils::RoundedCorners );
else
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/resolver-default.svg", size );
return QLatin1String( RESPATH "images/resolver-default.svg" );
break;
case DefaultCollection:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/collection.svg", size );
return QLatin1String( RESPATH "images/collection.svg" );
break;
case NowPlayingSpeaker:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/now-playing-speaker.svg", size );
return QLatin1String( RESPATH "images/now-playing-speaker.svg" );
break;
case NowPlayingSpeakerDark:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/now-playing-speaker-dark.svg", size );
return QLatin1String( RESPATH "images/now-playing-speaker-dark.svg" );
break;
case InfoIcon:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/info.svg", size );
return QLatin1String( RESPATH "images/info.svg" );
break;
case PlayButton:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/play-rest.svg", size );
return QLatin1String( RESPATH "images/play-rest.svg" );
break;
case PlayButtonPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/play-pressed.svg", size );
return QLatin1String( RESPATH "images/play-pressed.svg" );
break;
case PauseButton:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/pause-rest.svg", size );
return QLatin1String( RESPATH "images/pause-rest.svg" );
break;
case PauseButtonPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/pause-pressed.svg", size );
return QLatin1String( RESPATH "images/pause-pressed.svg" );
break;
case PrevButton:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/back-rest.svg", size );
return QLatin1String( RESPATH "images/back-rest.svg" );
break;
case PrevButtonPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/back-pressed.svg", size );
return QLatin1String( RESPATH "images/back-pressed.svg" );
break;
case NextButton:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/skip-rest.svg", size );
return QLatin1String( RESPATH "images/skip-rest.svg" );
break;
case NextButtonPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/skip-pressed.svg", size );
return QLatin1String( RESPATH "images/skip-pressed.svg" );
break;
case ShuffleOff:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/shuffle-off-rest.svg", size );
return QLatin1String( RESPATH "images/shuffle-off-rest.svg" );
break;
case ShuffleOffPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/shuffle-off-pressed.svg", size );
return QLatin1String( RESPATH "images/shuffle-off-pressed.svg" );
break;
case ShuffleOn:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/shuffle-on-rest.svg", size );
return QLatin1String( RESPATH "images/shuffle-on-rest.svg" );
break;
case ShuffleOnPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/shuffle-on-pressed.svg", size );
return QLatin1String( RESPATH "images/shuffle-on-pressed.svg" );
break;
case RepeatOne:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-1-on-rest.svg", size );
return QLatin1String( RESPATH "images/repeat-1-on-rest.svg" );
break;
case RepeatOnePressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-1-on-pressed.svg", size );
return QLatin1String( RESPATH "images/repeat-1-on-pressed.svg" );
break;
case RepeatAll:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-all-on-rest.svg", size );
return QLatin1String( RESPATH "images/repeat-all-on-rest.svg" );
break;
case RepeatAllPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-all-on-pressed.svg", size );
return QLatin1String( RESPATH "images/repeat-all-on-pressed.svg" );
break;
case RepeatOff:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-off-rest.svg", size );
return QLatin1String( RESPATH "images/repeat-off-rest.svg" );
break;
case RepeatOffPressed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/repeat-off-pressed.svg", size );
return QLatin1String( RESPATH "images/repeat-off-pressed.svg" );
break;
case VolumeMuted:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/volume-icon-muted.svg", size );
return QLatin1String( RESPATH "images/volume-icon-muted.svg" );
break;
case VolumeFull:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/volume-icon-full.svg", size );
return QLatin1String( RESPATH "images/volume-icon-full.svg" );
break;
case Share:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/share.svg", size );
return QLatin1String( RESPATH "images/share.svg" );
break;
case NotLoved:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/not-loved.svg", size );
return QLatin1String( RESPATH "images/not-loved.svg" );
break;
case Loved:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/loved.svg", size );
return QLatin1String( RESPATH "images/loved.svg" );
break;
case Configure:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/configure.svg", size );
return QLatin1String( RESPATH "images/configure.svg" );
break;
case GreenDot:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/green-dot.svg", size );
return QLatin1String( RESPATH "images/green-dot.svg" );
break;
case AddContact:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/add-contact.svg", size );
return QLatin1String( RESPATH "images/add-contact.svg" );
break;
case SubscribeOn:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/subscribe-on.svg", size );
return QLatin1String( RESPATH "images/subscribe-on.svg" );
break;
case SubscribeOff:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/subscribe-off.svg", size );
return QLatin1String( RESPATH "images/subscribe-off.svg" );
break;
case JumpLink:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/jump-link.svg", size );
return QLatin1String( RESPATH "images/jump-link.svg" );
break;
case ProcessStop:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/process-stop.svg", size );
return QLatin1String( RESPATH "images/process-stop.svg" );
break;
case HeadphonesOn:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/headphones.svg", size );
return QLatin1String( RESPATH "images/headphones.svg" );
break;
case HeadphonesOff:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/headphones-off.svg", size );
return QLatin1String( RESPATH "images/headphones-off.svg" );
break;
case PadlockClosed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/closed-padlock.svg", size );
return QLatin1String( RESPATH "images/closed-padlock.svg" );
break;
case PadlockOpen:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/open-padlock.svg", size );
return QLatin1String( RESPATH "images/open-padlock.svg" );
break;
case Downloading:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/downloading.svg", size );
return QLatin1String( RESPATH "images/downloading.svg" );
break;
case Uploading:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/uploading.svg", size );
return QLatin1String( RESPATH "images/uploading.svg" );
break;
case ViewRefresh:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/view-refresh.svg", size );
return QLatin1String( RESPATH "images/view-refresh.svg" );
break;
case SuperCollection:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/supercollection.svg", size );
return QLatin1String( RESPATH "images/supercollection.svg" );
break;
case LovedPlaylist:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/loved_playlist.svg", size );
return QLatin1String( RESPATH "images/loved_playlist.svg" );
break;
case NewReleases:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/new-releases.svg", size );
return QLatin1String( RESPATH "images/new-releases.svg" );
break;
case NewAdditions:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/new-additions.svg", size );
return QLatin1String( RESPATH "images/new-additions.svg" );
break;
case RecentlyPlayed:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/recently-played.svg", size );
return QLatin1String( RESPATH "images/recently-played.svg" );
break;
case Charts:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/charts.svg", size );
return QLatin1String( RESPATH "images/charts.svg" );
break;
case AutomaticPlaylist:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/automatic-playlist.svg", size );
return QLatin1String( RESPATH "images/automatic-playlist.svg" );
break;
case Station:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/station.svg", size );
return QLatin1String( RESPATH "images/station.svg" );
break;
case Playlist:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/playlist-icon.svg", size );
return QLatin1String( RESPATH "images/playlist-icon.svg" );
break;
case Search:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/search-icon.svg", size );
return QLatin1String( RESPATH "images/search-icon.svg" );
break;
case Add:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/add.svg", size );
return QLatin1String( RESPATH "images/add.svg" );
break;
case ListAdd:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/list-add.svg", size );
return QLatin1String( RESPATH "images/list-add.svg" );
break;
case ListRemove:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/list-remove.svg", size );
return QLatin1String( RESPATH "images/list-remove.svg" );
break;
case AdvancedSettings:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/advanced-settings.svg", size );
return QLatin1String( RESPATH "images/advanced-settings.svg" );
break;
case AccountSettings:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/account-settings.svg", size );
return QLatin1String( RESPATH "images/account-settings.svg" );
break;
case MusicSettings:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/music-settings.svg", size );
return QLatin1String( RESPATH "images/music-settings.svg" );
break;
case DropSong:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-song.svg", size );
return QLatin1String( RESPATH "images/drop-song.svg" );
break;
case DropAlbum:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-album.svg", size );
return QLatin1String( RESPATH "images/drop-album.svg" );
break;
case DropAllSongs:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-all-songs.svg", size );
return QLatin1String( RESPATH "images/drop-all-songs.svg" );
break;
case DropLocalSongs:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-local-songs.svg", size );
return QLatin1String( RESPATH "images/drop-local-songs.svg" );
break;
case DropTopSongs:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/drop-top-songs.svg", size );
return QLatin1String( RESPATH "images/drop-top-songs.svg" );
break;
case Starred:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/starred.svg", size );
return QLatin1String( RESPATH "images/starred.svg" );
break;
case Unstarred:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/star-unstarred.svg", size );
return QLatin1String( RESPATH "images/star-unstarred.svg" );
break;
case StarHovered:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/star-hover.svg", size );
return QLatin1String( RESPATH "images/star-hover.svg" );
break;
case SipPluginOnline:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/sipplugin-online.svg", size );
return QLatin1String( RESPATH "images/sipplugin-online.svg" );
break;
case SipPluginOffline:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/sipplugin-offline.svg", size );
return QLatin1String( RESPATH "images/sipplugin-offline.svg" );
break;
case AccountNone:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/account-none.svg", size );
return QLatin1String( RESPATH "images/account-none.svg" );
break;
case LastfmIcon:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/lastfm-icon.svg", size );
return QLatin1String( RESPATH "images/lastfm-icon.svg" );
break;
case SpotifyIcon:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/spotify-sourceicon.svg", size );
return QLatin1String( RESPATH "images/spotify-sourceicon.svg" );
break;
case SoundcloudIcon:
pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/soundcloud.svg", size );
return QLatin1String( RESPATH "images/soundcloud.svg" );
break;
default:
break;
}
Q_ASSERT(false);
return QString();
}
QPixmap
defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
{
QPixmap pixmap;
if ( mode == RoundedCorners ) {
pixmap = ImageRegistry::instance()->pixmap( defaultImagePath( type, mode ), size, TomahawkUtils::RoundedCorners );
} else {
pixmap = ImageRegistry::instance()->pixmap( defaultImagePath( type, mode ), size );
}
if ( pixmap.isNull() )
{
Q_ASSERT( false );
@@ -711,6 +718,7 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
}
return pixmap;
}

View File

@@ -69,6 +69,7 @@ namespace TomahawkUtils
DLLEXPORT void styleScrollBar( QScrollBar* scrollBar );
DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode = TomahawkUtils::Original, const QSize& size = QSize( 0, 0 ) );
DLLEXPORT QString defaultImagePath( ImageType type, ImageMode mode = TomahawkUtils::Original );
DLLEXPORT QPixmap createTiledPixmap( int width, int height, const QImage& src );
DLLEXPORT QPixmap addDropShadow( const QPixmap& sourceImage, const QSize& targetSize );
DLLEXPORT QPixmap squareCenterPixmap( const QPixmap& sourceImage );

View File

@@ -0,0 +1,64 @@
#include "DeclarativeHeader.h"
#include "utils/TomahawkUtilsGui.h"
#include <QDeclarativeContext>
namespace Tomahawk
{
DeclarativeHeader::DeclarativeHeader(QWidget *parent)
: DeclarativeView(parent)
{
QStringList buttonList;
buttonList << "view-toggle-icon-artist" << "view-toggle-icon-list" << "view-toggle-icon-grid";
rootContext()->setContextProperty("toggleViewButtonModel", buttonList );
setSource( QUrl( "qrc" RESPATH "qml/tomahawkimports/FlexibleHeader.qml" ) );
connect(&m_filterTimer, SIGNAL(timeout()), SLOT(applyFilter()));
}
void DeclarativeHeader::setIconSource(const QString &iconSource)
{
rootContext()->setContextProperty("iconSource", iconSource);
}
void DeclarativeHeader::setCaption(const QString &caption)
{
rootContext()->setContextProperty("caption", caption);
}
void DeclarativeHeader::setDescription(const QString &description)
{
rootContext()->setContextProperty("description", description);
}
QSize DeclarativeHeader::sizeHint() const
{
return QSize(0, TomahawkUtils::defaultFontHeight() * 4);
}
void DeclarativeHeader::viewModeSelected(int viewMode)
{
emit viewModeChanged((TomahawkUtils::ViewMode)viewMode);
}
void DeclarativeHeader::setFilterText(const QString &filterText)
{
m_filter = filterText;
m_filterTimer.stop();
m_filterTimer.setInterval( 280 );
m_filterTimer.setSingleShot( true );
m_filterTimer.start();
}
void
DeclarativeHeader::applyFilter()
{
emit filterTextChanged( m_filter );
}
}

View File

@@ -0,0 +1,42 @@
#ifndef DECLARATIVEHEADER_H
#define DECLARATIVEHEADER_H
#include "DeclarativeView.h"
#include "utils/TomahawkUtils.h"
#include <QTimer>
namespace Tomahawk
{
class DeclarativeHeader: public DeclarativeView
{
Q_OBJECT
public:
DeclarativeHeader(QWidget *parent = 0);
void setIconSource(const QString &iconSource);
void setCaption(const QString &caption);
void setDescription(const QString &description);
QSize sizeHint() const;
signals:
void viewModeChanged(TomahawkUtils::ViewMode viewMode);
void filterTextChanged(const QString &filterText);
public slots:
void viewModeSelected(int viewMode);
void setFilterText(const QString &filterText);
private slots:
void applyFilter();
private:
QTimer m_filterTimer;
QString m_filter;
};
}
#endif

View File

@@ -9,4 +9,8 @@ SearchFieldQmlProxy::SearchFieldQmlProxy(QGraphicsItem *parent) :
m_searchField->setAttribute(Qt::WA_NoSystemBackground);
setWidget(m_searchField);
connect(m_searchField, SIGNAL(textChanged(QString)), SIGNAL(textChanged(QString)));
connect(m_searchField, SIGNAL(editingFinished()), SIGNAL(editingFinished()));
connect(m_searchField, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
}

View File

@@ -11,6 +11,11 @@ class SearchFieldQmlProxy: public QGraphicsProxyWidget
public:
SearchFieldQmlProxy(QGraphicsItem* parent = 0);
signals:
void textChanged(const QString &text);
void editingFinished();
void returnPressed();
private:
QSearchField *m_searchField;
};

View File

@@ -61,7 +61,7 @@ public:
virtual QString title() const { return m_title; }
virtual QString description() const { return m_description; }
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual QString iconSource() const { if ( m_iconSource.isEmpty() ) return Tomahawk::ViewPage::iconSource(); else return m_iconSource; }
virtual bool jumpToCurrentTrack() { return false; }
signals:
@@ -83,7 +83,7 @@ private:
QString m_title;
QString m_description;
QString m_longDescription;
QPixmap m_pixmap;
QString m_iconSource;
static QString s_popularAlbumsQuery;
static QString s_mostPlayedPlaylistsQuery;

View File

@@ -76,7 +76,7 @@ AlbumInfoWidget::AlbumInfoWidget( const Tomahawk::album_ptr& album, QWidget* par
ui->tracks->setFrameShape( QFrame::StyledPanel );
ui->tracks->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_iconSource = TomahawkUtils::defaultImagePath( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover );
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );
ui->biography->setFrameShape( QFrame::NoFrame );
@@ -233,8 +233,8 @@ AlbumInfoWidget::onAlbumImageUpdated()
if ( m_album->cover( QSize( 0, 0 ) ).isNull() )
return;
m_pixmap = m_album->cover( QSize( 0, 0 ) );
emit pixmapChanged( m_pixmap );
m_iconSource = QLatin1String( "image://albumart/" ) + m_album->coverId();
emit imageSourceChanged( m_iconSource );
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_album->cover( ui->cover->sizeHint() ), QSize( 0, 0 ) ) );
}

View File

@@ -64,7 +64,7 @@ public:
virtual QString title() const { return m_title; }
virtual QString description() const { return m_description; }
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual QString iconSource() const { if ( m_iconSource.isNull() ) return Tomahawk::ViewPage::iconSource(); else return m_iconSource; }
virtual bool isTemporaryPage() const { return true; }
virtual bool showInfoBar() const { return false; }
@@ -86,7 +86,7 @@ public slots:
signals:
void longDescriptionChanged( const QString& description );
void descriptionChanged( const Tomahawk::artist_ptr& artist );
void pixmapChanged( const QPixmap& pixmap );
void imageSourceChanged( const QString& imageSource );
protected:
void changeEvent( QEvent* e );
@@ -111,7 +111,7 @@ private:
QString m_title;
QString m_description;
QString m_longDescription;
QPixmap m_pixmap;
QString m_iconSource;
friend class MetaAlbumInfoInterface;
};

View File

@@ -96,7 +96,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->topHits->setFrameShape( QFrame::StyledPanel );
ui->topHits->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_iconSource = TomahawkUtils::defaultImagePath( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover );
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultArtistImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );
QFont f = font();
@@ -317,8 +317,8 @@ ArtistInfoWidget::onArtistImageUpdated()
if ( m_artist->cover( QSize( 0, 0 ) ).isNull() )
return;
m_pixmap = m_artist->cover( QSize( 0, 0 ) );
emit pixmapChanged( m_pixmap );
m_iconSource = QLatin1String( "image://albumart/" ) + m_artist->coverId();
emit pixmapChanged( m_iconSource );
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_artist->cover( ui->cover->sizeHint() ), QSize( 0, 0 ) ) );
}

View File

@@ -76,7 +76,7 @@ public:
virtual QString title() const { return m_title; }
virtual QString description() const { return m_description; }
virtual QString longDescription() const { return m_longDescription; }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual QString iconSource() const { if ( m_iconSource.isNull() ) return Tomahawk::ViewPage::iconSource(); else return m_iconSource; }
virtual bool isTemporaryPage() const { return true; }
virtual bool showInfoBar() const { return false; }
@@ -115,7 +115,7 @@ private:
QString m_title;
QString m_description;
QString m_longDescription;
QPixmap m_pixmap;
QString m_iconSource;
friend class ::MetaArtistInfoInterface;
};

View File

@@ -96,7 +96,7 @@ TrackInfoWidget::TrackInfoWidget( const Tomahawk::query_ptr& query, QWidget* par
ui->similarTracksView->proxyModel()->sort( -1 );
ui->similarTracksView->setEmptyTip( tr( "Sorry, but we could not find similar tracks for this song!" ) );
m_pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, QSize( 48, 48 ) );
m_iconSource = TomahawkUtils::defaultImagePath( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover);
ui->cover->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::ScaledCover, QSize( ui->cover->sizeHint() ) ) );
m_scrollArea = new QScrollArea();
@@ -218,8 +218,8 @@ TrackInfoWidget::onCoverUpdated()
if ( m_query->cover( QSize( 0, 0 ) ).isNull() )
return;
m_pixmap = m_query->cover( ui->cover->size() );
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_pixmap, QSize( 0, 0 ) ) );
m_iconSource = m_query->coverId();
ui->cover->setPixmap( TomahawkUtils::createRoundedImage( m_query->cover( ui->cover->size() ), QSize( 0, 0 ) ) );
}

View File

@@ -63,7 +63,7 @@ public:
virtual QString title() const { return m_title; }
virtual QString description() const { return QString(); }
virtual QString longDescription() const { return QString(); }
virtual QPixmap pixmap() const { if ( m_pixmap.isNull() ) return Tomahawk::ViewPage::pixmap(); else return m_pixmap; }
virtual QString iconSource() const { if ( m_iconSource.isEmpty() ) return Tomahawk::ViewPage::iconSource(); else return m_iconSource; }
virtual bool isBeingPlayed() const;
virtual bool isTemporaryPage() const { return true; }
@@ -96,7 +96,7 @@ private:
PlayableModel* m_relatedTracksModel;
QString m_title;
QPixmap m_pixmap;
QString m_iconSource;
};
#endif // TRACKINFOWIDGET_H

View File

@@ -73,7 +73,7 @@ LovedTracksItem::activate()
{
SourceItem* par = dynamic_cast< SourceItem* >( parent() );
FlexibleView* pv = new FlexibleView( ViewManager::instance()->widget() );
pv->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::LovedPlaylist, TomahawkUtils::Original, QSize( 128, 128 ) ) );
pv->setHeaderIconSource( TomahawkUtils::defaultImagePath( TomahawkUtils::LovedPlaylist, TomahawkUtils::Original ) );
LovedTracksModel* raModel = new LovedTracksModel( pv );
raModel->setTitle( text() );

View File

@@ -516,7 +516,7 @@ SourceItem::latestAdditionsClicked()
if ( !m_latestAdditionsPage )
{
FlexibleView* pv = new FlexibleView( ViewManager::instance()->widget() );
pv->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::NewAdditions, TomahawkUtils::Original ) );
pv->setHeaderIconSource( TomahawkUtils::defaultImagePath( TomahawkUtils::NewAdditions, TomahawkUtils::Original ) );
RecentlyAddedModel* raModel = new RecentlyAddedModel( pv );
raModel->setTitle( tr( "Latest Additions" ) );
@@ -559,7 +559,7 @@ SourceItem::recentPlaysClicked()
if ( !m_recentPlaysPage )
{
FlexibleView* pv = new FlexibleView( ViewManager::instance()->widget() );
pv->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::RecentlyPlayed ) );
pv->setHeaderIconSource( TomahawkUtils::defaultImagePath( TomahawkUtils::RecentlyPlayed ) );
RecentlyPlayedModel* raModel = new RecentlyPlayedModel( pv );
raModel->setTitle( tr( "Recently Played Tracks" ) );