File indexing completed on 2024-05-05 04:47:21
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Pulic License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "ContextUrlGenerator.h" 0018 0019 #include "AmarokUrl.h" 0020 #include "AmarokUrlHandler.h" 0021 #include "context/ContextView.h" 0022 0023 #include <KLocalizedString> 0024 0025 0026 ContextUrlGenerator * ContextUrlGenerator::s_instance = nullptr; 0027 0028 ContextUrlGenerator * ContextUrlGenerator::instance() 0029 { 0030 if( s_instance == nullptr ) 0031 s_instance = new ContextUrlGenerator(); 0032 0033 return s_instance; 0034 } 0035 0036 ContextUrlGenerator::ContextUrlGenerator() 0037 { 0038 } 0039 0040 ContextUrlGenerator::~ContextUrlGenerator() 0041 { 0042 The::amarokUrlHandler()->unRegisterGenerator( this ); 0043 } 0044 0045 AmarokUrl 0046 ContextUrlGenerator::createContextBookmark() 0047 { 0048 QStringList pluginNames = Context::ContextView::self()->currentApplets(); 0049 QStringList appletNames = Context::ContextView::self()->currentAppletNames(); 0050 AmarokUrl url; 0051 0052 url.setCommand( QStringLiteral("context") ); 0053 url.setArg( QStringLiteral("applets"), pluginNames.join( QStringLiteral(",") ) ); 0054 0055 url.setName( i18n( "Context: %1", appletNames.join( QStringLiteral(",") ) ) ); 0056 return url; 0057 } 0058 0059 0060 QString 0061 ContextUrlGenerator::description() 0062 { 0063 return i18n( "Bookmark Context View Applets" ); 0064 } 0065 0066 QIcon ContextUrlGenerator::icon() 0067 { 0068 return QIcon::fromTheme( QStringLiteral("x-media-podcast-amarok") ); 0069 } 0070 0071 AmarokUrl 0072 ContextUrlGenerator::createUrl() 0073 { 0074 return createContextBookmark(); 0075 }