author | ulf69 <ulf69> | 2004-09-03 01:20:37 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-03 01:20:37 (UTC) |
commit | 7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c (patch) (side-by-side diff) | |
tree | cd2d7717d04533ab62cfc8435c7cafae8c82a8dc | |
parent | 546841acf4cdfd83d576cdd2a5ddbcc94c3921f6 (diff) | |
download | kdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.zip kdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.tar.gz kdepimpi-7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c.tar.bz2 |
sourceforge 1014886: added configurationsettings for color and font of tableview
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 216 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.h | 21 |
3 files changed, 223 insertions, 19 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index bec1862..45c7b55 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -334,6 +334,11 @@ void ViewManager::editView() mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); + + + //US this is a bugfix, that we get notified if we change a views configuration + emit modified(); + } } diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp index e1cc63e..cd09bcf 100644 --- a/kaddressbook/views/configuretableviewdialog.cpp +++ b/kaddressbook/views/configuretableviewdialog.cpp @@ -24,16 +24,21 @@ #include <qstring.h> #include <qwidget.h> #include <qlayout.h> +#include <qlabel.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qvbox.h> #include <qbuttongroup.h> +#include <qtabwidget.h> +#include <qwhatsthis.h> +#include <qpushbutton.h> #include <kglobal.h> #include <klocale.h> #include <klineedit.h> #include <kurlrequester.h> #include <kiconloader.h> +#include <kfontdialog.h> #ifndef KAB_EMBEDDED #include <kimageio.h> @@ -42,6 +47,8 @@ #include <kconfig.h> +#include "colorlistbox.h" + #include "configuretableviewdialog.h" ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, @@ -77,7 +84,7 @@ void ConfigureTableViewWidget::saveSettings( KConfig *config ) LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) - : QWidget(parent, name) + : QVBox(parent, name) { initGUI(); @@ -96,6 +103,49 @@ void LookAndFeelPage::restoreSettings( KConfig *config ) mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); + + // colors + cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); + QColor c; +qDebug("LookAndFeelPage::restoreSettings make base color configurable"); + +#ifndef KAB_EMBEDDED + c = KGlobalSettings::baseColor(); +#else //KAB_EMBEDDED + c = QColor(0,0,0); +#endif //KAB_EMBEDDED + + lbColors->insertItem( new ColorListItem( i18n("Background Color"), + config->readColorEntry( "BackgroundColor", &c ) ) ); + c = colorGroup().foreground(); + lbColors->insertItem( new ColorListItem( i18n("Text Color"), + config->readColorEntry( "TextColor", &c ) ) ); + c = colorGroup().button(); + lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), + config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); + c = colorGroup().buttonText(); + lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), + config->readColorEntry( "HeaderTextColor", &c ) ) ); + c = colorGroup().highlight(); + lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), + config->readColorEntry( "HighlightColor", &c ) ) ); + c = colorGroup().highlightedText(); + lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), + config->readColorEntry( "HighlightedTextColor", &c ) ) ); + c = colorGroup().background(); + lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), + config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); + + enableColors(); + + // fonts + QFont fnt = font(); + updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); + fnt.setBold( true ); + updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); + cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); + enableFonts(); + } void LookAndFeelPage::saveSettings( KConfig *config ) @@ -105,44 +155,171 @@ void LookAndFeelPage::saveSettings( KConfig *config ) config->writeEntry("ToolTips", mToolTipBox->isChecked()); config->writeEntry("Background", mBackgroundBox->isChecked()); config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); + + // colors + config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); + if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. + { + config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); + 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() ); +} + +void LookAndFeelPage::enableColors() +{ + lbColors->setEnabled( cbEnableCustomColors->isChecked() ); } void LookAndFeelPage::initGUI() { - QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint()); - + 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"), this); - layout->addWidget(group); + 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"); - // Background Checkbox/Selector - QHBoxLayout *backgroundLayout = new QHBoxLayout(); - layout->addLayout(backgroundLayout); - - mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this, + mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, "mBackgroundBox"); connect(mBackgroundBox, SIGNAL(toggled(bool)), SLOT(enableBackgroundToggled(bool))); - backgroundLayout->addWidget(mBackgroundBox); - mBackgroundName = new KURLRequester(this, "mBackgroundName"); + 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 - backgroundLayout->addWidget(mBackgroundName); - // ToolTip Checkbox - mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this, + mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, "mToolTipBox"); - layout->addWidget(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()) ); + lbColors = new ColorListBox( colorTab ); + tabs->addTab( colorTab, i18n("&Colors") ); + + QWhatsThis::add( cbEnableCustomColors, i18n( + "If custom colors are enabled, you may choose the colors for the view below. " + "Otherwise colors from your current KDE color scheme are used." + ) ); + QWhatsThis::add( lbColors, i18n( + "Double click or press RETURN on a item to select a color for the related strings in the view." + ) ); + + // Fonts + QVBox *fntTab = new QVBox( this, "fonttab" ); + + fntTab->setSpacing( spacing ); + fntTab->setMargin( spacing ); + + cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); + connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); + + vbFonts = new QWidget( fntTab ); + QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); + gFnts->setSpacing( spacing ); + gFnts->setAutoAdd( true ); + gFnts->setColStretch( 1, 1 ); + QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); + lTextFont = new QLabel( vbFonts ); + lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); +#ifndef KAB_EMBEDDED + btnFont = new KPushButton( i18n("Choose..."), vbFonts ); +#else //KAB_EMBEDDED + btnFont = new QPushButton( i18n("Choose..."), vbFonts ); +#endif //KAB_EMBEDDED + + lTFnt->setBuddy( btnFont ); + + connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); + + QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); + lHeaderFont = new QLabel( vbFonts ); + lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); +#ifndef KAB_EMBEDDED + btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); +#else //KAB_EMBEDDED + btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); +#endif //KAB_EMBEDDED + lHFnt->setBuddy( btnHeaderFont ); + connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); + + fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); + + QWhatsThis::add( cbEnableCustomFonts, i18n( + "If custom fonts are enabled, you may choose which fonts to use for this view below. " + "Otherwise the default KDE font will be used, in bold style for the header and " + "normal style for the data." + ) ); + + tabs->addTab( fntTab, i18n("&Fonts") ); + } void LookAndFeelPage::enableBackgroundToggled(bool enabled) @@ -150,6 +327,13 @@ void LookAndFeelPage::enableBackgroundToggled(bool enabled) mBackgroundName->setEnabled(enabled); } + +void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) +{ + l->setFont( fnt ); + l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); +} + #ifndef KAB_EMBEDDED #include "configuretableviewdialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/configuretableviewdialog.h b/kaddressbook/views/configuretableviewdialog.h index 8392710..003ccf8 100644 --- a/kaddressbook/views/configuretableviewdialog.h +++ b/kaddressbook/views/configuretableviewdialog.h @@ -26,12 +26,15 @@ #include "viewconfigurewidget.h" +#include <qvbox.h> + class QString; class QWidget; class QRadioButton; class QCheckBox; class KURLRequester; class KConfig; +class QLabel; namespace KABC { class AddressBook; } @@ -60,7 +63,7 @@ class ConfigureTableViewWidget : public ViewConfigureWidget /** Internal class. It is only defined here for moc */ -class LookAndFeelPage : public QWidget +class LookAndFeelPage : public QVBox { Q_OBJECT @@ -73,10 +76,22 @@ class LookAndFeelPage : public QWidget protected slots: void enableBackgroundToggled( bool ); - + void setTextFont(); + void setHeaderFont(); + void enableFonts(); + void enableColors(); + private: void initGUI(); - + void updateFontLabel( QFont, QLabel * ); + + QCheckBox *cbEnableCustomFonts, + *cbEnableCustomColors; + class ColorListBox *lbColors; + QLabel *lTextFont, *lHeaderFont; + class QPushButton *btnFont, *btnHeaderFont; + class QWidget* vbFonts; + QRadioButton *mAlternateButton; QRadioButton *mLineButton; QRadioButton *mNoneButton; |