File indexing completed on 2024-05-12 17:10:51
0001 /* 0002 * kwin_smaragd_config.cpp - Emerald window decoration for KDE 0003 * 0004 * Copyright (c) 2010 Christoph Feck <christoph@maxiom.de> 0005 * 0006 * This program is free software; you can redistribute it and/or modify 0007 * it under the terms of the GNU General Public License as published by 0008 * the Free Software Foundation; either version 2 of the License, or 0009 * (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program; if not, write to the Free Software 0018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0019 * 0020 */ 0021 0022 #include "kwin_smaragd_config.h" 0023 0024 #include <KConfig> 0025 #include <KConfigGroup> 0026 0027 extern "C" Q_DECL_EXPORT QObject *allocate_config(KConfig *conf, QWidget *parent) 0028 { 0029 return new Smaragd::Config(conf, parent); 0030 } 0031 0032 namespace Smaragd 0033 { 0034 0035 Config::Config(KConfig *config, QWidget *parent) 0036 : QObject(parent) 0037 { 0038 Q_UNUSED(config); 0039 smaragdConfig = new KConfig(QLatin1String("kwinsmaragdrc")); 0040 // KGlobal::locale()->insertCatalog(QLatin1String("kwin_clients")); 0041 // KGlobal::locale()->insertCatalog(QLatin1String("kwin3_smaragd")); 0042 ui = new ConfigUi(parent); 0043 ui->cm_UseKWinShadows->hide(); 0044 configManager.addWidgets(ui); 0045 load(KConfigGroup(smaragdConfig, "General")); 0046 configManager.connectConfigChanged(this, SLOT(slotSelectionChanged())); 0047 } 0048 0049 Config::~Config() 0050 { 0051 delete smaragdConfig; 0052 delete ui; 0053 } 0054 0055 void Config::load(const KConfigGroup &configGroup) 0056 { 0057 Q_UNUSED(configGroup); 0058 configManager.load(KConfigGroup(smaragdConfig, "General")); 0059 } 0060 0061 void Config::save(KConfigGroup &configGroup) 0062 { 0063 Q_UNUSED(configGroup); 0064 KConfigGroup smaragdConfigGroup(smaragdConfig, "General"); 0065 configManager.save(smaragdConfigGroup); 0066 smaragdConfig->sync(); 0067 } 0068 0069 void Config::defaults() 0070 { 0071 configManager.defaults(); 0072 } 0073 0074 void Config::slotSelectionChanged() 0075 { 0076 if (configManager.hasChanged()) { 0077 emit changed(); 0078 } 0079 } 0080 0081 }; // namespace Smaragd 0082