From b76b22feb60c4ecdeb454a4def0655b8d791ced9 Mon Sep 17 00:00:00 2001 From: ikemo Date: Mon, 29 Dec 2003 05:26:29 +0000 Subject: [PATCH] implements color pref git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/kita/kita/trunk@735 56b19765-1e22-0410-a548-a0f45d66c51a --- kita/src/kitacolorprefbase.ui | 43 ++++++++++++++++++++------------- kita/src/pref.cpp | 55 +++++++++++++++++++++++++++++++++++++++++-- kita/src/pref.h | 3 +++ 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/kita/src/kitacolorprefbase.ui b/kita/src/kitacolorprefbase.ui index 6866830..caa7328 100644 --- a/kita/src/kitacolorprefbase.ui +++ b/kita/src/kitacolorprefbase.ui @@ -15,22 +15,6 @@ Form1 - - - customColorCheck - - - - 10 - 10 - 122 - 18 - - - - Use custom colors - - colorList @@ -49,7 +33,10 @@ - kPushButton1 + changeButton + + + false @@ -63,6 +50,22 @@ Change... + + + customColorCheck + + + + 10 + 10 + 144 + 19 + + + + Use custom colors + + @@ -71,6 +74,12 @@ colorList setEnabled(bool) + + customColorCheck + toggled(bool) + changeButton + setEnabled(bool) + customColorCheck_toggled( bool state ) diff --git a/kita/src/pref.cpp b/kita/src/pref.cpp index f2fa468..d378e5a 100644 --- a/kita/src/pref.cpp +++ b/kita/src/pref.cpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include @@ -80,13 +82,13 @@ KitaColorPrefPage::KitaColorPrefPage( QWidget *parent ) : KitaColorPrefBase(parent) { // FIXME: refactoring. - QPixmap textPixmap( 30, 10 ); +/* QPixmap textPixmap( 30, 10 ); textPixmap.fill( Qt::black ); colorList->insertItem( textPixmap, "text" ); QPixmap backPixmap( 30, 10 ); backPixmap.fill( Qt::white ); - colorList->insertItem( backPixmap, "background" ); + colorList->insertItem( backPixmap, "background" );*/ QPixmap popupTextPixmap( 30, 10 ); popupTextPixmap.fill( Qt::black ); @@ -95,6 +97,55 @@ KitaColorPrefPage::KitaColorPrefPage( QWidget *parent ) QPixmap popupBackPixmap( 30, 10 ); popupBackPixmap.fill( Qt::yellow ); colorList->insertItem( popupBackPixmap, "popup background" ); + + connect( changeButton, SIGNAL( clicked() ), + SLOT( slotChangeButtonClicked() ) ); +} + +void KitaColorPrefPage::slotChangeButtonClicked() +{ + int index = colorList->currentItem(); + + if ( index == -1 ) { + return; + } + + QColor newColor; + QColor defaultColor; + + // FIXME: refactoring. + switch( index ) { + case 0: + defaultColor = KitaConfig::popupColor(); + break; + case 1: + defaultColor = KitaConfig::popupBackgroundColor(); + break; + default: + return; + } + + int result = KColorDialog::getColor( newColor, defaultColor ); + if ( result == KColorDialog::Rejected ) { + return; + } + + QPixmap newPixmap( 30, 10 ); + // FIXME: refactoring. + switch( index ) { + case 0: + KitaConfig::setPopupColor( newColor ); + newPixmap.fill( newColor ); + colorList->changeItem( newPixmap, "popup text", index ); + break; + case 1: + KitaConfig::setPopupBackgroundColor( newColor ); + newPixmap.fill( newColor ); + colorList->changeItem( newPixmap, "popup background", index ); + break; + default: + return; + } } #include "pref.moc" diff --git a/kita/src/pref.h b/kita/src/pref.h index d1be695..e3cef55 100644 --- a/kita/src/pref.h +++ b/kita/src/pref.h @@ -58,6 +58,9 @@ class KitaColorPrefPage : public KitaColorPrefBase public: KitaColorPrefPage( QWidget *parent = 0 ); + +public slots: + void slotChangeButtonClicked(); }; #endif // _KITAPREF_H_ -- 2.11.0