2 Copyright (C) 1997 Thomas Tanghus (tanghus@earthling.net)
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
22 #include "kbackedcombobox.h"
25 #include <KFontRequester>
28 #include <KConfigGroup>
29 #include <KStandardDirs>
30 #include <KLanguageButton>
34 #include <QPushButton>
35 #include <QFormLayout>
36 #include <QVBoxLayout>
38 extern KConfig
*config
;
40 KDMGeneralWidget::KDMGeneralWidget( QWidget
*parent
)
45 QBoxLayout
*ml
= new QVBoxLayout( this );
46 ml
->setSpacing( KDialog::spacingHint() );
47 ml
->setMargin( KDialog::marginHint() );
49 QGroupBox
* box
= new QGroupBox( i18nc("@title:group 'man locale' ...", "Locale"), this );
51 QFormLayout
*fl
= new QFormLayout( box
);
52 fl
->setSpacing( KDialog::spacingHint() );
53 fl
->setMargin( KDialog::marginHint() );
55 // The Language group box
56 langcombo
= new KLanguageButton( box
);
57 langcombo
->showLanguageCodes( true );
58 langcombo
->loadAllLanguages();
59 connect( langcombo
, SIGNAL(activated( QString
)), SIGNAL(changed()) );
60 fl
->addRow( i18n("&Language:"), langcombo
);
62 "Here you can choose the language used by KDM. This setting does not "
63 "affect a user's personal settings; that will take effect after login.");
64 langcombo
->setWhatsThis( wtstr
);
66 QBoxLayout
*mlml
= new QHBoxLayout();
67 ml
->setSpacing( KDialog::spacingHint() );
71 box
= new QGroupBox( i18nc("@title:group", "Appearance"), this );
72 mlml
->addWidget( box
);
74 fl
= new QFormLayout( box
);
75 fl
->setSpacing( KDialog::spacingHint() );
76 fl
->setMargin( KDialog::marginHint() );
78 useThemeCheck
= new QCheckBox( i18n("&Use themed greeter"), box
);
79 connect( useThemeCheck
, SIGNAL(toggled( bool )), SLOT(slotUseThemeChanged()) );
80 useThemeCheck
->setWhatsThis( i18n(
81 "Enable this if you would like to use a themed Login Manager.") );
82 fl
->addRow( useThemeCheck
);
84 guicombo
= new KBackedComboBox( box
);
85 guicombo
->insertItem( "", i18n("<placeholder>default</placeholder>") );
86 loadGuiStyles( guicombo
);
87 guicombo
->model()->sort( 0 );
89 connect( guicombo
, SIGNAL(activated( int )), SIGNAL(changed()) );
90 fl
->addRow( i18n("GUI s&tyle:"), guicombo
);
92 "You can choose a basic GUI style here that will be used by KDM only.");
93 guicombo
->setWhatsThis( wtstr
);
95 colcombo
= new KBackedComboBox( box
);
96 colcombo
->insertItem( "", i18n("<placeholder>default</placeholder>") );
97 loadColorSchemes( colcombo
);
98 colcombo
->model()->sort( 0 );
99 connect( colcombo
, SIGNAL(activated( int )), SIGNAL(changed()) );
100 fl
->addRow( i18n("Color sche&me:"), colcombo
);
102 "You can choose a basic Color Scheme here that will be used by KDM only.");
103 colcombo
->setWhatsThis( wtstr
);
105 box
= new QGroupBox( i18nc("@title:group", "Fonts"), this );
106 mlml
->addWidget( box
);
107 fl
= new QFormLayout( box
);
108 fl
->setSpacing( KDialog::spacingHint() );
109 fl
->setMargin( KDialog::marginHint() );
111 stdFontChooser
= new KFontRequester( box
);
112 stdFontChooser
->setWhatsThis( i18n(
113 "This changes the font which is used for all the text in the login manager "
114 "except for the greeting and failure messages.") );
115 connect( stdFontChooser
, SIGNAL(fontSelected( const QFont
& )), SIGNAL(changed()) );
116 fl
->addRow( i18nc("... font", "&General:"), stdFontChooser
);
118 failFontChooser
= new KFontRequester( box
);
119 failFontChooser
->setWhatsThis( i18n(
120 "This changes the font which is used for failure messages in the login manager.") );
121 connect( failFontChooser
, SIGNAL(fontSelected( const QFont
& )), SIGNAL(changed()) );
122 fl
->addRow( i18nc("font for ...", "&Failure:"), failFontChooser
);
124 greetingFontChooser
= new KFontRequester( box
);
125 greetingFontChooser
->setWhatsThis( i18n(
126 "This changes the font which is used for the login manager's greeting.") );
127 connect( greetingFontChooser
, SIGNAL(fontSelected( const QFont
& )), SIGNAL(changed()) );
128 fl
->addRow( i18nc("font for ...", "Gree&ting:"), greetingFontChooser
);
130 aacb
= new QCheckBox( i18n("Use anti-aliasing for fonts"), box
);
131 aacb
->setWhatsThis( i18n(
132 "If you check this box and your X-Server has the Xft extension, "
133 "fonts will be antialiased (smoothed) in the login dialog.") );
134 connect( aacb
, SIGNAL(toggled( bool )), SIGNAL(changed()) );
140 void KDMGeneralWidget::makeReadOnly()
142 useThemeCheck
->setEnabled( false );
143 guicombo
->setEnabled( false );
144 colcombo
->setEnabled( false );
145 langcombo
->setEnabled( false );
146 stdFontChooser
->button()->setEnabled( false );
147 failFontChooser
->button()->setEnabled( false );
148 greetingFontChooser
->button()->setEnabled( false );
149 aacb
->setEnabled( false );
152 void KDMGeneralWidget::loadColorSchemes( KBackedComboBox
*combo
)
154 // XXX: Global + local schemes
155 const QStringList list
= KGlobal::dirs()->
156 findAllResources( "data", "color-schemes/*.colors", KStandardDirs::NoDuplicates
);
157 for (QStringList::ConstIterator it
= list
.constBegin(); it
!= list
.constEnd(); ++it
)
159 KConfig
_config( *it
, KConfig::SimpleConfig
);
160 KConfigGroup
config( &_config
, "General" );
163 if (!(str
= config
.readEntry( "Name" )).isEmpty())
165 QString str2
= (*it
).mid( (*it
).lastIndexOf( '/' ) + 1 ); // strip off path
166 str2
.chop( 7 ); // strip off ".colors"
167 combo
->insertItem( str2
, str
);
172 void KDMGeneralWidget::loadGuiStyles( KBackedComboBox
*combo
)
174 // XXX: Global + local schemes
175 const QStringList list
= KGlobal::dirs()->
176 findAllResources( "data", "kstyle/themes/*.themerc", KStandardDirs::NoDuplicates
);
177 for (QStringList::ConstIterator it
= list
.constBegin(); it
!= list
.constEnd(); ++it
)
179 KConfig
config( *it
, KConfig::SimpleConfig
);
181 if (!(config
.hasGroup( "KDE" ) && config
.hasGroup( "Misc" )))
184 if (config
.group( "Desktop Entry" ).readEntry( "Hidden" , false ))
187 QString str2
= config
.group( "KDE" ).readEntry( "WidgetStyle" );
191 combo
->insertItem( str2
, config
.group( "Misc" ).readEntry( "Name" ) );
195 void KDMGeneralWidget::set_def()
197 stdFontChooser
->setFont( QFont( "Sans Serif", 10 ) );
198 failFontChooser
->setFont( QFont( "Sans Serif", 10, QFont::Bold
) );
199 greetingFontChooser
->setFont( QFont( "Serif", 20 ) );
202 void KDMGeneralWidget::save()
204 KConfigGroup configGrp
= config
->group( "X-*-Greeter" );
206 configGrp
.writeEntry( "UseTheme", useThemeCheck
->isChecked() );
207 configGrp
.writeEntry( "GUIStyle", guicombo
->currentId() );
208 configGrp
.writeEntry( "ColorScheme", colcombo
->currentId() );
209 configGrp
.writeEntry( "Language", langcombo
->current() );
210 configGrp
.writeEntry( "StdFont", stdFontChooser
->font() );
211 configGrp
.writeEntry( "GreetFont", greetingFontChooser
->font() );
212 configGrp
.writeEntry( "FailFont", failFontChooser
->font() );
213 configGrp
.writeEntry( "AntiAliasing", aacb
->isChecked() );
217 void KDMGeneralWidget::load()
221 KConfigGroup configGrp
= config
->group( "X-*-Greeter" );
223 useThemeCheck
->setChecked( configGrp
.readEntry( "UseTheme", false ) );
225 // Check the GUI type
226 guicombo
->setCurrentId( configGrp
.readEntry( "GUIStyle" ) );
228 // Check the Color Scheme
229 colcombo
->setCurrentId( configGrp
.readEntry( "ColorScheme" ) );
232 langcombo
->setCurrentItem( configGrp
.readEntry( "Language", "C" ) );
235 QFont font
= stdFontChooser
->font();
236 stdFontChooser
->setFont( configGrp
.readEntry( "StdFont", font
) );
237 font
= failFontChooser
->font();
238 failFontChooser
->setFont( configGrp
.readEntry( "FailFont", font
) );
239 font
= greetingFontChooser
->font();
240 greetingFontChooser
->setFont( configGrp
.readEntry( "GreetFont", font
) );
242 aacb
->setChecked( configGrp
.readEntry( "AntiAliasing", false ) );
246 void KDMGeneralWidget::defaults()
248 useThemeCheck
->setChecked( true );
249 guicombo
->setCurrentId( "" );
250 colcombo
->setCurrentId( "" );
251 langcombo
->setCurrentItem( "en_US" );
253 aacb
->setChecked( false );
256 void KDMGeneralWidget::slotUseThemeChanged()
258 bool en
= useThemeCheck
->isChecked();
259 failFontChooser
->setEnabled( !en
);
260 greetingFontChooser
->setEnabled( !en
);
261 emit
useThemeChanged( en
);
265 #include "kdm-gen.moc"