From b7d9f2c7194be9639d821e77fa64c70b3d41a4ef Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 12 Oct 2014 10:37:52 +0200 Subject: [PATCH] * Removed obsolete filtering via ViewManager / InfoBar. --- src/libtomahawk/ViewManager.cpp | 22 -- src/libtomahawk/ViewManager.h | 5 - src/libtomahawk/infobar/InfoBar.cpp | 350 ------------------------ src/libtomahawk/infobar/InfoBar.h | 89 ------ src/libtomahawk/infobar/InfoBar.ui | 220 --------------- src/libtomahawk/playlist/TrackView.h | 1 - src/libtomahawk/playlist/TreeWidget.cpp | 7 - src/libtomahawk/playlist/TreeWidget.h | 1 - 8 files changed, 695 deletions(-) delete mode 100644 src/libtomahawk/infobar/InfoBar.cpp delete mode 100644 src/libtomahawk/infobar/InfoBar.h delete mode 100644 src/libtomahawk/infobar/InfoBar.ui diff --git a/src/libtomahawk/ViewManager.cpp b/src/libtomahawk/ViewManager.cpp index e763d2b1a..09834e273 100644 --- a/src/libtomahawk/ViewManager.cpp +++ b/src/libtomahawk/ViewManager.cpp @@ -61,8 +61,6 @@ #include -#define FILTER_TIMEOUT 280 - using namespace Tomahawk; ViewManager* ViewManager::s_instance = 0; @@ -426,26 +424,6 @@ ViewManager::showInboxPage() } -void -ViewManager::setFilter( const QString& filter ) -{ - m_filter = filter; - - m_filterTimer.stop(); - m_filterTimer.setInterval( FILTER_TIMEOUT ); - m_filterTimer.setSingleShot( true ); - m_filterTimer.start(); -} - - -void -ViewManager::applyFilter() -{ - if ( m_currentPage ) - m_currentPage->setFilter( m_filter ); -} - - void ViewManager::historyBack() { diff --git a/src/libtomahawk/ViewManager.h b/src/libtomahawk/ViewManager.h index 265b08f1c..75c6fa986 100644 --- a/src/libtomahawk/ViewManager.h +++ b/src/libtomahawk/ViewManager.h @@ -113,8 +113,6 @@ public: void addDynamicPage( Tomahawk::ViewPagePlugin* viewPage, const QString& pageName = QString() ); signals: - void filterAvailable( bool b ); - void playClicked(); void pauseClicked(); @@ -203,9 +201,6 @@ private: Tomahawk::collection_ptr m_currentCollection; - QTimer m_filterTimer; - QString m_filter; - static ViewManager* s_instance; }; diff --git a/src/libtomahawk/infobar/InfoBar.cpp b/src/libtomahawk/infobar/InfoBar.cpp deleted file mode 100644 index 4d9898177..000000000 --- a/src/libtomahawk/infobar/InfoBar.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2012, Leo Franchi - * Copyright 2013, Teo Mrnjavac - * - * 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 "InfoBar.h" -#include "ui_InfoBar.h" - -#include -#include -#include -#include -#include - -#include "Source.h" -#include "ViewManager.h" -#include "thirdparty/Qocoa/qsearchfield.h" -#include "widgets/QueryLabel.h" -#include "utils/TomahawkStyle.h" -#include "utils/TomahawkUtilsGui.h" -#include "utils/Logger.h" - -#define ANIMATION_TIME 400 -#define IMAGE_HEIGHT 48 - -using namespace Tomahawk; - - -InfoBar::InfoBar( QWidget* parent ) - : QWidget( parent ) - , ui( new Ui::InfoBar ) - , m_queryLabel( 0 ) -{ - ui->setupUi( this ); - - ui->imageLabel->setMargin( 0 ); - ui->imageLabel->setFixedSize( TomahawkUtils::defaultIconSize().width() * 3, - TomahawkUtils::defaultIconSize().height() * 3 ); - - ui->horizontalLayout->insertSpacing( 1, TomahawkUtils::defaultIconSize().width() / 4 ); - ui->horizontalLayout->setStretchFactor( ui->verticalLayout, 2 ); - - QFont font = ui->captionLabel->font(); - - int captionFontSize = TomahawkUtils::defaultFontSize() + 6; - font.setPointSize( captionFontSize ); - font.setBold( true ); - font.setFamily( "Titillium Web" ); - - ui->captionLabel->setFont( font ); - ui->captionLabel->setElideMode( Qt::ElideRight ); - ui->captionLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft ); - ui->captionLabel->setMargin( 2 ); - ui->captionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * ui->captionLabel->margin() ); - - int descriptionFontSize = TomahawkUtils::defaultFontSize() + 2; - font.setPointSize( descriptionFontSize ); - font.setBold( false ); - ui->descriptionLabel->setFont( font ); - ui->descriptionLabel->setElideMode( Qt::ElideRight ); - ui->descriptionLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft ); - ui->descriptionLabel->setMargin( 2 ); - ui->descriptionLabel->setMinimumHeight( QFontMetrics( font ).height() + 2 * ui->descriptionLabel->margin() ); - - QFont regFont = ui->longDescriptionLabel->font(); - regFont.setPointSize( TomahawkUtils::defaultFontSize() ); - ui->longDescriptionLabel->setFont( regFont ); - ui->longDescriptionLabel->setMargin( 4 ); - - m_whitePal = ui->captionLabel->palette(); - m_whitePal.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT ); - m_whitePal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); - - ui->captionLabel->setPalette( m_whitePal ); - ui->descriptionLabel->setPalette( m_whitePal ); - ui->longDescriptionLabel->setPalette( m_whitePal ); - - ui->captionLabel->setText( QString() ); - ui->descriptionLabel->setText( QString() ); - ui->longDescriptionLabel->setText( QString() ); - ui->imageLabel->setText( QString() ); - - ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) ); - ui->lineAbove->setFrameShape( QFrame::HLine ); - ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) ); - ui->lineBelow->setFrameShape( QFrame::HLine ); - - m_queryLabel = new QueryLabel( this ); - m_queryLabel->setType( QueryLabel::Artist ); - m_queryLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_queryLabel->setFont( font ); - m_queryLabel->hide(); - connect( m_queryLabel, SIGNAL( clicked() ), this, SLOT( artistClicked() ) ); - - m_searchWidget = new QSearchField( this ); - m_searchWidget->setPlaceholderText( tr( "Filter..." ) ); - m_searchWidget->setMinimumWidth( 220 ); - connect( m_searchWidget, SIGNAL( textChanged( QString ) ), this, SLOT( onFilterEdited() ) ); - - ui->horizontalLayout->addWidget( m_searchWidget ); - - QPalette pal = m_whitePal; - pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); - - TomahawkUtils::unmarginLayout( ui->horizontalLayout ); - - // on 72dpi, 1px = 1pt - // margins that should be around 8 4 8 4 on ~100dpi - int leftRightMargin = TomahawkUtils::defaultFontHeight() / 3; - int topBottomMargin = TomahawkUtils::defaultFontHeight() / 6; - - ui->horizontalLayout->setContentsMargins( leftRightMargin, topBottomMargin, - leftRightMargin, topBottomMargin ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); - // top-margin + header + layout spacing + description + bottom-margin - setFixedHeight( qMax( topBottomMargin + ui->captionLabel->height() + TomahawkUtils::defaultIconSize().height() / 4 + ui->descriptionLabel->height() + topBottomMargin, - topBottomMargin + ui->imageLabel->height() + topBottomMargin ) ); - - setAutoFillBackground( true ); - setPalette( pal ); - - connect( ViewManager::instance(), SIGNAL( filterAvailable( bool ) ), SLOT( setFilterAvailable( bool ) ) ); -} - - -InfoBar::~InfoBar() -{ - delete ui; -} - - -void -InfoBar::setCaption( const QString& s ) -{ - ui->captionLabel->setText( s ); -} - - -void -InfoBar::setDescription( const QString& s ) -{ - if ( m_queryLabel->isVisible() ) - { - ui->verticalLayout->removeWidget( m_queryLabel ); - m_queryLabel->hide(); - - ui->verticalLayout->addWidget( ui->descriptionLabel ); - ui->verticalLayout->setContentsMargins( 0, 0, 0, 0 ); - ui->descriptionLabel->show(); - } - ui->descriptionLabel->setText( s ); -} - - -void -InfoBar::setDescription( const artist_ptr& artist ) -{ - m_queryLabel->setArtist( artist ); - - if ( !m_queryLabel->isVisible() ) - { - ui->verticalLayout->removeWidget( ui->descriptionLabel ); - ui->descriptionLabel->hide(); - - m_queryLabel->show(); - ui->verticalLayout->addWidget( m_queryLabel ); - ui->verticalLayout->setContentsMargins( 0, 0, 0, 15 ); - } - -} - -void -InfoBar::setDescription( const album_ptr& ) -{ - // TODO -} - - -void -InfoBar::artistClicked() -{ - if ( m_queryLabel && !m_queryLabel->artist().isNull() ) - ViewManager::instance()->show( m_queryLabel->artist() ); -} - - -void -InfoBar::setLongDescription( const QString& s ) -{ - ui->longDescriptionLabel->setText( s ); - - if ( s.isEmpty() ) - { - ui->horizontalLayout->setStretchFactor( ui->verticalLayout, 1 ); - ui->horizontalLayout->setStretchFactor( ui->verticalLayout_2, 0 ); - } else - { - ui->horizontalLayout->setStretchFactor( ui->verticalLayout, 0 ); - ui->horizontalLayout->setStretchFactor( ui->verticalLayout_2, 99 ); - } -} - - -void -InfoBar::setPixmap( const QPixmap& p ) -{ - ui->imageLabel->setPixmap( p.scaledToHeight( ui->imageLabel->height(), Qt::SmoothTransformation ) ); -} - - -void -InfoBar::setFilter( const QString& filter ) -{ - m_searchWidget->setText( filter ); -} - - -void -InfoBar::setFilterAvailable( bool b ) -{ - m_searchWidget->setVisible( b ); -} - - -void -InfoBar::setUpdaters( const QList& updaters ) -{ - QList< QWidget* > newUpdaterWidgets; - foreach ( PlaylistUpdaterInterface* updater, updaters ) - { - if ( updater->configurationWidget() ) - newUpdaterWidgets << updater->configurationWidget(); - } - - foreach ( QWidget* updaterWidget, m_updaterConfigurations ) - { - updaterWidget->hide(); - - if ( !newUpdaterWidgets.contains( updaterWidget ) ) - { - // Old config widget no longer present, remove it - ui->horizontalLayout->removeWidget( updaterWidget ); - } - } - - m_updaters = updaters; - m_updaterConfigurations = newUpdaterWidgets; - - // Display each new widget in the proper place - int insertIdx = -1; // Ugh, no indexOf for QSpacerItem* - for ( int i = 0; i < ui->horizontalLayout->count(); i++ ) - { - if ( ui->horizontalLayout->itemAt( i )->spacerItem() == ui->horizontalSpacer_4 ) - { - insertIdx = i; - break; - } - } - insertIdx++; - - foreach ( QWidget* updaterWidget, m_updaterConfigurations ) - { - updaterWidget->setPalette( m_whitePal ); - ui->horizontalLayout->insertWidget( insertIdx, updaterWidget ); - updaterWidget->show(); - } - -// if ( m_updaterConfiguration ) -// m_updaterConfiguration->hide(); -// -// if ( m_updaterConfiguration && ( interface ? (m_updaterConfiguration != interface->configurationWidget()) : true ) ) -// ui->horizontalLayout->removeWidget( m_updaterConfiguration ); -// -// m_updaterInterface = interface; -// m_updaterConfiguration = interface ? interface->configurationWidget() : 0; -// -// if ( !m_updaterInterface || !m_updaterConfiguration ) -// return; -// -// m_updaterConfiguration->setPalette( m_whitePal ); -// int insertIdx = -1; // Ugh, no indexOf for QSpacerItem* -// for ( int i = 0; i < ui->horizontalLayout->count(); i++ ) -// { -// if ( ui->horizontalLayout->itemAt( i )->spacerItem() == ui->horizontalSpacer_4 ) -// { -// insertIdx = i; -// break; -// } -// } -// insertIdx++; -// ui->horizontalLayout->insertWidget( insertIdx, m_updaterConfiguration ); -// -// m_updaterConfiguration->show(); -} - - -void -InfoBar::onFilterEdited() -{ - emit filterTextChanged( m_searchWidget->text() ); -} - - -void -InfoBar::paintEvent( QPaintEvent* event ) -{ - QWidget::paintEvent( event ); - -/* QPainter painter( this ); - painter.setRenderHint( QPainter::Antialiasing ); - - QLinearGradient gradient( QPoint( 0, 0 ), QPoint( 0, 1 ) ); - gradient.setCoordinateMode( QGradient::ObjectBoundingMode ); - gradient.setColorAt( 0.0, TomahawkStyle::HEADER_LOWER ); - gradient.setColorAt( 1.0, TomahawkStyle::HEADER_UPPER ); - - painter.setBrush( gradient ); - painter.fillRect( rect(), gradient );*/ -} - - -void -InfoBar::changeEvent( QEvent* event ) -{ - QWidget::changeEvent( event ); - switch ( event->type() ) - { - case QEvent::LanguageChange: -// ui->retranslateUi( this ); - break; - - default: - break; - } -} diff --git a/src/libtomahawk/infobar/InfoBar.h b/src/libtomahawk/infobar/InfoBar.h deleted file mode 100644 index 3c540016a..000000000 --- a/src/libtomahawk/infobar/InfoBar.h +++ /dev/null @@ -1,89 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2014, Christian Muehlhaeuser - * Copyright 2012, Leo Franchi - * - * 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 INFOBAR_H -#define INFOBAR_H - -#include - -#include "DllMacro.h" -#include "Artist.h" - -class QueryLabel; -class QCheckBox; -class QTimeLine; -class QSearchField; - -namespace Ui -{ - class InfoBar; -} - -namespace Tomahawk -{ -class PlaylistUpdaterInterface; -} - -class DLLEXPORT InfoBar : public QWidget -{ -Q_OBJECT - -public: - InfoBar( QWidget* parent = 0 ); - ~InfoBar(); - -public slots: - void setCaption( const QString& s ); - - void setDescription( const QString& s ); - // If you want a querylabel instead of an ElidedLabel - void setDescription( const Tomahawk::artist_ptr& artist ); - void setDescription( const Tomahawk::album_ptr& album_ptr ); - - void setLongDescription( const QString& s ); - void setPixmap( const QPixmap& p ); - - void setFilter( const QString& filter ); - void setFilterAvailable( bool b ); - - void setUpdaters( const QList& updaters ); -signals: - void filterTextChanged( const QString& filter ); - -protected: - void changeEvent( QEvent* event ); - void paintEvent( QPaintEvent* event ); - -private slots: - void onFilterEdited(); - void artistClicked(); - -private: - Ui::InfoBar* ui; - - QPalette m_whitePal; - - QList m_updaters; - QList m_updaterConfigurations; - - QSearchField* m_searchWidget; - QueryLabel* m_queryLabel; -}; - -#endif // INFOBAR_H diff --git a/src/libtomahawk/infobar/InfoBar.ui b/src/libtomahawk/infobar/InfoBar.ui deleted file mode 100644 index b80752a9b..000000000 --- a/src/libtomahawk/infobar/InfoBar.ui +++ /dev/null @@ -1,220 +0,0 @@ - - - InfoBar - - - - 0 - 0 - 770 - 72 - - - - - 0 - 0 - - - - - 0 - 72 - - - - InfoBar - - - - 0 - - - 0 - - - - - 8 - - - 8 - - - 4 - - - 8 - - - 4 - - - - - - 48 - 48 - - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 75 - true - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 1 - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 16 - 0 - - - - - - - - - - - 0 - 0 - - - - - 0 - 62 - - - - - 16777215 - 62 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Qt::Horizontal - - - - 40 - 1 - - - - - - - - - - - - - 16777215 - 1 - - - - Qt::Horizontal - - - - - - - - 16777215 - 1 - - - - Qt::Horizontal - - - - - - - - ElidedLabel - QLabel -
widgets/ElidedLabel.h
-
-
- - -
diff --git a/src/libtomahawk/playlist/TrackView.h b/src/libtomahawk/playlist/TrackView.h index 2fd9dfb05..55069efe6 100644 --- a/src/libtomahawk/playlist/TrackView.h +++ b/src/libtomahawk/playlist/TrackView.h @@ -71,7 +71,6 @@ public: virtual QString description() const; virtual QPixmap pixmap() const; - virtual bool showFilter() const { return true; } virtual bool setFilter( const QString& filter ); virtual bool jumpToCurrentTrack(); diff --git a/src/libtomahawk/playlist/TreeWidget.cpp b/src/libtomahawk/playlist/TreeWidget.cpp index 593a3375b..e9db1d66a 100644 --- a/src/libtomahawk/playlist/TreeWidget.cpp +++ b/src/libtomahawk/playlist/TreeWidget.cpp @@ -89,13 +89,6 @@ TreeWidget::pixmap() const } -bool -TreeWidget::showFilter() const -{ - return true; -} - - bool TreeWidget::setFilter( const QString& filter ) { diff --git a/src/libtomahawk/playlist/TreeWidget.h b/src/libtomahawk/playlist/TreeWidget.h index d24f0462e..ddd58c9f0 100644 --- a/src/libtomahawk/playlist/TreeWidget.h +++ b/src/libtomahawk/playlist/TreeWidget.h @@ -41,7 +41,6 @@ public: virtual QString description() const; virtual QPixmap pixmap() const; - virtual bool showFilter() const; virtual bool jumpToCurrentTrack(); virtual bool showInfoBar() const;