1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

Merge branch 'master' of github.com:tomahawk-player/tomahawk

This commit is contained in:
Hugo Lindström 2011-10-21 23:58:31 +02:00
commit 8d561b5a56
26 changed files with 204 additions and 29 deletions

BIN
data/images/star-hover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
data/images/starred.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

@ -92,6 +92,9 @@
<file>data/images/artist-icon.png</file>
<file>data/images/album-icon.png</file>
<file>data/images/search-icon.png</file>
<file>data/images/star-hover.png</file>
<file>data/images/starred.png</file>
<file>data/images/star-unstarred.png</file>
<file>data/images/track-icon-22x22.png</file>
<file>data/images/track-icon-32x32.png</file>
<file>data/images/track-icon-16x16.png</file>

View File

@ -29,6 +29,7 @@
#define PADDING 4
#define PADDING_BETWEEN_STARS 2
#define STAR_SIZE 12
#ifdef Q_WS_MAC
#define SIZEHINT_HEIGHT 70
@ -41,11 +42,14 @@ GetNewStuffDelegate::GetNewStuffDelegate( QObject* parent )
, m_widestTextWidth( 0 )
{
m_defaultCover.load( RESPATH "images/sipplugin-online.png" );
m_ratingStarPositive.load( RESPATH "images/loved.png" );
m_ratingStarNegative.load( RESPATH "images/not-loved.png" );
m_ratingStarPositive.load( RESPATH "images/starred.png" );
m_ratingStarNegative.load( RESPATH "images/star-unstarred.png" );
m_onHoverStar.load( RESPATH "images/star-hover.png" );
m_ratingStarPositive = m_ratingStarPositive.scaled( STAR_SIZE, STAR_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
m_ratingStarNegative = m_ratingStarNegative.scaled( STAR_SIZE, STAR_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
m_onHoverStar = m_onHoverStar.scaled( STAR_SIZE, STAR_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation );
m_ratingStarPositive = m_ratingStarPositive.scaled( 8, 8, Qt::KeepAspectRatio, Qt::SmoothTransformation );
m_ratingStarNegative = m_ratingStarNegative.scaled( 8, 8, Qt::KeepAspectRatio, Qt::SmoothTransformation );
const int w = SIZEHINT_HEIGHT - 2*PADDING;
m_defaultCover = m_defaultCover.scaled( w, w, Qt::KeepAspectRatio, Qt::SmoothTransformation );
@ -175,6 +179,7 @@ GetNewStuffDelegate::paint( QPainter* painter, const QStyleOptionViewItem& optio
painter->drawText( btnRect, Qt::AlignCenter, actionText );
painter->setPen( saved );
// rating stars
int rating = index.data( GetNewStuffModel::RatingRole ).toInt();
const int ratingWidth = 5 * ( m_ratingStarPositive.width() + PADDING_BETWEEN_STARS );
@ -185,10 +190,21 @@ GetNewStuffDelegate::paint( QPainter* painter, const QStyleOptionViewItem& optio
if ( i == 1 )
m_cachedStarRects[ QPair<int, int>(index.row(), index.column()) ] = r;
if ( i <= rating ) // positive star
painter->drawPixmap( r, m_ratingStarPositive );
QPixmap pm;
if ( m_hoveringOver > -1 )
{
if ( i <= m_hoveringOver ) // positive star
painter->drawPixmap( r, m_onHoverStar );
else
painter->drawPixmap( r, m_ratingStarNegative );
}
else
painter->drawPixmap( r, m_ratingStarNegative );
{
if ( i <= rating ) // positive star
painter->drawPixmap( r, m_ratingStarPositive );
else
painter->drawPixmap( r, m_ratingStarNegative );
}
runningEdge += m_ratingStarPositive.width() + PADDING_BETWEEN_STARS;
}
@ -242,10 +258,13 @@ bool
GetNewStuffDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
Q_UNUSED( option );
if ( event->type() != QEvent::MouseButtonRelease )
m_hoveringOver = -1;
if ( event->type() != QEvent::MouseButtonRelease &&
event->type() != QEvent::MouseMove )
return false;
if ( m_cachedButtonRects.contains( QPair<int, int>( index.row(), index.column() ) ) )
if ( event->type() == QEvent::MouseButtonRelease && m_cachedButtonRects.contains( QPair<int, int>( index.row(), index.column() ) ) )
{
QRect rect = m_cachedButtonRects[ QPair<int, int>( index.row(), index.column() ) ];
QMouseEvent* me = static_cast< QMouseEvent* >( event );
@ -273,8 +292,17 @@ GetNewStuffDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, cons
const int eachStar = starsWidth / 5;
const int clickOffset = me->pos().x() - fullStars.x();
const int whichStar = (clickOffset / eachStar) + 1;
tDebug() << "Clicked on:" << whichStar;
model->setData( index, whichStar, GetNewStuffModel::RatingRole );
if ( event->type() == QEvent::MouseButtonRelease )
{
tDebug() << "Clicked on:" << whichStar;
model->setData( index, whichStar, GetNewStuffModel::RatingRole );
}
else if ( event->type() == QEvent::MouseMove )
{
// 0-indexed
m_hoveringOver = whichStar;
}
return true;
}

View File

@ -35,11 +35,10 @@ protected:
virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
private:
QPixmap m_defaultCover;
QPixmap m_ratingStarPositive;
QPixmap m_ratingStarNegative;
QPixmap m_defaultCover, m_onHoverStar, m_ratingStarPositive, m_ratingStarNegative;
int m_widestTextWidth;
int m_hoveringOver;
mutable QHash< QPair<int, int>, QRect > m_cachedButtonRects;
mutable QHash< QPair<int, int>, QRect > m_cachedStarRects;
};

View File

@ -33,6 +33,8 @@ GetNewStuffDialog::GetNewStuffDialog( QWidget *parent, Qt::WindowFlags f )
ui->listView->setItemDelegate( new GetNewStuffDelegate( ui->listView ) );
ui->listView->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
ui->listView->setMouseTracking( true );
#ifdef Q_WS_MAC
setMinimumSize( 510, 350 );
setMaximumSize( 510, 350 );

View File

@ -22,7 +22,8 @@
#include "database/databasecommand_genericselect.h"
#include "database/database.h"
#include "utils/tomahawkutils.h"
#include <sourcelist.h>
#include "sourcelist.h"
#include "audio/audioengine.h"
using namespace Tomahawk;
@ -54,6 +55,19 @@ CustomPlaylistView::CustomPlaylistView( CustomPlaylistView::PlaylistType type, c
CustomPlaylistView::~CustomPlaylistView()
{}
bool
CustomPlaylistView::isBeingPlayed() const
{
return AudioEngine::instance()->currentTrackPlaylist() == playlistInterface();
}
bool
CustomPlaylistView::jumpToCurrentTrack()
{
return PlaylistView::jumpToCurrentTrack();
}
void
CustomPlaylistView::generateTracks()
{

View File

@ -46,7 +46,10 @@ public:
virtual QPixmap pixmap() const;
virtual QString description() const;
virtual QString longDescription() const;
virtual bool isTemporaryPage() const { return false; }
virtual bool isBeingPlayed() const;
virtual bool jumpToCurrentTrack();
private slots:
void tracksGenerated( QList<Tomahawk::query_ptr> tracks );

View File

@ -569,7 +569,6 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
}
m_stack->setCurrentWidget( page->widget() );
page->widget()->setFocus();
updateView();
}

View File

@ -53,6 +53,7 @@ public:
virtual bool jumpToCurrentTrack() = 0;
virtual bool isTemporaryPage() const { return false; }
virtual bool isBeingPlayed() const { return false; }
virtual bool canAutoUpdate() const { return false; }
virtual void setAutoUpdate( bool ) {}

View File

@ -19,6 +19,7 @@
#include "AlbumInfoWidget.h"
#include "ui_AlbumInfoWidget.h"
#include "audio/audioengine.h"
#include "viewmanager.h"
#include "database/database.h"
#include "playlist/treemodel.h"
@ -117,6 +118,18 @@ AlbumInfoWidget::onLoadingFinished()
m_button->show();
}
bool
AlbumInfoWidget::isBeingPlayed() const
{
if ( ui->albumsView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->tracksView->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
return false;
}
void
AlbumInfoWidget::load( const album_ptr& album )

View File

@ -75,6 +75,7 @@ public:
virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
signals:
void longDescriptionChanged( const QString& description );

View File

@ -19,6 +19,7 @@
#include "ArtistInfoWidget.h"
#include "ui_ArtistInfoWidget.h"
#include "audio/audioengine.h"
#include "viewmanager.h"
#include "playlist/treemodel.h"
#include "playlist/playlistmodel.h"
@ -125,6 +126,36 @@ ArtistInfoWidget::onLoadingFinished()
m_button->show();
}
bool
ArtistInfoWidget::isBeingPlayed() const
{
if ( ui->albums->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->relatedArtists->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
if ( ui->topHits->playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() )
return true;
return false;
}
bool
ArtistInfoWidget::jumpToCurrentTrack()
{
if ( ui->albums->jumpToCurrentTrack() )
return true;
if ( ui->relatedArtists->jumpToCurrentTrack() )
return true;
if ( ui->topHits->jumpToCurrentTrack() )
return true;
return false;
}
void
ArtistInfoWidget::load( const artist_ptr& artist )
@ -168,7 +199,8 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
if ( output.canConvert< QVariantMap >() )
{
if ( trackInfo["artist"] != m_artist->name() )
const QString artist = requestData.input.toString();
if ( trackInfo["artist"] != m_artist->name() && artist != m_artist->name() )
{
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_artist->name();
return;

View File

@ -76,7 +76,8 @@ public:
virtual bool isTemporaryPage() const { return true; }
virtual bool showStatsBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool jumpToCurrentTrack();
virtual bool isBeingPlayed() const;
signals:
void longDescriptionChanged( const QString& description );

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@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
@ -98,6 +99,12 @@ WelcomeWidget::~WelcomeWidget()
delete ui;
}
bool
WelcomeWidget::isBeingPlayed() const
{
return AudioEngine::instance()->currentTrackPlaylist() == ui->tracksView->playlistInterface();
}
void
WelcomeWidget::updateRecentTracks()

View File

@ -93,6 +93,7 @@ public:
virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool isBeingPlayed() const;
protected:
void changeEvent( QEvent* e );

View File

@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@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
@ -29,6 +30,7 @@
#include "RecentPlaylistsModel.h"
#include "audio/audioengine.h"
#include "dynamic/GeneratorInterface.h"
#include "playlist/playlistmodel.h"
#include "playlist/treeproxymodel.h"
#include "widgets/overlaywidget.h"
@ -36,7 +38,6 @@
#include "widgets/kbreadcrumbselectionmodel.h"
#include "utils/tomahawkutils.h"
#include "utils/logger.h"
#include <dynamic/GeneratorInterface.h>
#include <pipeline.h>
#define HISTORY_TRACK_ITEMS 25
@ -99,6 +100,7 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistChanged( Tomahawk::PlaylistInterface* ) ) );
QTimer::singleShot( 0, this, SLOT( fetchData() ) );
}
@ -109,6 +111,31 @@ WhatsHotWidget::~WhatsHotWidget()
}
bool
WhatsHotWidget::isBeingPlayed() const
{
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->artistsViewLeft->playlistInterface() )
return true;
if ( AudioEngine::instance()->currentTrackPlaylist() == ui->tracksViewLeft->playlistInterface() )
return true;
return false;
}
bool
WhatsHotWidget::jumpToCurrentTrack()
{
if ( ui->artistsViewLeft->jumpToCurrentTrack() )
return true;
if ( ui->tracksViewLeft->jumpToCurrentTrack() )
return true;
return false;
}
void
WhatsHotWidget::fetchData()
{

View File

@ -65,7 +65,8 @@ public:
virtual bool showStatsBar() const { return false; }
virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool jumpToCurrentTrack();
virtual bool isBeingPlayed() const;
protected:
void changeEvent( QEvent* e );
@ -80,7 +81,6 @@ private slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
void leftCrumbIndexChanged( QModelIndex );
private:
void setLeftViewArtists( TreeModel* artistModel );
void setLeftViewAlbums( AlbumModel* albumModel );

View File

@ -409,7 +409,8 @@ CollectionItem::requestExpanding()
void
CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
{
int idx = children().count();
const int idx = children().count();
const int latest = children().last()->IDValue();
foreach ( TemporaryPageItem* page, m_tempItems )
{
@ -420,13 +421,28 @@ CollectionItem::tempPageActivated( Tomahawk::ViewPage* v )
}
}
// Only keep 5 temporary pages at once
while ( m_tempItems.size() > 4 )
{
TemporaryPageItem* item = m_tempItems.takeFirst();
QTimer::singleShot( 0, item, SLOT( removeFromList() ) );
}
emit beginRowsAdded( idx, idx );
TemporaryPageItem* tempPage = new TemporaryPageItem( model(), this, v, idx );
TemporaryPageItem* tempPage = new TemporaryPageItem( model(), this, v, latest + 1 );
connect( tempPage, SIGNAL( removed() ), this, SLOT( temporaryPageDestroyed() ) );
m_tempItems << tempPage;
endRowsAdded();
emit selectRequest( tempPage );
}
void
CollectionItem::temporaryPageDestroyed()
{
TemporaryPageItem* tempPage = qobject_cast< TemporaryPageItem* >( sender() );
Q_ASSERT( tempPage );
m_tempItems.removeAll( tempPage );
}
ViewPage*
CollectionItem::sourceInfoClicked()

