You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
228 lines
7.5 KiB
228 lines
7.5 KiB
15 years ago
|
/* This file is part of the KDE Display Manager Configuration package
|
||
|
Copyright (C) 1997-1998 Thomas Tanghus (tanghus@earthling.net)
|
||
|
|
||
|
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 Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <unistd.h>
|
||
|
#include <sys/types.h>
|
||
|
|
||
|
|
||
14 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqwhatsthis.h>
|
||
15 years ago
|
|
||
|
#include <ksimpleconfig.h>
|
||
|
#include <karrowbutton.h>
|
||
|
#include <klineedit.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kdialog.h>
|
||
|
#include <kurlrequester.h>
|
||
|
|
||
13 years ago
|
#include "tdm-shut.h"
|
||
15 years ago
|
#include "kbackedcombobox.h"
|
||
|
|
||
|
extern KSimpleConfig *config;
|
||
|
|
||
|
|
||
13 years ago
|
TDMSessionsWidget::TDMSessionsWidget(TQWidget *parent, const char *name)
|
||
14 years ago
|
: TQWidget(parent, name)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString wtstr;
|
||
15 years ago
|
|
||
|
|
||
14 years ago
|
TQGroupBox *group0 = new TQGroupBox( i18n("Allow Shutdown"), this );
|
||
15 years ago
|
|
||
14 years ago
|
sdlcombo = new TQComboBox( FALSE, group0 );
|
||
|
sdllabel = new TQLabel (sdlcombo, i18n ("&Local:"), group0);
|
||
15 years ago
|
sdlcombo->insertItem(i18n("Everybody"), SdAll);
|
||
|
sdlcombo->insertItem(i18n("Only Root"), SdRoot);
|
||
|
sdlcombo->insertItem(i18n("Nobody"), SdNone);
|
||
14 years ago
|
connect(sdlcombo, TQT_SIGNAL(activated(int)), TQT_SLOT(changed()));
|
||
|
sdrcombo = new TQComboBox( FALSE, group0 );
|
||
|
sdrlabel = new TQLabel (sdrcombo, i18n ("&Remote:"), group0);
|
||
15 years ago
|
sdrcombo->insertItem(i18n("Everybody"), SdAll);
|
||
|
sdrcombo->insertItem(i18n("Only Root"), SdRoot);
|
||
|
sdrcombo->insertItem(i18n("Nobody"), SdNone);
|
||
14 years ago
|
connect(sdrcombo, TQT_SIGNAL(activated(int)), TQT_SLOT(changed()));
|
||
|
TQWhatsThis::add( group0, i18n("Here you can select who is allowed to shutdown"
|
||
13 years ago
|
" the computer using TDM. You can specify different values for local (console) and remote displays. "
|
||
15 years ago
|
"Possible values are:<ul>"
|
||
13 years ago
|
" <li><em>Everybody:</em> everybody can shutdown the computer using TDM</li>"
|
||
|
" <li><em>Only root:</em> TDM will only allow shutdown after the user has entered the root password</li>"
|
||
|
" <li><em>Nobody:</em> nobody can shutdown the computer using TDM</li></ul>") );
|
||
15 years ago
|
|
||
|
|
||
14 years ago
|
TQGroupBox *group1 = new TQGroupBox( i18n("Commands"), this );
|
||
15 years ago
|
|
||
|
shutdown_lined = new KURLRequester(group1);
|
||
14 years ago
|
TQLabel *shutdown_label = new TQLabel(shutdown_lined, i18n("H&alt:"), group1);
|
||
|
connect(shutdown_lined, TQT_SIGNAL(textChanged(const TQString&)),
|
||
|
TQT_SLOT(changed()));
|
||
15 years ago
|
wtstr = i18n("Command to initiate the system halt. Typical value: /sbin/halt");
|
||
14 years ago
|
TQWhatsThis::add( shutdown_label, wtstr );
|
||
|
TQWhatsThis::add( shutdown_lined, wtstr );
|
||
15 years ago
|
|
||
|
restart_lined = new KURLRequester(group1);
|
||
14 years ago
|
TQLabel *restart_label = new TQLabel(restart_lined, i18n("Reb&oot:"), group1);
|
||
|
connect(restart_lined, TQT_SIGNAL(textChanged(const TQString&)),
|
||
|
TQT_SLOT(changed()));
|
||
15 years ago
|
wtstr = i18n("Command to initiate the system reboot. Typical value: /sbin/reboot");
|
||
14 years ago
|
TQWhatsThis::add( restart_label, wtstr );
|
||
|
TQWhatsThis::add( restart_lined, wtstr );
|
||
15 years ago
|
|
||
|
|
||
14 years ago
|
TQGroupBox *group4 = new TQGroupBox( i18n("Miscellaneous"), this );
|
||
15 years ago
|
|
||
|
bm_combo = new KBackedComboBox( group4 );
|
||
|
bm_combo->insertItem("None", i18n("boot manager", "None"));
|
||
|
bm_combo->insertItem("Grub", i18n("Grub"));
|
||
|
#if defined(__linux__) && ( defined(__i386__) || defined(__amd64__) )
|
||
|
bm_combo->insertItem("Lilo", i18n("Lilo"));
|
||
|
#endif
|
||
14 years ago
|
TQLabel *bm_label = new TQLabel( bm_combo, i18n("Boot manager:"), group4 );
|
||
|
connect(bm_combo, TQT_SIGNAL(activated(int)), TQT_SLOT(changed()));
|
||
15 years ago
|
wtstr = i18n("Enable boot options in the \"Shutdown...\" dialog.");
|
||
14 years ago
|
TQWhatsThis::add( bm_label, wtstr );
|
||
|
TQWhatsThis::add( bm_combo, wtstr );
|
||
15 years ago
|
|
||
14 years ago
|
TQBoxLayout *main = new TQVBoxLayout( this, 10 );
|
||
|
TQGridLayout *lgroup0 = new TQGridLayout( group0, 1, 1, 10);
|
||
|
TQGridLayout *lgroup1 = new TQGridLayout( group1, 1, 1, 10);
|
||
|
TQGridLayout *lgroup4 = new TQGridLayout( group4, 1, 1, 10);
|
||
15 years ago
|
|
||
|
main->addWidget(group0);
|
||
|
main->addWidget(group1);
|
||
|
main->addWidget(group4);
|
||
|
main->addStretch();
|
||
|
|
||
|
lgroup0->addRowSpacing(0, group0->fontMetrics().height()/2);
|
||
|
lgroup0->addColSpacing(2, KDialog::spacingHint() * 2);
|
||
|
lgroup0->setColStretch(1, 1);
|
||
|
lgroup0->setColStretch(4, 1);
|
||
|
lgroup0->addWidget(sdllabel, 1, 0);
|
||
|
lgroup0->addWidget(sdlcombo, 1, 1);
|
||
|
lgroup0->addWidget(sdrlabel, 1, 3);
|
||
|
lgroup0->addWidget(sdrcombo, 1, 4);
|
||
|
|
||
|
lgroup1->addRowSpacing(0, group1->fontMetrics().height()/2);
|
||
|
lgroup1->addColSpacing(2, KDialog::spacingHint() * 2);
|
||
|
lgroup1->setColStretch(1, 1);
|
||
|
lgroup1->setColStretch(4, 1);
|
||
|
lgroup1->addWidget(shutdown_label, 1, 0);
|
||
|
lgroup1->addWidget(shutdown_lined, 1, 1);
|
||
|
lgroup1->addWidget(restart_label, 1, 3);
|
||
|
lgroup1->addWidget(restart_lined, 1, 4);
|
||
|
|
||
|
lgroup4->addRowSpacing(0, group4->fontMetrics().height()/2);
|
||
|
lgroup4->addWidget(bm_label, 1, 0);
|
||
|
lgroup4->addWidget(bm_combo, 1, 1);
|
||
|
lgroup4->setColStretch(2, 1);
|
||
|
|
||
|
main->activate();
|
||
|
|
||
|
}
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::makeReadOnly()
|
||
15 years ago
|
{
|
||
|
sdlcombo->setEnabled(false);
|
||
|
sdrcombo->setEnabled(false);
|
||
|
|
||
|
restart_lined->lineEdit()->setReadOnly(true);
|
||
|
restart_lined->button()->setEnabled(false);
|
||
|
shutdown_lined->lineEdit()->setReadOnly(true);
|
||
|
shutdown_lined->button()->setEnabled(false);
|
||
|
|
||
|
bm_combo->setEnabled(false);
|
||
|
}
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::writeSD(TQComboBox *combo)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString what;
|
||
15 years ago
|
switch (combo->currentItem()) {
|
||
|
case SdAll: what = "All"; break;
|
||
|
case SdRoot: what = "Root"; break;
|
||
|
default: what = "None"; break;
|
||
|
}
|
||
|
config->writeEntry( "AllowShutdown", what);
|
||
|
}
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::save()
|
||
15 years ago
|
{
|
||
|
config->setGroup("X-:*-Core");
|
||
|
writeSD(sdlcombo);
|
||
|
|
||
|
config->setGroup("X-*-Core");
|
||
|
writeSD(sdrcombo);
|
||
|
|
||
|
config->setGroup("Shutdown");
|
||
|
config->writeEntry("HaltCmd", shutdown_lined->url(), true);
|
||
|
config->writeEntry("RebootCmd", restart_lined->url(), true);
|
||
|
|
||
|
config->writeEntry("BootManager", bm_combo->currentId());
|
||
|
}
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::readSD(TQComboBox *combo, TQString def)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQString str = config->readEntry("AllowShutdown", def);
|
||
15 years ago
|
SdModes sdMode;
|
||
|
if(str == "All")
|
||
|
sdMode = SdAll;
|
||
|
else if(str == "Root")
|
||
|
sdMode = SdRoot;
|
||
|
else
|
||
|
sdMode = SdNone;
|
||
|
combo->setCurrentItem(sdMode);
|
||
|
}
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::load()
|
||
15 years ago
|
{
|
||
|
config->setGroup("X-:*-Core");
|
||
|
readSD(sdlcombo, "All");
|
||
|
|
||
|
config->setGroup("X-*-Core");
|
||
|
readSD(sdrcombo, "Root");
|
||
|
|
||
|
config->setGroup("Shutdown");
|
||
|
restart_lined->setURL(config->readEntry("RebootCmd", "/sbin/reboot"));
|
||
15 years ago
|
shutdown_lined->setURL(config->readEntry("HaltCmd", "/sbin/poweroff"));
|
||
15 years ago
|
|
||
|
bm_combo->setCurrentId(config->readEntry("BootManager", "None"));
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::defaults()
|
||
15 years ago
|
{
|
||
|
restart_lined->setURL("/sbin/reboot");
|
||
15 years ago
|
shutdown_lined->setURL("/sbin/poweroff");
|
||
15 years ago
|
|
||
|
sdlcombo->setCurrentItem(SdAll);
|
||
|
sdrcombo->setCurrentItem(SdRoot);
|
||
|
|
||
|
bm_combo->setCurrentId("None");
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
void TDMSessionsWidget::changed()
|
||
15 years ago
|
{
|
||
|
emit changed(true);
|
||
|
}
|
||
|
|
||
13 years ago
|
#include "tdm-shut.moc"
|