not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / ksmserver / kcm / kcmsmserver.cpp
blobf3a2adc537009ef4128363e8409fd1ef94aef775
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 <kstandarddirs.h>
32 #include <qregexp.h>
33 #include <kdesktopfile.h>
34 #include <kdebug.h>
35 #include <kprocess.h>
36 #include <kmessagebox.h>
37 #include <QtDBus/QtDBus>
39 #include "kcmsmserver.h"
40 #include "smserverconfigimpl.h"
41 #include <KPluginFactory>
42 #include <KPluginLoader>
44 K_PLUGIN_FACTORY(SMSFactory,
45 registerPlugin<SMServerConfig>();
47 K_EXPORT_PLUGIN(SMSFactory("kcmsmserver"))
49 SMServerConfig::SMServerConfig( QWidget *parent, const QVariantList & )
50 : KCModule (SMSFactory::componentData(), parent)
52 setQuickHelp( i18n("<h1>Session Manager</h1>"
53 " You can configure the session manager here."
54 " This includes options such as whether or not the session exit (logout)"
55 " should be confirmed, whether the session should be restored again when logging in"
56 " and whether the computer should be automatically shut down after session"
57 " exit by default."));
59 QVBoxLayout *topLayout = new QVBoxLayout(this);
60 topLayout->setMargin(0);
61 topLayout->setSpacing(KDialog::spacingHint());
62 dialog = new SMServerConfigImpl(this);
63 connect(dialog, SIGNAL(changed()), SLOT(changed()));
65 topLayout->addWidget(dialog);
68 void SMServerConfig::load()
70 KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General");
71 dialog->confirmLogoutCheck->setChecked(c.readEntry("confirmLogout", true));
72 bool en = c.readEntry("offerShutdown", true);
73 dialog->offerShutdownCheck->setChecked(en);
74 dialog->sdGroup->setEnabled(en);
76 QString s = c.readEntry( "loginMode" );
77 if ( s == "default" )
78 dialog->emptySessionRadio->setChecked(true);
79 else if ( s == "restoreSavedSession" )
80 dialog->savedSessionRadio->setChecked(true);
81 else // "restorePreviousLogout"
82 dialog->previousSessionRadio->setChecked(true);
84 switch (c.readEntry("shutdownType", int(KWorkSpace::ShutdownTypeNone))) {
85 case int(KWorkSpace::ShutdownTypeHalt):
86 dialog->haltRadio->setChecked(true);
87 break;
88 case int(KWorkSpace::ShutdownTypeReboot):
89 dialog->rebootRadio->setChecked(true);
90 break;
91 default:
92 dialog->logoutRadio->setChecked(true);
93 break;
95 dialog->excludeLineedit->setText( c.readEntry("excludeApps"));
97 emit changed(false);
100 void SMServerConfig::save()
102 KConfig c("ksmserverrc", KConfig::NoGlobals);
103 KConfigGroup group = c.group("General");
104 group.writeEntry( "confirmLogout", dialog->confirmLogoutCheck->isChecked());
105 group.writeEntry( "offerShutdown", dialog->offerShutdownCheck->isChecked());
106 QString s = "restorePreviousLogout";
107 if ( dialog->emptySessionRadio->isChecked() )
108 s = "default";
109 else if ( dialog->savedSessionRadio->isChecked() )
110 s = "restoreSavedSession";
111 group.writeEntry( "loginMode", s );
113 group.writeEntry( "shutdownType",
114 dialog->haltRadio->isChecked() ?
115 int(KWorkSpace::ShutdownTypeHalt) :
116 dialog->rebootRadio->isChecked() ?
117 int(KWorkSpace::ShutdownTypeReboot) :
118 int(KWorkSpace::ShutdownTypeNone));
119 group.writeEntry("excludeApps", dialog->excludeLineedit->text());
120 c.sync();
121 # if 0
122 // update the k menu if necessary
123 QDBusInterface kicker("org.kde.kicker", "/kicker", "org.kde.kicker");
124 kicker.call("configure");
125 #endif
128 void SMServerConfig::defaults()
130 dialog->previousSessionRadio->setChecked(true);
131 dialog->confirmLogoutCheck->setChecked(true);
132 dialog->offerShutdownCheck->setChecked(true);
133 dialog->sdGroup->setEnabled(true);
134 dialog->logoutRadio->setChecked(true);
135 dialog->excludeLineedit->clear();
138 #include "kcmsmserver.moc"