summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Side-by-side diff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/colorlistbox.cpp7
-rw-r--r--kaddressbook/views/colorlistbox.h1
-rw-r--r--kaddressbook/views/configurecardviewdialog.cpp4
-rw-r--r--kaddressbook/views/configuretableviewdialog.cpp6
4 files changed, 16 insertions, 2 deletions
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp
index c243fa0..7386207 100644
--- a/kaddressbook/views/colorlistbox.cpp
+++ b/kaddressbook/views/colorlistbox.cpp
@@ -1,125 +1,130 @@
/*
* kmail: KDE mail client
* This file: Copyright (C) 2000 Espen Sand, espen@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <qpainter.h>
#include <kcolordialog.h>
#ifndef KAB_EMBEDDED
#include <kcolordrag.h>
#endif //KAB_EMBEDDED
#include "colorlistbox.h"
ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f )
:KListBox( parent, name, f ), mCurrentOnDragEnter(-1)
{
connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) );
+ connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) );
setAcceptDrops( true);
}
void ColorListBox::setEnabled( bool state )
{
if( state == isEnabled() )
{
return;
}
QListBox::setEnabled( state );
for( uint i=0; i<count(); i++ )
{
updateItem( i );
}
}
void ColorListBox::setColor( uint index, const QColor &color )
{
if( index < count() )
{
ColorListItem *colorItem = (ColorListItem*)item(index);
colorItem->setColor(color);
updateItem( colorItem );
}
}
QColor ColorListBox::color( uint index ) const
{
if( index < count() )
{
ColorListItem *colorItem = (ColorListItem*)item(index);
return( colorItem->color() );
}
else
{
return( black );
}
}
-
+void ColorListBox::slotNewColor(QListBoxItem * i)
+{
+ if ( i )
+ newColor( index( i ) );
+}
void ColorListBox::newColor( int index )
{
if( isEnabled() == false )
{
return;
}
if( (uint)index < count() )
{
QColor c = color( index );
#ifndef KAB_EMBEDDED
if( KColorDialog::getColor( c, this ) != QDialog::Rejected )
{
setColor( index, c );
}
#else //KAB_EMBEDDED
KColorDialog* k = new KColorDialog( this );
k->setColor( c );
int res = k->exec();
if ( res ) {
setColor( index, k->getColor() );
}
delete k;
#endif //KAB_EMBEDDED
}
}
void ColorListBox::dragEnterEvent( QDragEnterEvent *e )
{
#ifndef KAB_EMBEDDED
if( KColorDrag::canDecode(e) && isEnabled() )
{
mCurrentOnDragEnter = currentItem();
e->accept( true );
}
else
{
mCurrentOnDragEnter = -1;
e->accept( false );
}
#else //KAB_EMBEDDED
qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported");
#endif //KAB_EMBEDDED
}
diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h
index 4a0e705..bb91484 100644
--- a/kaddressbook/views/colorlistbox.h
+++ b/kaddressbook/views/colorlistbox.h
@@ -3,74 +3,75 @@
* This file: Copyright (C) 2000 Espen Sand, espen@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef _COLOR_LISTBOX_H_
#define _COLOR_LISTBOX_H_
#include <klistbox.h>
class QDragEnterEvent;
class QDragLeaveEvent;
class QDragMoveEvent;
class QDropEvent;
class ColorListBox : public KListBox
{
Q_OBJECT
public:
ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 );
void setColor( uint index, const QColor &color );
QColor color( uint index ) const;
public slots:
virtual void setEnabled( bool state );
protected:
void dragEnterEvent( QDragEnterEvent *e );
void dragLeaveEvent( QDragLeaveEvent *e );
void dragMoveEvent( QDragMoveEvent *e );
void dropEvent( QDropEvent *e );
private slots:
void newColor( int index );
+ void slotNewColor(QListBoxItem * i);
private:
int mCurrentOnDragEnter;
};
class ColorListItem : public QListBoxItem
{
public:
ColorListItem( const QString &text, const QColor &color=Qt::black );
const QColor &color( void );
void setColor( const QColor &color );
protected:
virtual void paint( QPainter * );
virtual int height( const QListBox * ) const;
virtual int width( const QListBox * ) const;
private:
QColor mColor;
int mBoxWidth;
};
#endif
diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp
index 366e54c..e0fbd21 100644
--- a/kaddressbook/views/configurecardviewdialog.cpp
+++ b/kaddressbook/views/configurecardviewdialog.cpp
@@ -170,101 +170,105 @@ void CardViewLookNFeelPage::saveSettings( KConfig *config )
if ( cbEnableCustomFonts->isChecked() )
{
config->writeEntry( "TextFont", lTextFont->font() );
config->writeEntry( "HeaderFont", lHeaderFont->font() );
}
// layout
config->writeEntry( "ItemMargin", sbMargin->value() );
config->writeEntry( "ItemSpacing", sbSpacing->value() );
config->writeEntry( "SeparatorWidth", sbSepWidth->value() );
config->writeEntry("DrawBorder", cbDrawBorders->isChecked());
config->writeEntry("DrawSeparators", cbDrawSeps->isChecked());
// behaviour
config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked());
config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked());
}
void CardViewLookNFeelPage::setTextFont()
{
QFont f( lTextFont->font() );
#ifndef KAB_EMBEDDED
if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
updateFontLabel( f, lTextFont );
#else //KAB_EMBEDDED
bool ok;
QFont fout = KFontDialog::getFont( f, ok);
if ( ok )
updateFontLabel( fout, lTextFont );
#endif //KAB_EMBEDDED
}
void CardViewLookNFeelPage::setHeaderFont()
{
QFont f( lHeaderFont->font() );
#ifndef KAB_EMBEDDED
if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
updateFontLabel( f, lHeaderFont );
#else //KAB_EMBEDDED
bool ok;
QFont fout = KFontDialog::getFont( f, ok);
if ( ok )
updateFontLabel( fout, lHeaderFont );
#endif //KAB_EMBEDDED
}
void CardViewLookNFeelPage::enableFonts()
{
vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
+ if ( cbEnableCustomFonts->isChecked() )
+ vbFonts->setFocus();
}
void CardViewLookNFeelPage::enableColors()
{
lbColors->setEnabled( cbEnableCustomColors->isChecked() );
+ if ( cbEnableCustomColors->isChecked() )
+ lbColors->setFocus();
}
void CardViewLookNFeelPage::initGUI()
{
int spacing = KDialog::spacingHint();
int margin = KDialog::marginHint();
QTabWidget *tabs = new QTabWidget( this );
// Layout
QVBox *loTab = new QVBox( this, "layouttab" );
loTab->setSpacing( spacing );
loTab->setMargin( margin );
QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab );
cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral );
QHBox *hbSW = new QHBox( gbGeneral );
QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW );
sbSepWidth = new QSpinBox( 1, 50, 1, hbSW );
lSW->setBuddy( sbSepWidth);
QHBox *hbPadding = new QHBox( gbGeneral );
QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding );
sbSpacing = new QSpinBox( 0, 100, 1, hbPadding );
lSpacing->setBuddy( sbSpacing );
QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab );
QHBox *hbMargin = new QHBox( gbCards );
QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin );
sbMargin = new QSpinBox( 0, 100, 1, hbMargin );
lMargin->setBuddy( sbMargin );
cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards );
loTab->setStretchFactor( new QWidget( loTab ), 1 );
QWhatsThis::add( sbMargin, i18n(
"The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, "
"incrementing the item margin will add space between the focus rectangle and the item data."
) );
QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) );
QWhatsThis::add( sbSpacing, i18n(
"The Item Spacing decides the distance (in pixels) between the items and anything else: the view "
"borders, other items or column separators."
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp
index 8bcceb2..0e36abd 100644
--- a/kaddressbook/views/configuretableviewdialog.cpp
+++ b/kaddressbook/views/configuretableviewdialog.cpp
@@ -165,101 +165,105 @@ void LookAndFeelPage::saveSettings( KConfig *config )
config->writeEntry( "TextColor", lbColors->color( 1 ) );
config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) );
config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) );
config->writeEntry( "HighlightColor", lbColors->color( 4 ) );
config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) );
config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) );
}
// fonts
config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() );
if ( cbEnableCustomFonts->isChecked() )
{
config->writeEntry( "TextFont", lTextFont->font() );
config->writeEntry( "HeaderFont", lHeaderFont->font() );
}
}
void LookAndFeelPage::setTextFont()
{
QFont f( lTextFont->font() );
#ifndef KAB_EMBEDDED
if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted )
updateFontLabel( f, lTextFont );
#else //KAB_EMBEDDED
bool ok;
QFont fout = KFontDialog::getFont( f, ok);
if ( ok )
updateFontLabel( fout, lTextFont );
#endif //KAB_EMBEDDED
}
void LookAndFeelPage::setHeaderFont()
{
QFont f( lHeaderFont->font() );
#ifndef KAB_EMBEDDED
if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted )
updateFontLabel( f, lHeaderFont );
#else //KAB_EMBEDDED
bool ok;
QFont fout = KFontDialog::getFont( f, ok);
if ( ok )
updateFontLabel( fout, lHeaderFont );
#endif //KAB_EMBEDDED
}
void LookAndFeelPage::enableFonts()
{
vbFonts->setEnabled( cbEnableCustomFonts->isChecked() );
+ if ( cbEnableCustomFonts->isChecked() )
+ vbFonts->setFocus();
}
void LookAndFeelPage::enableColors()
{
- lbColors->setEnabled( cbEnableCustomColors->isChecked() );
+ lbColors->setEnabled( cbEnableCustomColors->isChecked() );
+ if ( cbEnableCustomColors->isChecked() )
+ lbColors->setFocus();
}
void LookAndFeelPage::initGUI()
{
int spacing = KDialog::spacingHint();
int margin = KDialog::marginHint();
QTabWidget *tabs = new QTabWidget( this );
// General
QVBox *generalTab = new QVBox( this, "generaltab" );
generalTab->setSpacing( spacing );
generalTab->setMargin( margin );
QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal,
i18n("Row Separator"), generalTab);
mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
group, "mAlternateButton");
mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab,
"mBackgroundBox");
connect(mBackgroundBox, SIGNAL(toggled(bool)),
SLOT(enableBackgroundToggled(bool)));
// LR image not implemented
mBackgroundBox->setEnabled( false );
mBackgroundName = new KURLRequester(generalTab, "mBackgroundName");
#ifndef KAB_EMBEDDED
mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
KFile::LocalOnly);
mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
#endif //KAB_EMBEDDED
// ToolTip Checkbox
mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab,
"mToolTipBox");
tabs->addTab( generalTab, i18n("&General") );
// Colors
QVBox *colorTab = new QVBox( this, "colortab" );
colorTab->setSpacing( spacing );
colorTab->setMargin( spacing );
cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab );
connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) );