Skip to content

Commit

Permalink
* Removed ugly queue button for good.
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli authored and Michael Zanetti committed Sep 4, 2011
1 parent 03f726f commit e0e79c0
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/libtomahawk/CMakeLists.txt
Expand Up @@ -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
)

Expand Down
27 changes: 20 additions & 7 deletions src/libtomahawk/context/ContextWidget.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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() );
Expand All @@ -269,6 +271,7 @@ ContextWidget::onAnimationFinished()
if ( m_timeLine->direction() == QTimeLine::Forward )
{
setFixedHeight( m_maxHeight );
m_visible = true;
ui->contextView->show();

fadeOut( false );
Expand All @@ -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 );
}
}
2 changes: 2 additions & 0 deletions src/libtomahawk/context/ContextWidget.h
Expand Up @@ -61,6 +61,7 @@ private slots:
void onAnimationFinished();

protected:
void paintEvent( QPaintEvent* e );
void resizeEvent( QResizeEvent* e );

private:
Expand All @@ -81,6 +82,7 @@ private slots:
int m_currentView;

Tomahawk::query_ptr m_query;
bool m_visible;
};

#endif // CONTEXTWIDGET_H
2 changes: 1 addition & 1 deletion src/libtomahawk/context/ContextWidget.ui
Expand Up @@ -38,7 +38,7 @@
<string>Dashboard</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
Expand Down
57 changes: 43 additions & 14 deletions src/libtomahawk/playlist/queueview.cpp
Expand Up @@ -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"
Expand All @@ -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() ) );
}


Expand All @@ -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;

Expand All @@ -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;

Expand Down
12 changes: 10 additions & 2 deletions src/libtomahawk/playlist/queueview.h
Expand Up @@ -26,6 +26,11 @@

#include "dllmacro.h"

namespace Ui
{
class QueueView;
}

class DLLEXPORT QueueView : public AnimatedWidget
{
Q_OBJECT
Expand All @@ -34,16 +39,19 @@ Q_OBJECT
explicit QueueView( AnimatedSplitter* parent );
~QueueView();

PlaylistView* queue() const { return m_queue; }
PlaylistView* queue() const;

QSize sizeHint() const { return QSize( 0, 200 ); }

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
2 changes: 1 addition & 1 deletion src/libtomahawk/utils/animatedsplitter.cpp
Expand Up @@ -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() ) );
Expand Down
23 changes: 2 additions & 21 deletions src/tomahawkwindow.cpp
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down Expand Up @@ -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();
}


Expand All @@ -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();
}


Expand Down

0 comments on commit e0e79c0

Please sign in to comment.