mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 23:39:42 +01:00
* Added initial ContextView. Yikes.
This commit is contained in:
parent
5dfb3ccc5c
commit
a467b8f2e8
@ -40,6 +40,13 @@ set( libSources
|
||||
|
||||
audio/audioengine.cpp
|
||||
|
||||
context/ContextPage.cpp
|
||||
context/ContextWidget.cpp
|
||||
context/pages/TopTracksContext.cpp
|
||||
context/pages/RelatedArtistsContext.cpp
|
||||
context/pages/WikipediaContext.cpp
|
||||
context/pages/WebContext.cpp
|
||||
|
||||
database/database.cpp
|
||||
database/fuzzyindex.cpp
|
||||
database/databasecollection.cpp
|
||||
@ -234,6 +241,13 @@ set( libHeaders
|
||||
|
||||
audio/audioengine.h
|
||||
|
||||
context/ContextPage.h
|
||||
context/ContextWidget.h
|
||||
context/pages/TopTracksContext.h
|
||||
context/pages/RelatedArtistsContext.h
|
||||
context/pages/WikipediaContext.h
|
||||
context/pages/WebContext.h
|
||||
|
||||
database/database.h
|
||||
database/fuzzyindex.h
|
||||
database/databaseworker.h
|
||||
@ -417,6 +431,7 @@ set( libUI ${libUI}
|
||||
widgets/infowidgets/AlbumInfoWidget.ui
|
||||
playlist/topbar/topbar.ui
|
||||
playlist/infobar/infobar.ui
|
||||
context/ContextWidget.ui
|
||||
)
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ..
|
||||
|
94
src/libtomahawk/context/ContextPage.cpp
Normal file
94
src/libtomahawk/context/ContextPage.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/* === 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>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
void
|
||||
ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
painter->setPen( StyleHelper::headerHighlightColor() );
|
||||
painter->setBrush( StyleHelper::headerHighlightColor() );
|
||||
painter->drawRoundedRect( option->rect, 4.0, 4.0 );
|
||||
|
||||
QFont f( font() );
|
||||
f.setBold( true );
|
||||
f.setPixelSize( 14 );
|
||||
painter->setFont( f );
|
||||
painter->setPen( Qt::white );
|
||||
|
||||
QRect r( 1, 1, option->rect.width(), 19 );
|
||||
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;
|
||||
|
||||
QGraphicsWebView* testWebView = qobject_cast<QGraphicsWebView*>( page->widget() );
|
||||
if ( testWebView )
|
||||
{
|
||||
setContentsMargins( 4, 4, 4, 4 );
|
||||
}
|
||||
|
||||
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
|
||||
layout->setContentsMargins( 4, 20, 4, 4 );
|
||||
layout->addItem( page->widget() );
|
||||
setLayout( layout );
|
||||
|
||||
page->widget()->installEventFilter( this );
|
||||
page->widget()->installSceneEventFilter( 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 );
|
||||
}
|
91
src/libtomahawk/context/ContextPage.h
Normal file
91
src/libtomahawk/context/ContextPage.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* === 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 CONTEXTPAGE_H
|
||||
#define CONTEXTPAGE_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsWebView>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "utils/stylehelper.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
#include <signal.h>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT ContextPage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ContextPage() {}
|
||||
virtual ~ContextPage() {}
|
||||
|
||||
virtual QGraphicsWidget* widget() = 0;
|
||||
virtual Tomahawk::PlaylistInterface* 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 setQuery( const Tomahawk::query_ptr& query ) = 0;
|
||||
|
||||
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
|
293
src/libtomahawk/context/ContextWidget.cpp
Normal file
293
src/libtomahawk/context/ContextWidget.cpp
Normal file
@ -0,0 +1,293 @@
|
||||
/* === 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 "playlist/artistview.h"
|
||||
#include "playlist/treemodel.h"
|
||||
|
||||
#define ANIMATION_TIME 450
|
||||
#define SLIDE_TIME 350
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
ContextWidget::ContextWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::ContextWidget )
|
||||
, m_minHeight( 24 )
|
||||
, m_currentView( 0 )
|
||||
{
|
||||
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( "background: transparent" );
|
||||
ui->contextView->setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||
ui->contextView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
ui->contextView->hide();
|
||||
|
||||
QPalette p = palette();
|
||||
p.setBrush( QPalette::Window, QColor( 0x70, 0x70, 0x70 ) );
|
||||
setPalette( p );
|
||||
|
||||
QPalette whitePal = ui->toggleButton->palette();
|
||||
whitePal.setColor( QPalette::Foreground, Qt::white );
|
||||
ui->toggleButton->setPalette( whitePal );
|
||||
|
||||
QFont boldFont = ui->toggleButton->font();
|
||||
boldFont.setPixelSize( 12 );
|
||||
boldFont.setBold( true );
|
||||
ui->toggleButton->setFont( boldFont );
|
||||
ui->toggleButton->setText( tr( "Open Dashboard" ) );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
setFixedHeight( m_minHeight );
|
||||
|
||||
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::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::setQuery( const Tomahawk::query_ptr& query, bool force )
|
||||
{
|
||||
if ( query.isNull() )
|
||||
return;
|
||||
if ( !force && !m_query.isNull() && query->artist() == m_query->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 )
|
||||
{
|
||||
ui->toggleButton->setText( tr( "Close Dashboard" ) );
|
||||
|
||||
m_timeLine->setFrameRange( height(), m_maxHeight );
|
||||
m_timeLine->setDirection( QTimeLine::Forward );
|
||||
m_timeLine->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->toggleButton->setText( tr( "Open Dashboard" ) );
|
||||
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 );
|
||||
ui->contextView->show();
|
||||
|
||||
fadeOut( false );
|
||||
m_scene->setSceneRect( ui->contextView->viewport()->rect() );
|
||||
layoutViews( false );
|
||||
setQuery( m_query, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFixedHeight( m_minHeight );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContextWidget::resizeEvent( QResizeEvent* e )
|
||||
{
|
||||
QWidget::resizeEvent( e );
|
||||
|
||||
m_scene->setSceneRect( ui->contextView->viewport()->rect() );
|
||||
layoutViews( false );
|
||||
}
|
86
src/libtomahawk/context/ContextWidget.h
Normal file
86
src/libtomahawk/context/ContextWidget.h
Normal file
@ -0,0 +1,86 @@
|
||||
/* === 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 setQuery( const Tomahawk::query_ptr& query, bool force = false );
|
||||
|
||||
void toggleSize();
|
||||
|
||||
private slots:
|
||||
void onPageFocused();
|
||||
|
||||
void onAnimationStep( int frame );
|
||||
void onAnimationFinished();
|
||||
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent* 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::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // CONTEXTWIDGET_H
|
76
src/libtomahawk/context/ContextWidget.ui
Normal file
76
src/libtomahawk/context/ContextWidget.ui
Normal file
@ -0,0 +1,76 @@
|
||||
<?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>72</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>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>Dashboard</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</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>
|
125
src/libtomahawk/context/pages/RelatedArtistsContext.cpp
Normal file
125
src/libtomahawk/context/pages/RelatedArtistsContext.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/* === 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 "RelatedArtistsContext.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "playlist/artistview.h"
|
||||
#include "playlist/treemodel.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
RelatedArtistsContext::RelatedArtistsContext()
|
||||
: ContextPage()
|
||||
, m_infoId( uuid() )
|
||||
{
|
||||
m_relatedView = new ArtistView();
|
||||
m_relatedModel = new TreeModel( m_relatedView );
|
||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
m_relatedView->setTreeModel( m_relatedModel );
|
||||
m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_relatedView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_relatedView->header()->setVisible( false );
|
||||
m_relatedView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
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 );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
}
|
||||
|
||||
|
||||
RelatedArtistsContext::~RelatedArtistsContext()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RelatedArtistsContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
|
||||
artistInfo["artist"] = query->artist();
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = m_infoId;
|
||||
requestData.customData = QVariantMap();
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
|
||||
|
||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSimilars;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RelatedArtistsContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != m_infoId )
|
||||
return;
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
|
||||
if ( output.canConvert< QVariantMap >() )
|
||||
{
|
||||
if ( trackInfo["artist"] != m_query->artist() )
|
||||
{
|
||||
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_query->artist();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoSystem::InfoArtistSimilars:
|
||||
{
|
||||
m_relatedModel->clear();
|
||||
const QStringList artists = returnedData["artists"].toStringList();
|
||||
foreach ( const QString& artist, artists )
|
||||
{
|
||||
m_relatedModel->addArtists( Artist::get( artist ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RelatedArtistsContext::infoSystemFinished( QString target )
|
||||
{
|
||||
Q_UNUSED( target );
|
||||
}
|
67
src/libtomahawk/context/pages/RelatedArtistsContext.h
Normal file
67
src/libtomahawk/context/pages/RelatedArtistsContext.h
Normal file
@ -0,0 +1,67 @@
|
||||
/* === 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 RELATEDARTISTSCONTEXT_H
|
||||
#define RELATEDARTISTSCONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "context/ContextPage.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
class TreeModel;
|
||||
class ArtistView;
|
||||
|
||||
class DLLEXPORT RelatedArtistsContext : public Tomahawk::ContextPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RelatedArtistsContext();
|
||||
~RelatedArtistsContext();
|
||||
|
||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Related Artists" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
ArtistView* m_relatedView;
|
||||
TreeModel* m_relatedModel;
|
||||
|
||||
QGraphicsProxyWidget* m_proxy;
|
||||
|
||||
QString m_infoId;
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // RELATEDARTISTSCONTEXT_H
|
128
src/libtomahawk/context/pages/TopTracksContext.cpp
Normal file
128
src/libtomahawk/context/pages/TopTracksContext.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
/* === 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 "TopTracksContext.h"
|
||||
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "playlist/playlistview.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
TopTracksContext::TopTracksContext()
|
||||
: ContextPage()
|
||||
, m_infoId( uuid() )
|
||||
{
|
||||
m_topHitsView = new PlaylistView();
|
||||
m_topHitsView->setUpdatesContextView( false );
|
||||
m_topHitsModel = new PlaylistModel( m_topHitsView );
|
||||
m_topHitsModel->setStyle( TrackModel::Short );
|
||||
m_topHitsView->setTrackModel( m_topHitsModel );
|
||||
m_topHitsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
m_topHitsView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
|
||||
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 );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||
|
||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
}
|
||||
|
||||
|
||||
TopTracksContext::~TopTracksContext()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopTracksContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash artistInfo;
|
||||
artistInfo["artist"] = query->artist();
|
||||
|
||||
Tomahawk::InfoSystem::InfoRequestData requestData;
|
||||
requestData.caller = m_infoId;
|
||||
requestData.customData = QVariantMap();
|
||||
requestData.input = QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( artistInfo );
|
||||
|
||||
requestData.type = Tomahawk::InfoSystem::InfoArtistSongs;
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopTracksContext::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != m_infoId )
|
||||
return;
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
|
||||
if ( output.canConvert< QVariantMap >() )
|
||||
{
|
||||
if ( trackInfo["artist"] != m_query->artist() )
|
||||
{
|
||||
qDebug() << "Returned info was for:" << trackInfo["artist"] << "- was looking for:" << m_query->artist();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
case InfoSystem::InfoArtistSongs:
|
||||
{
|
||||
m_topHitsModel->clear();
|
||||
const QStringList tracks = returnedData["tracks"].toStringList();
|
||||
|
||||
int i = 0;
|
||||
foreach ( const QString& track, tracks )
|
||||
{
|
||||
query_ptr query = Query::get( m_query->artist(), track, QString(), uuid() );
|
||||
m_topHitsModel->append( query );
|
||||
|
||||
if ( ++i == 15 )
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TopTracksContext::infoSystemFinished( QString target )
|
||||
{
|
||||
Q_UNUSED( target );
|
||||
}
|
67
src/libtomahawk/context/pages/TopTracksContext.h
Normal file
67
src/libtomahawk/context/pages/TopTracksContext.h
Normal file
@ -0,0 +1,67 @@
|
||||
/* === 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 TOPTRACKSCONTEXT_H
|
||||
#define TOPTRACKSCONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "context/ContextPage.h"
|
||||
#include "infosystem/infosystem.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* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Top Hits" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
PlaylistView* m_topHitsView;
|
||||
PlaylistModel* m_topHitsModel;
|
||||
|
||||
QGraphicsProxyWidget* m_proxy;
|
||||
|
||||
QString m_infoId;
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // TOPTRACKSCONTEXT_H
|
37
src/libtomahawk/context/pages/WebContext.cpp
Normal file
37
src/libtomahawk/context/pages/WebContext.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* === 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"
|
||||
|
||||
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()
|
||||
{
|
||||
}
|
45
src/libtomahawk/context/pages/WebContext.h
Normal file
45
src/libtomahawk/context/pages/WebContext.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* === 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
|
43
src/libtomahawk/context/pages/WikipediaContext.cpp
Normal file
43
src/libtomahawk/context/pages/WikipediaContext.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
/* === 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"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
void
|
||||
WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
webView()->load( QString( "http://en.wikipedia.org/w/index.php?printable=yes&title=%1" ).arg( query->artist() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastfmContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
webView()->load( QString( "http://last.fm/music/%1" ).arg( query->artist() ) );
|
||||
}
|
74
src/libtomahawk/context/pages/WikipediaContext.h
Normal file
74
src/libtomahawk/context/pages/WikipediaContext.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* === 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 WIKIPEDIACONTEXT_H
|
||||
#define WIKIPEDIACONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "WebContext.h"
|
||||
|
||||
class DLLEXPORT WikipediaContext : public WebContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WikipediaContext() : WebContext() {}
|
||||
~WikipediaContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Wikipedia" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private:
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT LastfmContext : public WebContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LastfmContext() : WebContext() {}
|
||||
~LastfmContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Last.fm" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private:
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // WIKIPEDIACONTEXT_H
|
@ -467,7 +467,7 @@ GlobalActionManager::handleSearchCommand( const QUrl& url )
|
||||
return false;
|
||||
|
||||
ViewManager::instance()->showSuperCollection();
|
||||
ViewManager::instance()->topbar()->setFilter( queryStr );
|
||||
// ViewManager::instance()->topbar()->setFilter( queryStr );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -20,22 +20,25 @@
|
||||
#include "ui_infobar.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "context/ContextWidget.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#define ANIMATION_TIME 400
|
||||
#define IMAGE_HEIGHT 64
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
InfoBar::InfoBar( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::InfoBar )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
layout()->setSpacing( 0 );
|
||||
layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
TomahawkUtils::unmarginLayout( layout() );
|
||||
layout()->setContentsMargins( 8, 4, 8, 4 );
|
||||
|
||||
QFont boldFont = ui->captionLabel->font();
|
||||
boldFont.setPixelSize( 18 );
|
||||
|
@ -23,6 +23,11 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
|
||||
class QTimeLine;
|
||||
class ContextWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class InfoBar;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>72</height>
|
||||
<width>774</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -25,168 +25,149 @@
|
||||
<property name="windowTitle">
|
||||
<string>InfoBar</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,1,0,99,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="captionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="descriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="longDescriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>62</height>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>1</height>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="captionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="descriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="longDescriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -117,7 +117,7 @@ PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const
|
||||
opacity = item->query()->results().first()->score();
|
||||
|
||||
opacity = qMax( (float)0.3, opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option->palette.color( QPalette::Foreground ), option->palette.color( QPalette::Background ), opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option->palette.color( QPalette::Text ), option->palette.color( QPalette::BrightText ), opacity );
|
||||
|
||||
option->palette.setColor( QPalette::Text, textColor );
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ PlaylistModel::clear()
|
||||
emit beginResetModel();
|
||||
delete m_rootItem;
|
||||
m_rootItem = 0;
|
||||
emit endResetModel();
|
||||
m_rootItem = new TrackModelItem( 0, this );
|
||||
emit endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@
|
||||
|
||||
#include "trackheader.h"
|
||||
#include "viewmanager.h"
|
||||
#include "queueview.h"
|
||||
#include "trackmodel.h"
|
||||
#include "trackproxymodel.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "context/ContextWidget.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
#include "dynamic/widgets/LoadingSpinner.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
@ -48,6 +48,7 @@ TrackView::TrackView( QWidget* parent )
|
||||
, m_loadingSpinner( new LoadingSpinner( this ) )
|
||||
, m_resizing( false )
|
||||
, m_dragging( false )
|
||||
, m_updateContextView( true )
|
||||
, m_contextMenu( new ContextMenu( this ) )
|
||||
{
|
||||
setMouseTracking( true );
|
||||
@ -154,6 +155,20 @@ TrackView::setTrackModel( TrackModel* model )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackView::currentChanged( const QModelIndex& current, const QModelIndex& /* previous */ )
|
||||
{
|
||||
if ( !m_updateContextView )
|
||||
return;
|
||||
|
||||
TrackModelItem* item = m_model->itemFromIndex( m_proxyModel->mapToSource( current ) );
|
||||
if ( item )
|
||||
{
|
||||
ViewManager::instance()->context()->setQuery( item->query() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackView::onItemActivated( const QModelIndex& index )
|
||||
{
|
||||
|
@ -62,6 +62,9 @@ explicit TrackView( QWidget* parent = 0 );
|
||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||
|
||||
bool updatesContextView() const { return m_updateContextView; }
|
||||
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
||||
|
||||
public slots:
|
||||
void onItemActivated( const QModelIndex& index );
|
||||
|
||||
@ -84,6 +87,9 @@ protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
|
||||
protected slots:
|
||||
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
|
||||
|
||||
private slots:
|
||||
void onItemResized( const QModelIndex& index );
|
||||
void onFilterChanged( const QString& filter );
|
||||
@ -105,6 +111,8 @@ private:
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
|
||||
bool m_updateContextView;
|
||||
|
||||
QModelIndex m_hoveredIndex;
|
||||
QModelIndex m_contextMenuIndex;
|
||||
Tomahawk::ContextMenu* m_contextMenu;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QMetaMethod>
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "context/ContextWidget.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
#include "infobar/infobar.h"
|
||||
#include "topbar/topbar.h"
|
||||
@ -31,7 +32,6 @@
|
||||
#include "collectionview.h"
|
||||
#include "playlistmodel.h"
|
||||
#include "playlistview.h"
|
||||
#include "queueview.h"
|
||||
#include "trackproxymodel.h"
|
||||
#include "trackmodel.h"
|
||||
#include "artistview.h"
|
||||
@ -77,37 +77,27 @@ ViewManager::ViewManager( QObject* parent )
|
||||
|
||||
m_widget->setLayout( new QVBoxLayout() );
|
||||
|
||||
m_topbar = new TopBar();
|
||||
// m_topbar = new TopBar();
|
||||
m_infobar = new InfoBar();
|
||||
m_stack = new QStackedWidget();
|
||||
|
||||
m_splitter = new AnimatedSplitter();
|
||||
/* m_splitter = new AnimatedSplitter();
|
||||
m_splitter->setOrientation( Qt::Vertical );
|
||||
m_splitter->setChildrenCollapsible( false );
|
||||
m_splitter->setGreedyWidget( 0 );
|
||||
m_splitter->addWidget( m_stack );
|
||||
m_splitter->addWidget( m_stack );*/
|
||||
|
||||
m_queueButton = new QPushButton();
|
||||
m_queueButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
#ifdef Q_OS_MAC
|
||||
// QPushButtons on mac have lots of weird layouting issues. Fix them by forcing the widget rect for layout calculations
|
||||
m_queueButton->setAttribute( Qt::WA_LayoutUsesWidgetRect );
|
||||
#endif
|
||||
// m_splitter->addWidget( m_queueView );
|
||||
// m_splitter->hide( 1, false );
|
||||
|
||||
m_queueView = new QueueView( m_splitter );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
m_splitter->addWidget( m_queueView );
|
||||
m_splitter->hide( 1, false );
|
||||
m_contextWidget = new ContextWidget();
|
||||
|
||||
m_widget->layout()->addWidget( m_infobar );
|
||||
m_widget->layout()->addWidget( m_topbar );
|
||||
m_widget->layout()->addWidget( m_splitter );
|
||||
m_widget->layout()->addWidget( m_queueButton );
|
||||
// m_widget->layout()->addWidget( m_topbar );
|
||||
// m_widget->layout()->addWidget( m_splitter );
|
||||
m_widget->layout()->addWidget( m_stack );
|
||||
m_widget->layout()->addWidget( m_contextWidget );
|
||||
// m_widget->layout()->addWidget( m_queueButton );
|
||||
|
||||
m_superCollectionView = new ArtistView();
|
||||
m_superCollectionModel = new TreeModel( m_superCollectionView );
|
||||
@ -132,12 +122,11 @@ ViewManager::ViewManager( QObject* parent )
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||
/* connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||
connect( m_topbar, SIGNAL( flatMode() ), SLOT( setTableMode() ) );
|
||||
connect( m_topbar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) );
|
||||
connect( m_topbar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );
|
||||
connect( m_topbar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/
|
||||
}
|
||||
|
||||
|
||||
@ -148,13 +137,6 @@ ViewManager::~ViewManager()
|
||||
}
|
||||
|
||||
|
||||
PlaylistView*
|
||||
ViewManager::queue() const
|
||||
{
|
||||
return m_queueView->queue();
|
||||
}
|
||||
|
||||
|
||||
PlaylistView*
|
||||
ViewManager::createPageForPlaylist( const playlist_ptr& pl )
|
||||
{
|
||||
@ -218,10 +200,10 @@ ViewManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
|
||||
setPage( m_dynamicWidgets.value( playlist ).data() );
|
||||
|
||||
if ( playlist->mode() == Tomahawk::OnDemand )
|
||||
m_queueView->hide();
|
||||
/* if ( playlist->mode() == Tomahawk::OnDemand )
|
||||
hideQueue();
|
||||
else
|
||||
m_queueView->show();
|
||||
showQueue();*/
|
||||
|
||||
emit numSourcesChanged( SourceList::instance()->count() );
|
||||
|
||||
@ -491,42 +473,6 @@ ViewManager::setAlbumMode()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to hide queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( showQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( hideQueue() ) );
|
||||
|
||||
m_splitter->show( 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( hideQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
m_splitter->hide( 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::historyBack()
|
||||
{
|
||||
@ -699,7 +645,7 @@ ViewManager::updateView()
|
||||
connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
|
||||
m_topbar->setFilter( currentPlaylistInterface()->filter() );
|
||||
// m_topbar->setFilter( currentPlaylistInterface()->filter() );
|
||||
}
|
||||
|
||||
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
||||
@ -716,19 +662,19 @@ ViewManager::updateView()
|
||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||
}
|
||||
|
||||
if ( currentPage()->queueVisible() )
|
||||
m_queueView->show();
|
||||
/* if ( currentPage()->queueVisible() )
|
||||
showQueue();
|
||||
else
|
||||
m_queueView->hide();
|
||||
hideQueue();*/
|
||||
|
||||
emit statsAvailable( currentPage()->showStatsBar() );
|
||||
emit modesAvailable( currentPage()->showModes() );
|
||||
emit filterAvailable( currentPage()->showFilter() );
|
||||
|
||||
if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||
/* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||
m_topbar->setVisible( false );
|
||||
else
|
||||
m_topbar->setVisible( true );
|
||||
m_topbar->setVisible( true );*/
|
||||
|
||||
m_infobar->setVisible( currentPage()->showInfoBar() );
|
||||
m_infobar->setCaption( currentPage()->title() );
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "collection.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "playlist/queueview.h"
|
||||
#include "viewpage.h"
|
||||
#include "widgets/welcomewidget.h"
|
||||
#include "widgets/whatshotwidget.h"
|
||||
@ -40,9 +41,9 @@ class ArtistView;
|
||||
class CollectionModel;
|
||||
class CollectionFlatModel;
|
||||
class CollectionView;
|
||||
class ContextWidget;
|
||||
class PlaylistModel;
|
||||
class PlaylistView;
|
||||
class QueueView;
|
||||
class TrackProxyModel;
|
||||
class TrackModel;
|
||||
class TreeProxyModel;
|
||||
@ -71,8 +72,11 @@ public:
|
||||
~ViewManager();
|
||||
|
||||
QWidget* widget() const { return m_widget; }
|
||||
PlaylistView* queue() const;
|
||||
TopBar* topbar() const { return m_topbar; }
|
||||
InfoBar* infobar() const { return m_infobar; }
|
||||
ContextWidget* context() const { return m_contextWidget; }
|
||||
|
||||
PlaylistView* queue() const { return m_queue->queue(); }
|
||||
void setQueue( QueueView* queue ) { m_queue = queue; }
|
||||
|
||||
bool isSuperCollectionVisible() const;
|
||||
bool isNewPlaylistPageVisible() const;
|
||||
@ -120,6 +124,9 @@ signals:
|
||||
void tempPageActivated( Tomahawk::ViewPage* );
|
||||
void viewPageActivated( Tomahawk::ViewPage* );
|
||||
|
||||
void showQueueRequested();
|
||||
void hideQueueRequested();
|
||||
|
||||
public slots:
|
||||
Tomahawk::ViewPage* showSuperCollection();
|
||||
Tomahawk::ViewPage* showWelcomePage();
|
||||
@ -137,13 +144,13 @@ public slots:
|
||||
void historyBack();
|
||||
void removeFromHistory( Tomahawk::ViewPage* p );
|
||||
|
||||
void showQueue() { emit showQueueRequested(); }
|
||||
void hideQueue() { emit hideQueueRequested(); }
|
||||
|
||||
void setTreeMode();
|
||||
void setTableMode();
|
||||
void setAlbumMode();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void setShuffled( bool enabled );
|
||||
|
||||
@ -172,18 +179,15 @@ private:
|
||||
|
||||
QWidget* m_widget;
|
||||
InfoBar* m_infobar;
|
||||
TopBar* m_topbar;
|
||||
QPushButton* m_queueButton;
|
||||
ContextWidget* m_contextWidget;
|
||||
QStackedWidget* m_stack;
|
||||
AnimatedSplitter* m_splitter;
|
||||
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
|
||||
AlbumModel* m_superAlbumModel;
|
||||
AlbumView* m_superAlbumView;
|
||||
TreeModel* m_superCollectionModel;
|
||||
ArtistView* m_superCollectionView;
|
||||
QueueView* m_queue;
|
||||
WelcomeWidget* m_welcomeWidget;
|
||||
WhatsHotWidget* m_whatsHotWidget;
|
||||
|
||||
|
@ -34,7 +34,6 @@ class DLLEXPORT ViewPage
|
||||
{
|
||||
public:
|
||||
ViewPage() {}
|
||||
|
||||
virtual ~ViewPage() {}
|
||||
|
||||
virtual QWidget* widget() = 0;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "HeaderLabel.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include "utils/logger.h"
|
||||
@ -51,6 +52,23 @@ HeaderLabel::sizeHint() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
QFrame::mousePressEvent( event );
|
||||
m_time.start();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
QFrame::mouseReleaseEvent( event );
|
||||
if ( m_time.elapsed() < qApp->doubleClickInterval() )
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::paintEvent( QPaintEvent* /* event */ )
|
||||
{
|
||||
@ -58,7 +76,7 @@ HeaderLabel::paintEvent( QPaintEvent* /* event */ )
|
||||
QRect r = contentsRect();
|
||||
StyleHelper::horizontalHeader(&p, r);
|
||||
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
QTextOption to( alignment() | Qt::AlignVCenter );
|
||||
r.adjust( 8, 0, -8, 0 );
|
||||
p.setPen( StyleHelper::headerTextColor() );
|
||||
p.drawText( r, text(), to );
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define HEADERLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTime>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
@ -38,14 +39,19 @@ public:
|
||||
QSize minimumSizeHint() const { return sizeHint(); }
|
||||
QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
// void changeEvent( QEvent* e );
|
||||
void paintEvent( QPaintEvent* event );
|
||||
|
||||
void mousePressEvent( QMouseEvent* event );
|
||||
void mouseReleaseEvent( QMouseEvent* event );
|
||||
|
||||
private:
|
||||
QWidget* m_parent;
|
||||
QTime m_time;
|
||||
};
|
||||
|
||||
#endif // HEADERLABEL_H
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::ArtistInfoWidget )
|
||||
@ -120,10 +121,7 @@ void
|
||||
ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != m_infoId )
|
||||
{
|
||||
// qDebug() << "Info of wrong type or not with our identifier";
|
||||
return;
|
||||
}
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
@ -137,7 +135,6 @@ ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestD
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "ARTISTINFOWIDGET got infosystem info for:" << m_title << output.value< Tomahawk::InfoSystem::InfoGenericMap >();
|
||||
QVariantMap returnedData = output.value< QVariantMap >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "sourcetree/sourcetreeview.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
#include "utils/proxystyle.h"
|
||||
#include "utils/widgetdragfilter.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/searchwidget.h"
|
||||
@ -59,6 +58,7 @@
|
||||
#include "tomahawktrayicon.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
#include "scanmanager.h"
|
||||
#include "playlist/queueview.h"
|
||||
#include "tomahawkapp.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
@ -80,7 +80,10 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
{
|
||||
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||
|
||||
new ViewManager( this );
|
||||
ViewManager* vm = new ViewManager( this );
|
||||
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
|
||||
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
||||
|
||||
ui->setupUi( this );
|
||||
applyPlatformTweaks();
|
||||
|
||||
@ -96,7 +99,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
// set initial state
|
||||
onSipDisconnected();
|
||||
ViewManager::instance()->showWelcomePage();
|
||||
vm->setQueue( m_queueView );
|
||||
vm->showWelcomePage();
|
||||
}
|
||||
|
||||
|
||||
@ -184,28 +188,49 @@ TomahawkWindow::setupSideBar()
|
||||
QWidget* sidebarWidget = new QWidget();
|
||||
sidebarWidget->setLayout( new QVBoxLayout() );
|
||||
|
||||
AnimatedSplitter* sidebar = new AnimatedSplitter();
|
||||
sidebar->setOrientation( Qt::Vertical );
|
||||
sidebar->setChildrenCollapsible( false );
|
||||
m_sidebar = new AnimatedSplitter();
|
||||
m_sidebar->setOrientation( Qt::Vertical );
|
||||
m_sidebar->setChildrenCollapsible( false );
|
||||
|
||||
m_searchWidget = new QSearchField( sidebar );
|
||||
m_searchWidget = new QSearchField( m_sidebar );
|
||||
m_searchWidget->setPlaceholderText( "Global Search..." );
|
||||
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
||||
|
||||
m_sourcetree = new SourceTreeView();
|
||||
TransferView* transferView = new TransferView( sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( sidebar );
|
||||
TransferView* transferView = new TransferView( m_sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
|
||||
|
||||
sidebar->addWidget( m_searchWidget );
|
||||
sidebar->addWidget( m_sourcetree );
|
||||
sidebar->addWidget( transferView );
|
||||
sidebar->addWidget( pipelineView );
|
||||
m_queueButton = new QPushButton();
|
||||
m_queueButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
#ifdef Q_OS_MAC
|
||||
// QPushButtons on mac have lots of weird layouting issues. Fix them by forcing the widget rect for layout calculations
|
||||
m_queueButton->setAttribute( Qt::WA_LayoutUsesWidgetRect );
|
||||
#endif
|
||||
|
||||
sidebar->setGreedyWidget( 1 );
|
||||
sidebar->hide( 1, false );
|
||||
sidebar->hide( 2, false );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
sidebarWidget->layout()->addWidget( sidebar );
|
||||
m_queueView = new QueueView( m_sidebar );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueModel->setStyle( PlaylistModel::Short );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
m_sidebar->addWidget( m_searchWidget );
|
||||
m_sidebar->addWidget( m_sourcetree );
|
||||
m_sidebar->addWidget( transferView );
|
||||
m_sidebar->addWidget( pipelineView );
|
||||
m_sidebar->addWidget( m_queueView );
|
||||
|
||||
m_sidebar->setGreedyWidget( 1 );
|
||||
m_sidebar->hide( 1, false );
|
||||
m_sidebar->hide( 2, false );
|
||||
m_sidebar->hide( 3, false );
|
||||
m_sidebar->hide( 4, false );
|
||||
|
||||
sidebarWidget->layout()->addWidget( m_sidebar );
|
||||
sidebarWidget->layout()->addWidget( m_queueButton );
|
||||
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setMargin( 0 );
|
||||
@ -225,6 +250,7 @@ TomahawkWindow::setupSideBar()
|
||||
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setupUpdateCheck()
|
||||
{
|
||||
@ -663,6 +689,42 @@ TomahawkWindow::onFilterEdited()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to hide queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( showQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( hideQueue() ) );
|
||||
|
||||
m_sidebar->show( 4 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( hideQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
m_sidebar->hide( 4 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::minimize()
|
||||
{
|
||||
|
@ -35,6 +35,9 @@ class QAction;
|
||||
class MusicScanner;
|
||||
class AudioControls;
|
||||
class TomahawkTrayIcon;
|
||||
class PlaylistModel;
|
||||
class QueueView;
|
||||
class AnimatedSplitter;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@ -95,6 +98,9 @@ private slots:
|
||||
void onSearch( const QString& search );
|
||||
void onFilterEdited();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void minimize();
|
||||
void maximize();
|
||||
|
||||
@ -114,6 +120,10 @@ private:
|
||||
TomahawkTrayIcon* m_trayIcon;
|
||||
SourceTreeView* m_sourcetree;
|
||||
QPushButton* m_statusButton;
|
||||
QPushButton* m_queueButton;
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
AnimatedSplitter* m_sidebar;
|
||||
|
||||
Tomahawk::result_ptr m_currentTrack;
|
||||
QString m_windowTitle;
|
||||
|
Loading…
x
Reference in New Issue
Block a user