Source Code (Use browser search to find items of interest.)
Class Index
kcontrol'KAppearanceOptions (./kdebase/kcontrol/konqhtml/htmlopts.h:29)
class KAppearanceOptions : public KCModule
{
Q_OBJECT
public:
KAppearanceOptions(KConfig *config, QString group, QWidget *parent=0, const char *name=0);
virtual void load();
virtual void save();
virtual void defaults();
public slots:
void slotFontSize( int );
void slotStandardFont(const QString& n);
void slotFixedFont(const QString& n);
void slotCharset( const QString& n);
void slotBgColorChanged( const QColor &col );
void slotTextColorChanged( const QColor &col );
void slotLinkColorChanged( const QColor &col );
void slotVLinkColorChanged( const QColor &col );
private slots:
void changed();
private:
void getFontList( QStrList &list, const char *pattern );
void addFont( QStrList &list, const char *xfont );
void updateGUI();
private:
KConfig *m_pConfig;
QString m_groupname;
QRadioButton* m_pSmall;
QRadioButton* m_pMedium;
QRadioButton* m_pLarge;
QComboBox* m_pFixed;
QComboBox* m_pStandard;
QComboBox* m_pCharset;
int fSize;
QString stdName;
QString fixedName;
QString charsetName;
QStrList standardFonts;
QStrList fixedFonts;
QStringList charsets;
KColorButton* m_pBg;
KColorButton* m_pText;
KColorButton* m_pLink;
KColorButton* m_pVLink;
QCheckBox *forceDefaultsbox;
QColor bgColor;
QColor textColor;
QColor linkColor;
QColor vLinkColor;
};
kcontrol'KAppearanceOptions::KAppearanceOptions() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:32)
KAppearanceOptions::KAppearanceOptions(KConfig *config, QString group, QWidget *parent, const char *name)
: KCModule( parent, name ), m_pConfig(config), m_groupname(group)
{
QString wtstr;
QGridLayout *lay = new QGridLayout(this, 1 ,1 , 10, 5);
int r = 0;
int E = 0, M = 1, W = 3; //CT 3 (instead 2) allows smaller color buttons
QButtonGroup *bg = new QButtonGroup( 1, QGroupBox::Vertical,
i18n("Font Size"), this );
lay->addMultiCellWidget(bg, r, r, E, W);
QWhatsThis::add( bg, i18n("This is the relative font size konqueror uses to display web sites.") );
bg->setExclusive( TRUE );
connect(bg, SIGNAL(clicked(int)), this, SLOT(changed()));
m_pSmall = new QRadioButton( i18n("Small"), bg );
m_pMedium = new QRadioButton( i18n("Medium"), bg );
m_pLarge = new QRadioButton( i18n("Large"), bg );
QLabel* label = new QLabel( i18n("Standard Font"), this );
lay->addWidget( label , ++r, E);
m_pStandard = new QComboBox( false, this );
lay->addMultiCellWidget(m_pStandard, r, r, M, W);
wtstr = i18n("This is the font used to display normal text in a web page.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pStandard, wtstr );
getFontList( standardFonts, "-*-*-*-*-*-*-*-*-*-*-p-*-*-*" );
m_pStandard->insertStrList( &standardFonts );
connect( m_pStandard, SIGNAL( activated(const QString&) ),
SLOT( slotStandardFont(const QString&) ) );
connect( m_pStandard, SIGNAL( activated(const QString&) ),
SLOT(changed() ) );
label = new QLabel( i18n( "Fixed Font"), this );
lay->addWidget( label, ++r, E);
m_pFixed = new QComboBox( false, this );
lay->addMultiCellWidget(m_pFixed, r, r, M, W);
wtstr = i18n("This is the font used to display fixed-width (i.e. non-proportional) text.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pFixed, wtstr );
getFontList( fixedFonts, "-*-*-*-*-*-*-*-*-*-*-m-*-*-*" );
m_pFixed->insertStrList( &fixedFonts );
connect( m_pFixed, SIGNAL( activated(const QString&) ),
SLOT( slotFixedFont(const QString&) ) );
connect( m_pFixed, SIGNAL( activated(const QString&) ),
SLOT(changed() ) );
// default charset Lars Knoll 17Nov98 (moved by David)
label = new QLabel( i18n( "Default Charset"), this );
lay->addWidget( label, ++r, E);
m_pCharset = new QComboBox( false, this );
charsets = KGlobal::charsets()->availableCharsetNames();
charsets.prepend(i18n("Use language charset"));
m_pCharset->insertStringList( charsets );
lay->addMultiCellWidget(m_pCharset,r, r, M, W);
wtstr = i18n("Select the default charset to be used. Normally, you'll be fine with 'Use language charset' "
"and should not have to change this.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pCharset, wtstr );
connect( m_pCharset, SIGNAL( activated(const QString& ) ),
SLOT( slotCharset(const QString&) ) );
connect( m_pCharset, SIGNAL( activated(const QString& ) ),
SLOT(changed() ) );
connect( bg, SIGNAL( clicked( int ) ), SLOT( slotFontSize( int ) ) );
label = new QLabel( i18n("Background Color:"), this );
lay->addWidget( label, ++r, E);
m_pBg = new KColorButton( bgColor, this );
lay->addWidget(m_pBg, r, M);
wtstr = i18n("This is the default background color for web pages. Note that if 'Always use my colors' "
"is not selected, this value can be overridden by a differing web page.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pBg, wtstr );
connect( m_pBg, SIGNAL( changed( const QColor & ) ),
SLOT( slotBgColorChanged( const QColor & ) ) );
connect( m_pBg, SIGNAL( changed( const QColor & ) ),
SLOT( changed() ) );
label = new QLabel( i18n("Normal Text Color:"), this );
lay->addWidget( label, ++r, E);
m_pText = new KColorButton( textColor, this );
lay->addWidget(m_pText, r, M);
wtstr = i18n("This is the default text color for web pages. Note that if 'Always use my colors' "
"is not selected, this value can be overridden by a differing web page.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pText, wtstr );
connect( m_pText, SIGNAL( changed( const QColor & ) ),
SLOT( slotTextColorChanged( const QColor & ) ) );
connect( m_pText, SIGNAL( changed( const QColor & ) ),
SLOT( changed() ) );
label = new QLabel( i18n("URL Link Color:"), this );
lay->addWidget( label, ++r, E);
m_pLink = new KColorButton( linkColor, this );
lay->addWidget(m_pLink, r, M);
wtstr = i18n("This is the default color used to display links. Note that if 'Always use my colors' "
"is not selected, this value can be overridden by a differing web page.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pLink, wtstr );
connect( m_pLink, SIGNAL( changed( const QColor & ) ),
SLOT( slotLinkColorChanged( const QColor & ) ) );
connect( m_pLink, SIGNAL( changed( const QColor & ) ),
SLOT( changed() ) );
label = new QLabel( i18n("Followed Link Color:"), this );
lay->addWidget( label, ++r, E);
m_pVLink = new KColorButton( vLinkColor, this );
lay->addWidget(m_pVLink, r, M);
wtstr = i18n("This is the color used to display links that you've already visited, i.e. are cached. "
"Note that if 'Always use my colors' is not selected, this value can be overridden by a differing "
"web page.");
QWhatsThis::add( label, wtstr );
QWhatsThis::add( m_pVLink, wtstr );
connect( m_pVLink, SIGNAL( changed( const QColor & ) ),
SLOT( slotVLinkColorChanged( const QColor & ) ) );
connect( m_pVLink, SIGNAL( changed( const QColor & ) ),
SLOT( changed() ) );
forceDefaultsbox = new QCheckBox(i18n("Always use my colors"), this);
r++; lay->addMultiCellWidget(forceDefaultsbox, r, r, E, W);
QWhatsThis::add( forceDefaultsbox, i18n("If this is selected, konqueror will always "
"use your default colors to display a web page, even if different colors are specified "
"in its HTML description.") );
connect(forceDefaultsbox, SIGNAL(clicked()), this, SLOT(changed()));
r++; lay->setRowStretch(r, 10);
load();
}
kcontrol'KAppearanceOptions::getFontList() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:189)
void KAppearanceOptions::getFontList( QStrList &list, const char *pattern )
{
int num;
char **xFonts = XListFonts( qt_xdisplay(), pattern, 2000, &num );
for ( int i = 0; i < num; i++ )
{
addFont( list, xFonts[i] );
}
XFreeFontNames( xFonts );
}
kcontrol'KAppearanceOptions::addFont() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:203)
void KAppearanceOptions::addFont( QStrList &list, const char *xfont )
{
const char *ptr = strchr( xfont, '-' );
if ( !ptr )
return;
ptr = strchr( ptr + 1, '-' );
if ( !ptr )
return;
QString font = ptr + 1;
int pos;
if ( ( pos = font.find( '-' ) ) > 0 )
{
font.truncate( pos );
if ( font.find( "open look", 0, false ) >= 0 )
return;
QStrListIterator it( list );
for ( ; it.current(); ++it )
if ( it.current() == font )
return;
list.append( font.ascii() );
}
}
kcontrol'KAppearanceOptions::slotFontSize() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:233)
void KAppearanceOptions::slotFontSize( int i )
{
fSize = i+3;
}
kcontrol'KAppearanceOptions::slotStandardFont() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:238)
void KAppearanceOptions::slotStandardFont(const QString& n )
{
stdName = n;
}
kcontrol'KAppearanceOptions::slotFixedFont() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:243)
void KAppearanceOptions::slotFixedFont(const QString& n )
{
fixedName = n;
}
kcontrol'KAppearanceOptions::slotCharset() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:248)
void KAppearanceOptions::slotCharset(const QString& n)
{
charsetName = n;
}
kcontrol'KAppearanceOptions::load() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:253)
void KAppearanceOptions::load()
{
m_pConfig->setGroup(m_groupname);
QString fs = m_pConfig->readEntry( "BaseFontSize" );
if ( !fs.isEmpty() )
{
fSize = fs.toInt();
if ( fSize < 3 )
fSize = 3;
else if ( fSize > 5 )
fSize = 5;
}
else
fSize = 3;
stdName = m_pConfig->readEntry( "StandardFont" );
fixedName = m_pConfig->readEntry( "FixedFont" );
charsetName = m_pConfig->readEntry( "DefaultCharset" );
bgColor = m_pConfig->readColorEntry( "BgColor", &HTML_DEFAULT_BG_COLOR );
textColor = m_pConfig->readColorEntry( "TextColor", &HTML_DEFAULT_TXT_COLOR );
linkColor = m_pConfig->readColorEntry( "LinkColor", &HTML_DEFAULT_LNK_COLOR );
vLinkColor = m_pConfig->readColorEntry( "VLinkColor", &HTML_DEFAULT_VLNK_COLOR);
bool forceDefaults = m_pConfig->readBoolEntry("ForceDefaultColors", false);
m_pBg->setColor( bgColor );
m_pText->setColor( textColor );
m_pLink->setColor( linkColor );
m_pVLink->setColor( vLinkColor );
forceDefaultsbox->setChecked( forceDefaults );
updateGUI();
}
kcontrol'KAppearanceOptions::defaults() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:287)
void KAppearanceOptions::defaults()
{
fSize=4;
stdName = KGlobal::generalFont().family();
fixedName = KGlobal::fixedFont().family();
charsetName = "";
bgColor = HTML_DEFAULT_BG_COLOR;
textColor = HTML_DEFAULT_TXT_COLOR;
linkColor = HTML_DEFAULT_LNK_COLOR;
vLinkColor = HTML_DEFAULT_VLNK_COLOR;
m_pBg->setColor( bgColor );
m_pText->setColor( textColor );
m_pLink->setColor( linkColor );
m_pVLink->setColor( vLinkColor );
forceDefaultsbox->setChecked( false );
updateGUI();
}
kcontrol'KAppearanceOptions::updateGUI() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:308)
void KAppearanceOptions::updateGUI()
{
if ( stdName.isEmpty() )
stdName = KGlobal::generalFont().family();
if ( fixedName.isEmpty() )
fixedName = KGlobal::fixedFont().family();
QStrListIterator sit( standardFonts );
int i;
for ( i = 0; sit.current(); ++sit, i++ )
{
if ( stdName == sit.current() )
m_pStandard->setCurrentItem( i );
}
QStrListIterator fit( fixedFonts );
for ( i = 0; fit.current(); ++fit, i++ )
{
if ( fixedName == fit.current() )
m_pFixed->setCurrentItem( i );
}
for ( QStringList::Iterator cit = charsets.begin(); cit != charsets.end(); ++cit )
{
if ( charsetName == *cit )
m_pCharset->setCurrentItem( i );
}
m_pSmall->setChecked( fSize == 3 );
m_pMedium->setChecked( fSize == 4 );
m_pLarge->setChecked( fSize == 5 );
}
kcontrol'KAppearanceOptions::save() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:341)
void KAppearanceOptions::save()
{
m_pConfig->setGroup(m_groupname);
m_pConfig->writeEntry( "BaseFontSize", fSize );
m_pConfig->writeEntry( "StandardFont", stdName );
m_pConfig->writeEntry( "FixedFont", fixedName );
// If the user chose "Use language charset", write an empty string
if (charsetName == i18n("Use language charset"))
charsetName = "";
m_pConfig->writeEntry( "DefaultCharset", charsetName );
m_pConfig->writeEntry( "BgColor", bgColor );
m_pConfig->writeEntry( "TextColor", textColor );
m_pConfig->writeEntry( "LinkColor", linkColor);
m_pConfig->writeEntry( "VLinkColor", vLinkColor );
m_pConfig->writeEntry("ForceDefaultColors", forceDefaultsbox->isChecked() );
m_pConfig->sync();
}
kcontrol'KAppearanceOptions::changed() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:360)
void KAppearanceOptions::changed()
{
emit KCModule::changed(true);
}
kcontrol'KAppearanceOptions::slotBgColorChanged() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:365)
void KAppearanceOptions::slotBgColorChanged( const QColor &col )
{
if ( bgColor != col )
bgColor = col;
}
kcontrol'KAppearanceOptions::slotTextColorChanged() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:371)
void KAppearanceOptions::slotTextColorChanged( const QColor &col )
{
if ( textColor != col )
textColor = col;
}
kcontrol'KAppearanceOptions::slotLinkColorChanged() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:377)
void KAppearanceOptions::slotLinkColorChanged( const QColor &col )
{
if ( linkColor != col )
linkColor = col;
}
kcontrol'KAppearanceOptions::slotVLinkColorChanged() (./kdebase/kcontrol/konqhtml/htmlopts.cpp:383)
void KAppearanceOptions::slotVLinkColorChanged( const QColor &col )
{
if ( vLinkColor != col )
vLinkColor = col;
}