1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
4
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
20
#include "FlexibleHeader.h"
26
#include <QPaintEvent>
28
#include <QRadioButton>
30
#include "playlist/FlexibleView.h"
31
#include "ViewManager.h"
32
#include "thirdparty/Qocoa/qsearchfield.h"
33
#include "utils/Closure.h"
34
#include "utils/TomahawkUtilsGui.h"
35
#include "utils/Logger.h"
36
#include "widgets/QueryLabel.h"
39
using namespace Tomahawk;
42
FlexibleHeader::FlexibleHeader( FlexibleView* parent )
43
: BasicHeader( parent )
46
QFile f( RESPATH "stylesheets/topbar-radiobuttons.css" );
47
f.open( QFile::ReadOnly );
48
QString css = QString::fromAscii( f.readAll() );
51
QHBoxLayout* outerModeLayout = new QHBoxLayout;
52
m_verticalLayout->addLayout( outerModeLayout );
53
outerModeLayout->addSpacing( 156 );
54
outerModeLayout->addStretch();
56
QWidget* modeWidget = new QWidget( this );
57
QHBoxLayout* modeLayout = new QHBoxLayout;
58
modeWidget->setLayout( modeLayout );
59
modeWidget->setStyleSheet( css );
61
m_radioNormal = new QRadioButton( modeWidget );
62
m_radioDetailed = new QRadioButton( modeWidget );
63
m_radioCloud = new QRadioButton( modeWidget );
65
m_radioNormal->setObjectName( "radioNormal" );
66
m_radioCloud->setObjectName( "radioCloud" );
68
m_radioNormal->setFocusPolicy( Qt::NoFocus );
69
m_radioDetailed->setFocusPolicy( Qt::NoFocus );
70
m_radioCloud->setFocusPolicy( Qt::NoFocus );
72
modeLayout->addWidget( m_radioNormal );
73
modeLayout->addWidget( m_radioDetailed );
74
modeLayout->addWidget( m_radioCloud );
76
modeWidget->setFixedSize( 87, 30 );
78
m_radioNormal->setChecked( true );
80
outerModeLayout->addWidget( modeWidget );
81
outerModeLayout->addStretch();
83
m_filterField = new QSearchField( this );
84
m_filterField->setPlaceholderText( tr( "Filter..." ) );
85
m_filterField->setFixedWidth( 220 );
86
m_mainLayout->addWidget( m_filterField );
88
TomahawkUtils::unmarginLayout( outerModeLayout );
89
TomahawkUtils::unmarginLayout( modeLayout );
91
connect( &m_filterTimer, SIGNAL( timeout() ), SLOT( applyFilter() ) );
92
connect( m_filterField, SIGNAL( textChanged( QString ) ), SLOT( onFilterEdited() ) );
94
NewClosure( m_radioNormal, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Flat )->setAutoDelete( false );
95
NewClosure( m_radioDetailed, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Detailed )->setAutoDelete( false );
96
NewClosure( m_radioCloud, SIGNAL( clicked() ), const_cast< FlexibleView* >( parent ), SLOT( setCurrentMode( FlexibleViewMode ) ), FlexibleView::Grid )->setAutoDelete( false );
100
FlexibleHeader::~FlexibleHeader()
106
FlexibleHeader::setFilter( const QString& filter )
108
m_filterField->setText( filter );
113
FlexibleHeader::onFilterEdited()
115
m_filter = m_filterField->text();
117
m_filterTimer.stop();
118
m_filterTimer.setInterval( 280 );
119
m_filterTimer.setSingleShot( true );
120
m_filterTimer.start();
125
FlexibleHeader::applyFilter()
127
emit filterTextChanged( m_filterField->text() );
132
FlexibleHeader::changeEvent( QEvent* e )
134
QWidget::changeEvent( e );
137
case QEvent::LanguageChange:
138
// ui->retranslateUi( this );