1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-20 19:01:34 +02:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Michael Zanetti
a78a25baa6 remove unused old code 2011-09-24 15:26:40 +02:00
Michael Zanetti
375ffd1445 speedup animation a bit to match the other dropmenu's duration 2011-09-24 15:26:15 +02:00
Michael Zanetti
c3d223d8cb completed dropmenu in audio controls area 2011-09-24 15:20:44 +02:00
Michael Zanetti
b2f3dedaff more work the dropmenu for the audiocontrols 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
a3ae74dc10 * Some more cleanups. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
4dfb989676 * Don't react to hover events unless TrackView is in Detailed mode. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
e0d1289a16 * Resize ContextPage's columns. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
cc5ba35a08 * Add forgotten ui file. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
e0e79c09a4 * Removed ugly queue button for good. 2011-09-04 20:56:10 +02:00
Christian Muehlhaeuser
03f726f46c * Added initial ContextView. Yikes. 2011-09-04 20:56:10 +02:00
Michael Zanetti
c0edc3a989 initial try on a dragndrop menu for audiocontrols 2011-09-04 01:54:13 +02:00
49 changed files with 2472 additions and 563 deletions

View File

@@ -47,6 +47,7 @@ AudioControls::AudioControls( QWidget* parent )
, ui( new Ui::AudioControls ) , ui( new Ui::AudioControls )
, m_repeatMode( PlaylistInterface::NoRepeat ) , m_repeatMode( PlaylistInterface::NoRepeat )
, m_shuffled( false ) , m_shuffled( false )
, m_dropAreaExpanded( false )
{ {
ui->setupUi( this ); ui->setupUi( this );
setAcceptDrops( true ); setAcceptDrops( true );
@@ -148,6 +149,46 @@ AudioControls::AudioControls( QWidget* parent )
ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize ); ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize );
onPlaybackStopped(); // initial state onPlaybackStopped(); // initial state
m_dragAnimation = new QPropertyAnimation( this, "dropAreaSize", this );
m_dragAnimation->setStartValue( 0 );
m_dragAnimation->setDuration( 300 );
m_dragAnimation->setEasingCurve( QEasingCurve::Linear );
connect( m_dragAnimation, SIGNAL( finished() ), SLOT(dragAnimationFinished()));
m_dropAreaCollapseTimer.setInterval( 300 );
m_dropAreaCollapseTimer.setSingleShot( true );
connect( &m_dropAreaCollapseTimer, SIGNAL( timeout() ), this, SLOT( collapseDropMenu() ) );
connect( ui->metaDataDropArea, SIGNAL( dropReceived( QDropEvent* ) ), this, SLOT( dropReceived( QDropEvent* ) ) );
connect( ui->metaDataDropArea, SIGNAL( mouseLeft() ), &m_dropAreaCollapseTimer, SLOT( start() ) );
DropMenuEntry *trackEntry = new DropMenuEntry( QPixmap(":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Track",
DropJob::DropFlagTrack );
ui->metaDataDropArea->addEntry( trackEntry, true );
DropMenuEntry *albumEntry = new DropMenuEntry( QPixmap(":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Album",
DropJob::DropFlagAlbum );
ui->metaDataDropArea->addEntry( albumEntry );
DropMenuEntry *artistEntry = new DropMenuEntry( QPixmap(":/data/images/drop-all-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Artist",
DropJob::DropFlagArtist );
ui->metaDataDropArea->addEntry( artistEntry );
DropMenuEntry *localEntry = new DropMenuEntry( QPixmap(":/data/images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Local",
DropJob::DropFlagAlbum | DropJob::DropFlagLocal );
ui->metaDataDropArea->addEntry( localEntry );
DropMenuEntry *top10Entry = new DropMenuEntry( QPixmap(":/data/images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ),
"Top 10",
DropJob::DropFlagArtist | DropJob::DropFlagTop10 );
ui->metaDataDropArea->addEntry( top10Entry );
} }
@@ -521,7 +562,36 @@ void
AudioControls::dragEnterEvent( QDragEnterEvent* e ) AudioControls::dragEnterEvent( QDragEnterEvent* e )
{ {
if ( DropJob::acceptsMimeData( e->mimeData() ) ) if ( DropJob::acceptsMimeData( e->mimeData() ) )
{
e->acceptProposedAction(); e->acceptProposedAction();
m_dropAreaCollapseTimer.stop();
DropJob::DropFlags flags = DropJob::DropFlagsNone;
if ( e->mimeData()->hasFormat( "application/tomahawk.query.list" )
|| e->mimeData()->hasFormat( "application/tomahawk.result.list" )
|| e->mimeData()->hasFormat( "application/tomahawk.result" ) )
flags = DropJob::DropFlagsAll;
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.album" ) )
flags = DropJob::DropFlagAlbum | DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
if ( e->mimeData()->hasFormat( "application/tomahawk.metadata.artist" ) )
flags = DropJob::DropFlagArtist | DropJob::DropFlagLocal | DropJob::DropFlagTop10;
ui->metaDataDropArea->setFilter( flags );
if( !m_dropAreaExpanded )
{
m_dragAnimation->stop();
m_dragAnimation->setDirection( QAbstractAnimation::Forward );
m_dragAnimation->setStartValue( dropAreaSize() );
m_dragAnimation->setEndValue( ui->metaDataArea->height() );
m_dragAnimation->start();
m_dropAreaExpanded = true;
}
}
} }
@@ -533,6 +603,32 @@ AudioControls::dragMoveEvent( QDragMoveEvent* /* e */ )
} }
void
AudioControls::dragLeaveEvent( QDragLeaveEvent * )
{
qDebug() << "******************************** dragLeaveEvent" << ui->metaDataDropArea->hovered();
if( !ui->metaDataDropArea->hovered() )
m_dropAreaCollapseTimer.start();
}
void
AudioControls::collapseDropMenu()
{
// Check if the menu is hovered now...
if( ui->metaDataDropArea->hovered() )
return;
m_dropAreaExpanded = false;
m_dragAnimation->stop();
// m_dragAnimation->setDirection( QAbstractAnimation::Backward );
m_dragAnimation->setStartValue( dropAreaSize() );
m_dragAnimation->setEndValue( 0 );
m_dragAnimation->start();
}
void void
AudioControls::dropEvent( QDropEvent* e ) AudioControls::dropEvent( QDropEvent* e )
{ {
@@ -541,8 +637,11 @@ AudioControls::dropEvent( QDropEvent* e )
{ {
DropJob *dj = new DropJob(); DropJob *dj = new DropJob();
connect( dj, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) ); connect( dj, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) );
dj->setDropFlags( ui->metaDataDropArea->activeEntry()->dropFlags() );
dj->tracksFromMimeData( e->mimeData() ); dj->tracksFromMimeData( e->mimeData() );
QTimer::singleShot( 0, this, SLOT( collapseDropMenu() ) );
e->accept(); e->accept();
} }
} }
@@ -595,3 +694,28 @@ AudioControls::onLoveButtonClicked( bool checked )
} }
} }
void
AudioControls::dragAnimationFinished()
{
}
int
AudioControls::dropAreaSize()
{
return ui->metaDataDropArea->maximumHeight();
}
void
AudioControls::setDropAreaSize( int size )
{
ui->metaDataDropArea->setMaximumHeight( size );
ui->metaDataInfoArea->setMaximumHeight( ui->metaDataArea->height() - size );
}
void
AudioControls::dropReceived( QDropEvent *event )
{
dropEvent( event );
}

View File

@@ -21,10 +21,13 @@
#include <QWidget> #include <QWidget>
#include <QTimeLine> #include <QTimeLine>
#include <QPropertyAnimation>
#include <QTimer>
#include "result.h" #include "result.h"
#include "playlistinterface.h" #include "playlistinterface.h"
#include "infosystem/infosystem.h" #include "infosystem/infosystem.h"
#include "utils/dropmenu.h"
class QDropEvent; class QDropEvent;
class QDragEnterEvent; class QDragEnterEvent;
@@ -37,6 +40,7 @@ namespace Ui
class AudioControls : public QWidget class AudioControls : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( int dropAreaSize READ dropAreaSize WRITE setDropAreaSize )
public: public:
AudioControls( QWidget* parent = 0 ); AudioControls( QWidget* parent = 0 );
@@ -54,8 +58,12 @@ protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
void dragEnterEvent ( QDragEnterEvent* ); void dragEnterEvent ( QDragEnterEvent* );
void dragMoveEvent ( QDragMoveEvent* ); void dragMoveEvent ( QDragMoveEvent* );
void dragLeaveEvent( QDragLeaveEvent * );
void dropEvent ( QDropEvent* ); void dropEvent ( QDropEvent* );
int dropAreaSize();
void setDropAreaSize( int size );
private slots: private slots:
void onPlaybackStarted( const Tomahawk::result_ptr& result ); void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackLoading( const Tomahawk::result_ptr& result ); void onPlaybackLoading( const Tomahawk::result_ptr& result );
@@ -82,6 +90,10 @@ private slots:
void socialActionsLoaded(); void socialActionsLoaded();
void collapseDropMenu();
void dragAnimationFinished();
void dropReceived( QDropEvent *event );
private: private:
Ui::AudioControls *ui; Ui::AudioControls *ui;
@@ -93,6 +105,10 @@ private:
QTimeLine m_sliderTimeLine; QTimeLine m_sliderTimeLine;
qint64 m_seekMsecs; qint64 m_seekMsecs;
QPropertyAnimation *m_dragAnimation;
bool m_dropAreaExpanded;
QTimer m_dropAreaCollapseTimer;
}; };
#endif // AUDIOCONTROLS_H #endif // AUDIOCONTROLS_H

