diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index 6bcd65ce3e..8616e1f0b0 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -431,6 +431,7 @@ set( libUI ${libUI} widgets/infowidgets/AlbumInfoWidget.ui playlist/topbar/topbar.ui playlist/infobar/infobar.ui + playlist/queueview.ui context/ContextWidget.ui ) diff --git a/src/libtomahawk/context/ContextWidget.cpp b/src/libtomahawk/context/ContextWidget.cpp index 8546518dba..5c5afcae8c 100644 --- a/src/libtomahawk/context/ContextWidget.cpp +++ b/src/libtomahawk/context/ContextWidget.cpp @@ -41,8 +41,9 @@ using namespace Tomahawk; ContextWidget::ContextWidget( QWidget* parent ) : QWidget( parent ) , ui( new Ui::ContextWidget ) - , m_minHeight( 24 ) + , m_minHeight( 22 ) , m_currentView( 0 ) + , m_visible( false ) { ui->setupUi( this ); TomahawkUtils::unmarginLayout( layout() ); @@ -78,10 +79,6 @@ ContextWidget::ContextWidget( QWidget* parent ) ui->contextView->hide(); - QPalette p = palette(); - p.setBrush( QPalette::Window, QColor( 0x70, 0x70, 0x70 ) ); - setPalette( p ); - QPalette whitePal = ui->toggleButton->palette(); whitePal.setColor( QPalette::Foreground, Qt::white ); ui->toggleButton->setPalette( whitePal ); @@ -95,6 +92,10 @@ ContextWidget::ContextWidget( QWidget* parent ) 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 ); @@ -247,6 +248,7 @@ ContextWidget::toggleSize() else { ui->toggleButton->setText( tr( "Open Dashboard" ) ); + m_visible = false; ui->contextView->hide(); m_timeLine->setFrameRange( m_minHeight, height() ); @@ -269,6 +271,7 @@ ContextWidget::onAnimationFinished() if ( m_timeLine->direction() == QTimeLine::Forward ) { setFixedHeight( m_maxHeight ); + m_visible = true; ui->contextView->show(); fadeOut( false ); @@ -283,11 +286,21 @@ ContextWidget::onAnimationFinished() } +void +ContextWidget::paintEvent( QPaintEvent* e ) +{ + QWidget::paintEvent( e ); +} + + void ContextWidget::resizeEvent( QResizeEvent* e ) { QWidget::resizeEvent( e ); - m_scene->setSceneRect( ui->contextView->viewport()->rect() ); - layoutViews( false ); + if ( m_visible ) + { + m_scene->setSceneRect( ui->contextView->viewport()->rect() ); + layoutViews( false ); + } } diff --git a/src/libtomahawk/context/ContextWidget.h b/src/libtomahawk/context/ContextWidget.h index fc79648acf..17a471d244 100644 --- a/src/libtomahawk/context/ContextWidget.h +++ b/src/libtomahawk/context/ContextWidget.h @@ -61,6 +61,7 @@ private slots: void onAnimationFinished(); protected: + void paintEvent( QPaintEvent* e ); void resizeEvent( QResizeEvent* e ); private: @@ -81,6 +82,7 @@ private slots: int m_currentView; Tomahawk::query_ptr m_query; + bool m_visible; }; #endif // CONTEXTWIDGET_H diff --git a/src/libtomahawk/context/ContextWidget.ui b/src/libtomahawk/context/ContextWidget.ui index efb8358b76..34c0d71e42 100644 --- a/src/libtomahawk/context/ContextWidget.ui +++ b/src/libtomahawk/context/ContextWidget.ui @@ -38,7 +38,7 @@ Dashboard - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignCenter diff --git a/src/libtomahawk/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp index c3abc49ee2..656ac81782 100644 --- a/src/libtomahawk/playlist/queueview.cpp +++ b/src/libtomahawk/playlist/queueview.cpp @@ -17,9 +17,11 @@ */ #include "queueview.h" +#include "ui_queueview.h" #include +#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() ); - - 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 ); - - layout()->setMargin( 0 ); - layout()->addWidget( m_queue ); + ui->setupUi( this ); + TomahawkUtils::unmarginLayout( layout() ); + setContentsMargins( 0, 0, 0, 0 ); + + setHiddenSize( QSize( 0, 22 ) ); + + 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; diff --git a/src/libtomahawk/playlist/queueview.h b/src/libtomahawk/playlist/queueview.h index fb04a2f128..3b207fb491 100644 --- a/src/libtomahawk/playlist/queueview.h +++ b/src/libtomahawk/playlist/queueview.h @@ -26,6 +26,11 @@ #include "dllmacro.h" +namespace Ui +{ + class QueueView; +} + class DLLEXPORT QueueView : public AnimatedWidget { Q_OBJECT @@ -34,7 +39,7 @@ Q_OBJECT 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 diff --git a/src/libtomahawk/utils/animatedsplitter.cpp b/src/libtomahawk/utils/animatedsplitter.cpp index 0a34e32af3..45b4092ab2 100644 --- a/src/libtomahawk/utils/animatedsplitter.cpp +++ b/src/libtomahawk/utils/animatedsplitter.cpp @@ -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() ) ); diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp index 0cd8439fdb..cc8f89bd25 100644 --- a/src/tomahawkwindow.cpp +++ b/src/tomahawkwindow.cpp @@ -200,16 +200,6 @@ TomahawkWindow::setupSideBar() TransferView* transferView = new TransferView( m_sidebar ); PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar ); - 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 - - connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) ); - m_queueView = new QueueView( m_sidebar ); m_queueModel = new PlaylistModel( m_queueView ); m_queueModel->setStyle( PlaylistModel::Short ); @@ -230,7 +220,6 @@ TomahawkWindow::setupSideBar() m_sidebar->hide( 4, false ); sidebarWidget->layout()->addWidget( m_sidebar ); - sidebarWidget->layout()->addWidget( m_queueButton ); sidebarWidget->setContentsMargins( 0, 0, 0, 0 ); sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); sidebarWidget->layout()->setMargin( 0 ); @@ -699,11 +688,7 @@ TomahawkWindow::showQueue() return; } - m_queueButton->setText( tr( "Click to hide queue" ) ); - disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( showQueue() ) ); - connect( m_queueButton, SIGNAL( clicked() ), SLOT( hideQueue() ) ); - - m_sidebar->show( 4 ); + m_queueView->show(); } @@ -717,11 +702,7 @@ TomahawkWindow::hideQueue() return; } - m_queueButton->setText( tr( "Click to show queue" ) ); - disconnect( m_queueButton, SIGNAL( clicked() ), this, SLOT( hideQueue() ) ); - connect( m_queueButton, SIGNAL( clicked() ), SLOT( showQueue() ) ); - - m_sidebar->hide( 4 ); + m_queueView->hide(); }