5 Copyright (C) 1997, 1998 Steffen Hansen <hansen@kde.org>
6 Copyright (C) 2000-2003 Oswald Buddenhagen <ossi@kde.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include "kdmconfig.h"
26 #include "kdm_greet.h"
29 #include <kconfiggroup.h>
36 #include <sys/utsname.h>
38 #define WANT_GREET_DEFS
51 return qString( getCfgStr( id
) );
55 getCfgQStrList( int id
)
57 return qStringList( getCfgStrArr( id
, 0 ) );
60 // Based on kconfiggroupgui.cpp
62 str2Font( const QString
&aValue
)
66 QFont
*aRetFont
= new QFont();
68 QStringList sl
= aValue
.split( QString::fromLatin1(","), QString::SkipEmptyParts
);
70 if (sl
.count() == 1) {
72 aRetFont
->setRawMode( true );
73 aRetFont
->setRawName( aValue
);
74 } else if (sl
.count() == 10) {
76 aRetFont
->fromString( aValue
);
77 } else if (sl
.count() == 6) {
78 /* backward compatible kde2 font spec */
79 aRetFont
->setFamily( sl
[0] );
80 aRetFont
->setPointSize( sl
[1].toInt() );
81 aRetFont
->setWeight( sl
[4].toUInt() );
83 aRetFont
->setStyleHint( (QFont::StyleHint
)sl
[2].toUInt() );
85 nFontBits
= sl
[5].toUInt();
86 aRetFont
->setItalic( (nFontBits
& 0x01) != 0 );
87 aRetFont
->setUnderline( (nFontBits
& 0x02) != 0 );
88 aRetFont
->setStrikeOut( (nFontBits
& 0x04) != 0 );
89 aRetFont
->setFixedPitch( (nFontBits
& 0x08) != 0 );
90 aRetFont
->setRawMode( (nFontBits
& 0x20) != 0 );
92 aRetFont
->setStyleStrategy( (QFont::StyleStrategy
)
94 (_antiAliasing
? QFont::PreferAntialias
: QFont::NoAntialias
)) );
100 void initConfig( void )
104 _isLocal
= getCfgInt( C_isLocal
);
105 _isReserve
= _isLocal
&& getCfgInt( C_isReserve
);
106 _hasConsole
= _hasConsole
&& _isLocal
&& getCfgInt( C_hasConsole
);
107 _authorized
= getCfgInt( C_isAuthorized
);
109 _stsFile
= _dataDir
+ "/kdmsts";
112 char hostname
[256], *ptr
;
114 if (!gethostname( hostname
, sizeof(hostname
) ))
115 hostname
[sizeof(hostname
)-1] = '\0';
116 struct utsname tuname
;
118 QString gst
= _greetString
;
119 _greetString
.clear();
120 int i
, j
, l
= gst
.length();
121 for (i
= 0; i
< l
; i
++) {
123 switch (gst
[++i
].cell()) {
124 case '%': _greetString
+= gst
[i
]; continue;
125 case 'd': ptr
= dname
; break;
126 case 'h': ptr
= hostname
; break;
127 case 'n': ptr
= tuname
.nodename
;
128 for (j
= 0; ptr
[j
]; j
++)
134 case 's': ptr
= tuname
.sysname
; break;
135 case 'r': ptr
= tuname
.release
; break;
136 case 'm': ptr
= tuname
.machine
; break;
137 default: _greetString
+= i18nc("@item:intext substitution for "
138 "an undefined %X placeholder wrongly "
139 "given in the config file 'kdmrc', "
140 "telling the user to fix it",
141 "[fix kdmrc]"); continue;
143 _greetString
+= QString::fromLocal8Bit( ptr
);
145 _greetString
+= gst
[i
];
149 void initQAppConfig( void )
153 KConfigGroup
cfg( KGlobal::config(), "General" );
154 cfg
.writeEntry( "nopaletteChange", true );
155 cfg
.writeEntry( "font", *_normalFont
);
156 if (!_GUIStyle
.isEmpty())
157 cfg
.writeEntry( "widgetStyle", _GUIStyle
);