View File

@@ -84,14 +84,14 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item> <item row="0" column="0">
<widget class="ImageButton" name="playPauseButton"> <widget class="ImageButton" name="playPauseButton">
<property name="text"> <property name="text">
<string>Play</string> <string>Play</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="0">
<widget class="ImageButton" name="pauseButton"> <widget class="ImageButton" name="pauseButton">
<property name="text"> <property name="text">
<string>Pause</string> <string>Pause</string>
@@ -125,248 +125,269 @@
</item> </item>
<item> <item>
<widget class="QWidget" name="metaDataArea" native="true"> <widget class="QWidget" name="metaDataArea" native="true">
<property name="maximumSize"> <layout class="QVBoxLayout" name="verticalLayout_4">
<size> <property name="margin">
<width>16777215</width>
<height>74</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>12</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="coverImage"> <widget class="DropMenu" name="metaDataDropArea" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>58</width> <width>16777215</width>
<height>58</height> <height>0</height>
</size> </size>
</property> </property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QWidget" name="metaDataInfoArea" native="true">
<property name="leftMargin"> <property name="maximumSize">
<number>4</number> <size>
<width>16777215</width>
<height>74</height>
</size>
</property> </property>
<property name="topMargin"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<number>6</number> <property name="leftMargin">
</property> <number>10</number>
<property name="bottomMargin"> </property>
<number>2</number> <property name="topMargin">
</property> <number>0</number>
<item> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0"> <property name="rightMargin">
<property name="topMargin"> <number>12</number>
<number>0</number> </property>
</property> <property name="bottomMargin">
<property name="bottomMargin"> <number>0</number>
<number>0</number> </property>
</property> <item>
<item> <widget class="QLabel" name="coverImage">
<layout class="QVBoxLayout" name="trackLabelLayout"> <property name="sizePolicy">
<property name="topMargin"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<number>0</number> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="bottomMargin"> </sizepolicy>
<number>0</number> </property>
</property> <property name="minimumSize">
<item> <size>
<widget class="QueryLabel" name="artistTrackLabel"> <width>58</width>
<property name="sizePolicy"> <height>58</height>
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> </size>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="maximumSize">
</sizepolicy> <size>
</property> <width>58</width>
<property name="minimumSize"> <height>58</height>
<size> </size>
<width>0</width> </property>
<height>16</height> <property name="text">
</size> <string>TextLabel</string>
</property> </property>
<property name="cursor"> <property name="alignment">
<cursorShape>PointingHandCursor</cursorShape> <set>Qt::AlignCenter</set>
</property> </property>
<property name="text"> </widget>
<string>Artist</string> </item>
</property> <item>
</widget> <layout class="QVBoxLayout" name="verticalLayout">
</item> <property name="leftMargin">
<item> <number>4</number>
<widget class="QueryLabel" name="albumLabel"> </property>
<property name="sizePolicy"> <property name="topMargin">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum"> <number>6</number>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="bottomMargin">
</sizepolicy> <number>2</number>
</property> </property>
<property name="minimumSize"> <item>
<size> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0,0">
<width>0</width> <property name="topMargin">
<height>16</height> <number>0</number>
</size> </property>
</property> <property name="bottomMargin">
<property name="cursor"> <number>0</number>
<cursorShape>PointingHandCursor</cursorShape> </property>
</property> <item>
<property name="text"> <layout class="QVBoxLayout" name="trackLabelLayout">
<string>Album</string> <property name="topMargin">
</property> <number>0</number>
</widget> </property>
</item> <property name="bottomMargin">
</layout> <number>0</number>
</item> </property>
<item> <item>
<spacer name="horizontalSpacer_3"> <widget class="QueryLabel" name="artistTrackLabel">
<property name="orientation"> <property name="sizePolicy">
<enum>Qt::Horizontal</enum> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
</property> <horstretch>0</horstretch>
<property name="sizeHint" stdset="0"> <verstretch>0</verstretch>
<size> </sizepolicy>
<width>4</width> </property>
<height>8</height> <property name="minimumSize">
</size> <size>
</property> <width>0</width>
</spacer> <height>16</height>
</item> </size>
<item> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <property name="cursor">
<item> <cursorShape>PointingHandCursor</cursorShape>
<widget class="ImageButton" name="loveButton"> </property>
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <string>Artist</string>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> </widget>
</sizepolicy> </item>
</property> <item>
<property name="cursor"> <widget class="QueryLabel" name="albumLabel">
<cursorShape>PointingHandCursor</cursorShape> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<property name="text"> <horstretch>0</horstretch>
<string>love</string> <verstretch>0</verstretch>
</property> </sizepolicy>
</widget> </property>
</item> <property name="minimumSize">
<item> <size>
<spacer name="verticalSpacer_2"> <width>0</width>
<property name="orientation"> <height>16</height>
<enum>Qt::Vertical</enum> </size>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="cursor">
<size> <cursorShape>PointingHandCursor</cursorShape>
<width>20</width> </property>
<height>13</height> <property name="text">
</size> <string>Album</string>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QLabel" name="ownerLabel"> <spacer name="horizontalSpacer_3">
<property name="font"> <property name="orientation">
<font> <enum>Qt::Horizontal</enum>
<pointsize>7</pointsize> </property>
</font> <property name="sizeHint" stdset="0">
</property> <size>
<property name="text"> <width>4</width>
<string>Owner</string> <height>8</height>
</property> </size>
<property name="alignment"> </property>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </spacer>
</property> </item>
<property name="margin"> <item>
<number>0</number> <layout class="QVBoxLayout" name="verticalLayout_2">
</property> <item>
</widget> <widget class="ImageButton" name="loveButton">
</item> <property name="sizePolicy">
</layout> <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
</item> <horstretch>0</horstretch>
<item> <verstretch>0</verstretch>
<spacer name="verticalSpacer"> </sizepolicy>
<property name="orientation"> </property>
<enum>Qt::Vertical</enum> <property name="cursor">
</property> <cursorShape>PointingHandCursor</cursorShape>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="text">
<width>20</width> <string>love</string>
<height>4</height> </property>
</size> </widget>
</property> </item>
</spacer> <item>
</item> <spacer name="verticalSpacer_2">
<item> <property name="orientation">
<layout class="QHBoxLayout" name="horizontalLayout"> <enum>Qt::Vertical</enum>
<property name="leftMargin"> </property>
<number>4</number> <property name="sizeHint" stdset="0">
</property> <size>
<item> <width>20</width>
<widget class="QLabel" name="timeLabel"> <height>13</height>
<property name="text"> </size>
<string>Time</string> </property>
</property> </spacer>
</widget> </item>
</item> </layout>
<item> </item>
<widget class="SeekSlider" name="seekSlider"> <item>
<property name="minimumSize"> <widget class="QLabel" name="ownerLabel">
<size> <property name="font">
<width>0</width> <font>
<height>20</height> <pointsize>7</pointsize>
</size> </font>
</property> </property>
<property name="maximumSize"> <property name="text">
<size> <string>Owner</string>
<width>16777215</width> </property>
<height>20</height> <property name="alignment">
</size> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property> </property>
<property name="orientation"> <property name="margin">
<enum>Qt::Horizontal</enum> <number>0</number>
</property> </property>
</widget> </widget>
</item> </item>
<item> </layout>
<widget class="QLabel" name="timeLeftLabel"> </item>
<property name="text"> <item>
<string>Time Left</string> <spacer name="verticalSpacer">
</property> <property name="orientation">
</widget> <enum>Qt::Vertical</enum>
</item> </property>
</layout> <property name="sizeHint" stdset="0">
</item> <size>
</layout> <width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="timeLabel">
<property name="text">
<string>Time</string>
</property>
</widget>
</item>
<item>
<widget class="SeekSlider" name="seekSlider">
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeLeftLabel">
<property name="text">
<string>Time Left</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item> </item>
</layout> </layout>
<zorder>metaDataInfoArea</zorder>
<zorder>metaDataDropArea</zorder>
</widget> </widget>
</item> </item>
<item> <item>
@@ -544,6 +565,12 @@
<extends>QLabel</extends> <extends>QLabel</extends>
<header>utils/querylabel.h</header> <header>utils/querylabel.h</header>
</customwidget> </customwidget>
<customwidget>
<class>DropMenu</class>
<extends>QWidget</extends>
<header>utils/dropmenu.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -40,6 +40,13 @@ set( libSources
audio/audioengine.cpp 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/database.cpp
database/fuzzyindex.cpp database/fuzzyindex.cpp
database/databasecollection.cpp database/databasecollection.cpp
@@ -176,6 +183,7 @@ set( libSources
utils/rdioparser.cpp utils/rdioparser.cpp
utils/shortenedlinkparser.cpp utils/shortenedlinkparser.cpp
utils/stylehelper.cpp utils/stylehelper.cpp
utils/dropmenu.cpp
widgets/newplaylistwidget.cpp widgets/newplaylistwidget.cpp
widgets/searchwidget.cpp widgets/searchwidget.cpp
@@ -234,6 +242,13 @@ set( libHeaders
audio/audioengine.h 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/database.h
database/fuzzyindex.h database/fuzzyindex.h
database/databaseworker.h database/databaseworker.h
@@ -367,6 +382,7 @@ set( libHeaders
utils/rdioparser.h utils/rdioparser.h
utils/shortenedlinkparser.h utils/shortenedlinkparser.h
utils/stylehelper.h utils/stylehelper.h
utils/dropmenu.h
widgets/newplaylistwidget.h widgets/newplaylistwidget.h
widgets/searchwidget.h widgets/searchwidget.h
@@ -417,6 +433,8 @@ set( libUI ${libUI}
widgets/infowidgets/AlbumInfoWidget.ui widgets/infowidgets/AlbumInfoWidget.ui
playlist/topbar/topbar.ui playlist/topbar/topbar.ui
playlist/infobar/infobar.ui playlist/infobar/infobar.ui
playlist/queueview.ui
context/ContextWidget.ui
) )
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. .. include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ..

View 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 );
}

View 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

View File

@@ -0,0 +1,306 @@
/* === 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( 22 )
, 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( "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 );
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 );
QPalette pal = palette();
pal.setBrush( QPalette::Window, QColor( 0x70, 0x70, 0x70 ) );
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::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" ) );
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 );
setQuery( m_query, true );
}
else
{
setFixedHeight( m_minHeight );
}
}
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 );
}
}

View File

@@ -0,0 +1,88 @@
/* === 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 paintEvent( QPaintEvent* e );
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;
bool m_visible;
};
#endif // CONTEXTWIDGET_H

View 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::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>

View File

@@ -0,0 +1,123 @@
/* === 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_relatedView->setGuid( "RelatedArtistsContext" );
m_relatedModel = new TreeModel( m_relatedView );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
m_relatedView->setTreeModel( m_relatedModel );
m_relatedView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
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 );
}

View 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

View File

@@ -0,0 +1,129 @@
/* === 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"
#include "playlist/trackheader.h"
using namespace Tomahawk;
TopTracksContext::TopTracksContext()
: ContextPage()
, m_infoId( uuid() )
{
m_topHitsView = new PlaylistView();
m_topHitsView->setGuid( "TopTracksContext" );
m_topHitsView->setUpdatesContextView( false );
m_topHitsModel = new PlaylistModel( m_topHitsView );
m_topHitsModel->setStyle( TrackModel::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 );
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 );
}

View 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

View 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()
{
}

View 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

View 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() ) );
}

View 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

View File

@@ -34,6 +34,7 @@ using namespace Tomahawk;
DropJob::DropJob( QObject *parent ) DropJob::DropJob( QObject *parent )
: QObject( parent ) : QObject( parent )
, m_queryCount( 0 ) , m_queryCount( 0 )
, m_dropFlags( DropFlagsNone )
{ {
} }
@@ -98,31 +99,72 @@ DropJob::acceptsMimeData( const QMimeData* data, bool tracksOnly )
void void
DropJob::setGetWholeArtists( bool getWholeArtists ) DropJob::setGetWholeArtists( bool getWholeArtists )
{ {
m_getWholeArtists = getWholeArtists; if( getWholeArtists )
m_dropFlags |= DropFlagArtist;
else
m_dropFlags &= !DropFlagArtist;
} }
void void
DropJob::setGetWholeAlbums( bool getWholeAlbums ) DropJob::setGetWholeAlbums( bool getWholeAlbums )
{ {
m_getWholeAlbums = getWholeAlbums; if ( getWholeAlbums )
m_dropFlags |= DropFlagAlbum;
else
m_dropFlags &= !DropFlagAlbum;
} }
void void
DropJob::tracksFromMimeData( const QMimeData* data, bool allowDuplicates, bool onlyLocal, bool top10 ) DropJob::setGetTop10( bool top10 )
{ {
m_allowDuplicates = allowDuplicates; if( top10 )
m_onlyLocal = onlyLocal; m_dropFlags |= DropFlagTop10;
m_top10 = top10; else
m_dropFlags &= !DropFlagTop10;
}
void
DropJob::setOnlyLocal( bool onlyLocal )
{
if( onlyLocal )
m_dropFlags |= DropFlagLocal;
else
m_dropFlags &= !DropFlagLocal;
}
void
DropJob::setAllowDuplicates( bool allowDuplicates )
{
if( allowDuplicates )
m_dropFlags |= DropFlagAllowDuplicates;
else
m_dropFlags &= !DropFlagAllowDuplicates;
}
void
DropJob::setDropFlags( DropFlags flags )
{
m_dropFlags = flags;
}
void
DropJob::tracksFromMimeData( const QMimeData* data )
{
parseMimeData( data ); parseMimeData( data );
if ( m_queryCount == 0 ) if ( m_queryCount == 0 )
{ {
if ( onlyLocal ) if ( m_dropFlags.testFlag( DropFlagLocal ) )
removeRemoteSources(); removeRemoteSources();
if ( !allowDuplicates ) if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
removeDuplicates(); removeDuplicates();
emit tracks( m_resultList ); emit tracks( m_resultList );
@@ -171,15 +213,15 @@ DropJob::tracksFromQueryList( const QMimeData* data )
{ {
tDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track(); tDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
if ( m_top10 ) if ( m_dropFlags.testFlag( DropFlagTop10 ) )
{ {
getTopTen( query->data()->artist() ); getTopTen( query->data()->artist() );
} }
else if ( m_getWholeArtists ) else if ( m_dropFlags.testFlag( DropFlagArtist ) )
{ {
queries << getArtist( query->data()->artist() ); queries << getArtist( query->data()->artist() );
} }
else if ( m_getWholeAlbums ) else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
{ {
queries << getAlbum( query->data()->artist(), query->data()->album() ); queries << getAlbum( query->data()->artist(), query->data()->album() );
} }
@@ -211,15 +253,15 @@ DropJob::tracksFromResultList( const QMimeData* data )
tDebug() << "Dropped result item:" << result->data()->artist()->name() << "-" << result->data()->track(); tDebug() << "Dropped result item:" << result->data()->artist()->name() << "-" << result->data()->track();
query_ptr q = result->data()->toQuery(); query_ptr q = result->data()->toQuery();
if ( m_top10 ) if ( m_dropFlags.testFlag( DropFlagTop10 ) )
{ {
getTopTen( q->artist() ); getTopTen( q->artist() );
} }
else if ( m_getWholeArtists ) else if ( m_dropFlags.testFlag( DropFlagArtist ) )
{ {
queries << getArtist( q->artist() ); queries << getArtist( q->artist() );
} }
else if ( m_getWholeAlbums ) else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
{ {
queries << getAlbum( q->artist(), q->album() ); queries << getAlbum( q->artist(), q->album() );
} }
@@ -248,9 +290,9 @@ DropJob::tracksFromAlbumMetaData( const QMimeData *data )
QString album; QString album;
stream >> album; stream >> album;
if ( m_top10 ) if ( m_dropFlags.testFlag( DropFlagTop10 ) )
getTopTen( artist ); getTopTen( artist );
else if ( m_getWholeArtists ) else if ( m_dropFlags.testFlag( DropFlagArtist ) )
queries << getArtist( artist ); queries << getArtist( artist );
else else
queries << getAlbum( artist, album ); queries << getAlbum( artist, album );
@@ -270,14 +312,10 @@ DropJob::tracksFromArtistMetaData( const QMimeData *data )
QString artist; QString artist;
stream >> artist; stream >> artist;
if ( !m_top10 ) if ( m_dropFlags.testFlag( DropFlagTop10 ) )
{
queries << getArtist( artist );
}
else
{
getTopTen( artist ); getTopTen( artist );
} else
queries << getArtist( artist );
} }
return queries; return queries;
} }
@@ -381,10 +419,10 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
if ( --m_queryCount == 0 ) if ( --m_queryCount == 0 )
{ {
if ( m_onlyLocal ) if ( m_dropFlags.testFlag( DropFlagLocal ) )
removeRemoteSources(); removeRemoteSources();
if ( !m_allowDuplicates ) if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
removeDuplicates(); removeDuplicates();
emit tracks( m_resultList ); emit tracks( m_resultList );

View File

@@ -28,10 +28,48 @@
#include <QStringList> #include <QStringList>
#include <QMimeData> #include <QMimeData>
/** @class DropJob
* Allows you to process dropped mimedata in different ways:
* Configure the DropJob using setDropFlags() or the set*() functions to do
* what you want and then feed it with MimeMata. Connect to the tracks() signal
* to receive the results.
*
* Possible configuration flags are:
* - DropFlagTrack: Get the dropped track (only valid if the dropped item is acutally a track)
* - DropFlagAlbum: Get this album (only valid if the dropped item is an album or a track with album information)
* - DropFlagArtist: Get this artist
* - DropFlagTop10: Query the Top 10 for this artist in the Network
* - DropFlagLocal: Only get local items (Filters out all remote ones)
* - DropFlagAllowDuplicates: Allow duplicate results, e.g. same song from different sources.
*
* Note: The largest possible set of the configured Flags applies. E.g. Artist is greater than Album.
* If you set both of them only the album will be fetched. Requesting the Top 10 items always results in a
* query for the whole artist. It is not possible to e.g. request the Top 10 tracks of a given album.
*
* If you configure nothing or dropping incompatible data (e.g. configured DropTrack but dropping an album),
* the DropJob will do this default actions:
* - Get this track for dropped tracks
* - Get whole album for dropped albums
* - Get whole artist for dropped artists
*/
class DLLEXPORT DropJob : public QObject class DLLEXPORT DropJob : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum DropFlag
{
DropFlagsNone = 0x00,
DropFlagTrack = 0x01,
DropFlagAlbum = 0x02,
DropFlagArtist = 0x04,
DropFlagTop10 = 0x08,
DropFlagLocal = 0x10,
DropFlagAllowDuplicates = 0x20,
DropFlagsAll = 0xff
};
Q_DECLARE_FLAGS( DropFlags, DropFlag )
explicit DropJob( QObject *parent = 0 ); explicit DropJob( QObject *parent = 0 );
~DropJob(); ~DropJob();
@@ -46,9 +84,15 @@ public:
static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true ); static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true );
static QStringList mimeTypes(); static QStringList mimeTypes();
void setDropFlags( DropFlags flags );
void setGetWholeArtists( bool getWholeArtists ); void setGetWholeArtists( bool getWholeArtists );
void setGetWholeAlbums( bool getWholeAlbums ); void setGetWholeAlbums( bool getWholeAlbums );
void tracksFromMimeData( const QMimeData* data, bool allowDuplicates = false, bool onlyLocal = false, bool top10 = false ); void setGetTop10( bool top10 );
void setOnlyLocal( bool onlyLocal );
void setAllowDuplicates( bool allowDuplicates );
void tracksFromMimeData( const QMimeData* data );
signals: signals:
/// QMimeData parsing results /// QMimeData parsing results
@@ -81,13 +125,10 @@ private:
void removeRemoteSources(); void removeRemoteSources();
int m_queryCount; int m_queryCount;
bool m_allowDuplicates; DropFlags m_dropFlags;
bool m_onlyLocal;
bool m_getWholeArtists;
bool m_getWholeAlbums;
bool m_top10;
QList< Tomahawk::query_ptr > m_resultList; QList< Tomahawk::query_ptr > m_resultList;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS( DropJob::DropFlags )
#endif // DROPJOB_H #endif // DROPJOB_H

