summaryrefslogtreecommitdiffstats
path: root/kcontrol/colors
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/colors')
-rw-r--r--kcontrol/colors/Makefile.am15
-rw-r--r--kcontrol/colors/colors.desktop252
-rw-r--r--kcontrol/colors/colorscm.cpp980
-rw-r--r--kcontrol/colors/colorscm.h90
-rw-r--r--kcontrol/colors/stdclient_bitmaps.h128
-rw-r--r--kcontrol/colors/widgetcanvas.cpp596
-rw-r--r--kcontrol/colors/widgetcanvas.h121
7 files changed, 2182 insertions, 0 deletions
diff --git a/kcontrol/colors/Makefile.am b/kcontrol/colors/Makefile.am
new file mode 100644
index 000000000..87f4048ef
--- /dev/null
+++ b/kcontrol/colors/Makefile.am
@@ -0,0 +1,15 @@
+AM_CPPFLAGS = $(all_includes)
+
+kde_module_LTLIBRARIES = kcm_colors.la
+
+kcm_colors_la_SOURCES = colorscm.cpp widgetcanvas.cpp
+kcm_colors_la_LDFLAGS = $(KDE_RPATH) -module -avoid-version $(all_libraries) -no-undefined
+kcm_colors_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) $(top_builddir)/kcontrol/krdb/libkrdb.la
+METASOURCES = colorscm.moc widgetcanvas.moc
+
+noinst_HEADERS = colorscm.h widgetcanvas.h
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kcmcolors.pot
+
+xdg_apps_DATA = colors.desktop
diff --git a/kcontrol/colors/colors.desktop b/kcontrol/colors/colors.desktop
new file mode 100644
index 000000000..a13e45861
--- /dev/null
+++ b/kcontrol/colors/colors.desktop
@@ -0,0 +1,252 @@
+[Desktop Entry]
+Exec=kcmshell colors
+Icon=colorscm
+Type=Application
+DocPath=kcontrol/colors/index.html
+
+
+X-KDE-Library=colors
+X-KDE-FactoryName=colors
+X-KDE-ParentApp=kcontrol
+
+Name=Colors
+Name[af]=Kleure
+Name[ar]=الألوان
+Name[az]=Rənglər
+Name[be]=Колеры
+Name[bg]=Цветове
+Name[bn]=রং
+Name[br]=Livioù
+Name[bs]=Boje
+Name[cs]=Barvy
+Name[csb]=Farwë
+Name[cy]=Lliwiau
+Name[da]=Farver
+Name[de]=Farben
+Name[el]=Χρώματα
+Name[en_GB]=Colours
+Name[eo]=Koloroj
+Name[es]=Colores
+Name[et]=Värvid
+Name[eu]=Koloreak
+Name[fa]=رنگها
+Name[fi]=Värit
+Name[fo]=Litir
+Name[fr]=Couleurs
+Name[fy]=Kleuren
+Name[ga]=Dathanna
+Name[gl]=Cores
+Name[he]=צבעים
+Name[hi]=रंग
+Name[hr]=Boje
+Name[hu]=Színek
+Name[id]=Warna
+Name[is]=Litir
+Name[it]=Colori
+Name[ja]=色
+Name[ka]=ცვეტები
+Name[kk]=Түстер
+Name[km]=ពណ៌
+Name[ko]=색
+Name[lo]=ສີ
+Name[lt]=Spalvos
+Name[lv]=Krāsas
+Name[mk]=Бои
+Name[mn]=Өнгө
+Name[ms]=Warna
+Name[mt]=Kuluri
+Name[nb]=Farger
+Name[nds]=Klören
+Name[ne]=रङ
+Name[nl]=Kleuren
+Name[nn]=Fargar
+Name[nso]=Mebala
+Name[pa]=ਰੰਗ
+Name[pl]=Kolory
+Name[pt]=Cores
+Name[pt_BR]=Cores
+Name[ro]=Culori
+Name[ru]=Цвета
+Name[rw]=Amabara
+Name[se]=Ivnnit
+Name[sk]=Farby
+Name[sl]=Barve
+Name[sr]=Боје
+Name[sr@Latn]=Boje
+Name[ss]=Imibala
+Name[sv]=Färger
+Name[ta]=வண்ணங்கள்
+Name[te]=రంగులు
+Name[tg]=Рангҳо
+Name[th]=สี
+Name[tr]=Renkler
+Name[tt]=Töslär
+Name[uk]=Кольори
+Name[uz]=Ranglar
+Name[uz@cyrillic]=Ранглар
+Name[ven]=Mivhala
+Name[vi]=Màu
+Name[wa]=Coleurs
+Name[xh]=Imibala
+Name[zh_CN]=颜色
+Name[zh_TW]=顏色
+Name[zu]=Imibala
+
+Comment=Color settings
+Comment[af]=Kleur instellings
+Comment[ar]=ضبط الألوان
+Comment[az]=Rəng qurğuları
+Comment[be]=Настаўленне колераў
+Comment[bg]=Настройване цветовете на системата
+Comment[bn]=রং সেটিংস
+Comment[br]=Kefluniañ al livioù
+Comment[bs]=Podešavanje boja
+Comment[ca]=Arranjament dels colors
+Comment[cs]=Nastavení barev
+Comment[csb]=Ùstôw farwów
+Comment[cy]=Gosodiadau lliwiau
+Comment[da]=Farveindstillinger
+Comment[de]=Einstellung der Bildschirmfarben
+Comment[el]=Ρυθμίσεις χρωμάτων
+Comment[en_GB]=Colour settings
+Comment[eo]=Agordo de la koloroj
+Comment[es]=Preferencias sobre los colores
+Comment[et]=Värvide seadistused
+Comment[eu]=Koloreen konfigurazioa
+Comment[fa]=تنطیمات رنگها
+Comment[fi]=Väriasetukset
+Comment[fo]=Lituppseting
+Comment[fr]=Configuration des couleurs
+Comment[fy]=Kleuren ynstelle
+Comment[ga]=Socruithe na ndathanna
+Comment[gl]=Configuración das cores
+Comment[he]=שינוי הגדרות הצבעים
+Comment[hi]=रंग विन्यास
+Comment[hr]=Postava boja
+Comment[hu]=Színbeállítások
+Comment[id]=Seting warna
+Comment[is]=Stillingar lita
+Comment[it]=Impostazioni dei colori
+Comment[ja]=色の設定
+Comment[ka]=ფერების კონფიგურაცია
+Comment[kk]=Түстерді орнату
+Comment[km]=ការ​កំណត់​ពណ៌
+Comment[ko]=색 설정
+Comment[lo]=ຕັ້ງຄ່າສີ
+Comment[lt]=Spalvų parametrai
+Comment[lv]=Krāsu uzstādījumi
+Comment[mk]=Поставувања за боите
+Comment[mn]=Дэлгэцийн өнгө тохируулах
+Comment[ms]=Seting warna
+Comment[mt]=Konfigurazzjoni tal-kuluri
+Comment[nb]=Fargeinnstillinger
+Comment[nds]=Klören instellen
+Comment[ne]=रङ सेटिङ
+Comment[nl]=Kleuren instellen
+Comment[nn]=Fargeinnstillingar
+Comment[nso]=Dipeakanyo tsa mebala
+Comment[oc]=Arranjament dèus colors
+Comment[pa]=ਰੰਗ ਸੈਟਿੰਗ
+Comment[pl]=Ustawienia kolorów
+Comment[pt]=Configuração das cores
+Comment[pt_BR]=Configurações de cor
+Comment[ro]=Configurează culorile ferestrelor
+Comment[ru]=Настройка цветов
+Comment[rw]=Amagenamiterere y'ibara
+Comment[se]=Ivdneheivehusat
+Comment[sk]=Nastavenie farieb
+Comment[sl]=Nastavitve barv
+Comment[sr]=Поставке боја
+Comment[sr@Latn]=Postavke boja
+Comment[ss]=Kuhleleka kwembala
+Comment[sv]=Anpassa färger
+Comment[ta]=வண்ண அமைப்புகள்
+Comment[te]=రంగుల అమరికలు
+Comment[tg]=Танзимоти ранг
+Comment[th]=ตั้งค่าสี
+Comment[tr]=Renk ayarları
+Comment[tt]=Tös caylaw
+Comment[uk]=Налаштування кольорів
+Comment[uz]=Ranglarning moslamalari
+Comment[uz@cyrillic]=Рангларнинг мосламалари
+Comment[ven]=Mavhekanyele a muvhala
+Comment[vi]=Thiết lập màu
+Comment[wa]=Apontiaedje des coleurs
+Comment[xh]=Izicwangciso zombala
+Comment[zh_CN]=颜色设置
+Comment[zh_TW]=顏色設定
+Comment[zu]=Izilungiso zombala
+
+Keywords=colors,colours,scheme,contrast,Widget colors,Color Scheme
+Keywords[af]=colors,colours,Skema,contrast,Widget colors,Color Skema
+Keywords[az]=rənglər,sxem,kontrast,Rəng Cədvəli
+Keywords[be]=колеры,схема,кантраст,колеры віджэтаў,колерная схема,colors,colours,scheme,contrast,Widget colors,Color Scheme
+Keywords[bg]=цветове, схема, цветова, colors, colours, scheme, contrast, Widget colors, Color Scheme
+Keywords[ca]=colors,esquema,contrast,colors d'estri,esquema de color
+Keywords[cs]=Barvy,Schéma,Kontrast,Barevná schémata
+Keywords[csb]=farwa,schema,kòntrast,farwë elementów òknów,schema farwów
+Keywords[cy]=lliwiau,cynlluniau,cyferbyniad,lliwiau celfigion,Cynllun Lliw
+Keywords[da]=farver,system,kontrast,Kontrolfarver,Farvesammensætning
+Keywords[de]=Farben,Schema,Kontrast,Farbschema,Elemente
+Keywords[el]=χρώματα,χρώματα,θέμα,αντίθεση,Χρώματα γραφικού συστατικού,Θέμα χρωμάτων
+Keywords[en_GB]=colours,scheme,contrast,Widget colours,Colour Scheme
+Keywords[eo]=koloroj,skemo,kontrasto,fenestraĵo-koloroj,koloraro
+Keywords[es]=colores,esquema,contraste,Colores de los objetos visuales,Colores de los widgets,Esquema de colores
+Keywords[et]=värvid,skeem,kontrast,värviskeem
+Keywords[eu]=koloreak,antolamendua,kontrastea,Widget-en koloreak,Kolore eskema
+Keywords[fa]=رنگها، رنگها، طرحواره، سایه روشن، رنگهای عنصر، طرحوارۀ رنگ
+Keywords[fi]=väri,teema,kontrasti,työkalujen värit,väriteema
+Keywords[fo]=litir
+Keywords[fr]=couleurs,modèles de couleurs,contraste,couleur des éléments graphiques,modèle
+Keywords[fy]=kleuren,kleur,skema,kontrast,widgetkleuren,kleurenskema
+Keywords[ga]=dathanna,scéim,codarsnacht,dathanna giuirléidí,Scéim Dathanna
+Keywords[gl]=cor,cores,esquema,contraste,cores dos widgets,Esquema das cores
+Keywords[he]=colors,colours,scheme,contrast,Widget colors,Color,Schemeצבעים,תבנית,חדות,צבע פריטים,תבנית צבעים
+Keywords[hi]=रंग,योजना,कंट्रास्ट,विजेट रंग,रंग योजना
+Keywords[hr]=colors,colours,scheme,contrast,Widget colors,Color Scheme,boja,boje,shema,kontrast,Boje widgeta,Shema bojanja
+Keywords[hu]=színek,séma,kontraszt,elemszín,színösszeállítás
+Keywords[id]=warna,scheme,kontras, warna widget, warna scheme
+Keywords[is]=litir,litur,skema,skerpa
+Keywords[it]=colori,schema,contrasto,colore widget,colore elementi grafici,schema di colori
+Keywords[ja]=色,スキーム,コントラスト,ウィジェット色,色スキーム
+Keywords[km]=ពណ៌,គ្រោងការណ៍,កម្រិត​ពណ៌,ពណ៌​របស់​វត្ថុ​មើលឃើញ,គ្រោងការណ៍​ពណ៌
+Keywords[lt]=colors,colours,scheme,contrast,Widget colors,Color Scheme,spalvos,koloritai,schema,kontrastas, Valdiklių spalvos, Spalvų Schema
+Keywords[lv]=krāsu,krāsas,shēma,kontrasts,Vidžeta krāsas,Krāsu Shēma
+Keywords[mk]=colors,colours,scheme,contrast,Widget colors,Color Scheme,бои,шема,контраст,Шема на бои
+Keywords[mn]=Өнгө,Схем,Эрчим,Өнгөний схем,Элемент
+Keywords[ms]=warna,warna,skema, kontras, warna Widget,Skema Warna
+Keywords[nb]=farger,oppsett,kontrast,elementfarger,fargeoppsett
+Keywords[nds]=Klören,Schema,Kontrast,Bedeenelementen,Klöörschema
+Keywords[ne]=रङ, रङ्ग, योजना, व्यतिरेक, विजेट रङ, रङ योजना
+Keywords[nl]=kleuren,kleur,schema,contrast,widgetkleuren,kleurenschema
+Keywords[nn]=fargar,oppsett,kontrast,elementfargar,fargeoppsett
+Keywords[nso]=mebala,mebala,leano,phapano,Mebala ya Widget,Leano la Mmala
+Keywords[pa]=colors,colours,scheme,contrast,Widget colors,Color Scheme,ਰੰਗ,ਸਕੀਮ
+Keywords[pl]=kolory,schemat,kontrast,kolory elementów okienek,schemat kolorów
+Keywords[pt]=cores,esquema,esquema,contraste,cores dos elementos,esquema de cor
+Keywords[pt_BR]=cores,esquema,contraste,cores de controles,Esquema de cor
+Keywords[ro]=culoare,culori,schemă,contrast,componente,schemă de culori
+Keywords[rw]=Amabara,amabara,Igishushanyombonera,inyuranyamigaragarire, Amabara y'akabanga,Igishushombonera cy'ibara
+Keywords[se]=ivnnit,coahkádusat,vuostálasvuohta,áhtaivnnit,ivdnečoahkádus
+Keywords[sk]=farby,schémy,kontrast,farby prvkov,schéma farieb
+Keywords[sl]=barva,barve,sheme,kontrast,nadzor gradnikov,barvna shema
+Keywords[sr]=боје,шема,контраст,шема боја
+Keywords[sr@Latn]=boje,šema,kontrast,šema boja
+Keywords[ss]=mibala,mibala,inhlanganisela,kucatsanisa,mibala yesisetjentiswa,kwakheka kwembala
+Keywords[sv]=färger,schema,kontrast,Komponentfärger,Färgschema
+Keywords[ta]=வண்ணங்கள்,வண்ணங்கள்,திட்டம்,எதிரான,Widget வண்ணங்கள்,வண்ண முறை
+Keywords[tg]=colors,colours,scheme,contrast,Widget colors,Color Scheme,рангҳо,рангҳо
+Keywords[th]=สี,ชุดสี,ความตัดกันของสี,สีของคอนโทรล
+Keywords[tr]=renkler,şema,kontrast,Renk Tablosu
+Keywords[uk]=кольори,схема,контрастність,кольори віджетів,схема кольорів
+Keywords[uz]=ranglar,qolip,kontrast,vidjet ranglari,rang qolipi
+Keywords[uz@cyrillic]=ранглар,қолип,контраст,виджет ранглари,ранг қолипи
+Keywords[ven]=mivhala,mivhala,tshikimu,mbambe,Widget mivhala,Tshikimu tsha Muvhala
+Keywords[vi]=màu,màu sắc,sắc thái,tương phản,Màu của ô điều khiển,Sắc thái Màu
+Keywords[wa]=coleurs,arindjmint,contrasse,coleurs d' ahesse,arindjmint di coleurs,arindjmints d' coleurs
+Keywords[xh]=imibala,imibala,udweliso,isiboniso somahluko,Imibala ye widget,Udweliso Olunombala
+Keywords[zh_CN]=colors,colours,scheme,contrast,Widget colors,Color Scheme,颜色,方案,对比,部件颜色,配色方案
+Keywords[zh_TW]=colors,colours,scheme,contrast,Widget colors,Color Scheme,顏色,對比,元件顏色,配色
+Keywords[zu]=imibala,imibala,iplani,ukugqama,imibala ye-Widget,Iplani Lombala
+
+Categories=Qt;KDE;X-KDE-settings-looknfeel;
diff --git a/kcontrol/colors/colorscm.cpp b/kcontrol/colors/colorscm.cpp
new file mode 100644
index 000000000..39e5574c2
--- /dev/null
+++ b/kcontrol/colors/colorscm.cpp
@@ -0,0 +1,980 @@
+// KDE Display color scheme setup module
+//
+// Copyright (c) Mark Donohoe 1997
+//
+// Converted to a kcc module by Matthias Hoelzer 1997
+// Ported to Qt-2.0 by Matthias Ettrich 1999
+// Ported to kcontrol2 by Geert Jansen 1999
+// Made maintainable by Waldo Bastian 2000
+
+#include <assert.h>
+#include <config.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qslider.h>
+#include <qvgroupbox.h>
+#include <qwhatsthis.h>
+
+#include <kcolorbutton.h>
+#include <kcursor.h>
+#include <kfiledialog.h>
+#include <kgenericfactory.h>
+#include <kglobalsettings.h>
+#include <kinputdialog.h>
+#include <kio/netaccess.h>
+#include <kipc.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kstandarddirs.h>
+#include <kaboutdata.h>
+
+#if defined Q_WS_X11 && !defined K_WS_QTONLY
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#endif
+
+#include "../krdb/krdb.h"
+
+#include "colorscm.h"
+
+
+/**** DLL Interface ****/
+typedef KGenericFactory<KColorScheme , QWidget> KolorFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_colors, KolorFactory("kcmcolors") )
+
+class KColorSchemeEntry {
+public:
+ KColorSchemeEntry(const QString &_path, const QString &_name, bool _local)
+ : path(_path), name(_name), local(_local) { }
+
+ QString path;
+ QString name;
+ bool local;
+};
+
+class KColorSchemeList : public QPtrList<KColorSchemeEntry> {
+public:
+ KColorSchemeList()
+ { setAutoDelete(true); }
+
+ int compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2)
+ {
+ KColorSchemeEntry *i1 = (KColorSchemeEntry*)item1;
+ KColorSchemeEntry *i2 = (KColorSchemeEntry*)item2;
+ if (i1->local != i2->local)
+ return i1->local ? -1 : 1;
+ return i1->name.localeAwareCompare(i2->name);
+ }
+};
+
+#define SIZE 8
+
+// make a 24 * 8 pixmap with the main colors in a scheme
+QPixmap mkColorPreview(const WidgetCanvas *cs)
+{
+ QPixmap group(SIZE*3,SIZE);
+ QPixmap block(SIZE,SIZE);
+ group.fill(QColor(0,0,0));
+ block.fill(cs->back); bitBlt(&group,0*SIZE,0,&block,0,0,SIZE,SIZE);
+ block.fill(cs->window); bitBlt(&group,1*SIZE,0,&block,0,0,SIZE,SIZE);
+ block.fill(cs->aTitle); bitBlt(&group,2*SIZE,0,&block,0,0,SIZE,SIZE);
+ QPainter p(&group);
+ p.drawRect(0,0,3*SIZE,SIZE);
+ return group;
+}
+
+/**** KColorScheme ****/
+
+KColorScheme::KColorScheme(QWidget *parent, const char *name, const QStringList &)
+ : KCModule(KolorFactory::instance(), parent, name)
+{
+ nSysSchemes = 2;
+
+ setQuickHelp( i18n("<h1>Colors</h1> This module allows you to choose"
+ " the color scheme used for the KDE desktop. The different"
+ " elements of the desktop, such as title bars, menu text, etc.,"
+ " are called \"widgets\". You can choose the widget whose"
+ " color you want to change by selecting it from a list, or by"
+ " clicking on a graphical representation of the desktop.<p>"
+ " You can save color settings as complete color schemes,"
+ " which can also be modified or deleted. KDE comes with several"
+ " predefined color schemes on which you can base your own.<p>"
+ " All KDE applications will obey the selected color scheme."
+ " Non-KDE applications may also obey some or all of the color"
+ " settings, if this option is enabled."));
+
+ KConfig *cfg = new KConfig("kcmdisplayrc");
+ cfg->setGroup("X11");
+ useRM = cfg->readBoolEntry("useResourceManager", true);
+ delete cfg;
+
+ cs = new WidgetCanvas( this );
+ cs->setCursor( KCursor::handCursor() );
+
+ // LAYOUT
+
+ QGridLayout *topLayout = new QGridLayout( this, 3, 2, 0,
+ KDialog::spacingHint() );
+ topLayout->setRowStretch(0,0);
+ topLayout->setRowStretch(1,0);
+ topLayout->setColStretch(0,1);
+ topLayout->setColStretch(1,1);
+
+ cs->setFixedHeight(160);
+ cs->setMinimumWidth(440);
+
+ QWhatsThis::add( cs, i18n("This is a preview of the color settings which"
+ " will be applied if you click \"Apply\" or \"OK\". You can click on"
+ " different parts of this preview image. The widget name in the"
+ " \"Widget color\" box will change to reflect the part of the preview"
+ " image you clicked.") );
+
+ connect( cs, SIGNAL( widgetSelected( int ) ),
+ SLOT( slotWidgetColor( int ) ) );
+ connect( cs, SIGNAL( colorDropped( int, const QColor&)),
+ SLOT( slotColorForWidget( int, const QColor&)));
+ topLayout->addMultiCellWidget( cs, 0, 0, 0, 1 );
+
+ QGroupBox *group = new QVGroupBox( i18n("Color Scheme"), this );
+ topLayout->addWidget( group, 1, 0 );
+
+ sList = new KListBox( group );
+ mSchemeList = new KColorSchemeList();
+ readSchemeNames();
+ sList->setCurrentItem( 0 );
+ connect(sList, SIGNAL(highlighted(int)), SLOT(slotPreviewScheme(int)));
+
+ QWhatsThis::add( sList, i18n("This is a list of predefined color schemes,"
+ " including any that you may have created. You can preview an existing"
+ " color scheme by selecting it from the list. The current scheme will"
+ " be replaced by the selected color scheme.<p>"
+ " Warning: if you have not yet applied any changes you may have made"
+ " to the current scheme, those changes will be lost if you select"
+ " another color scheme.") );
+
+ addBt = new QPushButton(i18n("&Save Scheme..."), group);
+ connect(addBt, SIGNAL(clicked()), SLOT(slotAdd()));
+
+ QWhatsThis::add( addBt, i18n("Press this button if you want to save"
+ " the current color settings as a color scheme. You will be"
+ " prompted for a name.") );
+
+ removeBt = new QPushButton(i18n("R&emove Scheme"), group);
+ removeBt->setEnabled(FALSE);
+ connect(removeBt, SIGNAL(clicked()), SLOT(slotRemove()));
+
+ QWhatsThis::add( removeBt, i18n("Press this button to remove the selected"
+ " color scheme. Note that this button is disabled if you do not have"
+ " permission to delete the color scheme.") );
+
+ importBt = new QPushButton(i18n("I&mport Scheme..."), group);
+ connect(importBt, SIGNAL(clicked()),SLOT(slotImport()));
+
+ QWhatsThis::add( importBt, i18n("Press this button to import a new color"
+ " scheme. Note that the color scheme will only be available for the"
+ " current user." ));
+
+
+ QBoxLayout *stackLayout = new QVBoxLayout;
+ topLayout->addLayout(stackLayout, 1, 1);
+
+ group = new QGroupBox(i18n("&Widget Color"), this);
+ stackLayout->addWidget(group);
+ QBoxLayout *groupLayout = new QVBoxLayout(group, 10);
+ groupLayout->addSpacing(10);
+
+ wcCombo = new QComboBox(false, group);
+ for(int i=0; i < CSM_LAST;i++)
+ {
+ wcCombo->insertItem(QString::null);
+ }
+
+ setColorName(i18n("Inactive Title Bar") , CSM_Inactive_title_bar);
+ setColorName(i18n("Inactive Title Text"), CSM_Inactive_title_text);
+ setColorName(i18n("Inactive Title Blend"), CSM_Inactive_title_blend);
+ setColorName(i18n("Active Title Bar"), CSM_Active_title_bar);
+ setColorName(i18n("Active Title Text"), CSM_Active_title_text);
+ setColorName(i18n("Active Title Blend"), CSM_Active_title_blend);
+ setColorName(i18n("Window Background"), CSM_Background);
+ setColorName(i18n("Window Text"), CSM_Text);
+ setColorName(i18n("Selected Background"), CSM_Select_background);
+ setColorName(i18n("Selected Text"), CSM_Select_text);
+ setColorName(i18n("Standard Background"), CSM_Standard_background);
+ setColorName(i18n("Standard Text"), CSM_Standard_text);
+ setColorName(i18n("Button Background"), CSM_Button_background);
+ setColorName(i18n("Button Text"), CSM_Button_text);
+ setColorName(i18n("Active Title Button"), CSM_Active_title_button);
+ setColorName(i18n("Inactive Title Button"), CSM_Inactive_title_button);
+ setColorName(i18n("Active Window Frame"), CSM_Active_frame);
+ setColorName(i18n("Active Window Handle"), CSM_Active_handle);
+ setColorName(i18n("Inactive Window Frame"), CSM_Inactive_frame);
+ setColorName(i18n("Inactive Window Handle"), CSM_Inactive_handle);
+ setColorName(i18n("Link"), CSM_Link);
+ setColorName(i18n("Followed Link"), CSM_Followed_Link);
+ setColorName(i18n("Alternate Background in Lists"), CSM_Alternate_background);
+
+ wcCombo->adjustSize();
+ connect(wcCombo, SIGNAL(activated(int)), SLOT(slotWidgetColor(int)));
+ groupLayout->addWidget(wcCombo);
+
+ QWhatsThis::add( wcCombo, i18n("Click here to select an element of"
+ " the KDE desktop whose color you want to change. You may either"
+ " choose the \"widget\" here, or click on the corresponding part"
+ " of the preview image above.") );
+
+ colorButton = new KColorButton( group );
+ connect( colorButton, SIGNAL( changed(const QColor &)),
+ SLOT(slotSelectColor(const QColor &)));
+
+ groupLayout->addWidget( colorButton );
+
+ QWhatsThis::add( colorButton, i18n("Click here to bring up a dialog"
+ " box where you can choose a color for the \"widget\" selected"
+ " in the above list.") );
+
+ cbShadeList = new QCheckBox(i18n("Shade sorted column in lists"), this);
+ stackLayout->addWidget(cbShadeList);
+ connect(cbShadeList, SIGNAL(toggled(bool)), this, SLOT(slotShadeSortColumnChanged(bool)));
+
+ QWhatsThis::add(cbShadeList,
+ i18n("Check this box to show the sorted column in a list with a shaded background"));
+
+ group = new QGroupBox( i18n("Con&trast"), this );
+ stackLayout->addWidget(group);
+
+ QVBoxLayout *groupLayout2 = new QVBoxLayout(group, 10);
+ groupLayout2->addSpacing(10);
+ groupLayout = new QHBoxLayout;
+ groupLayout2->addLayout(groupLayout);
+
+ sb = new QSlider( QSlider::Horizontal,group,"Slider" );
+ sb->setRange( 0, 10 );
+ sb->setFocusPolicy( QWidget::StrongFocus );
+ connect(sb, SIGNAL(valueChanged(int)), SLOT(sliderValueChanged(int)));
+
+ QWhatsThis::add(sb, i18n("Use this slider to change the contrast level"
+ " of the current color scheme. Contrast does not affect all of the"
+ " colors, only the edges of 3D objects."));
+
+ QLabel *label = new QLabel(sb, i18n("Low Contrast", "Low"), group);
+ groupLayout->addWidget(label);
+ groupLayout->addWidget(sb, 10);
+ label = new QLabel(group);
+ label->setText(i18n("High Contrast", "High"));
+ groupLayout->addWidget( label );
+
+ cbExportColors = new QCheckBox(i18n("Apply colors to &non-KDE applications"), this);
+ topLayout->addMultiCellWidget( cbExportColors, 2, 2, 0, 1 );
+ connect(cbExportColors, SIGNAL(toggled(bool)), this, SLOT(changed()));
+
+ QWhatsThis::add(cbExportColors, i18n("Check this box to apply the"
+ " current color scheme to non-KDE applications."));
+
+ load();
+
+ KAboutData* about = new KAboutData("kcmcolors", I18N_NOOP("Colors"), 0, 0,
+ KAboutData::License_GPL,
+ I18N_NOOP("(c) 1997-2005 Colors Developers"), 0, 0);
+ about->addAuthor("Mark Donohoe", 0, 0);
+ about->addAuthor("Matthias Hoelzer", 0, 0);
+ about->addAuthor("Matthias Ettrich", 0, 0);
+ about->addAuthor("Geert Jansen", 0, 0);
+ about->addAuthor("Waldo Bastian", 0, 0);
+ setAboutData( about );
+}
+
+
+KColorScheme::~KColorScheme()
+{
+ delete mSchemeList;
+}
+
+void KColorScheme::setColorName( const QString &name, int id )
+{
+ wcCombo->changeItem(name, id);
+ cs->addToolTip( id, name );
+}
+
+void KColorScheme::load()
+{
+ load( false );
+}
+void KColorScheme::load( bool useDefaults )
+{
+ KConfig *config = KGlobal::config();
+ config->setReadDefaults( useDefaults );
+ config->setGroup("KDE");
+ sCurrentScheme = config->readEntry("colorScheme");
+
+ sList->setCurrentItem(findSchemeByName(sCurrentScheme));
+ readScheme(0);
+
+ cbShadeList->setChecked(cs->shadeSortColumn);
+
+ cs->drawSampleWidgets();
+ slotWidgetColor(wcCombo->currentItem());
+ sb->blockSignals(true);
+ sb->setValue(cs->contrast);
+ sb->blockSignals(false);
+
+ KConfig cfg("kcmdisplayrc", true, false);
+ cfg.setGroup("X11");
+ bool exportColors = cfg.readBoolEntry("exportKDEColors", true);
+ cbExportColors->setChecked(exportColors);
+
+ emit changed( useDefaults );
+}
+
+
+void KColorScheme::save()
+{
+ KConfig *cfg = KGlobal::config();
+ cfg->setGroup( "General" );
+ cfg->writeEntry("background", cs->back, true, true);
+ cfg->writeEntry("selectBackground", cs->select, true, true);
+ cfg->writeEntry("foreground", cs->txt, true, true);
+ cfg->writeEntry("windowForeground", cs->windowTxt, true, true);
+ cfg->writeEntry("windowBackground", cs->window, true, true);
+ cfg->writeEntry("selectForeground", cs->selectTxt, true, true);
+ cfg->writeEntry("buttonBackground", cs->button, true, true);
+ cfg->writeEntry("buttonForeground", cs->buttonTxt, true, true);
+ cfg->writeEntry("linkColor", cs->link, true, true);
+ cfg->writeEntry("visitedLinkColor", cs->visitedLink, true, true);
+ cfg->writeEntry("alternateBackground", cs->alternateBackground, true, true);
+
+ cfg->writeEntry("shadeSortColumn", cs->shadeSortColumn, true, true);
+
+ cfg->setGroup( "WM" );
+ cfg->writeEntry("activeForeground", cs->aTxt, true, true);
+ cfg->writeEntry("inactiveBackground", cs->iaTitle, true, true);
+ cfg->writeEntry("inactiveBlend", cs->iaBlend, true, true);
+ cfg->writeEntry("activeBackground", cs->aTitle, true, true);
+ cfg->writeEntry("activeBlend", cs->aBlend, true, true);
+ cfg->writeEntry("inactiveForeground", cs->iaTxt, true, true);
+ cfg->writeEntry("activeTitleBtnBg", cs->aTitleBtn, true, true);
+ cfg->writeEntry("inactiveTitleBtnBg", cs->iTitleBtn, true, true);
+ cfg->writeEntry("frame", cs->aFrame, true, true);
+ cfg->writeEntry("inactiveFrame", cs->iaFrame, true, true);
+ cfg->writeEntry("handle", cs->aHandle, true, true);
+ cfg->writeEntry("inactiveHandle", cs->iaHandle, true, true);
+
+ cfg->setGroup( "KDE" );
+ cfg->writeEntry("contrast", cs->contrast, true, true);
+ cfg->writeEntry("colorScheme", sCurrentScheme, true, true);
+ cfg->sync();
+
+ // KDE-1.x support
+ KSimpleConfig *config =
+ new KSimpleConfig( QDir::homeDirPath() + "/.kderc" );
+ config->setGroup( "General" );
+ config->writeEntry("background", cs->back );
+ config->writeEntry("selectBackground", cs->select );
+ config->writeEntry("foreground", cs->txt, true, true);
+ config->writeEntry("windowForeground", cs->windowTxt );
+ config->writeEntry("windowBackground", cs->window );
+ config->writeEntry("selectForeground", cs->selectTxt );
+ config->sync();
+ delete config;
+
+ KConfig cfg2("kcmdisplayrc", false, false);
+ cfg2.setGroup("X11");
+ bool exportColors = cbExportColors->isChecked();
+ cfg2.writeEntry("exportKDEColors", exportColors);
+ cfg2.sync();
+ QApplication::syncX();
+
+ // Notify all qt-only apps of the KDE palette changes
+ uint flags = KRdbExportQtColors;
+ if ( exportColors )
+ flags |= KRdbExportColors;
+ else
+ {
+#if defined Q_WS_X11 && !defined K_WS_QTONLY
+ // Undo the property xrdb has placed on the root window (if any),
+ // i.e. remove all entries, including ours
+ XDeleteProperty( qt_xdisplay(), qt_xrootwin(), XA_RESOURCE_MANAGER );
+#endif
+ }
+ runRdb( flags ); // Save the palette to qtrc for KStyles
+
+ // Notify all KDE applications
+ KIPC::sendMessageAll(KIPC::PaletteChanged);
+
+ // Update the "Current Scheme"
+ int current = findSchemeByName(sCurrentScheme);
+ sList->setCurrentItem(0);
+ readScheme(0);
+ QPixmap preview = mkColorPreview(cs);
+ sList->changeItem(preview, sList->text(0), 0);
+ sList->setCurrentItem(current);
+ readScheme(current);
+ preview = mkColorPreview(cs);
+ sList->changeItem(preview, sList->text(current), current);
+
+ emit changed(false);
+}
+
+
+void KColorScheme::defaults()
+{
+ load( true );
+}
+
+void KColorScheme::sliderValueChanged( int val )
+{
+ cs->contrast = val;
+ cs->drawSampleWidgets();
+
+ sCurrentScheme = QString::null;
+
+ emit changed(true);
+}
+
+
+void KColorScheme::slotSave( )
+{
+ KColorSchemeEntry *entry = mSchemeList->at(sList->currentItem()-nSysSchemes);
+ if (!entry) return;
+ sCurrentScheme = entry->path;
+ KSimpleConfig *config = new KSimpleConfig(sCurrentScheme );
+ int i = sCurrentScheme.findRev('/');
+ if (i >= 0)
+ sCurrentScheme = sCurrentScheme.mid(i+1);
+
+ config->setGroup("Color Scheme" );
+ config->writeEntry("background", cs->back );
+ config->writeEntry("selectBackground", cs->select );
+ config->writeEntry("foreground", cs->txt );
+ config->writeEntry("activeForeground", cs->aTxt );
+ config->writeEntry("inactiveBackground", cs->iaTitle );
+ config->writeEntry("inactiveBlend", cs->iaBlend );
+ config->writeEntry("activeBackground", cs->aTitle );
+ config->writeEntry("activeBlend", cs->aBlend );
+ config->writeEntry("inactiveForeground", cs->iaTxt );
+ config->writeEntry("windowForeground", cs->windowTxt );
+ config->writeEntry("windowBackground", cs->window );
+ config->writeEntry("selectForeground", cs->selectTxt );
+ config->writeEntry("contrast", cs->contrast );
+ config->writeEntry("buttonForeground", cs->buttonTxt );
+ config->writeEntry("buttonBackground", cs->button );
+ config->writeEntry("activeTitleBtnBg", cs->aTitleBtn);
+ config->writeEntry("inactiveTitleBtnBg", cs->iTitleBtn);
+ config->writeEntry("frame", cs->aFrame);
+ config->writeEntry("inactiveFrame", cs->iaFrame);
+ config->writeEntry("handle", cs->aHandle);
+ config->writeEntry("inactiveHandle", cs->iaHandle);
+ config->writeEntry("linkColor", cs->link);
+ config->writeEntry("visitedLinkColor", cs->visitedLink);
+ config->writeEntry("alternateBackground", cs->alternateBackground);
+ config->writeEntry("shadeSortColumn", cs->shadeSortColumn);
+
+ delete config;
+}
+
+
+void KColorScheme::slotRemove()
+{
+ uint ind = sList->currentItem();
+ KColorSchemeEntry *entry = mSchemeList->at(ind-nSysSchemes);
+ if (!entry) return;
+
+ if (unlink(QFile::encodeName(entry->path).data())) {
+ KMessageBox::error( 0,
+ i18n("This color scheme could not be removed.\n"
+ "Perhaps you do not have permission to alter the file"
+ "system where the color scheme is stored." ));
+ return;
+ }
+
+ sList->removeItem(ind);
+ mSchemeList->remove(entry);
+
+ ind = sList->currentItem();
+ entry = mSchemeList->at(ind-nSysSchemes);
+ if (!entry) return;
+ removeBt->setEnabled(entry ? entry->local : false);
+}
+
+
+/*
+ * Add a local color scheme.
+ */
+void KColorScheme::slotAdd()
+{
+ QString sName;
+ if (sList->currentItem() >= nSysSchemes)
+ sName = sList->currentText();
+
+ QString sFile;
+
+ bool valid = false;
+ bool ok;
+ int exists = -1;
+
+ while (!valid)
+ {
+ sName = KInputDialog::getText( i18n( "Save Color Scheme" ),
+ i18n( "Enter a name for the color scheme:" ), sName, &ok, this );
+ if (!ok)
+ return;
+
+ sName = sName.simplifyWhiteSpace();
+ sFile = sName;
+
+ int i = 0;
+
+ exists = -1;
+ // Check if it's already there
+ for (i=0; i < (int) sList->count(); i++)
+ {
+ if (sName == sList->text(i))
+ {
+ exists = i;
+ int result = KMessageBox::warningContinueCancel( this,
+ i18n("A color scheme with the name '%1' already exists.\n"
+ "Do you want to overwrite it?\n").arg(sName),
+ i18n("Save Color Scheme"),
+ i18n("Overwrite"));
+ if (result == KMessageBox::Cancel)
+ break;
+ }
+ }
+ if (i == (int) sList->count())
+ valid = true;
+ }
+
+ disconnect(sList, SIGNAL(highlighted(int)), this,
+ SLOT(slotPreviewScheme(int)));
+
+ if (exists != -1)
+ {
+ sList->setFocus();
+ sList->setCurrentItem(exists);
+ }
+ else
+ {
+ sFile = KGlobal::dirs()->saveLocation("data", "kdisplay/color-schemes/") + sFile + ".kcsrc";
+ KSimpleConfig *config = new KSimpleConfig(sFile);
+ config->setGroup( "Color Scheme");
+ config->writeEntry("Name", sName);
+ delete config;
+
+ insertEntry(sFile, sName);
+
+ }
+ slotSave();
+
+ QPixmap preview = mkColorPreview(cs);
+ int current = sList->currentItem();
+ sList->changeItem(preview, sList->text(current), current);
+ connect(sList, SIGNAL(highlighted(int)), SLOT(slotPreviewScheme(int)));
+ slotPreviewScheme(current);
+}
+
+void KColorScheme::slotImport()
+{
+ QString location = locateLocal( "data", "kdisplay/color-schemes/" );
+
+ KURL file ( KFileDialog::getOpenFileName(QString::null, "*.kcsrc", this) );
+ if ( file.isEmpty() )
+ return;
+
+ //kdDebug() << "Location: " << location << endl;
+ if (!KIO::NetAccess::file_copy(file, KURL( location+file.fileName( false ) ) ) )
+ {
+ KMessageBox::error(this, KIO::NetAccess::lastErrorString(),i18n("Import failed."));
+ return;
+ }
+ else
+ {
+ QString sFile = location + file.fileName( false );
+ KSimpleConfig *config = new KSimpleConfig(sFile);
+ config->setGroup( "Color Scheme");
+ QString sName = config->readEntry("Name", i18n("Untitled Theme"));
+ delete config;
+
+
+ insertEntry(sFile, sName);
+ QPixmap preview = mkColorPreview(cs);
+ int current = sList->currentItem();
+ sList->changeItem(preview, sList->text(current), current);
+ connect(sList, SIGNAL(highlighted(int)), SLOT(slotPreviewScheme(int)));
+ slotPreviewScheme(current);
+ }
+}
+
+QColor &KColorScheme::color(int index)
+{
+ switch(index) {
+ case CSM_Inactive_title_bar:
+ return cs->iaTitle;
+ case CSM_Inactive_title_text:
+ return cs->iaTxt;
+ case CSM_Inactive_title_blend:
+ return cs->iaBlend;
+ case CSM_Active_title_bar:
+ return cs->aTitle;
+ case CSM_Active_title_text:
+ return cs->aTxt;
+ case CSM_Active_title_blend:
+ return cs->aBlend;
+ case CSM_Background:
+ return cs->back;
+ case CSM_Text:
+ return cs->txt;
+ case CSM_Select_background:
+ return cs->select;
+ case CSM_Select_text:
+ return cs->selectTxt;
+ case CSM_Standard_background:
+ return cs->window;
+ case CSM_Standard_text:
+ return cs->windowTxt;
+ case CSM_Button_background:
+ return cs->button;
+ case CSM_Button_text:
+ return cs->buttonTxt;
+ case CSM_Active_title_button:
+ return cs->aTitleBtn;
+ case CSM_Inactive_title_button:
+ return cs->iTitleBtn;
+ case CSM_Active_frame:
+ return cs->aFrame;
+ case CSM_Active_handle:
+ return cs->aHandle;
+ case CSM_Inactive_frame:
+ return cs->iaFrame;
+ case CSM_Inactive_handle:
+ return cs->iaHandle;
+ case CSM_Link:
+ return cs->link;
+ case CSM_Followed_Link:
+ return cs->visitedLink;
+ case CSM_Alternate_background:
+ return cs->alternateBackground;
+ }
+
+ assert(0); // Should never be here!
+ return cs->iaTxt; // Silence compiler
+}
+
+
+void KColorScheme::slotSelectColor(const QColor &col)
+{
+ int selection;
+ selection = wcCombo->currentItem();
+
+ // Adjust the alternate background color if the standard color changes
+ // Only if the previous alternate color was not a user-configured one
+ // of course
+ if ( selection == CSM_Standard_background &&
+ color(CSM_Alternate_background) ==
+ KGlobalSettings::calculateAlternateBackgroundColor(
+ color(CSM_Standard_background) ) )
+ {
+ color(CSM_Alternate_background) =
+ KGlobalSettings::calculateAlternateBackgroundColor( col );
+ }
+
+ color(selection) = col;
+
+ cs->drawSampleWidgets();
+
+ sCurrentScheme = QString::null;
+
+ emit changed(true);
+}
+
+
+void KColorScheme::slotWidgetColor(int indx)
+{
+ if (indx < 0)
+ indx = 0;
+ if (wcCombo->currentItem() != indx)
+ wcCombo->setCurrentItem( indx );
+
+ // Do not emit KCModule::changed()
+ colorButton->blockSignals( true );
+
+ QColor col = color(indx);
+ colorButton->setColor( col );
+ colorPushColor = col;
+
+ colorButton->blockSignals( false );
+}
+
+
+void KColorScheme::slotColorForWidget(int indx, const QColor& col)
+{
+ if (wcCombo->currentItem() != indx)
+ wcCombo->setCurrentItem( indx );
+
+ slotSelectColor(col);
+}
+
+void KColorScheme::slotShadeSortColumnChanged(bool b)
+{
+ cs->shadeSortColumn = b;
+ sCurrentScheme = QString::null;
+
+ emit changed(true);
+}
+
+/*
+ * Read a color scheme into "cs".
+ *
+ * KEEP IN SYNC with thememgr!
+ */
+void KColorScheme::readScheme( int index )
+{
+ KConfigBase* config;
+
+ QColor widget(239, 239, 239);
+ QColor kde34Blue(103,141,178);
+ QColor inactiveBackground(157,170,186);
+ QColor activeBackground(65,142,220);
+ QColor inactiveForeground(221,221,221);
+ QColor activeBlend(107,145,184);
+ QColor inactiveBlend(157,170,186);
+ QColor activeTitleBtnBg(220,220,220);
+ QColor inactiveTitleBtnBg(220,220,220);
+ QColor alternateBackground(237,244,249);
+
+ QColor button;
+ if (QPixmap::defaultDepth() > 8)
+ button.setRgb(221, 223, 228 );
+ else
+ button.setRgb(220, 220, 220);
+
+ QColor link(0, 0, 238);
+ QColor visitedLink(82, 24,139);
+
+ // note: keep default color scheme in sync with default Current Scheme
+ if (index == 1) {
+ sCurrentScheme = "<default>";
+ cs->txt = black;
+ cs->back = widget;
+ cs->select = kde34Blue;
+ cs->selectTxt = white;
+ cs->window = white;
+ cs->windowTxt = black;
+ cs->iaTitle = inactiveBackground;
+ cs->iaTxt = inactiveForeground;
+ cs->iaBlend = inactiveBlend;
+ cs->aTitle = activeBackground;
+ cs->aTxt = white;
+ cs->aBlend = activeBlend;
+ cs->button = button;
+ cs->buttonTxt = black;
+ cs->aTitleBtn = activeTitleBtnBg;
+ cs->iTitleBtn = inactiveTitleBtnBg;
+ cs->aFrame = cs->back;
+ cs->aHandle = cs->back;
+ cs->iaFrame = cs->back;
+ cs->iaHandle = cs->back;
+ cs->link = link;
+ cs->visitedLink = visitedLink;
+ cs->alternateBackground = alternateBackground;
+
+ cs->contrast = 7;
+ cs->shadeSortColumn = KDE_DEFAULT_SHADE_SORT_COLUMN;
+
+ return;
+ }
+
+ if (index == 0) {
+ // Current scheme
+ config = KGlobal::config();
+ config->setGroup("General");
+ } else {
+ // Open scheme file
+ KColorSchemeEntry *entry = mSchemeList->at(sList->currentItem()-nSysSchemes);
+ if (!entry) return;
+ sCurrentScheme = entry->path;
+ config = new KSimpleConfig(sCurrentScheme, true);
+ config->setGroup("Color Scheme");
+ int i = sCurrentScheme.findRev('/');
+ if (i >= 0)
+ sCurrentScheme = sCurrentScheme.mid(i+1);
+ }
+
+ cs->shadeSortColumn = config->readBoolEntry( "shadeSortColumn", KDE_DEFAULT_SHADE_SORT_COLUMN );
+
+ // note: defaults should be the same as the KDE default
+ cs->txt = config->readColorEntry( "foreground", &black );
+ cs->back = config->readColorEntry( "background", &widget );
+ cs->select = config->readColorEntry( "selectBackground", &kde34Blue );
+ cs->selectTxt = config->readColorEntry( "selectForeground", &white );
+ cs->window = config->readColorEntry( "windowBackground", &white );
+ cs->windowTxt = config->readColorEntry( "windowForeground", &black );
+ cs->button = config->readColorEntry( "buttonBackground", &button );
+ cs->buttonTxt = config->readColorEntry( "buttonForeground", &black );
+ cs->link = config->readColorEntry( "linkColor", &link );
+ cs->visitedLink = config->readColorEntry( "visitedLinkColor", &visitedLink );
+ QColor alternate = KGlobalSettings::calculateAlternateBackgroundColor(cs->window);
+ cs->alternateBackground = config->readColorEntry( "alternateBackground", &alternate );
+
+ if (index == 0)
+ config->setGroup( "WM" );
+
+ cs->iaTitle = config->readColorEntry("inactiveBackground", &inactiveBackground);
+ cs->iaTxt = config->readColorEntry("inactiveForeground", &inactiveForeground);
+ cs->iaBlend = config->readColorEntry("inactiveBlend", &inactiveBackground);
+ cs->iaFrame = config->readColorEntry("inactiveFrame", &cs->back);
+ cs->iaHandle = config->readColorEntry("inactiveHandle", &cs->back);
+ cs->aTitle = config->readColorEntry("activeBackground", &activeBackground);
+ cs->aTxt = config->readColorEntry("activeForeground", &white);
+ cs->aBlend = config->readColorEntry("activeBlend", &activeBlend);
+ cs->aFrame = config->readColorEntry("frame", &cs->back);
+ cs->aHandle = config->readColorEntry("handle", &cs->back);
+ // hack - this is all going away. For now just set all to button bg
+ cs->aTitleBtn = config->readColorEntry("activeTitleBtnBg", &activeTitleBtnBg);
+ cs->iTitleBtn = config->readColorEntry("inactiveTitleBtnBg", &inactiveTitleBtnBg);
+
+ if (index == 0)
+ config->setGroup( "KDE" );
+
+ cs->contrast = config->readNumEntry( "contrast", 7 );
+ if (index != 0)
+ delete config;
+}
+
+
+/*
+ * Get all installed color schemes.
+ */
+void KColorScheme::readSchemeNames()
+{
+ mSchemeList->clear();
+ sList->clear();
+ // Always a current and a default scheme
+ sList->insertItem( i18n("Current Scheme"), 0 );
+ sList->insertItem( i18n("KDE Default"), 1 );
+ nSysSchemes = 2;
+
+ // Global + local schemes
+ QStringList list = KGlobal::dirs()->findAllResources("data",
+ "kdisplay/color-schemes/*.kcsrc", false, true);
+
+ // And add them
+ for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
+ KSimpleConfig *config = new KSimpleConfig(*it);
+ config->setGroup("Color Scheme");
+ QString str = config->readEntry("Name");
+ if (str.isEmpty()) {
+ str = config->readEntry("name");
+ if (str.isEmpty())
+ continue;
+ }
+ mSchemeList->append(new KColorSchemeEntry(*it, str, !config->isImmutable()));
+ delete config;
+ }
+
+ mSchemeList->sort();
+
+ for(KColorSchemeEntry *entry = mSchemeList->first(); entry; entry = mSchemeList->next())
+ {
+ sList->insertItem(entry->name);
+ }
+
+ for (uint i = 0; i < (nSysSchemes + mSchemeList->count()); i++)
+ {
+ sList->setCurrentItem(i);
+ readScheme(i);
+ QPixmap preview = mkColorPreview(cs);
+ sList->changeItem(preview, sList->text(i), i);
+ }
+
+}
+
+/*
+ * Find scheme based on filename
+ */
+int KColorScheme::findSchemeByName(const QString &scheme)
+{
+ if (scheme.isEmpty())
+ return 0;
+ if (scheme == "<default>")
+ return 1;
+
+ QString search = scheme;
+ int i = search.findRev('/');
+ if (i >= 0)
+ search = search.mid(i+1);
+
+ i = 0;
+
+ for(KColorSchemeEntry *entry = mSchemeList->first(); entry; entry = mSchemeList->next())
+ {
+ KURL url;
+ url.setPath(entry->path);
+ if (url.fileName() == search)
+ return i+nSysSchemes;
+ i++;
+ }
+
+ return 0;
+}
+
+
+void KColorScheme::slotPreviewScheme(int indx)
+{
+ readScheme(indx);
+
+ // Set various appropriate for the scheme
+
+ cbShadeList->setChecked(cs->shadeSortColumn);
+
+ cs->drawSampleWidgets();
+ sb->blockSignals(true);
+ sb->setValue(cs->contrast);
+ sb->blockSignals(false);
+ slotWidgetColor(wcCombo->currentItem());
+ if (indx < nSysSchemes)
+ removeBt->setEnabled(false);
+ else
+ {
+ KColorSchemeEntry *entry = mSchemeList->at(indx-nSysSchemes);
+ removeBt->setEnabled(entry ? entry->local : false);
+ }
+
+ emit changed((indx != 0));
+}
+
+
+/* this function should dissappear: colorscm should work directly on a Qt palette, since
+ this will give us much more cusomization with qt-2.0.
+ */
+QPalette KColorScheme::createPalette()
+{
+ QColorGroup disabledgrp(cs->windowTxt, cs->back, cs->back.light(150),
+ cs->back.dark(), cs->back.dark(120), cs->back.dark(120),
+ cs->window);
+
+ QColorGroup colgrp(cs->windowTxt, cs->back, cs->back.light(150),
+ cs->back.dark(), cs->back.dark(120), cs->txt, cs->window);
+
+ colgrp.setColor(QColorGroup::Highlight, cs->select);
+ colgrp.setColor(QColorGroup::HighlightedText, cs->selectTxt);
+ colgrp.setColor(QColorGroup::Button, cs->button);
+ colgrp.setColor(QColorGroup::ButtonText, cs->buttonTxt);
+ return QPalette( colgrp, disabledgrp, colgrp);
+}
+
+void KColorScheme::insertEntry(const QString &sFile, const QString &sName)
+{
+ KColorSchemeEntry *newEntry = new KColorSchemeEntry(sFile, sName, true);
+ mSchemeList->inSort(newEntry);
+ int newIndex = mSchemeList->findRef(newEntry)+nSysSchemes;
+ sList->insertItem(sName, newIndex);
+ sList->setCurrentItem(newIndex);
+}
+
+#include "colorscm.moc"
diff --git a/kcontrol/colors/colorscm.h b/kcontrol/colors/colorscm.h
new file mode 100644
index 000000000..23b47c6a0
--- /dev/null
+++ b/kcontrol/colors/colorscm.h
@@ -0,0 +1,90 @@
+//-----------------------------------------------------------------------------
+//
+// KDE Display color scheme setup module
+//
+// Copyright (c) Mark Donohoe 1997
+//
+
+#ifndef __COLORSCM_H__
+#define __COLORSCM_H__
+
+#include <qcolor.h>
+#include <qobject.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+#include <kcmodule.h>
+#include <kdialogbase.h>
+
+#include "widgetcanvas.h"
+
+class QSlider;
+class QComboBox;
+class QPushButton;
+class QCheckBox;
+class QResizeEvent;
+class KLineEdit;
+class QPalette;
+class KListBox;
+class KColorButton;
+class KConfig;
+class KStdDirs;
+class KColorSchemeList;
+
+/**
+ * The Desktop/Colors tab in kcontrol.
+ */
+class KColorScheme: public KCModule
+{
+ Q_OBJECT
+
+public:
+ KColorScheme(QWidget *parent, const char *name, const QStringList &);
+ ~KColorScheme();
+
+ virtual void load();
+ virtual void load( bool useDefaults );
+ virtual void save();
+ virtual void defaults();
+
+private slots:
+ void sliderValueChanged(int val);
+ void slotSave();
+ void slotAdd();
+ void slotRemove();
+ void slotImport();
+ void slotSelectColor(const QColor &col);
+ void slotWidgetColor(int);
+ void slotColorForWidget(int, const QColor &);
+ void slotPreviewScheme(int);
+ void slotShadeSortColumnChanged(bool);
+
+private:
+ void setColorName( const QString &name, int id );
+ void readScheme(int index=0);
+ void readSchemeNames();
+ void insertEntry(const QString &sFile, const QString &sName);
+ int findSchemeByName(const QString &scheme);
+ QPalette createPalette();
+
+ QColor &color(int index);
+
+ int nSysSchemes;
+ bool useRM;
+
+ QColor colorPushColor;
+ QSlider *sb;
+ QComboBox *wcCombo;
+ QPushButton *addBt, *removeBt, *importBt;
+ KListBox *sList;
+ KColorSchemeList *mSchemeList;
+ QString sCurrentScheme;
+
+ KColorButton *colorButton;
+ WidgetCanvas *cs;
+
+ QCheckBox *cbExportColors;
+ QCheckBox *cbShadeList;
+};
+
+#endif
diff --git a/kcontrol/colors/stdclient_bitmaps.h b/kcontrol/colors/stdclient_bitmaps.h
new file mode 100644
index 000000000..912040fe2
--- /dev/null
+++ b/kcontrol/colors/stdclient_bitmaps.h
@@ -0,0 +1,128 @@
+#ifndef __STDCLIENT_BITMAPS_H
+#define __STDCLIENT_BITMAPS_H
+
+/**
+ * The standard client has the capability to color it's titlebar buttons
+ * according to the new color scheme. In order to do this it needs a bitmap
+ * for each shade which it draws into a pixmap with the appropriate color.
+ * These are all the bitmaps.
+ */
+
+static unsigned char close_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x02,
+ 0x20, 0x01, 0x40, 0x00, 0x40, 0x00, 0x20, 0x01, 0x10, 0x02, 0x08, 0x04,
+ 0x04, 0x08, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char close_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x18, 0x30, 0x30, 0x18, 0x60, 0x0c,
+ 0xc0, 0x06, 0x80, 0x03, 0x80, 0x03, 0xc0, 0x06, 0x60, 0x0c, 0x30, 0x18,
+ 0x18, 0x30, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char close_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x0c, 0x30, 0x1c, 0x38, 0x38, 0x1c, 0x70, 0x0e,
+ 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0x70, 0x0e, 0x38, 0x1c,
+ 0x1c, 0x38, 0x0c, 0x30, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char iconify_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x03, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char iconify_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+
+static unsigned char iconify_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x03, 0x80, 0x02, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximize_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x04, 0x00, 0x04, 0x08, 0x04, 0x08,
+ 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0xf4, 0x0f,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximize_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x08, 0x10, 0x08, 0x10,
+ 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10,
+ 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximize_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0xfc, 0x1f, 0x0c, 0x18, 0x0c, 0x18,
+ 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0xfc, 0x1f,
+ 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximizedown_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x08, 0x10,
+ 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10,
+ 0x08, 0x10, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximizedown_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0x04, 0x00, 0x04, 0x08,
+ 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04, 0x08, 0x04, 0x08,
+ 0xf4, 0x0f, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char maximizedown_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0xfc, 0x1f, 0x0c, 0x18,
+ 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18, 0x0c, 0x18,
+ 0xfc, 0x1f, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char menu_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0x3f, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char menu_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x20, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char menu_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pindown_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x1f, 0xa0, 0x03,
+ 0xb0, 0x01, 0x30, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pindown_gray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
+ 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x80, 0x07, 0xc0, 0x03, 0xe0, 0x01,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pindown_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x10, 0x70, 0x20, 0x50, 0x20,
+ 0x48, 0x30, 0xc8, 0x38, 0x08, 0x1f, 0x08, 0x18, 0x10, 0x1c, 0x10, 0x0e,
+ 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pindown_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x1f, 0xf0, 0x3f, 0xf0, 0x3f,
+ 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x1f, 0xf0, 0x0f,
+ 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pinup_white_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x11,
+ 0x3f, 0x15, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pinup_gray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x80, 0x0a, 0xbf, 0x0a, 0x80, 0x15, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pinup_dgray_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x40, 0x31, 0x40, 0x2e,
+ 0x40, 0x20, 0x40, 0x20, 0x7f, 0x2a, 0x40, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+static unsigned char pinup_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0xc0, 0x31, 0xc0, 0x3f,
+ 0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xc0, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+
+#endif
diff --git a/kcontrol/colors/widgetcanvas.cpp b/kcontrol/colors/widgetcanvas.cpp
new file mode 100644
index 000000000..42adcc3bb
--- /dev/null
+++ b/kcontrol/colors/widgetcanvas.cpp
@@ -0,0 +1,596 @@
+//
+// A special widget which draws a sample of KDE widgets
+// It is used to preview color schemes
+//
+// Copyright (c) Mark Donohoe 1998
+//
+
+#include <qdrawutil.h>
+#include <qpainter.h>
+#include <qscrollbar.h>
+#include <qbitmap.h>
+#include <qtooltip.h>
+#include <qstyle.h>
+#include <qpopupmenu.h>
+
+#include <kcolordrag.h>
+#include <kpixmapeffect.h>
+#include <kglobalsettings.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kpixmap.h>
+
+#include "widgetcanvas.h"
+#include "widgetcanvas.moc"
+#include "stdclient_bitmaps.h"
+
+static QPixmap* close_pix = 0;
+static QPixmap* maximize_pix = 0;
+static QPixmap* minimize_pix = 0;
+static QPixmap* normalize_pix = 0;
+static QPixmap* pinup_pix = 0;
+static QPixmap* pindown_pix = 0;
+static QPixmap* menu_pix = 0;
+
+static QPixmap* dis_close_pix = 0;
+static QPixmap* dis_maximize_pix = 0;
+static QPixmap* dis_minimize_pix = 0;
+static QPixmap* dis_normalize_pix = 0;
+static QPixmap* dis_pinup_pix = 0;
+static QPixmap* dis_pindown_pix = 0;
+static QPixmap* dis_menu_pix = 0;
+
+
+WidgetCanvas::WidgetCanvas( QWidget *parent, const char *name )
+ : QWidget( parent, name ), shadeSortColumn( true )
+{
+ setMouseTracking( true );
+ setBackgroundMode( NoBackground );
+ setAcceptDrops( true);
+ setMinimumSize(200, 100);
+ currentHotspot = -1;
+}
+
+void WidgetCanvas::addToolTip( int area, const QString &tip )
+{
+ tips.insert(area, tip);
+}
+
+void WidgetCanvas::paintEvent(QPaintEvent *)
+{
+ bitBlt( this, 0, 0, &smplw );
+}
+
+void WidgetCanvas::mousePressEvent( QMouseEvent *me )
+{
+ for ( int i = 0; i < MAX_HOTSPOTS; i++ )
+ if ( hotspots[i].rect.contains( me->pos() ) ) {
+ emit widgetSelected( hotspots[i].number );
+ return;
+ }
+}
+
+void WidgetCanvas::mouseMoveEvent( QMouseEvent *me )
+{
+ for ( int i = 0; i < MAX_HOTSPOTS; i++ )
+ if ( hotspots[i].rect.contains( me->pos() ) ) {
+ if ( i != currentHotspot ) {
+ QString tip = tips[hotspots[i].number];
+ QToolTip::remove( this );
+ QToolTip::add( this, tip );
+ currentHotspot = i;
+ }
+ return;
+ }
+
+ QToolTip::remove( this );
+}
+
+void WidgetCanvas::dropEvent( QDropEvent *e)
+{
+ QColor c;
+ if (KColorDrag::decode( e, c)) {
+ for ( int i = 0; i < MAX_HOTSPOTS; i++ )
+ if ( hotspots[i].rect.contains( e->pos() ) ) {
+ emit colorDropped( hotspots[i].number, c);
+ return;
+ }
+ }
+}
+
+
+void WidgetCanvas::dragEnterEvent( QDragEnterEvent *e)
+{
+ e->accept( KColorDrag::canDecode( e));
+}
+
+void WidgetCanvas::paletteChange(const QPalette &)
+{
+ drawSampleWidgets();
+}
+
+void WidgetCanvas::resizeEvent(QResizeEvent *)
+{
+ drawSampleWidgets();
+}
+
+/*
+ * This is necessary because otherwise the scrollbar in drawSampleWidgets()
+ * doesn't show the first time.
+ */
+void WidgetCanvas::showEvent(QShowEvent *)
+{
+ drawSampleWidgets();
+}
+
+void WidgetCanvas::resetTitlebarPixmaps(const QColor &actMed,
+ const QColor &disMed)
+{
+ if(close_pix) delete close_pix;
+ if(maximize_pix) delete maximize_pix;
+ if(minimize_pix) delete minimize_pix;
+ if(normalize_pix) delete normalize_pix;
+ if(pinup_pix) delete pinup_pix;
+ if(pindown_pix) delete pindown_pix;
+ if(menu_pix) delete menu_pix;
+
+ if(dis_close_pix) delete dis_close_pix;
+ if(dis_maximize_pix) delete dis_maximize_pix;
+ if(dis_minimize_pix) delete dis_minimize_pix;
+ if(dis_normalize_pix) delete dis_normalize_pix;
+ if(dis_pinup_pix) delete dis_pinup_pix;
+ if(dis_pindown_pix) delete dis_pindown_pix;
+ if(dis_menu_pix) delete dis_menu_pix;
+
+ QPainter pact, pdis;
+ QBitmap bitmap;
+ QColor actHigh = actMed.light(150);
+ QColor actLow = actMed.dark(120);
+ QColor disHigh = disMed.light(150);
+ QColor disLow = disMed.dark(120);
+
+ close_pix = new QPixmap(16, 16);
+ dis_close_pix = new QPixmap(16, 16);
+ pact.begin(close_pix); pdis.begin(dis_close_pix);
+ bitmap = QBitmap(16, 16, close_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, close_dgray_bits, true);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, close_mask_bits, true);
+ close_pix->setMask(bitmap); dis_close_pix->setMask(bitmap);
+
+ minimize_pix = new QPixmap(16, 16);
+ dis_minimize_pix = new QPixmap(16, 16);
+ pact.begin(minimize_pix); pdis.begin(dis_minimize_pix);
+ bitmap = QBitmap(16, 16, iconify_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, iconify_dgray_bits, true);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, iconify_mask_bits, true);
+ minimize_pix->setMask(bitmap); dis_minimize_pix->setMask(bitmap);
+
+ maximize_pix = new QPixmap(16, 16);
+ dis_maximize_pix = new QPixmap(16, 16);
+ pact.begin(maximize_pix); pdis.begin(dis_maximize_pix);
+ bitmap = QBitmap(16, 16, maximize_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, maximize_dgray_bits, true);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, maximize_mask_bits, true);
+ maximize_pix->setMask(bitmap); dis_maximize_pix->setMask(bitmap);
+
+ normalize_pix = new QPixmap(16, 16);
+ dis_normalize_pix = new QPixmap(16, 16);
+ pact.begin(normalize_pix); pdis.begin(dis_normalize_pix);
+ bitmap = QBitmap(16, 16, maximizedown_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, maximizedown_dgray_bits, true);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, maximizedown_mask_bits, true);
+ normalize_pix->setMask(bitmap); dis_normalize_pix->setMask(bitmap);
+
+ menu_pix = new QPixmap(16, 16);
+ dis_menu_pix = new QPixmap(16, 16);
+ pact.begin(menu_pix); pdis.begin(dis_menu_pix);
+ bitmap = QBitmap(16, 16, menu_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, menu_dgray_bits, true);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, menu_mask_bits, true);
+ menu_pix->setMask(bitmap); dis_menu_pix->setMask(bitmap);
+
+ pinup_pix = new QPixmap(16, 16);
+ dis_pinup_pix = new QPixmap(16, 16);
+ pact.begin(pinup_pix); pdis.begin(dis_pinup_pix);
+ bitmap = QBitmap(16, 16, pinup_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, pinup_gray_bits, true);
+ pact.setPen(actMed); pdis.setPen(disMed);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, pinup_dgray_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, pinup_mask_bits, true);
+ pinup_pix->setMask(bitmap); dis_pinup_pix->setMask(bitmap);
+
+ pindown_pix = new QPixmap(16, 16);
+ dis_pindown_pix = new QPixmap(16, 16);
+ pact.begin(pindown_pix); pdis.begin(dis_pindown_pix);
+ bitmap = QBitmap(16, 16, pindown_white_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actHigh); pdis.setPen(disHigh);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, pindown_gray_bits, true);
+ pact.setPen(actMed); pdis.setPen(disMed);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ bitmap = QBitmap(16, 16, pindown_dgray_bits, true);
+ bitmap.setMask(bitmap);
+ pact.setPen(actLow); pdis.setPen(disLow);
+ pact.drawPixmap(0, 0, bitmap);
+ pdis.drawPixmap(0, 0, bitmap);
+ pact.end(); pdis.end();
+ bitmap = QBitmap(16, 16, pindown_mask_bits, true);
+ pindown_pix->setMask(bitmap); dis_pindown_pix->setMask(bitmap);
+
+}
+
+void WidgetCanvas::drawSampleWidgets()
+{
+ int textLen, tmp;
+ int highlightVal, lowlightVal;
+
+ KConfig * c = new KConfig("kcmfonts");
+
+ // Keep in sync with kglobalsettings.
+
+ QFont windowFontGuess(KGlobalSettings::generalFont().family(), 12, QFont::SansSerif, true);
+ windowFontGuess.setPixelSize(12);
+
+ c->setGroup("WM");
+ QFont windowFont = c->readFontEntry("activeFont", &windowFontGuess);
+
+ c->setGroup("General");
+ QFont defaultMenuFont = KGlobalSettings::menuFont();
+ QFont menuFont = c->readFontEntry("menuFont", &defaultMenuFont);
+
+ delete c;
+ c = 0;
+
+ // Calculate the highlight and lowloght from contrast value and create
+ // color group from color scheme.
+
+ highlightVal=100+(2*contrast+4)*16/10;
+ lowlightVal=100+(2*contrast+4)*10;
+
+ QColorGroup cg( txt, back,
+ back.light(highlightVal),
+ back.dark(lowlightVal),
+ back.dark(120),
+ txt, window );
+
+ // We will need this brush.
+
+ QBrush brush(SolidPattern);
+ brush.setColor( back );
+
+ // Create a scrollbar and redirect drawing into a temp. pixmap to save a
+ // lot of fiddly drawing later.
+
+ QScrollBar *vertScrollBar = new QScrollBar( QScrollBar::Vertical, this );
+ // TODO: vertScrollBar->setStyle( new QMotifStyle() );
+ vertScrollBar->setGeometry( 400, 400, SCROLLBAR_SIZE, height());
+ vertScrollBar->setRange( 0, 0 );
+ vertScrollBar->setPalette( QPalette(cg,cg,cg));
+ vertScrollBar->show();
+
+ QPixmap pm( vertScrollBar->width(), vertScrollBar->height() );
+ pm.fill( back );
+#ifndef __osf__
+ QPainter::redirect( vertScrollBar, &pm );
+#endif
+ vertScrollBar->repaint();
+ QPainter::redirect( vertScrollBar, 0 );
+ vertScrollBar->hide();
+
+ // Reset the titlebar pixmaps
+ resetTitlebarPixmaps(aTitleBtn, iTitleBtn);
+
+ // Initialize the pixmap which we draw sample widgets into.
+
+ smplw.resize(width(), height());
+ //smplw.fill( parentWidget()->back() );
+ smplw.fill( parentWidget()->colorGroup().mid() );
+
+ // Actually start painting in
+
+ QPainter paint( &smplw );
+
+ // Inactive window
+
+ qDrawWinPanel ( &paint, 15, 5, width()-48, height(), cg, FALSE,
+ &brush);
+
+ paint.setBrush( iaTitle );
+ paint.setPen( iaTitle );
+ //paint.drawRect( 20, 10, width()-60, 20 );
+
+ KPixmap pmTitle;
+ pmTitle.resize( width()-160, 20 );
+
+ // Switched to vertical gradient because those kwin styles that
+ // use the gradient have it vertical.
+ KPixmapEffect::gradient(pmTitle, iaTitle, iaBlend,
+ KPixmapEffect::HorizontalGradient);
+ paint.drawPixmap( 60, 10, pmTitle );
+
+
+ paint.setFont( windowFont );
+ paint.setPen( iaTxt );
+ paint.drawText( 65, 25, i18n("Inactive window") );
+ textLen = paint.fontMetrics().width( i18n("Inactive window") );
+
+ tmp = width()-100;
+ paint.drawPixmap(22, 12, *dis_menu_pix);
+ paint.drawPixmap(42, 12, *dis_pinup_pix);
+ paint.drawPixmap(tmp+2, 12, *dis_minimize_pix);
+ paint.drawPixmap(tmp+22, 12, *dis_maximize_pix);
+ paint.drawPixmap(tmp+42, 12, *dis_close_pix);
+
+ int spot = 0;
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 65, 25-14, textLen, 14 ), CSM_Inactive_title_text );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 60, 10, (width()-160)/2, 20 ), CSM_Inactive_title_bar );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 60+(width()-160)/2, 10,
+ (width()-160)/2, 20 ), CSM_Inactive_title_blend );
+
+ hotspots[spot++] =
+ HotSpot(QRect(20, 12, 40, 20), CSM_Inactive_title_button);
+ hotspots[spot++] =
+ HotSpot(QRect(tmp, 12, 60, 20), CSM_Inactive_title_button);
+
+
+ // Active window
+
+ qDrawWinPanel ( &paint, 20, 25+5, width()-40, height(), cg, FALSE,
+ &brush);
+
+ paint.setBrush( aTitle );paint.setPen( aTitle );
+ paint.drawRect( 65, 30+5, width()-152, 20 );
+
+ // Switched to vertical gradient because those kwin styles that
+ // use the gradient have it vertical.
+ pmTitle.resize( width()-152, 20 );
+ KPixmapEffect::gradient(pmTitle, aTitle, aBlend,
+ KPixmapEffect::HorizontalGradient);
+ paint.drawPixmap( 65, 35, pmTitle );
+
+ paint.setFont( windowFont );
+ paint.setPen( aTxt );
+ paint.drawText( 75, 50, i18n("Active window") );
+ textLen = paint.fontMetrics().width( i18n("Active window" ));
+
+ tmp = width()-152+65;
+ paint.drawPixmap(27, 35, *menu_pix);
+ paint.drawPixmap(47, 35, *pinup_pix);
+ paint.drawPixmap(tmp+2, 35, *minimize_pix);
+ paint.drawPixmap(tmp+22, 35, *maximize_pix);
+ paint.drawPixmap(tmp+42, 35, *close_pix);
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 75, 50-14, textLen, 14 ), CSM_Active_title_text);
+ hotspots[ spot ++] =
+ HotSpot( QRect( 65, 35, (width()-152)/2, 20 ), CSM_Active_title_bar );
+ hotspots[ spot ++] =
+ HotSpot( QRect( 65+(width()-152)/2, 35,
+ (width()-152)/2, 20 ), CSM_Active_title_blend );
+
+ hotspots[spot++] =
+ HotSpot(QRect(25, 35, 40, 20), CSM_Active_title_button);
+ hotspots[spot++] =
+ HotSpot(QRect(tmp, 35, 60, 20), CSM_Active_title_button);
+
+ // Menu bar
+
+ //qDrawShadePanel ( &paint, 25, 55, width()-52, 28, cg, FALSE, 2, &brush);
+ kapp->style().drawPrimitive(QStyle::PE_PanelMenuBar, &paint,
+ QRect(QPoint(25, 55), QSize(width()-52, 28)), cg);
+
+ paint.setFont( menuFont );
+ paint.setPen(txt );
+ QString file = i18n("File");
+ textLen = paint.fontMetrics().width( file );
+ //qDrawShadePanel ( &paint, 30, 59, textLen + 10, 21, cg, FALSE, 2, &brush);
+ kapp->style().drawPrimitive(QStyle::PE_Panel, &paint,
+ QRect(30, 59, textLen + 10, 21), cg);
+ paint.drawText( 35, 74, file );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 35, 62, textLen, 14 ), CSM_Text );
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 27, 57, 33, 21 ), CSM_Background );
+
+ paint.setFont( menuFont );
+ paint.setPen( txt );
+ paint.drawText( 35 + textLen + 20, 74, i18n("Edit") );
+ textLen = paint.fontMetrics().width( i18n("Edit") );
+
+ hotspots[ spot++ ] = HotSpot( QRect( 35 + textLen + 20, 62, textLen, 14 ), CSM_Text );
+
+ // Button Rects need to go before window
+
+ // Frame and window contents
+
+ brush.setColor( window );
+ qDrawShadePanel ( &paint, 25, 80+5-4, width()-7-45-2,
+ height(), cg, TRUE, 2, &brush);
+
+ // Standard text
+ QFont fnt = KGlobalSettings::generalFont();
+ paint.setFont( fnt );
+ paint.setPen( windowTxt );
+ paint.drawText( 140, 127-20, i18n( "Standard text") );
+ textLen = paint.fontMetrics().width( i18n("Standard text") );
+ int column2 = 120 + textLen + 40 + 16;
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 140, 113-20, textLen, 14 ), CSM_Standard_text );
+
+ // Selected text
+ textLen = paint.fontMetrics().width( i18n("Selected text") );
+ if (120 + textLen + 40 + 16 > column2)
+ column2 = 120 + textLen + 40 + 16;
+
+ paint.setBrush( select );paint.setPen( select );
+ paint.drawRect ( 120, 115, textLen+40, 32);
+
+ paint.setFont( fnt );
+ paint.setPen( selectTxt );
+ paint.drawText( 140, 135, i18n( "Selected text") );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 140, 121, textLen, 14 ), CSM_Select_text );
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 120, 115, textLen+40, 32), CSM_Select_background ); // select bg
+
+ // Link
+ paint.setPen( link );
+ paint.drawText( column2+18, 127-20, i18n( "link") );
+ textLen = paint.fontMetrics().width( i18n("link") );
+ paint.drawLine( column2+18, 109, column2+18+textLen, 109);
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( column2+18, 113-20, textLen, 17 ), CSM_Link );
+
+ int column3 = column2 + 25 + textLen;
+ // Followed Link
+ paint.setPen( visitedLink );
+ paint.drawText( column3, 127-20, i18n( "followed link") );
+ textLen = paint.fontMetrics().width( i18n("followed link") );
+ paint.drawLine( column3, 109, column3+textLen, 109);
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( column3, 113-20, textLen, 17 ), CSM_Followed_Link );
+
+ // Button
+ int xpos = column2;
+ int ypos = 115 + 2;
+ textLen = paint.fontMetrics().width(i18n("Push Button"));
+ hotspots[ spot++ ] =
+ HotSpot( QRect(xpos+16, ypos+((28-paint.fontMetrics().height())/2),
+ textLen, paint.fontMetrics().height()), CSM_Button_text );
+ hotspots[ spot++ ] =
+ HotSpot( QRect(xpos, ypos, textLen+32, 28), CSM_Button_background );
+ //brush.setColor( button );
+ QColorGroup cg2(cg);
+ cg2.setColor(QColorGroup::Button, button);
+ cg2.setColor(QColorGroup::Background, window);
+ //qDrawWinButton(&paint, xpos, ypos, textLen+32, 28, cg, false, &brush);
+ kapp->style().drawPrimitive(QStyle::PE_ButtonCommand, &paint,
+ QRect(xpos, ypos, textLen+32, 28), cg2, QStyle::Style_Enabled | QStyle::Style_Raised);
+ paint.setPen(buttonTxt);
+ paint.drawText(xpos, ypos, textLen+32, 28, AlignCenter,
+ i18n("Push Button"));
+
+ // Scrollbar
+ paint.drawPixmap(width()-55+27-16-2,80+5-2,pm);
+
+ // Menu
+
+ brush.setColor( back );
+
+ int textLenNew, textLenOpen, textLenSave;
+
+
+ textLenNew = paint.fontMetrics().width( i18n("New") );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 56, 83, textLenNew, 14 ), CSM_Text );
+
+ paint.setFont( menuFont );
+ textLenOpen = paint.fontMetrics().width( i18n("Menu item", "Open") );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 56, 105, textLenOpen, 14 ), CSM_Text );
+
+ paint.setFont( menuFont );
+ textLenSave = paint.fontMetrics().width( i18n("Menu item", "Save") );
+
+ QPopupMenu *popup = new QPopupMenu( this );
+ popup->setFont( menuFont );
+ popup->setPalette( QPalette(cg,cg,cg));
+ popup->insertItem(i18n("New"));
+ popup->insertItem(i18n("Menu item", "Open"));
+ int id = popup->insertItem(i18n("Menu item", "Save"));
+ popup->setItemEnabled( id, false );
+
+ // HACK: Force Layouting
+ //Sad Eagle: sizeHint() forces layouting too, and it's a lot less visible
+ //popup->sizeHint(); // Breaks with Qt 3.3
+ popup->resize(popup->sizeHint());
+
+ pm = QPixmap::grabWidget( popup );
+ delete popup;
+ bitBlt(&smplw, 30, 80, &pm, 0, 0, pm.width(), pm.height());
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 28, 78, 88, 77 ), CSM_Background );
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect(25, 80+5-4, width()-7-45-2-16, height()), CSM_Standard_background );
+
+
+ // Valance
+
+ qDrawWinPanel ( &paint, 0, 0, width(), height(),
+ parentWidget()->colorGroup(), TRUE, 0);
+
+ // Stop the painting
+
+ hotspots[ spot++ ] =
+ HotSpot( QRect( 0, 0, width(), height() ), CSM_Background ); // ?
+
+ repaint( FALSE );
+}
diff --git a/kcontrol/colors/widgetcanvas.h b/kcontrol/colors/widgetcanvas.h
new file mode 100644
index 000000000..e2f9bd057
--- /dev/null
+++ b/kcontrol/colors/widgetcanvas.h
@@ -0,0 +1,121 @@
+//
+// A special widget which draws a sample of KDE widgets
+// It is used to preview color schemes
+//
+// Copyright (c) Mark Donohoe 1998
+//
+
+#ifndef __WIDGETCANVAS_H__
+#define __WIDGETCANVAS_H__
+
+#include <qmap.h>
+#include <kapplication.h>
+
+#define MAX_HOTSPOTS 28
+#define SCROLLBAR_SIZE 16
+
+// These defines define the order of the colors in the combo box.
+#define CSM_Standard_background 0
+#define CSM_Standard_text 1
+#define CSM_Select_background 2
+#define CSM_Select_text 3
+#define CSM_Link 4
+#define CSM_Followed_Link 5
+#define CSM_Background 6
+#define CSM_Text 7
+#define CSM_Button_background 8
+#define CSM_Button_text 9
+#define CSM_Active_title_bar 10
+#define CSM_Active_title_text 11
+#define CSM_Active_title_blend 12
+#define CSM_Active_title_button 13
+#define CSM_Inactive_title_bar 14
+#define CSM_Inactive_title_text 15
+#define CSM_Inactive_title_blend 16
+#define CSM_Inactive_title_button 17
+#define CSM_Active_frame 18
+#define CSM_Active_handle 19
+#define CSM_Inactive_frame 20
+#define CSM_Inactive_handle 21
+#define CSM_Alternate_background 22
+#define CSM_LAST 23
+
+class QPixmap;
+class QColor;
+class QPainter;
+class QEvent;
+
+class KPixmap;
+
+class HotSpot
+{
+public:
+ HotSpot() {}
+ HotSpot( const QRect &r, int num )
+ : rect(r), number(num) {}
+
+ QRect rect;
+ int number;
+};
+
+class WidgetCanvas : public QWidget
+{
+ Q_OBJECT
+
+public:
+ WidgetCanvas( QWidget *parent=0, const char *name=0 );
+ void drawSampleWidgets();
+ void resetTitlebarPixmaps(const QColor &active,
+ const QColor &inactive);
+ void addToolTip( int area, const QString & );
+ QPixmap smplw;
+
+ QColor iaTitle;
+ QColor iaTxt;
+ QColor iaBlend;
+ QColor iaFrame;
+ QColor iaHandle;
+ QColor aTitle;
+ QColor aTxt;
+ QColor aBlend;
+ QColor aFrame;
+ QColor aHandle;
+ QColor back;
+ QColor txt;
+ QColor select;
+ QColor selectTxt;
+ QColor window;
+ QColor windowTxt;
+ QColor button;
+ QColor buttonTxt;
+ QColor aTitleBtn;
+ QColor iTitleBtn;
+ QColor link;
+ QColor visitedLink;
+ QColor alternateBackground;
+
+ int contrast;
+ bool shadeSortColumn;
+
+signals:
+ void widgetSelected( int );
+ void colorDropped( int, const QColor&);
+
+protected:
+ void redrawPopup(const QColorGroup &cg);
+
+ virtual void paintEvent( QPaintEvent * );
+ virtual void mousePressEvent( QMouseEvent * );
+ virtual void mouseMoveEvent( QMouseEvent * );
+ virtual void resizeEvent( QResizeEvent * );
+ virtual void showEvent( QShowEvent * );
+ virtual void dropEvent( QDropEvent *);
+ virtual void dragEnterEvent( QDragEnterEvent *);
+ void paletteChange( const QPalette & );
+
+ QMap<int,QString> tips;
+ HotSpot hotspots[MAX_HOTSPOTS];
+ int currentHotspot;
+};
+
+#endif