File indexing completed on 2024-05-19 04:48:45
0001 /**************************************************************************************** 0002 * Copyright (c) 2004-2007 Mark Kretschmann <kretschmann@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 #include "CollectionConfig.h" 0018 0019 #include "amarokconfig.h" 0020 #include <config.h> 0021 #include "configdialog/ConfigDialog.h" 0022 #include "core/support/Amarok.h" 0023 #include "core-impl/collections/db/sql/SqlCollection.h" 0024 #include "dialogs/CollectionSetup.h" 0025 0026 CollectionConfig::CollectionConfig( Amarok2ConfigDialog* parent ) 0027 : ConfigDialogBase( parent ) 0028 { 0029 m_collectionSetup = new CollectionSetup( this ); 0030 0031 QVBoxLayout *layout = new QVBoxLayout(); 0032 layout->addWidget( m_collectionSetup ); 0033 setLayout( layout ); 0034 0035 KConfigGroup transcodeGroup = Amarok::config( Collections::SQL_TRANSCODING_GROUP_NAME ); 0036 m_collectionSetup->transcodingConfig()->fillInChoices( Transcoding::Configuration::fromConfigGroup( transcodeGroup ) ); 0037 0038 connect( m_collectionSetup, &CollectionSetup::changed, parent, &Amarok2ConfigDialog::updateButtons ); 0039 connect( m_collectionSetup->transcodingConfig(), QOverload<int>::of(&QComboBox::currentIndexChanged), 0040 parent, &Amarok2ConfigDialog::updateButtons ); 0041 } 0042 0043 CollectionConfig::~CollectionConfig() 0044 {} 0045 0046 0047 /////////////////////////////////////////////////////////////// 0048 // REIMPLEMENTED METHODS from ConfigDialogBase 0049 /////////////////////////////////////////////////////////////// 0050 0051 bool 0052 CollectionConfig::hasChanged() 0053 { 0054 DEBUG_BLOCK 0055 0056 return m_collectionSetup->hasChanged() || m_collectionSetup->transcodingConfig()->hasChanged(); 0057 } 0058 0059 bool 0060 CollectionConfig::isDefault() 0061 { 0062 return false; 0063 } 0064 0065 void 0066 CollectionConfig::updateSettings() 0067 { 0068 m_collectionSetup->writeConfig(); 0069 0070 KConfigGroup transcodeGroup = Amarok::config( Collections::SQL_TRANSCODING_GROUP_NAME ); 0071 m_collectionSetup->transcodingConfig()->currentChoice().saveToConfigGroup( transcodeGroup ); 0072 } 0073