View File

@@ -467,7 +467,7 @@ GlobalActionManager::handleSearchCommand( const QUrl& url )
return false; return false;
ViewManager::instance()->showSuperCollection(); ViewManager::instance()->showSuperCollection();
ViewManager::instance()->topbar()->setFilter( queryStr ); // ViewManager::instance()->topbar()->setFilter( queryStr );
return true; return true;
} }

View File

@@ -129,6 +129,17 @@ ArtistView::setTreeModel( TreeModel* model )
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) ); connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
setAcceptDrops( false ); setAcceptDrops( false );
if ( model->columnStyle() == TreeModel::TrackOnly )
{
setHeaderHidden( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
}
else
{
setHeaderHidden( false );
setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
}
} }
@@ -178,6 +189,11 @@ ArtistView::resizeEvent( QResizeEvent* event )
{ {
QTreeView::resizeEvent( event ); QTreeView::resizeEvent( event );
m_header->checkState(); m_header->checkState();
if ( model()->columnCount( QModelIndex() ) == 1 )
{
m_header->resizeSection( 0, event->size().width() );
}
} }
@@ -333,5 +349,8 @@ ArtistView::jumpToCurrentTrack()
QString QString
ArtistView::guid() const ArtistView::guid() const
{ {
return QString( "artistview/%1" ).arg( m_model->columnCount( QModelIndex() ) ); if ( m_guid.isEmpty() )
m_guid = QString( "artistview/%1" ).arg( m_model->columnCount( QModelIndex() ) );
return m_guid;
} }

