Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kcontrol / smserver / kcmsmserver.cpp
blob67c309b857913c7f8628c3a13d3ce3f48c7d17d5
1 /*
2 * kcmsmserver.cpp
3 * Copyright (c) 2000,2002 Oswald Buddenhagen <ossi@kde.org>
5 * based on kcmtaskbar.cpp
6 * Copyright (c) 2000 Kurt Granroth <granroth@kde.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
22 #include <QCheckBox>
23 //Added by qt3to4:
24 #include <QVBoxLayout>
27 #include <kapplication.h>
28 #include <kconfig.h>
29 #include <klineedit.h>
30 #include <kworkspace.h>
31 #include <QtDBus/QtDBus>
33 #include "kcmsmserver.h"
34 #include "smserverconfigimpl.h"
35 #include <KPluginFactory>
36 #include <KPluginLoader>
38 K_PLUGIN_FACTORY(SMSFactory,
39 registerPlugin<SMServerConfig>();
41 K_EXPORT_PLUGIN(SMSFactory("kcmsmserver"))
43 SMServerConfig::SMServerConfig( QWidget *parent, const QVariantList & )
44 : KCModule (SMSFactory::componentData(), parent)
46 setQuickHelp( i18n("<h1>Session Manager</h1>"
47 " You can configure the session manager here."
48 " This includes options such as whether or not the session exit (logout)"
49 " should be confirmed, whether the session should be restored again when logging in"
50 " and whether the computer should be automatically shut down after session"
51 " exit by default."));
53 QVBoxLayout *topLayout = new QVBoxLayout(this);
54 topLayout->setMargin(0);
55 topLayout->setSpacing(KDialog::spacingHint());
56 dialog = new SMServerConfigImpl(this);
57 connect(dialog, SIGNAL(changed()), SLOT(changed()));
59 topLayout->addWidget(dialog);
60 load();
64 void SMServerConfig::load()
66 KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General");
67 dialog->confirmLogoutCheck->setChecked(c.readEntry("confirmLogout", true));
68 bool en = c.readEntry("offerShutdown", true);
69 dialog->offerShutdownCheck->setChecked(en);
70 dialog->sdGroup->setEnabled(en);
72 QString s = c.readEntry( "loginMode" );
73 if ( s == "default" )
74 dialog->emptySessionRadio->setChecked(true);
75 else if ( s == "restoreSavedSession" )
76 dialog->savedSessionRadio->setChecked(true);
77 else // "restorePreviousLogout"
78 dialog->previousSessionRadio->setChecked(true);
80 switch (c.readEntry("shutdownType", int(KWorkSpace::ShutdownTypeNone))) {
81 case int(KWorkSpace::ShutdownTypeHalt):
82 dialog->haltRadio->setChecked(true);
83 break;
84 case int(KWorkSpace::ShutdownTypeReboot):
85 dialog->rebootRadio->setChecked(true);
86 break;
87 default:
88 dialog->logoutRadio->setChecked(true);
89 break;
91 dialog->excludeLineedit->setText( c.readEntry("excludeApps"));
93 emit changed(false);
96 void SMServerConfig::save()
98 KConfig *c = new KConfig("ksmserverrc", KConfig::NoGlobals);
99 KConfigGroup group = c->group("General");
100 group.writeEntry( "confirmLogout", dialog->confirmLogoutCheck->isChecked());
101 group.writeEntry( "offerShutdown", dialog->offerShutdownCheck->isChecked());
102 QString s = "restorePreviousLogout";
103 if ( dialog->emptySessionRadio->isChecked() )
104 s = "default";
105 else if ( dialog->savedSessionRadio->isChecked() )
106 s = "restoreSavedSession";
107 group.writeEntry( "loginMode", s );
109 group.writeEntry( "shutdownType",
110 dialog->haltRadio->isChecked() ?
111 int(KWorkSpace::ShutdownTypeHalt) :
112 dialog->rebootRadio->isChecked() ?
113 int(KWorkSpace::ShutdownTypeReboot) :
114 int(KWorkSpace::ShutdownTypeNone));
115 group.writeEntry("excludeApps", dialog->excludeLineedit->text());
116 c->sync();
117 delete c;
118 # if 0
119 // update the k menu if necessary
120 QDBusInterface kicker("org.kde.kicker", "/kicker", "org.kde.kicker");
121 kicker.call("configure");
122 #endif
125 void SMServerConfig::defaults()
127 dialog->previousSessionRadio->setChecked(true);
128 dialog->confirmLogoutCheck->setChecked(true);
129 dialog->offerShutdownCheck->setChecked(true);
130 dialog->sdGroup->setEnabled(true);
131 dialog->logoutRadio->setChecked(true);
132 dialog->excludeLineedit->clear();
136 #include "kcmsmserver.moc"