Moved glow style from kdebase to kdeartwork.
svn path=/trunk/kdebase/kwin/; revision=114608
This commit is contained in:
parent
5a8b6fac89
commit
a06d4a5577
11 changed files with 0 additions and 1900 deletions
|
@ -1,25 +0,0 @@
|
|||
|
||||
INCLUDES = $(all_includes)
|
||||
|
||||
SUBDIRS = . config
|
||||
|
||||
kde_module_LTLIBRARIES = libkwinglow.la
|
||||
|
||||
libkwinglow_la_SOURCES = glowclient.cpp glowbutton.cpp
|
||||
libkwinglow_la_LIBADD = ../../kwin.la
|
||||
libkwinglow_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
|
||||
|
||||
METASOURCES = AUTO
|
||||
noinst_HEADERS = glowclient.h bitmaps.h glowbutton.h
|
||||
|
||||
datadir = $(kde_datadir)/kwin/
|
||||
data_DATA = glow.desktop
|
||||
|
||||
confdir = $(kde_confdir)
|
||||
conf_DATA = kwinglowrc
|
||||
|
||||
EXTRA_DIST = $(data_DATA) $(conf_DATA)
|
||||
|
||||
###KMAKE-start (don't edit or delete this block)
|
||||
|
||||
###KMAKE-end
|
|
@ -1,97 +0,0 @@
|
|||
/***************************************************************************
|
||||
bitmaps.h - description
|
||||
-------------------
|
||||
begin : Thu Sep 12 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#define DEFAULT_BITMAP_SIZE 17
|
||||
#define SMALL_BITMAP_SIZE 13
|
||||
|
||||
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 close_small_bits[] = {
|
||||
0x00,0xc0,0x00,0x00,0x00,0xa0,0x00,0x20,0x10,0xc1,0xb0,0x01,0xe0,0x00,0xb0,
|
||||
0x81,0x10,0x01,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x81,0xf2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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 help_small_bits[] = {
|
||||
0x00,0xc0,0x00,0x00,0x00,0xa0,0x00,0x20,0xe0,0xc0,0x80,0x00,0xc0,0x00,0x40,
|
||||
0x00,0x40,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xc2,0x08,0x91,0xf2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
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 maximizeoff_small_bits[] = {
|
||||
0x00,0xa0,0x00,0x00,0x00,0xa0,0x00,0x20,0xf0,0xa1,0xf0,0x01,0x10,0x01,0x10,
|
||||
0x01,0xf0,0x01,0x00,0xa0,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x49,0xf3,0x00,0x00,0x68,0xb9,0x65,0x40,0x68,0xb9,0x65,0x40,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
static unsigned char maximizeon_bits[] = {
|
||||
0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0xf8,0x00,0x00,0x0c,0xf0,0x07,0x60,
|
||||
0xf0,0x07,0x00,0x10,0x04,0xc8,0xd0,0x1f,0x16,0xd0,0x1f,0x60,0x70,0x10,0x00,
|
||||
0x40,0x10,0x00,0x40,0x10,0xf8,0xc0,0x1f,0x00,0x00,0x00,0xcc,0x00,0x00,0xfe,
|
||||
0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0xec,0xad,0x07,0x08,0x59,0xf2,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
static unsigned char maximizeon_small_bits[] = {
|
||||
0x00,0xc0,0x00,0x00,0x00,0xa0,0x00,0x20,0xf0,0xc0,0x90,0x00,0xf0,0x01,0x20,
|
||||
0x81,0xe0,0x01,0x00,0x60,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x81,
|
||||
0x08,0x08,0x19,0xf3,0x00,0x00,0x58,0xab,0x07,0x08,0x90,0xb9,0x65,0x40,0x8c,
|
||||
0x81,0x08,0x08,0x21,0x00,0x00,0x00 };
|
||||
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 minimize_small_bits[] = {
|
||||
0x00,0xc0,0x00,0x00,0x00,0xa0,0x00,0x20,0xf0,0xc1,0x00,0x00,0xf0,0x01,0xe0,
|
||||
0x00,0x40,0x00,0x00,0x80,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0xad,
|
||||
0x07,0x08,0x21,0xf3,0x00,0x00,0x68,0xb9,0x65,0x40,0x68,0xb9,0x65,0x40,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 };
|
||||
static unsigned char stickyoff_small_bits[] = {
|
||||
0x00,0xa0,0x00,0x00,0x00,0xa0,0x00,0x20,0xf0,0xa1,0x30,0x01,0x50,0x01,0x10,
|
||||
0x01,0xf0,0x01,0x00,0xc0,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,
|
||||
0x00,0x00,0x59,0xf3,0x00,0x00,0x68,0xb9,0x65,0x40,0x68,0xb9,0x65,0x40,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
static unsigned char stickyon_bits[] = {
|
||||
0x00,0x00,0x16,0x00,0x00,0x16,0x00,0x00,0xf8,0x00,0x00,0x0c,0x50,0x15,0x60,
|
||||
0xe0,0x0e,0x00,0xf0,0x1f,0xc8,0xe0,0x0e,0x16,0x50,0x15,0x60,0xe0,0x0e,0x00,
|
||||
0xf0,0x1f,0x00,0xe0,0x0e,0xf8,0x50,0x15,0x00,0x00,0x00,0xac,0x00,0x00,0xfe,
|
||||
0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x40,0x69,0xf2,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
||||
static unsigned char stickyon_small_bits[] = {
|
||||
0x00,0xc0,0x00,0x00,0x00,0xa0,0x00,0x20,0xf0,0xc1,0xb0,0x01,0x50,0x01,0xb0,
|
||||
0x81,0xf0,0x01,0x00,0xc0,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xb8,0xb9,
|
||||
0x65,0x40,0x49,0xf3,0x00,0x00,0xb0,0xb9,0x65,0x40,0xb0,0xb9,0x65,0x40,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00 };
|
|
@ -1,19 +0,0 @@
|
|||
INCLUDES = $(all_includes)
|
||||
|
||||
kde_module_LTLIBRARIES = libkwinglow_config.la
|
||||
|
||||
libkwinglow_config_la_SOURCES = glowconfigdialog.cpp
|
||||
libkwinglow_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
|
||||
libkwinglow_config_la_LIBADD = $(LIB_KDEUI)
|
||||
|
||||
METASOURCES = AUTO
|
||||
noinst_HEADERS = glowconfigdialog.h
|
||||
|
||||
lnkdir = $(kde_datadir)/kwin/
|
||||
|
||||
messages:
|
||||
$(XGETTEXT) *.cpp -o $(podir)/libkwinglow_config.pot
|
||||
|
||||
###KMAKE-start (don't edit or delete this block)
|
||||
|
||||
###KMAKE-end
|
|
@ -1,370 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowconfigdialog.cpp - description
|
||||
-------------------
|
||||
begin : Thu Sep 12 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 <qcheckbox.h>
|
||||
#include <qgroupbox.h>
|
||||
#include <qwhatsthis.h>
|
||||
#include <qlayout.h>
|
||||
#include <qabstractlayout.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qsignalmapper.h>
|
||||
#include <qradiobutton.h>
|
||||
#include <kglobal.h>
|
||||
#include <kconfig.h>
|
||||
#include <klocale.h>
|
||||
#include <kcolorbutton.h>
|
||||
|
||||
#include "glowconfigdialog.h"
|
||||
#include "../bitmaps.h"
|
||||
|
||||
#define DEFAULT_BUTTON_COLOR Qt::white
|
||||
#define DEFAULT_CLOSE_BUTTON_COLOR Qt::red
|
||||
|
||||
extern "C"
|
||||
{
|
||||
QObject* allocate_config( KConfig* conf, QWidget* parent )
|
||||
{
|
||||
return(new GlowConfigDialog(conf, parent));
|
||||
}
|
||||
}
|
||||
|
||||
GlowConfigDialog::GlowConfigDialog( KConfig * conf, QWidget * parent )
|
||||
: QObject(parent)
|
||||
{
|
||||
m_glowConfig = new KConfig("kwinglowrc");
|
||||
KGlobal::locale()->insertCatalogue("libkwinglow_config");
|
||||
|
||||
m_mainGroupBox = new QGroupBox(
|
||||
1, Qt::Vertical, i18n("Decoration Settings"), parent);
|
||||
|
||||
QGroupBox *buttonGlowColorGroupBox = new QGroupBox(
|
||||
0, Qt::Vertical, i18n("Glow Colors"), m_mainGroupBox);
|
||||
|
||||
QHBoxLayout *buttonGlowColorGroupBoxLayout =
|
||||
new QHBoxLayout(buttonGlowColorGroupBox->layout());
|
||||
|
||||
QVBoxLayout *buttonLayout = new QVBoxLayout(3);
|
||||
|
||||
// create buttons
|
||||
QSize buttonSize(DEFAULT_BITMAP_SIZE, DEFAULT_BITMAP_SIZE);
|
||||
QPixmap pm(buttonSize);
|
||||
pm.fill(Qt::black);
|
||||
|
||||
m_stickyButton = new QPushButton(buttonGlowColorGroupBox);
|
||||
pm.setMask(QBitmap(buttonSize, stickyoff_bits, true));
|
||||
m_stickyButton->setPixmap(pm);
|
||||
buttonLayout->addWidget(m_stickyButton);
|
||||
m_titleButtonList.push_back(m_stickyButton);
|
||||
|
||||
m_helpButton = new QPushButton(buttonGlowColorGroupBox);
|
||||
pm.setMask(QBitmap(buttonSize, help_bits, true));
|
||||
m_helpButton->setPixmap(pm);
|
||||
buttonLayout->addWidget(m_helpButton);
|
||||
m_titleButtonList.push_back(m_helpButton);
|
||||
|
||||
m_iconifyButton = new QPushButton(buttonGlowColorGroupBox);
|
||||
pm.setMask(QBitmap(buttonSize, minimize_bits, true));
|
||||
m_iconifyButton->setPixmap(pm);
|
||||
buttonLayout->addWidget(m_iconifyButton);
|
||||
m_titleButtonList.push_back(m_iconifyButton);
|
||||
|
||||
m_maximizeButton = new QPushButton(buttonGlowColorGroupBox);
|
||||
pm.setMask(QBitmap(buttonSize, maximizeoff_bits, true));
|
||||
m_maximizeButton->setPixmap(pm);
|
||||
buttonLayout->addWidget(m_maximizeButton);
|
||||
m_titleButtonList.push_back(m_maximizeButton);
|
||||
|
||||
m_closeButton = new QPushButton(buttonGlowColorGroupBox);
|
||||
pm.setMask(QBitmap(buttonSize, close_bits, true));
|
||||
m_closeButton->setPixmap(pm);
|
||||
buttonLayout->addWidget(m_closeButton);
|
||||
m_titleButtonList.push_back(m_closeButton);
|
||||
|
||||
// create signal mapper
|
||||
m_titleButtonMapper = new QSignalMapper(this);
|
||||
for( int i=0; i<m_titleButtonList.size(); i++ )
|
||||
{
|
||||
m_titleButtonMapper->setMapping(m_titleButtonList[i], i);
|
||||
QObject::connect(m_titleButtonList[i], SIGNAL(clicked()),
|
||||
m_titleButtonMapper, SLOT(map()));
|
||||
}
|
||||
QObject::connect(m_titleButtonMapper, SIGNAL(mapped(int)),
|
||||
this, SLOT(slotTitleButtonClicked(int)));
|
||||
|
||||
buttonGlowColorGroupBoxLayout->addLayout(buttonLayout);
|
||||
buttonGlowColorGroupBoxLayout->addSpacing(20);
|
||||
|
||||
QGroupBox *innerButtonGlowColorGroupBox = new QGroupBox(
|
||||
0, Qt::Vertical, buttonGlowColorGroupBox);
|
||||
|
||||
QGridLayout *innerButtonGlowColorGroupBoxLayout = new QGridLayout(
|
||||
innerButtonGlowColorGroupBox->layout(), 3, 2);
|
||||
innerButtonGlowColorGroupBoxLayout->setAlignment(
|
||||
Qt::AlignTop | Qt::AlignLeft);
|
||||
|
||||
// create color radio buttons
|
||||
m_titleBarColorButton = new QRadioButton(
|
||||
i18n("Title bar color"), innerButtonGlowColorGroupBox);
|
||||
m_colorRadioButtonList.push_back(m_titleBarColorButton);
|
||||
innerButtonGlowColorGroupBoxLayout->addWidget(
|
||||
m_titleBarColorButton, 0, 0);
|
||||
|
||||
m_titleBlendColorButton = new QRadioButton(
|
||||
i18n("Title blend color"), innerButtonGlowColorGroupBox);
|
||||
m_colorRadioButtonList.push_back(m_titleBlendColorButton);
|
||||
innerButtonGlowColorGroupBoxLayout->addWidget(
|
||||
m_titleBlendColorButton, 1, 0);
|
||||
|
||||
m_customColorButton = new QRadioButton(
|
||||
i18n("Custom color"), innerButtonGlowColorGroupBox);
|
||||
m_colorRadioButtonList.push_back(m_customColorButton);
|
||||
innerButtonGlowColorGroupBoxLayout->addWidget(
|
||||
m_customColorButton, 2, 0);
|
||||
|
||||
m_colorRadioButtonMapper = new QSignalMapper(this);
|
||||
for(int i=0; i<m_colorRadioButtonList.size(); i++ )
|
||||
{
|
||||
m_colorRadioButtonMapper->setMapping(m_colorRadioButtonList[i], i);
|
||||
QObject::connect(m_colorRadioButtonList[i], SIGNAL(clicked()),
|
||||
m_colorRadioButtonMapper, SLOT(map()));
|
||||
}
|
||||
QObject::connect(m_colorRadioButtonMapper, SIGNAL(mapped(int)),
|
||||
this, SLOT(slotColorRadioButtonClicked(int)));
|
||||
|
||||
m_colorButton = new KColorButton(innerButtonGlowColorGroupBox);
|
||||
innerButtonGlowColorGroupBoxLayout->addWidget(
|
||||
m_colorButton, 2, 1);
|
||||
|
||||
buttonGlowColorGroupBoxLayout->addWidget(innerButtonGlowColorGroupBox);
|
||||
buttonGlowColorGroupBoxLayout->addItem(new QSpacerItem(
|
||||
20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||
|
||||
// load config and update user interface
|
||||
load(conf);
|
||||
|
||||
m_mainGroupBox->show();
|
||||
}
|
||||
|
||||
GlowConfigDialog::~GlowConfigDialog()
|
||||
{
|
||||
delete m_mainGroupBox;
|
||||
}
|
||||
|
||||
void GlowConfigDialog::load( KConfig* conf )
|
||||
{
|
||||
m_glowConfig->setGroup("General");
|
||||
|
||||
QColor defaultButtonColor = DEFAULT_BUTTON_COLOR;
|
||||
QColor defaultCloseButtonColor = DEFAULT_CLOSE_BUTTON_COLOR;
|
||||
struct ButtonConfig cnf;
|
||||
|
||||
cnf.glowType = m_glowConfig->readEntry(
|
||||
"stickyButtonGlowType", "TitleBar");
|
||||
cnf.glowColor = m_glowConfig->readColorEntry(
|
||||
"stickyButtonGlowColor", &defaultButtonColor);
|
||||
m_buttonConfigMap["stickyButton"] = cnf;
|
||||
|
||||
cnf.glowType = m_glowConfig->readEntry(
|
||||
"helpButtonGlowType", "TitleBar");
|
||||
cnf.glowColor = m_glowConfig->readColorEntry(
|
||||
"helpButtonGlowColor", &defaultButtonColor);
|
||||
m_buttonConfigMap["helpButton"] = cnf;
|
||||
|
||||
cnf.glowType = m_glowConfig->readEntry(
|
||||
"iconifyButtonGlowType", "TitleBar");
|
||||
cnf.glowColor = m_glowConfig->readColorEntry(
|
||||
"iconifyButtonGlowColor", &defaultButtonColor);
|
||||
m_buttonConfigMap["iconifyButton"] = cnf;
|
||||
|
||||
cnf.glowType = m_glowConfig->readEntry(
|
||||
"maximizeButtonGlowType", "TitleBar");
|
||||
cnf.glowColor = m_glowConfig->readColorEntry(
|
||||
"maximizeButtonGlowColor", &defaultButtonColor);
|
||||
m_buttonConfigMap["maximizeButton"] = cnf;
|
||||
|
||||
cnf.glowType = m_glowConfig->readEntry(
|
||||
"closeButtonGlowType", "Custom");
|
||||
cnf.glowColor = m_glowConfig->readColorEntry(
|
||||
"closeButtonGlowColor", &defaultCloseButtonColor);
|
||||
m_buttonConfigMap["closeButton"] = cnf;
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::save( KConfig *conf )
|
||||
{
|
||||
updateConfig();
|
||||
|
||||
m_glowConfig->setGroup("General");
|
||||
|
||||
struct ButtonConfig cnf;
|
||||
|
||||
cnf = m_buttonConfigMap["stickyButton"];
|
||||
m_glowConfig->writeEntry("stickyButtonGlowType", cnf.glowType);
|
||||
m_glowConfig->writeEntry("stickyButtonGlowColor", cnf.glowColor);
|
||||
|
||||
cnf = m_buttonConfigMap["helpButton"];
|
||||
m_glowConfig->writeEntry("helpButtonGlowType", cnf.glowType);
|
||||
m_glowConfig->writeEntry("helpButtonGlowColor", cnf.glowColor);
|
||||
|
||||
cnf = m_buttonConfigMap["iconifyButton"];
|
||||
m_glowConfig->writeEntry("iconifyButtonGlowType", cnf.glowType);
|
||||
m_glowConfig->writeEntry("iconifyButtonGlowColor", cnf.glowColor);
|
||||
|
||||
cnf = m_buttonConfigMap["maximizeButton"];
|
||||
m_glowConfig->writeEntry("maximizeButtonGlowType", cnf.glowType);
|
||||
m_glowConfig->writeEntry("maximizeButtonGlowColor", cnf.glowColor);
|
||||
|
||||
cnf = m_buttonConfigMap["closeButton"];
|
||||
m_glowConfig->writeEntry("closeButtonGlowType", cnf.glowType);
|
||||
m_glowConfig->writeEntry("closeButtonGlowColor", cnf.glowColor);
|
||||
|
||||
m_glowConfig->sync();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::defaults()
|
||||
{
|
||||
QColor defaultButtonColor = DEFAULT_BUTTON_COLOR;
|
||||
QColor defaultCloseButtonColor = DEFAULT_CLOSE_BUTTON_COLOR;
|
||||
struct ButtonConfig cnf;
|
||||
|
||||
cnf.glowType = "TitleBar";
|
||||
cnf.glowColor = defaultButtonColor;
|
||||
|
||||
m_buttonConfigMap["stickyButton"] = cnf;
|
||||
m_buttonConfigMap["helpButton"] = cnf;
|
||||
m_buttonConfigMap["iconifyButton"] = cnf;
|
||||
m_buttonConfigMap["maximizeButton"] = cnf;
|
||||
|
||||
cnf.glowType = "Custom";
|
||||
cnf.glowColor = defaultCloseButtonColor;
|
||||
|
||||
m_buttonConfigMap["closeButton"] = cnf;
|
||||
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::slotSelectionChanged()
|
||||
{
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::slotTitleButtonClicked(int index)
|
||||
{
|
||||
updateConfig();
|
||||
for( int i=0; i<m_titleButtonList.size(); i++ )
|
||||
m_titleButtonList[i]->setDown(i==index);
|
||||
updateUI();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::slotColorRadioButtonClicked(int index)
|
||||
{
|
||||
for( int i=0; i<m_colorRadioButtonList.size(); i++ )
|
||||
m_colorRadioButtonList[i]->setChecked(i==index);
|
||||
m_colorButton->setEnabled(
|
||||
m_colorRadioButtonList[index]==m_customColorButton);
|
||||
|
||||
updateConfig();
|
||||
slotSelectionChanged();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::slotColorButtonChanged(const QColor&)
|
||||
{
|
||||
updateConfig();
|
||||
slotSelectionChanged();
|
||||
}
|
||||
|
||||
void GlowConfigDialog::updateUI()
|
||||
{
|
||||
struct ButtonConfig cnf;
|
||||
if( m_stickyButton->isDown() )
|
||||
cnf = m_buttonConfigMap["stickyButton"];
|
||||
else if( m_helpButton->isDown() )
|
||||
cnf = m_buttonConfigMap["helpButton"];
|
||||
else if( m_iconifyButton->isDown() )
|
||||
cnf = m_buttonConfigMap["iconifyButton"];
|
||||
else if( m_maximizeButton->isDown() )
|
||||
cnf = m_buttonConfigMap["maximizeButton"];
|
||||
else if( m_closeButton->isDown() )
|
||||
cnf = m_buttonConfigMap["closeButton"];
|
||||
else
|
||||
{
|
||||
m_stickyButton->setDown(true);
|
||||
cnf = m_buttonConfigMap["stickyButton"];
|
||||
}
|
||||
|
||||
if( cnf.glowType == "TitleBar" )
|
||||
{
|
||||
m_titleBarColorButton->setChecked(true);
|
||||
m_titleBlendColorButton->setChecked(false);
|
||||
m_customColorButton->setChecked(false);
|
||||
}
|
||||
else if( cnf.glowType == "TitleBlend" )
|
||||
{
|
||||
m_titleBarColorButton->setChecked(false);
|
||||
m_titleBlendColorButton->setChecked(true);
|
||||
m_customColorButton->setChecked(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_titleBarColorButton->setChecked(false);
|
||||
m_titleBlendColorButton->setChecked(false);
|
||||
m_customColorButton->setChecked(true);
|
||||
}
|
||||
m_colorButton->setColor(cnf.glowColor);
|
||||
m_colorButton->setEnabled(m_customColorButton->isChecked());
|
||||
}
|
||||
|
||||
void GlowConfigDialog::updateConfig()
|
||||
{
|
||||
QString glowType;
|
||||
if( m_titleBarColorButton->isChecked() )
|
||||
glowType = "TitleBar";
|
||||
else if( m_titleBlendColorButton->isChecked() )
|
||||
glowType = "TitleBlend";
|
||||
else
|
||||
glowType = "Custom";
|
||||
QColor glowColor = m_colorButton->color();
|
||||
if( m_stickyButton->isDown() )
|
||||
{
|
||||
m_buttonConfigMap["stickyButton"].glowType = glowType;
|
||||
m_buttonConfigMap["stickyButton"].glowColor = glowColor;
|
||||
}
|
||||
else if( m_helpButton->isDown() )
|
||||
{
|
||||
m_buttonConfigMap["helpButton"].glowType = glowType;
|
||||
m_buttonConfigMap["helpButton"].glowColor = glowColor;
|
||||
}
|
||||
else if( m_iconifyButton->isDown() )
|
||||
{
|
||||
m_buttonConfigMap["iconifyButton"].glowType = glowType;
|
||||
m_buttonConfigMap["iconifyButton"].glowColor = glowColor;
|
||||
}
|
||||
else if( m_maximizeButton->isDown() )
|
||||
{
|
||||
m_buttonConfigMap["maximizeButton"].glowType = glowType;
|
||||
m_buttonConfigMap["maximizeButton"].glowColor = glowColor;
|
||||
}
|
||||
else // if( m_closeButton->isDown() )
|
||||
{
|
||||
m_buttonConfigMap["closeButton"].glowType = glowType;
|
||||
m_buttonConfigMap["closeButton"].glowColor = glowColor;
|
||||
}
|
||||
}
|
||||
|
||||
#include "glowconfigdialog.moc"
|
|
@ -1,85 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowconfigdialog.h - description
|
||||
-------------------
|
||||
begin : Thu Sep 12 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 <vector>
|
||||
#include <map>
|
||||
#include <qobject.h>
|
||||
|
||||
class QPushButton;
|
||||
class QSignalMapper;
|
||||
class QRadioButton;
|
||||
class KConfig;
|
||||
class KColorButton;
|
||||
|
||||
class GlowConfigDialog : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct ButtonConfig
|
||||
{
|
||||
// one of "TitleBar", "TitleBlend", "Custom"
|
||||
QString glowType;
|
||||
QColor glowColor;
|
||||
};
|
||||
|
||||
GlowConfigDialog( KConfig* conf, QWidget* parent );
|
||||
~GlowConfigDialog();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
public slots:
|
||||
void load( KConfig* conf );
|
||||
void save( KConfig* conf );
|
||||
void defaults();
|
||||
|
||||
protected slots:
|
||||
void slotSelectionChanged(); // Internal use
|
||||
void slotTitleButtonClicked(int);
|
||||
void slotColorRadioButtonClicked(int);
|
||||
void slotColorButtonChanged(const QColor&);
|
||||
|
||||
private:
|
||||
KConfig *m_glowConfig;
|
||||
std::map<QString, ButtonConfig> m_buttonConfigMap;
|
||||
|
||||
QGroupBox *m_mainGroupBox;
|
||||
|
||||
QPushButton *m_stickyButton;
|
||||
QPushButton *m_helpButton;
|
||||
QPushButton *m_iconifyButton;
|
||||
QPushButton *m_maximizeButton;
|
||||
QPushButton *m_closeButton;
|
||||
std::vector<QPushButton*> m_titleButtonList;
|
||||
QSignalMapper *m_titleButtonMapper;
|
||||
|
||||
QRadioButton *m_titleBarColorButton;
|
||||
QRadioButton *m_titleBlendColorButton;
|
||||
QRadioButton *m_customColorButton;
|
||||
std::vector<QRadioButton*> m_colorRadioButtonList;
|
||||
QSignalMapper *m_colorRadioButtonMapper;
|
||||
KColorButton *m_colorButton;
|
||||
|
||||
void updateUI();
|
||||
void updateConfig();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,3 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Glow
|
||||
X-KDE-Library=libkwinglow
|
|
@ -1,346 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowbutton.cpp - description
|
||||
-------------------
|
||||
begin : Thu Sep 6 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 <vector>
|
||||
#include <math.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qpainter.h>
|
||||
#include <qimage.h>
|
||||
#include <qtimer.h>
|
||||
#include "glowbutton.h"
|
||||
|
||||
using namespace KWinInternal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
GlowButton::GlowButton(QWidget *parent, const char *name,
|
||||
const QString& tip, QPixmap *pixmap)
|
||||
: KWinWidgetButton(parent, name, 0, tip), m_pixmap(pixmap)
|
||||
{
|
||||
m_steps = 0;
|
||||
m_updateTime = 50;
|
||||
|
||||
m_timer = new QTimer();
|
||||
QObject::connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
|
||||
m_pos = 0;
|
||||
m_timerStatus = Stop;
|
||||
}
|
||||
|
||||
GlowButton::~GlowButton()
|
||||
{
|
||||
}
|
||||
|
||||
QPixmap *GlowButton::getPixmap()
|
||||
{
|
||||
return m_pixmap;
|
||||
}
|
||||
|
||||
void GlowButton::setPixmap(QPixmap *pixmap)
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
|
||||
// set mask
|
||||
QBitmap mask(width(), height());
|
||||
mask.fill(Qt::color0);
|
||||
bitBlt(&mask, 0, 0, pixmap->mask(), 0, 0, width(), height());
|
||||
setMask(mask);
|
||||
|
||||
// set steps
|
||||
m_steps = pixmap->height()/pixmap->width() - 1;
|
||||
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowButton::paintEvent( QPaintEvent *e )
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
if( m_pixmap != 0 )
|
||||
{
|
||||
int pos = m_pos>=0?m_pos:-m_pos;
|
||||
bitBlt(this, 0, 0, m_pixmap, 0, pos*height(), width(), height());
|
||||
}
|
||||
}
|
||||
|
||||
void GlowButton::enterEvent( QEvent *e )
|
||||
{
|
||||
if( m_pos<0 )
|
||||
m_pos=-m_pos;
|
||||
m_timerStatus = Run;
|
||||
if( ! m_timer->isActive() )
|
||||
m_timer->start(m_updateTime);
|
||||
KWinWidgetButton::enterEvent(e);
|
||||
}
|
||||
|
||||
void GlowButton::leaveEvent( QEvent *e )
|
||||
{
|
||||
m_timerStatus = Stop;
|
||||
if( ! m_timer->isActive() )
|
||||
m_timer->start(m_updateTime);
|
||||
KWinWidgetButton::leaveEvent(e);
|
||||
}
|
||||
|
||||
void GlowButton::mousePressEvent( QMouseEvent *e )
|
||||
{
|
||||
if( m_timer->isActive() )
|
||||
m_timer->stop();
|
||||
m_pos = m_steps;
|
||||
repaint(false);
|
||||
// emit pressed();
|
||||
KWinWidgetButton::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void GlowButton::mouseReleaseEvent( QMouseEvent *e )
|
||||
{
|
||||
QPoint p = mapToParent(mapFromGlobal(e->globalPos()));
|
||||
if( ! geometry().contains(p) )
|
||||
m_timerStatus = Stop;
|
||||
else
|
||||
{
|
||||
emit clicked();
|
||||
emit clicked(e->button());
|
||||
}
|
||||
if( ! m_timer->isActive() )
|
||||
m_timer->start(m_updateTime);
|
||||
// emit released();
|
||||
KWinWidgetButton::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
void GlowButton::slotTimeout()
|
||||
{
|
||||
repaint(false);
|
||||
|
||||
if( m_pos>=m_steps-1 )
|
||||
m_pos = -m_pos;
|
||||
|
||||
if( m_timerStatus==Stop )
|
||||
{
|
||||
if( m_pos==0 )
|
||||
{
|
||||
m_timer->stop();
|
||||
return;
|
||||
}
|
||||
else if( m_pos>0 )
|
||||
m_pos = -m_pos;
|
||||
}
|
||||
|
||||
m_pos++;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
GlowButtonFactory::GlowButtonFactory()
|
||||
{
|
||||
m_steps = 20;
|
||||
}
|
||||
|
||||
int GlowButtonFactory::getSteps()
|
||||
{
|
||||
return m_steps;
|
||||
}
|
||||
|
||||
void GlowButtonFactory::setSteps(int steps)
|
||||
{
|
||||
m_steps = steps;
|
||||
}
|
||||
|
||||
QPixmap* GlowButtonFactory::createGlowButtonPixmap(
|
||||
const QSize& size, const QColor& glowColor,
|
||||
const QColorGroup& colorGroup, const QPixmap& fgPixmap )
|
||||
{
|
||||
QPixmap pm(size);
|
||||
pm.fill(glowColor);
|
||||
return createGlowButtonPixmap(
|
||||
size, pm, colorGroup, fgPixmap);
|
||||
}
|
||||
|
||||
QPixmap* GlowButtonFactory::createGlowButtonPixmap(
|
||||
const QSize& size, const QPixmap& glowPixmap,
|
||||
const QColorGroup& colorGroup, const QPixmap& fgPixmap)
|
||||
{
|
||||
// cerr << "GlowButtonFactory " << "createGlowButtonPixmap " << endl;
|
||||
int w = size.width();
|
||||
int h = size.height();
|
||||
|
||||
std::vector< std::vector<float> > intensityField;
|
||||
intensityField.resize(h);
|
||||
for( int i=0; i<h; i++ )
|
||||
{
|
||||
intensityField[i].resize(w);
|
||||
for( int j=0; j<w; j++ )
|
||||
{
|
||||
float distance = 0;
|
||||
// float distance = sqrt(
|
||||
// ((w/2.0-j)*(w/2.0-j)+(h/2.0-i)*(h/2.0-i))/(w*w/4.0+h*h/4.0) );
|
||||
intensityField[i][j] = (1-distance);
|
||||
}
|
||||
}
|
||||
|
||||
QPainter painter;
|
||||
QPixmap upPixmap(w, h);
|
||||
upPixmap = DrawUtils::drawSimpleRoundButton(size, colorGroup);
|
||||
// upPixmap.fill(colorGroup.background());
|
||||
painter.begin(&upPixmap);
|
||||
// QApplication::style().drawButton(
|
||||
// &painter, 0, 0, w, h, colorGroup, false );
|
||||
painter.drawPixmap(0, 0, fgPixmap);
|
||||
painter.end();
|
||||
|
||||
QPixmap downPixmap(w, h);
|
||||
downPixmap = DrawUtils::drawSimpleRoundButton(size, colorGroup);
|
||||
// downPixmap.fill(colorGroup.background());
|
||||
painter.begin(&downPixmap);
|
||||
// QApplication::style().drawButton(
|
||||
// &painter, 0, 0, w, h, colorGroup, true );
|
||||
painter.drawPixmap(1, 1, fgPixmap);
|
||||
painter.end();
|
||||
|
||||
QPixmap *pm = new QPixmap(w, (m_steps+1)*h);
|
||||
QPixmap fadedPixmap;
|
||||
for( int i=0; i<m_steps; i++ )
|
||||
{
|
||||
// float intensity = (float) i/m_steps;
|
||||
float intensity = (float) i/m_steps/2;
|
||||
fadedPixmap = DrawUtils::fadePixmaps(upPixmap, glowPixmap,
|
||||
intensityField, intensity);
|
||||
bitBlt(pm, 0, i*h, &fadedPixmap);
|
||||
}
|
||||
fadedPixmap = DrawUtils::fadePixmaps(downPixmap, glowPixmap,
|
||||
intensityField, 0.5f);
|
||||
bitBlt(pm, 0, m_steps*h, &fadedPixmap);
|
||||
|
||||
QBitmap simpleMask = DrawUtils::drawSimpleRoundButtonMask(size);
|
||||
QBitmap mask(w, (m_steps+1)*h);
|
||||
mask.fill(Qt::color0);
|
||||
// painter.begin(&mask);
|
||||
for( int i=0; i<m_steps+1; i++ )
|
||||
bitBlt(&mask, 0, i*h, &simpleMask);
|
||||
// QApplication::style().drawButtonMask( &painter, 0, i*h, w, h );
|
||||
// painter.end();
|
||||
|
||||
pm->setMask(mask);
|
||||
return pm;
|
||||
}
|
||||
|
||||
GlowButton* GlowButtonFactory::createGlowButton(
|
||||
QWidget *parent, const char* name, const QString& tip, QPixmap *pixmap)
|
||||
{
|
||||
GlowButton *glowButton = new GlowButton(
|
||||
parent, name, tip, pixmap);
|
||||
return glowButton;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QPixmap DrawUtils::fadePixmaps(
|
||||
const QPixmap& bgPixmap, const QPixmap& fgPixmap,
|
||||
const std::vector< std::vector<float> >& intensityField, float intensity )
|
||||
{
|
||||
// cerr << "DrawUtils " << "fadePixmaps " << endl;
|
||||
QImage bgImg = bgPixmap.convertToImage();
|
||||
QImage fgImg = fgPixmap.convertToImage();
|
||||
QImage newImg(bgImg.width(), bgImg.height(), bgImg.depth());
|
||||
int w = bgImg.width();
|
||||
int h = bgImg.height();
|
||||
for( int y=0; y<h; y++ )
|
||||
{
|
||||
uint* bgLine = (uint*) bgImg.scanLine(y);
|
||||
uint* fgLine = (uint*) fgImg.scanLine(y);
|
||||
uint* newLine = (uint*) newImg.scanLine(y);
|
||||
for( int x=0; x<w; x++ )
|
||||
{
|
||||
QRgb bgRgb = *(bgLine+x);
|
||||
uint bgRed = qRed(bgRgb);
|
||||
uint bgGreen = qGreen(bgRgb);
|
||||
uint bgBlue = qBlue(bgRgb);
|
||||
QRgb fgRgb = *(fgLine+x);
|
||||
uint fgRed = qRed(fgRgb);
|
||||
uint fgGreen = qGreen(fgRgb);
|
||||
uint fgBlue = qBlue(fgRgb);
|
||||
float factor = intensityField[y][x]*intensity;
|
||||
uint newRed = (uint) ((1-factor)*bgRed + factor*fgRed);
|
||||
uint newGreen = (uint) ((1-factor)*bgGreen + factor*fgGreen);
|
||||
uint newBlue = (uint) ((1-factor)*bgBlue + factor*fgBlue);
|
||||
*(newLine+x) = qRgb( newRed, newGreen, newBlue );
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap newPixmap;
|
||||
newPixmap.convertFromImage(newImg);
|
||||
return newPixmap;
|
||||
}
|
||||
|
||||
QPixmap DrawUtils::drawSimpleRoundButton(
|
||||
const QSize& size, const QColorGroup& colorGroup)
|
||||
{
|
||||
QColor mid = colorGroup.button();
|
||||
QColor border = colorGroup.light();
|
||||
int w = size.width();
|
||||
int h = size.height();
|
||||
|
||||
QPainter p;
|
||||
|
||||
std::vector< std::vector<float> > intensityField;
|
||||
intensityField.resize(h);
|
||||
for( int i=0; i<h; i++ )
|
||||
{
|
||||
intensityField[i].resize(w);
|
||||
for( int j=0; j<w; j++ )
|
||||
{
|
||||
float distance = sqrt(
|
||||
((w/2.0-j)*(w/2.0-j)+(h/2.0-i)*(h/2.0-i))/(w*w/4.0+h*h/4.0) );
|
||||
intensityField[i][j] = (1-distance);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap darkPm(size);
|
||||
darkPm.fill(mid);
|
||||
QPixmap lightPm(size);
|
||||
lightPm.fill(border);
|
||||
|
||||
QPixmap pm = fadePixmaps(lightPm, darkPm, intensityField, 1.0);
|
||||
|
||||
p.begin(&pm);
|
||||
int hh, ss, vv;
|
||||
mid.hsv(&hh, &ss, &vv);
|
||||
mid.setHsv(hh, 0, vv);
|
||||
p.setPen(colorGroup.mid());
|
||||
p.drawEllipse(0, 0, w, h);
|
||||
p.end();
|
||||
|
||||
pm.setMask(drawSimpleRoundButtonMask(size));
|
||||
|
||||
return pm;
|
||||
}
|
||||
|
||||
QBitmap DrawUtils::drawSimpleRoundButtonMask( const QSize& size )
|
||||
{
|
||||
int w = size.width();
|
||||
int h = size.height();
|
||||
QPainter p;
|
||||
QBitmap mask(size);
|
||||
mask.fill(Qt::color0);
|
||||
p.begin(&mask);
|
||||
p.setPen(Qt::color1);
|
||||
p.setBrush(Qt::color1);
|
||||
p.drawEllipse(0, 0, w, h);
|
||||
p.end();
|
||||
return mask;
|
||||
}
|
||||
|
||||
#include "glowbutton.moc"
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowbutton.h - description
|
||||
-------------------
|
||||
begin : Thu Sep 14 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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_BUTTON_H
|
||||
#define GLOW_BUTTON_H
|
||||
|
||||
#include <vector>
|
||||
#include <kwin/kwinbutton.h>
|
||||
|
||||
class QPixmap;
|
||||
class QBitmap;
|
||||
class QTimer;
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
class GlowButton : public KWinWidgetButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GlowButton(QWidget *parent, const char* name,
|
||||
const QString& tip, QPixmap *bgPixmap=0);
|
||||
~GlowButton();
|
||||
|
||||
QPixmap *getPixmap();
|
||||
|
||||
/**
|
||||
* Sets the background pixmap of the button.
|
||||
* The pixmap should consist of sub pixmaps of the size of the button which
|
||||
* are placed one below the other. Each sub pixmap is copied on the button
|
||||
* in succession to create the glow effect. The last sub pixmap is used
|
||||
* when the button is pressed.
|
||||
*/
|
||||
void setPixmap(QPixmap* pixmap);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void enterEvent( QEvent * );
|
||||
virtual void leaveEvent( QEvent * );
|
||||
virtual void mousePressEvent( QMouseEvent * );
|
||||
virtual void mouseReleaseEvent( QMouseEvent * );
|
||||
|
||||
protected slots:
|
||||
void slotTimeout();
|
||||
|
||||
private:
|
||||
enum TimerStatus { Run, Stop };
|
||||
|
||||
int m_updateTime;
|
||||
int m_steps;
|
||||
|
||||
QPixmap *m_pixmap;
|
||||
QTimer *m_timer;
|
||||
int m_pos;
|
||||
TimerStatus m_timerStatus;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void clicked(int button);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class GlowButtonFactory
|
||||
{
|
||||
public:
|
||||
GlowButtonFactory();
|
||||
|
||||
int getSteps();
|
||||
|
||||
/**
|
||||
* Sets the number of pixmaps used to create the glow effect of the
|
||||
* glow buttons.
|
||||
*/
|
||||
void setSteps(int steps);
|
||||
|
||||
QPixmap* createGlowButtonPixmap(
|
||||
const QSize& size, const QColor& glowColor,
|
||||
const QColorGroup& colorGroup, const QPixmap& fgPixmap );
|
||||
QPixmap* createGlowButtonPixmap(
|
||||
const QSize& size, const QPixmap& glowPixmap,
|
||||
const QColorGroup& colorGroup, const QPixmap& fgPixmap );
|
||||
GlowButton* createGlowButton(
|
||||
QWidget *parent, const char* name,
|
||||
const QString& tip, QPixmap *pixmap=0);
|
||||
|
||||
private:
|
||||
int m_steps;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class DrawUtils
|
||||
{
|
||||
public:
|
||||
static QPixmap fadePixmaps(
|
||||
const QPixmap& bgPixmap, const QPixmap& glowPixmap,
|
||||
const std::vector< std::vector<float> >& intensityField, float intensity );
|
||||
static QPixmap drawSimpleRoundButton(
|
||||
const QSize& size, const QColorGroup& group);
|
||||
static QBitmap drawSimpleRoundButtonMask(const QSize& size);
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
||||
#endif
|
|
@ -1,678 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowclient.cpp - description
|
||||
-------------------
|
||||
begin : Thu Sep 6 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 <cmath>
|
||||
#include <qpixmap.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qpainter.h>
|
||||
#include <qapplication.h>
|
||||
#include <qlayout.h>
|
||||
#include <qfontmetrics.h>
|
||||
#include <kpixmapeffect.h>
|
||||
#include <kpixmap.h>
|
||||
#include <kconfig.h>
|
||||
#include <kwin/options.h>
|
||||
#include <kwin/workspace.h>
|
||||
#include "bitmaps.h"
|
||||
#include "glowclient.h"
|
||||
#include "glowbutton.h"
|
||||
|
||||
using namespace KWinInternal;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
GlowClientConfig::GlowClientConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void GlowClientConfig::load()
|
||||
{
|
||||
KConfig conf("kwinglowrc");
|
||||
conf.setGroup("General");
|
||||
|
||||
QColor defaultButtonColor = Qt::white;
|
||||
QColor defaultCloseButtonColor = Qt::red;
|
||||
|
||||
QString stickyButtonGlowType =
|
||||
conf.readEntry("stickyButtonGlowType", "TitleBar");
|
||||
if(stickyButtonGlowType=="TitleBar")
|
||||
stickyButtonGlowColor = options->color(Options::TitleBar);
|
||||
else if(stickyButtonGlowType=="TitleBlend")
|
||||
stickyButtonGlowColor = options->color(Options::TitleBlend);
|
||||
else // if( stickyButtonGlowType=="Custom" )
|
||||
stickyButtonGlowColor = conf.readColorEntry(
|
||||
"stickyButtonGlowColor", &defaultButtonColor);
|
||||
|
||||
QString helpButtonGlowType =
|
||||
conf.readEntry("helpButtonGlowType", "TitleBar");
|
||||
if(helpButtonGlowType=="TitleBar")
|
||||
helpButtonGlowColor = options->color(Options::TitleBar);
|
||||
else if(helpButtonGlowType=="TitleBlend")
|
||||
helpButtonGlowColor = options->color(Options::TitleBlend);
|
||||
else // if( helpButtonGlowType=="Custom" )
|
||||
helpButtonGlowColor = conf.readColorEntry(
|
||||
"helpButtonGlowColor", &defaultButtonColor);
|
||||
|
||||
QString iconifyButtonGlowType =
|
||||
conf.readEntry("iconifyButtonGlowType", "TitleBar");
|
||||
if(iconifyButtonGlowType=="TitleBar")
|
||||
iconifyButtonGlowColor = options->color(Options::TitleBar);
|
||||
else if(iconifyButtonGlowType=="TitleBlend")
|
||||
iconifyButtonGlowColor = options->color(Options::TitleBlend);
|
||||
else // if( iconifyButtonGlowType=="Custom" )
|
||||
iconifyButtonGlowColor = conf.readColorEntry(
|
||||
"iconifyButtonGlowColor", &defaultButtonColor);
|
||||
|
||||
QString maximizeButtonGlowType =
|
||||
conf.readEntry("maximizeButtonGlowType", "TitleBar");
|
||||
if(maximizeButtonGlowType=="TitleBar")
|
||||
maximizeButtonGlowColor = options->color(Options::TitleBar);
|
||||
else if(maximizeButtonGlowType=="TitleBlend")
|
||||
maximizeButtonGlowColor = options->color(Options::TitleBlend);
|
||||
else // if( maximizeButtonGlowType=="Custom" )
|
||||
maximizeButtonGlowColor = conf.readColorEntry(
|
||||
"maximizeButtonGlowColor", &defaultButtonColor);
|
||||
|
||||
QString closeButtonGlowType =
|
||||
conf.readEntry("closeButtonGlowType", "Custom");
|
||||
if(closeButtonGlowType=="TitleBar")
|
||||
closeButtonGlowColor = options->color(Options::TitleBar);
|
||||
else if(closeButtonGlowType=="TitleBlend")
|
||||
closeButtonGlowColor = options->color(Options::TitleBlend);
|
||||
else // if( closeButtonGlowType=="Custom" )
|
||||
closeButtonGlowColor = conf.readColorEntry(
|
||||
"closeButtonGlowColor", &defaultCloseButtonColor);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
GlowClientGlobals *GlowClientGlobals::m_instance = 0;
|
||||
|
||||
GlowClientGlobals *GlowClientGlobals::instance()
|
||||
{
|
||||
// cerr << "GlowClientGlobals " << "instance " << endl;
|
||||
if( ! m_instance )
|
||||
m_instance = new GlowClientGlobals();
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
GlowClientGlobals::~GlowClientGlobals()
|
||||
{
|
||||
deletePixmaps();
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
QPixmap *GlowClientGlobals::getPixmap(
|
||||
int type, bool isActive, bool isLeft, bool isSmall)
|
||||
{
|
||||
int modifiers = 0;
|
||||
modifiers |= isActive ? Active : NotActive;
|
||||
modifiers |= isLeft ? PosLeft : PosRight;
|
||||
modifiers |= isSmall ? SizeSmall : SizeNormal;
|
||||
return m_pixmapMap[type][modifiers];
|
||||
}
|
||||
|
||||
GlowClientGlobals::GlowClientGlobals()
|
||||
: QObject()
|
||||
{
|
||||
// cerr << "GlowClientGlobals " << "GlowClientGlobals " << endl;
|
||||
buttonFactory = new GlowButtonFactory();
|
||||
readConfig();
|
||||
createPixmaps();
|
||||
}
|
||||
|
||||
void GlowClientGlobals::readConfig()
|
||||
{
|
||||
config = new GlowClientConfig();
|
||||
config->load();
|
||||
}
|
||||
|
||||
std::vector<int> GlowClientGlobals::getPixmapTypes()
|
||||
{
|
||||
std::vector<int> pixmapTypes;
|
||||
pixmapTypes.push_back(StickyOn);
|
||||
pixmapTypes.push_back(StickyOff);
|
||||
pixmapTypes.push_back(Help);
|
||||
pixmapTypes.push_back(Iconify);
|
||||
pixmapTypes.push_back(MaximizeOn);
|
||||
pixmapTypes.push_back(MaximizeOff);
|
||||
pixmapTypes.push_back(Close);
|
||||
|
||||
return pixmapTypes;
|
||||
}
|
||||
|
||||
std::vector<int> GlowClientGlobals::getPixmapModifiers()
|
||||
{
|
||||
std::vector<int> pixmapModifiers;
|
||||
pixmapModifiers.push_back(Active | PosLeft | SizeSmall);
|
||||
pixmapModifiers.push_back(Active | PosLeft | SizeNormal);
|
||||
pixmapModifiers.push_back(Active | PosRight | SizeSmall);
|
||||
pixmapModifiers.push_back(Active | PosRight | SizeNormal);
|
||||
pixmapModifiers.push_back(NotActive | PosLeft | SizeSmall);
|
||||
pixmapModifiers.push_back(NotActive | PosLeft | SizeNormal);
|
||||
pixmapModifiers.push_back(NotActive | PosRight | SizeSmall);
|
||||
pixmapModifiers.push_back(NotActive | PosRight | SizeNormal);
|
||||
|
||||
return pixmapModifiers;
|
||||
}
|
||||
|
||||
void GlowClientGlobals::reset()
|
||||
{
|
||||
// cerr << "GlowClientGlobals " << "reset " << endl;
|
||||
deletePixmaps();
|
||||
delete config;
|
||||
readConfig();
|
||||
createPixmaps();
|
||||
}
|
||||
|
||||
void GlowClientGlobals::createPixmaps()
|
||||
{
|
||||
// cerr << "GlowClientGlobals " << "createPixmaps " << endl;
|
||||
std::vector<int> types = getPixmapTypes();
|
||||
for( int i=0; i<types.size(); i++ )
|
||||
{
|
||||
std::vector<int> modifiers = getPixmapModifiers();
|
||||
for( int j=0; j<modifiers.size(); j++ )
|
||||
m_pixmapMap[types[i]][modifiers[j]] =
|
||||
createPixmap(types[i],modifiers[j]);
|
||||
}
|
||||
}
|
||||
|
||||
void GlowClientGlobals::deletePixmaps()
|
||||
{
|
||||
std::vector<int> types = getPixmapTypes();
|
||||
for( int i=0; i<types.size(); i++ )
|
||||
{
|
||||
if( m_pixmapMap.find(types[i]) == m_pixmapMap.end() )
|
||||
continue;
|
||||
std::vector<int> modifiers = getPixmapModifiers();
|
||||
std::map<int, QPixmap*> modifierMap = m_pixmapMap[types[i]];
|
||||
for( int j=0; j<modifiers.size(); j++ )
|
||||
if( modifierMap.find(modifiers[j]) == modifierMap.end() )
|
||||
delete modifierMap[modifiers[j]];
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap *GlowClientGlobals::createPixmap(int type, int modifiers)
|
||||
{
|
||||
// cerr << "GlowClientGlobals " << "createPixmap " << endl;
|
||||
bool isActive;
|
||||
if( modifiers & Active )
|
||||
isActive = true;
|
||||
else
|
||||
isActive = false;
|
||||
int size;
|
||||
if( modifiers & SizeNormal )
|
||||
size = DEFAULT_BITMAP_SIZE;
|
||||
else
|
||||
size = SMALL_BITMAP_SIZE;
|
||||
QColorGroup g;
|
||||
if( modifiers & PosLeft )
|
||||
g = options->colorGroup(Options::TitleBar, isActive);
|
||||
else
|
||||
g = options->colorGroup(Options::ButtonBg, isActive);
|
||||
QColor c;
|
||||
if( qGray(g.background().rgb()) <= 127 ) // background is dark
|
||||
c = Qt::white;
|
||||
else // background is light
|
||||
c = Qt::black;
|
||||
|
||||
QPixmap pm(size, size);
|
||||
pm.fill(c);
|
||||
|
||||
if( type == StickyOn )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, stickyon_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, stickyon_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->stickyButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==StickyOff )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, stickyoff_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, stickyoff_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->stickyButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==Help )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, help_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, help_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->helpButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==Iconify )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, minimize_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, minimize_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->iconifyButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==MaximizeOn )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, maximizeon_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, maximizeon_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->maximizeButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==MaximizeOff )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, maximizeoff_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, maximizeoff_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->maximizeButtonGlowColor, g, pm);
|
||||
}
|
||||
else if( type==Close )
|
||||
{
|
||||
if( modifiers & SizeNormal )
|
||||
pm.setMask(QBitmap(size, size, close_bits, true));
|
||||
else
|
||||
pm.setMask(QBitmap(size, size, close_small_bits, true));
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), config->closeButtonGlowColor, g, pm);
|
||||
}
|
||||
else // should not happen
|
||||
return buttonFactory->createGlowButtonPixmap(
|
||||
QSize(size,size), Qt::white, g, QPixmap());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
GlowClient::GlowClient(KWinInternal::Workspace *ws, WId w,
|
||||
QWidget *parent, const char* name )
|
||||
: KWinInternal::Client(ws, w, parent, name),
|
||||
m_stickyButton(0), m_helpButton(0), m_minimizeButton(0),
|
||||
m_maximizeButton(0), m_closeButton(0),
|
||||
m_mainLayout(0)
|
||||
{
|
||||
// cerr << "GlowClient " << "GlowClient " << endl;
|
||||
createButtons();
|
||||
resetLayout();
|
||||
repaint();
|
||||
|
||||
QObject::connect(KWinInternal::options, SIGNAL(resetClients()),
|
||||
this, SLOT(slotReset()));
|
||||
}
|
||||
|
||||
GlowClient::~GlowClient()
|
||||
{
|
||||
// cerr << "GlowClient " << "~GlowClient " << endl;
|
||||
}
|
||||
|
||||
void GlowClient::resizeEvent( QResizeEvent *e )
|
||||
{
|
||||
Client::resizeEvent(e);
|
||||
doShape();
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowClient::paintEvent( QPaintEvent *e )
|
||||
{
|
||||
// cerr << "GlowClient " << "paintEvent " << endl;
|
||||
Client::paintEvent(e);
|
||||
|
||||
QRect r_this = rect();
|
||||
QRect r_title = m_titleSpacer->geometry();
|
||||
QColorGroup titleCg =
|
||||
options->colorGroup(Options::TitleBar, isActive());
|
||||
QColorGroup titleBlendCg =
|
||||
options->colorGroup(Options::TitleBlend, isActive());
|
||||
QColorGroup cg = colorGroup();
|
||||
QColor titleColor = options->color(Options::TitleBar, isActive());
|
||||
QColor titleBlendColor = options->color(Options::TitleBlend, isActive());
|
||||
QPainter painter;
|
||||
|
||||
painter.begin(this);
|
||||
painter.setPen(cg.dark());
|
||||
// draw an outer dark frame
|
||||
painter.drawRect(r_this);
|
||||
// draw a line below title bar
|
||||
painter.drawLine(0, r_title.height()-1,
|
||||
r_this.width()-1, r_title.height()-1);
|
||||
painter.end();
|
||||
|
||||
// pixmap for title bar
|
||||
// int titleBufferWidth = r_title.x() + r_title.width();
|
||||
int titleBufferWidth = width()-2;
|
||||
int titleBufferHeight = r_title.height()-2;
|
||||
KPixmap titleBuffer(QSize(titleBufferWidth, titleBufferHeight));
|
||||
KPixmapEffect::gradient(titleBuffer, titleColor, titleBlendColor,
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
painter.begin(&titleBuffer);
|
||||
painter.setFont(options->font(isActive()));
|
||||
painter.setPen(options->color(Options::Font, isActive()));
|
||||
painter.drawText(r_title.x(), 0,
|
||||
r_title.x()+r_title.width(), titleBufferHeight,
|
||||
Qt::AlignLeft | Qt::AlignVCenter, caption() );
|
||||
painter.end();
|
||||
|
||||
painter.begin(this);
|
||||
painter.drawPixmap(1, 1, titleBuffer);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
void GlowClient::showEvent( QShowEvent *e )
|
||||
{
|
||||
Client::showEvent(e);
|
||||
doShape();
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowClient::mouseDoubleClickEvent( QMouseEvent *e )
|
||||
{
|
||||
if( m_titleSpacer->geometry().contains(e->pos()) )
|
||||
workspace()->performWindowOperation(
|
||||
this, options->operationTitlebarDblClick());
|
||||
}
|
||||
|
||||
void GlowClient::captionChange(const QString&)
|
||||
{
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowClient::activeChange(bool)
|
||||
{
|
||||
updateButtonPixmaps();
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowClient::iconChange()
|
||||
{
|
||||
// we have no (t yet an) icon button, so do nothing
|
||||
}
|
||||
|
||||
void GlowClient::stickyChange(bool on)
|
||||
{
|
||||
if(on)
|
||||
m_stickyButton->setPixmap(
|
||||
GlowClientGlobals::instance()->getPixmap(
|
||||
GlowClientGlobals::StickyOn, isActive(),
|
||||
isLeft(m_stickyButton), isTool()));
|
||||
else
|
||||
m_stickyButton->setPixmap(
|
||||
GlowClientGlobals::instance()->getPixmap(
|
||||
GlowClientGlobals::StickyOff, isActive(),
|
||||
isLeft(m_stickyButton), isTool()));
|
||||
}
|
||||
|
||||
void GlowClient::maximizeChange(bool on)
|
||||
{
|
||||
if(on)
|
||||
m_maximizeButton->setPixmap(
|
||||
GlowClientGlobals::instance()->getPixmap(
|
||||
GlowClientGlobals::MaximizeOn, isActive(),
|
||||
isLeft(m_maximizeButton), isTool()));
|
||||
else
|
||||
m_maximizeButton->setPixmap(
|
||||
GlowClientGlobals::instance()->getPixmap(
|
||||
GlowClientGlobals::MaximizeOff, isActive(),
|
||||
isLeft(m_maximizeButton), isTool()));
|
||||
}
|
||||
|
||||
Client::MousePosition GlowClient::mousePosition(const QPoint &pos) const
|
||||
{
|
||||
// we have no resize handle yet so we return the default position
|
||||
return Client::mousePosition(pos);
|
||||
}
|
||||
|
||||
void GlowClient::createButtons()
|
||||
{
|
||||
// cerr << "GlowClient " << "createButtons " << endl;
|
||||
GlowClientGlobals *globals = GlowClientGlobals::instance();
|
||||
GlowButtonFactory *factory = globals->buttonFactory;
|
||||
int s = isTool() ? SMALL_BITMAP_SIZE : DEFAULT_BITMAP_SIZE;
|
||||
QSize size(s,s);
|
||||
|
||||
m_stickyButton = factory->createGlowButton(
|
||||
this, "StickyButton", "Sticky");
|
||||
m_stickyButton->setFixedSize(size);
|
||||
QObject::connect(m_stickyButton, SIGNAL(clicked()),
|
||||
this, SLOT(toggleSticky()));
|
||||
m_buttonList.insert(m_buttonList.end(), m_stickyButton);
|
||||
|
||||
m_helpButton = factory->createGlowButton(
|
||||
this, "HelpButton", "Help");
|
||||
m_helpButton->setFixedSize(size);
|
||||
QObject::connect(m_helpButton, SIGNAL(clicked()),
|
||||
this, SLOT(contextHelp()));
|
||||
m_buttonList.insert(m_buttonList.end(), m_helpButton);
|
||||
|
||||
m_minimizeButton = factory->createGlowButton(
|
||||
this, "IconifyButton", "Minimize");
|
||||
m_minimizeButton->setFixedSize(size);
|
||||
QObject::connect(m_minimizeButton, SIGNAL(clicked()),
|
||||
this, SLOT(iconify()));
|
||||
m_buttonList.insert(m_buttonList.end(), m_minimizeButton);
|
||||
|
||||
m_maximizeButton=factory->createGlowButton(
|
||||
this, "MaximizeButton", "Maximize");
|
||||
m_maximizeButton->setFixedSize(size);
|
||||
QObject::connect(m_maximizeButton, SIGNAL(clicked(int)),
|
||||
this, SLOT(slotMaximize(int)));
|
||||
m_buttonList.insert(m_buttonList.end(), m_maximizeButton);
|
||||
|
||||
m_closeButton = factory->createGlowButton(
|
||||
this, "CloseButton", "Close");
|
||||
m_closeButton->setFixedSize(size);
|
||||
QObject::connect(m_closeButton, SIGNAL(clicked()),
|
||||
this, SLOT(closeWindow()));
|
||||
m_buttonList.insert(m_buttonList.end(), m_closeButton);
|
||||
}
|
||||
|
||||
void GlowClient::resetLayout()
|
||||
{
|
||||
// cerr << "GlowClient " << "resetLayout " << endl;
|
||||
const unsigned int sideMargin = 2;
|
||||
const unsigned int bottomMargin = 2;
|
||||
const unsigned int titleVMargin = 2;
|
||||
|
||||
QFontMetrics fm(KWinInternal::options->font(isActive(),isTool()));
|
||||
unsigned int titleHeight = QMAX(15, fm.height()+2*titleVMargin);
|
||||
if( titleHeight%2 != 0 )
|
||||
titleHeight+=1;
|
||||
|
||||
if( m_mainLayout )
|
||||
delete m_mainLayout;
|
||||
m_mainLayout = new QVBoxLayout(this, 0, 0);
|
||||
|
||||
// update button positions and colors
|
||||
updateButtonPositions();
|
||||
updateButtonPixmaps();
|
||||
|
||||
QHBoxLayout *topLayout = new QHBoxLayout(m_mainLayout, 1);
|
||||
topLayout->addSpacing(sideMargin);
|
||||
for( unsigned int i=0; i<m_leftButtonList.size(); i++ )
|
||||
topLayout->addWidget(m_leftButtonList[i], Qt::AlignVCenter);
|
||||
topLayout->addSpacing(sideMargin);
|
||||
|
||||
m_titleSpacer = new QSpacerItem(0, titleHeight,
|
||||
QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
topLayout->addItem(m_titleSpacer);
|
||||
|
||||
topLayout->addSpacing(sideMargin);
|
||||
for( unsigned int i=0; i<m_rightButtonList.size(); i++ )
|
||||
topLayout->addWidget(m_rightButtonList[i], Qt::AlignVCenter);
|
||||
topLayout->addSpacing(sideMargin);
|
||||
|
||||
QHBoxLayout *midLayout = new QHBoxLayout(m_mainLayout, 0);
|
||||
midLayout->addSpacing(sideMargin);
|
||||
midLayout->addWidget(windowWrapper());
|
||||
midLayout->addSpacing(sideMargin);
|
||||
|
||||
m_mainLayout->addSpacing(bottomMargin);
|
||||
m_mainLayout->setStretchFactor(topLayout, 0);
|
||||
m_mainLayout->setStretchFactor(midLayout, 1);
|
||||
}
|
||||
|
||||
void GlowClient::updateButtonPositions()
|
||||
{
|
||||
// cerr << "GlowClient " << "updateButtonPositions " << endl;
|
||||
QString buttons = options->titleButtonsLeft() + "|"
|
||||
+ options->titleButtonsRight();
|
||||
std::vector<GlowButton*> *buttonList = &m_leftButtonList;
|
||||
|
||||
// hide all buttons
|
||||
for( unsigned int i=0; i<m_buttonList.size(); i++ )
|
||||
m_buttonList[i]->hide();
|
||||
|
||||
m_leftButtonList.clear();
|
||||
m_rightButtonList.clear();
|
||||
|
||||
for( unsigned int i=0; i<buttons.length(); i++ )
|
||||
{
|
||||
char c = buttons[i].latin1();
|
||||
GlowButton *button = 0;
|
||||
if( c=='S' ) // sticky
|
||||
button = m_stickyButton;
|
||||
else if( c=='H' && providesContextHelp() ) // help
|
||||
button = m_helpButton;
|
||||
else if( c=='I' && isMinimizable() ) // iconify
|
||||
button = m_minimizeButton;
|
||||
else if( c=='A' && isMaximizable() ) // maximize
|
||||
button = m_maximizeButton;
|
||||
else if( c=='X' ) // close
|
||||
button= m_closeButton;
|
||||
else if( c=='|' )
|
||||
buttonList = &m_rightButtonList;
|
||||
|
||||
if(button)
|
||||
{
|
||||
button->show(); // show visible buttons
|
||||
buttonList->insert(buttonList->end(), button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GlowClient::updateButtonPixmaps()
|
||||
{
|
||||
// cerr << "GlowClient " << "updateButtonPixmaps " << endl;
|
||||
GlowClientGlobals *globals = GlowClientGlobals::instance();
|
||||
|
||||
if( isSticky() )
|
||||
m_stickyButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::StickyOn, isActive(),
|
||||
isLeft(m_stickyButton), isTool()));
|
||||
else
|
||||
m_stickyButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::StickyOff, isActive(),
|
||||
isLeft(m_stickyButton), isTool()));
|
||||
|
||||
m_helpButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::Help, isActive(),
|
||||
isLeft(m_helpButton), isTool()));
|
||||
|
||||
m_minimizeButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::Iconify, isActive(),
|
||||
isLeft(m_minimizeButton), isTool()));
|
||||
|
||||
if( isMaximized() )
|
||||
m_maximizeButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::MaximizeOn, isActive(),
|
||||
isLeft(m_maximizeButton), isTool()));
|
||||
else
|
||||
m_maximizeButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::MaximizeOff, isActive(),
|
||||
isLeft(m_maximizeButton), isTool()));
|
||||
|
||||
m_closeButton->setPixmap(globals->getPixmap(
|
||||
GlowClientGlobals::Close, isActive(),
|
||||
isLeft(m_closeButton), isTool()));
|
||||
}
|
||||
|
||||
void GlowClient::doShape()
|
||||
{
|
||||
QRegion mask(QRect(0, 0, width(), height()));
|
||||
mask -= QRect(0, 0, 1, 1);
|
||||
mask -= QRect(width()-1, 0, 1, 1);
|
||||
mask -= QRect(0, height()-1, 1, 1);
|
||||
mask -= QRect(width()-1, height()-1, 1, 1);
|
||||
setMask(mask);
|
||||
}
|
||||
|
||||
bool GlowClient::isLeft(GlowButton *button)
|
||||
{
|
||||
for( unsigned int i=0; i<m_leftButtonList.size(); i++ )
|
||||
if( m_leftButtonList[i] == button )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GlowClient::isRight(GlowButton *button)
|
||||
{
|
||||
for( unsigned int i=0; i<m_rightButtonList.size(); i++ )
|
||||
if( m_rightButtonList[i] == button )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GlowClient::slotReset()
|
||||
{
|
||||
resetLayout();
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void GlowClient::slotMaximize(int button)
|
||||
{
|
||||
if(button == QMouseEvent::RightButton)
|
||||
maximize(MaximizeHorizontal);
|
||||
else if(button == QMouseEvent::MidButton)
|
||||
maximize(MaximizeVertical);
|
||||
else // if(button == QMouseEvent::LeftButton)
|
||||
maximize(MaximizeFull);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Client * allocate(Workspace * ws, WId w)
|
||||
{
|
||||
// cerr << "#### allocate " << endl;
|
||||
return new GlowClient(ws, w);
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
// cerr << "#### init " << endl;
|
||||
GlowClientGlobals::instance();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
// cerr << "#### reset " << endl;
|
||||
GlowClientGlobals::instance()->reset();
|
||||
Workspace::self()->slotResetAllClientsDelayed();
|
||||
}
|
||||
|
||||
void deinit()
|
||||
{
|
||||
// cerr << "#### deinit " << endl;
|
||||
delete GlowClientGlobals::instance();
|
||||
}
|
||||
}
|
||||
|
||||
#include "glowclient.moc"
|
|
@ -1,145 +0,0 @@
|
|||
/***************************************************************************
|
||||
glowclient.h - description
|
||||
-------------------
|
||||
begin : Thu Sep 6 2001
|
||||
copyright : (C) 2001 by Henning Burchardt
|
||||
email : h_burchardt@gmx.de
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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_CLIENT_H
|
||||
#define GLOW_CLIENT_H
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <kwin/client.h>
|
||||
#include <kwin/kwinbutton.h>
|
||||
|
||||
class QPixmap;
|
||||
class QBitmap;
|
||||
class QTimer;
|
||||
class QVBoxLayout;
|
||||
class QSpacerItem;
|
||||
|
||||
namespace KWinInternal
|
||||
{
|
||||
|
||||
class GlowButton;
|
||||
class GlowButtonFactory;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class GlowClientConfig
|
||||
{
|
||||
public:
|
||||
GlowClientConfig();
|
||||
|
||||
void load();
|
||||
|
||||
QColor stickyButtonGlowColor;
|
||||
QColor helpButtonGlowColor;
|
||||
QColor iconifyButtonGlowColor;
|
||||
QColor maximizeButtonGlowColor;
|
||||
QColor closeButtonGlowColor;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class GlowClientGlobals : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PixmapType { StickyOn, StickyOff, Help, Iconify, MaximizeOn,
|
||||
MaximizeOff, Close };
|
||||
enum PixmapModifiers { Active=2, NotActive=4, PosLeft=8, PosRight=16,
|
||||
SizeNormal=32, SizeSmall=64 };
|
||||
|
||||
static GlowClientGlobals *instance();
|
||||
|
||||
~GlowClientGlobals();
|
||||
|
||||
QPixmap *getPixmap(int type, bool isActive, bool isLeft, bool isSmall);
|
||||
std::vector<int> getPixmapTypes();
|
||||
std::vector<int> getPixmapModifiers();
|
||||
|
||||
void reset();
|
||||
|
||||
GlowClientConfig *config;
|
||||
GlowButtonFactory *buttonFactory;
|
||||
|
||||
private:
|
||||
static GlowClientGlobals *m_instance;
|
||||
|
||||
GlowClientGlobals();
|
||||
|
||||
void readConfig();
|
||||
void createPixmaps();
|
||||
void deletePixmaps();
|
||||
QPixmap *createPixmap(int type, int modifiers);
|
||||
|
||||
std::map< int, std::map< int, QPixmap* > > m_pixmapMap;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class GlowClient : public KWinInternal::Client
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GlowClient( KWinInternal::Workspace *ws, WId w,
|
||||
QWidget *parent=0, const char* name=0 );
|
||||
~GlowClient();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent( QResizeEvent * );
|
||||
virtual void paintEvent( QPaintEvent * );
|
||||
virtual void showEvent( QShowEvent * );
|
||||
virtual void mouseDoubleClickEvent( QMouseEvent * );
|
||||
virtual void captionChange( const QString& name );
|
||||
virtual void maximizeChange(bool m);
|
||||
virtual void activeChange(bool);
|
||||
virtual void iconChange();
|
||||
virtual void stickyChange(bool on);
|
||||
virtual MousePosition mousePosition(const QPoint &) const;
|
||||
|
||||
private:
|
||||
std::vector<GlowButton*> m_buttonList;
|
||||
std::vector<GlowButton*> m_leftButtonList;
|
||||
std::vector<GlowButton*> m_rightButtonList;
|
||||
GlowButton *m_stickyButton;
|
||||
GlowButton *m_helpButton;
|
||||
GlowButton *m_minimizeButton;
|
||||
GlowButton *m_maximizeButton;
|
||||
GlowButton *m_closeButton;
|
||||
QVBoxLayout *m_mainLayout;
|
||||
QSpacerItem *m_titleSpacer;
|
||||
|
||||
void createButtons();
|
||||
void updateButtonPositions();
|
||||
/**
|
||||
* Before this method is called we have to update the button
|
||||
* positions with updateButtonPositions() because the pixmaps
|
||||
* depend on the position
|
||||
*/
|
||||
void updateButtonPixmaps();
|
||||
void resetLayout();
|
||||
void doShape();
|
||||
bool isLeft(GlowButton *button);
|
||||
bool isRight(GlowButton *button);
|
||||
|
||||
protected slots:
|
||||
void slotReset();
|
||||
void slotMaximize(int button);
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
[General]
|
||||
stickyButtonGlowType=TitleBar
|
||||
stickyButtonGlowColor=255,255,255
|
||||
helpButtonGlowType=TitleBar
|
||||
helpButtonGlowColor=255,255,255
|
||||
iconifyButtonGlowType=TitleBar
|
||||
iconifyButtonGlowColor=255,255,255
|
||||
maximizeButtonGlowType=TitleBar
|
||||
maximizeButtonGlowColor=255,255,255
|
||||
closeButtonGlowType=Custom
|
||||
closeButtonGlowColor=255,0,0
|
Loading…
Reference in a new issue