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
|
/*
* This file is part of the TDE Help Center
*
* Copyright (C) 2003 Frerich Raabe <raabe@kde.org>
*
* 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 General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "fontdialog.h"
#include <tdeapplication.h>
#include <kcharsets.h>
#include <kcombobox.h>
#include <tdeconfig.h>
#include <tdefontcombo.h>
#include <tdehtmldefaults.h>
#include <tdelocale.h>
#include <knuminput.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqspinbox.h>
using namespace KHC;
FontDialog::FontDialog( TQWidget *parent, const char *name )
: KDialogBase( parent, name, true, i18n( "Font Configuration" ),
Ok | Cancel )
{
makeVBoxMainWidget();
setupFontSizesBox();
setupFontTypesBox();
setupFontEncodingBox();
load();
}
void FontDialog::slotOk()
{
save();
accept();
}
void FontDialog::setupFontSizesBox()
{
TQGroupBox *gb = new TQGroupBox( i18n( "Sizes" ), mainWidget() );
TQGridLayout *layout = new TQGridLayout( gb );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() * 2 );
TQLabel *lMinFontSize = new TQLabel( i18n( "M&inimum font size:" ), gb );
layout->addWidget( lMinFontSize, 0, 0 );
m_minFontSize = new KIntNumInput( gb );
layout->addWidget( m_minFontSize, 0, 1 );
m_minFontSize->setRange( 1, 20 );
lMinFontSize->setBuddy( m_minFontSize );
TQLabel *lMedFontSize = new TQLabel( i18n( "M&edium font size:" ), gb );
layout->addWidget( lMedFontSize, 1, 0 );
m_medFontSize = new KIntNumInput( gb );
layout->addWidget( m_medFontSize, 1, 1 );
m_medFontSize->setRange( 4, 28 );
lMedFontSize->setBuddy( m_medFontSize );
}
void FontDialog::setupFontTypesBox()
{
TQGroupBox *gb = new TQGroupBox( i18n( "Fonts" ), mainWidget() );
TQGridLayout *layout = new TQGridLayout( gb );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() * 2 );
TQLabel *lStandardFont = new TQLabel( i18n( "S&tandard font:" ), gb );
layout->addWidget( lStandardFont, 0, 0 );
m_standardFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_standardFontCombo, 0, 1 );
lStandardFont->setBuddy( m_standardFontCombo );
TQLabel *lFixedFont = new TQLabel( i18n( "F&ixed font:" ), gb );
layout->addWidget( lFixedFont, 1, 0 );
m_fixedFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_fixedFontCombo, 1, 1 );
lFixedFont->setBuddy( m_fixedFontCombo );
TQLabel *lSerifFont = new TQLabel( i18n( "S&erif font:" ), gb );
layout->addWidget( lSerifFont, 2, 0 );
m_serifFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_serifFontCombo, 2, 1 );
lSerifFont->setBuddy( m_serifFontCombo );
TQLabel *lSansSerifFont = new TQLabel( i18n( "S&ans serif font:" ), gb );
layout->addWidget( lSansSerifFont, 3, 0 );
m_sansSerifFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_sansSerifFontCombo, 3, 1 );
lSansSerifFont->setBuddy( m_sansSerifFontCombo );
TQLabel *lItalicFont = new TQLabel( i18n( "&Italic font:" ), gb );
layout->addWidget( lItalicFont, 4, 0 );
m_italicFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_italicFontCombo, 4, 1 );
lItalicFont->setBuddy( m_italicFontCombo );
TQLabel *lFantasyFont = new TQLabel( i18n( "&Fantasy font:" ), gb );
layout->addWidget( lFantasyFont, 5, 0 );
m_fantasyFontCombo = new TDEFontCombo( gb );
layout->addWidget( m_fantasyFontCombo, 5, 1 );
lFantasyFont->setBuddy( m_fantasyFontCombo );
}
void FontDialog::setupFontEncodingBox()
{
TQGroupBox *gb = new TQGroupBox( i18n( "Encoding" ), mainWidget() );
TQGridLayout *layout = new TQGridLayout( gb );
layout->setSpacing( KDialog::spacingHint() );
layout->setMargin( KDialog::marginHint() * 2 );
TQLabel *lDefaultEncoding = new TQLabel( i18n( "&Default encoding:" ), gb );
layout->addWidget( lDefaultEncoding, 0, 0 );
m_defaultEncoding = new KComboBox( false, gb );
layout->addWidget( m_defaultEncoding, 0, 1 );
TQStringList encodings = TDEGlobal::charsets()->availableEncodingNames();
encodings.prepend( i18n( "Use Language Encoding" ) );
m_defaultEncoding->insertStringList( encodings );
lDefaultEncoding->setBuddy( m_defaultEncoding );
TQLabel *lFontSizeAdjustement = new TQLabel( i18n( "&Font size adjustment:" ), gb );
layout->addWidget( lFontSizeAdjustement, 1, 0 );
m_fontSizeAdjustement = new TQSpinBox( -5, 5, 1, gb );
layout->addWidget( m_fontSizeAdjustement, 1, 1 );
lFontSizeAdjustement->setBuddy( m_fontSizeAdjustement );
}
void FontDialog::load()
{
TDEConfig *cfg = kapp->config();
{
TDEConfigGroupSaver groupSaver( cfg, "HTML Settings" );
m_minFontSize->setValue( cfg->readNumEntry( "MinimumFontSize", HTML_DEFAULT_MIN_FONT_SIZE ) );
m_medFontSize->setValue( cfg->readNumEntry( "MediumFontSize", 10 ) );
TQStringList fonts = cfg->readListEntry( "Fonts" );
if ( fonts.isEmpty() )
fonts << TDEGlobalSettings::generalFont().family()
<< TDEGlobalSettings::fixedFont().family()
<< HTML_DEFAULT_VIEW_SERIF_FONT
<< HTML_DEFAULT_VIEW_SANSSERIF_FONT
<< HTML_DEFAULT_VIEW_CURSIVE_FONT
<< HTML_DEFAULT_VIEW_FANTASY_FONT;
m_standardFontCombo->setCurrentFont( fonts[ 0 ] );
m_fixedFontCombo->setCurrentFont( fonts[ 1 ] );
m_serifFontCombo->setCurrentFont( fonts[ 2 ] );
m_sansSerifFontCombo->setCurrentFont( fonts[ 3 ] );
m_italicFontCombo->setCurrentFont( fonts[ 4 ] );
m_fantasyFontCombo->setCurrentFont( fonts[ 5 ] );
m_defaultEncoding->setCurrentItem( cfg->readEntry( "DefaultEncoding" ) );
m_fontSizeAdjustement->setValue( fonts[ 6 ].toInt() );
}
}
void FontDialog::save()
{
TDEConfig *cfg = kapp->config();
{
TDEConfigGroupSaver groupSaver( cfg, "General" );
cfg->writeEntry( "UseKonqSettings", false );
}
{
TDEConfigGroupSaver groupSaver( cfg, "HTML Settings" );
cfg->writeEntry( "MinimumFontSize", m_minFontSize->value() );
cfg->writeEntry( "MediumFontSize", m_medFontSize->value() );
TQStringList fonts;
fonts << m_standardFontCombo->currentText()
<< m_fixedFontCombo->currentText()
<< m_serifFontCombo->currentText()
<< m_sansSerifFontCombo->currentText()
<< m_italicFontCombo->currentText()
<< m_fantasyFontCombo->currentText()
<< TQString::number( m_fontSizeAdjustement->value() );
cfg->writeEntry( "Fonts", fonts );
if ( m_defaultEncoding->currentText() == i18n( "Use Language Encoding" ) )
cfg->writeEntry( "DefaultEncoding", TQString::null );
else
cfg->writeEntry( "DefaultEncoding", m_defaultEncoding->currentText() );
}
cfg->sync();
}
#include "fontdialog.moc"
|