add more spacing
[personal-kdebase.git] / workspace / khotkeys / kcm_hotkeys / global_settings_widget.cpp
blob481d54b2f235e98955a2e282bb12b78a4ace9cfc
1 /*
2 Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "global_settings_widget.h"
22 #include <KDebug>
23 #include <KDesktopFile>
24 #include <KGlobal>
25 #include <KStandardDirs>
28 GlobalSettingsWidget::GlobalSettingsWidget( QWidget *parent )
29 : HotkeysWidgetIFace( parent )
31 ui.setupUi(this);
32 layout()->setContentsMargins(0,0,0,0);
34 QString path = KGlobal::dirs()->findResource( "services", "kded/khotkeys.desktop");
35 if ( KDesktopFile::isDesktopFile(path) )
37 _config = KSharedConfig::openConfig(
38 path,
39 KConfig::NoGlobals,
40 "services" );
43 connect(
44 ui.enabled, SIGNAL(stateChanged(int)),
45 _changedSignals, SLOT(map()) );
46 _changedSignals->setMapping(ui.enabled, "enabled" );
50 GlobalSettingsWidget::~GlobalSettingsWidget()
55 void GlobalSettingsWidget::doCopyFromObject()
57 if ( _config )
59 KConfigGroup file(_config, "Desktop Entry");
60 ui.enabled->setChecked(file.readEntry("X-KDE-Kded-autoload", false));
65 void GlobalSettingsWidget::doCopyToObject()
67 kDebug();
68 if (_config)
70 KConfigGroup file(_config, "Desktop Entry");
71 file.writeEntry("X-KDE-Kded-autoload", ui.enabled->checkState()==Qt::Checked);
72 _config->sync();
77 bool GlobalSettingsWidget::isChanged() const
79 if (_config)
81 KConfigGroup file(_config, "Desktop Entry");
82 bool enabled = file.readEntry("X-KDE-Kded-autoload", false);
84 if ( enabled && ( ui.enabled->checkState() != Qt::Checked ) )
86 return true;
89 if ( !enabled && ( ui.enabled->checkState() != Qt::Unchecked ) )
91 return true;
94 return false;
98 #include "moc_global_settings_widget.cpp"