From 33a237086ce6c714c12e8965a8870369180b79d4 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 14 Aug 2011 06:29:07 +0200 Subject: [PATCH] * Fixed queue button flickering. Much smoother animation. QSplitter, I'll meet you in hell. --- .../dynamic/widgets/DynamicWidget.cpp | 3 +- src/libtomahawk/playlist/queueview.cpp | 22 +------------- src/libtomahawk/playlist/queueview.h | 1 - src/libtomahawk/viewmanager.cpp | 29 ++++++++++++------- src/libtomahawk/viewmanager.h | 2 ++ 5 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp index 23cfa14a9..872d09726 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicWidget.cpp @@ -407,7 +407,7 @@ DynamicWidget::generatorError( const QString& title, const QString& content ) void -DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity ) +DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& /* pal */, QRect& r, qreal opacity ) { p.setBackgroundMode( Qt::TransparentMode ); p.setRenderHint( QPainter::Antialiasing ); @@ -427,6 +427,7 @@ DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qre p.drawRoundedRect( r, 10, 10 ); } + QPixmap DynamicWidget::pixmap() const { diff --git a/src/libtomahawk/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp index 1f2893c5e..c3abc49ee 100644 --- a/src/libtomahawk/playlist/queueview.cpp +++ b/src/libtomahawk/playlist/queueview.cpp @@ -24,19 +24,13 @@ #include "widgets/overlaywidget.h" #include "utils/logger.h" -#ifdef Q_WS_MAC -#define MINIMUM_HEIGHT 38 -#else -#define MINIMUM_HEIGHT 27 -#endif - using namespace Tomahawk; QueueView::QueueView( AnimatedSplitter* parent ) : AnimatedWidget( parent ) { - setHiddenSize( QSize( 0, MINIMUM_HEIGHT ) ); + setHiddenSize( QSize( 0, 0 ) ); setLayout( new QVBoxLayout() ); m_queue = new PlaylistView( this ); @@ -46,14 +40,8 @@ QueueView::QueueView( AnimatedSplitter* parent ) m_queue->setAttribute( Qt::WA_MacShowFocusRect, 0 ); m_queue->overlay()->setEnabled( false ); - m_button = new QPushButton(); - m_button->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); - m_button->setText( tr( "Click to show queue" ) ); - connect( m_button, SIGNAL( clicked() ), SIGNAL( showWidget() ) ); - layout()->setMargin( 0 ); layout()->addWidget( m_queue ); - layout()->addWidget( m_button ); } @@ -71,10 +59,6 @@ QueueView::onShown( QWidget* widget, bool animated ) return; AnimatedWidget::onShown( widget, animated ); - - m_button->setText( tr( "Click to hide queue" ) ); - disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( showWidget() ) ); - connect( m_button, SIGNAL( clicked() ), SIGNAL( hideWidget() ) ); } @@ -86,8 +70,4 @@ QueueView::onHidden( QWidget* widget, bool animated ) return; AnimatedWidget::onHidden( widget, animated ); - - m_button->setText( tr( "Click to show queue" ) ); - disconnect( m_button, SIGNAL( clicked() ), this, SIGNAL( hideWidget() ) ); - connect( m_button, SIGNAL( clicked() ), SIGNAL( showWidget() ) ); } diff --git a/src/libtomahawk/playlist/queueview.h b/src/libtomahawk/playlist/queueview.h index a8549fffa..fb04a2f12 100644 --- a/src/libtomahawk/playlist/queueview.h +++ b/src/libtomahawk/playlist/queueview.h @@ -44,7 +44,6 @@ public slots: private: PlaylistView* m_queue; - QPushButton* m_button; }; #endif // QUEUEVIEW_H diff --git a/src/libtomahawk/viewmanager.cpp b/src/libtomahawk/viewmanager.cpp index 206dab56e..5c734e299 100644 --- a/src/libtomahawk/viewmanager.cpp +++ b/src/libtomahawk/viewmanager.cpp @@ -86,6 +86,10 @@ ViewManager::ViewManager( QObject* parent ) m_splitter->setGreedyWidget( 0 ); m_splitter->addWidget( m_stack ); + m_queueButton = new QPushButton(); + m_queueButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); + m_queueButton->setText( tr( "Click to show queue" ) ); + m_queueView = new QueueView( m_splitter ); m_queueModel = new PlaylistModel( m_queueView ); m_queueView->queue()->setPlaylistModel( m_queueModel ); @@ -98,6 +102,7 @@ ViewManager::ViewManager( QObject* parent ) 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_superCollectionView = new ArtistView(); m_superCollectionModel = new TreeModel( m_superCollectionView ); @@ -122,18 +127,12 @@ 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( flatMode() ), - SLOT( setTableMode() ) ); - - connect( m_topbar, SIGNAL( artistMode() ), - SLOT( setTreeMode() ) ); - - connect( m_topbar, SIGNAL( albumMode() ), - SLOT( setAlbumMode() ) ); + 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() ) ); } @@ -476,6 +475,10 @@ ViewManager::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_splitter->show( 1 ); } @@ -490,6 +493,10 @@ ViewManager::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_splitter->hide( 1 ); } diff --git a/src/libtomahawk/viewmanager.h b/src/libtomahawk/viewmanager.h index 8d597d610..74ac6b942 100644 --- a/src/libtomahawk/viewmanager.h +++ b/src/libtomahawk/viewmanager.h @@ -51,6 +51,7 @@ class SourceInfoWidget; class InfoBar; class TopBar; class WelcomeWidget; +class QPushButton; namespace Tomahawk { @@ -170,6 +171,7 @@ private: QWidget* m_widget; InfoBar* m_infobar; TopBar* m_topbar; + QPushButton* m_queueButton; QStackedWidget* m_stack; AnimatedSplitter* m_splitter;