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
24 #include <QVBoxLayout>
27 #include <kapplication.h>
29 #include <klineedit.h>
30 #include <kworkspace.h>
31 #include <kstandarddirs.h>
33 #include <kdesktopfile.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" );
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);
88 case int(KWorkSpace::ShutdownTypeReboot
):
89 dialog
->rebootRadio
->setChecked(true);
92 dialog
->logoutRadio
->setChecked(true);
95 dialog
->excludeLineedit
->setText( c
.readEntry("excludeApps"));
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() )
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());
122 // update the k menu if necessary
123 QDBusInterface
kicker("org.kde.kicker", "/kicker", "org.kde.kicker");
124 kicker
.call("configure");
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"