View File

@@ -40,6 +40,9 @@ public:
explicit ArtistView( QWidget* parent = 0 ); explicit ArtistView( QWidget* parent = 0 );
~ArtistView(); ~ArtistView();
virtual QString guid() const;
virtual void setGuid( const QString& guid ) { m_guid = guid; }
void setProxyModel( TreeProxyModel* model ); void setProxyModel( TreeProxyModel* model );
TreeModel* model() const { return m_model; } TreeModel* model() const { return m_model; }
@@ -64,8 +67,6 @@ public:
virtual bool jumpToCurrentTrack(); virtual bool jumpToCurrentTrack();
QString guid() const;
public slots: public slots:
void onItemActivated( const QModelIndex& index ); void onItemActivated( const QModelIndex& index );
@@ -96,6 +97,7 @@ private:
bool m_showModes; bool m_showModes;
QTimer m_timer; QTimer m_timer;
mutable QString m_guid;
}; };
#endif // ARTISTVIEW_H #endif // ARTISTVIEW_H

View File

@@ -20,22 +20,25 @@
#include "ui_infobar.h" #include "ui_infobar.h"
#include <QLabel> #include <QLabel>
#include <QPropertyAnimation>
#include <QPixmap> #include <QPixmap>
#include "context/ContextWidget.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "utils/logger.h" #include "utils/logger.h"
#define ANIMATION_TIME 400
#define IMAGE_HEIGHT 64 #define IMAGE_HEIGHT 64
using namespace Tomahawk;
InfoBar::InfoBar( QWidget* parent ) InfoBar::InfoBar( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::InfoBar ) , ui( new Ui::InfoBar )
{ {
ui->setupUi( this ); ui->setupUi( this );
layout()->setSpacing( 0 ); TomahawkUtils::unmarginLayout( layout() );
layout()->setContentsMargins( 0, 0, 0, 0 ); layout()->setContentsMargins( 8, 4, 8, 4 );
QFont boldFont = ui->captionLabel->font(); QFont boldFont = ui->captionLabel->font();
boldFont.setPixelSize( 18 ); boldFont.setPixelSize( 18 );

View File

@@ -23,6 +23,11 @@
#include "dllmacro.h" #include "dllmacro.h"
#include "query.h"
class QTimeLine;
class ContextWidget;
namespace Ui namespace Ui
{ {
class InfoBar; class InfoBar;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>774</width>
<height>72</height> <height>80</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -25,168 +25,149 @@
<property name="windowTitle"> <property name="windowTitle">
<string>InfoBar</string> <string>InfoBar</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,1,0,99,0"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<spacer name="horizontalSpacer_3"> <layout class="QHBoxLayout" name="horizontalLayout">
<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">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </property>
<item> <item>
<widget class="ElidedLabel" name="captionLabel"> <widget class="QLabel" name="imageLabel">
<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>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>64</width>
<height>62</height> <height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>62</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>16</width>
<height>1</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</item> </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> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@@ -117,7 +117,7 @@ PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const
opacity = item->query()->results().first()->score(); opacity = item->query()->results().first()->score();
opacity = qMax( (float)0.3, opacity ); 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 ); option->palette.setColor( QPalette::Text, textColor );
} }

View File

@@ -176,8 +176,8 @@ PlaylistModel::clear()
emit beginResetModel(); emit beginResetModel();
delete m_rootItem; delete m_rootItem;
m_rootItem = 0; m_rootItem = 0;
emit endResetModel();
m_rootItem = new TrackModelItem( 0, this ); m_rootItem = new TrackModelItem( 0, this );
emit endResetModel();
} }
} }

