<property name="caption">
<string>Form1</string>
</property>
- <widget class="QCheckBox">
- <property name="name">
- <cstring>customColorCheck</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>122</width>
- <height>18</height>
- </rect>
- </property>
- <property name="text">
- <string>Use custom colors</string>
- </property>
- </widget>
<widget class="KListBox">
<property name="name">
<cstring>colorList</cstring>
</widget>
<widget class="KPushButton">
<property name="name">
- <cstring>kPushButton1</cstring>
+ <cstring>changeButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
</property>
<property name="geometry">
<rect>
<string>Change...</string>
</property>
</widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>customColorCheck</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>144</width>
+ <height>19</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Use custom colors</string>
+ </property>
+ </widget>
</widget>
<connections>
<connection>
<receiver>colorList</receiver>
<slot>setEnabled(bool)</slot>
</connection>
+ <connection>
+ <sender>customColorCheck</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>changeButton</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
</connections>
<slots>
<slot>customColorCheck_toggled( bool state )</slot>
#include <klocale.h>
#include <kfontdialog.h>
+#include <kcolordialog.h>
+#include <kpushbutton.h>
#include <qlayout.h>
#include <qlabel.h>
: 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 );
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"