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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
/* This file is part of the KDE project
Copyright (C) 1999 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library 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 <assert.h>
#include <tqcheckbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqwhatsthis.h>
#include <dcopclient.h>
#include <tdeapplication.h>
#include <kcolorbutton.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <tdefontcombo.h>
#include <tdefontdialog.h>
#include <tdelocale.h>
#include <konq_defaults.h> // include default values directly from konqueror
#include "fontopts.h"
//-----------------------------------------------------------------------------
KonqFontOptions::KonqFontOptions(TDEConfig *config, TQString group, bool desktop, TQWidget *parent, const char* /*name*/)
: TDECModule( parent, "kcmkonq" ), g_pConfig(config), groupname(group), m_bDesktop(desktop)
{
TQLabel *label;
TQString wtstr;
int row = 0;
int LASTLINE = m_bDesktop ? 8 : 10; // this can be different :)
#define LASTCOLUMN 2
TQGridLayout *lay = new TQGridLayout(this,LASTLINE+1,LASTCOLUMN+1, 0,
KDialog::spacingHint());
lay->setRowStretch(LASTLINE,10);
lay->setColStretch(LASTCOLUMN,10);
row++;
m_pStandard = new TDEFontCombo( this );
label = new TQLabel( m_pStandard, i18n("&Standard font:"), this );
lay->addWidget(label,row,0);
lay->addMultiCellWidget(m_pStandard,row,row,1,1);
wtstr = i18n("This is the font used to display text in Konqueror windows.");
TQWhatsThis::add( label, wtstr );
TQWhatsThis::add( m_pStandard, wtstr );
row++;
connect( m_pStandard, TQT_SIGNAL( activated(const TQString&) ),
TQT_SLOT( slotStandardFont(const TQString&) ) );
connect( m_pStandard, TQT_SIGNAL( activated(const TQString&) ),
TQT_SLOT(changed() ) );
connect( m_pStandard, TQT_SIGNAL( textChanged(const TQString&) ),
TQT_SLOT( slotStandardFont(const TQString&) ) );
connect( m_pStandard, TQT_SIGNAL( textChanged(const TQString&) ),
TQT_SLOT(changed() ) );
m_pSize = new TQSpinBox( 4,18,1,this );
label = new TQLabel( m_pSize, i18n("Font si&ze:"), this );
lay->addWidget(label,row,0);
lay->addMultiCellWidget(m_pSize,row,row,1,1);
connect( m_pSize, TQT_SIGNAL( valueChanged(int) ),
this, TQT_SLOT( slotFontSize(int) ) );
row+=2;
wtstr = i18n("This is the font size used to display text in Konqueror windows.");
TQWhatsThis::add( label, wtstr );
TQWhatsThis::add( m_pSize, wtstr );
int hAlign = TQApplication::reverseLayout() ? AlignRight : AlignLeft;
//
#define COLOR_BUTTON_COL 1
m_pNormalText = new KColorButton( normalTextColor, this );
label = new TQLabel( m_pNormalText, i18n("Normal te&xt color:"), this );
lay->addWidget(label,row,0);
lay->addWidget(m_pNormalText,row,COLOR_BUTTON_COL,(TQ_Alignment)hAlign);
wtstr = i18n("This is the color used to display text in Konqueror windows.");
TQWhatsThis::add( label, wtstr );
TQWhatsThis::add( m_pNormalText, wtstr );
connect( m_pNormalText, TQT_SIGNAL( changed( const TQColor & ) ),
TQT_SLOT( slotNormalTextColorChanged( const TQColor & ) ) );
/*
row++;
label = new TQLabel( i18n("Highlighted text color:"), this );
lay->addWidget(label,row,0);
m_pHighlightedText = new KColorButton( highlightedTextColor, this );
lay->addWidget(m_pHighlightedText,row,COLOR_BUTTON_COL,hAlign);
wtstr = i18n("This is the color used to display selected text in Konqueror windows.");
TQWhatsThis::add( label, wtstr );
TQWhatsThis::add( m_pHighlightedText, wtstr );
connect( m_pHighlightedText, TQT_SIGNAL( changed( const TQColor & ) ),
TQT_SLOT( slotHighlightedTextColorChanged( const TQColor & ) ) );
*/
row++;
if ( m_bDesktop )
{
m_cbTextBackground = new TQCheckBox( i18n("&Text background color:"), this );
lay->addWidget(m_cbTextBackground,row,0);
connect( m_cbTextBackground, TQT_SIGNAL( clicked() ),
TQT_SLOT( slotTextBackgroundClicked() ) );
m_pTextBackground = new KColorButton( textBackgroundColor, this );
lay->addWidget(m_pTextBackground,row,COLOR_BUTTON_COL,(TQ_Alignment)hAlign);
wtstr = i18n("This is the color used behind the text for the icons on the desktop.");
TQWhatsThis::add( label, wtstr );
TQWhatsThis::add( m_pTextBackground, wtstr );
connect( m_pTextBackground, TQT_SIGNAL( changed( const TQColor & ) ),
TQT_SLOT( slotTextBackgroundColorChanged( const TQColor & ) ) );
row++;
}
else
{
m_pNbLines = new TQSpinBox( 1, 10, 1, this );
TQLabel* label = new TQLabel( m_pNbLines, i18n("H&eight for icon text:"), this );
lay->addWidget( label, row, 0 );
lay->addWidget( m_pNbLines, row, 1 );
connect( m_pNbLines, TQT_SIGNAL( valueChanged(int) ),
this, TQT_SLOT( changed() ) );
connect( m_pNbLines, TQT_SIGNAL( valueChanged(int) ),
TQT_SLOT( slotPNbLinesChanged(int)) );
TQString thwt = i18n("This is the maximum number of lines that can be"
" used to draw icon text. Long file names are"
" truncated at the end of the last line.");
TQWhatsThis::add( label, thwt );
TQWhatsThis::add( m_pNbLines, thwt );
row++;
// width for the items in multicolumn icon view
m_pNbWidth = new TQSpinBox( 1, 100000, 1, this );
label = new TQLabel( m_pNbWidth, i18n("&Width for icon text:"), this );
lay->addWidget( label, row, 0 );
lay->addWidget( m_pNbWidth, row, 1 );
connect( m_pNbWidth, TQT_SIGNAL( valueChanged(int) ),
this, TQT_SLOT( changed() ) );
connect( m_pNbWidth, TQT_SIGNAL( valueChanged(int) ),
TQT_SLOT( slotPNbWidthChanged(int)) );
thwt = i18n( "This is the maximum width for the icon text when konqueror "
"is used in multi column view mode." );
TQWhatsThis::add( label, thwt );
TQWhatsThis::add( m_pNbWidth, thwt );
row++;
}
cbUnderline = new TQCheckBox(i18n("&Underline filenames"), this);
lay->addMultiCellWidget(cbUnderline,row,row,0,LASTCOLUMN,(TQ_Alignment)hAlign);
connect(cbUnderline, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed()));
TQWhatsThis::add( cbUnderline, i18n("Checking this option will result in filenames"
" being underlined, so that they look like links on a web page. Note:"
" to complete the analogy, make sure that single click activation is"
" enabled in the mouse control module.") );
if ( !m_bDesktop )
{
row++;
m_pSizeInBytes = new TQCheckBox(i18n("Display file sizes in b&ytes"), this);
lay->addMultiCellWidget( m_pSizeInBytes,row,row,0,LASTCOLUMN,(TQ_Alignment)hAlign );
connect( m_pSizeInBytes, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed()) );
TQWhatsThis::add( m_pSizeInBytes, i18n("Checking this option will result in file sizes"
" being displayed in bytes. Otherwise file sizes are"
" being displayed in kilobytes or megabytes if appropriate.") );
}
row++;
assert( row == LASTLINE-1 );
// The last line is empty and grows if resized
load();
}
void KonqFontOptions::slotFontSize(int i)
{
m_fSize = i;
changed();
}
void KonqFontOptions::slotStandardFont(const TQString& n )
{
m_stdName = n;
}
void KonqFontOptions::slotPNbLinesChanged(int value)
{
m_pNbLines->setSuffix( i18n( " line", " lines", value ) );
}
void KonqFontOptions::slotPNbWidthChanged(int value)
{
m_pNbWidth->setSuffix( i18n( " pixel", " pixels", value ) );
}
void KonqFontOptions::load()
{
load( false );
}
void KonqFontOptions::load( bool useDefaults )
{
g_pConfig->setReadDefaults( useDefaults );
g_pConfig->setGroup(groupname);
TQFont stdFont = g_pConfig->readFontEntry( "StandardFont" );
m_stdName = stdFont.family();
m_fSize = stdFont.pointSize();
// we have to use TQFontInfo, in case the font was specified with a pixel size
if ( m_fSize == -1 )
m_fSize = TQFontInfo(stdFont).pointSize();
normalTextColor = TDEGlobalSettings::textColor();
normalTextColor = g_pConfig->readColorEntry( "NormalTextColor", &normalTextColor );
m_pNormalText->setColor( normalTextColor );
/* highlightedTextColor = TDEGlobalSettings::highlightedTextColor();
highlightedTextColor = g_pConfig->readColorEntry( "HighlightedTextColor", &highlightedTextColor );
m_pHighlightedText->setColor( highlightedTextColor );
*/
if ( m_bDesktop )
{
textBackgroundColor = g_pConfig->readColorEntry( "ItemTextBackground" );
m_cbTextBackground->setChecked(textBackgroundColor.isValid());
m_pTextBackground->setEnabled(textBackgroundColor.isValid());
m_pTextBackground->setColor( textBackgroundColor );
// Don't keep an invalid color around, otherwise checking the checkbox still gives invalid.
if ( !textBackgroundColor.isValid() )
textBackgroundColor = Qt::black;
}
else
{
int n = g_pConfig->readNumEntry( "TextHeight", 0 );
if ( n == 0 ) {
if ( g_pConfig->readBoolEntry( "WordWrapText", true ) )
n = DEFAULT_TEXTHEIGHT;
else
n = 1;
}
m_pNbLines->setValue( n );
n = g_pConfig->readNumEntry( "TextWidth", DEFAULT_TEXTWIDTH_MULTICOLUMN );
m_pNbWidth->setValue( n );
m_pSizeInBytes->setChecked( g_pConfig->readBoolEntry( "DisplayFileSizeInBytes", DEFAULT_FILESIZEINBYTES ) );
}
cbUnderline->setChecked( g_pConfig->readBoolEntry("UnderlineLinks", DEFAULT_UNDERLINELINKS ) );
TDEConfig cfg("kdeglobals");
cfg.setGroup("DesktopIcons");
updateGUI();
emit changed( useDefaults );
}
void KonqFontOptions::defaults()
{
load( true );
}
void KonqFontOptions::updateGUI()
{
if ( m_stdName.isEmpty() )
m_stdName = TDEGlobalSettings::generalFont().family();
m_pStandard->setCurrentFont( m_stdName );
m_pSize->setValue( m_fSize );
}
void KonqFontOptions::save()
{
g_pConfig->setGroup(groupname);
TQFont stdFont( m_stdName, m_fSize );
g_pConfig->writeEntry( "StandardFont", stdFont );
g_pConfig->writeEntry( "NormalTextColor", normalTextColor );
//g_pConfig->writeEntry( "HighlightedTextColor", highlightedTextColor );
if ( m_bDesktop )
g_pConfig->writeEntry( "ItemTextBackground", m_cbTextBackground->isChecked() ? textBackgroundColor : TQColor());
else
{
g_pConfig->writeEntry( "TextHeight", m_pNbLines->value() );
g_pConfig->writeEntry( "TextWidth", m_pNbWidth->value() );
g_pConfig->writeEntry( "DisplayFileSizeInBytes", m_pSizeInBytes->isChecked() );
}
g_pConfig->writeEntry( "UnderlineLinks", cbUnderline->isChecked() );
g_pConfig->sync();
TDEConfig cfg("kdeglobals");
cfg.setGroup("DesktopIcons");
// Send signal to konqueror
// Warning. In case something is added/changed here, keep kfmclient in sync
TQByteArray data;
if ( !kapp->dcopClient()->isAttached() )
kapp->dcopClient()->attach();
kapp->dcopClient()->send( "konqueror*", "KonquerorIface", "reparseConfiguration()", data );
// Tell kdesktop about the new config file
int konq_screen_number = TDEApplication::desktop()->primaryScreen();
TQCString appname;
if (konq_screen_number == 0)
appname = "kdesktop";
else
appname.sprintf("kdesktop-screen-%d", konq_screen_number);
kapp->dcopClient()->send( appname, "KDesktopIface", "configure()", data );
}
void KonqFontOptions::slotTextBackgroundClicked()
{
m_pTextBackground->setEnabled( m_cbTextBackground->isChecked() );
changed();
}
void KonqFontOptions::slotNormalTextColorChanged( const TQColor &col )
{
if ( normalTextColor != col )
{
normalTextColor = col;
changed();
}
}
/*
void KonqFontOptions::slotHighlightedTextColorChanged( const TQColor &col )
{
if ( highlightedTextColor != col )
{
highlightedTextColor = col;
changed();
}
}
*/
void KonqFontOptions::slotTextBackgroundColorChanged( const TQColor &col )
{
if ( textBackgroundColor != col )
{
textBackgroundColor = col;
changed();
}
}
TQString KonqFontOptions::quickHelp() const
{
return i18n("<h1>Appearance</h1> You can configure how Konqueror looks as a file manager here.");
}
#include "fontopts.moc"
|