View File

@ -65,6 +65,7 @@ private slots:
void requestExpanding();
void tempPageActivated( Tomahawk::ViewPage* );
void temporaryPageDestroyed();
Tomahawk::ViewPage* sourceInfoClicked();
Tomahawk::ViewPage* getSourceInfoPage() const;

View File

@ -85,9 +85,8 @@ GenericPageItem::setText( const QString &text )
bool
GenericPageItem::isBeingPlayed() const
{
if ( dynamic_cast< PlaylistInterface* >( m_get() ) )
{
return AudioEngine::instance()->currentTrackPlaylist() == dynamic_cast< PlaylistInterface* >( m_get() );
}
if ( m_get() )
return m_get()->isBeingPlayed();
return false;
}

View File

@ -17,7 +17,10 @@
*/
#include "temporarypageitem.h"
#include <viewmanager.h>
#include "viewmanager.h"
#include "widgets/infowidgets/AlbumInfoWidget.h"
#include "widgets/infowidgets/ArtistInfoWidget.h"
#include "widgets/searchwidget.h"
using namespace Tomahawk;
@ -27,6 +30,13 @@ TemporaryPageItem::TemporaryPageItem ( SourcesModel* mdl, SourceTreeItem* parent
, m_icon( QIcon( RESPATH "images/playlist-icon.png" ) )
, m_sortValue( sortValue )
{
if ( dynamic_cast< ArtistInfoWidget* >( page ) )
m_icon = QIcon( RESPATH "images/artist-icon.png" );
else if ( dynamic_cast< AlbumInfoWidget* >( page ) )
m_icon = QIcon( RESPATH "images/album-icon.png" );
else if ( dynamic_cast< SearchWidget* >( page ) )
m_icon = QIcon( RESPATH "images/search-icon.png" );
model()->linkSourceItemToPage( this, page );
}
@ -55,6 +65,13 @@ TemporaryPageItem::peerSortValue() const
return m_sortValue;
}
int
TemporaryPageItem::IDValue() const
{
return m_sortValue;
}
void
TemporaryPageItem::removeFromList()
{
@ -67,5 +84,7 @@ TemporaryPageItem::removeFromList()
parent()->removeChild( this );
parent()->endRowsRemoved();
emit removed();
deleteLater();
}

View File

@ -20,6 +20,7 @@
#define TEMPORARYPAGEITEM_H
#include "items/sourcetreeitem.h"
#include "viewpage.h"
class TemporaryPageItem : public SourceTreeItem
{
@ -32,9 +33,16 @@ public:
virtual QIcon icon() const;
virtual int peerSortValue() const;
virtual int IDValue() const;
void removeFromList();
Tomahawk::ViewPage* page() const { return m_page; }
virtual bool isBeingPlayed() const { return m_page->isBeingPlayed(); }
public slots:
void removeFromList();
signals:
bool removed();
private:
Tomahawk::ViewPage* m_page;

View File

@ -140,6 +140,7 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
const bool playable = ( type == SourcesModel::StaticPlaylist ||
type == SourcesModel::AutomaticPlaylist ||
type == SourcesModel::Station ||
type == SourcesModel::TemporaryPage ||
type == SourcesModel::GenericPage );
if ( playable && item->isBeingPlayed() )