mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-09-06 04:02:54 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a78a25baa6 | ||
|
375ffd1445 | ||
|
c3d223d8cb | ||
|
b2f3dedaff | ||
|
a3ae74dc10 | ||
|
4dfb989676 | ||
|
e0d1289a16 | ||
|
cc5ba35a08 | ||
|
e0e79c09a4 | ||
|
03f726f46c | ||
|
c0edc3a989 |
@@ -47,6 +47,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
, ui( new Ui::AudioControls )
|
||||
, m_repeatMode( PlaylistInterface::NoRepeat )
|
||||
, m_shuffled( false )
|
||||
, m_dropAreaExpanded( false )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
setAcceptDrops( true );
|
||||
@@ -148,6 +149,46 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize );
|
||||
|
||||
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 )
|
||||
{
|
||||
if ( DropJob::acceptsMimeData( e->mimeData() ) )
|
||||
{
|
||||
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
|
||||
AudioControls::dropEvent( QDropEvent* e )
|
||||
{
|
||||
@@ -541,8 +637,11 @@ AudioControls::dropEvent( QDropEvent* e )
|
||||
{
|
||||
DropJob *dj = new DropJob();
|
||||
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() );
|
||||
|
||||
QTimer::singleShot( 0, this, SLOT( collapseDropMenu() ) );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
@@ -21,10 +21,13 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimeLine>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QTimer>
|
||||
|
||||
#include "result.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
#include "utils/dropmenu.h"
|
||||
|
||||
class QDropEvent;
|
||||
class QDragEnterEvent;
|
||||
@@ -37,6 +40,7 @@ namespace Ui
|
||||
class AudioControls : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( int dropAreaSize READ dropAreaSize WRITE setDropAreaSize )
|
||||
|
||||
public:
|
||||
AudioControls( QWidget* parent = 0 );
|
||||
@@ -54,8 +58,12 @@ protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void dragEnterEvent ( QDragEnterEvent* );
|
||||
void dragMoveEvent ( QDragMoveEvent* );
|
||||
void dragLeaveEvent( QDragLeaveEvent * );
|
||||
void dropEvent ( QDropEvent* );
|
||||
|
||||
int dropAreaSize();
|
||||
void setDropAreaSize( int size );
|
||||
|
||||
private slots:
|
||||
void onPlaybackStarted( const Tomahawk::result_ptr& result );
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
@@ -82,6 +90,10 @@ private slots:
|
||||
|
||||
void socialActionsLoaded();
|
||||
|
||||
void collapseDropMenu();
|
||||
void dragAnimationFinished();
|
||||
void dropReceived( QDropEvent *event );
|
||||
|
||||
private:
|
||||
Ui::AudioControls *ui;
|
||||
|
||||
@@ -93,6 +105,10 @@ private:
|
||||
|
||||
QTimeLine m_sliderTimeLine;
|
||||
qint64 m_seekMsecs;
|
||||
|
||||
QPropertyAnimation *m_dragAnimation;
|
||||
bool m_dropAreaExpanded;
|
||||
QTimer m_dropAreaCollapseTimer;
|
||||
};
|
||||
|
||||
#endif // AUDIOCONTROLS_H
|
||||
|
@@ -84,14 +84,14 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<item row="0" column="0">
|
||||
<widget class="ImageButton" name="playPauseButton">
|
||||
<property name="text">
|
||||
<string>Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="0">
|
||||
<widget class="ImageButton" name="pauseButton">
|
||||
<property name="text">
|
||||
<string>Pause</string>
|
||||
@@ -125,248 +125,269 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="metaDataArea" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<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">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="coverImage">
|
||||
<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>
|
||||
<widget class="DropMenu" name="metaDataDropArea" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
<width>16777215</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
<widget class="QWidget" name="metaDataInfoArea" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>74</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="trackLabelLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QueryLabel" name="artistTrackLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Artist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QueryLabel" name="albumLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>4</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="ImageButton" name="loveButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>love</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="ownerLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>7</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owner</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<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>
|
||||
<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>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="coverImage">
|
||||
<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">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="1,0,0,0">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="trackLabelLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QueryLabel" name="artistTrackLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Artist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QueryLabel" name="albumLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>4</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="ImageButton" name="loveButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>love</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>13</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="ownerLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>7</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owner</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<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>
|
||||
</layout>
|
||||
<zorder>metaDataInfoArea</zorder>
|
||||
<zorder>metaDataDropArea</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -544,6 +565,12 @@
|
||||
<extends>QLabel</extends>
|
||||
<header>utils/querylabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>DropMenu</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>utils/dropmenu.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@@ -40,6 +40,13 @@ set( libSources
|
||||
|
||||
audio/audioengine.cpp
|
||||
|
||||
context/ContextPage.cpp
|
||||
context/ContextWidget.cpp
|
||||
context/pages/TopTracksContext.cpp
|
||||
context/pages/RelatedArtistsContext.cpp
|
||||
context/pages/WikipediaContext.cpp
|
||||
context/pages/WebContext.cpp
|
||||
|
||||
database/database.cpp
|
||||
database/fuzzyindex.cpp
|
||||
database/databasecollection.cpp
|
||||
@@ -176,6 +183,7 @@ set( libSources
|
||||
utils/rdioparser.cpp
|
||||
utils/shortenedlinkparser.cpp
|
||||
utils/stylehelper.cpp
|
||||
utils/dropmenu.cpp
|
||||
|
||||
widgets/newplaylistwidget.cpp
|
||||
widgets/searchwidget.cpp
|
||||
@@ -234,6 +242,13 @@ set( libHeaders
|
||||
|
||||
audio/audioengine.h
|
||||
|
||||
context/ContextPage.h
|
||||
context/ContextWidget.h
|
||||
context/pages/TopTracksContext.h
|
||||
context/pages/RelatedArtistsContext.h
|
||||
context/pages/WikipediaContext.h
|
||||
context/pages/WebContext.h
|
||||
|
||||
database/database.h
|
||||
database/fuzzyindex.h
|
||||
database/databaseworker.h
|
||||
@@ -367,6 +382,7 @@ set( libHeaders
|
||||
utils/rdioparser.h
|
||||
utils/shortenedlinkparser.h
|
||||
utils/stylehelper.h
|
||||
utils/dropmenu.h
|
||||
|
||||
widgets/newplaylistwidget.h
|
||||
widgets/searchwidget.h
|
||||
@@ -417,6 +433,8 @@ set( libUI ${libUI}
|
||||
widgets/infowidgets/AlbumInfoWidget.ui
|
||||
playlist/topbar/topbar.ui
|
||||
playlist/infobar/infobar.ui
|
||||
playlist/queueview.ui
|
||||
context/ContextWidget.ui
|
||||
)
|
||||
|
||||
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ..
|
||||
|
94
src/libtomahawk/context/ContextPage.cpp
Normal file
94
src/libtomahawk/context/ContextPage.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ContextPage.h"
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
void
|
||||
ContextProxyPage::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
painter->setPen( StyleHelper::headerHighlightColor() );
|
||||
painter->setBrush( StyleHelper::headerHighlightColor() );
|
||||
painter->drawRoundedRect( option->rect, 4.0, 4.0 );
|
||||
|
||||
QFont f( font() );
|
||||
f.setBold( true );
|
||||
f.setPixelSize( 14 );
|
||||
painter->setFont( f );
|
||||
painter->setPen( Qt::white );
|
||||
|
||||
QRect r( 1, 1, option->rect.width(), 19 );
|
||||
QTextOption to( Qt::AlignCenter );
|
||||
painter->drawText( r, m_page->title(), to );
|
||||
|
||||
painter->restore();
|
||||
|
||||
QGraphicsWidget::paint( painter, option, widget );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ContextProxyPage::setPage( Tomahawk::ContextPage* page )
|
||||
{
|
||||
m_page = page;
|
||||
|
||||
QGraphicsWebView* testWebView = qobject_cast<QGraphicsWebView*>( page->widget() );
|
||||
if ( testWebView )
|
||||
{
|
||||
setContentsMargins( 4, 4, 4, 4 );
|
||||
}
|
||||
|
||||
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout();
|
||||
layout->setContentsMargins( 4, 20, 4, 4 );
|
||||
layout->addItem( page->widget() );
|
||||
setLayout( layout );
|
||||
|
||||
page->widget()->installEventFilter( this );
|
||||
page->widget()->installSceneEventFilter( this );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ContextProxyPage::eventFilter( QObject* watched, QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::GrabMouse )
|
||||
{
|
||||
emit focused();
|
||||
}
|
||||
|
||||
return QGraphicsWidget::eventFilter( watched, event );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ContextProxyPage::sceneEvent( QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::GrabMouse )
|
||||
{
|
||||
emit focused();
|
||||
}
|
||||
|
||||
return QGraphicsWidget::sceneEvent( event );
|
||||
}
|
91
src/libtomahawk/context/ContextPage.h
Normal file
91
src/libtomahawk/context/ContextPage.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONTEXTPAGE_H
|
||||
#define CONTEXTPAGE_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
#include <QGraphicsWebView>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
#include "typedefs.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "utils/stylehelper.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
#include <signal.h>
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
class DLLEXPORT ContextPage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ContextPage() {}
|
||||
virtual ~ContextPage() {}
|
||||
|
||||
virtual QGraphicsWidget* widget() = 0;
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const = 0;
|
||||
|
||||
virtual QString title() const = 0;
|
||||
virtual QString description() const = 0;
|
||||
virtual QPixmap pixmap() const { return QPixmap( RESPATH "icons/tomahawk-icon-128x128.png" ); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() = 0;
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query ) = 0;
|
||||
|
||||
signals:
|
||||
void nameChanged( const QString& );
|
||||
void descriptionChanged( const QString& );
|
||||
void pixmapChanged( const QPixmap& );
|
||||
void destroyed( QWidget* widget );
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT ContextProxyPage : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ContextProxyPage() : QGraphicsWidget()
|
||||
{}
|
||||
|
||||
Tomahawk::ContextPage* page() const { return m_page; }
|
||||
void setPage( Tomahawk::ContextPage* page );
|
||||
|
||||
virtual bool eventFilter( QObject* watched, QEvent* event );
|
||||
|
||||
signals:
|
||||
void focused();
|
||||
|
||||
protected:
|
||||
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget );
|
||||
virtual bool sceneEvent( QEvent* event );
|
||||
|
||||
private:
|
||||
Tomahawk::ContextPage* m_page;
|
||||
};
|
||||
|
||||
}; // ns
|
||||
|
||||
#endif //CONTEXTPAGE_H
|
306
src/libtomahawk/context/ContextWidget.cpp
Normal file
306
src/libtomahawk/context/ContextWidget.cpp
Normal 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 );
|
||||
}
|
||||
}
|
88
src/libtomahawk/context/ContextWidget.h
Normal file
88
src/libtomahawk/context/ContextWidget.h
Normal 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
|
76
src/libtomahawk/context/ContextWidget.ui
Normal file
76
src/libtomahawk/context/ContextWidget.ui
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ContextWidget</class>
|
||||
<widget class="QWidget" name="ContextWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>774</width>
|
||||
<height>72</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>72</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>InfoBar</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="HeaderLabel" name="toggleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dashboard</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::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>
|
123
src/libtomahawk/context/pages/RelatedArtistsContext.cpp
Normal file
123
src/libtomahawk/context/pages/RelatedArtistsContext.cpp
Normal 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 );
|
||||
}
|
67
src/libtomahawk/context/pages/RelatedArtistsContext.h
Normal file
67
src/libtomahawk/context/pages/RelatedArtistsContext.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RELATEDARTISTSCONTEXT_H
|
||||
#define RELATEDARTISTSCONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "context/ContextPage.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
class TreeModel;
|
||||
class ArtistView;
|
||||
|
||||
class DLLEXPORT RelatedArtistsContext : public Tomahawk::ContextPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RelatedArtistsContext();
|
||||
~RelatedArtistsContext();
|
||||
|
||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Related Artists" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
ArtistView* m_relatedView;
|
||||
TreeModel* m_relatedModel;
|
||||
|
||||
QGraphicsProxyWidget* m_proxy;
|
||||
|
||||
QString m_infoId;
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // RELATEDARTISTSCONTEXT_H
|
129
src/libtomahawk/context/pages/TopTracksContext.cpp
Normal file
129
src/libtomahawk/context/pages/TopTracksContext.cpp
Normal 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 );
|
||||
}
|
67
src/libtomahawk/context/pages/TopTracksContext.h
Normal file
67
src/libtomahawk/context/pages/TopTracksContext.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOPTRACKSCONTEXT_H
|
||||
#define TOPTRACKSCONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "context/ContextPage.h"
|
||||
#include "infosystem/infosystem.h"
|
||||
|
||||
class PlaylistModel;
|
||||
class PlaylistView;
|
||||
|
||||
class DLLEXPORT TopTracksContext : public Tomahawk::ContextPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TopTracksContext();
|
||||
~TopTracksContext();
|
||||
|
||||
virtual QGraphicsWidget* widget() { return m_proxy; }
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Top Hits" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private slots:
|
||||
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
|
||||
void infoSystemFinished( QString target );
|
||||
|
||||
private:
|
||||
PlaylistView* m_topHitsView;
|
||||
PlaylistModel* m_topHitsModel;
|
||||
|
||||
QGraphicsProxyWidget* m_proxy;
|
||||
|
||||
QString m_infoId;
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // TOPTRACKSCONTEXT_H
|
37
src/libtomahawk/context/pages/WebContext.cpp
Normal file
37
src/libtomahawk/context/pages/WebContext.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "WebContext.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
WebContext::WebContext()
|
||||
: ContextPage()
|
||||
{
|
||||
m_webView = new QGraphicsWebView();
|
||||
|
||||
QPalette pal = m_webView->palette();
|
||||
pal.setColor( QPalette::Window, QColor( 0, 0, 0, 0 ) );
|
||||
m_webView->setPalette( pal );
|
||||
}
|
||||
|
||||
|
||||
WebContext::~WebContext()
|
||||
{
|
||||
}
|
45
src/libtomahawk/context/pages/WebContext.h
Normal file
45
src/libtomahawk/context/pages/WebContext.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WEBCONTEXT_H
|
||||
#define WEBCONTEXT_H
|
||||
|
||||
#include <QGraphicsWebView>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "context/ContextPage.h"
|
||||
|
||||
class DLLEXPORT WebContext : public Tomahawk::ContextPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WebContext();
|
||||
~WebContext();
|
||||
|
||||
QGraphicsWebView* webView() const { return m_webView; }
|
||||
virtual QGraphicsWidget* widget() { return m_webView; }
|
||||
|
||||
private:
|
||||
QGraphicsWebView* m_webView;
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // WEBCONTEXT_H
|
43
src/libtomahawk/context/pages/WikipediaContext.cpp
Normal file
43
src/libtomahawk/context/pages/WikipediaContext.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "WikipediaContext.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
void
|
||||
WikipediaContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
webView()->load( QString( "http://en.wikipedia.org/w/index.php?printable=yes&title=%1" ).arg( query->artist() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LastfmContext::setQuery( const Tomahawk::query_ptr& query )
|
||||
{
|
||||
if ( !m_query.isNull() && query->artist() == m_query->artist() )
|
||||
return;
|
||||
|
||||
m_query = query;
|
||||
webView()->load( QString( "http://last.fm/music/%1" ).arg( query->artist() ) );
|
||||
}
|
74
src/libtomahawk/context/pages/WikipediaContext.h
Normal file
74
src/libtomahawk/context/pages/WikipediaContext.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WIKIPEDIACONTEXT_H
|
||||
#define WIKIPEDIACONTEXT_H
|
||||
|
||||
#include <QGraphicsProxyWidget>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
#include "WebContext.h"
|
||||
|
||||
class DLLEXPORT WikipediaContext : public WebContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WikipediaContext() : WebContext() {}
|
||||
~WikipediaContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Wikipedia" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private:
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
|
||||
class DLLEXPORT LastfmContext : public WebContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LastfmContext() : WebContext() {}
|
||||
~LastfmContext() {}
|
||||
|
||||
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
|
||||
|
||||
virtual QString title() const { return tr( "Last.fm" ); }
|
||||
virtual QString description() const { return QString(); }
|
||||
|
||||
virtual bool jumpToCurrentTrack() { return false; }
|
||||
|
||||
public slots:
|
||||
virtual void setQuery( const Tomahawk::query_ptr& query );
|
||||
|
||||
private:
|
||||
Tomahawk::query_ptr m_query;
|
||||
};
|
||||
|
||||
#endif // WIKIPEDIACONTEXT_H
|
@@ -34,6 +34,7 @@ using namespace Tomahawk;
|
||||
DropJob::DropJob( QObject *parent )
|
||||
: QObject( parent )
|
||||
, m_queryCount( 0 )
|
||||
, m_dropFlags( DropFlagsNone )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -98,31 +99,72 @@ DropJob::acceptsMimeData( const QMimeData* data, bool tracksOnly )
|
||||
void
|
||||
DropJob::setGetWholeArtists( bool getWholeArtists )
|
||||
{
|
||||
m_getWholeArtists = getWholeArtists;
|
||||
if( getWholeArtists )
|
||||
m_dropFlags |= DropFlagArtist;
|
||||
else
|
||||
m_dropFlags &= !DropFlagArtist;
|
||||
}
|
||||
|
||||
void
|
||||
DropJob::setGetWholeAlbums( bool getWholeAlbums )
|
||||
{
|
||||
m_getWholeAlbums = getWholeAlbums;
|
||||
if ( getWholeAlbums )
|
||||
m_dropFlags |= DropFlagAlbum;
|
||||
else
|
||||
m_dropFlags &= !DropFlagAlbum;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DropJob::tracksFromMimeData( const QMimeData* data, bool allowDuplicates, bool onlyLocal, bool top10 )
|
||||
DropJob::setGetTop10( bool top10 )
|
||||
{
|
||||
m_allowDuplicates = allowDuplicates;
|
||||
m_onlyLocal = onlyLocal;
|
||||
m_top10 = top10;
|
||||
if( top10 )
|
||||
m_dropFlags |= DropFlagTop10;
|
||||
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 );
|
||||
|
||||
if ( m_queryCount == 0 )
|
||||
{
|
||||
if ( onlyLocal )
|
||||
if ( m_dropFlags.testFlag( DropFlagLocal ) )
|
||||
removeRemoteSources();
|
||||
|
||||
if ( !allowDuplicates )
|
||||
if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
|
||||
removeDuplicates();
|
||||
|
||||
emit tracks( m_resultList );
|
||||
@@ -171,15 +213,15 @@ DropJob::tracksFromQueryList( const QMimeData* data )
|
||||
{
|
||||
tDebug() << "Dropped query item:" << query->data()->artist() << "-" << query->data()->track();
|
||||
|
||||
if ( m_top10 )
|
||||
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
|
||||
{
|
||||
getTopTen( query->data()->artist() );
|
||||
}
|
||||
else if ( m_getWholeArtists )
|
||||
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
|
||||
{
|
||||
queries << getArtist( query->data()->artist() );
|
||||
}
|
||||
else if ( m_getWholeAlbums )
|
||||
else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
|
||||
{
|
||||
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();
|
||||
query_ptr q = result->data()->toQuery();
|
||||
|
||||
if ( m_top10 )
|
||||
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
|
||||
{
|
||||
getTopTen( q->artist() );
|
||||
}
|
||||
else if ( m_getWholeArtists )
|
||||
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
|
||||
{
|
||||
queries << getArtist( q->artist() );
|
||||
}
|
||||
else if ( m_getWholeAlbums )
|
||||
else if ( m_dropFlags.testFlag( DropFlagAlbum ) )
|
||||
{
|
||||
queries << getAlbum( q->artist(), q->album() );
|
||||
}
|
||||
@@ -248,9 +290,9 @@ DropJob::tracksFromAlbumMetaData( const QMimeData *data )
|
||||
QString album;
|
||||
stream >> album;
|
||||
|
||||
if ( m_top10 )
|
||||
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
|
||||
getTopTen( artist );
|
||||
else if ( m_getWholeArtists )
|
||||
else if ( m_dropFlags.testFlag( DropFlagArtist ) )
|
||||
queries << getArtist( artist );
|
||||
else
|
||||
queries << getAlbum( artist, album );
|
||||
@@ -270,14 +312,10 @@ DropJob::tracksFromArtistMetaData( const QMimeData *data )
|
||||
QString artist;
|
||||
stream >> artist;
|
||||
|
||||
if ( !m_top10 )
|
||||
{
|
||||
queries << getArtist( artist );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_dropFlags.testFlag( DropFlagTop10 ) )
|
||||
getTopTen( artist );
|
||||
}
|
||||
else
|
||||
queries << getArtist( artist );
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
@@ -381,10 +419,10 @@ DropJob::onTracksAdded( const QList<Tomahawk::query_ptr>& tracksList )
|
||||
|
||||
if ( --m_queryCount == 0 )
|
||||
{
|
||||
if ( m_onlyLocal )
|
||||
if ( m_dropFlags.testFlag( DropFlagLocal ) )
|
||||
removeRemoteSources();
|
||||
|
||||
if ( !m_allowDuplicates )
|
||||
if ( !m_dropFlags.testFlag( DropFlagAllowDuplicates ) )
|
||||
removeDuplicates();
|
||||
|
||||
emit tracks( m_resultList );
|
||||
|
@@ -28,10 +28,48 @@
|
||||
#include <QStringList>
|
||||
#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
|
||||
{
|
||||
Q_OBJECT
|
||||
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 );
|
||||
~DropJob();
|
||||
|
||||
@@ -46,9 +84,15 @@ public:
|
||||
static bool acceptsMimeData( const QMimeData* data, bool tracksOnly = true );
|
||||
static QStringList mimeTypes();
|
||||
|
||||
void setDropFlags( DropFlags flags );
|
||||
|
||||
void setGetWholeArtists( bool getWholeArtists );
|
||||
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:
|
||||
/// QMimeData parsing results
|
||||
@@ -81,13 +125,10 @@ private:
|
||||
void removeRemoteSources();
|
||||
|
||||
int m_queryCount;
|
||||
bool m_allowDuplicates;
|
||||
bool m_onlyLocal;
|
||||
bool m_getWholeArtists;
|
||||
bool m_getWholeAlbums;
|
||||
bool m_top10;
|
||||
DropFlags m_dropFlags;
|
||||
|
||||
QList< Tomahawk::query_ptr > m_resultList;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( DropJob::DropFlags )
|
||||
|
||||
#endif // DROPJOB_H
|
||||
|
@@ -467,7 +467,7 @@ GlobalActionManager::handleSearchCommand( const QUrl& url )
|
||||
return false;
|
||||
|
||||
ViewManager::instance()->showSuperCollection();
|
||||
ViewManager::instance()->topbar()->setFilter( queryStr );
|
||||
// ViewManager::instance()->topbar()->setFilter( queryStr );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -129,6 +129,17 @@ ArtistView::setTreeModel( TreeModel* model )
|
||||
connect( m_proxyModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ) );
|
||||
|
||||
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 );
|
||||
m_header->checkState();
|
||||
|
||||
if ( model()->columnCount( QModelIndex() ) == 1 )
|
||||
{
|
||||
m_header->resizeSection( 0, event->size().width() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -333,5 +349,8 @@ ArtistView::jumpToCurrentTrack()
|
||||
QString
|
||||
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;
|
||||
}
|
||||
|
@@ -40,6 +40,9 @@ public:
|
||||
explicit ArtistView( QWidget* parent = 0 );
|
||||
~ArtistView();
|
||||
|
||||
virtual QString guid() const;
|
||||
virtual void setGuid( const QString& guid ) { m_guid = guid; }
|
||||
|
||||
void setProxyModel( TreeProxyModel* model );
|
||||
|
||||
TreeModel* model() const { return m_model; }
|
||||
@@ -64,8 +67,6 @@ public:
|
||||
|
||||
virtual bool jumpToCurrentTrack();
|
||||
|
||||
QString guid() const;
|
||||
|
||||
public slots:
|
||||
void onItemActivated( const QModelIndex& index );
|
||||
|
||||
@@ -96,6 +97,7 @@ private:
|
||||
|
||||
bool m_showModes;
|
||||
QTimer m_timer;
|
||||
mutable QString m_guid;
|
||||
};
|
||||
|
||||
#endif // ARTISTVIEW_H
|
||||
|
@@ -20,22 +20,25 @@
|
||||
#include "ui_infobar.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "context/ContextWidget.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
#define ANIMATION_TIME 400
|
||||
#define IMAGE_HEIGHT 64
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
InfoBar::InfoBar( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::InfoBar )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
layout()->setSpacing( 0 );
|
||||
layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
TomahawkUtils::unmarginLayout( layout() );
|
||||
layout()->setContentsMargins( 8, 4, 8, 4 );
|
||||
|
||||
QFont boldFont = ui->captionLabel->font();
|
||||
boldFont.setPixelSize( 18 );
|
||||
|
@@ -23,6 +23,11 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
#include "query.h"
|
||||
|
||||
class QTimeLine;
|
||||
class ContextWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class InfoBar;
|
||||
|
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>72</height>
|
||||
<width>774</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -25,168 +25,149 @@
|
||||
<property name="windowTitle">
|
||||
<string>InfoBar</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,1,0,99,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="captionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="descriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="longDescriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>62</height>
|
||||
<width>64</width>
|
||||
<height>64</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>1</height>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="captionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ElidedLabel" name="descriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="longDescriptionLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>62</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@@ -117,7 +117,7 @@ PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const
|
||||
opacity = item->query()->results().first()->score();
|
||||
|
||||
opacity = qMax( (float)0.3, opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option->palette.color( QPalette::Foreground ), option->palette.color( QPalette::Background ), opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option->palette.color( QPalette::Text ), option->palette.color( QPalette::BrightText ), opacity );
|
||||
|
||||
option->palette.setColor( QPalette::Text, textColor );
|
||||
}
|
||||
|
@@ -176,8 +176,8 @@ PlaylistModel::clear()
|
||||
emit beginResetModel();
|
||||
delete m_rootItem;
|
||||
m_rootItem = 0;
|
||||
emit endResetModel();
|
||||
m_rootItem = new TrackModelItem( 0, this );
|
||||
emit endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -62,13 +62,16 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
|
||||
TrackView::setTrackModel( m_model );
|
||||
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() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
|
||||
if ( !m_model->playlist().isNull() )
|
||||
{
|
||||
setGuid( QString( "playlistview/%1/%2" ).arg( m_model->columnCount() ).arg( m_model->playlist()->guid() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
|
||||
}
|
||||
}
|
||||
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
|
@@ -17,9 +17,11 @@
|
||||
*/
|
||||
|
||||
#include "queueview.h"
|
||||
#include "ui_queueview.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "widgets/HeaderLabel.h"
|
||||
#include "playlist/queueproxymodel.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
#include "utils/logger.h"
|
||||
@@ -29,19 +31,21 @@ using namespace Tomahawk;
|
||||
|
||||
QueueView::QueueView( AnimatedSplitter* parent )
|
||||
: AnimatedWidget( parent )
|
||||
, ui( new Ui::QueueView )
|
||||
{
|
||||
setHiddenSize( QSize( 0, 0 ) );
|
||||
setLayout( new QVBoxLayout() );
|
||||
ui->setupUi( this );
|
||||
TomahawkUtils::unmarginLayout( layout() );
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
m_queue = new PlaylistView( this );
|
||||
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 );
|
||||
setHiddenSize( QSize( 0, 22 ) );
|
||||
|
||||
layout()->setMargin( 0 );
|
||||
layout()->addWidget( m_queue );
|
||||
ui->queue->setProxyModel( new QueueProxyModel( this ) );
|
||||
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
|
||||
QueueView::onShown( QWidget* widget, bool animated )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << widget;
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
@@ -65,7 +95,6 @@ QueueView::onShown( QWidget* widget, bool animated )
|
||||
void
|
||||
QueueView::onHidden( QWidget* widget, bool animated )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << widget;
|
||||
if ( widget != this )
|
||||
return;
|
||||
|
||||
|
@@ -26,6 +26,11 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class QueueView;
|
||||
}
|
||||
|
||||
class DLLEXPORT QueueView : public AnimatedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -34,7 +39,7 @@ public:
|
||||
explicit QueueView( AnimatedSplitter* parent );
|
||||
~QueueView();
|
||||
|
||||
PlaylistView* queue() const { return m_queue; }
|
||||
PlaylistView* queue() const;
|
||||
|
||||
QSize sizeHint() const { return QSize( 0, 200 ); }
|
||||
|
||||
@@ -42,8 +47,11 @@ public slots:
|
||||
virtual void onShown( QWidget*, bool animated );
|
||||
virtual void onHidden( QWidget*, bool animated );
|
||||
|
||||
virtual void show();
|
||||
virtual void hide();
|
||||
|
||||
private:
|
||||
PlaylistView* m_queue;
|
||||
Ui::QueueView* ui;
|
||||
};
|
||||
|
||||
#endif // QUEUEVIEW_H
|
||||
|
81
src/libtomahawk/playlist/queueview.ui
Normal file
81
src/libtomahawk/playlist/queueview.ui
Normal 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>
|
@@ -24,11 +24,11 @@
|
||||
|
||||
#include "trackheader.h"
|
||||
#include "viewmanager.h"
|
||||
#include "queueview.h"
|
||||
#include "trackmodel.h"
|
||||
#include "trackproxymodel.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "context/ContextWidget.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
#include "dynamic/widgets/LoadingSpinner.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
@@ -48,6 +48,7 @@ TrackView::TrackView( QWidget* parent )
|
||||
, m_loadingSpinner( new LoadingSpinner( this ) )
|
||||
, m_resizing( false )
|
||||
, m_dragging( false )
|
||||
, m_updateContextView( true )
|
||||
, m_contextMenu( new ContextMenu( this ) )
|
||||
{
|
||||
setMouseTracking( true );
|
||||
@@ -141,7 +142,7 @@ TrackView::setTrackModel( TrackModel* model )
|
||||
|
||||
setAcceptDrops( true );
|
||||
|
||||
if ( model->style() == TrackModel::Short )
|
||||
if ( model->style() == TrackModel::Short || model->style() == TrackModel::ShortWithAvatars )
|
||||
{
|
||||
setHeaderHidden( true );
|
||||
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
|
||||
TrackView::onItemActivated( const QModelIndex& index )
|
||||
{
|
||||
@@ -213,6 +228,11 @@ TrackView::resizeEvent( QResizeEvent* event )
|
||||
// restoreState keeps overwriting our previous sort-order
|
||||
sortByColumn( sortSection, sortOrder );
|
||||
}
|
||||
|
||||
if ( model()->columnCount() == 1 )
|
||||
{
|
||||
m_header->resizeSection( 0, event->size().width() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -448,7 +468,7 @@ TrackView::updateHoverIndex( const QPoint& pos )
|
||||
repaint();
|
||||
}
|
||||
|
||||
if ( m_model->style() == TrackModel::Short )
|
||||
if ( m_model->style() == TrackModel::Short || m_model->style() == TrackModel::ShortWithAvatars )
|
||||
return;
|
||||
|
||||
if ( idx.column() == TrackModel::Artist || idx.column() == TrackModel::Album )
|
||||
@@ -499,8 +519,11 @@ void
|
||||
TrackView::mousePressEvent( QMouseEvent* 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 &&
|
||||
event->pos().x() < header()->sectionViewportPosition( idx.column() ) + header()->sectionSize( idx.column() ) )
|
||||
{
|
||||
|
@@ -62,6 +62,9 @@ explicit TrackView( QWidget* parent = 0 );
|
||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||
|
||||
bool updatesContextView() const { return m_updateContextView; }
|
||||
void setUpdatesContextView( bool b ) { m_updateContextView = b; }
|
||||
|
||||
public slots:
|
||||
void onItemActivated( const QModelIndex& index );
|
||||
|
||||
@@ -84,6 +87,9 @@ protected:
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
|
||||
protected slots:
|
||||
virtual void currentChanged( const QModelIndex& current, const QModelIndex& previous );
|
||||
|
||||
private slots:
|
||||
void onItemResized( const QModelIndex& index );
|
||||
void onFilterChanged( const QString& filter );
|
||||
@@ -105,6 +111,8 @@ private:
|
||||
bool m_dragging;
|
||||
QRect m_dropRect;
|
||||
|
||||
bool m_updateContextView;
|
||||
|
||||
QModelIndex m_hoveredIndex;
|
||||
QModelIndex m_contextMenuIndex;
|
||||
Tomahawk::ContextMenu* m_contextMenu;
|
||||
|
@@ -821,6 +821,7 @@ TreeModel::onDataChanged()
|
||||
emit dataChanged( p->index, p->index.sibling( p->index.row(), columnCount( QModelIndex() ) - 1 ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TreeModel::setColumnStyle( TreeModel::ColumnStyle style )
|
||||
{
|
||||
|
@@ -91,6 +91,7 @@ public:
|
||||
|
||||
void getCover( const QModelIndex& index );
|
||||
|
||||
ColumnStyle columnStyle() const { return m_columnStyle; }
|
||||
void setColumnStyle( ColumnStyle style );
|
||||
|
||||
virtual QString title() const { return m_title; }
|
||||
|
@@ -151,7 +151,7 @@ AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent )
|
||||
{
|
||||
m_timeLine = new QTimeLine( ANIMATION_TIME, this );
|
||||
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( finished() ), SLOT( onAnimationFinished() ) );
|
||||
|
153
src/libtomahawk/utils/dropmenu.cpp
Normal file
153
src/libtomahawk/utils/dropmenu.cpp
Normal 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;
|
||||
}
|
73
src/libtomahawk/utils/dropmenu.h
Normal file
73
src/libtomahawk/utils/dropmenu.h
Normal 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
|
@@ -22,6 +22,7 @@
|
||||
#include <QMetaMethod>
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "context/ContextWidget.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
#include "infobar/infobar.h"
|
||||
#include "topbar/topbar.h"
|
||||
@@ -31,7 +32,6 @@
|
||||
#include "collectionview.h"
|
||||
#include "playlistmodel.h"
|
||||
#include "playlistview.h"
|
||||
#include "queueview.h"
|
||||
#include "trackproxymodel.h"
|
||||
#include "trackmodel.h"
|
||||
#include "artistview.h"
|
||||
@@ -77,37 +77,27 @@ ViewManager::ViewManager( QObject* parent )
|
||||
|
||||
m_widget->setLayout( new QVBoxLayout() );
|
||||
|
||||
m_topbar = new TopBar();
|
||||
// m_topbar = new TopBar();
|
||||
m_infobar = new InfoBar();
|
||||
m_stack = new QStackedWidget();
|
||||
|
||||
m_splitter = new AnimatedSplitter();
|
||||
/* m_splitter = new AnimatedSplitter();
|
||||
m_splitter->setOrientation( Qt::Vertical );
|
||||
m_splitter->setChildrenCollapsible( false );
|
||||
m_splitter->setGreedyWidget( 0 );
|
||||
m_splitter->addWidget( m_stack );
|
||||
m_splitter->addWidget( m_stack );*/
|
||||
|
||||
m_queueButton = new QPushButton();
|
||||
m_queueButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
#ifdef Q_OS_MAC
|
||||
// QPushButtons on mac have lots of weird layouting issues. Fix them by forcing the widget rect for layout calculations
|
||||
m_queueButton->setAttribute( Qt::WA_LayoutUsesWidgetRect );
|
||||
#endif
|
||||
// m_splitter->addWidget( m_queueView );
|
||||
// m_splitter->hide( 1, false );
|
||||
|
||||
m_queueView = new QueueView( m_splitter );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
m_splitter->addWidget( m_queueView );
|
||||
m_splitter->hide( 1, false );
|
||||
m_contextWidget = new ContextWidget();
|
||||
|
||||
m_widget->layout()->addWidget( m_infobar );
|
||||
m_widget->layout()->addWidget( m_topbar );
|
||||
m_widget->layout()->addWidget( m_splitter );
|
||||
m_widget->layout()->addWidget( m_queueButton );
|
||||
// m_widget->layout()->addWidget( m_topbar );
|
||||
// m_widget->layout()->addWidget( m_splitter );
|
||||
m_widget->layout()->addWidget( m_stack );
|
||||
m_widget->layout()->addWidget( m_contextWidget );
|
||||
// m_widget->layout()->addWidget( m_queueButton );
|
||||
|
||||
m_superCollectionView = new ArtistView();
|
||||
m_superCollectionModel = new TreeModel( m_superCollectionView );
|
||||
@@ -132,12 +122,11 @@ ViewManager::ViewManager( QObject* parent )
|
||||
connect( AudioEngine::instance(), SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( playlistInterfaceChanged( Tomahawk::PlaylistInterface* ) ) );
|
||||
|
||||
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||
/* connect( m_topbar, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||
connect( m_topbar, SIGNAL( flatMode() ), SLOT( setTableMode() ) );
|
||||
connect( m_topbar, SIGNAL( artistMode() ), SLOT( setTreeMode() ) );
|
||||
connect( m_topbar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );
|
||||
connect( m_topbar, SIGNAL( albumMode() ), SLOT( setAlbumMode() ) );*/
|
||||
}
|
||||
|
||||
|
||||
@@ -148,13 +137,6 @@ ViewManager::~ViewManager()
|
||||
}
|
||||
|
||||
|
||||
PlaylistView*
|
||||
ViewManager::queue() const
|
||||
{
|
||||
return m_queueView->queue();
|
||||
}
|
||||
|
||||
|
||||
PlaylistView*
|
||||
ViewManager::createPageForPlaylist( const playlist_ptr& pl )
|
||||
{
|
||||
@@ -218,10 +200,10 @@ ViewManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
|
||||
setPage( m_dynamicWidgets.value( playlist ).data() );
|
||||
|
||||
if ( playlist->mode() == Tomahawk::OnDemand )
|
||||
m_queueView->hide();
|
||||
/* if ( playlist->mode() == Tomahawk::OnDemand )
|
||||
hideQueue();
|
||||
else
|
||||
m_queueView->show();
|
||||
showQueue();*/
|
||||
|
||||
emit numSourcesChanged( SourceList::instance()->count() );
|
||||
|
||||
@@ -491,42 +473,6 @@ ViewManager::setAlbumMode()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to hide queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( showQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( hideQueue() ) );
|
||||
|
||||
m_splitter->show( 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueButton->setText( tr( "Click to show queue" ) );
|
||||
disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( hideQueue() ) );
|
||||
connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) );
|
||||
|
||||
m_splitter->hide( 1 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewManager::historyBack()
|
||||
{
|
||||
@@ -699,7 +645,7 @@ ViewManager::updateView()
|
||||
connect( currentPlaylistInterface()->object(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
SIGNAL( shuffleModeChanged( bool ) ) );
|
||||
|
||||
m_topbar->setFilter( currentPlaylistInterface()->filter() );
|
||||
// m_topbar->setFilter( currentPlaylistInterface()->filter() );
|
||||
}
|
||||
|
||||
if ( currentPage()->showStatsBar() && currentPlaylistInterface() )
|
||||
@@ -716,19 +662,19 @@ ViewManager::updateView()
|
||||
emit modeChanged( currentPlaylistInterface()->viewMode() );
|
||||
}
|
||||
|
||||
if ( currentPage()->queueVisible() )
|
||||
m_queueView->show();
|
||||
/* if ( currentPage()->queueVisible() )
|
||||
showQueue();
|
||||
else
|
||||
m_queueView->hide();
|
||||
hideQueue();*/
|
||||
|
||||
emit statsAvailable( currentPage()->showStatsBar() );
|
||||
emit modesAvailable( currentPage()->showModes() );
|
||||
emit filterAvailable( currentPage()->showFilter() );
|
||||
|
||||
if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||
/* if ( !currentPage()->showStatsBar() && !currentPage()->showModes() && !currentPage()->showFilter() )
|
||||
m_topbar->setVisible( false );
|
||||
else
|
||||
m_topbar->setVisible( true );
|
||||
m_topbar->setVisible( true );*/
|
||||
|
||||
m_infobar->setVisible( currentPage()->showInfoBar() );
|
||||
m_infobar->setCaption( currentPage()->title() );
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "collection.h"
|
||||
#include "playlistinterface.h"
|
||||
#include "playlist/queueview.h"
|
||||
#include "viewpage.h"
|
||||
#include "widgets/welcomewidget.h"
|
||||
#include "widgets/whatshotwidget.h"
|
||||
@@ -40,9 +41,9 @@ class ArtistView;
|
||||
class CollectionModel;
|
||||
class CollectionFlatModel;
|
||||
class CollectionView;
|
||||
class ContextWidget;
|
||||
class PlaylistModel;
|
||||
class PlaylistView;
|
||||
class QueueView;
|
||||
class TrackProxyModel;
|
||||
class TrackModel;
|
||||
class TreeProxyModel;
|
||||
@@ -71,8 +72,11 @@ public:
|
||||
~ViewManager();
|
||||
|
||||
QWidget* widget() const { return m_widget; }
|
||||
PlaylistView* queue() const;
|
||||
TopBar* topbar() const { return m_topbar; }
|
||||
InfoBar* infobar() const { return m_infobar; }
|
||||
ContextWidget* context() const { return m_contextWidget; }
|
||||
|
||||
PlaylistView* queue() const { return m_queue->queue(); }
|
||||
void setQueue( QueueView* queue ) { m_queue = queue; }
|
||||
|
||||
bool isSuperCollectionVisible() const;
|
||||
bool isNewPlaylistPageVisible() const;
|
||||
@@ -120,6 +124,9 @@ signals:
|
||||
void tempPageActivated( Tomahawk::ViewPage* );
|
||||
void viewPageActivated( Tomahawk::ViewPage* );
|
||||
|
||||
void showQueueRequested();
|
||||
void hideQueueRequested();
|
||||
|
||||
public slots:
|
||||
Tomahawk::ViewPage* showSuperCollection();
|
||||
Tomahawk::ViewPage* showWelcomePage();
|
||||
@@ -137,13 +144,13 @@ public slots:
|
||||
void historyBack();
|
||||
void removeFromHistory( Tomahawk::ViewPage* p );
|
||||
|
||||
void showQueue() { emit showQueueRequested(); }
|
||||
void hideQueue() { emit hideQueueRequested(); }
|
||||
|
||||
void setTreeMode();
|
||||
void setTableMode();
|
||||
void setAlbumMode();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void setRepeatMode( Tomahawk::PlaylistInterface::RepeatMode mode );
|
||||
void setShuffled( bool enabled );
|
||||
|
||||
@@ -172,18 +179,15 @@ private:
|
||||
|
||||
QWidget* m_widget;
|
||||
InfoBar* m_infobar;
|
||||
TopBar* m_topbar;
|
||||
QPushButton* m_queueButton;
|
||||
ContextWidget* m_contextWidget;
|
||||
QStackedWidget* m_stack;
|
||||
AnimatedSplitter* m_splitter;
|
||||
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
|
||||
AlbumModel* m_superAlbumModel;
|
||||
AlbumView* m_superAlbumView;
|
||||
TreeModel* m_superCollectionModel;
|
||||
ArtistView* m_superCollectionView;
|
||||
QueueView* m_queue;
|
||||
WelcomeWidget* m_welcomeWidget;
|
||||
WhatsHotWidget* m_whatsHotWidget;
|
||||
|
||||
|
@@ -34,7 +34,6 @@ class DLLEXPORT ViewPage
|
||||
{
|
||||
public:
|
||||
ViewPage() {}
|
||||
|
||||
virtual ~ViewPage() {}
|
||||
|
||||
virtual QWidget* widget() = 0;
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "HeaderLabel.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include "utils/logger.h"
|
||||
@@ -51,6 +52,23 @@ HeaderLabel::sizeHint() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
QFrame::mousePressEvent( event );
|
||||
m_time.start();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
QFrame::mouseReleaseEvent( event );
|
||||
if ( m_time.elapsed() < qApp->doubleClickInterval() )
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderLabel::paintEvent( QPaintEvent* /* event */ )
|
||||
{
|
||||
@@ -58,7 +76,7 @@ HeaderLabel::paintEvent( QPaintEvent* /* event */ )
|
||||
QRect r = contentsRect();
|
||||
StyleHelper::horizontalHeader(&p, r);
|
||||
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
QTextOption to( alignment() | Qt::AlignVCenter );
|
||||
r.adjust( 8, 0, -8, 0 );
|
||||
p.setPen( StyleHelper::headerTextColor() );
|
||||
p.drawText( r, text(), to );
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#define HEADERLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTime>
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
@@ -38,14 +39,19 @@ public:
|
||||
QSize minimumSizeHint() const { return sizeHint(); }
|
||||
QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
protected:
|
||||
// void changeEvent( QEvent* e );
|
||||
void paintEvent( QPaintEvent* event );
|
||||
|
||||
void mousePressEvent( QMouseEvent* event );
|
||||
void mouseReleaseEvent( QMouseEvent* event );
|
||||
|
||||
private:
|
||||
QWidget* m_parent;
|
||||
QTime m_time;
|
||||
};
|
||||
|
||||
#endif // HEADERLABEL_H
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::ArtistInfoWidget )
|
||||
@@ -58,8 +59,6 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
|
||||
m_relatedModel = new TreeModel( ui->relatedArtists );
|
||||
m_relatedModel->setColumnStyle( TreeModel::TrackOnly );
|
||||
ui->relatedArtists->setTreeModel( m_relatedModel );
|
||||
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
ui->relatedArtists->header()->setVisible( false );
|
||||
|
||||
m_topHitsModel = new PlaylistModel( ui->topHits );
|
||||
m_topHitsModel->setStyle( TrackModel::Short );
|
||||
@@ -120,10 +119,7 @@ void
|
||||
ArtistInfoWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||
{
|
||||
if ( requestData.caller != m_infoId )
|
||||
{
|
||||
// qDebug() << "Info of wrong type or not with our identifier";
|
||||
return;
|
||||
}
|
||||
|
||||
InfoSystem::InfoCriteriaHash trackInfo;
|
||||
trackInfo = requestData.input.value< InfoSystem::InfoCriteriaHash >();
|
||||
@@ -137,7 +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 >();
|
||||
switch ( requestData.type )
|
||||
{
|
||||
|
@@ -81,8 +81,6 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
m_tracksModel->setStyle( TrackModel::ShortWithAvatars );
|
||||
ui->tracksView->overlay()->setEnabled( false );
|
||||
ui->tracksView->setPlaylistModel( m_tracksModel );
|
||||
ui->tracksView->setHeaderHidden( true );
|
||||
ui->tracksView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||
|
||||
m_recentAlbumsModel = new AlbumModel( ui->additionsView );
|
||||
ui->additionsView->setAlbumModel( m_recentAlbumsModel );
|
||||
|
@@ -259,15 +259,14 @@ CategoryAddItem::dropMimeData( const QMimeData* data, Qt::DropAction )
|
||||
if ( dropType() == DropTypeLocalItems )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, true );
|
||||
dj->setOnlyLocal( true );
|
||||
}
|
||||
else if ( dropType() == DropTypeTop50 )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, false, true );
|
||||
dj->setGetTop10( true );
|
||||
}
|
||||
else
|
||||
dj->tracksFromMimeData( data, false, false );
|
||||
|
||||
dj->tracksFromMimeData( data );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -183,15 +183,12 @@ PlaylistItem::dropMimeData( const QMimeData* data, Qt::DropAction action )
|
||||
if ( dropType() == DropTypeLocalItems )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, true );
|
||||
dj->setOnlyLocal( true );
|
||||
}
|
||||
else if ( dropType() == DropTypeTop50 )
|
||||
{
|
||||
dj->setGetWholeArtists( true );
|
||||
dj->tracksFromMimeData( data, false, false, true );
|
||||
}
|
||||
else
|
||||
dj->tracksFromMimeData( data, false, false );
|
||||
dj->setGetTop10( true );
|
||||
|
||||
dj->tracksFromMimeData( data);
|
||||
|
||||
// TODO cant' know if it works or not yet...
|
||||
return true;
|
||||
|
@@ -43,7 +43,6 @@
|
||||
#include "sourcetree/sourcetreeview.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
#include "utils/proxystyle.h"
|
||||
#include "utils/widgetdragfilter.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/searchwidget.h"
|
||||
@@ -59,6 +58,7 @@
|
||||
#include "tomahawktrayicon.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
#include "scanmanager.h"
|
||||
#include "playlist/queueview.h"
|
||||
#include "tomahawkapp.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
@@ -80,7 +80,10 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
{
|
||||
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||
|
||||
new ViewManager( this );
|
||||
ViewManager* vm = new ViewManager( this );
|
||||
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
|
||||
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
||||
|
||||
ui->setupUi( this );
|
||||
applyPlatformTweaks();
|
||||
|
||||
@@ -96,7 +99,8 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
|
||||
// set initial state
|
||||
onSipDisconnected();
|
||||
ViewManager::instance()->showWelcomePage();
|
||||
vm->setQueue( m_queueView );
|
||||
vm->showWelcomePage();
|
||||
}
|
||||
|
||||
|
||||
@@ -184,28 +188,38 @@ TomahawkWindow::setupSideBar()
|
||||
QWidget* sidebarWidget = new QWidget();
|
||||
sidebarWidget->setLayout( new QVBoxLayout() );
|
||||
|
||||
AnimatedSplitter* sidebar = new AnimatedSplitter();
|
||||
sidebar->setOrientation( Qt::Vertical );
|
||||
sidebar->setChildrenCollapsible( false );
|
||||
m_sidebar = new AnimatedSplitter();
|
||||
m_sidebar->setOrientation( Qt::Vertical );
|
||||
m_sidebar->setChildrenCollapsible( false );
|
||||
|
||||
m_searchWidget = new QSearchField( sidebar );
|
||||
m_searchWidget = new QSearchField( m_sidebar );
|
||||
m_searchWidget->setPlaceholderText( "Global Search..." );
|
||||
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
||||
|
||||
m_sourcetree = new SourceTreeView();
|
||||
TransferView* transferView = new TransferView( sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( sidebar );
|
||||
TransferView* transferView = new TransferView( m_sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
|
||||
|
||||
sidebar->addWidget( m_searchWidget );
|
||||
sidebar->addWidget( m_sourcetree );
|
||||
sidebar->addWidget( transferView );
|
||||
sidebar->addWidget( pipelineView );
|
||||
m_queueView = new QueueView( m_sidebar );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueModel->setStyle( PlaylistModel::Short );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
sidebar->setGreedyWidget( 1 );
|
||||
sidebar->hide( 1, false );
|
||||
sidebar->hide( 2, false );
|
||||
m_sidebar->addWidget( m_searchWidget );
|
||||
m_sidebar->addWidget( m_sourcetree );
|
||||
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->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setMargin( 0 );
|
||||
@@ -225,6 +239,7 @@ TomahawkWindow::setupSideBar()
|
||||
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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
|
||||
TomahawkWindow::minimize()
|
||||
{
|
||||
|
@@ -35,6 +35,9 @@ class QAction;
|
||||
class MusicScanner;
|
||||
class AudioControls;
|
||||
class TomahawkTrayIcon;
|
||||
class PlaylistModel;
|
||||
class QueueView;
|
||||
class AnimatedSplitter;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -95,6 +98,9 @@ private slots:
|
||||
void onSearch( const QString& search );
|
||||
void onFilterEdited();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void minimize();
|
||||
void maximize();
|
||||
|
||||
@@ -114,6 +120,10 @@ private:
|
||||
TomahawkTrayIcon* m_trayIcon;
|
||||
SourceTreeView* m_sourcetree;
|
||||
QPushButton* m_statusButton;
|
||||
QPushButton* m_queueButton;
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
AnimatedSplitter* m_sidebar;
|
||||
|
||||
Tomahawk::result_ptr m_currentTrack;
|
||||
QString m_windowTitle;
|
||||
|
Reference in New Issue
Block a user