New page "Behaviour", with

single click on/off
auto select on/off
auto select delay (slider)
cursor and underline checkboxes from the "Colors" tab.

svn path=/trunk/kdebase/kcontrol/konq/; revision=30056
This commit is contained in:
David Faure 1999-10-03 21:11:54 +00:00
parent 5b0955b937
commit 44c13b1b6f
6 changed files with 214 additions and 19 deletions

View file

@ -4,10 +4,10 @@ LDFLAGS = $(all_libraries) $(KDE_RPATH)
LDADD = $(LIB_KDEUI)
bin_PROGRAMS = kcmkonq
METASOURCES = htmlopts.moc khttpoptdlg.moc miscopts.moc
noinst_HEADERS = htmlopts.h khttpoptdlg.h miscopts.h
METASOURCES = htmlopts.moc khttpoptdlg.moc miscopts.moc behaviour.moc
noinst_HEADERS = htmlopts.h khttpoptdlg.h miscopts.h behaviour.h
kcmkonq_SOURCES = main.cpp htmlopts.cpp khttpoptdlg.cpp miscopts.cpp
kcmkonq_SOURCES = main.cpp htmlopts.cpp khttpoptdlg.cpp miscopts.cpp behaviour.cpp
messages:
$(XGETTEXT) -C -ki18n -x $(includedir)/kde.pot $(kcmkonq_SOURCES) && mv messages.po ../../po/kcmkonq.pot

View file

@ -0,0 +1,133 @@
// Behaviour options for konqueror
#include <qcheckbox.h>
#include <qslider.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <kconfig.h>
#include <klocale.h>
#include "behaviour.h"
KBehaviourOptions::KBehaviourOptions( QWidget *parent, const char *name )
: KConfigWidget( parent, name )
{
QLabel * label;
int row = 0;
#define N_COLS 2
#define N_ROWS 7
QGridLayout *lay = new QGridLayout(this,N_ROWS,N_COLS, // rows, cols
20,15); // border, space
lay->setRowStretch(0,1);
lay->setRowStretch(1,1);
lay->setRowStretch(2,1);
lay->setRowStretch(3,0);
lay->setRowStretch(4,1);
lay->setRowStretch(5,1);
lay->setRowStretch(6,1);
lay->setColStretch(0,0);
lay->setColStretch(1,1);
cbSingleClick = new QCheckBox(i18n("&Single click to activate"),
this);
lay->addMultiCellWidget(cbSingleClick,row,row,0,N_COLS,Qt::AlignLeft);
row++;
cbAutoSelect = new QCheckBox(i18n("&Auto select"),
this);
lay->addMultiCellWidget(cbAutoSelect,row,row,0,N_COLS,Qt::AlignLeft);
//----------
row++;
slAutoSelect = new QSlider(0, 2000, 10, 0, QSlider::Horizontal, this);
slAutoSelect->setSteps( 125, 125 );
slAutoSelect->setTickmarks( QSlider::Below );
slAutoSelect->setTickInterval( 250 );
slAutoSelect->setTracking( true );
lay->addMultiCellWidget(slAutoSelect,row,row,1,N_COLS);
lDelay = new QLabel(slAutoSelect, i18n("De&lay:"), this);
lDelay->adjustSize();
lay->addWidget(lDelay,row,0);
row++;
label = new QLabel(i18n("Small"), this);
lay->addWidget(label,row,1);
label = new QLabel(i18n("Large"), this);
lay->addWidget(label,row,2, Qt::AlignRight);
//----------
row++;
cbCursor = new QCheckBox(i18n("&Change cursor over link"),
this);
lay->addMultiCellWidget(cbCursor,row,row,0,N_COLS,Qt::AlignLeft);
row++;
cbUnderline = new QCheckBox(i18n("&Underline links"),
this);
lay->addMultiCellWidget(cbUnderline,row,row,0,N_COLS,Qt::AlignLeft);
connect( cbSingleClick, SIGNAL( clicked() ), this, SLOT( slotClick() ) );
connect( cbAutoSelect, SIGNAL( clicked() ), this, SLOT( slotClick() ) );
loadSettings();
}
void KBehaviourOptions::loadSettings()
{
g_pConfig->setGroup( "Behaviour" );
bool singleClick = g_pConfig->readBoolEntry("SingleClick", true);
int autoSelect = g_pConfig->readNumEntry("AutoSelect", 50);
if ( autoSelect < 0 ) autoSelect = 0;
bool changeCursor = g_pConfig->readBoolEntry("ChangeCursor", false);
bool underlineLinks = g_pConfig->readBoolEntry("UnderlineLinks", true);
cbSingleClick->setChecked( singleClick );
cbAutoSelect->setChecked( autoSelect > 0 );
slAutoSelect->setValue( autoSelect );
cbCursor->setChecked( changeCursor );
cbUnderline->setChecked( underlineLinks );
slotClick();
}
void KBehaviourOptions::defaultSettings()
{
cbSingleClick->setChecked( true );
cbAutoSelect->setChecked( false );
slAutoSelect->setValue( 50 );
cbCursor->setChecked( false );
cbUnderline->setChecked( true );
slotClick();
}
void KBehaviourOptions::saveSettings()
{
g_pConfig->setGroup( "Behaviour" );
g_pConfig->writeEntry( "SingleClick", cbSingleClick->isChecked() );
g_pConfig->writeEntry( "AutoSelect", cbAutoSelect->isChecked()?slAutoSelect->value():-1 );
g_pConfig->writeEntry( "ChangeCursor", cbCursor->isChecked() );
g_pConfig->writeEntry( "UnderlineLinks", cbUnderline->isChecked() );
g_pConfig->sync();
}
void KBehaviourOptions::applySettings()
{
saveSettings();
}
void KBehaviourOptions::slotClick()
{
// Autoselect has a meaning only in single-click mode
cbAutoSelect->setEnabled( cbSingleClick->isChecked() );
// Delay has a meaning only for autoselect
bool bDelay = cbAutoSelect->isChecked() && cbSingleClick->isChecked();
slAutoSelect->setEnabled( bDelay );
lDelay->setEnabled( bDelay );
}
#include "behaviour.moc"