View File

@@ -62,13 +62,16 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
TrackView::setTrackModel( m_model ); TrackView::setTrackModel( m_model );
setColumnHidden( TrackModel::Age, true ); // Hide age column per default setColumnHidden( TrackModel::Age, true ); // Hide age column per default
if ( guid().isEmpty() && !m_model->playlist().isNull() ) if ( guid().isEmpty() )
{ {
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) ); if ( !m_model->playlist().isNull() )
} {
else setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) );
{ }
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) ); else
{
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
}
} }
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) ); connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );

View File

@@ -17,9 +17,11 @@
*/ */
#include "queueview.h" #include "queueview.h"
#include "ui_queueview.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include "widgets/HeaderLabel.h"
#include "playlist/queueproxymodel.h" #include "playlist/queueproxymodel.h"
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -29,19 +31,21 @@ using namespace Tomahawk;
QueueView::QueueView( AnimatedSplitter* parent ) QueueView::QueueView( AnimatedSplitter* parent )
: AnimatedWidget( parent ) : AnimatedWidget( parent )
, ui( new Ui::QueueView )
{ {
setHiddenSize( QSize( 0, 0 ) ); ui->setupUi( this );
setLayout( new QVBoxLayout() ); TomahawkUtils::unmarginLayout( layout() );
setContentsMargins( 0, 0, 0, 0 );
m_queue = new PlaylistView( this ); setHiddenSize( QSize( 0, 22 ) );
m_queue->setProxyModel( new QueueProxyModel( this ) );
m_queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
m_queue->setFrameShape( QFrame::NoFrame );
m_queue->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_queue->overlay()->setEnabled( false );
layout()->setMargin( 0 ); ui->queue->setProxyModel( new QueueProxyModel( this ) );
layout()->addWidget( m_queue ); ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored );
ui->queue->setFrameShape( QFrame::NoFrame );
ui->queue->setAttribute( Qt::WA_MacShowFocusRect, 0 );
ui->queue->overlay()->setEnabled( false );
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
} }
@@ -51,10 +55,36 @@ QueueView::~QueueView()
} }
PlaylistView*
QueueView::queue() const
{
return ui->queue;
}
void
QueueView::hide()
{
disconnect( ui->toggleButton, SIGNAL( clicked() ), this, SLOT( hide() ) );
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( show() ) );
ui->toggleButton->setText( tr( "Show Queue" ) );
emit hideWidget();
}
void
QueueView::show()
{
disconnect( ui->toggleButton, SIGNAL( clicked() ), this, SLOT( show() ) );
connect( ui->toggleButton, SIGNAL( clicked() ), SLOT( hide() ) );
ui->toggleButton->setText( tr( "Hide Queue" ) );
emit showWidget();
}
void void
QueueView::onShown( QWidget* widget, bool animated ) QueueView::onShown( QWidget* widget, bool animated )
{ {
qDebug() << Q_FUNC_INFO << widget;
if ( widget != this ) if ( widget != this )
return; return;
@@ -65,7 +95,6 @@ QueueView::onShown( QWidget* widget, bool animated )
void void
QueueView::onHidden( QWidget* widget, bool animated ) QueueView::onHidden( QWidget* widget, bool animated )
{ {
qDebug() << Q_FUNC_INFO << widget;
if ( widget != this ) if ( widget != this )
return; return;

View File

@@ -26,6 +26,11 @@
#include "dllmacro.h" #include "dllmacro.h"
namespace Ui
{
class QueueView;
}
class DLLEXPORT QueueView : public AnimatedWidget class DLLEXPORT QueueView : public AnimatedWidget
{ {
Q_OBJECT Q_OBJECT
@@ -34,7 +39,7 @@ public:
explicit QueueView( AnimatedSplitter* parent ); explicit QueueView( AnimatedSplitter* parent );
~QueueView(); ~QueueView();
PlaylistView* queue() const { return m_queue; } PlaylistView* queue() const;
QSize sizeHint() const { return QSize( 0, 200 ); } QSize sizeHint() const { return QSize( 0, 200 ); }
@@ -42,8 +47,11 @@ public slots:
virtual void onShown( QWidget*, bool animated ); virtual void onShown( QWidget*, bool animated );
virtual void onHidden( QWidget*, bool animated ); virtual void onHidden( QWidget*, bool animated );
virtual void show();
virtual void hide();
private: private:
PlaylistView* m_queue; Ui::QueueView* ui;
}; };
#endif // QUEUEVIEW_H #endif // QUEUEVIEW_H

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QueueView</class>
<widget class="QWidget" name="QueueView">
<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>Open Queue</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="PlaylistView" name="queue"/>
</item>
<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>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>HeaderLabel</class>
<extends>QLabel</extends>
<header location="global">widgets/HeaderLabel.h</header>
</customwidget>
<customwidget>
<class>PlaylistView</class>
<extends>QTreeView</extends>
<header location="global">playlist/playlistview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -24,11 +24,11 @@
#include "trackheader.h" #include "trackheader.h"
#include "viewmanager.h" #include "viewmanager.h"
#include "queueview.h"
#include "trackmodel.h" #include "trackmodel.h"
#include "trackproxymodel.h" #include "trackproxymodel.h"
#include "audio/audioengine.h" #include "audio/audioengine.h"
#include "context/ContextWidget.h"
#include "widgets/overlaywidget.h" #include "widgets/overlaywidget.h"
#include "dynamic/widgets/LoadingSpinner.h" #include "dynamic/widgets/LoadingSpinner.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
@@ -48,6 +48,7 @@ TrackView::TrackView( QWidget* parent )
, m_loadingSpinner( new LoadingSpinner( this ) ) , m_loadingSpinner( new LoadingSpinner( this ) )
, m_resizing( false ) , m_resizing( false )
, m_dragging( false ) , m_dragging( false )
, m_updateContextView( true )
, m_contextMenu( new ContextMenu( this ) ) , m_contextMenu( new ContextMenu( this ) )
{ {
setMouseTracking( true ); setMouseTracking( true );
@@ -141,7 +142,7 @@ TrackView::setTrackModel( TrackModel* model )
setAcceptDrops( true ); setAcceptDrops( true );
if ( model->style() == TrackModel::Short ) if ( model->style() == TrackModel::Short || model->style() == TrackModel::ShortWithAvatars )
{ {
setHeaderHidden( true ); setHeaderHidden( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -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 void
TrackView::onItemActivated( const QModelIndex& index ) TrackView::onItemActivated( const QModelIndex& index )
{ {
@@ -213,6 +228,11 @@ TrackView::resizeEvent( QResizeEvent* event )
// restoreState keeps overwriting our previous sort-order // restoreState keeps overwriting our previous sort-order
sortByColumn( sortSection, sortOrder ); sortByColumn( sortSection, sortOrder );
} }
if ( model()->columnCount() == 1 )
{
m_header->resizeSection( 0, event->size().width() );
}
} }
@@ -448,7 +468,7 @@ TrackView::updateHoverIndex( const QPoint& pos )
repaint(); repaint();
} }
if ( m_model->style() == TrackModel::Short ) if ( m_model->style() == TrackModel::Short || m_model->style() == TrackModel::ShortWithAvatars )
return; return;
if ( idx.column() == TrackModel::Artist || idx.column() == TrackModel::Album ) if ( idx.column() == TrackModel::Artist || idx.column() == TrackModel::Album )
@@ -499,8 +519,11 @@ void
TrackView::mousePressEvent( QMouseEvent* event ) TrackView::mousePressEvent( QMouseEvent* event )
{ {
QTreeView::mousePressEvent( event ); QTreeView::mousePressEvent( event );
QModelIndex idx = indexAt( event->pos() );
if ( m_model->style() != TrackModel::Detailed )
return;
QModelIndex idx = indexAt( event->pos() );
if ( event->pos().x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 && if ( event->pos().x() > header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) - 16 &&
event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) ) event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
{ {

View File

@@ -62,6 +62,9 @@ explicit TrackView( QWidget* parent = 0 );
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; } QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; } void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
bool updatesContextView() const { return m_updateContextView; }
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
public slots: public slots:
void onItemActivated( const QModelIndex& index ); void onItemActivated( const QModelIndex& index );
@@ -84,6 +87,9 @@ protected:
void paintEvent( QPaintEvent* event ); void paintEvent( QPaintEvent* event );
void keyPressEvent( QKeyEvent* event ); void keyPressEvent( QKeyEvent* event );
protected slots:
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
private slots: private slots:
void onItemResized( const QModelIndex& index ); void onItemResized( const QModelIndex& index );
void onFilterChanged( const QString& filter ); void onFilterChanged( const QString& filter );
@@ -105,6 +111,8 @@ private:
bool m_dragging; bool m_dragging;
QRect m_dropRect; QRect m_dropRect;
bool m_updateContextView;
QModelIndex m_hoveredIndex; QModelIndex m_hoveredIndex;
QModelIndex m_contextMenuIndex; QModelIndex m_contextMenuIndex;
Tomahawk::ContextMenu* m_contextMenu; Tomahawk::ContextMenu* m_contextMenu;

View File

@@ -821,6 +821,7 @@ TreeModel::onDataChanged()
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) ); emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
} }
void void
TreeModel::setColumnStyle( TreeModel::ColumnStyle style ) TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
{ {

View File

@@ -91,6 +91,7 @@ public:
void getCover( const QModelIndex& index ); void getCover( const QModelIndex& index );
ColumnStyle columnStyle() const { return m_columnStyle; }
void setColumnStyle( ColumnStyle style ); void setColumnStyle( ColumnStyle style );
virtual QString title() const { return m_title; } virtual QString title() const { return m_title; }

View File

@@ -151,7 +151,7 @@ AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent )
{ {
m_timeLine = new QTimeLine( ANIMATION_TIME, this ); m_timeLine = new QTimeLine( ANIMATION_TIME, this );
m_timeLine->setUpdateInterval( 20 ); m_timeLine->setUpdateInterval( 20 );
m_timeLine->setEasingCurve( QEasingCurve::OutBack ); m_timeLine->setEasingCurve( QEasingCurve::OutCubic );
connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) );
connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) );

View File

@@ -0,0 +1,153 @@
#include "dropmenu.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QDragEnterEvent>
DropMenu::DropMenu( QWidget *parent )
: QWidget( parent )
{
setLayout( new QHBoxLayout() );
layout()->setSpacing( 0 );
}
void
DropMenu::addEntry( DropMenuEntry *entry, bool isDefault )
{
layout()->addWidget( entry );
if( m_entries.isEmpty() || isDefault )
m_activeEntry = entry;
m_entries.append( entry );
connect( entry, SIGNAL( mouseEntered( DropMenuEntry* ) ), this, SLOT( entryHovered( DropMenuEntry* ) ) );
connect( entry, SIGNAL( mouseLeft( DropMenuEntry* ) ), this, SLOT( entryLeft(DropMenuEntry*) ) );
connect( entry, SIGNAL( dropReceived( QDropEvent* ) ) , this, SIGNAL( dropReceived( QDropEvent* ) ) );
if( isDefault )
m_defaultEntry = entry;
}
void
DropMenu::setFilter(DropJob::DropFlags shownEntries)
{
foreach( DropMenuEntry *entry, m_entries )
{
if( ( entry->dropFlags() & shownEntries ) != DropJob::DropFlagsNone )
entry->setVisible( true );
else
entry->setVisible( false );
}
}
bool
DropMenu::hovered() const
{
foreach( DropMenuEntry *entry, m_entries )
{
if( entry->hovered() )
return true;
}
return false;
}
DropMenuEntry*
DropMenu::activeEntry()
{
return m_activeEntry;
}
void
DropMenu::entryHovered( DropMenuEntry *entry )
{
m_activeEntry->setActive( false );
m_activeEntry = entry;
entry->setActive( true );
}
void
DropMenu::entryLeft( DropMenuEntry *entry )
{
entry->setActive( false );
m_defaultEntry->setActive( true );
m_activeEntry = m_defaultEntry;
emit mouseLeft();
}
DropMenuEntry::DropMenuEntry( const QPixmap &icon, const QString &text, DropJob::DropFlags flags, QWidget *parent )
: QWidget( parent )
, m_hovered( false )
, m_flags( flags )
{
QVBoxLayout *layout = new QVBoxLayout();
QLabel* image = new QLabel;
image->setAlignment( Qt::AlignHCenter );
image->setPixmap( icon );
layout->addWidget( image );
m_label = new QLabel( text );
m_label->setAlignment( Qt::AlignHCenter );
layout->addWidget( m_label );
setLayout( layout );
setAcceptDrops( true );
setMouseTracking( true );
}
void
DropMenuEntry::dragEnterEvent( QDragEnterEvent *event )
{
event->acceptProposedAction();
emit mouseEntered( this );
m_hovered = true;
}
void
DropMenuEntry::dragLeaveEvent( QDragLeaveEvent *event )
{
emit mouseLeft( this );
m_hovered = false;
}
void
DropMenuEntry::setActive( bool active )
{
QFont font = m_label->font();
font.setBold( active );
m_label->setFont( font );
}
void
DropMenuEntry::dropEvent( QDropEvent *event )
{
emit dropReceived( event );
m_hovered = false;
}
bool
DropMenuEntry::hovered() const
{
return m_hovered;
}
DropJob::DropFlags
DropMenuEntry::dropFlags() const
{
return m_flags;
}

View File

@@ -0,0 +1,73 @@
#ifndef DROPMENU_H
#define DROPMENU_H
#include "dllmacro.h"
#include "dropjob.h"
#include <QWidget>
#include <QLabel>
class DropMenuEntry;
class DLLEXPORT DropMenu: public QWidget
{
Q_OBJECT
public:
/** @brief Create a DropMenu with the given default flags if an invalid/empty area is hovered */
explicit DropMenu( QWidget *parent = 0 );
void addEntry( DropMenuEntry *entry, bool isDefault = false );
void setFilter( DropJob::DropFlags shownEntries );
/** @brief Returns true if the mouse is somewhere over the contained entries */
bool hovered() const;
DropMenuEntry *activeEntry();
signals:
void dropReceived( QDropEvent *event );
void mouseLeft();
private slots:
void entryHovered( DropMenuEntry* entry );
void entryLeft( DropMenuEntry* entry );
private:
QList< DropMenuEntry* > m_entries;
DropJob::DropFlags m_defaultFlags;
DropMenuEntry *m_defaultEntry;
DropMenuEntry *m_activeEntry;
};
class DLLEXPORT DropMenuEntry : public QWidget
{
Q_OBJECT
public:
explicit DropMenuEntry( const QPixmap &icon, const QString &text, DropJob::DropFlags flags, QWidget *parent = 0 );
void setActive( bool active );
bool hovered() const;
DropJob::DropFlags dropFlags() const;
signals:
void dropReceived( QDropEvent *event );
void mouseEntered( DropMenuEntry *entry );
void mouseLeft( DropMenuEntry *entry );
public slots:
protected:
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dragLeaveEvent( QDragLeaveEvent *event );
virtual void dropEvent( QDropEvent *event );
private:
bool m_hovered;
QLabel *m_label;
DropJob::DropFlags m_flags;
};
#endif // DROPMENU_H

View File

@@ -22,6 +22,7 @@
#include <QMetaMethod> #include <QMetaMethod>
#include "audio/audioengine.h" #include "audio/audioengine.h"
#include "context/ContextWidget.h"
#include "utils/animatedsplitter.h" #include "utils/animatedsplitter.h"
#include "infobar/infobar.h" #include "infobar/infobar.h"
#include "topbar/topbar.h" #include "topbar/topbar.h"
@@ -31,7 +32,6 @@
#include "collectionview.h" #include "collectionview.h"
#include "playlistmodel.h" #include "playlistmodel.h"
#include "playlistview.h" #include "playlistview.h"
#include "queueview.h"
#include "trackproxymodel.h" #include "trackproxymodel.h"
#include "trackmodel.h" #include "trackmodel.h"
#include "artistview.h" #include "artistview.h"
@@ -77,37 +77,27 @@ ViewManager::ViewManager( QObject* parent )
m_widget->setLayout( new QVBoxLayout() ); m_widget->setLayout( new QVBoxLayout() );
m_topbar = new TopBar(); // m_topbar = new TopBar();
m_infobar = new InfoBar(); m_infobar = new InfoBar();
m_stack = new QStackedWidget(); m_stack = new QStackedWidget();
m_splitter = new AnimatedSplitter(); /* m_splitter = new AnimatedSplitter();
m_splitter->setOrientation( Qt::Vertical ); m_splitter->setOrientation( Qt::Vertical );
m_splitter->setChildrenCollapsible( false ); m_splitter->setChildrenCollapsible( false );
m_splitter->setGreedyWidget( 0 ); m_splitter->setGreedyWidget( 0 );
m_splitter->addWidget( m_stack ); m_splitter->addWidget( m_stack );*/
m_queueButton = new QPushButton(); // m_splitter->addWidget( m_queueView );
m_queueButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); // m_splitter->hide( 1, false );
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_queueView = new QueueView( m_splitter ); m_contextWidget = new ContextWidget();
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_widget->layout()->addWidget( m_infobar ); m_widget->layout()->addWidget( m_infobar );
m_widget->layout()->addWidget( m_topbar ); // m_widget->layout()->addWidget( m_topbar );
m_widget->layout()->addWidget( m_splitter ); // m_widget->layout()->addWidget( m_splitter );
m_widget->layout()->addWidget( m_queueButton ); m_widget->layout()->addWidget( m_stack );
m_widget->layout()->addWidget( m_contextWidget );
// m_widget->layout()->addWidget( m_queueButton );
m_superCollectionView = new ArtistView(); m_superCollectionView = new ArtistView();
m_superCollectionModel = new TreeModel( m_superCollectionView ); 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( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::PlaylistInterface* ) ) );
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); 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( flatMode() ), SLOT( setTableMode() ) );
connect( m_topbar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) ); 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* PlaylistView*
ViewManager::createPageForPlaylist( const playlist_ptr& pl ) ViewManager::createPageForPlaylist( const playlist_ptr& pl )
{ {
@@ -218,10 +200,10 @@ ViewManager::show( const Tomahawk::dynplaylist_ptr& playlist )
setPage( m_dynamicWidgets.value( playlist ).data() ); setPage( m_dynamicWidgets.value( playlist ).data() );
if ( playlist->mode() == Tomahawk::OnDemand ) /* if ( playlist->mode() == Tomahawk::OnDemand )
m_queueView->hide(); hideQueue();
else else
m_queueView->show(); showQueue();*/
emit numSourcesChanged( SourceList::instance()->count() ); 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 void
ViewManager::historyBack() ViewManager::historyBack()
{ {
@@ -699,7 +645,7 @@ ViewManager::updateView()
connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ), connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
SIGNAL( shuffleModeChanged( bool ) ) ); SIGNAL( shuffleModeChanged( bool ) ) );
m_topbar->setFilter( currentPlaylistInterface()->filter() ); // m_topbar->setFilter( currentPlaylistInterface()->filter() );
} }
if ( currentPage()->showStatsBar() && currentPlaylistInterface() ) if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
@@ -716,19 +662,19 @@ ViewManager::updateView()
emit modeChanged( currentPlaylistInterface()->viewMode() ); emit modeChanged( currentPlaylistInterface()->viewMode() );
} }
if ( currentPage()->queueVisible() ) /* if ( currentPage()->queueVisible() )
m_queueView->show(); showQueue();
else else
m_queueView->hide(); hideQueue();*/
emit statsAvailable( currentPage()->showStatsBar() ); emit statsAvailable( currentPage()->showStatsBar() );
emit modesAvailable( currentPage()->showModes() ); emit modesAvailable( currentPage()->showModes() );
emit filterAvailable( currentPage()->showFilter() ); emit filterAvailable( currentPage()->showFilter() );
if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() ) /* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
m_topbar->setVisible( false ); m_topbar->setVisible( false );
else else
m_topbar->setVisible( true ); m_topbar->setVisible( true );*/
m_infobar->setVisible( currentPage()->showInfoBar() ); m_infobar->setVisible( currentPage()->showInfoBar() );
m_infobar->setCaption( currentPage()->title() ); m_infobar->setCaption( currentPage()->title() );

