summaryrefslogtreecommitdiffstats
path: root/kcontrol/icons
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/icons
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/icons')
-rw-r--r--kcontrol/icons/Makefile.am25
-rw-r--r--kcontrol/icons/icons.cpp666
-rw-r--r--kcontrol/icons/icons.desktop249
-rw-r--r--kcontrol/icons/icons.h152
-rw-r--r--kcontrol/icons/iconthemes.cpp452
-rw-r--r--kcontrol/icons/iconthemes.h72
-rw-r--r--kcontrol/icons/main.cpp105
-rw-r--r--kcontrol/icons/main.h55
-rw-r--r--kcontrol/icons/testicons.cpp13
-rw-r--r--kcontrol/icons/uninstall.desktop2
10 files changed, 1791 insertions, 0 deletions
diff --git a/kcontrol/icons/Makefile.am b/kcontrol/icons/Makefile.am
new file mode 100644
index 000000000..4e00a730c
--- /dev/null
+++ b/kcontrol/icons/Makefile.am
@@ -0,0 +1,25 @@
+AM_CPPFLAGS = $(all_includes)
+
+kde_module_LTLIBRARIES = kcm_icons.la
+
+kcm_icons_la_SOURCES = iconthemes.cpp icons.cpp main.cpp
+kcm_icons_la_LDFLAGS = -module -avoid-version $(all_libraries) -no-undefined
+kcm_icons_la_LIBADD = $(LIB_KIO)
+
+METASOURCES = AUTO
+
+noinst_HEADERS = icons.h iconthemes.h main.h
+
+check_PROGRAMS = testicons
+testicons_SOURCES = testicons.cpp
+testicons_LDFLAGS = $(all_libraries)
+testicons_LDADD = $(LIB_KDEUI) icons.lo
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kcmicons.pot
+
+xdg_apps_DATA = icons.desktop
+
+install-data-local: uninstall.desktop
+ $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Settings/LookNFeel/Themes
+ $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(DESTDIR)$(kde_appsdir)/Settings/LookNFeel/Themes/iconthemes.desktop
diff --git a/kcontrol/icons/icons.cpp b/kcontrol/icons/icons.cpp
new file mode 100644
index 000000000..85a72e075
--- /dev/null
+++ b/kcontrol/icons/icons.cpp
@@ -0,0 +1,666 @@
+/* vi: ts=8 sts=4 sw=4
+ *
+ * This file is part of the KDE project, module kcmdisplay.
+ * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * with minor additions and based on ideas from
+ * Torsten Rahn <torsten@kde.org> *
+ *
+ * You can Freely distribute this program under the GNU General Public
+ * License. See the file "COPYING" for the exact licensing terms.
+ */
+
+#include <stdlib.h>
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qslider.h>
+
+#include <kcolorbutton.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kiconeffect.h>
+#include <kiconloader.h>
+#include <kipc.h>
+#include <klocale.h>
+#include <kseparator.h>
+
+#include "icons.h"
+
+/**** KIconConfig ****/
+
+KIconConfig::KIconConfig(QWidget *parent, const char *name)
+ : KCModule(parent, name)
+{
+
+ QGridLayout *top = new QGridLayout(this, 2, 2,
+ KDialog::marginHint(),
+ KDialog::spacingHint());
+ top->setColStretch(0, 1);
+ top->setColStretch(1, 1);
+
+ // Use of Icon at (0,0) - (1, 0)
+ QGroupBox *gbox = new QGroupBox(i18n("Use of Icon"), this);
+ top->addMultiCellWidget(gbox, 0, 1, 0, 0);
+ QBoxLayout *g_vlay = new QVBoxLayout(gbox,
+ KDialog::marginHint(),
+ KDialog::spacingHint());
+ g_vlay->addSpacing(fontMetrics().lineSpacing());
+ mpUsageList = new QListBox(gbox);
+ connect(mpUsageList, SIGNAL(highlighted(int)), SLOT(slotUsage(int)));
+ g_vlay->addWidget(mpUsageList);
+
+ KSeparator *sep = new KSeparator( KSeparator::HLine, this );
+ top->addWidget(sep, 1, 1);
+ // Preview at (2,0) - (2, 1)
+ QGridLayout *g_lay = new QGridLayout(4, 3, KDialog::marginHint(), 0);
+ top->addMultiCellLayout(g_lay, 2, 2, 0, 1);
+ g_lay->addRowSpacing(0, fontMetrics().lineSpacing());
+
+ QPushButton *push;
+
+ push = addPreviewIcon(0, i18n("Default"), this, g_lay);
+ connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup0()));
+ push = addPreviewIcon(1, i18n("Active"), this, g_lay);
+ connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup1()));
+ push = addPreviewIcon(2, i18n("Disabled"), this, g_lay);
+ connect(push, SIGNAL(clicked()), SLOT(slotEffectSetup2()));
+
+ m_pTab1 = new QWidget(this, "General Tab");
+ top->addWidget(m_pTab1, 0, 1);
+
+ QGridLayout *grid = new QGridLayout(m_pTab1, 4, 3, 10, 10);
+ grid->setColStretch(1, 1);
+ grid->setColStretch(2, 1);
+
+
+ // Size
+ QLabel *lbl = new QLabel(i18n("Size:"), m_pTab1);
+ lbl->setFixedSize(lbl->sizeHint());
+ grid->addWidget(lbl, 0, 0, Qt::AlignLeft);
+ mpSizeBox = new QComboBox(m_pTab1);
+ connect(mpSizeBox, SIGNAL(activated(int)), SLOT(slotSize(int)));
+ lbl->setBuddy(mpSizeBox);
+ grid->addWidget(mpSizeBox, 0, 1, Qt::AlignLeft);
+
+ mpDPCheck = new QCheckBox(i18n("Double-sized pixels"), m_pTab1);
+ connect(mpDPCheck, SIGNAL(toggled(bool)), SLOT(slotDPCheck(bool)));
+ grid->addMultiCellWidget(mpDPCheck, 1, 1, 0, 1, Qt::AlignLeft);
+
+ mpAnimatedCheck = new QCheckBox(i18n("Animate icons"), m_pTab1);
+ connect(mpAnimatedCheck, SIGNAL(toggled(bool)), SLOT(slotAnimatedCheck(bool)));
+ grid->addMultiCellWidget(mpAnimatedCheck, 2, 2, 0, 1, Qt::AlignLeft);
+
+ top->activate();
+
+ init();
+ read();
+ apply();
+ preview();
+}
+
+KIconConfig::~KIconConfig()
+{
+ delete mpEffect;
+}
+
+QPushButton *KIconConfig::addPreviewIcon(int i, const QString &str, QWidget *parent, QGridLayout *lay)
+{
+ QLabel *lab = new QLabel(str, parent);
+ lay->addWidget(lab, 1, i, AlignCenter);
+ mpPreview[i] = new QLabel(parent);
+ mpPreview[i]->setAlignment(AlignCenter);
+ mpPreview[i]->setMinimumSize(105, 105);
+ lay->addWidget(mpPreview[i], 2, i);
+ QPushButton *push = new QPushButton(i18n("Set Effect..."), parent);
+ lay->addWidget(push, 3, i, AlignCenter);
+ return push;
+}
+
+void KIconConfig::init()
+{
+ mpLoader = KGlobal::iconLoader();
+ mpConfig = KGlobal::config();
+ mpEffect = new KIconEffect;
+ mpTheme = mpLoader->theme();
+ mUsage = 0;
+ for (int i=0; i<KIcon::LastGroup; i++)
+ mbChanged[i] = false;
+
+ // Fill list/checkboxen
+ mpUsageList->insertItem(i18n("Desktop/File Manager"));
+ mpUsageList->insertItem(i18n("Toolbar"));
+ mpUsageList->insertItem(i18n("Main Toolbar"));
+ mpUsageList->insertItem(i18n("Small Icons"));
+ mpUsageList->insertItem(i18n("Panel"));
+ mpUsageList->insertItem(i18n("All Icons"));
+
+ // For reading the configuration
+ mGroups += "Desktop";
+ mGroups += "Toolbar";
+ mGroups += "MainToolbar";
+ mGroups += "Small";
+ mGroups += "Panel";
+
+ mStates += "Default";
+ mStates += "Active";
+ mStates += "Disabled";
+}
+
+void KIconConfig::initDefaults()
+{
+ mDefaultEffect[0].type = KIconEffect::NoEffect;
+ mDefaultEffect[1].type = KIconEffect::NoEffect;
+ mDefaultEffect[2].type = KIconEffect::ToGray;
+ mDefaultEffect[0].transparant = false;
+ mDefaultEffect[1].transparant = false;
+ mDefaultEffect[2].transparant = true;
+ mDefaultEffect[0].value = 1.0;
+ mDefaultEffect[1].value = 1.0;
+ mDefaultEffect[2].value = 1.0;
+ mDefaultEffect[0].color = QColor(144,128,248);
+ mDefaultEffect[1].color = QColor(169,156,255);
+ mDefaultEffect[2].color = QColor(34,202,0);
+ mDefaultEffect[0].color2 = QColor(0,0,0);
+ mDefaultEffect[1].color2 = QColor(0,0,0);
+ mDefaultEffect[2].color2 = QColor(0,0,0);
+
+ const int defDefSizes[] = { 32, 22, 22, 16, 32 };
+
+ KIcon::Group i;
+ QStringList::ConstIterator it;
+ for(it=mGroups.begin(), i=KIcon::FirstGroup; it!=mGroups.end(); ++it, i++)
+ {
+ mbDP[i] = false;
+ mbChanged[i] = true;
+ mbAnimated[i] = false;
+ if (mpTheme)
+ mSizes[i] = mpTheme->defaultSize(i);
+ else
+ mSizes[i] = defDefSizes[i];
+
+ mEffects[i][0] = mDefaultEffect[0];
+ mEffects[i][1] = mDefaultEffect[1];
+ mEffects[i][2] = mDefaultEffect[2];
+ }
+ // Animate desktop icons by default
+ int group = mGroups.findIndex( "Desktop" );
+ if ( group != -1 )
+ mbAnimated[group] = true;
+
+ // This is the new default in KDE 2.2, in sync with the kiconeffect of kdelibs Nolden 2001/06/11
+ int activeState = mStates.findIndex( "Active" );
+ if ( activeState != -1 )
+ {
+ int group = mGroups.findIndex( "Desktop" );
+ if ( group != -1 )
+ {
+ mEffects[ group ][ activeState ].type = KIconEffect::ToGamma;
+ mEffects[ group ][ activeState ].value = 0.7;
+ }
+
+ group = mGroups.findIndex( "Panel" );
+ if ( group != -1 )
+ {
+ mEffects[ group ][ activeState ].type = KIconEffect::ToGamma;
+ mEffects[ group ][ activeState ].value = 0.7;
+ }
+ }
+}
+
+void KIconConfig::read()
+{
+ if (mpTheme)
+ {
+ for (KIcon::Group i=KIcon::FirstGroup; i<KIcon::LastGroup; i++)
+ mAvSizes[i] = mpTheme->querySizes(i);
+
+ mTheme = mpTheme->current();
+ mExample = mpTheme->example();
+ }
+ else
+ {
+ for (KIcon::Group i=KIcon::FirstGroup; i<KIcon::LastGroup; i++)
+ mAvSizes[i] = QValueList<int>();
+
+ mTheme = QString::null;
+ mExample = QString::null;
+ }
+
+ initDefaults();
+
+ int i, j, effect;
+ QStringList::ConstIterator it, it2;
+ for (it=mGroups.begin(), i=0; it!=mGroups.end(); ++it, i++)
+ {
+ mbChanged[i] = false;
+
+ mpConfig->setGroup(*it + "Icons");
+ mSizes[i] = mpConfig->readNumEntry("Size", mSizes[i]);
+ mbDP[i] = mpConfig->readBoolEntry("DoublePixels", mbDP[i]);
+ mbAnimated[i] = mpConfig->readBoolEntry("Animated", mbAnimated[i]);
+
+ for (it2=mStates.begin(), j=0; it2!=mStates.end(); ++it2, j++)
+ {
+ QString tmp = mpConfig->readEntry(*it2 + "Effect");
+ if (tmp == "togray")
+ effect = KIconEffect::ToGray;
+ else if (tmp == "colorize")
+ effect = KIconEffect::Colorize;
+ else if (tmp == "togamma")
+ effect = KIconEffect::ToGamma;
+ else if (tmp == "desaturate")
+ effect = KIconEffect::DeSaturate;
+ else if (tmp == "tomonochrome")
+ effect = KIconEffect::ToMonochrome;
+ else if (tmp == "none")
+ effect = KIconEffect::NoEffect;
+ else continue;
+ mEffects[i][j].type = effect;
+ mEffects[i][j].value = mpConfig->readDoubleNumEntry(*it2 + "Value");
+ mEffects[i][j].color = mpConfig->readColorEntry(*it2 + "Color");
+ mEffects[i][j].color2 = mpConfig->readColorEntry(*it2 + "Color2");
+ mEffects[i][j].transparant = mpConfig->readBoolEntry(*it2 + "SemiTransparent");
+ }
+ }
+}
+
+void KIconConfig::apply()
+{
+ mpUsageList->setCurrentItem(mUsage);
+
+ int delta = 1000, dw, index = -1, size = 0, i;
+ QValueList<int>::Iterator it;
+ mpSizeBox->clear();
+ if (mUsage < KIcon::LastGroup) {
+ for (it=mAvSizes[mUsage].begin(), i=0; it!=mAvSizes[mUsage].end(); ++it, i++)
+ {
+ mpSizeBox->insertItem(QString().setNum(*it));
+ dw = abs(mSizes[mUsage] - *it);
+ if (dw < delta)
+ {
+ delta = dw;
+ index = i;
+ size = *it;
+ }
+
+ }
+ if (index != -1)
+ {
+ mpSizeBox->setCurrentItem(index);
+ mSizes[mUsage] = size; // best or exact match
+ }
+ mpDPCheck->setChecked(mbDP[mUsage]);
+ mpAnimatedCheck->setChecked(mbAnimated[mUsage]);
+ }
+}
+
+void KIconConfig::preview(int i)
+{
+ // Apply effects ourselves because we don't want to sync
+ // the configuration every preview.
+
+ int viewedGroup = (mUsage == KIcon::LastGroup) ? KIcon::FirstGroup : mUsage;
+
+ QPixmap pm = mpLoader->loadIcon(mExample, KIcon::NoGroup, mSizes[viewedGroup]);
+ QImage img = pm.convertToImage();
+ if (mbDP[viewedGroup])
+ {
+ int w = img.width() * 2;
+ img = img.smoothScale(w, w);
+ }
+
+ Effect &effect = mEffects[viewedGroup][i];
+
+ img = mpEffect->apply(img, effect.type,
+ effect.value, effect.color, effect.color2, effect.transparant);
+ pm.convertFromImage(img);
+ mpPreview[i]->setPixmap(pm);
+}
+
+void KIconConfig::preview()
+{
+ preview(0);
+ preview(1);
+ preview(2);
+}
+
+void KIconConfig::load()
+{
+ load( false );
+}
+
+void KIconConfig::load( bool useDefaults )
+{
+ mpConfig = KGlobal::config();
+ mpConfig->setReadDefaults( useDefaults );
+ read();
+ apply();
+ for (int i=0; i<KIcon::LastGroup; i++)
+ mbChanged[i] = false;
+ preview();
+ emit changed( useDefaults );
+}
+
+
+void KIconConfig::save()
+{
+ int i, j;
+ QStringList::ConstIterator it, it2;
+ for (it=mGroups.begin(), i=0; it!=mGroups.end(); ++it, i++)
+ {
+ mpConfig->setGroup(*it + "Icons");
+ mpConfig->writeEntry("Size", mSizes[i], true, true);
+ mpConfig->writeEntry("DoublePixels", mbDP[i], true, true);
+ mpConfig->writeEntry("Animated", mbAnimated[i], true, true);
+ for (it2=mStates.begin(), j=0; it2!=mStates.end(); ++it2, j++)
+ {
+ QString tmp;
+ switch (mEffects[i][j].type)
+ {
+ case KIconEffect::ToGray:
+ tmp = "togray";
+ break;
+ case KIconEffect::ToGamma:
+ tmp = "togamma";
+ break;
+ case KIconEffect::Colorize:
+ tmp = "colorize";
+ break;
+ case KIconEffect::DeSaturate:
+ tmp = "desaturate";
+ break;
+ case KIconEffect::ToMonochrome:
+ tmp = "tomonochrome";
+ break;
+ default:
+ tmp = "none";
+ break;
+ }
+ mpConfig->writeEntry(*it2 + "Effect", tmp, true, true);
+ mpConfig->writeEntry(*it2 + "Value", mEffects[i][j].value, true, true);
+ mpConfig->writeEntry(*it2 + "Color", mEffects[i][j].color, true, true);
+ mpConfig->writeEntry(*it2 + "Color2", mEffects[i][j].color2, true, true);
+ mpConfig->writeEntry(*it2 + "SemiTransparent", mEffects[i][j].transparant, true, true);
+ }
+ }
+
+ mpConfig->sync();
+
+ emit changed(false);
+
+ // Emit KIPC change message.
+ for (int i=0; i<KIcon::LastGroup; i++)
+ {
+ if (mbChanged[i])
+ {
+ KIPC::sendMessageAll(KIPC::IconChanged, i);
+ mbChanged[i] = false;
+ }
+ }
+}
+
+void KIconConfig::defaults()
+{
+ load( true );
+}
+
+void KIconConfig::slotUsage(int index)
+{
+ mUsage = index;
+ if ( mUsage == KIcon::Panel || mUsage == KIcon::LastGroup )
+ {
+ mpSizeBox->setEnabled(false);
+ mpDPCheck->setEnabled(false);
+ mpAnimatedCheck->setEnabled( mUsage == KIcon::Panel );
+ }
+ else
+ {
+ mpSizeBox->setEnabled(true);
+ mpDPCheck->setEnabled(true);
+ mpAnimatedCheck->setEnabled( mUsage == KIcon::Desktop );
+ }
+
+ apply();
+ preview();
+}
+
+void KIconConfig::EffectSetup(int state)
+{
+ int viewedGroup = (mUsage == KIcon::LastGroup) ? KIcon::FirstGroup : mUsage;
+
+ QPixmap pm = mpLoader->loadIcon(mExample, KIcon::NoGroup, mSizes[viewedGroup]);
+ QImage img = pm.convertToImage();
+ if (mbDP[viewedGroup])
+ {
+ int w = img.width() * 2;
+ img = img.smoothScale(w, w);
+ }
+
+ QString caption;
+ switch (state)
+ {
+ case 0 : caption = i18n("Setup Default Icon Effect"); break;
+ case 1 : caption = i18n("Setup Active Icon Effect"); break;
+ case 2 : caption = i18n("Setup Disabled Icon Effect"); break;
+ }
+
+ KIconEffectSetupDialog dlg(mEffects[viewedGroup][state], mDefaultEffect[state], caption, img);
+
+ if (dlg.exec() == QDialog::Accepted)
+ {
+ if (mUsage == KIcon::LastGroup) {
+ for (int i=0; i<KIcon::LastGroup; i++)
+ mEffects[i][state] = dlg.effect();
+ } else {
+ mEffects[mUsage][state] = dlg.effect();
+ }
+
+ // AK - can this call be moved therefore removing
+ // code duplication?
+
+ emit changed(true);
+
+ if (mUsage == KIcon::LastGroup) {
+ for (int i=0; i<KIcon::LastGroup; i++)
+ mbChanged[i] = true;
+ } else {
+ mbChanged[mUsage] = true;
+ }
+ }
+ preview(state);
+}
+
+void KIconConfig::slotSize(int index)
+{
+ Q_ASSERT(mUsage < KIcon::LastGroup);
+ mSizes[mUsage] = mAvSizes[mUsage][index];
+ preview();
+ emit changed(true);
+ mbChanged[mUsage] = true;
+}
+
+void KIconConfig::slotDPCheck(bool check)
+{
+ Q_ASSERT(mUsage < KIcon::LastGroup);
+ if (mbDP[mUsage] != check)
+ {
+ mbDP[mUsage] = check;
+ emit changed(true);
+ mbChanged[mUsage] = true;
+ }
+ preview();
+
+}
+
+void KIconConfig::slotAnimatedCheck(bool check)
+{
+ Q_ASSERT(mUsage < KIcon::LastGroup);
+ if (mbAnimated[mUsage] != check)
+ {
+ mbAnimated[mUsage] = check;
+ emit changed(true);
+ mbChanged[mUsage] = true;
+ }
+}
+
+KIconEffectSetupDialog::KIconEffectSetupDialog(const Effect &effect,
+ const Effect &defaultEffect,
+ const QString &caption, const QImage &image,
+ QWidget *parent, char *name)
+ : KDialogBase(parent, name, true, caption,
+ Default|Ok|Cancel, Ok, true),
+ mEffect(effect),
+ mDefaultEffect(defaultEffect),
+ mExample(image)
+{
+ mpEffect = new KIconEffect;
+
+ QLabel *lbl;
+ QGroupBox *frame;
+ QGridLayout *grid;
+
+ QWidget *page = new QWidget(this);
+ setMainWidget(page);
+
+ QGridLayout *top = new QGridLayout(page, 4, 2, 0, spacingHint());
+ top->setColStretch(0,1);
+ top->addColSpacing(1,10);
+ top->setColStretch(2,2);
+ top->setRowStretch(1,1);
+
+ lbl = new QLabel(i18n("&Effect:"), page);
+ lbl->setFixedSize(lbl->sizeHint());
+ top->addWidget(lbl, 0, 0, Qt::AlignLeft);
+ mpEffectBox = new QListBox(page);
+ mpEffectBox->insertItem(i18n("No Effect"));
+ mpEffectBox->insertItem(i18n("To Gray"));
+ mpEffectBox->insertItem(i18n("Colorize"));
+ mpEffectBox->insertItem(i18n("Gamma"));
+ mpEffectBox->insertItem(i18n("Desaturate"));
+ mpEffectBox->insertItem(i18n("To Monochrome"));
+ mpEffectBox->setMinimumWidth( 100 );
+ connect(mpEffectBox, SIGNAL(highlighted(int)), SLOT(slotEffectType(int)));
+ top->addMultiCellWidget(mpEffectBox, 1, 2, 0, 0, Qt::AlignLeft);
+ lbl->setBuddy(mpEffectBox);
+
+ mpSTCheck = new QCheckBox(i18n("&Semi-transparent"), page);
+ connect(mpSTCheck, SIGNAL(toggled(bool)), SLOT(slotSTCheck(bool)));
+ top->addWidget(mpSTCheck, 3, 0, Qt::AlignLeft);
+
+ frame = new QGroupBox(i18n("Preview"), page);
+ top->addMultiCellWidget(frame, 0, 1, 1, 1);
+ grid = new QGridLayout(frame, 2, 1, marginHint(), spacingHint());
+ grid->addRowSpacing(0, fontMetrics().lineSpacing());
+ grid->setRowStretch(1, 1);
+
+ mpPreview = new QLabel(frame);
+ mpPreview->setAlignment(AlignCenter);
+ mpPreview->setMinimumSize(105, 105);
+ grid->addWidget(mpPreview, 1, 0);
+
+ mpEffectGroup = new QGroupBox(i18n("Effect Parameters"), page);
+ top->addMultiCellWidget(mpEffectGroup, 2, 3, 1, 1);
+ grid = new QGridLayout(mpEffectGroup, 3, 2, marginHint(), spacingHint());
+ grid->addRowSpacing(0, fontMetrics().lineSpacing());
+
+ mpEffectLabel = new QLabel(i18n("&Amount:"), mpEffectGroup);
+ grid->addWidget(mpEffectLabel, 1, 0);
+ mpEffectSlider = new QSlider(0, 100, 5, 10, QSlider::Horizontal, mpEffectGroup);
+ mpEffectLabel->setBuddy( mpEffectSlider );
+ connect(mpEffectSlider, SIGNAL(valueChanged(int)), SLOT(slotEffectValue(int)));
+ grid->addWidget(mpEffectSlider, 1, 1);
+
+ mpEffectColor = new QLabel(i18n("Co&lor:"), mpEffectGroup);
+ grid->addWidget(mpEffectColor, 2, 0);
+ mpEColButton = new KColorButton(mpEffectGroup);
+ mpEffectColor->setBuddy( mpEColButton );
+ connect(mpEColButton, SIGNAL(changed(const QColor &)),
+ SLOT(slotEffectColor(const QColor &)));
+ grid->addWidget(mpEColButton, 2, 1);
+
+ mpEffectColor2 = new QLabel(i18n("&Second color:"), mpEffectGroup);
+ grid->addWidget(mpEffectColor2, 3, 0);
+ mpECol2Button = new KColorButton(mpEffectGroup);
+ mpEffectColor2->setBuddy( mpECol2Button );
+ connect(mpECol2Button, SIGNAL(changed(const QColor &)),
+ SLOT(slotEffectColor2(const QColor &)));
+ grid->addWidget(mpECol2Button, 3, 1);
+
+ init();
+ preview();
+}
+
+KIconEffectSetupDialog::~KIconEffectSetupDialog()
+{
+ delete mpEffect;
+}
+
+void KIconEffectSetupDialog::init()
+{
+ mpEffectBox->setCurrentItem(mEffect.type);
+ mpEffectSlider->setEnabled(mEffect.type != KIconEffect::NoEffect);
+ mpEColButton->setEnabled(mEffect.type == KIconEffect::Colorize || mEffect.type == KIconEffect::ToMonochrome);
+ mpECol2Button->setEnabled(mEffect.type == KIconEffect::ToMonochrome);
+ mpEffectSlider->setValue((int) (100.0 * mEffect.value + 0.5));
+ mpEColButton->setColor(mEffect.color);
+ mpECol2Button->setColor(mEffect.color2);
+ mpSTCheck->setChecked(mEffect.transparant);
+}
+
+void KIconEffectSetupDialog::slotEffectValue(int value)
+{
+ mEffect.value = 0.01 * value;
+ preview();
+}
+
+void KIconEffectSetupDialog::slotEffectColor(const QColor &col)
+{
+ mEffect.color = col;
+ preview();
+}
+
+void KIconEffectSetupDialog::slotEffectColor2(const QColor &col)
+{
+ mEffect.color2 = col;
+ preview();
+}
+
+void KIconEffectSetupDialog::slotEffectType(int type)
+{
+ mEffect.type = type;
+ mpEffectGroup->setEnabled(mEffect.type != KIconEffect::NoEffect);
+ mpEffectSlider->setEnabled(mEffect.type != KIconEffect::NoEffect);
+ mpEffectColor->setEnabled(mEffect.type == KIconEffect::Colorize || mEffect.type == KIconEffect::ToMonochrome);
+ mpEColButton->setEnabled(mEffect.type == KIconEffect::Colorize || mEffect.type == KIconEffect::ToMonochrome);
+ mpEffectColor2->setEnabled(mEffect.type == KIconEffect::ToMonochrome);
+ mpECol2Button->setEnabled(mEffect.type == KIconEffect::ToMonochrome);
+ preview();
+}
+
+void KIconEffectSetupDialog::slotSTCheck(bool b)
+{
+ mEffect.transparant = b;
+ preview();
+}
+
+void KIconEffectSetupDialog::slotDefault()
+{
+ mEffect = mDefaultEffect;
+ init();
+ preview();
+}
+
+void KIconEffectSetupDialog::preview()
+{
+ QPixmap pm;
+ QImage img = mExample.copy();
+ img = mpEffect->apply(img, mEffect.type,
+ mEffect.value, mEffect.color, mEffect.color2, mEffect.transparant);
+ pm.convertFromImage(img);
+ mpPreview->setPixmap(pm);
+}
+
+#include "icons.moc"
diff --git a/kcontrol/icons/icons.desktop b/kcontrol/icons/icons.desktop
new file mode 100644
index 000000000..966b377b9
--- /dev/null
+++ b/kcontrol/icons/icons.desktop
@@ -0,0 +1,249 @@
+[Desktop Entry]
+Type=Application
+DocPath=kcontrol/icons/index.html
+Icon=icons
+Exec=kcmshell icons
+
+
+X-KDE-Library=icons
+X-KDE-FactoryName=icons
+X-KDE-ParentApp=kcontrol
+
+Name=Icons
+Name[af]=Ikoone
+Name[ar]=الأيقونات
+Name[az]=Timsallar
+Name[be]=Значкі
+Name[bg]=Икони
+Name[bn]=আইকন
+Name[br]=Arlunioù
+Name[bs]=Ikone
+Name[ca]=Icones
+Name[cs]=Ikony
+Name[csb]=Ikònë
+Name[cy]=Eicon
+Name[da]=Ikoner
+Name[de]=Symbole
+Name[el]=Εικονίδια
+Name[eo]=Piktogramoj
+Name[es]=Iconos
+Name[et]=Ikoonid
+Name[eu]=Ikonoak
+Name[fa]=شمایلها
+Name[fi]=Kuvakkeet
+Name[fr]=Icônes
+Name[fy]=Byldkaikes
+Name[ga]=Deilbhíní
+Name[gl]=Iconas
+Name[he]=סמלים
+Name[hi]=प्रतीक
+Name[hr]=Ikone
+Name[hu]=Ikonok
+Name[id]=Ikon
+Name[is]=Táknmyndir
+Name[it]=Icone
+Name[ja]=アイコン
+Name[ka]=ხატულები
+Name[kk]=Таңбашалар
+Name[km]=រូបតំណាង
+Name[ko]=아이콘
+Name[lo]=ໄອຄອນ
+Name[lt]=Ženkliukai
+Name[lv]=Ikonas
+Name[mk]=Икони
+Name[mn]=Тэмдэг
+Name[ms]=Ikon
+Name[mt]=Ikoni
+Name[nb]=Ikoner
+Name[nds]=Lüttbiller
+Name[ne]=प्रतिमा
+Name[nl]=Pictogrammen
+Name[nn]=Ikon
+Name[nso]=Diemedi
+Name[oc]=Icones
+Name[pa]=ਆਈਕਾਨ
+Name[pl]=Ikony
+Name[pt]=Ícones
+Name[pt_BR]=Ícones
+Name[ro]=Iconițe
+Name[ru]=Значки
+Name[rw]=Agashushondanga
+Name[se]=Govažat
+Name[sk]=Ikony
+Name[sl]=Ikone
+Name[sr]=Иконе
+Name[sr@Latn]=Ikone
+Name[ss]=Timeleli
+Name[sv]=Ikoner
+Name[ta]=சின்னங்கள்
+Name[te]=ప్రతిమలు
+Name[tg]=Нишонаҳо
+Name[th]=ไอคอน
+Name[tr]=Simgeler
+Name[tt]=Tamğalar
+Name[uk]=Піктограми
+Name[uz]=Nishonchalar
+Name[uz@cyrillic]=Нишончалар
+Name[ven]=Aikhono
+Name[vi]=Biểu tượng
+Name[wa]=Imådjetes
+Name[xh]=Imphawu zemmifanekiso
+Name[zh_CN]=图标
+Name[zh_TW]=圖示
+Name[zu]=Izimpawu zezithombe
+
+Comment=Customize KDE Icons
+Comment[af]=Pasmaak Kde Ikoone
+Comment[ar]=تخصيص أيقونات KDE الإعتيادية
+Comment[az]=KDE Timsallarını Xüsusiləşdirir
+Comment[be]=Настаўленні значак KDE
+Comment[bg]=Настройване и избор на тема с икони
+Comment[bn]=কে.ডি.ই. আইকন বেছে নিন
+Comment[br]=Neuziañ arlunioù KDE
+Comment[bs]=Podesite KDE ikone
+Comment[ca]=Configura les icones del KDE
+Comment[cs]=Přizpůsobení ikon KDE
+Comment[csb]=Dopasëjë ikònë KDE
+Comment[cy]=Addasu Eiconau KDE
+Comment[da]=Brugerdefinér KDE-ikoner
+Comment[de]=KDE-Symbole einrichten
+Comment[el]=Προσαρμογή των εικονιδίων του KDE
+Comment[en_GB]=Customise KDE Icons
+Comment[eo]=Agordo de KDE-piktogramoj
+Comment[es]=Personaliza los iconos de KDE
+Comment[et]=KDE ikoonide kohandamine
+Comment[eu]=Pertsonalizatu KDEren ikonoak
+Comment[fa]=سفارشی‌سازی شمایلهای KDE
+Comment[fi]=Muokkaa KDE:n kuvakkeita
+Comment[fr]=Personnalisation des icônes de KDE
+Comment[fy]=KDE-byldkaikes oanpasse
+Comment[ga]=Saincheap Deilbhíní KDE
+Comment[gl]=Personaliza as Iconas de KDE
+Comment[he]=שינוי הגדרות הסמלים של KDE
+Comment[hi]=केडीई प्रतीक मनपसंद बनाएँ
+Comment[hr]=Prilagođavanje KDE ikona
+Comment[hu]=A KDE ikonok testreszabása
+Comment[id]=Customize Ikon KDE
+Comment[is]=Stilla táknmyndir KDE
+Comment[it]=Personalizza le icone di KDE
+Comment[ja]=KDE アイコンをカスタマイズ
+Comment[ka]=KDE–ს ხატულების კონფიგურაცია
+Comment[kk]=KDE таңбашаларын баптау
+Comment[km]=ប្ដូរ​រូបតំណាង KDE តាម​បំណង
+Comment[ko]=KDE 아이콘 사용자 정의
+Comment[lo]=ເລືອກໄອຄອນຂອງ KDE ເອງ
+Comment[lt]=KDE ženkliukų derinimas
+Comment[lv]=Pielāgot KDE Ikonas
+Comment[mk]=Прилагоди ги иконите на KDE
+Comment[mn]=КДЭ-Тэмдэг тохируулах
+Comment[ms]=Ikon KDE Langganan
+Comment[mt]=Agħżel ikoni ġodda għal KDE
+Comment[nb]=Tilpass ikonene i KDE
+Comment[nds]=Lüttbiller för KDE utsöken
+Comment[ne]=केडीई प्रतिमा अनुकूलन गर्नुहोस्
+Comment[nl]=KDE-pictogrammen aanpassen
+Comment[nn]=Tilpass KDE-ikon
+Comment[nso]=Amanya Diemedi tsa KDE
+Comment[oc]=Configura les icones KDE
+Comment[pa]=KDE ਆਈਕਾਨ ਪਸੰਦ
+Comment[pl]=Dostosuj ikony KDE
+Comment[pt]=Alterar os Ícones do KDE
+Comment[pt_BR]=Personalizar os ícones do KDE
+Comment[ro]=Personalizează iconițele KDE
+Comment[ru]=Настройка значков
+Comment[rw]=Kugena imiterere y'udushushondanga twa KDE
+Comment[se]=Heivet KDE-govažiid
+Comment[sk]=Zmena ikon v KDE
+Comment[sl]=Nastavitve ikon za KDE
+Comment[sr]=Прилагоди KDE иконе
+Comment[sr@Latn]=Prilagodi KDE ikone
+Comment[sv]=Anpassa KDE:s ikoner
+Comment[ta]=KDE சின்னங்களை தனதாக்கு
+Comment[tg]=Мизроб кардани нишонаҳои KDE
+Comment[th]=กำหนดไอคอนของ KDE
+Comment[tr]=KDE Simgelerini Özelleştirir
+Comment[tt]=KDE İkonnarın caylaw
+Comment[uk]=Налаштування піктограм KDE
+Comment[uz]=KDE nishonchalarini moslash
+Comment[uz@cyrillic]=KDE нишончаларини мослаш
+Comment[ven]=Customize dziaikhonu dza KDE
+Comment[vi]=Tuỳ chọn các Biểu tượng của KDE
+Comment[wa]=Imådjetes KDE da vosse
+Comment[xh]=Yenza Imphawu zomfanekiso ze KDE Ngokwemfuneko
+Comment[zh_CN]=定制 KDE 图标
+Comment[zh_TW]=自訂 KDE 圖示
+Comment[zu]=Yenza Izimpawu zezithombe ze-KDE ngokwemfuneko
+
+Keywords=icons,effects,size,hicolor,locolor
+Keywords[ar]=icons,effects,size,hicolor,locolor,أيقونات,تأثيرات,حجم لون عالي,لون مخفض,الحجم,التأثيرات,الأيقونات
+Keywords[az]=timsallar,effektlər,böyüklük,yüksək rəng,alçaq rəng
+Keywords[be]=значкі,эфекты,памер,кантраст,высокі кантраст,нізкі кантраст,icons,effects,size,hicolor,locolor
+Keywords[bg]=икона, икони, icons, effects, size, hicolor, locolor
+Keywords[br]=arlunioù,efedoù,ment,liv,liv izel
+Keywords[bs]=icons,effects,size,hicolor,locolor,ikone,efekti,veličina
+Keywords[ca]=icones,efectes,mida,hicolor,locolor
+Keywords[cs]=Ikony,Efekty,Velikost,HiColor,LoColor
+Keywords[csb]=ikònë,efektë,miara,wiele farwów,mało farwów
+Keywords[cy]=eicon,effeithiau,maint,lliw uchel,lliw isel
+Keywords[da]=ikoner,effekter,størrelse,højfarve,lavfarve
+Keywords[de]=Symbole,Icons,Effekte,Größe,64000-Farben,8-Bit-Farben
+Keywords[el]=εικονίδια,εφέ,μέγεθος,hicolor,locolor
+Keywords[en_GB]=icons,effects,size,hicolour,locolour
+Keywords[eo]=piktogramoj,efektoj,grandeco,koloro
+Keywords[es]=iconos,efectos,tamaño,alta profundidad,baja profundidad
+Keywords[et]=ikoonid,efektid,suurus,värv
+Keywords[eu]=ikonoak,efektuak,neurria,hicolor,locolor
+Keywords[fa]=شمایلها، جلوه‌ها، اندازه، پررنگ، کم‌رنگ
+Keywords[fi]=kuvakkeet,tehosteet,koko,korkeaväri,matalaväri
+Keywords[fr]=icônes,effets,taille,hicolor,locolor,coloré
+Keywords[fy]=iconen,byldkaikes,effekten,grutte,ôfmjiting,formaat,kleuren,hege,lege
+Keywords[gl]=iconas,efeitos,tamaño,moitas cores,poucas cores
+Keywords[he]=סמלים,אפקטים,גודל,צבע גבוה,צבע נמוך,icons,effects,size,hicolor,locolor
+Keywords[hi]=प्रतीक,प्रभाव,आकार,अधिक-रंग,कम-रंग
+Keywords[hr]=icons,effects,size,hicolor,locolor,ikone,efekti,veličina,boja
+Keywords[hu]=ikonok,effektek,méret,sokszínű,színszegény,színes
+Keywords[id]=ikon,efek,ukuran,hicolor,locolor
+Keywords[is]=táknmynd,tákn,teikn,áhrif,stærð,hágæði,lágæði,litur,litir
+Keywords[it]=icone,effetti,dimensione,molti colori,pochi colori
+Keywords[ja]=アイコン,効果,サイズ,ハイカラー,ローカラー
+Keywords[ka]=ხატულები,ეფექტები,ზომა,მაღალი გარჩევადობა,დაბალი გარჩევადობა
+Keywords[km]=រូបតំណាង,បែបបទ,ទំហំ,ពណ៌​ខ្ពស់,ពណ៌​ទាប
+Keywords[lo]=ໄອຄອນ,ເອຟເຟັກ,ຂະຫນາດ,ຄວາມລະອງດສີ ຫລາຍ,ຄວາມລະອງດສີຫນ້ອຍ
+Keywords[lt]=ženkliukai,piktogramos,efektai,dydis,hispalva,lospalva
+Keywords[lv]=ikonas,efekti,lielums,hicolor,locolor
+Keywords[mk]=icons,effects,size,hicolor,locolor,икони,ефекти,големина,високи бои,ниски бои
+Keywords[mn]=Тэмдэг,Icons,Нөлөө,Хэмжээ,64000-Өнгө,8бит-Өнгө
+Keywords[nb]=ikoner,effekter,størrelse,mange farger,få farger
+Keywords[nds]=Lüttbiller,Effekten,Grött,hicolor,locolor
+Keywords[ne]=प्रतिमा, प्रभाव, साइज, हाइकलर, लोकलर
+Keywords[nl]=iconen,pictogrammen,effecten,grootte,afmeting,formaat,kleuren
+Keywords[nn]=ikon,effektar,storleik,mange fargar,få fargar
+Keywords[nso]=diemedi,dikamego,bogolo,mmala wa godimo,mmala wa tlase
+Keywords[oc]=icones,efectes,talha,hicolor,locolor
+Keywords[pa]=icons,effects,size,hicolor,locolor,ਆਈਕਾਨ,ਪਰਭਾਵ,ਅਕਾਰ
+Keywords[pl]=ikony,efekty,rozmiar,wiele kolorów,mało kolorów
+Keywords[pt]=ícones,efeitos,tamanho,muitas cores,poucas cores
+Keywords[pt_BR]=ícones,efeitos,tamanho,alta resolução,baixa resolução
+Keywords[ro]=iconițe,efecte,mărime,culori multe,culori puține
+Keywords[rw]=Udushushondanga,ingaruka,ingano,ibara-hejuru,ibara-hasi
+Keywords[se]=govažat,effects,sturrodat,máŋga ivnni,unnan ivnnit
+Keywords[sk]=ikony,ikonky,veľkosť,hicolor,locolor
+Keywords[sl]=ikone,efekti,velikost,barve
+Keywords[sr]=icons,effects,size,hicolor,locolor,иконе,ефекти,величина,пуно боја,мало боја
+Keywords[sr@Latn]=icons,effects,size,hicolor,locolor,ikone,efekti,veličina,puno boja,malo boja
+Keywords[sv]=ikoner,effekter,storlek,många färger,få färger
+Keywords[ta]=சின்னங்கள்,விளைவுகள்,அளவு,அதிக வண்ணம்,குறைந்த வண்ணம்
+Keywords[th]=ไอคอน,เอฟเฟ็กต์,ขนาด,ความละเอียดสีมาก,ความละเอียดสีน้อย
+Keywords[tr]=simgeler,efektler,boyut,yüksek renk,düşük renk
+Keywords[uk]=піктограми,icons,ефекти,розмір,кольори
+Keywords[uz]=nishonchalar,effektlar,oʻlchami
+Keywords[uz@cyrillic]=нишончалар,эффектлар,ўлчами
+Keywords[ven]=dziaikhono,zwivhangi,saizi,muvhala wa ntha,muvhala wa fhasi
+Keywords[vi]=biểu tượng,hiệu ứng,cỡ,màu tươi,màu thẫm
+Keywords[wa]=imådjetes,efets,grandeu,hicolor,locolor
+Keywords[xh]=imphawu zomfanekiso,iziphumo,ubungakanani,hicolor,locolor
+Keywords[zh_CN]=icons,effects,size,hicolor,locolor,图标,效果,大小,高色彩,低色彩
+Keywords[zh_TW]=icons,effects,size,hicolor,locolor,圖示,效果,大小,高彩,低彩
+Keywords[zu]=izimpawu,imiphumela,usayizi,umbala ophezulu,umbala ophansi
+
+Categories=Qt;KDE;X-KDE-settings-looknfeel;
diff --git a/kcontrol/icons/icons.h b/kcontrol/icons/icons.h
new file mode 100644
index 000000000..93171f6d1
--- /dev/null
+++ b/kcontrol/icons/icons.h
@@ -0,0 +1,152 @@
+/* vi: ts=8 sts=4 sw=4
+ *
+ * This file is part of the KDE project, module kcmdisplay.
+ * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
+ * with minor additions and based on ideas from
+ * Torsten Rahn <torsten@kde.org>
+ *
+ * You can Freely distribute this program under the GNU General Public
+ * License. See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef __icons_h__
+#define __icons_h__
+
+#include <qcolor.h>
+#include <qimage.h>
+#include <qvaluelist.h>
+
+#include <kcmodule.h>
+#include <kdialogbase.h>
+
+class QCheckBox;
+class QColor;
+class QComboBox;
+class QGridLayout;
+class QGroupBox;
+class QIconView;
+class QLabel;
+class QListBox;
+class QListView;
+class QPushButton;
+class QSlider;
+class QTabWidget;
+class QWidget;
+
+class KColorButton;
+class KConfig;
+class KIconEffect;
+class KIconLoader;
+class KIconTheme;
+
+struct Effect
+{
+ int type;
+ float value;
+ QColor color;
+ QColor color2;
+ bool transparant;
+};
+
+
+/**
+ * The General Icons tab in kcontrol.
+ */
+class KIconConfig: public KCModule
+{
+ Q_OBJECT
+
+public:
+ KIconConfig(QWidget *parent, const char *name=0);
+ ~KIconConfig();
+
+ virtual void load();
+ virtual void load( bool useDefaults );
+ virtual void save();
+ virtual void defaults();
+ void preview();
+
+private slots:
+ void slotEffectSetup0() { EffectSetup(0); }
+ void slotEffectSetup1() { EffectSetup(1); }
+ void slotEffectSetup2() { EffectSetup(2); }
+
+ void slotUsage(int index);
+ void slotSize(int index);
+ void slotDPCheck(bool check);
+ void slotAnimatedCheck(bool check);
+
+private:
+ void preview(int i);
+ void EffectSetup(int state);
+ QPushButton *addPreviewIcon(int i, const QString &str, QWidget *parent, QGridLayout *lay);
+ void init();
+ void initDefaults();
+ void read();
+ void apply();
+
+
+ bool mbDP[6], mbChanged[6], mbAnimated[6];
+ int mSizes[6];
+ QValueList<int> mAvSizes[6];
+
+ Effect mEffects[6][3];
+ Effect mDefaultEffect[3];
+
+ int mUsage;
+ QString mTheme, mExample;
+ QStringList mGroups, mStates;
+
+ KIconEffect *mpEffect;
+ KIconTheme *mpTheme;
+ KIconLoader *mpLoader;
+ KConfig *mpConfig;
+
+ typedef QLabel *QLabelPtr;
+ QLabelPtr mpPreview[3];
+
+ QListBox *mpUsageList;
+ QComboBox *mpSizeBox;
+ QCheckBox *mpDPCheck, *wordWrapCB, *underlineCB, *mpAnimatedCheck;
+ QTabWidget *m_pTabWidget;
+ QWidget *m_pTab1;
+};
+
+class KIconEffectSetupDialog: public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ KIconEffectSetupDialog(const Effect &, const Effect &,
+ const QString &, const QImage &,
+ QWidget *parent=0L, char *name=0L);
+ ~KIconEffectSetupDialog();
+ Effect effect() { return mEffect; }
+
+protected:
+ void preview();
+ void init();
+
+protected slots:
+ void slotEffectValue(int value);
+ void slotEffectColor(const QColor &col);
+ void slotEffectColor2(const QColor &col);
+ void slotEffectType(int type);
+ void slotSTCheck(bool b);
+ void slotDefault();
+
+private:
+ KIconEffect *mpEffect;
+ QListBox *mpEffectBox;
+ QCheckBox *mpSTCheck;
+ QSlider *mpEffectSlider;
+ KColorButton *mpEColButton;
+ KColorButton *mpECol2Button;
+ Effect mEffect;
+ Effect mDefaultEffect;
+ QImage mExample;
+ QGroupBox *mpEffectGroup;
+ QLabel *mpPreview, *mpEffectLabel, *mpEffectColor, *mpEffectColor2;
+};
+
+#endif
diff --git a/kcontrol/icons/iconthemes.cpp b/kcontrol/icons/iconthemes.cpp
new file mode 100644
index 000000000..a79ad6ddf
--- /dev/null
+++ b/kcontrol/icons/iconthemes.cpp
@@ -0,0 +1,452 @@
+/**
+ * Copyright (c) 2000 Antonio Larrosa <larrosa@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <qfileinfo.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kstandarddirs.h>
+#include <kservice.h>
+#include <klocale.h>
+#include <ksimpleconfig.h>
+#undef Unsorted
+#include <kipc.h>
+
+#include <klistview.h>
+#include <kurlrequesterdlg.h>
+#include <kmessagebox.h>
+#include <kprogress.h>
+#include <kiconloader.h>
+
+#include <kio/job.h>
+#include <kio/netaccess.h>
+#include <ktar.h>
+
+#ifdef HAVE_LIBART
+#include <ksvgiconengine.h>
+#endif
+
+#include "iconthemes.h"
+
+IconThemesConfig::IconThemesConfig(QWidget *parent, const char *name)
+ : KCModule(parent, name)
+{
+ QVBoxLayout *topLayout = new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+
+ QFrame *m_preview=new QFrame(this);
+ m_preview->setMinimumHeight(50);
+
+ QHBoxLayout *lh2=new QHBoxLayout( m_preview );
+ m_previewExec=new QLabel(m_preview);
+ m_previewExec->setPixmap(DesktopIcon("exec"));
+ m_previewFolder=new QLabel(m_preview);
+ m_previewFolder->setPixmap(DesktopIcon("folder"));
+ m_previewDocument=new QLabel(m_preview);
+ m_previewDocument->setPixmap(DesktopIcon("document"));
+
+ lh2->addStretch(10);
+ lh2->addWidget(m_previewExec);
+ lh2->addStretch(1);
+ lh2->addWidget(m_previewFolder);
+ lh2->addStretch(1);
+ lh2->addWidget(m_previewDocument);
+ lh2->addStretch(10);
+
+
+ m_iconThemes=new KListView(this,"IconThemeList");
+ m_iconThemes->addColumn(i18n("Name"));
+ m_iconThemes->addColumn(i18n("Description"));
+ m_iconThemes->setAllColumnsShowFocus( true );
+ m_iconThemes->setFullWidth(true);
+ connect(m_iconThemes,SIGNAL(selectionChanged(QListViewItem *)),
+ SLOT(themeSelected(QListViewItem *)));
+
+ QPushButton *installButton=new QPushButton( i18n("Install New Theme..."),
+ this, "InstallNewTheme");
+ connect(installButton,SIGNAL(clicked()),SLOT(installNewTheme()));
+ m_removeButton=new QPushButton( i18n("Remove Theme"),
+ this, "RemoveTheme");
+ connect(m_removeButton,SIGNAL(clicked()),SLOT(removeSelectedTheme()));
+
+ topLayout->addWidget(
+ new QLabel(i18n("Select the icon theme you want to use:"), this));
+ topLayout->addWidget(m_preview);
+ topLayout->addWidget(m_iconThemes);
+ QHBoxLayout *lg = new QHBoxLayout(topLayout, KDialog::spacingHint());
+ lg->addWidget(installButton);
+ lg->addWidget(m_removeButton);
+
+ loadThemes();
+
+ load();
+
+ m_iconThemes->setFocus();
+}
+
+IconThemesConfig::~IconThemesConfig()
+{
+}
+
+QListViewItem *IconThemesConfig::iconThemeItem(const QString &name)
+{
+ QListViewItem *item;
+ for ( item=m_iconThemes->firstChild(); item ; item=item->nextSibling() )
+ if (m_themeNames[item->text(0)]==name) return item;
+
+ return 0L;
+}
+
+void IconThemesConfig::loadThemes()
+{
+ m_iconThemes->clear();
+ m_themeNames.clear();
+ QStringList themelist(KIconTheme::list());
+ QString name;
+ QString tname;
+ QStringList::Iterator it;
+ for (it=themelist.begin(); it != themelist.end(); ++it)
+ {
+ KIconTheme icontheme(*it);
+ if (!icontheme.isValid()) kdDebug() << "notvalid\n";
+ if (icontheme.isHidden()) continue;
+
+ name=icontheme.name();
+ tname=name;
+
+ // Just in case we have duplicated icon theme names on separate directories
+ for (int i=2; m_themeNames.find(tname)!=m_themeNames.end() ; i++)
+ tname=QString("%1-%2").arg(name).arg(i);
+
+ m_iconThemes->insertItem(new QListViewItem(m_iconThemes,name,
+ icontheme.description()));
+
+ m_themeNames.insert(name,*it);
+
+ }
+}
+
+void IconThemesConfig::installNewTheme()
+{
+ KURL themeURL = KURLRequesterDlg::getURL(QString::null, this,
+ i18n("Drag or Type Theme URL"));
+ kdDebug() << themeURL.prettyURL() << endl;
+
+ if (themeURL.url().isEmpty()) return;
+
+ QString themeTmpFile;
+ // themeTmpFile contains the name of the downloaded file
+
+ if (!KIO::NetAccess::download(themeURL, themeTmpFile, this)) {
+ QString sorryText;
+ if (themeURL.isLocalFile())
+ sorryText = i18n("Unable to find the icon theme archive %1.");
+ else
+ sorryText = i18n("Unable to download the icon theme archive;\n"
+ "please check that address %1 is correct.");
+ KMessageBox::sorry(this, sorryText.arg(themeURL.prettyURL()));
+ return;
+ }
+
+ QStringList themesNames = findThemeDirs(themeTmpFile);
+ if (themesNames.isEmpty()) {
+ QString invalidArch(i18n("The file is not a valid icon theme archive."));
+ KMessageBox::error(this, invalidArch);
+
+ KIO::NetAccess::removeTempFile(themeTmpFile);
+ return;
+ }
+
+ if (!installThemes(themesNames, themeTmpFile)) {
+ //FIXME: make me able to know what is wrong....
+ // QStringList instead of bool?
+ QString somethingWrong =
+ i18n("A problem occurred during the installation process; "
+ "however, most of the themes in the archive have been installed");
+ KMessageBox::error(this, somethingWrong);
+ }
+
+ KIO::NetAccess::removeTempFile(themeTmpFile);
+
+ KGlobal::instance()->newIconLoader();
+ loadThemes();
+
+ QListViewItem *item=iconThemeItem(KIconTheme::current());
+ m_iconThemes->setSelected(item, true);
+ updateRemoveButton();
+}
+
+bool IconThemesConfig::installThemes(const QStringList &themes, const QString &archiveName)
+{
+ bool everythingOk = true;
+ QString localThemesDir(locateLocal("icon", "./"));
+
+ KProgressDialog progressDiag(this, "themeinstallprogress",
+ i18n("Installing icon themes"),
+ QString::null,
+ true);
+ progressDiag.setAutoClose(true);
+ progressDiag.progressBar()->setTotalSteps(themes.count());
+ progressDiag.show();
+
+ KTar archive(archiveName);
+ archive.open(IO_ReadOnly);
+ kapp->processEvents();
+
+ const KArchiveDirectory* rootDir = archive.directory();
+
+ KArchiveDirectory* currentTheme;
+ for (QStringList::ConstIterator it = themes.begin();
+ it != themes.end();
+ ++it) {
+ progressDiag.setLabel(
+ i18n("<qt>Installing <strong>%1</strong> theme</qt>")
+ .arg(*it));
+ kapp->processEvents();
+
+ if (progressDiag.wasCancelled())
+ break;
+
+ currentTheme = dynamic_cast<KArchiveDirectory*>(
+ const_cast<KArchiveEntry*>(
+ rootDir->entry(*it)));
+ if (currentTheme == NULL) {
+ // we tell back that something went wrong, but try to install as much
+ // as possible
+ everythingOk = false;
+ continue;
+ }
+
+ currentTheme->copyTo(localThemesDir + *it);
+ progressDiag.progressBar()->advance(1);
+ }
+
+ archive.close();
+ return everythingOk;
+}
+
+QStringList IconThemesConfig::findThemeDirs(const QString &archiveName)
+{
+ QStringList foundThemes;
+
+ KTar archive(archiveName);
+ archive.open(IO_ReadOnly);
+ const KArchiveDirectory* themeDir = archive.directory();
+
+ KArchiveEntry* possibleDir = 0L;
+ KArchiveDirectory* subDir = 0L;
+
+ // iterate all the dirs looking for an index.theme or index.desktop file
+ QStringList entries = themeDir->entries();
+ for (QStringList::Iterator it = entries.begin();
+ it != entries.end();
+ ++it) {
+ possibleDir = const_cast<KArchiveEntry*>(themeDir->entry(*it));
+ if (possibleDir->isDirectory()) {
+ subDir = dynamic_cast<KArchiveDirectory*>( possibleDir );
+ if (subDir && (subDir->entry("index.theme") != NULL ||
+ subDir->entry("index.desktop") != NULL))
+ foundThemes.append(subDir->name());
+ }
+ }
+
+ archive.close();
+ return foundThemes;
+}
+
+void IconThemesConfig::removeSelectedTheme()
+{
+ QListViewItem *selected = m_iconThemes->selectedItem();
+ if (!selected)
+ return;
+
+ QString question=i18n("<qt>Are you sure you want to remove the "
+ "<strong>%1</strong> icon theme?<br>"
+ "<br>"
+ "This will delete the files installed by this theme.</qt>").
+ arg(selected->text(0));
+
+ bool deletingCurrentTheme=(selected==iconThemeItem(KIconTheme::current()));
+
+ int r=KMessageBox::warningContinueCancel(this,question,i18n("Confirmation"),KStdGuiItem::del());
+ if (r!=KMessageBox::Continue) return;
+
+ KIconTheme icontheme(m_themeNames[selected->text(0)]);
+
+ // delete the index file before the async KIO::del so loadThemes() will
+ // ignore that dir.
+ unlink(QFile::encodeName(icontheme.dir()+"/index.theme").data());
+ unlink(QFile::encodeName(icontheme.dir()+"/index.desktop").data());
+ KIO::del(KURL( icontheme.dir() ));
+
+ KGlobal::instance()->newIconLoader();
+
+ loadThemes();
+
+ QListViewItem *item=0L;
+ //Fallback to the default if we've deleted the current theme
+ if (!deletingCurrentTheme)
+ item=iconThemeItem(KIconTheme::current());
+ if (!item)
+ item=iconThemeItem(KIconTheme::defaultThemeName());
+
+ m_iconThemes->setSelected(item, true);
+ updateRemoveButton();
+
+ if (deletingCurrentTheme) // Change the configuration
+ save();
+}
+
+void IconThemesConfig::updateRemoveButton()
+{
+ QListViewItem *selected = m_iconThemes->selectedItem();
+ bool enabled = false;
+ if (selected)
+ {
+ KIconTheme icontheme(m_themeNames[selected->text(0)]);
+ QFileInfo fi(icontheme.dir());
+ enabled = fi.isWritable();
+ // Don't let users remove the current theme.
+ if(m_themeNames[selected->text(0)] == KIconTheme::current() ||
+ m_themeNames[selected->text(0)] == KIconTheme::defaultThemeName())
+ enabled = false;
+ }
+ m_removeButton->setEnabled(enabled);
+}
+
+void IconThemesConfig::themeSelected(QListViewItem *item)
+{
+#ifdef HAVE_LIBART
+ KSVGIconEngine engine;
+#endif
+ QString dirName(m_themeNames[item->text(0)]);
+ KIconTheme icontheme(dirName);
+ if (!icontheme.isValid()) kdDebug() << "notvalid\n";
+
+ updateRemoveButton();
+ const int size = icontheme.defaultSize(KIcon::Desktop);
+
+ KIcon icon=icontheme.iconPath("exec.png", size, KIcon::MatchBest);
+ if (!icon.isValid()) {
+#ifdef HAVE_LIBART
+ icon=icontheme.iconPath("exec.svg", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewExec->setPixmap(*engine.image());
+ else {
+ icon=icontheme.iconPath("exec.svgz", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewExec->setPixmap(*engine.image());
+ }
+#endif
+ }
+ else
+ m_previewExec->setPixmap(QPixmap(icon.path));
+
+ icon=icontheme.iconPath("folder.png",size,KIcon::MatchBest);
+ if (!icon.isValid()) {
+#ifdef HAVE_LIBART
+ icon=icontheme.iconPath("folder.svg", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewFolder->setPixmap(*engine.image());
+ else {
+ icon=icontheme.iconPath("folder.svgz", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewFolder->setPixmap(*engine.image());
+ }
+#endif
+ }
+ else
+ m_previewFolder->setPixmap(QPixmap(icon.path));
+
+ icon=icontheme.iconPath("txt.png",size,KIcon::MatchBest);
+ if (!icon.isValid()) {
+#ifdef HAVE_LIBART
+ icon=icontheme.iconPath("txt.svg", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewDocument->setPixmap(*engine.image());
+ else {
+ icon=icontheme.iconPath("txt.svgz", size, KIcon::MatchBest);
+ if(engine.load(size, size, icon.path))
+ m_previewDocument->setPixmap(*engine.image());
+ }
+#endif
+ }
+ else
+ m_previewDocument->setPixmap(QPixmap(icon.path));
+
+ emit changed(true);
+ m_bChanged = true;
+}
+
+void IconThemesConfig::load()
+{
+ m_defaultTheme=iconThemeItem(KIconTheme::current());
+ m_iconThemes->setSelected(m_defaultTheme, true);
+ updateRemoveButton();
+
+ emit changed(false);
+ m_bChanged = false;
+}
+
+void IconThemesConfig::save()
+{
+ if (!m_bChanged)
+ return;
+ QListViewItem *selected = m_iconThemes->selectedItem();
+ if (!selected)
+ return;
+
+ KSimpleConfig *config = new KSimpleConfig("kdeglobals", false);
+ config->setGroup("Icons");
+ config->writeEntry("Theme", m_themeNames[selected->text(0)]);
+ delete config;
+
+ KIconTheme::reconfigure();
+ emit changed(false);
+
+ for (int i=0; i<KIcon::LastGroup; i++)
+ {
+ KIPC::sendMessageAll(KIPC::IconChanged, i);
+ }
+
+ KService::rebuildKSycoca(this);
+
+ m_bChanged = false;
+ m_removeButton->setEnabled(false);
+}
+
+void IconThemesConfig::defaults()
+{
+ if (m_iconThemes->currentItem()==m_defaultTheme) return;
+
+ m_iconThemes->setSelected(m_defaultTheme, true);
+ updateRemoveButton();
+
+ emit changed(true);
+ m_bChanged = true;
+}
+
+#include "iconthemes.moc"
diff --git a/kcontrol/icons/iconthemes.h b/kcontrol/icons/iconthemes.h
new file mode 100644
index 000000000..d6d1a9e91
--- /dev/null
+++ b/kcontrol/icons/iconthemes.h
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2000 Antonio Larrosa <larrosa@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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef ICONTHEMES_H
+#define ICONTHEMES_H
+
+#include <kcmodule.h>
+#include <qmap.h>
+#include <klistview.h>
+
+class QPushButton;
+class DeviceManager;
+class QCheckBox;
+class QStringList;
+
+
+class IconThemesConfig : public KCModule
+{
+ Q_OBJECT
+
+public:
+ IconThemesConfig(QWidget *parent = 0L, const char *name = 0L);
+ virtual ~IconThemesConfig();
+
+ void loadThemes();
+ bool installThemes(const QStringList &themes, const QString &archiveName);
+ QStringList findThemeDirs(const QString &archiveName);
+
+ void updateRemoveButton();
+
+ void load();
+ void save();
+ void defaults();
+
+ int buttons();
+
+protected slots:
+ void themeSelected(QListViewItem *item);
+ void installNewTheme();
+ void removeSelectedTheme();
+
+private:
+ QListViewItem *iconThemeItem(const QString &name);
+
+ KListView *m_iconThemes;
+ QPushButton *m_removeButton;
+
+ QLabel *m_previewExec;
+ QLabel *m_previewFolder;
+ QLabel *m_previewDocument;
+ QListViewItem *m_defaultTheme;
+ QMap <QString, QString>m_themeNames;
+ bool m_bChanged;
+};
+
+#endif // ICONTHEMES_H
+
diff --git a/kcontrol/icons/main.cpp b/kcontrol/icons/main.cpp
new file mode 100644
index 000000000..fe8c8c1b3
--- /dev/null
+++ b/kcontrol/icons/main.cpp
@@ -0,0 +1,105 @@
+/*
+ * main.cpp
+ *
+ * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <qlayout.h>
+
+#include <kgenericfactory.h>
+#include <kaboutdata.h>
+
+#include "icons.h"
+#include "iconthemes.h"
+#include "main.h"
+
+/**** DLL Interface ****/
+typedef KGenericFactory<IconModule, QWidget> IconsFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_icons, IconsFactory("kcmicons") )
+
+/**** IconModule ****/
+
+IconModule::IconModule(QWidget *parent, const char *name, const QStringList &)
+ : KCModule(IconsFactory::instance(), parent, name)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ tab = new QTabWidget(this);
+ layout->addWidget(tab);
+
+ tab1 = new IconThemesConfig(this, "themes");
+ tab->addTab(tab1, i18n("&Theme"));
+ connect(tab1, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
+
+ tab2 = new KIconConfig(this, "effects");
+ tab->addTab(tab2, i18n("Ad&vanced"));
+ connect(tab2, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
+
+ KAboutData* about = new KAboutData("kcmicons", I18N_NOOP("Icons"), "3.0",
+ I18N_NOOP("Icons Control Panel Module"),
+ KAboutData::License_GPL,
+ I18N_NOOP("(c) 2000-2003 Geert Jansen"), 0, 0);
+ about->addAuthor("Geert Jansen", 0, "jansen@kde.org");
+ about->addAuthor("Antonio Larrosa Jimenez", 0, "larrosa@kde.org");
+ about->addCredit("Torsten Rahn", 0, "torsten@kde.org");
+ setAboutData( about );
+}
+
+
+void IconModule::load()
+{
+ tab1->load();
+ tab2->load();
+}
+
+
+void IconModule::save()
+{
+ tab1->save();
+ tab2->save();
+}
+
+
+void IconModule::defaults()
+{
+ tab1->defaults();
+ tab2->defaults();
+}
+
+
+void IconModule::moduleChanged(bool state)
+{
+ emit changed(state);
+}
+
+QString IconModule::quickHelp() const
+{
+ return i18n("<h1>Icons</h1>"
+ "This module allows you to choose the icons for your desktop.<p>"
+ "To choose an icon theme, click on its name and apply your choice by pressing the \"Apply\" button below. If you do not want to apply your choice you can press the \"Reset\" button to discard your changes.</p>"
+ "<p>By pressing the \"Install New Theme\" button you can install your new icon theme by writing its location in the box or browsing to the location."
+ " Press the \"OK\" button to finish the installation.</p>"
+ "<p>The \"Remove Theme\" button will only be activated if you select a theme that you installed using this module."
+ " You are not able to remove globally installed themes here.</p>"
+ "<p>You can also specify effects that should be applied to the icons.</p>");
+}
+
+
+
+#include "main.moc"
diff --git a/kcontrol/icons/main.h b/kcontrol/icons/main.h
new file mode 100644
index 000000000..90892351f
--- /dev/null
+++ b/kcontrol/icons/main.h
@@ -0,0 +1,55 @@
+/*
+ * main.h
+ *
+ * Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#ifndef __MAIN_H__
+#define __MAIN_H__
+
+
+#include <qtabwidget.h>
+#include <kcmodule.h>
+
+class IconModule : public KCModule
+{
+ Q_OBJECT
+
+public:
+ IconModule(QWidget *parent, const char *name, const QStringList &);
+
+ void load();
+ void save();
+ void defaults();
+ QString quickHelp() const;
+
+protected slots:
+ void moduleChanged(bool state);
+
+private:
+ QTabWidget *tab;
+
+ KCModule *tab1;
+ KCModule *tab2;
+};
+
+
+#endif
diff --git a/kcontrol/icons/testicons.cpp b/kcontrol/icons/testicons.cpp
new file mode 100644
index 000000000..d47f8af72
--- /dev/null
+++ b/kcontrol/icons/testicons.cpp
@@ -0,0 +1,13 @@
+/* Test programme for icons setup module. */
+
+#include <kapplication.h>
+#include "icons.h"
+
+int main(int argc, char **argv)
+{
+ KApplication app(argc, argv, "testicons");
+ KIconConfig *w = new KIconConfig(0L, "testicons");
+ app.setMainWidget(w);
+ w->show();
+ return app.exec();
+}
diff --git a/kcontrol/icons/uninstall.desktop b/kcontrol/icons/uninstall.desktop
new file mode 100644
index 000000000..e1e3e1732
--- /dev/null
+++ b/kcontrol/icons/uninstall.desktop
@@ -0,0 +1,2 @@
+[Desktop Entry]
+Hidden=true