add more spacing
[personal-kdebase.git] / workspace / kcontrol / kdm / background.cpp
blob5591942155d26defbfe6733e50532241da9474be
1 /*
2 * This file is part of the KDE project, module kcmdisplay.
3 * Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
5 * Modified 2000.07.14 by Brad Hughes <bhughes@trolltech.com>
6 * Improve layout and consistency with KDesktop's background selection
8 * Based on old backgnd.cpp:
10 * Copyright (c) Martin R. Jones 1996
11 * Converted to a kcc module by Matthias Hoelzer 1997
12 * Gradient backgrounds by Mark Donohoe 1997
13 * Pattern backgrounds by Stephan Kulow 1998
14 * Randomizing & dnd & new display modes by Matej Koss 1998
16 * You can Freely distribute this program under the GNU General Public
17 * License. See the file "COPYING" for the exact licensing terms.
20 #include "background.h"
22 #include <config-workspace.h>
24 #include "../background/bgdialog.h"
26 #include <KLocale>
27 #include <KConfig>
28 #include <KConfigGroup>
30 #include <QCheckBox>
31 #include <QVBoxLayout>
33 extern KConfig *config;
35 KBackground::KBackground( QWidget *parent )
36 : QWidget( parent )
39 // Enabling checkbox
40 m_pCBEnable = new QCheckBox( i18n("E&nable background"), this );
41 m_pCBEnable->setWhatsThis( i18n(
42 "If this is checked, KDM will use the settings below for the background."
43 " If it is disabled, you have to look after the background yourself."
44 " This is done by running some program (possibly xsetroot) in the script"
45 " specified in the Setup= option in kdmrc (usually Xsetup).") );
46 m_simpleConf = KSharedConfig::openConfig(
47 config->group( "X-*-Greeter" ).readEntry(
48 "BackgroundCfg", KDE_CONFDIR "/kdm/backgroundrc" ) );
49 m_background = new BGDialog( this, m_simpleConf );
51 connect( m_background, SIGNAL(changed( bool )), SIGNAL(changed()) );
53 // Top layout
54 QVBoxLayout *top = new QVBoxLayout( this );
55 top->setMargin( KDialog::marginHint() );
56 top->setSpacing( KDialog::spacingHint() );
57 top->addWidget( m_pCBEnable );
58 top->addWidget( m_background );
59 top->addStretch();
60 connect( m_pCBEnable, SIGNAL(toggled( bool )), SLOT(slotEnableChanged()) );
63 KBackground::~KBackground()
67 void KBackground::slotEnableChanged()
69 bool en = m_pCBEnable->isChecked();
70 m_background->setEnabled( en );
71 emit changed();
74 void KBackground::makeReadOnly()
76 m_pCBEnable->setEnabled( false );
77 m_background->makeReadOnly();
80 void KBackground::load()
82 m_pCBEnable->setChecked( config->group( "X-*-Greeter" ).readEntry( "UseBackground", true ) );
83 m_background->load();
84 slotEnableChanged();
88 void KBackground::save()
90 config->group( "X-*-Greeter" ).writeEntry( "UseBackground", m_pCBEnable->isChecked() );
91 m_background->save();
95 void KBackground::defaults()
97 m_pCBEnable->setChecked( true );
98 slotEnableChanged();
99 m_background->defaults();
102 #include "background.moc"