From 080b1b1817ad75c4100e28c0aa2aa64d3e7adb07 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 4 Jul 2012 04:47:20 +0200 Subject: [PATCH] * Remove TopBar and move SearchLineEdit into widgets/searchlineedit/. --- src/libtomahawk/playlist/topbar/TopBar.cpp | 344 ------------------ src/libtomahawk/playlist/topbar/TopBar.h | 87 ----- src/libtomahawk/playlist/topbar/TopBar.ui | 324 ----------------- .../searchlineedit}/ClearButton.cpp | 0 .../searchlineedit}/ClearButton.h | 0 .../searchlineedit}/LineEdit.cpp | 0 .../searchlineedit}/LineEdit.h | 0 .../searchlineedit}/LineEdit_p.h | 0 .../searchlineedit}/SearchButton.cpp | 0 .../searchlineedit}/SearchButton.h | 0 .../searchlineedit}/SearchLineEdit.cpp | 0 .../searchlineedit}/SearchLineEdit.h | 0 12 files changed, 755 deletions(-) delete mode 100644 src/libtomahawk/playlist/topbar/TopBar.cpp delete mode 100644 src/libtomahawk/playlist/topbar/TopBar.h delete mode 100644 src/libtomahawk/playlist/topbar/TopBar.ui rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/ClearButton.cpp (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/ClearButton.h (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/LineEdit.cpp (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/LineEdit.h (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/LineEdit_p.h (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/SearchButton.cpp (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/SearchButton.h (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/SearchLineEdit.cpp (100%) rename src/libtomahawk/{playlist/topbar => widgets/searchlineedit}/SearchLineEdit.h (100%) diff --git a/src/libtomahawk/playlist/topbar/TopBar.cpp b/src/libtomahawk/playlist/topbar/TopBar.cpp deleted file mode 100644 index 41adb5e7f..000000000 --- a/src/libtomahawk/playlist/topbar/TopBar.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2010-2011, Jeff Mitchell - * - * 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 . - */ - -#include "TopBar.h" -#include "ui_TopBar.h" - -#include "SearchButton.h" - -#include -#include -#include - -#include "utils/TomahawkUtils.h" -#include "utils/Logger.h" - -#define MAXDUDES 3 -#define DUDEWIDTH 10 -#define DUDEX( i ) ( DUDEWIDTH * i ) - -using namespace Tomahawk; - - -TopBar::TopBar( QWidget* parent ) - : QWidget( parent ) - , ui( new Ui::TopBar ) - , m_sources( 0 ) - , m_tracks( 0 ) - , m_artists( 0 ) - , m_shown( 0 ) -{ - ui->setupUi( this ); - - ui->statsLabelNumTracks->setFormat( "%L1 " + tr( "Tracks" ) ); - ui->statsLabelNumArtists->setFormat( "%L1 " + tr( "Artists" ) ); - connect( ui->filterEdit, SIGNAL( textChanged( QString ) ), SIGNAL( filterTextChanged( QString ) ) ); - - ui->filterEdit->setStyleSheet( "QLineEdit { border: 1px solid gray; border-radius: 6px; margin-right: 2px; }" ); - ui->filterEdit->setInactiveText( tr( "Filter" ) ); -#ifdef Q_WS_MAC - ui->filterEdit->setAttribute( Qt::WA_MacShowFocusRect, 0 ); -#endif - - ui->filterEdit->searchButton()->setImage( QImage( RESPATH "images/filter.png" ) ); - - // initialise dudes - for( int i = 0; i < MAXDUDES; ++i ) - { - QLabel* manlbl = new QLabel( ui->widgetMen ); - manlbl->setPixmap( QPixmap( RESPATH "images/avatar-dude.png" ) ); - manlbl->move( QPoint( -10,0 ) ); - manlbl->show(); - m_dudes.append( manlbl ); - } - - QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" ); - f.open( QFile::ReadOnly ); - QString css = QString::fromAscii( f.readAll() ); - f.close(); - - ui->widgetRadio->setStyleSheet( css ); - - ui->radioNormal->setFocusPolicy( Qt::NoFocus ); - ui->radioDetailed->setFocusPolicy( Qt::NoFocus ); - ui->radioCloud->setFocusPolicy( Qt::NoFocus ); - - ui->radioCloud->hide(); - - ui->radioNormal->setToolTip( tr( "Artist View" ) ); - ui->radioDetailed->setToolTip( tr("Flat View" ) ); - - connect( ui->radioNormal, SIGNAL( clicked() ), SIGNAL( artistMode() ) ); - connect( ui->radioDetailed, SIGNAL( clicked() ), SIGNAL( flatMode() ) ); - connect( ui->radioCloud, SIGNAL( clicked() ), SIGNAL( albumMode() ) ); - - setNumSources( 0 ); - setNumTracks( 0 ); - setNumArtists( 0 ); - setNumShown( 0 ); - - onArtistMode(); - - connect( ViewManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ), - SLOT( setNumSources( unsigned int ) ) ); - - connect( ViewManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ), - SLOT( setNumTracks( unsigned int ) ) ); - - connect( ViewManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ), - SLOT( setNumArtists( unsigned int ) ) ); - - connect( ViewManager::instance(), SIGNAL( numShownChanged( unsigned int ) ), - SLOT( setNumShown( unsigned int ) ) ); - - connect( ViewManager::instance(), SIGNAL( statsAvailable( bool ) ), - SLOT( setStatsVisible( bool ) ) ); - - connect( ViewManager::instance(), SIGNAL( modesAvailable( bool ) ), - SLOT( setModesVisible( bool ) ) ); - - connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), - SLOT( setFilterVisible( bool ) ) ); - - connect( ViewManager::instance(), SIGNAL( modeChanged( Tomahawk::PlaylistModes::ViewMode ) ), - SLOT( onModeChanged( Tomahawk::PlaylistModes::ViewMode ) ) ); -} - - -TopBar::~TopBar() -{ - delete ui; -} - - -void -TopBar::changeEvent( QEvent* e ) -{ - QWidget::changeEvent( e ); - switch ( e->type() ) - { - case QEvent::LanguageChange: - ui->retranslateUi( this ); - break; - - default: - break; - } -} - - -void -TopBar::resizeEvent( QResizeEvent* e ) -{ - QWidget::resizeEvent( e ); -} - - -void -TopBar::fadeInDude( unsigned int i ) -{ -// qDebug() << Q_FUNC_INFO << i; - - QLabel* dude = m_dudes.at( i ); - QPropertyAnimation* ani = new QPropertyAnimation( dude, "pos" ); - ani->setDuration( 1000 ); - ani->setEasingCurve( QEasingCurve::InQuad ); - ani->setStartValue( QPoint( -10,0 ) ); - ani->setEndValue( QPoint( DUDEX( i+1 ), 0 ) ); - - qDebug() << "Animating from" << ani->startValue() << "to" << ani->endValue(); - connect( ani, SIGNAL( finished() ), ani, SLOT( deleteLater() ) ); - ani->start(); -} - - -void -TopBar::fadeOutDude( unsigned int i ) -{ -// qDebug() << Q_FUNC_INFO << i; - - QLabel* dude = m_dudes.at( i ); - QPropertyAnimation* ani = new QPropertyAnimation( dude, "pos" ); - ani->setDuration( 1000 ); - ani->setEasingCurve( QEasingCurve::OutQuad ); - ani->setStartValue( dude->pos() ); - ani->setEndValue( QPoint( -10, 0 ) ); - - qDebug() << "Animating from" << ani->startValue() << "to" << ani->endValue(); - connect( ani, SIGNAL( finished() ), ani, SLOT( deleteLater() ) ); - ani->start(); -} - - -void -TopBar::setNumSources( unsigned int i ) -{ -// qDebug() << Q_FUNC_INFO << i; - - // Dude0 Dude1 Dude2 - ui->statsLabelNumSources->setText( QString( "%L1 %2" ).arg( i ).arg( tr( "Sources" ) ) ); - - if( ( m_sources >= MAXDUDES && i >= MAXDUDES ) || m_sources == i ) - { - m_sources = i; - return; - } - - if( i > m_sources ) - { - for( unsigned int k = m_sources; k < MAXDUDES && k < i; ++k ) - { - fadeInDude( k ); - } - m_sources = i; - } - else - { - int k = qMin( (unsigned int)MAXDUDES - 1, m_sources - 1 ); - do - { - fadeOutDude( k ); - m_sources--; - } while( (unsigned int)k-- > i ); - - m_sources = i; - } -} - - -void -TopBar::setNumTracks( unsigned int i ) -{ - m_tracks = i; - ui->statsLabelNumTracks->setVal( i ); -} - - -void -TopBar::setNumArtists( unsigned int i ) -{ - m_artists = i; - ui->statsLabelNumArtists->setVisible( m_artists > 0 ); - ui->statsLabelNumArtists->setVal( i ); -} - - -void -TopBar::setNumShown( unsigned int i ) -{ - m_shown = i; - ui->statsLabelNumShown->setVisible( m_shown != m_tracks && ui->statsLabelNumTracks->isVisible() ); - ui->statsLabelNumShown->setText( QString( "%L1 %2" ).arg( i ).arg( tr( "Shown" ) ) ); -} - - -void -TopBar::addSource() -{ -// qDebug() << Q_FUNC_INFO; - setNumSources( m_sources + 1 ); -} - - -void -TopBar::removeSource() -{ -// qDebug() << Q_FUNC_INFO; - Q_ASSERT( m_sources > 0 ); - setNumSources( m_sources - 1 ); -} - - -void -TopBar::setStatsVisible( bool b ) -{ - foreach( QLabel* dude, m_dudes ) - dude->setVisible( b ); - -// ui->statsLabelNumArtists->setVisible( b ); -// ui->statsLabelNumShown->setVisible( b ); - ui->statsLabelNumSources->setVisible( b ); - ui->statsLabelNumTracks->setVisible( b ); -} - - -void -TopBar::setModesVisible( bool b ) -{ - ui->widgetRadio->setVisible( b ); -} - - -void -TopBar::setFilterVisible( bool b ) -{ - ui->filterEdit->setVisible( b ); -} - - -void -TopBar::setFilter( const QString& filter ) -{ - ui->filterEdit->setText( filter ); -} - - -void -TopBar::onModeChanged( Tomahawk::PlaylistModes::ViewMode mode ) -{ - qDebug() << Q_FUNC_INFO << mode; - switch ( mode ) - { - case Tomahawk::PlaylistModes::Flat: - onFlatMode(); - break; - - case Tomahawk::PlaylistModes::Tree: - onArtistMode(); - break; - - case Tomahawk::PlaylistModes::Album: - onAlbumMode(); - break; - - default: - break; - } -} - - -void -TopBar::onFlatMode() -{ - ui->radioDetailed->setChecked( true ); -} - - -void -TopBar::onArtistMode() -{ - ui->radioNormal->setChecked( true ); -} - - -void -TopBar::onAlbumMode() -{ - ui->radioCloud->setChecked( true ); -} diff --git a/src/libtomahawk/playlist/topbar/TopBar.h b/src/libtomahawk/playlist/topbar/TopBar.h deleted file mode 100644 index 6cb50563b..000000000 --- a/src/libtomahawk/playlist/topbar/TopBar.h +++ /dev/null @@ -1,87 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * - * 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 . - */ - -#ifndef TOPBAR_H -#define TOPBAR_H - -#include -#include -#include - -#include "ViewManager.h" -#include "SourceList.h" -#include "DllMacro.h" - -namespace Ui -{ - class TopBar; -} - -class DLLEXPORT TopBar : public QWidget -{ -Q_OBJECT - -public: - TopBar( QWidget* parent = 0 ); - ~TopBar(); - -signals: - void filterTextChanged( const QString& newtext ); - - void flatMode(); - void artistMode(); - void albumMode(); - -public slots: - void setNumSources( unsigned int ); - void setNumTracks( unsigned int ); - void setNumArtists( unsigned int ); - void setNumShown( unsigned int ); - - void setStatsVisible( bool b ); - void setModesVisible( bool b ); - void setFilterVisible( bool b ); - - void addSource(); - void removeSource(); - - void setFilter( const QString& filter ); - -private slots: - void onModeChanged( Tomahawk::PlaylistModes::ViewMode mode ); - void onFlatMode(); - void onArtistMode(); - void onAlbumMode(); - -protected: - void changeEvent( QEvent* e ); - void resizeEvent( QResizeEvent* e ); - -private: - void fadeOutDude( unsigned int i ); - void fadeInDude( unsigned int i ); - - Ui::TopBar* ui; - - unsigned int m_sources, m_tracks, m_artists, m_shown; - QList m_dudes; - - Tomahawk::source_ptr m_onesource; -}; - -#endif // TOPBAR_H diff --git a/src/libtomahawk/playlist/topbar/TopBar.ui b/src/libtomahawk/playlist/topbar/TopBar.ui deleted file mode 100644 index 7498a6da0..000000000 --- a/src/libtomahawk/playlist/topbar/TopBar.ui +++ /dev/null @@ -1,324 +0,0 @@ - - - TopBar - - - - 0 - 0 - 809 - 45 - - - - - 0 - 0 - - - - - 0 - 38 - - - - Form - - - - 6 - - - 2 - - - 2 - - - 4 - - - - - - 0 - 0 - - - - - 36 - 22 - - - - margin-top:3px; - - - - - - - - - - 0 Sources - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - 0 Tracks - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - 0 Artists - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - 0 Shown - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 149 - 20 - - - - - - - - - 0 - 0 - - - - - 58 - 30 - - - - - 58 - 30 - - - - - - 0 - 0 - 29 - 30 - - - - - 0 - 0 - - - - - 29 - 30 - - - - - 29 - 30 - - - - - - - - - - 58 - 0 - 29 - 30 - - - - - 0 - 0 - - - - - 29 - 30 - - - - - 29 - 30 - - - - - - - - - - 29 - 0 - 29 - 30 - - - - - 0 - 0 - - - - - 29 - 30 - - - - - 29 - 30 - - - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 15 - 20 - - - - - - - - - 0 - 0 - - - - - 150 - 27 - - - - - 150 - 27 - - - - - - - - - AnimatedCounterLabel - QLabel -
widgets/AnimatedCounterLabel.h
-
- - SearchLineEdit - QLineEdit -
playlist/topbar/SearchLineEdit.h
-
-
- - -
diff --git a/src/libtomahawk/playlist/topbar/ClearButton.cpp b/src/libtomahawk/widgets/searchlineedit/ClearButton.cpp similarity index 100% rename from src/libtomahawk/playlist/topbar/ClearButton.cpp rename to src/libtomahawk/widgets/searchlineedit/ClearButton.cpp diff --git a/src/libtomahawk/playlist/topbar/ClearButton.h b/src/libtomahawk/widgets/searchlineedit/ClearButton.h similarity index 100% rename from src/libtomahawk/playlist/topbar/ClearButton.h rename to src/libtomahawk/widgets/searchlineedit/ClearButton.h diff --git a/src/libtomahawk/playlist/topbar/LineEdit.cpp b/src/libtomahawk/widgets/searchlineedit/LineEdit.cpp similarity index 100% rename from src/libtomahawk/playlist/topbar/LineEdit.cpp rename to src/libtomahawk/widgets/searchlineedit/LineEdit.cpp diff --git a/src/libtomahawk/playlist/topbar/LineEdit.h b/src/libtomahawk/widgets/searchlineedit/LineEdit.h similarity index 100% rename from src/libtomahawk/playlist/topbar/LineEdit.h rename to src/libtomahawk/widgets/searchlineedit/LineEdit.h diff --git a/src/libtomahawk/playlist/topbar/LineEdit_p.h b/src/libtomahawk/widgets/searchlineedit/LineEdit_p.h similarity index 100% rename from src/libtomahawk/playlist/topbar/LineEdit_p.h rename to src/libtomahawk/widgets/searchlineedit/LineEdit_p.h diff --git a/src/libtomahawk/playlist/topbar/SearchButton.cpp b/src/libtomahawk/widgets/searchlineedit/SearchButton.cpp similarity index 100% rename from src/libtomahawk/playlist/topbar/SearchButton.cpp rename to src/libtomahawk/widgets/searchlineedit/SearchButton.cpp diff --git a/src/libtomahawk/playlist/topbar/SearchButton.h b/src/libtomahawk/widgets/searchlineedit/SearchButton.h similarity index 100% rename from src/libtomahawk/playlist/topbar/SearchButton.h rename to src/libtomahawk/widgets/searchlineedit/SearchButton.h diff --git a/src/libtomahawk/playlist/topbar/SearchLineEdit.cpp b/src/libtomahawk/widgets/searchlineedit/SearchLineEdit.cpp similarity index 100% rename from src/libtomahawk/playlist/topbar/SearchLineEdit.cpp rename to src/libtomahawk/widgets/searchlineedit/SearchLineEdit.cpp diff --git a/src/libtomahawk/playlist/topbar/SearchLineEdit.h b/src/libtomahawk/widgets/searchlineedit/SearchLineEdit.h similarity index 100% rename from src/libtomahawk/playlist/topbar/SearchLineEdit.h rename to src/libtomahawk/widgets/searchlineedit/SearchLineEdit.h