View File

@@ -25,6 +25,7 @@
#include "collection.h" #include "collection.h"
#include "playlistinterface.h" #include "playlistinterface.h"
#include "playlist/queueview.h"
#include "viewpage.h" #include "viewpage.h"
#include "widgets/welcomewidget.h" #include "widgets/welcomewidget.h"
#include "widgets/whatshotwidget.h" #include "widgets/whatshotwidget.h"
@@ -40,9 +41,9 @@ class ArtistView;
class CollectionModel; class CollectionModel;
class CollectionFlatModel; class CollectionFlatModel;
class CollectionView; class CollectionView;
class ContextWidget;
class PlaylistModel; class PlaylistModel;
class PlaylistView; class PlaylistView;
class QueueView;
class TrackProxyModel; class TrackProxyModel;
class TrackModel; class TrackModel;
class TreeProxyModel; class TreeProxyModel;
@@ -71,8 +72,11 @@ public:
~ViewManager(); ~ViewManager();
QWidget* widget() const { return m_widget; } QWidget* widget() const { return m_widget; }
PlaylistView* queue() const; InfoBar* infobar() const { return m_infobar; }
TopBar* topbar() const { return m_topbar; } ContextWidget* context() const { return m_contextWidget; }
PlaylistView* queue() const { return m_queue->queue(); }
void setQueue( QueueView* queue ) { m_queue = queue; }
bool isSuperCollectionVisible() const; bool isSuperCollectionVisible() const;
bool isNewPlaylistPageVisible() const; bool isNewPlaylistPageVisible() const;
@@ -120,6 +124,9 @@ signals:
void tempPageActivated( Tomahawk::ViewPage* ); void tempPageActivated( Tomahawk::ViewPage* );
void viewPageActivated( Tomahawk::ViewPage* ); void viewPageActivated( Tomahawk::ViewPage* );
void showQueueRequested();
void hideQueueRequested();
public slots: public slots:
Tomahawk::ViewPage* showSuperCollection(); Tomahawk::ViewPage* showSuperCollection();
Tomahawk::ViewPage* showWelcomePage(); Tomahawk::ViewPage* showWelcomePage();
@@ -137,13 +144,13 @@ public slots:
void historyBack(); void historyBack();
void removeFromHistory( Tomahawk::ViewPage* p ); void removeFromHistory( Tomahawk::ViewPage* p );
void showQueue() { emit showQueueRequested(); }
void hideQueue() { emit hideQueueRequested(); }
void setTreeMode(); void setTreeMode();
void setTableMode(); void setTableMode();
void setAlbumMode(); void setAlbumMode();
void showQueue();
void hideQueue();
void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode ); void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode );
void setShuffled( bool enabled ); void setShuffled( bool enabled );
@@ -172,18 +179,15 @@ private:
QWidget* m_widget; QWidget* m_widget;
InfoBar* m_infobar; InfoBar* m_infobar;
TopBar* m_topbar; ContextWidget* m_contextWidget;
QPushButton* m_queueButton;
QStackedWidget* m_stack; QStackedWidget* m_stack;
AnimatedSplitter* m_splitter; AnimatedSplitter* m_splitter;
PlaylistModel* m_queueModel;
QueueView* m_queueView;
AlbumModel* m_superAlbumModel; AlbumModel* m_superAlbumModel;
AlbumView* m_superAlbumView; AlbumView* m_superAlbumView;
TreeModel* m_superCollectionModel; TreeModel* m_superCollectionModel;
ArtistView* m_superCollectionView; ArtistView* m_superCollectionView;
QueueView* m_queue;
WelcomeWidget* m_welcomeWidget; WelcomeWidget* m_welcomeWidget;
WhatsHotWidget* m_whatsHotWidget; WhatsHotWidget* m_whatsHotWidget;

