From 9a0089b2a12d75aaf04d9b485ea547d8ad096ba3 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 15 Jun 2013 09:52:29 +0200 Subject: [PATCH] * New layout for search page. --- src/libtomahawk/widgets/SearchWidget.cpp | 129 +++++++++-- src/libtomahawk/widgets/SearchWidget.h | 2 +- src/libtomahawk/widgets/SearchWidget.ui | 260 +++++++++++++++++++++-- 3 files changed, 351 insertions(+), 40 deletions(-) diff --git a/src/libtomahawk/widgets/SearchWidget.cpp b/src/libtomahawk/widgets/SearchWidget.cpp index 572a5b68b..c0fbaf556 100644 --- a/src/libtomahawk/widgets/SearchWidget.cpp +++ b/src/libtomahawk/widgets/SearchWidget.cpp @@ -20,52 +20,139 @@ #include "SearchWidget.h" #include "ui_SearchWidget.h" -#include -#include - #include "SourceList.h" #include "ViewManager.h" #include "playlist/PlayableModel.h" #include "playlist/PlaylistModel.h" #include "utils/AnimatedSpinner.h" - +#include "utils/TomahawkStyle.h" #include "utils/TomahawkUtilsGui.h" #include "utils/Logger.h" +#include +#include + SearchWidget::SearchWidget( const QString& search, QWidget* parent ) : QWidget( parent ) , ui( new Ui::SearchWidget ) , m_search( search ) { - ui->setupUi( this ); + QWidget* widget = new QWidget; + ui->setupUi( widget ); - ui->resultsView->setGuid( "searchwidget" ); - m_resultsModel = new PlaylistModel( ui->resultsView ); - ui->resultsView->setPlaylistModel( m_resultsModel ); - ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder ); + ui->lineAbove->setStyleSheet( QString( "QFrame { border: 1px solid black; }" ) ); + ui->lineBelow->setStyleSheet( QString( "QFrame { border: 1px solid %1; }" ).arg( TomahawkStyle::HEADER_BACKGROUND.name() ) ); - m_albumsModel = new PlayableModel( ui->albumView ); - ui->albumView->setPlayableModel( m_albumsModel ); + { + ui->resultsView->setGuid( "searchwidget" ); + m_resultsModel = new PlaylistModel( ui->resultsView ); - m_artistsModel = new PlayableModel( ui->artistView ); - ui->artistView->setPlayableModel( m_artistsModel ); + QPalette p = ui->resultsView->palette(); + p.setColor( QPalette::Text, TomahawkStyle::PAGE_TRACKLIST_TRACK_SOLVED ); + p.setColor( QPalette::BrightText, TomahawkStyle::PAGE_TRACKLIST_TRACK_UNRESOLVED ); + p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_TRACKLIST_NUMBER ); + p.setColor( QPalette::Highlight, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT ); + p.setColor( QPalette::HighlightedText, TomahawkStyle::PAGE_TRACKLIST_HIGHLIGHT_TEXT ); - ui->artistView->proxyModel()->sort( -1 ); - ui->albumView->proxyModel()->sort( -1 ); - ui->artistView->proxyModel()->setHideDupeItems( true ); - ui->albumView->proxyModel()->setHideDupeItems( true ); + ui->resultsView->setPalette( p ); + ui->resultsView->setFrameShape( QFrame::Panel ); + ui->resultsView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + ui->resultsView->setStyleSheet( "QTreeView { background-color: transparent; }" ); + TomahawkStyle::stylePageFrame( ui->resultsFrame ); - TomahawkUtils::unmarginLayout( ui->verticalLayout ); + ui->resultsView->setAlternatingRowColors( false ); + ui->resultsView->setAutoResize( true ); + ui->resultsView->setPlaylistModel( m_resultsModel ); + ui->resultsView->sortByColumn( PlaylistModel::Score, Qt::DescendingOrder ); + ui->resultsView->setEmptyTip( tr( "Sorry, we could not find any tracks!" ) ); + } + + { + m_albumsModel = new PlayableModel( ui->albumView ); + ui->albumView->setPlayableModel( m_albumsModel ); + + ui->albumView->setFrameShape( QFrame::NoFrame ); + ui->albumView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + ui->albumView->proxyModel()->sort( -1 ); + ui->albumView->proxyModel()->setHideDupeItems( true ); + + ui->albumView->setAutoResize( true ); + ui->albumView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + ui->albumView->setStyleSheet( "QListView { background-color: transparent; }" ); + TomahawkStyle::stylePageFrame( ui->albumFrame ); + } + + { + m_artistsModel = new PlayableModel( ui->artistView ); + ui->artistView->setPlayableModel( m_artistsModel ); + + ui->artistView->setFrameShape( QFrame::NoFrame ); + ui->artistView->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + ui->artistView->proxyModel()->sort( -1 ); + ui->artistView->proxyModel()->setHideDupeItems( true ); + + ui->artistView->setAutoResize( true ); + ui->artistView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + ui->artistView->setStyleSheet( "QListView { background-color: transparent; }" ); + TomahawkStyle::stylePageFrame( ui->artistFrame ); + } + + { + QFont f = ui->label->font(); + f.setFamily( "Fauna One" ); + + QPalette p = ui->label->palette(); + p.setColor( QPalette::Foreground, TomahawkStyle::PAGE_CAPTION ); + + ui->label->setFont( f ); + ui->label->setPalette( p ); + } + + { + QFont f = ui->label_2->font(); + f.setFamily( "Fauna One" ); + + QPalette p = ui->label_2->palette(); + p.setColor( QPalette::Foreground, TomahawkStyle::HEADER_TEXT ); + + ui->label_2->setFont( f ); + ui->label_3->setFont( f ); + ui->label_2->setPalette( p ); + ui->label_3->setPalette( p ); + } + + { + QScrollArea* area = new QScrollArea(); + area->setWidgetResizable( true ); + area->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); + area->setWidget( widget ); + + QPalette pal = palette(); + pal.setBrush( backgroundRole(), TomahawkStyle::HEADER_BACKGROUND ); + area->setPalette( pal ); + area->setAutoFillBackground( true ); + area->setFrameShape( QFrame::NoFrame ); + area->setAttribute( Qt::WA_MacShowFocusRect, 0 ); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->addWidget( area ); + setLayout( layout ); + TomahawkUtils::unmarginLayout( layout ); + } + + { + QPalette pal = palette(); + pal.setBrush( backgroundRole(), TomahawkStyle::PAGE_BACKGROUND ); + ui->resultsContainer->setPalette( pal ); + ui->resultsContainer->setAutoFillBackground( true ); + } m_artistsModel->startLoading(); m_albumsModel->startLoading(); m_resultsModel->startLoading(); m_queries << Tomahawk::Query::get( search, uuid() ); - ui->splitter_2->setStretchFactor( 0, 0 ); - ui->splitter_2->setStretchFactor( 1, 1 ); - foreach ( const Tomahawk::query_ptr& query, m_queries ) { connect( query.data(), SIGNAL( artistsAdded( QList ) ), SLOT( onArtistsFound( QList ) ) ); diff --git a/src/libtomahawk/widgets/SearchWidget.h b/src/libtomahawk/widgets/SearchWidget.h index c4da8481e..14877363b 100644 --- a/src/libtomahawk/widgets/SearchWidget.h +++ b/src/libtomahawk/widgets/SearchWidget.h @@ -54,8 +54,8 @@ public: virtual QString description() const { return tr( "Results for '%1'" ).arg( m_search ); } virtual QPixmap pixmap() const; + virtual bool showInfoBar() const { return true; } virtual bool isTemporaryPage() const { return true; } - virtual bool jumpToCurrentTrack(); protected: diff --git a/src/libtomahawk/widgets/SearchWidget.ui b/src/libtomahawk/widgets/SearchWidget.ui index e2df0a078..823bfc7e0 100644 --- a/src/libtomahawk/widgets/SearchWidget.ui +++ b/src/libtomahawk/widgets/SearchWidget.ui @@ -6,33 +6,257 @@ 0 0 - 985 - 460 + 939 + 647 Qt::TabFocus - + + + 0 + + + 0 + - + + + + 12 + + + 16 + + + 12 + + + 16 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 8 + + + 4 + + + 8 + + + 4 + + + + + + 20 + 50 + false + + + + Tracks + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + + + + 16777215 + 1 + + - Qt::Vertical + Qt::Horizontal - - 1 + + + + + + + 16777215 + 1 + - - - Qt::Horizontal + + Qt::Horizontal + + + + + + + + 0 - - 1 + + 16 - - - - + + 0 + + + 16 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 28 + + + 4 + + + 8 + + + 4 + + + + + + 20 + 50 + false + + + + Artists + + + + + + + + 0 + 190 + + + + + + + + + + + + + + + 0 + + + 16 + + + 0 + + + 16 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 28 + + + 4 + + + 8 + + + 4 + + + + + + 20 + 50 + false + + + + Albums + + + + + + + + 0 + 190 + + + + + + + + @@ -41,12 +265,12 @@ PlaylistView QTreeView -
playlist/PlaylistView.h
+
playlist/PlaylistView.h
GridView QListView -
playlist/GridView.h
+
playlist/GridView.h