summaryrefslogtreecommitdiffstats
path: root/kcontrol/smserver/kcmsmserver.cpp
blob: 3d165a577ce9b851446d747f9e8b02eda08d5364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 *  kcmsmserver.cpp
 *  Copyright (c) 2000,2002 Oswald Buddenhagen <[email protected]>
 *
 *  based on kcmtaskbar.cpp
 *  Copyright (c) 2000 Kurt Granroth <[email protected]>
 *
 *  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 <tqbuttongroup.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqradiobutton.h>

#include <dcopclient.h>

#include <tdeapplication.h>
#include <tdeconfig.h>
#include <kgenericfactory.h>
#include <klineedit.h>

#include "kcmsmserver.h"
#include "smserverconfigimpl.h"

typedef KGenericFactory<SMServerConfig, TQWidget > SMSFactory;
K_EXPORT_COMPONENT_FACTORY (kcm_smserver, SMSFactory("kcmsmserver") )

SMServerConfig::SMServerConfig( TQWidget *parent, const char* name, const TQStringList & )
  : TDECModule (SMSFactory::instance(), parent, name)
{
    setQuickHelp( i18n("<h1>Session Manager</h1>"
    " 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."));

    TQVBoxLayout *topLayout = new TQVBoxLayout(this);
    dialog = new SMServerConfigImpl(this);
    connect(dialog, TQ_SIGNAL(changed()), TQ_SLOT(changed()));

    dialog->show();
    topLayout->add(dialog);
    load();

}

void SMServerConfig::load()
{
	load( false );
}

void SMServerConfig::load(bool useDefaults )
{
  TDEConfig *c = new TDEConfig("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);

  TQString 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(TDEApplication::ShutdownTypeNone))) {
  case int(TDEApplication::ShutdownTypeHalt):
    dialog->haltRadio->setChecked(true);
    break;
  case int(TDEApplication::ShutdownTypeReboot):
    dialog->rebootRadio->setChecked(true);
    break;
  default:
    dialog->logoutRadio->setChecked(true);
    break;
  }
  dialog->excludeLineedit->setText( c->readEntry("excludeApps"));

  c->setGroup("Logout");
  dialog->showLogoutStatusDialog->setChecked(c->readBoolEntry("showLogoutStatusDlg", true));
  dialog->showUbuntuStyleDialog->setChecked(c->readBoolEntry("doUbuntuLogout", false));
  dialog->showFadeAway->setChecked(c->readBoolEntry("doFadeaway", true));
  dialog->showFancyFadeAway->setChecked(c->readBoolEntry("doFancyLogout", true));
  dialog->showFancyFadeAway->setEnabled(dialog->confirmLogoutCheck->isChecked() && dialog->showFadeAway->isChecked()),

  delete c;

  emit changed(useDefaults);
}

void SMServerConfig::save()
{
  TDEConfig *c = new TDEConfig("ksmserverrc", false, false);
  c->setGroup("General");
  c->writeEntry( "confirmLogout", dialog->confirmLogoutCheck->isChecked());
  c->writeEntry( "offerShutdown", dialog->offerShutdownCheck->isChecked());

  TQString 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(TDEApplication::ShutdownTypeHalt) :
                   dialog->rebootRadio->isChecked() ?
                     int(TDEApplication::ShutdownTypeReboot) :
                     int(TDEApplication::ShutdownTypeNone));
  c->writeEntry("excludeApps", dialog->excludeLineedit->text());
  c->setGroup("Logout");
  c->writeEntry( "showLogoutStatusDlg", dialog->showLogoutStatusDialog->isChecked());
  c->writeEntry( "doUbuntuLogout", dialog->showUbuntuStyleDialog->isChecked());
  c->writeEntry( "doFadeaway", dialog->showFadeAway->isChecked());
  c->writeEntry( "doFancyLogout", dialog->showFancyFadeAway->isChecked());
  c->sync();
  delete c;

  // update the k menu if necessary
  TQByteArray data;
  kapp->dcopClient()->send( "kicker", "kicker", "configure()", data );
}

void SMServerConfig::defaults()
{
	load( true );
}

#include "kcmsmserver.moc"