View File

@@ -34,7 +34,6 @@ class DLLEXPORT ViewPage
{ {
public: public:
ViewPage() {} ViewPage() {}
virtual ~ViewPage() {} virtual ~ViewPage() {}
virtual QWidget* widget() = 0; virtual QWidget* widget() = 0;

View File

@@ -18,6 +18,7 @@
#include "HeaderLabel.h" #include "HeaderLabel.h"
#include <QApplication>
#include <QPainter> #include <QPainter>
#include "utils/logger.h" #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 void
HeaderLabel::paintEvent( QPaintEvent* /* event */ ) HeaderLabel::paintEvent( QPaintEvent* /* event */ )
{ {
@@ -58,7 +76,7 @@ HeaderLabel::paintEvent( QPaintEvent* /* event */ )
QRect r = contentsRect(); QRect r = contentsRect();
StyleHelper::horizontalHeader(&p, r); StyleHelper::horizontalHeader(&p, r);
QTextOption to( Qt::AlignVCenter ); QTextOption to( alignment() | Qt::AlignVCenter );
r.adjust( 8, 0, -8, 0 ); r.adjust( 8, 0, -8, 0 );
p.setPen( StyleHelper::headerTextColor() ); p.setPen( StyleHelper::headerTextColor() );
p.drawText( r, text(), to ); p.drawText( r, text(), to );

View File

@@ -20,6 +20,7 @@
#define HEADERLABEL_H #define HEADERLABEL_H
#include <QLabel> #include <QLabel>
#include <QTime>
#include "dllmacro.h" #include "dllmacro.h"
@@ -38,14 +39,19 @@ public:
QSize minimumSizeHint() const { return sizeHint(); } QSize minimumSizeHint() const { return sizeHint(); }
QSize sizeHint() const; QSize sizeHint() const;
public slots: signals:
void clicked();
protected: protected:
// void changeEvent( QEvent* e ); // void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* event ); void paintEvent( QPaintEvent* event );
void mousePressEvent( QMouseEvent* event );
void mouseReleaseEvent( QMouseEvent* event );
private: private:
QWidget* m_parent; QWidget* m_parent;
QTime m_time;
}; };
#endif // HEADERLABEL_H #endif // HEADERLABEL_H

View File

@@ -33,6 +33,7 @@
using namespace Tomahawk; using namespace Tomahawk;
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent ) ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::ArtistInfoWidget ) , ui( new Ui::ArtistInfoWidget )
@@ -58,8 +59,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_relatedModel = new TreeModel( ui->relatedArtists ); m_relatedModel = new TreeModel( ui->relatedArtists );
m_relatedModel->setColumnStyle( TreeModel::TrackOnly ); m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
ui->relatedArtists->setTreeModel( m_relatedModel ); ui->relatedArtists->setTreeModel( m_relatedModel );
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->header()->setVisible( false );
m_topHitsModel = new PlaylistModel( ui->topHits ); m_topHitsModel = new PlaylistModel( ui->topHits );
m_topHitsModel->setStyle( TrackModel::Short ); m_topHitsModel->setStyle( TrackModel::Short );
@@ -120,10 +119,7 @@ void
ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output ) ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
{ {
if ( requestData.caller != m_infoId ) if ( requestData.caller != m_infoId )
{
// qDebug() << "Info of wrong type or not with our identifier";
return; return;
}
InfoSystem::InfoCriteriaHash trackInfo; InfoSystem::InfoCriteriaHash trackInfo;
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >(); trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
@@ -137,7 +133,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 >(); QVariantMap returnedData = output.value< QVariantMap >();
switch ( requestData.type ) switch ( requestData.type )
{ {

View File

@@ -81,8 +81,6 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
m_tracksModel->setStyle( TrackModel::ShortWithAvatars ); m_tracksModel->setStyle( TrackModel::ShortWithAvatars );
ui->tracksView->overlay()->setEnabled( false ); ui->tracksView->overlay()->setEnabled( false );
ui->tracksView->setPlaylistModel( m_tracksModel ); ui->tracksView->setPlaylistModel( m_tracksModel );
ui->tracksView->setHeaderHidden( true );
ui->tracksView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_recentAlbumsModel = new AlbumModel( ui->additionsView ); m_recentAlbumsModel = new AlbumModel( ui->additionsView );
ui->additionsView->setAlbumModel( m_recentAlbumsModel ); ui->additionsView->setAlbumModel( m_recentAlbumsModel );

View File

@@ -259,15 +259,14 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
if ( dropType() == DropTypeLocalItems ) if ( dropType() == DropTypeLocalItems )
{ {
dj->setGetWholeArtists( true ); dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, true ); dj->setOnlyLocal( true );
} }
else if ( dropType() == DropTypeTop50 ) else if ( dropType() == DropTypeTop50 )
{ {
dj->setGetWholeArtists( true ); dj->setGetTop10( true );
dj->tracksFromMimeData( data, false, false, true );
} }
else
dj->tracksFromMimeData( data, false, false ); dj->tracksFromMimeData( data );
return true; return true;
} }

View File

@@ -183,15 +183,12 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
if ( dropType() == DropTypeLocalItems ) if ( dropType() == DropTypeLocalItems )
{ {
dj->setGetWholeArtists( true ); dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, true ); dj->setOnlyLocal( true );
} }
else if ( dropType() == DropTypeTop50 ) else if ( dropType() == DropTypeTop50 )
{ dj->setGetTop10( true );
dj->setGetWholeArtists( true );
dj->tracksFromMimeData( data, false, false, true ); dj->tracksFromMimeData( data);
}
else
dj->tracksFromMimeData( data, false, false );
// TODO cant' know if it works or not yet... // TODO cant' know if it works or not yet...
return true; return true;

