1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 23:39:42 +01:00

* Removed obsolete filtering via ViewManager / InfoBar.

This commit is contained in:
Christian Muehlhaeuser 2014-10-12 10:37:52 +02:00
parent 778462b490
commit b7d9f2c719
8 changed files with 0 additions and 695 deletions

View File

@ -61,8 +61,6 @@
#include <QMetaMethod>
#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()
{

View File

@ -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;
};

View File

@ -1,350 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Leo Franchi <lfranchi@kde.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "InfoBar.h"
#include "ui_InfoBar.h"
#include <QLabel>
#include <QPixmap>
#include <QCheckBox>
#include <QPaintEvent>
#include <QPainter>
#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<PlaylistUpdaterInterface*>& 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;
}
}

View File

@ -1,89 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2012, Leo Franchi <lfranchi@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef INFOBAR_H
#define INFOBAR_H
#include <QWidget>
#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<Tomahawk::PlaylistUpdaterInterface*>& 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<Tomahawk::PlaylistUpdaterInterface*> m_updaters;
QList<QWidget*> m_updaterConfigurations;
QSearchField* m_searchWidget;
QueryLabel* m_queryLabel;
};
#endif // INFOBAR_H

View File

@ -1,220 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InfoBar</class>
<widget class="QWidget" name="InfoBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>770</width>
<height>72</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>72</height>
</size>
</property>
<property name="windowTitle">
<string notr="true" extracomment="not translatable because not shown to the user">InfoBar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="imageLabel">
<property name="minimumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="ElidedLabel" name="captionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="ElidedLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="ElidedLabel" name="longDescriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>62</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>62</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="lineAbove">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="lineBelow">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>widgets/ElidedLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

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

View File

@ -89,13 +89,6 @@ TreeWidget::pixmap() const
}
bool
TreeWidget::showFilter() const
{
return true;
}
bool
TreeWidget::setFilter( const QString& filter )
{

View File

@ -41,7 +41,6 @@ public:
virtual QString description() const;
virtual QPixmap pixmap() const;
virtual bool showFilter() const;
virtual bool jumpToCurrentTrack();
virtual bool showInfoBar() const;