From aa82c276c9c9a9d3429e694a4ee1d1c4e32ff756 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 14 Jul 2012 09:48:45 +0200 Subject: [PATCH] * Added Flexibleheader and PlaylistHeader.ui. --- src/libtomahawk/CMakeLists.txt | 4 +- src/libtomahawk/playlist/FlexibleHeader.cpp | 156 +++++++++++ src/libtomahawk/playlist/FlexibleHeader.h | 68 +++++ src/libtomahawk/playlist/PlaylistHeader.ui | 279 ++++++++++++++++++++ 4 files changed, 505 insertions(+), 2 deletions(-) create mode 100644 src/libtomahawk/playlist/FlexibleHeader.cpp create mode 100644 src/libtomahawk/playlist/FlexibleHeader.h create mode 100644 src/libtomahawk/playlist/PlaylistHeader.ui diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index a8118437e..535e581e0 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -48,6 +48,7 @@ set( libGuiSources infobar/InfoBar.cpp + playlist/FlexibleHeader.cpp playlist/FlexibleView.cpp playlist/TreeModel.cpp playlist/TreeProxyModel.cpp @@ -88,8 +89,6 @@ set( libGuiSources playlist/dynamic/widgets/CollapsibleControls.cpp playlist/dynamic/widgets/DynamicSetupWidget.cpp - - ExternalResolverGui.cpp resolvers/ScriptResolver.cpp resolvers/QtScriptResolver.cpp @@ -320,6 +319,7 @@ set( libUI ${libUI} widgets/infowidgets/AlbumInfoWidget.ui widgets/infowidgets/TrackInfoWidget.ui playlist/QueueView.ui + playlist/PlaylistHeader.ui filemetadata/MetadataEditor.ui context/ContextWidget.ui infobar/InfoBar.ui diff --git a/src/libtomahawk/playlist/FlexibleHeader.cpp b/src/libtomahawk/playlist/FlexibleHeader.cpp new file mode 100644 index 000000000..e58a2ea02 --- /dev/null +++ b/src/libtomahawk/playlist/FlexibleHeader.cpp @@ -0,0 +1,156 @@ +/* === 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 . + */ + +#include "FlexibleHeader.h" +#include "ui_PlaylistHeader.h" + +#include +#include +#include +#include +#include + +#include "playlist/FlexibleView.h" +#include "ViewManager.h" +#include "thirdparty/Qocoa/qsearchfield.h" +#include "utils/Closure.h" +#include "utils/TomahawkUtilsGui.h" +#include "utils/Logger.h" +#include "widgets/QueryLabel.h" +#include "Source.h" + +using namespace Tomahawk; + + +FlexibleHeader::FlexibleHeader( FlexibleView* parent ) + : QWidget( parent ) + , m_parent( parent ) + , ui( new Ui::PlaylistHeader ) +{ + ui->setupUi( this ); + + QPalette pal = palette(); + pal.setColor( QPalette::Foreground, Qt::white ); + + ui->captionLabel->setPalette( pal ); + ui->descLabel->setPalette( pal ); + + QFont font = ui->captionLabel->font(); + font.setPixelSize( 16 ); + font.setBold( true ); + ui->captionLabel->setFont( font ); + + font.setPixelSize( 11 ); + ui->descLabel->setFont( font ); + + ui->radioNormal->setFocusPolicy( Qt::NoFocus ); + ui->radioDetailed->setFocusPolicy( Qt::NoFocus ); + ui->radioCloud->setFocusPolicy( Qt::NoFocus ); + + QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" ); + f.open( QFile::ReadOnly ); + QString css = QString::fromAscii( f.readAll() ); + f.close(); + + ui->modeWidget->setStyleSheet( css ); + + ui->radioNormal->setChecked( true ); + ui->filter->setPlaceholderText( tr( "Filter..." ) ); + + pal = palette(); + pal.setColor( QPalette::Window, QColor( "#454e59" ) ); + + setPalette( pal ); + setAutoFillBackground( true ); + + connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) ); + connect( ui->filter, SIGNAL( textChanged( QString ) ), SLOT( onFilterEdited() ) ); + + NewClosure( ui->radioNormal, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Flat )->setAutoDelete( false ); + NewClosure( ui->radioDetailed, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Detailed )->setAutoDelete( false ); + NewClosure( ui->radioCloud, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Grid )->setAutoDelete( false ); +} + + +FlexibleHeader::~FlexibleHeader() +{ + delete ui; +} + + +void +FlexibleHeader::setCaption( const QString& s ) +{ + ui->captionLabel->setText( s ); +} + + +void +FlexibleHeader::setDescription( const QString& s ) +{ + ui->descLabel->setText( s ); +} + + +void +FlexibleHeader::setPixmap( const QPixmap& p ) +{ + ui->imageLabel->setPixmap( p.scaledToHeight( ui->imageLabel->height(), Qt::SmoothTransformation ) ); +} + + +void +FlexibleHeader::setFilter( const QString& filter ) +{ + ui->filter->setText( filter ); +} + + +void +FlexibleHeader::onFilterEdited() +{ + m_filter = ui->filter->text(); + + m_filterTimer.stop(); + m_filterTimer.setInterval( 280 ); + m_filterTimer.setSingleShot( true ); + m_filterTimer.start(); +} + + +void +FlexibleHeader::applyFilter() +{ + emit filterTextChanged( ui->filter->text() ); +} + + +void +FlexibleHeader::changeEvent( QEvent* e ) +{ + QWidget::changeEvent( e ); + switch ( e->type() ) + { + case QEvent::LanguageChange: +// ui->retranslateUi( this ); + break; + + default: + break; + } +} diff --git a/src/libtomahawk/playlist/FlexibleHeader.h b/src/libtomahawk/playlist/FlexibleHeader.h new file mode 100644 index 000000000..623293cec --- /dev/null +++ b/src/libtomahawk/playlist/FlexibleHeader.h @@ -0,0 +1,68 @@ +/* === 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 FLEXIBLEHEADER_H +#define FLEXIBLEHEADER_H + +#include +#include + +#include "DllMacro.h" +#include "Artist.h" + +class FlexibleView; + +namespace Ui +{ + class PlaylistHeader; +} + +class DLLEXPORT FlexibleHeader : public QWidget +{ +Q_OBJECT + +public: + FlexibleHeader( FlexibleView* parent ); + ~FlexibleHeader(); + +public slots: + void setCaption( const QString& s ); + void setDescription( const QString& s ); + void setPixmap( const QPixmap& p ); + + void setFilter( const QString& filter ); + +signals: + void filterTextChanged( const QString& filter ); + +protected: + void changeEvent( QEvent* e ); + +private slots: + void onFilterEdited(); + void applyFilter(); + +private: + FlexibleView* m_parent; + Ui::PlaylistHeader* ui; + + QString m_filter; + QTimer m_filterTimer; +}; + +#endif diff --git a/src/libtomahawk/playlist/PlaylistHeader.ui b/src/libtomahawk/playlist/PlaylistHeader.ui new file mode 100644 index 000000000..d6429c8fb --- /dev/null +++ b/src/libtomahawk/playlist/PlaylistHeader.ui @@ -0,0 +1,279 @@ + + + PlaylistHeader + + + + 0 + 0 + 774 + 80 + + + + + 0 + 0 + + + + + 0 + 72 + + + + InfoBar + + + + + + + 0 + 0 + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + 0 + + + 0 + + + 2 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Caption + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Description + + + + + + + Qt::Vertical + + + + 20 + 1 + + + + + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 156 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 87 + 30 + + + + + 87 + 30 + + + + + 0 + + + 0 + + + + + RadioButton + + + + + + + RadioButton + + + + + + + RadioButton + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + + 0 + 0 + + + + + 220 + 0 + + + + + 220 + 16777215 + + + + + + + + + ElidedLabel + QLabel +
widgets/ElidedLabel.h
+
+ + QSearchField + QLineEdit +
thirdparty/Qocoa/qsearchfield.h
+
+
+ + +