View File

@@ -43,7 +43,6 @@
#include "sourcetree/sourcetreeview.h" #include "sourcetree/sourcetreeview.h"
#include "utils/animatedsplitter.h" #include "utils/animatedsplitter.h"
#include "utils/proxystyle.h" #include "utils/proxystyle.h"
#include "utils/widgetdragfilter.h"
#include "utils/xspfloader.h" #include "utils/xspfloader.h"
#include "widgets/newplaylistwidget.h" #include "widgets/newplaylistwidget.h"
#include "widgets/searchwidget.h" #include "widgets/searchwidget.h"
@@ -59,6 +58,7 @@
#include "tomahawktrayicon.h" #include "tomahawktrayicon.h"
#include "playlist/dynamic/GeneratorInterface.h" #include "playlist/dynamic/GeneratorInterface.h"
#include "scanmanager.h" #include "scanmanager.h"
#include "playlist/queueview.h"
#include "tomahawkapp.h" #include "tomahawkapp.h"
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
@@ -80,7 +80,10 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
{ {
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) ); 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 ); ui->setupUi( this );
applyPlatformTweaks(); applyPlatformTweaks();
@@ -96,7 +99,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
// set initial state // set initial state
onSipDisconnected(); onSipDisconnected();
ViewManager::instance()->showWelcomePage(); vm->setQueue( m_queueView );
vm->showWelcomePage();
} }
@@ -184,28 +188,38 @@ TomahawkWindow::setupSideBar()
QWidget* sidebarWidget = new QWidget(); QWidget* sidebarWidget = new QWidget();
sidebarWidget->setLayout( new QVBoxLayout() ); sidebarWidget->setLayout( new QVBoxLayout() );
AnimatedSplitter* sidebar = new AnimatedSplitter(); m_sidebar = new AnimatedSplitter();
sidebar->setOrientation( Qt::Vertical ); m_sidebar->setOrientation( Qt::Vertical );
sidebar->setChildrenCollapsible( false ); m_sidebar->setChildrenCollapsible( false );
m_searchWidget = new QSearchField( sidebar ); m_searchWidget = new QSearchField( m_sidebar );
m_searchWidget->setPlaceholderText( "Global Search..." ); m_searchWidget->setPlaceholderText( "Global Search..." );
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) ); connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
m_sourcetree = new SourceTreeView(); m_sourcetree = new SourceTreeView();
TransferView* transferView = new TransferView( sidebar ); TransferView* transferView = new TransferView( m_sidebar );
PipelineStatusView* pipelineView = new PipelineStatusView( sidebar ); PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
sidebar->addWidget( m_searchWidget ); m_queueView = new QueueView( m_sidebar );
sidebar->addWidget( m_sourcetree ); m_queueModel = new PlaylistModel( m_queueView );
sidebar->addWidget( transferView ); m_queueModel->setStyle( PlaylistModel::Short );
sidebar->addWidget( pipelineView ); m_queueView->queue()->setPlaylistModel( m_queueModel );
m_queueView->queue()->playlistModel()->setReadOnly( false );
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
sidebar->setGreedyWidget( 1 ); m_sidebar->addWidget( m_searchWidget );
sidebar->hide( 1, false ); m_sidebar->addWidget( m_sourcetree );
sidebar->hide( 2, false ); m_sidebar->addWidget( transferView );
m_sidebar->addWidget( pipelineView );
m_sidebar->addWidget( m_queueView );
sidebarWidget->layout()->addWidget( sidebar ); 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->setContentsMargins( 0, 0, 0, 0 ); sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setMargin( 0 ); sidebarWidget->layout()->setMargin( 0 );
@@ -225,6 +239,7 @@ TomahawkWindow::setupSideBar()
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() ); ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
} }
void void
TomahawkWindow::setupUpdateCheck() TomahawkWindow::setupUpdateCheck()
{ {
@@ -663,6 +678,34 @@ 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_queueView->show();
}
void
TomahawkWindow::hideQueue()
{
if ( QThread::currentThread() != thread() )
{
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
return;
}
m_queueView->hide();
}
void void
TomahawkWindow::minimize() TomahawkWindow::minimize()
{ {

View File

@@ -35,6 +35,9 @@ class QAction;
class MusicScanner; class MusicScanner;
class AudioControls; class AudioControls;
class TomahawkTrayIcon; class TomahawkTrayIcon;
class PlaylistModel;
class QueueView;
class AnimatedSplitter;
namespace Ui namespace Ui
{ {
@@ -95,6 +98,9 @@ private slots:
void onSearch( const QString& search ); void onSearch( const QString& search );
void onFilterEdited(); void onFilterEdited();
void showQueue();
void hideQueue();
void minimize(); void minimize();
void maximize(); void maximize();
@@ -114,6 +120,10 @@ private:
TomahawkTrayIcon* m_trayIcon; TomahawkTrayIcon* m_trayIcon;
SourceTreeView* m_sourcetree; SourceTreeView* m_sourcetree;
QPushButton* m_statusButton; QPushButton* m_statusButton;
QPushButton* m_queueButton;
PlaylistModel* m_queueModel;
QueueView* m_queueView;
AnimatedSplitter* m_sidebar;
Tomahawk::result_ptr m_currentTrack; Tomahawk::result_ptr m_currentTrack;
QString m_windowTitle; QString m_windowTitle;