mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Remove now unused context-widget sources.
This commit is contained in:
@@ -1,111 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "ContextPage.h"
|
|
||||||
|
|
||||||
#include <QGraphicsLinearLayout>
|
|
||||||
|
|
||||||
#include "PlaylistInterface.h"
|
|
||||||
#include "utils/TomahawkStyle.h"
|
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
|
||||||
|
|
||||||
// Forward Declarations breaking QSharedPointer
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
#include "collection/Collection.h"
|
|
||||||
#include "Source.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
|
|
||||||
{
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
|
||||||
painter->setPen( TomahawkStyle::HEADER_HIGHLIGHT );
|
|
||||||
painter->setBrush( TomahawkStyle::HEADER_HIGHLIGHT );
|
|
||||||
painter->drawRoundedRect( option->rect, 4.0, 4.0 );
|
|
||||||
|
|
||||||
QFont f( font() );
|
|
||||||
f.setBold( true );
|
|
||||||
f.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
|
||||||
painter->setFont( f );
|
|
||||||
painter->setPen( Qt::white );
|
|
||||||
|
|
||||||
QFontMetrics fm( f );
|
|
||||||
QRect r( 1, 1, option->rect.width(), fm.height() * 1.1 );
|
|
||||||
QTextOption to( Qt::AlignCenter );
|
|
||||||
painter->drawText( r, m_page->title(), to );
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
|
|
||||||
QGraphicsWidget::paint( painter, option, widget );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextProxyPage::setPage( Tomahawk::ContextPage* page )
|
|
||||||
{
|
|
||||||
m_page = page;
|
|
||||||
|
|
||||||
#ifdef Q_WS_X11 //FIXME: why do we need this? maybe it's only oxygen style misbehaving?
|
|
||||||
QGraphicsWebView* testWebView = qobject_cast<QGraphicsWebView*>( page->widget() );
|
|
||||||
if ( testWebView )
|
|
||||||
{
|
|
||||||
setContentsMargins( 4, 4, 4, 4 );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFont f( font() );
|
|
||||||
f.setBold( true );
|
|
||||||
f.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
|
||||||
QFontMetrics fm( f );
|
|
||||||
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
|
|
||||||
layout->setContentsMargins( 4, fm.height() * 1.1, 4, 4 );
|
|
||||||
layout->addItem( page->widget() );
|
|
||||||
setLayout( layout );
|
|
||||||
|
|
||||||
page->widget()->installEventFilter( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
ContextProxyPage::eventFilter( QObject* watched, QEvent* event )
|
|
||||||
{
|
|
||||||
if ( event->type() == QEvent::GrabMouse )
|
|
||||||
{
|
|
||||||
emit focused();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QGraphicsWidget::eventFilter( watched, event );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
ContextProxyPage::sceneEvent( QEvent* event )
|
|
||||||
{
|
|
||||||
if ( event->type() == QEvent::GrabMouse )
|
|
||||||
{
|
|
||||||
emit focused();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QGraphicsWidget::sceneEvent( event );
|
|
||||||
}
|
|
@@ -1,94 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 CONTEXTPAGE_H
|
|
||||||
#define CONTEXTPAGE_H
|
|
||||||
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
#include <QGraphicsWebView>
|
|
||||||
#include <QStyleOptionGraphicsItem>
|
|
||||||
|
|
||||||
#include "Typedefs.h"
|
|
||||||
#include "utils/TomahawkUtils.h"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
class PlaylistInterface;
|
|
||||||
|
|
||||||
namespace Tomahawk
|
|
||||||
{
|
|
||||||
|
|
||||||
class DLLEXPORT ContextPage : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ContextPage() {}
|
|
||||||
virtual ~ContextPage() {}
|
|
||||||
|
|
||||||
virtual QGraphicsWidget* widget() = 0;
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const = 0;
|
|
||||||
|
|
||||||
virtual QString title() const = 0;
|
|
||||||
virtual QString description() const = 0;
|
|
||||||
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() = 0;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void setArtist( const Tomahawk::artist_ptr& artist ) { Q_UNUSED( artist ); }
|
|
||||||
virtual void setAlbum( const Tomahawk::album_ptr& album ) { Q_UNUSED( album ); }
|
|
||||||
virtual void setQuery( const Tomahawk::query_ptr& query ) { Q_UNUSED( query ); }
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void nameChanged( const QString& );
|
|
||||||
void descriptionChanged( const QString& );
|
|
||||||
void pixmapChanged( const QPixmap& );
|
|
||||||
void destroyed( QWidget* widget );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT ContextProxyPage : public QGraphicsWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ContextProxyPage() : QGraphicsWidget()
|
|
||||||
{}
|
|
||||||
|
|
||||||
Tomahawk::ContextPage* page() const { return m_page; }
|
|
||||||
void setPage( Tomahawk::ContextPage* page );
|
|
||||||
|
|
||||||
virtual bool eventFilter( QObject* watched, QEvent* event );
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void focused();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
|
|
||||||
virtual bool sceneEvent( QEvent* event );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Tomahawk::ContextPage* m_page;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // ns
|
|
||||||
|
|
||||||
#endif //CONTEXTPAGE_H
|
|
@@ -1,370 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "ContextWidget.h"
|
|
||||||
#include "ui_ContextWidget.h"
|
|
||||||
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
#include <QGraphicsScene>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
#include <QTimeLine>
|
|
||||||
|
|
||||||
#include "context/ContextPage.h"
|
|
||||||
#include "context/pages/RelatedArtistsContext.h"
|
|
||||||
#include "context/pages/TopTracksContext.h"
|
|
||||||
#include "context/pages/WikipediaContext.h"
|
|
||||||
#include "utils/TomahawkStyle.h"
|
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
|
||||||
|
|
||||||
// Forward Declarations breaking QSharedPointer
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
#include "PlaylistInterface.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include "Source.h"
|
|
||||||
#include "Track.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define ANIMATION_TIME 450
|
|
||||||
#define SLIDE_TIME 350
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
ContextWidget::ContextWidget( QWidget* parent )
|
|
||||||
: QWidget( parent )
|
|
||||||
, ui( new Ui::ContextWidget )
|
|
||||||
, m_currentView( 0 )
|
|
||||||
, m_visible( false )
|
|
||||||
{
|
|
||||||
ui->setupUi( this );
|
|
||||||
TomahawkUtils::unmarginLayout( layout() );
|
|
||||||
setContentsMargins( 0, 0, 0, 0 );
|
|
||||||
|
|
||||||
m_scene = new QGraphicsScene( this );
|
|
||||||
|
|
||||||
TopTracksContext* ttc = new TopTracksContext();
|
|
||||||
RelatedArtistsContext* rac = new RelatedArtistsContext();
|
|
||||||
WebContext* wiki = new WikipediaContext();
|
|
||||||
/*WebContext* lastfm = new LastfmContext();*/
|
|
||||||
|
|
||||||
m_views << ttc;
|
|
||||||
m_views << rac;
|
|
||||||
m_views << wiki;
|
|
||||||
/* m_views << lastfm;*/
|
|
||||||
|
|
||||||
foreach ( ContextPage* view, m_views )
|
|
||||||
{
|
|
||||||
ContextProxyPage* page = new ContextProxyPage();
|
|
||||||
page->setPage( view );
|
|
||||||
m_scene->addItem( page );
|
|
||||||
|
|
||||||
connect( page, SIGNAL( focused() ), SLOT( onPageFocused() ) );
|
|
||||||
m_pages << page;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->contextView->setScene( m_scene );
|
|
||||||
ui->contextView->setFrameShape( QFrame::NoFrame );
|
|
||||||
ui->contextView->setStyleSheet( "QGraphicsView { background: transparent; }" );
|
|
||||||
ui->contextView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
|
||||||
ui->contextView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
|
||||||
|
|
||||||
ui->contextView->hide();
|
|
||||||
|
|
||||||
QPalette whitePal = ui->toggleButton->palette();
|
|
||||||
whitePal.setColor( QPalette::Foreground, Qt::white );
|
|
||||||
ui->toggleButton->setPalette( whitePal );
|
|
||||||
ui->toggleButton->setCursor( Qt::PointingHandCursor );
|
|
||||||
|
|
||||||
m_minHeight = TomahawkUtils::defaultFontHeight() * 1.4;
|
|
||||||
ui->toggleButton->setMinimumHeight( m_minHeight );
|
|
||||||
|
|
||||||
setAutoFillBackground( true );
|
|
||||||
setFixedHeight( m_minHeight );
|
|
||||||
|
|
||||||
ensurePolished();
|
|
||||||
QPalette pal = palette();
|
|
||||||
pal.setBrush( QPalette::Window, TomahawkStyle::FOOTNOTES_BACKGROUND );
|
|
||||||
setPalette( pal );
|
|
||||||
|
|
||||||
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( toggleSize() ) );
|
|
||||||
|
|
||||||
m_timeLine = new QTimeLine( ANIMATION_TIME, this );
|
|
||||||
m_timeLine->setUpdateInterval( 20 );
|
|
||||||
m_timeLine->setEasingCurve( QEasingCurve::OutCubic );
|
|
||||||
|
|
||||||
connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
|
|
||||||
connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ContextWidget::~ContextWidget()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::changeEvent( QEvent* e )
|
|
||||||
{
|
|
||||||
QWidget::changeEvent( e );
|
|
||||||
switch ( e->type() )
|
|
||||||
{
|
|
||||||
case QEvent::LanguageChange:
|
|
||||||
ui->retranslateUi( this );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::layoutViews( bool animate )
|
|
||||||
{
|
|
||||||
int smallViewWidth = 120;
|
|
||||||
float smallViewOpacity = 0.6;
|
|
||||||
|
|
||||||
int margin = 6;
|
|
||||||
int maxVisible = 2;
|
|
||||||
int itemSize = ( m_scene->sceneRect().width() - smallViewWidth * 2 ) / maxVisible;
|
|
||||||
int firstPos = margin;
|
|
||||||
float opacity;
|
|
||||||
|
|
||||||
if ( m_currentView > 0 )
|
|
||||||
firstPos = smallViewWidth;
|
|
||||||
|
|
||||||
if ( m_currentView + maxVisible >= m_pages.count() )
|
|
||||||
{
|
|
||||||
int delta = m_pages.count() - m_currentView;
|
|
||||||
firstPos = m_scene->sceneRect().width() - ( delta * itemSize ) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( int i = 0; i < m_pages.count(); i++ )
|
|
||||||
{
|
|
||||||
QGraphicsWidget* view = m_pages.at( i );
|
|
||||||
|
|
||||||
int x = firstPos - ( ( m_currentView - i ) * itemSize );
|
|
||||||
|
|
||||||
if ( ( x < smallViewWidth && x < firstPos ) || i > m_currentView + maxVisible - 1 )
|
|
||||||
{
|
|
||||||
opacity = smallViewOpacity;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
opacity = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation( view, "opacity" );
|
|
||||||
animation->setDuration( SLIDE_TIME );
|
|
||||||
animation->setEndValue( opacity );
|
|
||||||
animation->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect rect( x, margin, itemSize - margin * 2, m_scene->sceneRect().height() - margin * 2 );
|
|
||||||
if ( animate )
|
|
||||||
{
|
|
||||||
{
|
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation( view, "geometry" );
|
|
||||||
animation->setDuration( SLIDE_TIME );
|
|
||||||
animation->setEndValue( rect );
|
|
||||||
animation->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
view->setGeometry( rect );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::onPageFocused()
|
|
||||||
{
|
|
||||||
ContextProxyPage* widget = qobject_cast< ContextProxyPage* >( sender() );
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach ( ContextProxyPage* view, m_pages )
|
|
||||||
{
|
|
||||||
if ( view == widget )
|
|
||||||
{
|
|
||||||
m_currentView = i;
|
|
||||||
layoutViews( true );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::fadeOut( bool animate )
|
|
||||||
{
|
|
||||||
foreach ( QGraphicsWidget* view, m_pages )
|
|
||||||
{
|
|
||||||
if ( animate )
|
|
||||||
{
|
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation( view, "opacity" );
|
|
||||||
animation->setDuration( SLIDE_TIME );
|
|
||||||
animation->setEndValue( 0.0 );
|
|
||||||
animation->start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
view->setOpacity( 0.0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::setArtist( const Tomahawk::artist_ptr& artist )
|
|
||||||
{
|
|
||||||
if ( artist.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_artist = artist;
|
|
||||||
if ( height() > m_minHeight )
|
|
||||||
{
|
|
||||||
foreach ( ContextProxyPage* proxy, m_pages )
|
|
||||||
{
|
|
||||||
proxy->page()->setArtist( artist );
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutViews( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::setAlbum( const Tomahawk::album_ptr& album )
|
|
||||||
{
|
|
||||||
if ( album.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_album = album;
|
|
||||||
if ( height() > m_minHeight )
|
|
||||||
{
|
|
||||||
foreach ( ContextProxyPage* proxy, m_pages )
|
|
||||||
{
|
|
||||||
proxy->page()->setAlbum( album );
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutViews( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::setQuery( const Tomahawk::query_ptr& query, bool force )
|
|
||||||
{
|
|
||||||
if ( query.isNull() )
|
|
||||||
return;
|
|
||||||
if ( !force && !m_query.isNull() && query->track()->artist() == m_query->track()->artist() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_query = query;
|
|
||||||
if ( height() > m_minHeight )
|
|
||||||
{
|
|
||||||
foreach ( ContextProxyPage* proxy, m_pages )
|
|
||||||
{
|
|
||||||
proxy->page()->setQuery( query );
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutViews( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::toggleSize()
|
|
||||||
{
|
|
||||||
m_maxHeight = TomahawkUtils::tomahawkWindow()->height() * 0.3;
|
|
||||||
|
|
||||||
if ( height() == m_minHeight )
|
|
||||||
{
|
|
||||||
m_timeLine->setFrameRange( height(), m_maxHeight );
|
|
||||||
m_timeLine->setDirection( QTimeLine::Forward );
|
|
||||||
m_timeLine->start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_visible = false;
|
|
||||||
ui->contextView->hide();
|
|
||||||
|
|
||||||
m_timeLine->setFrameRange( m_minHeight, height() );
|
|
||||||
m_timeLine->setDirection( QTimeLine::Backward );
|
|
||||||
m_timeLine->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::onAnimationStep( int frame )
|
|
||||||
{
|
|
||||||
setFixedHeight( frame );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::onAnimationFinished()
|
|
||||||
{
|
|
||||||
if ( m_timeLine->direction() == QTimeLine::Forward )
|
|
||||||
{
|
|
||||||
setFixedHeight( m_maxHeight );
|
|
||||||
m_visible = true;
|
|
||||||
ui->contextView->show();
|
|
||||||
|
|
||||||
fadeOut( false );
|
|
||||||
m_scene->setSceneRect( ui->contextView->viewport()->rect() );
|
|
||||||
layoutViews( false );
|
|
||||||
setArtist( m_artist );
|
|
||||||
setAlbum( m_album );
|
|
||||||
setQuery( m_query, true );
|
|
||||||
|
|
||||||
ui->toggleButton->setText( tr( "Hide Footnotes" ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setFixedHeight( m_minHeight );
|
|
||||||
|
|
||||||
ui->toggleButton->setText( tr( "Show Footnotes" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::paintEvent( QPaintEvent* e )
|
|
||||||
{
|
|
||||||
QWidget::paintEvent( e );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ContextWidget::resizeEvent( QResizeEvent* e )
|
|
||||||
{
|
|
||||||
QWidget::resizeEvent( e );
|
|
||||||
|
|
||||||
if ( m_visible )
|
|
||||||
{
|
|
||||||
m_scene->setSceneRect( ui->contextView->viewport()->rect() );
|
|
||||||
layoutViews( false );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,93 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 CONTEXTWIDGET_H
|
|
||||||
#define CONTEXTWIDGET_H
|
|
||||||
|
|
||||||
#include <QGraphicsView>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include "Query.h"
|
|
||||||
|
|
||||||
class QGraphicsScene;
|
|
||||||
class QGraphicsWebView;
|
|
||||||
class QGraphicsWidget;
|
|
||||||
class QTimeLine;
|
|
||||||
|
|
||||||
namespace Tomahawk
|
|
||||||
{
|
|
||||||
class ContextPage;
|
|
||||||
class ContextProxyPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Ui
|
|
||||||
{
|
|
||||||
class ContextWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DLLEXPORT ContextWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ContextWidget( QWidget* parent = 0 );
|
|
||||||
~ContextWidget();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setArtist( const Tomahawk::artist_ptr& artist );
|
|
||||||
void setAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
void setQuery( const Tomahawk::query_ptr& query, bool force = false );
|
|
||||||
|
|
||||||
void toggleSize();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onPageFocused();
|
|
||||||
|
|
||||||
void onAnimationStep( int frame );
|
|
||||||
void onAnimationFinished();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent( QPaintEvent* e );
|
|
||||||
void resizeEvent( QResizeEvent* e );
|
|
||||||
void changeEvent( QEvent* e );
|
|
||||||
|
|
||||||
private:
|
|
||||||
void fadeOut( bool animate );
|
|
||||||
|
|
||||||
void layoutViews( bool animate = true );
|
|
||||||
|
|
||||||
Ui::ContextWidget* ui;
|
|
||||||
|
|
||||||
int m_minHeight;
|
|
||||||
int m_maxHeight;
|
|
||||||
QTimeLine* m_timeLine;
|
|
||||||
|
|
||||||
QGraphicsScene* m_scene;
|
|
||||||
QList<Tomahawk::ContextPage*> m_views;
|
|
||||||
QList<Tomahawk::ContextProxyPage*> m_pages;
|
|
||||||
|
|
||||||
int m_currentView;
|
|
||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
|
||||||
Tomahawk::album_ptr m_album;
|
|
||||||
Tomahawk::query_ptr m_query;
|
|
||||||
bool m_visible;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CONTEXTWIDGET_H
|
|
@@ -1,76 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ContextWidget</class>
|
|
||||||
<widget class="QWidget" name="ContextWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>774</width>
|
|
||||||
<height>173</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>72</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string notr="true" comment="not translatable because not shown to the user">InfoBar</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="HeaderLabel" name="toggleButton">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Show Footnotes</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>1</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGraphicsView" name="contextView"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>HeaderLabel</class>
|
|
||||||
<extends>QLabel</extends>
|
|
||||||
<header location="global">widgets/HeaderLabel.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
@@ -1,107 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 "RelatedArtistsContext.h"
|
|
||||||
|
|
||||||
#include <QHeaderView>
|
|
||||||
|
|
||||||
#include "playlist/TreeView.h"
|
|
||||||
#include "playlist/TreeModel.h"
|
|
||||||
#include "Source.h"
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
RelatedArtistsContext::RelatedArtistsContext()
|
|
||||||
: ContextPage()
|
|
||||||
{
|
|
||||||
m_relatedView = new TreeView();
|
|
||||||
m_relatedView->setGuid( "RelatedArtistsContext" );
|
|
||||||
m_relatedView->setUpdatesContextView( false );
|
|
||||||
m_relatedModel = new TreeModel( m_relatedView );
|
|
||||||
m_relatedView->proxyModel()->setStyle( PlayableProxyModel::Large );
|
|
||||||
m_relatedView->setTreeModel( m_relatedModel );
|
|
||||||
m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
||||||
m_relatedView->setSortingEnabled( false );
|
|
||||||
m_relatedView->proxyModel()->sort( -1 );
|
|
||||||
|
|
||||||
QPalette pal = m_relatedView->palette();
|
|
||||||
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
|
||||||
m_relatedView->setPalette( pal );
|
|
||||||
|
|
||||||
m_proxy = new QGraphicsProxyWidget();
|
|
||||||
m_proxy->setWidget( m_relatedView );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RelatedArtistsContext::~RelatedArtistsContext()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RelatedArtistsContext::setArtist( const Tomahawk::artist_ptr& artist )
|
|
||||||
{
|
|
||||||
if ( artist.isNull() )
|
|
||||||
return;
|
|
||||||
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !m_artist.isNull() )
|
|
||||||
{
|
|
||||||
disconnect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), this, SLOT( onSimilarArtistsLoaded() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_artist = artist;
|
|
||||||
|
|
||||||
connect( m_artist.data(), SIGNAL( similarArtistsLoaded() ), SLOT( onSimilarArtistsLoaded() ) );
|
|
||||||
|
|
||||||
m_relatedModel->clear();
|
|
||||||
onSimilarArtistsLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
if ( query.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( query->track()->artistPtr() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RelatedArtistsContext::setAlbum( const Tomahawk::album_ptr& album )
|
|
||||||
{
|
|
||||||
if ( album.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( album->artist() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RelatedArtistsContext::onSimilarArtistsLoaded()
|
|
||||||
{
|
|
||||||
foreach ( const artist_ptr& artist, m_artist->similarArtists() )
|
|
||||||
{
|
|
||||||
m_relatedModel->addArtists( artist );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 RELATEDARTISTSCONTEXT_H
|
|
||||||
#define RELATEDARTISTSCONTEXT_H
|
|
||||||
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include "Artist.h"
|
|
||||||
#include "Album.h"
|
|
||||||
#include "Query.h"
|
|
||||||
#include "context/ContextPage.h"
|
|
||||||
|
|
||||||
class TreeModel;
|
|
||||||
class TreeView;
|
|
||||||
|
|
||||||
class DLLEXPORT RelatedArtistsContext : public Tomahawk::ContextPage
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
RelatedArtistsContext();
|
|
||||||
~RelatedArtistsContext();
|
|
||||||
|
|
||||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
|
||||||
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Related Artists" ); }
|
|
||||||
virtual QString description() const { return QString(); }
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() { return false; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void setArtist( const Tomahawk::artist_ptr& artist );
|
|
||||||
virtual void setAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onSimilarArtistsLoaded();
|
|
||||||
|
|
||||||
private:
|
|
||||||
TreeView* m_relatedView;
|
|
||||||
TreeModel* m_relatedModel;
|
|
||||||
|
|
||||||
QGraphicsProxyWidget* m_proxy;
|
|
||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RELATEDARTISTSCONTEXT_H
|
|
@@ -1,106 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 "TopTracksContext.h"
|
|
||||||
|
|
||||||
#include "playlist/PlaylistModel.h"
|
|
||||||
#include "playlist/PlaylistView.h"
|
|
||||||
#include "Source.h"
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
TopTracksContext::TopTracksContext()
|
|
||||||
: ContextPage()
|
|
||||||
{
|
|
||||||
m_topHitsView = new PlaylistView();
|
|
||||||
m_topHitsView->setGuid( "TopTracksContext" );
|
|
||||||
m_topHitsView->setUpdatesContextView( false );
|
|
||||||
m_topHitsModel = new PlaylistModel( m_topHitsView );
|
|
||||||
m_topHitsView->proxyModel()->setStyle( PlayableProxyModel::Short );
|
|
||||||
m_topHitsView->setPlaylistModel( m_topHitsModel );
|
|
||||||
m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
||||||
|
|
||||||
QPalette pal = m_topHitsView->palette();
|
|
||||||
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
|
||||||
m_topHitsView->setPalette( pal );
|
|
||||||
|
|
||||||
m_proxy = new QGraphicsProxyWidget();
|
|
||||||
m_proxy->setWidget( m_topHitsView );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TopTracksContext::~TopTracksContext()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TopTracksContext::setArtist( const Tomahawk::artist_ptr& artist )
|
|
||||||
{
|
|
||||||
if ( artist.isNull() )
|
|
||||||
return;
|
|
||||||
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( !m_artist.isNull() )
|
|
||||||
{
|
|
||||||
disconnect( m_artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
|
||||||
this, SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_artist = artist;
|
|
||||||
|
|
||||||
connect( m_artist.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
|
|
||||||
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode ) ) );
|
|
||||||
|
|
||||||
m_topHitsModel->clear();
|
|
||||||
onTracksFound( m_artist->tracks(), Mixed );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TopTracksContext::setAlbum( const Tomahawk::album_ptr& album )
|
|
||||||
{
|
|
||||||
if ( album.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( album->artist() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
if ( query.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( query->track()->artistPtr() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TopTracksContext::onTracksFound( const QList<Tomahawk::query_ptr>& queries, ModelMode mode )
|
|
||||||
{
|
|
||||||
Q_UNUSED( mode );
|
|
||||||
|
|
||||||
m_topHitsModel->appendQueries( queries );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,69 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 TOPTRACKSCONTEXT_H
|
|
||||||
#define TOPTRACKSCONTEXT_H
|
|
||||||
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include "Artist.h"
|
|
||||||
#include "Album.h"
|
|
||||||
#include "Query.h"
|
|
||||||
#include "context/ContextPage.h"
|
|
||||||
|
|
||||||
class PlaylistModel;
|
|
||||||
class PlaylistView;
|
|
||||||
|
|
||||||
class DLLEXPORT TopTracksContext : public Tomahawk::ContextPage
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
TopTracksContext();
|
|
||||||
~TopTracksContext();
|
|
||||||
|
|
||||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
|
||||||
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Top Hits" ); }
|
|
||||||
virtual QString description() const { return QString(); }
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() { return false; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void setArtist( const Tomahawk::artist_ptr& artist );
|
|
||||||
virtual void setAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onTracksFound( const QList<Tomahawk::query_ptr>& queries, Tomahawk::ModelMode mode );
|
|
||||||
|
|
||||||
private:
|
|
||||||
PlaylistView* m_topHitsView;
|
|
||||||
PlaylistModel* m_topHitsModel;
|
|
||||||
|
|
||||||
QGraphicsProxyWidget* m_proxy;
|
|
||||||
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TOPTRACKSCONTEXT_H
|
|
@@ -1,38 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "WebContext.h"
|
|
||||||
#include "Source.h"
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
WebContext::WebContext()
|
|
||||||
: ContextPage()
|
|
||||||
{
|
|
||||||
m_webView = new QGraphicsWebView();
|
|
||||||
|
|
||||||
QPalette pal = m_webView->palette();
|
|
||||||
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
|
||||||
m_webView->setPalette( pal );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebContext::~WebContext()
|
|
||||||
{
|
|
||||||
}
|
|
@@ -1,45 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 WEBCONTEXT_H
|
|
||||||
#define WEBCONTEXT_H
|
|
||||||
|
|
||||||
#include <QGraphicsWebView>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include "Query.h"
|
|
||||||
#include "context/ContextPage.h"
|
|
||||||
|
|
||||||
class DLLEXPORT WebContext : public Tomahawk::ContextPage
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
WebContext();
|
|
||||||
~WebContext();
|
|
||||||
|
|
||||||
QGraphicsWebView* webView() const { return m_webView; }
|
|
||||||
virtual QGraphicsWidget* widget() { return m_webView; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QGraphicsWebView* m_webView;
|
|
||||||
Tomahawk::query_ptr m_query;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WEBCONTEXT_H
|
|
@@ -1,98 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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 "WikipediaContext.h"
|
|
||||||
#include "Source.h"
|
|
||||||
#include "Track.h"
|
|
||||||
|
|
||||||
// Forward Declarations breaking QSharedPointer
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
|
|
||||||
#include "PlaylistInterface.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WikipediaContext::setArtist( const Tomahawk::artist_ptr& artist )
|
|
||||||
{
|
|
||||||
if ( artist.isNull() )
|
|
||||||
return;
|
|
||||||
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_artist = artist;
|
|
||||||
|
|
||||||
QString lang = QLocale::system().name().split("_").first();
|
|
||||||
webView()->load( QString( "http://%1.wikipedia.org/w/index.php?useformat=mobile&title=%2" ).arg( lang ).arg( m_artist->name() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WikipediaContext::setAlbum( const Tomahawk::album_ptr& album )
|
|
||||||
{
|
|
||||||
if ( album.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( album->artist() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
if ( query.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( query->track()->artistPtr() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
LastfmContext::setArtist( const Tomahawk::artist_ptr& artist )
|
|
||||||
{
|
|
||||||
if ( artist.isNull() )
|
|
||||||
return;
|
|
||||||
if ( !m_artist.isNull() && m_artist->name() == artist->name() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_artist = artist;
|
|
||||||
|
|
||||||
webView()->load( QString( "http://last.fm/music/%1" ).arg( m_artist->name() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
LastfmContext::setAlbum( const Tomahawk::album_ptr& album )
|
|
||||||
{
|
|
||||||
if ( album.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( album->artist() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
LastfmContext::setQuery( const Tomahawk::query_ptr& query )
|
|
||||||
{
|
|
||||||
if ( query.isNull() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
setArtist( query->track()->artistPtr() );
|
|
||||||
}
|
|
@@ -1,81 +0,0 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
|
||||||
*
|
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
|
||||||
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.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 WIKIPEDIACONTEXT_H
|
|
||||||
#define WIKIPEDIACONTEXT_H
|
|
||||||
|
|
||||||
#include <QGraphicsProxyWidget>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
|
||||||
|
|
||||||
#include "Artist.h"
|
|
||||||
#include "Album.h"
|
|
||||||
#include "Query.h"
|
|
||||||
#include "WebContext.h"
|
|
||||||
|
|
||||||
class DLLEXPORT WikipediaContext : public WebContext
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
WikipediaContext() : WebContext() {}
|
|
||||||
~WikipediaContext() {}
|
|
||||||
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Wikipedia" ); }
|
|
||||||
virtual QString description() const { return QString(); }
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() { return false; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void setArtist( const Tomahawk::artist_ptr& artist );
|
|
||||||
virtual void setAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT LastfmContext : public WebContext
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
LastfmContext() : WebContext() {}
|
|
||||||
~LastfmContext() {}
|
|
||||||
|
|
||||||
virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return Tomahawk::playlistinterface_ptr(); }
|
|
||||||
|
|
||||||
virtual QString title() const { return tr( "Last.fm" ); }
|
|
||||||
virtual QString description() const { return QString(); }
|
|
||||||
|
|
||||||
virtual bool jumpToCurrentTrack() { return false; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
virtual void setArtist( const Tomahawk::artist_ptr& artist );
|
|
||||||
virtual void setAlbum( const Tomahawk::album_ptr& album );
|
|
||||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Tomahawk::artist_ptr m_artist;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WIKIPEDIACONTEXT_H
|
|
Reference in New Issue
Block a user