File indexing completed on 2024-05-19 04:48:46
0001 /**************************************************************************************** 0002 * Copyright (c) 2007 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 Public 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 #define DEBUG_PREFIX "PluginsConfig" 0018 0019 #include "PluginsConfig.h" 0020 0021 #include "configdialog/ConfigDialog.h" 0022 #include "core/support/Debug.h" 0023 #include "services/ServiceBase.h" 0024 #include "PluginManager.h" 0025 0026 #include <KPluginInfo> 0027 #include <KPluginSelector> 0028 0029 #include <QVBoxLayout> 0030 0031 PluginsConfig::PluginsConfig( Amarok2ConfigDialog *parent ) 0032 : ConfigDialogBase( parent ) 0033 , m_configChanged( false ) 0034 { 0035 DEBUG_BLOCK 0036 m_selector = new KPluginSelector( this ); 0037 m_selector->setSizePolicy( QSizePolicy:: Expanding, QSizePolicy::Expanding ); 0038 0039 QVBoxLayout *layout = new QVBoxLayout( this ); 0040 layout->setMargin( 0 ); 0041 layout->addWidget( m_selector ); 0042 0043 m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Collection ), 0044 KPluginSelector::ReadConfigFile, i18n("Collections"), QStringLiteral("Collection") ); 0045 0046 m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Service ), 0047 KPluginSelector::ReadConfigFile, i18n("Internet Services"), QStringLiteral("Service") ); 0048 0049 m_selector->addPlugins( The::pluginManager()->plugins( Plugins::PluginManager::Importer ), 0050 KPluginSelector::ReadConfigFile, i18n("Statistics importers"), QStringLiteral("Importer") ); 0051 0052 connect( m_selector, &KPluginSelector::changed, this, &PluginsConfig::slotConfigChanged ); 0053 connect( m_selector, &KPluginSelector::changed, parent, &Amarok2ConfigDialog::updateButtons ); 0054 } 0055 0056 PluginsConfig::~PluginsConfig() 0057 {} 0058 0059 void PluginsConfig::updateSettings() 0060 { 0061 DEBUG_BLOCK 0062 if( m_configChanged ) 0063 { 0064 debug() << "config changed"; 0065 m_selector->save(); 0066 0067 // check if any services were disabled and needs to be removed, or any 0068 // that are hidden needs to be enabled 0069 The::pluginManager()->checkPluginEnabledStates(); 0070 } 0071 } 0072 0073 bool PluginsConfig::hasChanged() 0074 { 0075 return m_configChanged; 0076 } 0077 0078 bool PluginsConfig::isDefault() 0079 { 0080 return false; 0081 } 0082 0083 void PluginsConfig::slotConfigChanged( bool changed ) 0084 { 0085 m_configChanged = changed; 0086 if( changed ) 0087 debug() << "config changed"; 0088 } 0089