File indexing completed on 2024-05-05 04:48:44
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * Copyright (c) 2009 Téo Mrnjavac <teo@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #include "PlaylistViewUrlRunner.h" 0019 0020 #include "MainWindow.h" 0021 #include "amarokurls/AmarokUrlHandler.h" 0022 #include "core/support/Debug.h" 0023 #include "layouts/LayoutManager.h" 0024 #include "playlist/PlaylistDock.h" 0025 #include "playlist/ProgressiveSearchWidget.h" 0026 0027 #include <KLocalizedString> 0028 0029 #include <QActionGroup> 0030 #include <QList> 0031 #include <QStandardPaths> 0032 #include <QStringList> 0033 0034 namespace Playlist 0035 { 0036 0037 ViewUrlRunner::ViewUrlRunner() 0038 : AmarokUrlRunnerBase() 0039 {} 0040 0041 ViewUrlRunner::~ViewUrlRunner() 0042 { 0043 The::amarokUrlHandler()->unRegisterRunner( this ); 0044 } 0045 0046 bool 0047 ViewUrlRunner::run( const AmarokUrl &url ) 0048 { 0049 DEBUG_BLOCK 0050 0051 const QMap< QString, QString > args = url.args(); 0052 auto playlistDock = The::mainWindow()->playlistDock(); 0053 0054 if( args.keys().contains( QStringLiteral("filter") ) ) 0055 { 0056 const QString filterExpr = args.value( QStringLiteral("filter") ); 0057 playlistDock->searchWidget()->setCurrentFilter( filterExpr ); 0058 if( args.keys().contains( QStringLiteral("matches") ) ) 0059 { 0060 const QString onlyMatches = args.value( QStringLiteral("matches") ); 0061 playlistDock->searchWidget()->slotShowOnlyMatches( ( onlyMatches == QStringLiteral( "true" ) ) ); 0062 } 0063 } 0064 if( args.keys().contains( QStringLiteral("sort") ) ) 0065 { 0066 const QString sortPath = args.value( QStringLiteral("sort") ); 0067 playlistDock->sortWidget()->readSortPath( sortPath ); 0068 } 0069 0070 if( args.keys().contains( QStringLiteral("layout") ) ) 0071 { 0072 const QString layout = args.value( QStringLiteral("layout") ); 0073 LayoutManager::instance()->setActiveLayout( layout ); 0074 } 0075 0076 The::mainWindow()->showDock( MainWindow::AmarokDockPlaylist ); 0077 0078 return true; 0079 } 0080 0081 QString 0082 ViewUrlRunner::command() const 0083 { 0084 return QStringLiteral("playlist"); 0085 } 0086 0087 QString 0088 ViewUrlRunner::prettyCommand() const 0089 { 0090 return i18nc( "A type of command that affects the sorting, layout and filtering int he Playlist", "Playlist" ); 0091 } 0092 0093 QIcon 0094 ViewUrlRunner::icon() const 0095 { 0096 return QIcon( QPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/playlist-bookmark-16.png" ) ) ); 0097 } 0098 0099 } //namespace Playlist