From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcontrol/smserver/kcmsmserver.cpp | 134 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 kcontrol/smserver/kcmsmserver.cpp (limited to 'kcontrol/smserver/kcmsmserver.cpp') diff --git a/kcontrol/smserver/kcmsmserver.cpp b/kcontrol/smserver/kcmsmserver.cpp new file mode 100644 index 000000000..9de1334b0 --- /dev/null +++ b/kcontrol/smserver/kcmsmserver.cpp @@ -0,0 +1,134 @@ +/* + * kcmsmserver.cpp + * Copyright (c) 2000,2002 Oswald Buddenhagen + * + * based on kcmtaskbar.cpp + * Copyright (c) 2000 Kurt Granroth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + */ +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "kcmsmserver.h" +#include "smserverconfigimpl.h" + +typedef KGenericFactory SMSFactory; +K_EXPORT_COMPONENT_FACTORY (kcm_smserver, SMSFactory("kcmsmserver") ) + +SMServerConfig::SMServerConfig( QWidget *parent, const char* name, const QStringList & ) + : KCModule (SMSFactory::instance(), parent, name) +{ + setQuickHelp( i18n("

Session Manager

" + " You can configure the session manager here." + " This includes options such as whether or not the session exit (logout)" + " should be confirmed, whether the session should be restored again when logging in" + " and whether the computer should be automatically shut down after session" + " exit by default.")); + + QVBoxLayout *topLayout = new QVBoxLayout(this); + dialog = new SMServerConfigImpl(this); + connect(dialog, SIGNAL(changed()), SLOT(changed())); + + dialog->show(); + topLayout->add(dialog); + load(); + +} + +void SMServerConfig::load() +{ + load( false ); +} + +void SMServerConfig::load(bool useDefaults ) +{ + KConfig *c = new KConfig("ksmserverrc", false, false); + c->setReadDefaults( useDefaults ); + c->setGroup("General"); + dialog->confirmLogoutCheck->setChecked(c->readBoolEntry("confirmLogout", true)); + bool en = c->readBoolEntry("offerShutdown", true); + dialog->offerShutdownCheck->setChecked(en); + dialog->sdGroup->setEnabled(en); + + QString s = c->readEntry( "loginMode" ); + if ( s == "default" ) + dialog->emptySessionRadio->setChecked(true); + else if ( s == "restoreSavedSession" ) + dialog->savedSessionRadio->setChecked(true); + else // "restorePreviousLogout" + dialog->previousSessionRadio->setChecked(true); + + switch (c->readNumEntry("shutdownType", int(KApplication::ShutdownTypeNone))) { + case int(KApplication::ShutdownTypeHalt): + dialog->haltRadio->setChecked(true); + break; + case int(KApplication::ShutdownTypeReboot): + dialog->rebootRadio->setChecked(true); + break; + default: + dialog->logoutRadio->setChecked(true); + break; + } + dialog->excludeLineedit->setText( c->readEntry("excludeApps")); + + delete c; + + emit changed(useDefaults); +} + +void SMServerConfig::save() +{ + KConfig *c = new KConfig("ksmserverrc", false, false); + c->setGroup("General"); + c->writeEntry( "confirmLogout", dialog->confirmLogoutCheck->isChecked()); + c->writeEntry( "offerShutdown", dialog->offerShutdownCheck->isChecked()); + QString s = "restorePreviousLogout"; + if ( dialog->emptySessionRadio->isChecked() ) + s = "default"; + else if ( dialog->savedSessionRadio->isChecked() ) + s = "restoreSavedSession"; + c->writeEntry( "loginMode", s ); + + c->writeEntry( "shutdownType", + dialog->haltRadio->isChecked() ? + int(KApplication::ShutdownTypeHalt) : + dialog->rebootRadio->isChecked() ? + int(KApplication::ShutdownTypeReboot) : + int(KApplication::ShutdownTypeNone)); + c->writeEntry("excludeApps", dialog->excludeLineedit->text()); + c->sync(); + delete c; + + // update the k menu if necessary + QByteArray data; + kapp->dcopClient()->send( "kicker", "kicker", "configure()", data ); +} + +void SMServerConfig::defaults() +{ + load( true ); +} + +#include "kcmsmserver.moc" + -- cgit v1.2.1