View file

@ -0,0 +1,38 @@
#ifndef __BEHAVIOUR_H__
#define __BEHAVIOUR_H__
#include <kcontrol.h>
class QCheckBox;
class QSlider;
class KConfig;
extern KConfig *g_pConfig;
//-----------------------------------------------------------------------------
class KBehaviourOptions : public KConfigWidget
{
Q_OBJECT
public:
KBehaviourOptions( QWidget *parent = 0L, const char *name = 0L );
virtual void loadSettings();
virtual void saveSettings();
virtual void applySettings();
virtual void defaultSettings();
protected slots:
virtual void slotClick();
private:
QCheckBox *cbSingleClick;
QCheckBox *cbAutoSelect;
QLabel *lDelay;
QSlider *slAutoSelect;
QCheckBox *cbCursor;
QCheckBox *cbUnderline;
};
#endif // __BEHAVIOUR_H__

View file

@ -337,6 +337,7 @@ KColorOptions::KColorOptions( QWidget *parent, const char *name )
connect( m_pVLink, SIGNAL( changed( const QColor & ) ),
SLOT( slotVLinkColorChanged( const QColor & ) ) );
/*
cursorbox = new QCheckBox(i18n("Change cursor over link."),
this);
lay->addMultiCellWidget(cursorbox,8,8,1,3);
@ -344,6 +345,7 @@ KColorOptions::KColorOptions( QWidget *parent, const char *name )
underlinebox = new QCheckBox(i18n("Underline links"),
this);
lay->addMultiCellWidget(underlinebox,9,9,1,3);
*/
forceDefaultsbox = new QCheckBox(i18n("Always use my colors"),
this);
@ -383,16 +385,12 @@ void KColorOptions::loadSettings()
textColor = g_pConfig->readColorEntry( "TextColor", &HTML_DEFAULT_TXT_COLOR );
linkColor = g_pConfig->readColorEntry( "LinkColor", &HTML_DEFAULT_LNK_COLOR );
vLinkColor = g_pConfig->readColorEntry( "VLinkColor", &HTML_DEFAULT_VLNK_COLOR);
bool changeCursor = g_pConfig->readBoolEntry("ChangeCursor", false);
bool underlineLinks = g_pConfig->readBoolEntry("UnderlineLinks", true);
bool forceDefaults = g_pConfig->readBoolEntry("ForceDefaultColors", false);
m_pBg->setColor( bgColor );
m_pText->setColor( textColor );
m_pLink->setColor( linkColor );
m_pVLink->setColor( vLinkColor );
cursorbox->setChecked( changeCursor );
underlinebox->setChecked( underlineLinks );
forceDefaultsbox->setChecked( forceDefaults );
}
@ -407,8 +405,6 @@ void KColorOptions::defaultSettings()
m_pText->setColor( textColor );
m_pLink->setColor( linkColor );
m_pVLink->setColor( vLinkColor );
cursorbox->setChecked( false );
underlinebox->setChecked( false );
forceDefaultsbox->setChecked( false );
}
@ -419,8 +415,6 @@ void KColorOptions::saveSettings()
g_pConfig->writeEntry( "TextColor", textColor );
g_pConfig->writeEntry( "LinkColor", linkColor);
g_pConfig->writeEntry( "VLinkColor", vLinkColor );
g_pConfig->writeEntry( "ChangeCursor", cursorbox->isChecked() );
g_pConfig->writeEntry( "UnderlineLinks", underlinebox->isChecked() );
g_pConfig->writeEntry("ForceDefaultColors", forceDefaultsbox->isChecked() );
g_pConfig->sync();
}

