diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 8b2aa1b5301ab60368a03e36df4ff5216726e87d (patch) | |
tree | 36163d4ee667c23b5cf232df2f3004cd0a76202a /kwin-styles/glow/config | |
download | tdeartwork-8b2aa1b5301ab60368a03e36df4ff5216726e87d.tar.gz tdeartwork-8b2aa1b5301ab60368a03e36df4ff5216726e87d.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/kdeartwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kwin-styles/glow/config')
-rw-r--r-- | kwin-styles/glow/config/Makefile.am | 17 | ||||
-rw-r--r-- | kwin-styles/glow/config/bitmaps.h | 55 | ||||
-rw-r--r-- | kwin-styles/glow/config/glowconfigdialog.cpp | 369 | ||||
-rw-r--r-- | kwin-styles/glow/config/glowconfigdialog.h | 91 |
4 files changed, 532 insertions, 0 deletions
diff --git a/kwin-styles/glow/config/Makefile.am b/kwin-styles/glow/config/Makefile.am new file mode 100644 index 00000000..e677ff91 --- /dev/null +++ b/kwin-styles/glow/config/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = kwin_glow_config.la + +kwin_glow_config_la_SOURCES = glowconfigdialog.cpp +kwin_glow_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +kwin_glow_config_la_LIBADD = $(LIB_KDEUI) + +METASOURCES = AUTO +noinst_HEADERS = glowconfigdialog.h + +lnkdir = $(kde_datadir)/kwin/ + + +###KMAKE-start (don't edit or delete this block) + +###KMAKE-end diff --git a/kwin-styles/glow/config/bitmaps.h b/kwin-styles/glow/config/bitmaps.h new file mode 100644 index 00000000..7ecb262a --- /dev/null +++ b/kwin-styles/glow/config/bitmaps.h @@ -0,0 +1,55 @@ +/*************************************************************************** + bitmaps.h - description + ------------------- + begin : Thu Sep 12 2001 + copyright : (C) 2001 by Henning Burchardt + email : h_burchardt@gmx.net + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef BITMAPS_H +#define BITMAPS_H + +#define BITMAP_SIZE 17 + +static unsigned char close_bits[] = { + 0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0xf8,0x00,0x00,0x0c,0x10,0x10,0x60, + 0x30,0x18,0x00,0x60,0x0c,0xc8,0xc0,0x07,0x16,0x80,0x03,0x60,0xc0,0x07,0x00, + 0x60,0x0c,0x00,0x30,0x18,0xf8,0x10,0x10,0x00,0x00,0x00,0x46,0x00,0x00,0xfe, + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x89,0xf3,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static unsigned char help_bits[] = { + 0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0x10,0x00,0x00,0x0c,0x80,0x07,0xb6, + 0x40,0x0c,0x00,0x00,0x0c,0xc8,0x00,0x0c,0x16,0x00,0x06,0xb6,0x00,0x03,0x00, + 0x00,0x01,0x00,0x00,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0xac,0x00,0x00,0xfe, + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x24,0xc4,0x3f,0x40,0x01,0xf3,0x00,0x00, + 0x70,0xb9,0x65,0x40,0x70,0xb9,0x65,0x40 }; +static unsigned char maximizeoff_bits[] = { + 0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0x1e,0x00,0x00,0x0c,0xf0,0x1f,0x60, + 0xf0,0x1f,0x00,0x10,0x10,0xc8,0x10,0x10,0x16,0x10,0x10,0x60,0x10,0x10,0x00, + 0x10,0x10,0x00,0x10,0x10,0x1e,0xf0,0x1f,0x00,0x00,0x00,0x50,0x00,0x00,0xfe, + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x68,0xb9,0x65,0x40,0x01,0xf2,0x00,0x00, + 0x00,0x00,0x00,0x00,0xe0,0xb1,0x65,0x40 }; +static unsigned char minimize_bits[] = { + 0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0x10,0x00,0x00,0x0c,0x00,0x00,0xb6, + 0xe0,0x0f,0x00,0x00,0x00,0xc8,0x20,0x08,0x16,0x60,0x0c,0xb6,0xc0,0x06,0x00, + 0x80,0x03,0x00,0x00,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0xb2,0x00,0x00,0xfe, + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xf2,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; +static unsigned char stickyoff_bits[] = { + 0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0x1e,0x00,0x00,0x0c,0x50,0x15,0x60, + 0xe0,0x00,0x00,0xf0,0x11,0xc8,0xe0,0x00,0x16,0x50,0x15,0x60,0x00,0x00,0x00, + 0x10,0x11,0x00,0x00,0x00,0x1e,0x50,0x15,0x00,0x00,0x00,0x46,0x00,0x00,0xfe, + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x08,0x31,0xf2,0x00,0x00, + 0x00,0x00,0x00,0x00,0x29,0xf2,0x00,0x00 }; + +#endif + diff --git a/kwin-styles/glow/config/glowconfigdialog.cpp b/kwin-styles/glow/config/glowconfigdialog.cpp new file mode 100644 index 00000000..41144c8a --- /dev/null +++ b/kwin-styles/glow/config/glowconfigdialog.cpp @@ -0,0 +1,369 @@ +/*************************************************************************** + glowconfigdialog.cpp - description + ------------------- + begin : Thu Sep 12 2001 + copyright : (C) 2001 by Henning Burchardt + email : h_burchardt@gmx.net + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include <qbitmap.h> +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <qgroupbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qsignalmapper.h> +#include <qstringlist.h> +#include <kconfig.h> +#include <kcolorbutton.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <klocale.h> +#include <kpixmap.h> +#include <kpixmapeffect.h> +#include <kstandarddirs.h> +#include "bitmaps.h" +#include "glowconfigdialog.h" +#include "../resources.h" + +#define NUMBER_OF_BUTTONS 5 + +extern "C" +{ + KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent ) + { + return(new GlowConfigDialog(conf, parent)); + } +} + +GlowConfigDialog::GlowConfigDialog( KConfig * conf, QWidget * parent ) + : QObject(parent) +{ + _glowConfig = new KConfig("kwinglowrc"); + KGlobal::locale()->insertCatalogue("kwin_glow_config"); + + _main_group_box = new QWidget(parent); + QVBoxLayout *main_group_boxLayout = new QVBoxLayout(_main_group_box); + main_group_boxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + main_group_boxLayout->setSpacing(6); + + //------------------------------------------------------------------------- + // themes + + _theme_list_view = new QListView (_main_group_box, "theme_list_view"); + _theme_list_view->addColumn (i18n("Theme")); + _theme_list_view->addColumn (i18n("Button Size")); + _theme_list_view->setAllColumnsShowFocus(true); + _theme_list_view->setResizeMode(QListView::AllColumns); + + main_group_boxLayout->addWidget (_theme_list_view); + QObject::connect (_theme_list_view, SIGNAL(selectionChanged()), + this, SLOT(slotThemeListViewSelectionChanged())); + slotLoadThemeList(); + + _button_glow_color_group_box = new QGroupBox( + 0, Qt::Horizontal, i18n("Button Glow Colors"), _main_group_box); + QHBoxLayout *colorHBoxLayout = + new QHBoxLayout(_button_glow_color_group_box->layout()); + + // create buttons + QSize buttonSize(BITMAP_SIZE, BITMAP_SIZE); + QPixmap pm(buttonSize); + pm.fill(Qt::black); + + _stickyButton = new QPushButton(_button_glow_color_group_box); + pm.setMask(QBitmap(buttonSize, stickyoff_bits, true)); + _stickyButton->setPixmap(pm); + colorHBoxLayout->addWidget(_stickyButton); + _titleButtonList.push_back(_stickyButton); + + _helpButton = new QPushButton(_button_glow_color_group_box); + pm.setMask(QBitmap(buttonSize, help_bits, true)); + _helpButton->setPixmap(pm); + colorHBoxLayout->addWidget(_helpButton); + _titleButtonList.push_back(_helpButton); + + _iconifyButton = new QPushButton(_button_glow_color_group_box); + pm.setMask(QBitmap(buttonSize, minimize_bits, true)); + _iconifyButton->setPixmap(pm); + colorHBoxLayout->addWidget(_iconifyButton); + _titleButtonList.push_back(_iconifyButton); + + _maximizeButton = new QPushButton(_button_glow_color_group_box); + pm.setMask(QBitmap(buttonSize, maximizeoff_bits, true)); + _maximizeButton->setPixmap(pm); + colorHBoxLayout->addWidget(_maximizeButton); + _titleButtonList.push_back(_maximizeButton); + + _closeButton = new QPushButton(_button_glow_color_group_box); + pm.setMask(QBitmap(buttonSize, close_bits, true)); + _closeButton->setPixmap(pm); + colorHBoxLayout->addWidget(_closeButton); + _titleButtonList.push_back(_closeButton); + + // create signal mapper + _titleButtonMapper = new QSignalMapper(this); + for( uint i=0; i<_titleButtonList.size(); i++ ) { + _titleButtonMapper->setMapping(_titleButtonList[i], i); + connect(_titleButtonList[i], SIGNAL(clicked()),_titleButtonMapper, SLOT(map())); + } + connect(_titleButtonMapper, SIGNAL(mapped(int)),this, SLOT(slotTitleButtonClicked(int))); + + _colorButton = new KColorButton(_button_glow_color_group_box); + _colorButton->setEnabled(false); + connect(_colorButton, SIGNAL(changed(const QColor&)), + this, SLOT(slotColorButtonChanged(const QColor&))); + + colorHBoxLayout->addItem(new QSpacerItem( + 200, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); + colorHBoxLayout->addWidget(_colorButton); + + main_group_boxLayout->addWidget(_button_glow_color_group_box); + + QHBoxLayout *titlebarGradientTypeLayout = new QHBoxLayout(); + _titlebarGradientTypeComboBox = new QComboBox(_main_group_box); + + KConfig *c = KGlobal::config(); + KConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); + QColor activeBackground = c->readColorEntry("activeBackground"); + QColor activeBlend = c->readColorEntry("activeBlend"); + + // If the colors are equal, change one to get a gradient effect + if (activeBackground==activeBlend) { + activeBackground = activeBackground.dark(); + } + for (int i=0; i< KPixmapEffect::EllipticGradient; i++ ) { + KPixmap gradPixmap(QSize(196,20)); + KPixmapEffect::gradient(gradPixmap, activeBackground, + activeBlend, (KPixmapEffect::GradientType) i); + + _titlebarGradientTypeComboBox->insertItem(gradPixmap, i); + } + + connect(_titlebarGradientTypeComboBox, SIGNAL(activated(int)), + this, SLOT(slotTitlebarGradientTypeChanged(int))); + titlebarGradientTypeLayout->addWidget( + new QLabel(i18n("Titlebar gradient:"), _main_group_box)); + titlebarGradientTypeLayout->addWidget(_titlebarGradientTypeComboBox, 0, Qt::AlignLeft); + titlebarGradientTypeLayout->addStretch(10); + main_group_boxLayout->addLayout(titlebarGradientTypeLayout); + + + _showResizeHandleCheckBox = new QCheckBox( + i18n("Show resize handle"), _main_group_box); + connect(_showResizeHandleCheckBox, SIGNAL(clicked()), + this, SLOT(slotResizeHandleCheckBoxChanged())); + main_group_boxLayout->addWidget(_showResizeHandleCheckBox); + + // load config and update user interface + load(conf); + + _main_group_box->show(); +} + +GlowConfigDialog::~GlowConfigDialog() +{ + delete _main_group_box; + delete _glowConfig; + delete[] _buttonConfigMap; +} + +void GlowConfigDialog::load( KConfig* /* conf */ ) +{ + QColor color; + const QColor defaultCloseButtonColor(DEFAULT_CLOSE_BUTTON_COLOR); + const QColor defaultMaximizeButtonColor(DEFAULT_MAXIMIZE_BUTTON_COLOR); + const QColor defaultIconifyButtonColor(DEFAULT_ICONIFY_BUTTON_COLOR); + const QColor defaultHelpButtonColor(DEFAULT_HELP_BUTTON_COLOR); + const QColor defaultStickyButtonColor(DEFAULT_STICKY_BUTTON_COLOR); + + _glowConfig->setGroup("General"); + + _buttonConfigMap = new QColor[NUMBER_OF_BUTTONS]; + color = _glowConfig->readColorEntry("stickyButtonGlowColor", + &defaultStickyButtonColor); + _buttonConfigMap[stickyButton] = color; + + color = _glowConfig->readColorEntry("helpButtonGlowColor", + &defaultHelpButtonColor); + _buttonConfigMap[helpButton] = color; + + color = _glowConfig->readColorEntry("iconifyButtonGlowColor", + &defaultIconifyButtonColor); + _buttonConfigMap[iconifyButton] = color; + + color = _glowConfig->readColorEntry("maximizeButtonGlowColor", + &defaultMaximizeButtonColor); + _buttonConfigMap[maximizeButton] = color; + + color = _glowConfig->readColorEntry("closeButtonGlowColor", + &defaultCloseButtonColor); + _buttonConfigMap[closeButton] = color; + + _showResizeHandle = _glowConfig->readBoolEntry("showResizeHandle", true); + _titlebarGradientType = static_cast<KPixmapEffect::GradientType> + (_glowConfig->readNumEntry("titlebarGradientType", + KPixmapEffect::DiagonalGradient)); + + _showResizeHandleCheckBox->setChecked(_showResizeHandle); + _titlebarGradientTypeComboBox->setCurrentItem(_titlebarGradientType); + + _theme_name = _glowConfig->readEntry ("themeName", "default"); + _theme_list_view->setSelected ( + _theme_list_view->findItem (_theme_name, 0), true); + slotTitleButtonClicked(0); +} + +void GlowConfigDialog::save( KConfig* /* conf */ ) +{ + _glowConfig->setGroup("General"); + + _glowConfig->writeEntry("stickyButtonGlowColor", _buttonConfigMap[stickyButton]); + _glowConfig->writeEntry("helpButtonGlowColor", _buttonConfigMap[helpButton]); + _glowConfig->writeEntry("iconifyButtonGlowColor", _buttonConfigMap[iconifyButton]); + _glowConfig->writeEntry("maximizeButtonGlowColor", _buttonConfigMap[maximizeButton]); + _glowConfig->writeEntry("closeButtonGlowColor", _buttonConfigMap[closeButton]); + + _glowConfig->writeEntry("showResizeHandle", _showResizeHandle); + _glowConfig->writeEntry("titlebarGradientType", _titlebarGradientType); + + _glowConfig->writeEntry ("themeName", _theme_name); + + _glowConfig->sync(); +} + +void GlowConfigDialog::defaults() +{ + const QColor defaultCloseButtonColor = DEFAULT_CLOSE_BUTTON_COLOR; + const QColor defaultMaximizeButtonColor(DEFAULT_MAXIMIZE_BUTTON_COLOR); + const QColor defaultIconifyButtonColor(DEFAULT_ICONIFY_BUTTON_COLOR); + const QColor defaultHelpButtonColor(DEFAULT_HELP_BUTTON_COLOR); + const QColor defaultStickyButtonColor(DEFAULT_STICKY_BUTTON_COLOR); + + _buttonConfigMap[stickyButton] = defaultStickyButtonColor; + _buttonConfigMap[helpButton] = defaultHelpButtonColor; + _buttonConfigMap[iconifyButton] = defaultIconifyButtonColor; + _buttonConfigMap[maximizeButton] = defaultMaximizeButtonColor; + _buttonConfigMap[closeButton] = defaultCloseButtonColor; + + _showResizeHandle = true; + _titlebarGradientType = KPixmapEffect::DiagonalGradient; + + _showResizeHandleCheckBox->setChecked(_showResizeHandle); + _titlebarGradientTypeComboBox->setCurrentItem(_titlebarGradientType); + + _theme_list_view->setSelected ( + _theme_list_view->findItem("default", 0), true); +} + +void GlowConfigDialog::slotLoadThemeList () +{ + QStringList dir_list=KGlobal::dirs()->findDirs("data", "kwin/glow-themes"); + + QStringList::ConstIterator it; + + _theme_list_view->clear(); + new QListViewItem (_theme_list_view, "default", "17x17"); + + for (it=dir_list.begin(); it!=dir_list.end(); ++it) + { + QDir dir (*it, QString("*"), QDir::Unsorted, + QDir::Dirs | QDir::Readable); + if (dir.exists()) + { + QFileInfoListIterator it2(*dir.entryInfoList()); + QFileInfo * finfo; + + while ((finfo=it2.current())) + { + if (finfo->fileName() == "." || finfo->fileName() == "..") { + ++it2; + continue; + } + + if (! _theme_list_view->findItem (finfo->fileName(), 0)) + { + KConfig conf (dir.path() + "/" + finfo->fileName() + "/" + + finfo->fileName() + ".theme"); + QSize button_size = conf.readSizeEntry ( + "buttonSize", new QSize (-1, -1)); + if (button_size.width() == -1) + { + ++it2; + continue; + } + QString size_string = QString("") + + QString::number(button_size.width()) + + "x" + QString::number(button_size.height()); + new QListViewItem (_theme_list_view, + finfo->fileName(), size_string); + } + + ++it2; + } + } + } +} + +void GlowConfigDialog::slotTitlebarGradientTypeChanged(int index) +{ + _titlebarGradientType = static_cast<KPixmapEffect::GradientType>(index); + emit changed(); +} + +void GlowConfigDialog::slotResizeHandleCheckBoxChanged() +{ + _showResizeHandle = _showResizeHandleCheckBox->isChecked(); + emit changed(); +} + +void GlowConfigDialog::slotTitleButtonClicked(int index) +{ + for( int i=0; i< ((int) _titleButtonList.size()); i++ ) { + _titleButtonList[i]->setDown(i==index); + } + _colorButton->setEnabled(true); + _colorButton->setColor(_buttonConfigMap[index]); +} + +void GlowConfigDialog::slotColorButtonChanged(const QColor& glowColor) +{ + if( _stickyButton->isDown() ) { + _buttonConfigMap[stickyButton] = glowColor; + } else if( _helpButton->isDown() ) { + _buttonConfigMap[helpButton] = glowColor; + } else if( _iconifyButton->isDown() ) { + _buttonConfigMap[iconifyButton] = glowColor; + } else if( _maximizeButton->isDown() ) { + _buttonConfigMap[maximizeButton] = glowColor; + } else { + _buttonConfigMap[closeButton] = glowColor; + } + emit changed(); +} + +void GlowConfigDialog::slotThemeListViewSelectionChanged () +{ + if( _theme_list_view->selectedItem() != 0 ) { + _theme_name = _theme_list_view->selectedItem()->text (0); + + emit changed(); + } +} + +#include "glowconfigdialog.moc" diff --git a/kwin-styles/glow/config/glowconfigdialog.h b/kwin-styles/glow/config/glowconfigdialog.h new file mode 100644 index 00000000..2190b3ce --- /dev/null +++ b/kwin-styles/glow/config/glowconfigdialog.h @@ -0,0 +1,91 @@ +/*************************************************************************** + glowconfigdialog.h - description + ------------------- + begin : Thu Sep 12 2001 + copyright : (C) 2001 by Henning Burchardt + email : h_burchardt@gmx.net + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef GLOW_CONFIG_DIALOG_H +#define GLOW_CONFIG_DIALOG_H + +#include <qvaluevector.h> +#include <qobject.h> + +class QListView; +class QPushButton; +class QSignalMapper; +class QCheckBox; +class QComboBox; +class KConfig; +class KColorButton; + +class GlowConfigDialog : public QObject +{ + Q_OBJECT + +public: + GlowConfigDialog( KConfig* conf, QWidget* parent ); + ~GlowConfigDialog(); + +signals: + void changed(); + +public slots: + void load( KConfig* conf ); + void save( KConfig* conf ); + void defaults(); + +protected slots: + void slotTitleButtonClicked(int); + void slotColorButtonChanged(const QColor&); + void slotTitlebarGradientTypeChanged(int); + void slotResizeHandleCheckBoxChanged(); + void slotThemeListViewSelectionChanged (); + +private slots: + void slotLoadThemeList (); + +private: + enum ButtonType{stickyButton, helpButton, iconifyButton, + maximizeButton, closeButton }; + + KConfig *_glowConfig; + + bool _showResizeHandle; + KPixmapEffect::GradientType _titlebarGradientType; + QString _theme_name; + + QWidget *_main_group_box; + QGroupBox *_button_glow_color_group_box; + QGroupBox *_theme_group_box; + + QListView * _theme_list_view; + + QCheckBox *_showResizeHandleCheckBox; + QComboBox *_titlebarGradientTypeComboBox; + + QPushButton *_stickyButton; + QPushButton *_helpButton; + QPushButton *_iconifyButton; + QPushButton *_maximizeButton; + QPushButton *_closeButton; + QSignalMapper *_titleButtonMapper; + + QColor* _buttonConfigMap; + QValueVector<QPushButton*> _titleButtonList; + + KColorButton *_colorButton; +}; + +#endif + |