1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 12:21:52 +02:00

initial try on a dragndrop menu for audiocontrols

This commit is contained in:
Michael Zanetti
2011-09-04 01:37:01 +02:00
parent 5dfb3ccc5c
commit c0edc3a989
3 changed files with 355 additions and 231 deletions

View File

@@ -148,6 +148,61 @@ AudioControls::AudioControls( QWidget* parent )
ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize ); ui->stackedLayout->setSizeConstraint( QLayout::SetFixedSize );
onPlaybackStopped(); // initial state onPlaybackStopped(); // initial state
m_dragAnimation = new QPropertyAnimation( this, "dropAreaSize", this );
m_dragAnimation->setDuration( 500 );
m_dragAnimation->setEasingCurve( QEasingCurve::OutExpo );
connect( m_dragAnimation, SIGNAL( finished() ), SLOT(dragAnimationFinished()));
QGridLayout *dropMenuLayout = new QGridLayout;
ui->metaDataDropArea->setLayout( dropMenuLayout );
QLabel* dropTrackImage = new QLabel;
dropTrackImage->setAlignment( Qt::AlignHCenter );
dropTrackImage->setPixmap( QPixmap(":/data/images/drop-song.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
dropMenuLayout->addWidget( dropTrackImage, 0, 0 );
QLabel* dropAlbumImage = new QLabel;
dropAlbumImage->setAlignment( Qt::AlignHCenter );
dropAlbumImage->setPixmap( QPixmap( ":/data/images/drop-album.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
dropMenuLayout->addWidget( dropAlbumImage, 0, 1 );
QLabel* dropArtistImage = new QLabel;
dropArtistImage->setAlignment( Qt::AlignHCenter );
dropArtistImage->setPixmap( QPixmap( ":/data/images/drop-all-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
dropMenuLayout->addWidget( dropArtistImage, 0, 2 );
QLabel* dropLocalImage = new QLabel;
dropLocalImage->setAlignment( Qt::AlignHCenter );
dropLocalImage->setPixmap( QPixmap( ":/data/images/drop-local-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
dropMenuLayout->addWidget( dropLocalImage, 0, 3 );
QLabel* dropTop10Image = new QLabel;
dropTop10Image->setAlignment( Qt::AlignHCenter );
dropTop10Image->setPixmap( QPixmap( ":/data/images/drop-top-songs.png" ).scaledToWidth( 32, Qt::SmoothTransformation ) );
dropMenuLayout->addWidget( dropTop10Image, 0, 4 );
QLabel* dropAllText = new QLabel( "Track" );
dropAllText->setAlignment( Qt::AlignHCenter );
dropMenuLayout->addWidget( dropAllText, 1, 0 );
QLabel* dropAlbumText = new QLabel( "Album" );
dropAlbumText->setAlignment( Qt::AlignHCenter );
dropMenuLayout->addWidget( dropAlbumText, 1, 1 );
QLabel* dropArtistText = new QLabel( "Artist" );
dropArtistText->setAlignment( Qt::AlignHCenter );
dropMenuLayout->addWidget( dropArtistText, 1, 2 );
QLabel* dropLocalText = new QLabel( "Local" );
dropLocalText->setAlignment( Qt::AlignHCenter );
dropMenuLayout->addWidget( dropLocalText, 1, 3 );
QLabel* dropTop10Text = new QLabel( "Top 10" );
dropTop10Text->setAlignment( Qt::AlignHCenter );
dropMenuLayout->addWidget( dropTop10Text, 1, 4 );
} }
@@ -521,7 +576,14 @@ void
AudioControls::dragEnterEvent( QDragEnterEvent* e ) AudioControls::dragEnterEvent( QDragEnterEvent* e )
{ {
if ( DropJob::acceptsMimeData( e->mimeData() ) ) if ( DropJob::acceptsMimeData( e->mimeData() ) )
{
e->acceptProposedAction(); e->acceptProposedAction();
m_dragAnimation->setStartValue( 0 );
m_dragAnimation->setEndValue( ui->metaDataArea->height() );
m_dragAnimation->setDirection( QAbstractAnimation::Forward );
m_dragAnimation->start();
}
} }
@@ -533,6 +595,18 @@ AudioControls::dragMoveEvent( QDragMoveEvent* /* e */ )
} }
void
AudioControls::dragLeaveEvent( QDragLeaveEvent * )
{
ui->metaDataInfoArea->setMaximumHeight( 1000 );
ui->metaDataDropArea->setMaximumHeight( 0 );
m_dragAnimation->setDirection( QAbstractAnimation::Backward );
m_dragAnimation->start();
}
void void
AudioControls::dropEvent( QDropEvent* e ) AudioControls::dropEvent( QDropEvent* e )
{ {
@@ -595,3 +669,22 @@ 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 );
}

View File

@@ -21,6 +21,7 @@
#include <QWidget> #include <QWidget>
#include <QTimeLine> #include <QTimeLine>
#include <QPropertyAnimation>
#include "result.h" #include "result.h"
#include "playlistinterface.h" #include "playlistinterface.h"
@@ -37,6 +38,7 @@ namespace Ui
class AudioControls : public QWidget class AudioControls : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( int dropAreaSize READ dropAreaSize WRITE setDropAreaSize )
public: public:
AudioControls( QWidget* parent = 0 ); AudioControls( QWidget* parent = 0 );
@@ -54,8 +56,12 @@ protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
void dragEnterEvent ( QDragEnterEvent* ); void dragEnterEvent ( QDragEnterEvent* );
void dragMoveEvent ( QDragMoveEvent* ); void dragMoveEvent ( QDragMoveEvent* );
void dragLeaveEvent( QDragLeaveEvent * );
void dropEvent ( QDropEvent* ); void dropEvent ( QDropEvent* );
int dropAreaSize();
void setDropAreaSize( int size );
private slots: private slots:
void onPlaybackStarted( const Tomahawk::result_ptr& result ); void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackLoading( const Tomahawk::result_ptr& result ); void onPlaybackLoading( const Tomahawk::result_ptr& result );
@@ -82,6 +88,8 @@ private slots:
void socialActionsLoaded(); void socialActionsLoaded();
void dragAnimationFinished();
private: private:
Ui::AudioControls *ui; Ui::AudioControls *ui;
@@ -93,6 +101,8 @@ private:
QTimeLine m_sliderTimeLine; QTimeLine m_sliderTimeLine;
qint64 m_seekMsecs; qint64 m_seekMsecs;
QPropertyAnimation *m_dragAnimation;
}; };
#endif // AUDIOCONTROLS_H #endif // AUDIOCONTROLS_H

View File

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