View file

@ -89,8 +89,6 @@ private:
KColorButton* m_pText;
KColorButton* m_pLink;
KColorButton* m_pVLink;
QCheckBox *cursorbox;
QCheckBox *underlinebox;
QCheckBox *forceDefaultsbox;
QColor bgColor;
QColor textColor;

View file

@ -1,14 +1,21 @@
// (c) Torben Weis 1998
// (c) David Faure 1998
#include <config.h>
#include <stdio.h>
#include <kcontrol.h>
#include <klocale.h>
#include <kstddirs.h>
#include <kmessagebox.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "htmlopts.h"
#include "khttpoptdlg.h"
#include "miscopts.h"
#include "behaviour.h"
KConfig *g_pConfig;
@ -26,6 +33,7 @@ private:
KColorOptions *m_pColorOptions;
KHTTPOptions *m_pHTTPOptions;
KMiscOptions *m_pMiscOptions;
KBehaviourOptions *m_pBehaviourOptions;
};
KonqControlApplication::KonqControlApplication( int &argc, char **argv )
@ -39,29 +47,35 @@ KonqControlApplication::KonqControlApplication( int &argc, char **argv )
if ( !runGUI() )
return;
if ( !pages || pages->contains( "behaviour" ) )
addPage( m_pBehaviourOptions = new KBehaviourOptions( dialog, "behaviour" ), i18n( "&Behaviour" ), "konq-1.html" );
if ( !pages || pages->contains( "font" ) )
addPage( m_pFontOptions = new KFontOptions( dialog, "font" ), i18n( "&Font" ), "konq-1.html" );
addPage( m_pFontOptions = new KFontOptions( dialog, "font" ), i18n( "&Font" ), "konq-2.html" );
if ( !pages || pages->contains( "color" ) )
addPage( m_pColorOptions = new KColorOptions( dialog, "color" ), i18n( "&Color" ), "konq-2.html" );
addPage( m_pColorOptions = new KColorOptions( dialog, "color" ), i18n( "&Color" ), "konq-3.html" );
if ( !pages || pages->contains( "http" ) )
addPage( m_pHTTPOptions = new KHTTPOptions( dialog, "http" ), i18n( "&HTTP" ), "konq-3.html" );
addPage( m_pHTTPOptions = new KHTTPOptions( dialog, "http" ), i18n( "&HTTP" ), "konq-4.html" );
if ( !pages || pages->contains( "misc" ) )
addPage( m_pMiscOptions = new KMiscOptions( dialog, "misc" ), i18n( "&Other" ), "konq-4.html" );
addPage( m_pMiscOptions = new KMiscOptions( dialog, "misc" ), i18n( "&Other" ), "konq-5.html" );
if ( m_pFontOptions || m_pColorOptions || m_pHTTPOptions || m_pMiscOptions )
if ( m_pFontOptions || m_pColorOptions || m_pHTTPOptions || m_pMiscOptions || m_pBehaviourOptions )
dialog->show();
else
{
fprintf(stderr, i18n("usage: %s [-init | {font,color,misc}]\n").ascii(), argv[0] );;
fprintf(stderr, i18n("usage: %s [-init | {behavour,font,color,http,misc}]\n").ascii(), argv[0] );;
justInit = true;
}
}
void KonqControlApplication::init()
{
if ( m_pBehaviourOptions )
m_pBehaviourOptions->loadSettings();
if ( m_pFontOptions )
m_pFontOptions->loadSettings();
@ -77,6 +91,9 @@ void KonqControlApplication::init()
void KonqControlApplication::defaultValues()
{
if ( m_pBehaviourOptions )
m_pBehaviourOptions->defaultSettings();
if ( m_pFontOptions )
m_pFontOptions->defaultSettings();
@ -92,6 +109,9 @@ void KonqControlApplication::defaultValues()
void KonqControlApplication::apply()
{
if ( m_pBehaviourOptions )
m_pBehaviourOptions->applySettings();
if ( m_pFontOptions )
m_pFontOptions->applySettings();
@ -103,6 +123,18 @@ void KonqControlApplication::apply()
if ( m_pMiscOptions )
m_pMiscOptions->applySettings();
QString exeloc = locate("exe","kfmclient");
if ( exeloc.isEmpty() )
KMessageBox::error( 0L, i18n( "Can't find the kfmclient program - can't apply configuration dynamically" ), i18n( "Error" ) );
else
if ( fork() == 0 )
{
// execute 'kfmclient configure'
execl(exeloc, "kfmclient", "configure", 0L);
warning("Error launching 'kfmclient configure' !");
exit(1);
}
}
int main(int argc, char **argv )