From a600e78779e6499a53663be60524ca21144e6ca9 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 12 Feb 2021 12:11:09 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- deco/CMakeLists.txt | 4 +- deco/Makefile.am | 2 +- deco/baghiraclient.cc | 2643 ------------------------------------- deco/baghiraclient.cpp | 2643 +++++++++++++++++++++++++++++++++++++ deco/config/CMakeLists.txt | 8 +- deco/config/Makefile.am | 2 +- deco/config/aquariusbutton.cc | 166 --- deco/config/aquariusbutton.cpp | 166 +++ deco/config/baghiraconfig.cc | 729 ---------- deco/config/baghiraconfig.cc.new | 730 ---------- deco/config/baghiraconfig.cpp | 729 ++++++++++ deco/config/baghiraconfig.cpp.new | 730 ++++++++++ deco/config/colorpicker.cc | 126 -- deco/config/colorpicker.cpp | 126 ++ 14 files changed, 4402 insertions(+), 4402 deletions(-) delete mode 100644 deco/baghiraclient.cc create mode 100644 deco/baghiraclient.cpp delete mode 100644 deco/config/aquariusbutton.cc create mode 100644 deco/config/aquariusbutton.cpp delete mode 100644 deco/config/baghiraconfig.cc delete mode 100644 deco/config/baghiraconfig.cc.new create mode 100644 deco/config/baghiraconfig.cpp create mode 100644 deco/config/baghiraconfig.cpp.new delete mode 100644 deco/config/colorpicker.cc create mode 100644 deco/config/colorpicker.cpp (limited to 'deco') diff --git a/deco/CMakeLists.txt b/deco/CMakeLists.txt index b04b68e..e4d516a 100644 --- a/deco/CMakeLists.txt +++ b/deco/CMakeLists.txt @@ -57,14 +57,14 @@ add_custom_command( ##### twin3_baghira (kpart) set_source_files_properties( - baghiraclient.cc + baghiraclient.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_header} ) tde_add_kpart( twin3_baghira AUTOMOC SOURCES - baghiraclient.cc + baghiraclient.cpp LINK tdecore-shared tdeui-shared diff --git a/deco/Makefile.am b/deco/Makefile.am index 84944ad..9931018 100644 --- a/deco/Makefile.am +++ b/deco/Makefile.am @@ -14,7 +14,7 @@ EXTRA_DIST = $(twin_DATA) images noinst_HEADERS = baghiraclient.h pixmaps.h masks.h kde_module_LTLIBRARIES = twin3_baghira.la -twin3_baghira_la_SOURCES = baghiraclient.cc +twin3_baghira_la_SOURCES = baghiraclient.cpp twin3_baghira_la_LIBADD = $(kde_libraries)/libtdecorations.la twin3_baghira_la_LDFLAGS = $(all_libraries) $(LIB_TQT) $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx -module twin3_baghira_la_METASOURCES = AUTO diff --git a/deco/baghiraclient.cc b/deco/baghiraclient.cc deleted file mode 100644 index 471e440..0000000 --- a/deco/baghiraclient.cc +++ /dev/null @@ -1,2643 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// baghiraclient.h -// ------------------- -// Baghira window decoration for KDE -// ------------------- -// Copyright (c) 2004, 2005 Thomas Lübking -// Please see the header file for copyright and license information. -////////////////////////////////////////////////////////////////////////////// - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -// #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "baghiraclient.h" -#include "pixmaps.h" -#include "masks.h" - -#define COLOR_SPACE(R,G,B) \ - if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \ - if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \ - if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255; - -#define SATURATION_COLOR(R,G,B) \ - grey = (299 * R + 587 * G + 114 * B) / 1000; \ - delta = 255 - grey; \ - grey = (grey *(10 - 5)) / 10; \ - iGrey = 255 - grey;\ - destR = (iGrey * (srcR - delta) + grey * R) / 255; \ - destG = (iGrey * (srcG - delta) + grey * G) / 255; \ - destB = (iGrey * (srcB - delta) + grey * B) / 255; - -#define CLAMP(x,l,u) x < l ? l :\ - x > u ? u :\ - x - -#define SATURATION_COLOR2(S,R,G,B,cR,cG,cB) \ - int max = 255+0.65*(100-S); \ - destR = CLAMP((cR + R - 128), 0, max); \ - destG = CLAMP((cG + G - 128), 0, max); \ - destB = CLAMP((cB + B - 128), 0, max); \ - destR = (S*destR + (100-S)*R)/100; \ - destG = (S*destG + (100-S)*G)/100; \ - destB = (S*destB + (100-S)*B)/100; - -using namespace Baghira; - -static const int BUTTONSIZE = 15; -static const int MENUBUTTONWIDTH = 20; -static const int DECOSIZE = 8; -int TITLESIZE;// = 26; -static const int TITLESIZESMALL = 18; -static const int MARGIN = 6; - -////////////////////////////////////////////////////////////////////////////// -// BaghiraFactory Class // -////////////////////////////////////////////////////////////////////////////// - -bool BaghiraFactory::initialized_ = false; -Baghira::TitlebarType BaghiraFactory::effect_[5][2]; -TQt::AlignmentFlags BaghiraFactory::titlealign_; -TQColor BaghiraFactory::colors_[5][ ColorTypeCount ][ 2 ]; -KPixmap BaghiraFactory::pix_[5][ PixmapTypeCount ][ 2 ][ 2 ]; -int BaghiraFactory::bordersize_[5] = {0,0,6,0,0};//{BorderTiny, BorderTiny, BorderVeryHuge}; -TQPixmap BaghiraFactory::ButtonPixmap_[5][WindowStateAmount][ButtonTypeAmount][ButtonStateAmount][2]; -TQColor BaghiraFactory::brushedMetalColor; -TQColor BaghiraFactory::ButtonColor_[ButtonTypeAmount+1]; -TQPixmap BaghiraFactory::nostalgia_[5][3][2]; -int BaghiraFactory::contrast_; -int BaghiraFactory::_3DImpact_[5]; -int BaghiraFactory::LineImpact_[5]; -bool BaghiraFactory::bgStipple_; -bool BaghiraFactory::comicFrame_; -bool BaghiraFactory::addAutoSpacing_; -bool BaghiraFactory::maxResizable_; -bool BaghiraFactory::shape_ul[5]; -bool BaghiraFactory::shape_ur[5]; -bool BaghiraFactory::shape_ll[5]; -bool BaghiraFactory::shape_lr[5]; -bool BaghiraFactory::allowEasyClosing_; -bool BaghiraFactory::resizeGrip_; -uint BaghiraFactory::defaultMode_; -bool BaghiraFactory::drawIcon_[5]; -bool BaghiraFactory::tintBrush_; -bool BaghiraFactory::showTitle_; -TQColor BaghiraFactory::brushTint; -int BaghiraFactory::minimumTitleHeight_; -ButtonStyle BaghiraFactory::buttonStyle_[5]; - -TQBitmap BaghiraFactory::helpMask; -TQBitmap BaghiraFactory::jaguarDownMask; -TQBitmap BaghiraFactory::jaguarMenuDownMask; -TQBitmap BaghiraFactory::jaguarMenuMask; -TQBitmap BaghiraFactory::jaguarMask; -TQBitmap BaghiraFactory::milkMenuDownMask; -TQBitmap BaghiraFactory::milkMenuMask; -TQBitmap BaghiraFactory::milkMask; -TQBitmap BaghiraFactory::pantherMenuMask; -TQBitmap BaghiraFactory::pantherMask; -TQBitmap BaghiraFactory::milkDownMask; -TQBitmap BaghiraFactory::arrowUp; -TQBitmap BaghiraFactory::arrowDown; -DeMaximizer BaghiraFactory::deMaximizer_; -bool BaghiraFactory::fullSpec_; -bool BaghiraFactory::noModalDeco_; -bool BaghiraFactory::delAppname_; - -Atom baghira_deco_design = XInternAtom(tqt_xdisplay(), "BAGHIRA_DECO_DESIGN", False); - -extern "C" -{ - KDE_EXPORT KDecorationFactory* create_factory() - { - return new Baghira::BaghiraFactory(); - } -} - -DeMaximizer::DeMaximizer() : TQWidget(0, "deMaximizer", TQt::WType_TopLevel | TQt::WStyle_NoBorder | TQt::WX11BypassWM ) -{ - client_ = 0L; - setFixedSize(16,16); - setMouseTracking(TRUE); - setAutoMask(TRUE); - move(TQApplication::desktop()->availableGeometry().right()-17,TQApplication::desktop()->availableGeometry().top()+2); - setBackgroundMode( NoBackground ); -// setBackgroundMode (TQt::X11ParentRelative); -// setPaletteBackgroundColor(TQt::green); -} - -void DeMaximizer::mouseReleaseEvent( TQMouseEvent *) -{ - hasMouse()?setState(1):setState(0); - if (client_) client_->demaxButtonPressed(); -} - -void DeMaximizer::mousePressEvent ( TQMouseEvent *) -{ - setState(2); -} - -void DeMaximizer::enterEvent ( TQEvent *) -{ - setState(1); -} - -void DeMaximizer::leaveEvent ( TQEvent *) -{ - setState(0); -} - -void DeMaximizer::setState(int i) -{ - erase(); - TQPainter p(this); - p.drawPixmap(0,0,pixmap[i]); - p.end(); -} - -void DeMaximizer::setPixmap(int i, TQImage &image ) -{ - pixmap[i] = TQPixmap(image); -} - - -void DeMaximizer::setClient(BaghiraClient *client) -{ - if (client_) - { - TQObject::disconnect ( client_, SIGNAL(hide()), this, SLOT(hide()) ); - client_ = 0L; - } - if (client) - { - client_ = client; - connect ( client_, SIGNAL(hide()), SLOT(hide()) ); - setState(0); - } -// repaint(); -} - -#if KDE_IS_VERSION(3,3,91) -////////////////////////////////////////////////////////////////////////////// -// ResizeHandle() -// --------------- -// Constructor -ResizeHandle::ResizeHandle(BaghiraClient * parent) : TQWidget(parent->widget(), 0, 0) -{ - if (!parent->widget()) - return; - client = parent; - setCursor(TQCursor(TQt::SizeFDiagCursor)); - setFixedSize(16,16); - updateLook(FALSE); - WId root, daddy = 0; - WId *kids = 0L; - uint numKids = 0; - XQueryTree(tqt_xdisplay(), parent->windowId(), &root, &daddy, &kids, &numKids); - if (daddy) - XReparentWindow( tqt_xdisplay(), winId(), daddy, 0, 0 ); - else return; - move(client->width()-2*BaghiraFactory::borderSize(parent->currentStyle)-16,client->height()-client->titleheight_-16); - shape(); - parent->widget()->installEventFilter(this); - raise(); - show(); -} - -void ResizeHandle::updateLook(bool rp) -{ - pix = TQPixmap(16,16); - TQPainter p(&pix); - p.fillRect(pix.rect(), BaghiraFactory::effect(client->currentStyle, client->isActive()) == Baghira::Brushed ? BaghiraFactory::BrushedMetalColor().light(110):paletteBackgroundColor()); - p.setPen( BaghiraFactory::effect(client->currentStyle, client->isActive()) == Baghira::Brushed ? TQt::black:paletteForegroundColor() ); - p.drawLine(0,16,16,0); - p.drawLine(4,16,16,4); - p.drawLine(8,16,16,8); - p.drawLine(12,16,16,12); - p.end(); - setPaletteBackgroundPixmap(pix); - if (rp) repaint(); -} - -void ResizeHandle::shape() -{ - XRectangle* xrects = new XRectangle[16]; - for (int i = 0; i < 16; i++) - { - xrects[ i ].x = 15-i; - xrects[ i ].y = i; - xrects[ i ].width = i+1; - xrects[ i ].height = 1; - } - XShapeCombineRectangles( tqt_xdisplay(), winId(), ShapeBounding, 0, 0, - xrects, 16, ShapeSet, 0 ); - delete[] xrects; -} - -bool ResizeHandle::eventFilter(TQObject *obj, TQEvent *e) -{ - if ( obj != parent() ) - return false; - if ( e->type() == TQEvent::Resize) - { - if (client->maximizeMode() == BaghiraClient::MaximizeFull) - move(client->width() - 16, client->height() - client->titleheight_ - 16); - else - move(client->width() - 2*BaghiraFactory::borderSize(client->currentStyle) - 16, client->height() - client->titleheight_ - BaghiraFactory::borderSize(client->currentStyle) - 16); -// shape(); - return FALSE; - } - return FALSE; -} - -void ResizeHandle::mousePressEvent ( TQMouseEvent * ) -{ - client->performWindowOperation(/*Unrestricted*/KDecoration::ResizeOp); -} -void ResizeHandle::mouseReleaseEvent ( TQMouseEvent * ) -{ - client->performWindowOperation(KDecoration::NoOp); - repaint(TRUE); -} -void ResizeHandle::paintEvent ( TQPaintEvent * ) -{ - TQPainter p(this); - p.drawPixmap(0,0,pix); -} - -#endif - -////////////////////////////////////////////////////////////////////////////// -// BaghiraFactory() -// --------------- -// Constructor - -BaghiraFactory::BaghiraFactory() { - helpMask = TQBitmap( 14, 15, help_bits, true ); - jaguarDownMask = TQBitmap( 14, 15, jaguar2_bits, true ); - jaguarMenuDownMask = TQBitmap( 20, 15, jaguar_menu_down_bits, true ); - jaguarMenuMask = TQBitmap( 20, 15, jaguar_menu_bits, true ); - jaguarMask = TQBitmap( 14, 15, jaguar_bits, true ); - milkMenuDownMask = TQBitmap( 20, 15, milk_menu_down_bits, true ); - milkMenuMask = TQBitmap( 20, 15, milk_menu_bits, true ); - milkMask = TQBitmap( 14, 15, milk_bits, true ); - pantherMenuMask = TQBitmap( 20, 15, panther_menu_bits, true ); - pantherMask = TQBitmap( 14, 15, panther_bits, true ); - milkDownMask = TQBitmap( 14, 15, milk_pressed_bits, true ); - arrowUp = TQBitmap( 8, 4, arrowUp_bits, true ); - arrowUp.setMask( arrowUp ); - arrowDown = TQBitmap( 8, 4, arrowDown_bits, true ); - arrowDown.setMask( arrowDown ); - readConfig(); - createPixmaps(); - initialized_ = true; -} - -////////////////////////////////////////////////////////////////////////////// -// ~BaghiraFactory() -// ---------------- -// Destructor - -BaghiraFactory::~BaghiraFactory() -{ - deMaximizer_.setClient(NULL); - initialized_ = false; -} - -////////////////////////////////////////////////////////////////////////////// -// createDecoration() -// ------------------ -// Create the decoration - -KDecoration* BaghiraFactory::createDecoration( KDecorationBridge* b ) { - return new BaghiraClient( b, this ); -} - -////////////////////////////////////////////////////////////////////////////// -// reset() -// ------- -// Reset the handler. Returns true if decorations need to be remade - -TQString BaghiraFactory::indexedString(TQString s, int i){ - TQString result; - result.setNum(i+1); - result.prepend("_"); - result.prepend(s); -// tqWarning("%s",result.ascii()); - return result; -} - -bool BaghiraFactory::reset( unsigned long changed ) { - initialized_ = false; - changed |= readConfig(); - if ( changed & ( SettingColors | SettingDecoration | SettingBorder ) ) { - createPixmaps(); - } - initialized_ = true; - - if ( changed & ( SettingColors | SettingDecoration | SettingFont | - SettingButtons | SettingBorder ) ) { - return true; - } else { - resetDecorations( changed ); - return false; - } -} - -////////////////////////////////////////////////////////////////////////////// -// readConfig() -// ------------ -// Read in the configuration file - -unsigned long BaghiraFactory::readConfig() { - - TQSettings config; - config.beginGroup("/baghira/Style"); -// TDEConfig config( "baghirarc" ); -// config.setGroup( "Style" ); - bgStipple_ = config.readBoolEntry( "Design_StippleBackground", false); - contrast_ = config.readNumEntry( "Design_StippleContrast", 30 ); - tintBrush_ = config.readBoolEntry( "Colors_TintBrushedMetal", false ); - if (tintBrush_) - brushTint.setRgb( config.readNumEntry( "Colors_BrushTint")); - - TQColor oldcolor; - unsigned long changed = 0; - oldcolor = colors_[3][ Baghira::ColorTitleBar ][ false ]; - colors_[3][ Baghira::ColorTitleBar ][ false ] = tqApp->palette().active().background(); - if ( oldcolor != colors_[3][ Baghira::ColorTitleBar ][ false ] ) - changed |= SettingColors; - - oldcolor = colors_[3][ Baghira::ColorTitleBlend ][ false ]; - colors_[3][ Baghira::ColorTitleBlend ][ false ] = colors_[3][ Baghira::ColorTitleBar ][ false ].dark(100 + config.readNumEntry( "Design_StippleContrast", 3)); - if ( oldcolor != colors_[3][ Baghira::ColorTitleBlend ][ false ] ) - changed |= SettingColors; - - config.endGroup(); - config.beginGroup( "/baghira/Deco" ); - - - // common settings - - bool oldNoModalDeco = noModalDeco_; - noModalDeco_ = config.readBoolEntry( "NoModalDeco", false ); - if (oldNoModalDeco != noModalDeco_) - changed |= SettingDecoration; - - bool oldDelAppname = delAppname_; - delAppname_ = config.readBoolEntry( "RemoveAppname", true ); - if (oldDelAppname != delAppname_) - changed |= SettingDecoration; - - int oldMinTH = minimumTitleHeight_; - minimumTitleHeight_ = (ButtonStyle) config.readNumEntry( "minimumTitleHeight", 18 ); - if ( oldMinTH != minimumTitleHeight_ ) - { - TQFontMetrics fm(options()->font(true, false)); - TITLESIZE = TQMAX(minimumTitleHeight_, fm.height()); - changed |= SettingFont; - changed |= SettingDecoration; - } - - bool allowEasyClosing__ = allowEasyClosing_; - allowEasyClosing_ = config.readBoolEntry( "allowEasyClosing", false ); - if ( allowEasyClosing__ != allowEasyClosing_ ) - changed |= SettingDecoration; - - bool resizeGrip__ = resizeGrip_; - resizeGrip_ = config.readBoolEntry( "ResizeGrip", false ); - if ( resizeGrip__ != resizeGrip_ ) - changed |= SettingDecoration; - - bool defaultMode__ = defaultMode_; - defaultMode_ = config.readNumEntry( "defaultMode", 1 ); - if ( defaultMode__ != defaultMode_ ) - changed |= SettingDecoration; - - TQt::AlignmentFlags oldalign = titlealign_; - TQString value = config.readEntry( "TitleAlignment", "AlignHCenter" ); - showTitle_ = TRUE; - if ( value == "AlignLeft" ) - titlealign_ = TQt::AlignLeft; - else if ( value == "AlignHCenter" ) - titlealign_ = TQt::AlignHCenter; - else if ( value == "AlignRight" ) - titlealign_ = TQt::AlignRight; - else if ( value == "noTitle" ) - { - showTitle_ = FALSE; - titlealign_ = TQt::AlignAuto; - } - if ( oldalign != titlealign_ ) - changed |= SettingFont; - - bool oldComic = comicFrame_; - comicFrame_ = config.readBoolEntry( "DrawComicFrame", false ); - if ( oldComic != comicFrame_ ) - changed |= SettingBorder; changed |= SettingDecoration; - - bool oldAutoSpacing = addAutoSpacing_; - addAutoSpacing_ = config.readBoolEntry( "AddAutoSpacing", true ); - if ( oldAutoSpacing != addAutoSpacing_ ) - changed |= SettingDecoration; - - bool oldMaxResizable = maxResizable_; - maxResizable_ = config.readBoolEntry( "MaxResizable", true ); - if ( oldMaxResizable != maxResizable_ ) - changed |= SettingDecoration; - - bool oldSpec = fullSpec_; - fullSpec_ = config.readBoolEntry( "FullSpec", false ); - if ( oldSpec != fullSpec_ ) - changed |= SettingDecoration; - - // custom settings - - for (int i = 0; i < 5; i++){ - - int oldbordersize = bordersize_[i]; - bordersize_[i] = config.readNumEntry( indexedString("BorderSize",i), i == 2 ? 6 : 0 ); - if ( oldbordersize != bordersize_[i] ) - changed |= SettingBorder; - - ButtonStyle oldButtons = buttonStyle_[i]; - buttonStyle_[i] = (ButtonStyle) config.readNumEntry( indexedString("ButtonStyle",i), i == 0 ? 1 : 0 ); - if ( oldButtons != buttonStyle_[i] ) - changed |= SettingDecoration; - - - bool oldShUL = shape_ul[i]; - shape_ul[i] = config.readBoolEntry( indexedString("ShapeUL",i), true ); - if ( oldShUL != shape_ul[i] ){ - changed |= SettingBorder; changed |= SettingDecoration; - } - - bool oldShUR = shape_ur[i]; - shape_ur[i] = config.readBoolEntry( indexedString("ShapeUR",i), true ); - if ( oldShUR != shape_ur[i] ){ - changed |= SettingBorder; changed |= SettingDecoration; - } - - bool oldShLL = shape_ll[i]; - shape_ll[i] = config.readBoolEntry( indexedString("ShapeLL",i), i == 2 ); - if ( oldShLL != shape_ll[i] ){ - changed |= SettingBorder; changed |= SettingDecoration; - } - - bool oldShLR = shape_lr[i]; - shape_lr[i] = config.readBoolEntry( indexedString("ShapeLR",i), i == 2 ); - if ( oldShLR != shape_lr[i] ){ - changed |= SettingBorder; changed |= SettingDecoration; - } - - - bool oldDrawIcon_ = drawIcon_[i]; - drawIcon_[i] = config.readBoolEntry( indexedString("drawIcon",i), true ); - if ( oldDrawIcon_ = drawIcon_[i] ) - changed |= SettingFont; - changed |= SettingDecoration; - - if (i != 3) - { - Baghira::TitlebarType oldeffect = effect_[i][1]; - effect_[i][1] = ( Baghira::TitlebarType ) config.readNumEntry( indexedString("TitleEffect",i), i == 0 ? Baghira::Stipples : (i == 1 || i == 4) ? Baghira::Gradient : Baghira::Brushed); - // tqWarning("%d",effect_[i]); - if ( oldeffect != effect_[i][1] ) - changed |= SettingDecoration; - - oldeffect = effect_[i][0]; - effect_[i][0] = ( Baghira::TitlebarType ) config.readNumEntry( indexedString("inactiveTitleEffect",i), i == 0 ? Baghira::Stipples : (i == 1 || i == 4) ? Baghira::Gradient : Baghira::Brushed); - // tqWarning("%d",effect_[i]); - if ( oldeffect != effect_[i][0] ) - changed |= SettingDecoration; - - int oldLineImpact = LineImpact_[i]; - LineImpact_[i] = config.readNumEntry( indexedString("LineImpact",i), i == 2 ? 0 : 40 ); - if ( oldLineImpact != LineImpact_[i] ) - changed |= SettingDecoration; - - oldcolor = colors_[i][ Baghira::ColorTitleBar ][ false ]; - colors_[i][ Baghira::ColorTitleBar ][ false ].setRgb((unsigned int)config.readNumEntry( indexedString("inactiveColor1",i), i == 0 ? TQColor(204,214,230).rgb() : i == 1 ? TQColor(246,242,246).rgb() : i == 3 ? TQColor(200,200,200).rgb() : TQColor(230,230,230).rgb())); - if ( oldcolor != colors_[i][ Baghira::ColorTitleBar ][ false ] ) - changed |= SettingColors; - - oldcolor = colors_[i][ Baghira::ColorTitleBlend ][ false ]; - colors_[i][ Baghira::ColorTitleBlend ][ false ].setRgb((unsigned int)config.readNumEntry( indexedString("inactiveColor2",i), i == 0 ? TQColor(194,196,211).rgb() : i == 1 ? TQColor(238,238,238).rgb() : i == 3 ? TQColor(150,150,150).rgb() : TQColor(250,250,250).rgb())); - if ( oldcolor != colors_[i][ Baghira::ColorTitleBlend ][ false ] ) - changed |= SettingColors; - } - else - { - effect_[3][1] = Baghira::Gradient; - effect_[3][0] = Baghira::FlatStipples; - LineImpact_[3] = 0; - } - - int old3DImpact = _3DImpact_[i]; - _3DImpact_[i] = config.readNumEntry( indexedString("3DImpact",i), 20 ); - if ( old3DImpact != _3DImpact_[i] ) - changed |= SettingDecoration; - - oldcolor = colors_[i][ Baghira::ColorTitleBar ][ true ]; - colors_[i][ Baghira::ColorTitleBar ][ true ].setRgb((unsigned int)config.readNumEntry( indexedString("activeColor1",i), i == 0 ? TQColor(255,255,255).rgb() : i == 1 ? TQColor(238,238,238).rgb() : i == 2 ? TQColor(202,202,202).rgb() : i == 3 ? TQColor(238,238,238).rgb() : TQColor(250,250,250).rgb())); - if ( oldcolor != colors_[i][ Baghira::ColorTitleBar ][ true ] ) - changed |= SettingColors; - - oldcolor = colors_[i][ Baghira::ColorTitleBlend ][ true ]; - colors_[i][ Baghira::ColorTitleBlend ][ true ].setRgb((unsigned int)config.readNumEntry( indexedString("activeColor2",i), i == 0 ? TQColor(238,234,238).rgb() : i == 1 ? TQColor(205,202,205).rgb() : i == 2 ? TQColor(150,150,150).rgb() : i == 3 ? TQColor(211,208,211).rgb() : TQColor(230,230,230).rgb())); - if ( oldcolor != colors_[i][ Baghira::ColorTitleBlend ][ true ] ) - changed |= SettingColors; - - } - - oldcolor = ButtonColor_[MinButton]; - ButtonColor_[MinButton].setRgb((unsigned int)config.readNumEntry( "MinButtonColor", TQColor(230,155,40).rgb() )); - if ( oldcolor != ButtonColor_[MinButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[MaxButton]; - ButtonColor_[MaxButton].setRgb((unsigned int)config.readNumEntry( "MaxButtonColor", TQColor(121,180,54).rgb() )); - if ( oldcolor != ButtonColor_[MaxButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[CloseButton]; - ButtonColor_[CloseButton].setRgb((unsigned int)config.readNumEntry( "CloseButtonColor", TQColor(200,85,70).rgb() )); - if ( oldcolor != ButtonColor_[CloseButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[StickyButton]; - ButtonColor_[StickyButton].setRgb((unsigned int)config.readNumEntry( "StickyButtonColor", TQColor(74,140,242).rgb() )); - if ( oldcolor != ButtonColor_[StickyButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[AboveBelowButton]; - ButtonColor_[AboveBelowButton].setRgb((unsigned int)config.readNumEntry( "AboveButtonColor", TQColor(74,140,242).rgb() )); - if ( oldcolor != ButtonColor_[AboveBelowButton] ) - changed |= SettingColors; - oldcolor = ButtonColor_[ShadeButton]; - ButtonColor_[ShadeButton].setRgb((unsigned int)config.readNumEntry( "ShadeButtonColor", TQColor(74,140,242).rgb() )); - if ( oldcolor != ButtonColor_[ShadeButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[MenuButton]; - ButtonColor_[MenuButton].setRgb((unsigned int)config.readNumEntry( "MenuButtonColor", TQColor(74,140,242).rgb() )); - if ( oldcolor != ButtonColor_[MenuButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[HelpButton]; - ButtonColor_[HelpButton].setRgb((unsigned int)config.readNumEntry( "HelpButtonColor", TQColor(0,0,0).rgb() )); - if ( oldcolor != ButtonColor_[HelpButton] ) - changed |= SettingColors; - - oldcolor = ButtonColor_[InactiveButton]; - ButtonColor_[InactiveButton].setRgb((unsigned int)config.readNumEntry( "InactiveButtonColor", TQColor(255,255,255).rgb() )); - if ( oldcolor != ButtonColor_[InactiveButton] ) - changed |= SettingColors; - - - config.endGroup(); - return changed; -} - -TQImage* BaghiraFactory::tintGlossy( const TQImage &src, const TQColor &c ) const -{ - TQImage *dest = new TQImage( src.width(), src.height(), 32); - dest->setAlphaBuffer( true ); - unsigned int *data = ( unsigned int * ) src.bits(); - unsigned int *destData = ( unsigned int* ) dest->bits(); - int total = src.width() * src.height(); - int u3rd = src.width()*4; - int red, green, blue; - int destR, destG, destB, alpha; - int srcR = c.red(); - int srcG = c.green(); - int srcB = c.blue(); - int hue, s, v; - c.getHsv( &hue, &s, &v ); - int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); - // float srcPercent, destPercent; - for ( int current = 0 ; current < total ; ++current ) { - alpha = tqAlpha( data[ current ] ); - if (alpha < 230){ - destData[ current ] = data[ current ]; - continue; //do not handle translucent parts to not affect blending - } - red = tqRed( data[ current ] ); - green = tqGreen( data[ current ] ); - blue = tqBlue( data[ current ] ); - if ( current > u3rd || red < 223 ){ - SATURATION_COLOR2(sq, red, green, blue, srcR, srcG, srcB) - } else { - SATURATION_COLOR2(sq, red, green, blue, 255, 255, 255); - } - // force back to valid colorspace ! - COLOR_SPACE(destR, destG, destB); - destData[ current ] = tqRgba( destR, destG, destB, alpha ); - } - return ( dest ); -} - -TQImage* BaghiraFactory::tintBrush( const TQImage &img, const TQColor &c ) const -{ - -// if ( img.depth() != 32 ) -// img = img.convertDepth( 32 ); - TQImage *dest = new TQImage( img.width(), img.height(), 32); - unsigned int *data = ( unsigned int * ) img.bits(); - unsigned int *destData = ( unsigned int* ) dest->bits(); - int total = img.width() * img.height(); - int current; - int delta; - int red, green, blue, grey, iGrey; - int destR, destG, destB, alpha; - - int srcR = c.red(); - int srcG = c.green(); - int srcB = c.blue(); - - SATURATION_COLOR(180, 180, 180); - COLOR_SPACE(destR, destG, destB); - brushedMetalColor = TQColor(destR, destG, destB); - - // float srcPercent, destPercent; - for ( current = 0 ; current < total ; ++current ) { - alpha = tqAlpha( data[ current ] ); - blue = tqBlue( data[ current ] ); - red = tqRed( data[ current ] ); - green = tqGreen( data[ current ] ); - SATURATION_COLOR(red, green, blue); - // force back to valid colorspace ! - COLOR_SPACE(destR, destG, destB); - destData[ current ] = tqRgba( destR, destG, destB, alpha ); - } - return ( dest ); -} - -void BaghiraFactory::createOS8Buttons(int style){ - TQPainter p; - TQColor initColor; - for ( int active = 0; active <= 1; ++active ){ - for (int t = 0; t < 3; t++){ - initColor = TQColor(color(style, Baghira::ColorTitleBar, active ).dark(100 + t*15)); - nostalgia_[style][t][active] = TQPixmap(BUTTONSIZE, BUTTONSIZE); - p.begin(&nostalgia_[style][t][active]); - p.setPen(color(style, Baghira::ColorTitleBar, active )); - p.drawPoint(0,BUTTONSIZE-1); - p.drawPoint(BUTTONSIZE-1,0); - p.setPen(initColor); - // dark color - // outer relief =============================== - p.drawLine(0,0,0,BUTTONSIZE-2); - p.drawLine(0,0,BUTTONSIZE-2,0); - // ============================================= - // inner relief ================================ - if (t < 2){ - p.drawLine(3,BUTTONSIZE-3,BUTTONSIZE-3,BUTTONSIZE-3); - p.drawLine(BUTTONSIZE-3,3,BUTTONSIZE-3,BUTTONSIZE-3); - } - else{ - p.drawLine(2,2,2,BUTTONSIZE-4); - p.drawLine(2,2,BUTTONSIZE-4,2); - } - // ======================================== - for (int i = 0; i < BUTTONSIZE - 6; i++){ - if (i == BUTTONSIZE - 7){ - p.drawPoint(2, BUTTONSIZE - 3); - p.drawPoint(BUTTONSIZE - 3, 2); - } - for (int j = 0; j < i+1; j++){ - p.setPen(initColor.light(100 + (i + j)*3)); - p.drawPoint(i+3,j+3); - if (i != j) p.drawPoint(j+3,i+3); - } - } - // Color is now Bright ;-) - // inner relief =============================== - if (t < 2){ - p.drawLine(2,2,2,BUTTONSIZE-4); - p.drawLine(2,2,BUTTONSIZE-4,2); - } - else{ - p.drawLine(3,BUTTONSIZE-3,BUTTONSIZE-3,BUTTONSIZE-3); - p.drawLine(BUTTONSIZE-3,3,BUTTONSIZE-3,BUTTONSIZE-3); - } - // ================================ - // outer relief ====================================== - p.drawLine(1,BUTTONSIZE-1,BUTTONSIZE-1,BUTTONSIZE-1); - p.drawLine(BUTTONSIZE-1,1,BUTTONSIZE-1,BUTTONSIZE-1); - //================================== - // black frame - p.setPen(TQt::black); - p.drawRect(1,1,BUTTONSIZE-2,BUTTONSIZE-2); - p.end(); - } - } -} - -TQPixmap &BaghiraFactory::ButtonPixmap( Baghira::WindowState wState, - Baghira::ButtonType type, Baghira::ButtonState state, int style, bool small ) { - return ButtonPixmap_[style][ wState ][ type ][ state ][small]; -} - -TQImage* BaghiraFactory::DecoImage( TQPixmap *pix, int x, int y, int width, int height ) { - TQPixmap tmpPix( width, height ); - bitBlt ( &tmpPix, 0, 0, pix, x, y, width, height ); - TQImage *returnImage = new TQImage( tmpPix.convertToImage() ); - return returnImage; -} - -/////////////////////////////////////////////////////////////////////////// -// createGradient() -// ---------------- -// Create a gradient - -void BaghiraFactory::createGradient(KPixmap &pix, const TQColor &light, const TQColor &dark, Baghira::TitlebarType effect) -{ - if (pix.width() == 0) return; - - TQPainter p; - switch( effect ){ - case Baghira::Stipples: - KPixmapEffect::unbalancedGradient(pix, light, light.dark(110), KPixmapEffect::VerticalGradient, 0); - p.begin(&pix); - p.setPen(dark); - for( int i = 0; i < pix.height(); i+=4 ){ - p.drawLine(0,i,pix.width(),i); - p.drawLine(0,i+1,pix.width(),i+1); - } - p.end(); - break; - case Baghira::FlatStipples: - { - p.begin(&pix); - p.fillRect(pix.rect(),light); - TQColor mid; - mid.setRgb((light.red()+2*dark.red())/3,(light.green()+2*dark.green())/3,(light.blue()+2*dark.blue())/3); - p.setPen(mid); - for( int i = pix.height() - 1; i > 0; i-=4 ) - { - p.drawLine(0,i,pix.width(),i); - p.drawLine(0,i-2,pix.width(),i-2); - } - p.setPen(dark); - for( int i = pix.height() - 2; i > 0; i-=4 ) - { - p.drawLine(0,i,pix.width(),i); - } - p.end(); - break; - } - case Baghira::Nostalgia: - p.begin(&pix); - p.fillRect(pix.rect(),light); - p.setPen(light.light(120)); - for (int i = (pix.height() - 1) / 4; i < (pix.height() - 1) / 4 * 3 + 1; i +=2) - p.drawLine(0,i,pix.width()-1,i); - p.setPen(light.dark(120)); - for (int i = (pix.height() - 1) / 4; i < (pix.height() - 1) / 4 * 3 + 1; i +=2) - p.drawLine(0,i+1,pix.width()-1,i+1); - p.end(); - break; - case Baghira::Gradient: - default: - KPixmapEffect::gradient(pix, light, dark, KPixmapEffect::VerticalGradient, 0); - break; - } -} - -static bool blend( const TQImage & upper, const TQImage & lower, TQImage & output) -// adopted from kimageeffect::blend - what is not endian safe... -{ - if - ( - upper.width() > lower.width() || - upper.height() > lower.height() || - upper.depth() != 32 || - lower.depth() != 32 - ) - return false; - - output = lower.copy(); - - uchar *i, *o; - int a; - int col; - int w = upper.width(); - int row(upper.height() - 1); - - do - { - i = upper.scanLine(row); - o = output.scanLine(row); - - col = w << 2; - - --col; - - do - { -#ifdef WORDS_BIGENDIAN - while (!(a = i[col-3]) && (col != 3)) -#else - while (!(a = i[col]) && (col != 3)) -#endif - { - --col; --col; --col; --col; - } -#ifndef WORDS_BIGENDIAN - --col; -#endif - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - -#ifdef WORDS_BIGENDIAN - --col; -#endif - - } while (col--); - } while (row--); - return true; -} - -////////////////////////////////////////////////////////////////////////////// -// createPixmaps() -// --------------- -// Create all our pixmaps -void BaghiraFactory::createPixmaps() { -// TQPainter painter; - TQColorGroup group; - TQPainter icyAPainter; - TQImage tmpResult; - TQImage tmpResult2; - TQImage tmpDeco; - TQImage buttonImage; - TQImage btnIcons[MenuButton]; - btnIcons[AboveBelowButton] = TQImage(); - // load icon images - useless for nostalgia style, but i assume they'll be used at least once ;) - btnIcons[MinButton] = uic_findImage( "icon_minimize" ); - btnIcons[MaxButton] = uic_findImage( "icon_maximize" ); - btnIcons[CloseButton] = uic_findImage( "icon_close" ); - btnIcons[StickyButton] = uic_findImage( "icon_sticky" ); -// btnIcons[AboveBelowButton] = uic_findImage( "icon_above" ); - btnIcons[ShadeButton] = uic_findImage( "icon_shade" ); - - int B_3 = 0; - int B_6 = 0; -// int bt, bs; - int xoff = 0; - int yoff = 1; - bool brushedMode; - - for (int style = 0; style < 5; style++){ - for ( int active = 0; active <= 1; ++active ) { - for ( int small = 0; small <= 1; ++small ) { - KPixmap &tbar = pix_[style][ TitleBar ][ active ][ small ]; - KPixmap &tcenter = pix_[style][ TitleCenter ][ active ][ small ]; - brushedMode = effect_[style][active] == Baghira::Brushed; - - // create gradients and fills - // if (effect_ == Baghira::Gradient || effect_ == Baghira::Stipples /*|| effect_ == Baghira::Glossy * / - if (effect_[style][active] < Baghira::Glossy || effect_[style][active] == Baghira::FlatStipples){ - // resize pixmap - tbar.resize( 100, small ? TITLESIZESMALL : TITLESIZE ); - createGradient( tbar, color(style, Baghira::ColorTitleBar, active ), color(style, Baghira::ColorTitleBlend, active ), effect_[style][active] ); - } - else if (brushedMode){ - TQPixmap brushTile; - TQPixmap brushGradient; - if (tintBrush_){ - brushTile = TQPixmap(*tintBrush(uic_findImage( "brushed-tile" ), brushTint)); - brushGradient = TQPixmap(*tintBrush(uic_findImage( "brushed-gradient" ), brushTint)); - } - else{ - brushTile = uic_findImage( "brushed-tile" ); - brushGradient = uic_findImage( "brushed-gradient" ); - brushedMetalColor = TQColor(180,180,180); - } - // resize pixmap - tbar.resize( 256, small ? TITLESIZESMALL : TITLESIZE ); - tcenter.resize( 1024, small ? TITLESIZESMALL : TITLESIZE ); - TQPainter painter(&tbar); - painter.drawTiledPixmap( 0,0, tbar.width(), tbar.height(), brushTile ); - painter.end(); - painter.begin(&tcenter); - painter.drawTiledPixmap( 0,0, tcenter.width(), tcenter.height(), brushGradient ); - } - else{ - tbar.resize( 32, small ? TITLESIZESMALL : TITLESIZE); - KPixmap tmp = TQPixmap(*tintGlossy(uic_findImage( "deco_glossy" ), color(style, Baghira::ColorTitleBar, active ))); - if (tbar.height() > 18){ - for (int i = 8; i < tbar.height() - 10; i++){ - bitBlt(&tbar, 0, i, &tmp, 0, 8, 32, 1); - } - } - bitBlt(&tbar, 0, tbar.height() - 11, &tmp, 0, 9, 32, 10); - bitBlt(&tbar, 0, 0, &tmp, 0, 0, 32, 8); - } - - switch ( buttonStyle_[style] ) { - - // Load Jaguar Buttons ========================================================================= - - case Jaguar: - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); - - // unpressed buttons - buttonImage = uic_findImage( "button_jaguar"); - - for (int bt = MinButton; bt < MenuButton; bt++){ - for (int bs = ButtonInactive; bs < Pressed; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? - ButtonColor_[InactiveButton] : - ButtonColor_[bt] ); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - if (bs > ButtonActive) blend( btnIcons[bt], tmpResult, tmpResult ); - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); - } - } - - // pressed buttons // as jaguar buttons shift - buttonImage = uic_findImage( "button_jaguar_down"); - - for (int bt = MinButton; bt < MenuButton; bt++){ - tmpResult2 = *tintGlossy( buttonImage, ButtonColor_[bt].dark(120)); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - KImageEffect::blendOnLower( xoff, yoff, btnIcons[bt], tmpResult); // must shift as well - ButtonPixmap_[style][ active ][ bt ][ Pressed ][small] = TQPixmap( tmpResult ); - } - - - // HelpButton - buttonImage = uic_findImage( "icon_help"); - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? - ButtonColor_[InactiveButton] : - bs == Hovered ? - ButtonColor_[HelpButton].light(120) : - bs == Pressed ? - ButtonColor_[HelpButton].dark(120) : - ButtonColor_[HelpButton] ); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); - } - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); - - // MenuButton - buttonImage = uic_findImage( "button_jaguar_menu"); - for (int bs = ButtonInactive; bs < Pressed; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs < Hovered ? - ButtonColor_[InactiveButton] : - ButtonColor_[MenuButton] ); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); - } - - - - // pressed MenuButton // as jaguar buttons shift - buttonImage = uic_findImage( "button_jaguar_menu_down"); - tmpResult2 = *tintGlossy( buttonImage, ButtonColor_[MenuButton].dark(120)); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ MenuButton ][ Pressed ][small] = TQPixmap( tmpResult ); - - - break; - - // Load Milk Buttons ========================================================================= - - case Milk: - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); - - // unpressed buttons - buttonImage = uic_findImage( "button_milk"); - - - for (int bt = MinButton; bt < MenuButton; bt++){ - for (int bs = ButtonInactive; bs < Pressed; bs++){ - /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); - if (bs > ButtonActive) blend( btnIcons[bt], tmpResult, tmpResult ); - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); - } - } - - // pressed buttons // as pressed milk buttons differ - buttonImage = uic_findImage( "button_milk_down"); - for (int bt = MinButton; bt < MenuButton; bt++){ - /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); - blend( btnIcons[bt], tmpResult, tmpResult ); - ButtonPixmap_[style][ active ][ bt ][ Pressed ][small] = TQPixmap( tmpResult ); - } - - // HelpButton - buttonImage = uic_findImage( "icon_help"); - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); - } - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); - - // MenuButton - buttonImage = uic_findImage( "button_milk_menu"); - for (int bs = ButtonInactive; bs < Pressed; bs++){ - /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); - } - - // pressed MenuButton // as pressed milk buttons differ - buttonImage = uic_findImage( "button_milk_menu_down"); - /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ MenuButton ][ Pressed ][small] = TQPixmap( tmpResult ); - - break; - - // Create Nostalgia Buttons ========================================================================= - - case NostalgiaButton: - createOS8Buttons(style); - B_3 = (int)((BUTTONSIZE -1 )/ 3); - B_6 = B_3*2; - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); - - for (int bt = MinButton; bt < ButtonTypeAmount; bt++){ - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - if (bs < Hovered) - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][1][active] ); - else if (bs == Hovered) - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][0][active] ); - else - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][2][active] ); - if (bs > ButtonInactive){ - icyAPainter.begin(&ButtonPixmap_[style][ active ][ bt ][ bs ][small]); - icyAPainter.setPen(TQt::black); - if (bt == MinButton){ - icyAPainter.drawLine(2,B_3,BUTTONSIZE - 3,B_3); - icyAPainter.drawLine(2,B_6,BUTTONSIZE - 3,B_6); - icyAPainter.end(); - continue; - } - if (bt == MaxButton){ - icyAPainter.drawLine(2,B_6,B_6,B_6); - icyAPainter.drawLine(B_6,2,B_6,B_6); - icyAPainter.end(); - continue; - } - if (bt == StickyButton){ - icyAPainter.fillRect(BUTTONSIZE/2-1,BUTTONSIZE/2-1,2,2,TQt::black); - icyAPainter.end(); - continue; - } - if (bt == ShadeButton){ - icyAPainter.drawLine(2,B_3,BUTTONSIZE-3,B_3); - icyAPainter.drawLine(2,B_3+3,BUTTONSIZE-3,B_3+3); - icyAPainter.drawLine(2,B_3+6,BUTTONSIZE-3,B_3+6); - icyAPainter.end(); - continue; - } - if (bt == HelpButton){ - TQFont tmpFont = TQFont(options() ->font( true, false )); - tmpFont.setPixelSize(BUTTONSIZE - 4); - icyAPainter.setFont(tmpFont); - icyAPainter.drawText( 0, 0, BUTTONSIZE, BUTTONSIZE, TQt::AlignHCenter | TQt::AlignVCenter, "?" ); - icyAPainter.end(); - continue; - } - if (bt == MenuButton){ - icyAPainter.drawLine(2,B_3,BUTTONSIZE-3,B_3); - icyAPainter.end(); - - } - icyAPainter.end(); - } - if (bt == MenuButton){ - buttonImage = ButtonPixmap_[style][ active ][ bt ][ bs ][small].convertToImage(); - blend( buttonImage , tmpDeco, tmpDeco ); - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap(tmpDeco); - } - } - } - break; - - // Load Panther Buttons ========================================================================= - - case Panther: - default: - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); - - // unpressed buttons - buttonImage = uic_findImage( "button_panther"); - - for (int bt = MinButton; bt < MenuButton; bt++){ - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? - ButtonColor_[InactiveButton] : - bs == Pressed ? - ButtonColor_[bt].dark(120) : - ButtonColor_[bt] ); - if (bs > ButtonActive) blend( btnIcons[bt], tmpResult2, tmpResult2 ); - if (bt == MaxButton && bs > ButtonInactive) deMaximizer_.setPixmap(bs - 1, tmpResult2); - blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); - } - } - - - // HelpButton - buttonImage = uic_findImage( "icon_help"); - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? - ButtonColor_[InactiveButton] : - bs == Hovered ? - ButtonColor_[HelpButton].light(120) : - bs == Pressed ? - ButtonColor_[HelpButton].dark(120) : - ButtonColor_[HelpButton] ); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); - } - - tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); - - // MenuButton - buttonImage = uic_findImage( "button_panther_menu"); - for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ - tmpResult2 = *tintGlossy( buttonImage, bs < Hovered ? - ButtonColor_[InactiveButton] : - bs == Pressed ? - ButtonColor_[MenuButton].dark(120) : - ButtonColor_[MenuButton] ); - /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); - ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); - } - } - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// borderSizes() -// ------------- -// Return list of valid border sizes - -TQValueList BaghiraFactory::borderSizes() const { - return TQValueList() << BorderTiny << BorderNormal - << BorderLarge << BorderVeryLarge - << BorderHuge << BorderVeryHuge; -} - -////////////////////////////////////////////////////////////////////////////// -// BaghiraButton Class // -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -// BaghiraButton() -// -------------- -// Constructor - -BaghiraButton::BaghiraButton( BaghiraClient *parent, const char *name, const TQString& tip, bool small, ButtonType type, int style ) -: TQButton( parent->widget(), name ), client_( parent ), type_( type ), deco_( 0 ), icon_(), small_( small ), lastmouse_( 0 ), mouseover_( false ), _blocked(false) { - setBackgroundMode( NoBackground ); - setCursor( arrowCursor ); - TQToolTip::add( this, tip ); - down_ = false; - mouseover_ = false; - mask = NULL; - maskDown = NULL; - - setFixedSize( type == Baghira::MenuButton ? MENUBUTTONWIDTH : BUTTONSIZE, BUTTONSIZE ); - for ( int bs = Baghira::ButtonInactive; bs <= Baghira::Pressed; bs++ ) { - pixmap[ Baghira::WindowInactive ][ ( Baghira::ButtonState ) bs ] = - &BaghiraFactory::ButtonPixmap( Baghira::WindowInactive, type, - ( Baghira::ButtonState ) bs, style, small ); - pixmap[ Baghira::WindowActive ][ ( Baghira::ButtonState ) bs ] = - &BaghiraFactory::ButtonPixmap( Baghira::WindowActive, type, - ( Baghira::ButtonState ) bs, style, small ); - } -} - -BaghiraButton::~BaghiraButton() -{ - if ( deco_ ) - delete deco_; -} - - -////////////////////////////////////////////////////////////////////////////// -// sizeHint() -// ---------- -// Return size hint - -TQSize BaghiraButton::sizeHint() const { - return TQSize( BUTTONSIZE, BUTTONSIZE ); -} - -////////////////////////////////////////////////////////////////////////////// -// enterEvent() -// ------------ -// Mouse has entered the button - -void BaghiraButton::enterEvent( TQEvent *e ) { -#if 0 - if (type_ == CloseButton) - { - _blocked = true; - TQTimer::singleShot(250,this,SLOT(delayedEnterEvent())); - TQButton::enterEvent( e ); - return; - } -#endif - mouseover_ = true; - repaint( false ); - TQButton::enterEvent( e ); -} - -void BaghiraButton::delayedEnterEvent() -{ - if (hasMouse()) - { - _blocked = false; - mouseover_ = true; - repaint( false ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// leaveEvent() -// ------------ -// Mouse has left the button - -void BaghiraButton::leaveEvent( TQEvent *e ) -{ - mouseover_ = false; - if ( type_ == Baghira::MenuButton ) - down_ = false; - repaint( false ); - TQButton::leaveEvent( e ); -} - -////////////////////////////////////////////////////////////////////////////// -// mousePressEvent() -// ----------------- -// Button has been pressed - -void BaghiraButton::mousePressEvent( TQMouseEvent* e ) -{ - if (_blocked && !(e->state() & TQt::ControlButton)) - return; - lastmouse_ = e->button(); - - //update mask - if (maskDown) - { - clearMask(); - setMask(*maskDown); - } - // translate and pass on mouse event - int button = LeftButton; - if ( ( type_ != MaxButton ) && ( e->button() != LeftButton ) ) - { - button = NoButton; // middle & right buttons inappropriate - } - down_ = true; - TQMouseEvent me( e->type(), e->pos(), e->globalPos(), button, e->state() ); - repaint( false ); - TQButton::mousePressEvent( &me ); -} - -// void BaghiraButton::setOn(bool on) -// { -// TQButton::setOn(on); -// } - -////////////////////////////////////////////////////////////////////////////// -// mouseReleaseEvent() -// ----------------- -// Button has been released - -void BaghiraButton::mouseReleaseEvent( TQMouseEvent* e ) { - lastmouse_ = e->button(); - - if (mask){ - clearMask(); - setMask(*mask); - } - // translate and pass on mouse event - int button = LeftButton; - if ( ( type_ != MaxButton ) && ( e->button() != LeftButton ) ) { - button = NoButton; // middle & right buttons inappropriate - } - down_ = false; - TQMouseEvent me( e->type(), e->pos(), e->globalPos(), button, e->state() ); - repaint( false ); - TQButton::mouseReleaseEvent( &me ); -} - -inline ButtonState BaghiraButton::state() { - if ( down_ || isDown() ) - return Pressed; - else if ( mouseover_ ) - return Hovered; - else if ( client_->isActive() ) - return ButtonActive; - else - return ButtonInactive; -} - -////////////////////////////////////////////////////////////////////////////// -// drawButton() -// ------------ -// Draw the button - -void BaghiraButton::drawButton( TQPainter *painter ) { - if ( !BaghiraFactory::initialized() ) - return ; - - bool active = client_->isActive(); - - if ( type_ == Baghira::StickyButton && client_->isOnAllDesktops() ) - painter->drawPixmap( 0, 0, BaghiraFactory::ButtonPixmap( ( Baghira::WindowState ) active, type_, state() == Pressed ? Pressed : Hovered, client_->currentStyle, client_->isTool() )); - else - painter->drawPixmap( 0, 0, BaghiraFactory::ButtonPixmap( ( Baghira::WindowState ) active, type_, state() , client_->currentStyle, client_->isTool() )); - - if (type_ == Baghira::AboveBelowButton) - { - if (client_->keepAbove()) - { - painter->drawPixmap((width()-8)/2,height()/2-4,BaghiraFactory::arrowUp); - } - else if (client_->keepBelow()) - { - painter->drawPixmap((width()-8)/2,height()/2,BaghiraFactory::arrowDown); - } - } -} - -void BaghiraButton::setMasks(TQBitmap *bitmask, TQBitmap *bitmaskDown){ - clearMask(); - mask = bitmask; - maskDown = bitmaskDown; - if (mask) setMask(*mask); -} -////////////////////////////////////////////////////////////////////////////// -// BaghiraClient Class // -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -// BaghiraClient() -// ------------- -// Constructor - -BaghiraClient::BaghiraClient( KDecorationBridge *b, KDecorationFactory *f ) - : KDecoration( b, f ) -{ - ; -} - -BaghiraClient::~BaghiraClient() -{ - if (noDeco_) - return; - BaghiraFactory::deMaximizer().setClient(NULL); - for ( int n = 0; n < ButtonTypeAmount; n++ ) - { - if ( button[ n ] ) - delete button[ n ]; - } -} - -////////////////////////////////////////////////////////////////////////////// -// init() -// ------ -// Real initialization - -void BaghiraClient::init() -{ - if (BaghiraFactory::noModalDeco() && isModal() && !isMinimizable() && !isResizable()) - { - noDeco_ = true; - createMainWidget( WResizeNoErase | WRepaintNoErase ); - widget() ->setBackgroundMode( NoBackground ); - return; - } - noDeco_ = false; -#if KDE_IS_VERSION(3,3,91) - //first try if there's an X setting - unsigned char *data = 0; - Atom actual; - int format, result; - unsigned long n, left; - currentStyle = BaghiraFactory::defaultMode(); - result = XGetWindowProperty(tqt_xdisplay(), windowId(), baghira_deco_design, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, &data); - if (result == Success && data != None) // found set design - { - memcpy (¤tStyle, data, sizeof (unsigned int)); - currentStyle = currentStyle>4?4:currentStyle; - } - else // try if there's a definition file - { - XClassHint classHint; - FILE *file = NULL; - if ( XGetClassHint( tqt_xdisplay(), windowId(), &classHint ) ) - { - TQString tmpString; - // overwrite file from bab starter? - don't worry, if there's been one and deleted by the style we've got the X setting (much better as it will take care of all subwindows) - tmpString = TQDir::homeDirPath() + "/.baghira/.bab/" + TQString( classHint.res_class ).lower(); - if( (file = fopen(tmpString.latin1(), "r")) != NULL ) - { - fscanf(file,"%d\n%d\n", &format, ¤tStyle); - fclose(file); - remove(tmpString.latin1()); // this is only temporary - } - else - { - tmpString = TQDir::homeDirPath() + "/.baghira/" + TQString( classHint.res_class ).lower(); - if( (file = fopen(tmpString.latin1(), "r")) != NULL ) - { - fscanf(file,"%d\n%d\n", &format, ¤tStyle); - fclose(file); - } - } - XFree( classHint.res_name ); - XFree( classHint.res_class ); - } - if (file == NULL) - { - TQString tmpString = TQDir::homeDirPath() + "/.baghira/.bab/.deco"; - if( (file = fopen(tmpString.latin1(), "r")) != NULL ) - { - fscanf(file,"%d\n%d\n", &format, ¤tStyle); - fclose(file); - } - } - } - if (currentStyle > 4) - currentStyle = BaghiraFactory::defaultMode(); -#else - TQSettings config; - config.beginGroup("/baghira/Style"); - if (config.readBoolEntry( "Design_Default", 1 ) == 2) - { - currentStyle = 2; - config.endGroup(); - } - else - { - config.endGroup(); - config.beginGroup("/baghira/Deco"); - int tmp = config.readNumEntry( "defaultMode", 1 ); - currentStyle = (tmp > -1 && tmp < 5) ? tmp : 1; - config.endGroup(); - } -#endif - createMainWidget( WResizeNoErase | WRepaintNoErase ); - widget() ->installEventFilter( this ); - widget() ->setBackgroundMode( NoBackground ); - - if ( isTool() ) // tool windows have tiny titlebars - titleheight_ = TITLESIZESMALL; - else - titleheight_ = TITLESIZE; - - // setup layout - TQVBoxLayout *mainlayout = new TQVBoxLayout( widget() ); - TQHBoxLayout *titlelayout = new TQHBoxLayout(); - windowlayout = new TQHBoxLayout(); - - titlebar_ = new TQSpacerItem( 1, titleheight_, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); - mainlayout->setResizeMode( TQLayout::FreeResize ); - mainlayout->addLayout( titlelayout ); - mainlayout->addLayout( windowlayout ); - - windowlayout->addSpacing( BaghiraFactory::borderSize(currentStyle) ); - if ( isPreview() ) - windowlayout->addWidget( new TQLabel( i18n( "
Baghira preview
" ), widget() ) ); - else - windowlayout->addItem( new TQSpacerItem( 0, 18 ) ); - - windowlayout->addSpacing( BaghiraFactory::borderSize(currentStyle) ); - - leftClose = false; - rightClose = false; - performEasyClose = false; - - // setup titlebar - for ( int n = 0; n < ButtonTypeAmount; n++ ) - button[ n ] = 0; - plusminus = 1; - addButtons( titlelayout, options() ->titleButtonsLeft() ); - titlelayout->addItem( titlebar_ ); - plusminus = -1; - isFaded = false; - addButtons( titlelayout, options() ->titleButtonsRight() ); -#if KDE_IS_VERSION(3,3,91) - grip = 0; -#endif - - if (BaghiraFactory::effect(currentStyle, true) >= Baghira::Brushed || BaghiraFactory::effect(currentStyle, false) >= Baghira::Brushed) - HandlePix = TQPixmap(BaghiraFactory::pix(currentStyle, TitleBar, isActive(), false )); - else if ( BaghiraFactory::bgStipple() ) - { - HandlePix = TQPixmap( 32, 32); - TQPainter painter; - TQColor c = widget()->colorGroup().background(); - HandlePix.fill(c); - painter.begin( &HandlePix ); - painter.setPen( c.dark( 100 + (BaghiraFactory::contrast()/2) ) ); - - for ( int i = 1; i < 32; i += 4 ) - { - painter.drawLine( 0, i, 31, i ); - painter.drawLine( 0, i+2, 31, i+2 ); - } - - painter.setPen( c.dark( 100 + BaghiraFactory::contrast() ) ); - - for ( int i = 2; i < 31; i += 4 ) - painter.drawLine( 0, i, 31, i ); - - painter.end(); - } -} - -TQString BaghiraClient::caption() const -{ - if (!BaghiraFactory::delAppname()) - return KDecoration::caption(); - if (caption_.isNull()) - // generate first - { - const_cast( this )->caption_ = KDecoration::caption(); - int pos; - if (caption_.startsWith( "tvtime" )) - { - pos = caption_.find(": "); - if (pos > -1) - const_cast( this )->caption_ = const_cast( this )->caption_.remove(0, pos+1); - } - else - { - pos = caption_.findRev(" - "); - if (pos > -1) - const_cast( this )->caption_ = caption_.left(pos); - } - } - return caption_; -} - -////////////////////////////////////////////////////////////////////////////// -// addButtons() -// ------------ -// Add buttons to title layout - -void BaghiraClient::addButtons( TQBoxLayout *layout, const TQString& s ) -{ - if (noDeco_) - return; - // const unsigned char *bitmap; - TQString tip; - TQBitmap *m = NULL; - TQBitmap *mn = NULL; - TQBitmap *mD = NULL; - TQBitmap *mnD = NULL; - TQBitmap *mH = NULL; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed){ - m = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - &BaghiraFactory::pantherMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMask : - NULL; - mn = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - &BaghiraFactory::pantherMenuMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMenuMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMenuMask : - NULL; - mD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - NULL : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarDownMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkDownMask : - NULL; - mnD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - NULL : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMenuDownMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMenuDownMask : - NULL; - mH = &BaghiraFactory::helpMask; - } - if ( s.length() > 0 ) { -// tqWarning("%s",s.ascii()); - layout->addSpacing( MARGIN ); - excursion = excursion + plusminus * MARGIN; - bool buttonAdded; - for ( unsigned n = 0; n < s.length(); n++ ) { - buttonAdded = false; - switch ( s[ n ].latin1() ) { - case 'M': // Menu button - if ( !button[ MenuButton ] ) { - button[ MenuButton ] = new BaghiraButton( this, "menu", - i18n( "Menu" ), isTool(), MenuButton ); - connect( button[ MenuButton ], SIGNAL( pressed() ), this, - SLOT( menuButtonPressed() ) ); - layout->addWidget( button[ MenuButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * MENUBUTTONWIDTH; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MenuButton ]->setMasks(mn, mnD); - } - break; - - case 'S': // Sticky button - if ( !button[ StickyButton ] ) { - if ( isOnAllDesktops() ) { - tip = i18n( "Un-Sticky" ); - } else { - tip = i18n( "Sticky" ); - } - button[ StickyButton ] = new BaghiraButton( this, "sticky", - tip, isTool(), StickyButton ); - connect( button[ StickyButton ], SIGNAL( clicked() ), this, - SLOT( toggleOnAllDesktops() ) ); - layout->addWidget( button[ StickyButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ StickyButton ]->setMasks(m, mD); - } - break; - - case 'H': // Help button - if ( ( !button[ HelpButton ] ) && providesContextHelp() ) { - button[ HelpButton ] = new BaghiraButton( this, "help", - i18n( "Help" ), isTool(), HelpButton ); - connect( button[ HelpButton ], SIGNAL( clicked() ), this, - SLOT( showContextHelp() ) ); - layout->addWidget( button[ HelpButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ HelpButton ]->setMasks(mH, NULL); - } - break; - - case 'I': // Minimize button - if ( ( !button[ MinButton ] ) && isMinimizable() ) { - button[ MinButton ] = new BaghiraButton( this, "iconify", - i18n( "Minimize" ), isTool(), MinButton ); - connect( button[ MinButton ], SIGNAL( clicked() ), this, - SLOT( minimize() ) ); - layout->addWidget( button[ MinButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MinButton ]->setMasks(m, mD); - } - break; - - case 'A': // Maximize button - if ( ( !button[ MaxButton ] ) && isMaximizable() ) { - if ( maximizeMode() == MaximizeFull ) { - tip = i18n( "Restore" ); - } else { - tip = i18n( "Maximize" ); - } - button[ MaxButton ] = new BaghiraButton( this, "maximize", - tip, isTool(), MaxButton ); - connect( button[ MaxButton ], SIGNAL( clicked() ), this, - SLOT( maxButtonPressed() ) ); - layout->addWidget( button[ MaxButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MaxButton ]->setMasks(m, mD); - } - break; - - case 'X': // Close button - if ( ( !button[ CloseButton ] ) && isCloseable() ) { - button[ CloseButton ] = new BaghiraButton( this, "close", - i18n( "Close" ), isTool(), CloseButton ); - connect( button[ CloseButton ], SIGNAL( clicked() ), this, - SLOT( closeWindow() ) ); - layout->addWidget( button[ CloseButton ] ); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (plusminus == 1 && n == 0) // left Button - leftClose = true; - if (plusminus == -1 && n == s.length() - 1) // right Button - rightClose = true; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ CloseButton ]->setMasks(m, mD); - } - break; - - case 'F': // Above button - case 'B': // Below button - if ((!button[AboveBelowButton])) - { - button[AboveBelowButton] = new BaghiraButton(this, "above", i18n("Keep Above/Below Others"), isTool(), AboveBelowButton); - button[AboveBelowButton]->setDown( keepAbove() || keepBelow() ); - connect(button[AboveBelowButton], SIGNAL(clicked()), this, SLOT(aboveBelowButtonPressed())); - layout->addWidget(button[AboveBelowButton]); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ AboveBelowButton ]->setMasks(m, mD); - } - break; - case 'L': // Shade button - if ((!button[ShadeButton] && isShadeable())) { - button[ShadeButton] = new BaghiraButton(this, "shade", isSetShade() ? tip = i18n("Unshade") : tip = i18n("Shade"), isTool(), ShadeButton); - button[ShadeButton]->setDown( isShade() ); - connect(button[ShadeButton], SIGNAL(clicked()), this, SLOT(shadeButtonPressed())); - layout->addWidget(button[ShadeButton]); - buttonAdded = true; - excursion = excursion + plusminus * BUTTONSIZE; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ ShadeButton ]->setMasks(m, mD); - } - break; -// case 'R': // Shade button -// if ((!button[ShadeButton] && isShadeable())) { -// button[ShadeButton] = new BaghiraButton(this, "shade", isSetShade() ? tip = i18n("Unshade") : tip = i18n("Shade"), isTool(), ShadeButton); -// button[ShadeButton]->setDown( isShade() ); -// connect(button[ShadeButton], SIGNAL(clicked()), this, SLOT(shadeButtonPressed())); -// layout->addWidget(button[ShadeButton]); -// buttonAdded = true; -// excursion = excursion + plusminus * BUTTONSIZE; -// if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ ShadeButton ]->setMasks(m, mD); -// } -// break; - - case '_': // Spacer item - layout->addSpacing( MARGIN ); - excursion = excursion + plusminus * MARGIN; - } - if (BaghiraFactory::addAutoSpacing() && buttonAdded){ - layout->addSpacing( MARGIN ); - excursion = excursion + plusminus * MARGIN; - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// eventFilter() -// ------------- -// Event filter - -bool BaghiraClient::eventFilter( TQObject *obj, TQEvent *e ) -{ - if ( obj != widget() ) - return false; - - switch ( e->type() ) { - case TQEvent::MouseButtonDblClick: { - mouseDoubleClickEvent( static_cast( e ) ); - return true; - } - case TQEvent::MouseButtonPress: { - if (titlebar_->geometry().contains( static_cast(e)->pos() ) && static_cast(e)->state() == TQt::ControlButton){ - currentStyle < 4 ? currentStyle++ : currentStyle = 0; -#if KDE_IS_VERSION(3,3,91) - unsigned long wmDesign = currentStyle; - XChangeProperty(tqt_xdisplay(), windowId(), baghira_deco_design, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &wmDesign, 1L); -#endif - widget()->repaint(); - TQBitmap *m = NULL; - TQBitmap *mn = NULL; - TQBitmap *mD = NULL; - TQBitmap *mnD = NULL; - TQBitmap *mH = NULL; - if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed){ - m = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - &BaghiraFactory::pantherMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMask : - NULL; - mn = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - &BaghiraFactory::pantherMenuMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMenuMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMenuMask : - NULL; - mD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - NULL : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarDownMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkDownMask : - NULL; - mnD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? - NULL : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? - &BaghiraFactory::jaguarMenuDownMask : - BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? - &BaghiraFactory::milkMenuDownMask : - NULL; - mH = &BaghiraFactory::helpMask; - } - for (int i = 0; i < ButtonTypeAmount; i++){ - if (button[i]){ - button[i]->setMasks(i < Baghira::MenuButton ? m : - i == Baghira::MenuButton ? mn : - mH, i < Baghira::MenuButton ? mD : - i == Baghira::MenuButton ? mnD : - NULL); - button[i]->repaint(); - } - } -#if KDE_IS_VERSION(3,3,91) - if (grip) - grip->updateLook(TRUE); -#endif - doShape(); - return true; - } - if (BaghiraFactory::allowEasyClosing()){ - if (maximizeMode() == MaximizeFull && isActive() && (leftClose && static_cast( e )->x() == 0 && static_cast( e )->y() == 0) || (rightClose && static_cast( e )->x() == ((TQWidget *)obj)->width() -1 && static_cast( e )->y() == 0)) - performEasyClose = true; - else processMousePressEvent( static_cast( e ) ); - } - else processMousePressEvent( static_cast( e ) ); - return true; - } - case TQEvent::MouseButtonRelease:{ - if (performEasyClose && maximizeMode() == MaximizeFull && (leftClose && static_cast( e )->x() == 0 && static_cast( e )->y() == 0) || (rightClose && static_cast( e )->x() == ((TQWidget *)obj)->width() -1 && static_cast( e )->y() == 0)){ - closeWindow(); - performEasyClose = false; - return true; - } - return FALSE; - } - case TQEvent::Paint: { - paintEvent( static_cast( e ) ); - return true; - } - case TQEvent::Resize: { - resizeEvent( static_cast( e ) ); - return true; - } - case TQEvent::Show: { -#if KDE_IS_VERSION(3,3,91) - if (!grip && BaghiraFactory::resizeGrip() && isResizable()) grip = new ResizeHandle(this); -#endif - showEvent( static_cast( e ) ); - return true; - } - case TQEvent::Hide: { - emit hide(); - } - case TQEvent::Wheel: { - wheelEvent(static_cast( e )); - return true; - } - default: { - return false; - } - } - - return false; -} - -////////////////////////////////////////////////////////////////////////////// -// mouseCoubleClickEvent() -// ----------------------- -// Doubleclick on title - -void BaghiraClient::mouseDoubleClickEvent( TQMouseEvent *e ) -{ - if ( titlebar_->geometry().contains( e->pos() ) ) - titlebarDblClickOperation(); -} - -void BaghiraClient::wheelEvent( TQWheelEvent *e ) -{ - if (titlebar_->geometry().contains( e->pos() ) && e->state() == TQt::ControlButton){ - // surf through the desktops :) - int target, cD; - if (e->delta() > 0){ - (cD = KWin::currentDesktop()) == KWin::numberOfDesktops() ? target = 1 : target = cD + 1; - } - else{ - (cD = KWin::currentDesktop()) == 1 ? target = KWin::numberOfDesktops() : target = cD - 1; - } - setDesktop (target); - KWin::setCurrentDesktop (target); - } -} - -////////////////////////////////////////////////////////////////////////////// -// paintEvent() -// ------------ -// Repaint the window - -void BaghiraClient::paintEvent( TQPaintEvent* ) -{ - if ( !BaghiraFactory::initialized() || noDeco_) - return ; - - TQPainter painter( widget() ); - TQColorGroup group; - - TQRect title( 0, 0, width(), titlebar_->geometry().height() ); - TQRect left( 0, title.height(), BaghiraFactory::borderSize(currentStyle), height() - - title.height() ); - TQRect right( width() - BaghiraFactory::borderSize(currentStyle), title.height(), - BaghiraFactory::borderSize(currentStyle), height() - title.height() ); - TQRect handle( 0, height() - BaghiraFactory::borderSize(currentStyle), - width(), BaghiraFactory::borderSize(currentStyle) ); - - int x, y, x2, y2, h, w; - - title.rect( &x, &y, &w, &h ); - - // draw title bar - if (BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Brushed) - { - if (w > 1024) - { - int w1 = (w - 1024)/2; - int w2 = w - 1024 - w1; - painter.drawTiledPixmap( 0,0, w1, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ),256-w1,0 ); - painter.drawPixmap( w1, 0/*, 1024, h*/, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ) ); - painter.drawTiledPixmap( w1 + 1024, 0, w2, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); - } - else - painter.drawTiledPixmap( 0, 0, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-w)/2, 0 ); - } - else - painter.drawTiledPixmap( title, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); - - x2 = title.right(); - y2 = title.bottom(); - int shapeW = w; - - const TQColor *ttbar = &(BaghiraFactory::color(currentStyle, Baghira::ColorTitleBar, isActive())); - - int tmp3Dimpact_ = 100 + BaghiraFactory::_3DImpact(currentStyle); - - painter.setPen( ttbar->light(tmp3Dimpact_)); - painter.drawLine( x+1, y+1, x2-1, y+1 ); - - if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) - { - // draw around the corners ;-) - if (BaghiraFactory::shapeUL(currentStyle)) - { - // Draw edge of top-left corner inside the area removed by the mask. - painter.drawPoint( 3, 2 ); - painter.drawPoint( 4, 2 ); - painter.drawPoint( 2, 3 ); - painter.drawPoint( 2, 4 ); - } - if (BaghiraFactory::shapeUR(currentStyle)) - { - // Draw edge of top-right corner inside the area removed by the mask. - painter.drawPoint( shapeW - 5, 2 ); - painter.drawPoint( shapeW - 4, 2 ); - painter.drawPoint( shapeW - 3, 3 ); - painter.drawPoint( shapeW - 3, 4 ); - } - } - - - painter.setPen( ttbar->dark(tmp3Dimpact_) ); - if (BaghiraFactory::drawComicFrame() && !(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) - { - painter.drawLine(x,y,x, y2); - painter.drawLine(x2,y,x2, y2); - } - painter.drawLine( x, y, x2, y ); - - if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) - { - // draw around the corners ;-) - if (BaghiraFactory::shapeUL(currentStyle)) - { - // Draw edge of top-left corner inside the area removed by the mask. - painter.drawPoint( 3, 1 ); - painter.drawPoint( 4, 1 ); - painter.drawPoint( 2, 2 ); - painter.drawPoint( 1, 3 ); - painter.drawPoint( 1, 4 ); - } - if (BaghiraFactory::shapeUR(currentStyle)) - { - // Draw edge of top-right corner inside the area removed by the mask. - painter.drawPoint( shapeW - 5, 1 ); - painter.drawPoint( shapeW - 4, 1 ); - painter.drawPoint( shapeW - 3, 2 ); - painter.drawPoint( shapeW - 2, 3 ); - painter.drawPoint( shapeW - 2, 4 ); - } - } - - const TQColor *ttblend = &(BaghiraFactory::color(currentStyle, Baghira::ColorTitleBlend, isActive())); - - if (BaghiraFactory::LineImpact(currentStyle) > 0) - { - painter.setPen( ttblend->dark(100 + BaghiraFactory::LineImpact(currentStyle)) ); - painter.drawLine( x, y2, x2, y2 ); - } - - // draw title text - titlebar_->geometry().rect( &x, &y, &w, &h ); - int iconLeft; - int iconWidth; - if (BaghiraFactory::showTitle()) - { - painter.setFont( options() ->font( isActive(), isTool() ) ); - painter.setPen( options()->color( ColorFont, isActive() ) ); - BaghiraFactory::drawIcon(currentStyle) ? iconWidth = 16 : iconWidth = 0; - if (BaghiraFactory::drawIcon(currentStyle) || BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Nostalgia) - { - TQRect textBound = painter.boundingRect ( x + 2 * MARGIN + iconWidth, y, w - MARGIN * 2 - iconWidth, h, BaghiraFactory::titleAlign() | AlignVCenter, caption() ); - iconLeft = textBound.x() - MARGIN - iconWidth; - if ( iconLeft < x + MARGIN ) iconLeft = x + MARGIN; - - if (BaghiraFactory::drawIcon(currentStyle)) - { - ICONX = iconLeft; - ICONY = y + ( titleheight_ - 16 ) / 2; - painter.drawPixmap( ICONX, ICONY, icon().pixmap( TQIconSet::Small, TQIconSet::Normal ) ); - } - - if (BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Nostalgia) - { - painter.fillRect( iconLeft - 5, y + 1, textBound.right() - iconLeft + 10, h - 2, BaghiraFactory::color(currentStyle, Baghira::ColorTitleBar, isActive() ) ); - painter.fillRect( title.x(), y + 1, x - title.x()+5, h - 2, *ttbar ); - painter.fillRect( x+w-5, y + 1, title.right() - w + 5, h - 2, *ttbar ); - } - } - painter.drawText( x + 2 * MARGIN + iconWidth, y, w - MARGIN * 2 - iconWidth, h, BaghiraFactory::titleAlign() | AlignVCenter, caption() ); - } - else if (BaghiraFactory::drawIcon(currentStyle)) - { - iconLeft = (width()-16)/2; - if ( iconLeft < x + MARGIN ) - iconLeft = x + MARGIN; - ICONX = iconLeft; - ICONY = y + ( titleheight_ - 16 ) / 2; - painter.drawPixmap( ICONX, ICONY, icon().pixmap( TQIconSet::Small, TQIconSet::Normal ) ); - } - - // draw outer frame - if ( !isShade() ) - { - TQColor background = widget() ->colorGroup().background(); - - // left side - left.rect( &x, &y, &w, &h ); - if (w > 0){ - if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed) - { - width() > 1024 ? - painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ) : - painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-width())/2 ); - } - else - { - BaghiraFactory::bgStipple() ? - painter.drawTiledPixmap( x, y, w, h, HandlePix ) : - painter.fillRect( x, y, w, h, background ); - } - } - - // right side - right.rect( &x, &y, &w, &h ); - if (w > 0){ - if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed) - { - width() > 1024 ? - painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ) : - painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-width())/2+width()-w ); - } - else - { - BaghiraFactory::bgStipple() ? - painter.drawTiledPixmap( x, y, w, h, HandlePix ) : - painter.fillRect( x, y, w, h, background ); - } - } - - // draw handle ===================================================== - // bottom bar - // handle middle - handle.rect( &x, &y, &w, &h ); - if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed){ - if (w > 1024){ - int w1 = (w - 1024)/2; - int w2 = w - 1024 - w1; - painter.drawTiledPixmap( 0, y, w1, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); - painter.drawPixmap( w1, y, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ) ); - painter.drawTiledPixmap( w1 + 1024, y, w2, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); - } - else{ - painter.drawPixmap( x, y, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-w)/2, 0, w, h ); - } - - int b = handle.bottom() - 1; -// painter.setPen( ttbar->light(tmp3Dimpact_)); - painter.setPen( ttbar->dark(tmp3Dimpact_*1.1) ); - painter.drawLine( x, b, w-1, b ); - if (maximizeMode() != MaximizeFull) - { - if (BaghiraFactory::shapeLL(currentStyle)){ - // Draw edge of bottom-left corner inside the area removed by the mask. - painter.drawPoint(3, b); - painter.drawPoint(4, b); - painter.drawPoint(2, b-1); - painter.drawPoint(1, b-2); - painter.drawPoint(1, b-3); - painter.drawPoint(0, b-4); - } - if (BaghiraFactory::shapeLR(currentStyle)){ - // Draw edge of bottom-right corner inside the area removed by the mask. - painter.drawPoint(shapeW - 5, b); - painter.drawPoint(shapeW - 4, b); - painter.drawPoint(shapeW - 3, b-1); - painter.drawPoint(shapeW - 2, b-2); - painter.drawPoint(shapeW - 2, b-3); - painter.drawPoint(shapeW - 1, b-4); - } - } - painter.setPen( ttbar->dark(tmp3Dimpact_*1.3) ); - painter.drawLine( x+1, b+1, w-2, b+1 ); - if (maximizeMode() != MaximizeFull) - { - if (BaghiraFactory::shapeLL(currentStyle)){ - // Draw edge of bottom-left corner inside the area removed by the mask. - painter.drawPoint(4, b); - painter.drawPoint(5, b); - painter.drawPoint(3, b-1); - painter.drawPoint(2, b-2); -// painter.drawPoint(2, b-3); - } - if (BaghiraFactory::shapeLR(currentStyle)){ - // Draw edge of bottom-right corner inside the area removed by the mask. - painter.drawPoint(shapeW - 6, b); - painter.drawPoint(shapeW - 5, b); - painter.drawPoint(shapeW - 4, b-1); - painter.drawPoint(shapeW - 3, b-2); -// painter.drawPoint(shapeW - 3, b-3); - } - } - if (BaghiraFactory::drawComicFrame()) - { - painter.drawLine(x,title.y(),x, b); - painter.drawLine(handle.right(),title.y(),x2, b); - } - } - else{ - BaghiraFactory::bgStipple() ? painter.drawTiledPixmap( x, y, w, h, HandlePix ) : - painter.fillRect( x, y, w, h, background ); - - x2 = handle.right(); - y2 = handle.bottom(); - if (BaghiraFactory::drawComicFrame() && maximizeMode() != MaximizeFull){ - painter.setPen(ttblend->dark(tmp3Dimpact_)); - painter.drawLine( handle.x()/*+7*/, y2, x2/*-7*/, y2 ); - painter.drawLine(0,title.bottom(),0, y2); - painter.drawLine(x2,title.bottom(),x2, y2); - } - } - if (BaghiraFactory::drawComicFrame() && maximizeMode() != MaximizeFull){ - int b = handle.bottom() - 1; - if (BaghiraFactory::shapeLL(currentStyle)){ - // Draw edge of bottom-left corner inside the area removed by the mask. - painter.drawPoint(3, b); - painter.drawPoint(4, b); - painter.drawPoint(2, b-1); - painter.drawPoint(1, b-2); - painter.drawPoint(1, b-3); - } - if (BaghiraFactory::shapeLR(currentStyle)){ - // Draw edge of bottom-right corner inside the area removed by the mask. - painter.drawPoint(shapeW - 5, b); - painter.drawPoint(shapeW - 4, b); - painter.drawPoint(shapeW - 3, b-1); - painter.drawPoint(shapeW - 2, b-2); - painter.drawPoint(shapeW - 2, b-3); - } - } - } -} - -////////////////////////////////////////////////////////////////////////////// -// resizeEvent() -// ------------- -// Window is being resized - -void BaghiraClient::resizeEvent( TQResizeEvent* ) -{ - if (noDeco_) - return; - /*if ( widget() ->isShown() ) { - TQRegion region = widget() ->rect(); - region = region.subtract( titlebar_->geometry() ); - widget() ->erase( region ); - }*/ -// widget()->repaint(); - doShape(); -} - -///////////////////////////////////////////////////////////////////////////// -// shape Corners -// =) ==================================================================0 - -void BaghiraClient::doShape() -{ -// return; - TQRegion mask; - - if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)){ - int r = width(); - int b = height() - 1; - mask = TQRegion( 0, 0, r, b+1 ); - - if (BaghiraFactory::shapeUL(currentStyle)){ - // Remove top-left corner. - mask -= TQRegion( 0, 0, 5, 1 ); - mask -= TQRegion( 0, 1, 3, 1 ); - mask -= TQRegion( 0, 2, 2, 1 ); - mask -= TQRegion( 0, 3, 1, 2 ); - } - if (BaghiraFactory::shapeUR(currentStyle)){ - // Remove top-right corner. - mask -= TQRegion( r - 5, 0, 5, 1 ); - mask -= TQRegion( r - 3, 1, 3, 1 ); - mask -= TQRegion( r - 2, 2, 2, 1 ); - mask -= TQRegion( r - 1, 3, 1, 2 ); - } - - if (BaghiraFactory::shapeLL(currentStyle)){ - // Remove bottom-left corner. - mask -= TQRegion(0, b-0, 5, 1); - mask -= TQRegion(0, b-1, 3, 1); - mask -= TQRegion(0, b-2, 2, 1); - mask -= TQRegion(0, b-4, 1, 2); - } - if (BaghiraFactory::shapeLR(currentStyle)){ - // Remove bottom-right corner. - mask -= TQRegion(r - 5, b-0, 5, 1); - mask -= TQRegion(r - 3, b-1, 3, 1); - mask -= TQRegion(r - 2, b-2, 2, 1); - mask -= TQRegion(r - 1, b-4, 1, 2); - } - } - setMask( mask, 1 ); -} - - -////////////////////////////////////////////////////////////////////////////// -// showEvent() -// ----------- -// Window is being shown - -void BaghiraClient::showEvent( TQShowEvent* ) -{ - if (noDeco_) - return; - doShape(); - widget() ->repaint(); -} - -////////////////////////////////////////////////////////////////////////////// -// activeChange() -// -------------- -// window active state has changed - -void BaghiraClient::activeChange() -{ - if (noDeco_) - return; - if (BaghiraFactory::fullSpec() && maximizeMode() == MaximizeFull) - { - if (isActive()) - { - BaghiraFactory::deMaximizer().show(); - BaghiraFactory::deMaximizer().setClient(this); - } - } - else - { - BaghiraFactory::deMaximizer().hide(); - for ( int n = 0; n < ButtonTypeAmount; n++ ) - { - if ( button[ n ] ) - { - button[n]->setAutoMask( BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Brushed); - button[ n ] ->reset(); - } - } - widget() ->repaint( false ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// captionChange() -// --------------- -// The title has changed - -void BaghiraClient::captionChange() -{ - if (noDeco_) - return; - if (BaghiraFactory::showTitle()) - { - if (BaghiraFactory::delAppname()) - { - caption_ = KDecoration::caption(); - int pos; - if (caption_.startsWith( "tvtime" )) - { - pos = caption_.find(": "); - if (pos > -1) - caption_ = caption_.remove(0, pos+1); - } - else - { - pos = caption_.findRev(" - "); - if (pos > -1) - caption_ = caption_.left(pos); - } - } - widget() ->repaint( titlebar_->geometry(), false ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// desktopChange() -// --------------- -// Sticky state has changed - -void BaghiraClient::desktopChange() -{ - if (noDeco_) - return; - bool d = isOnAllDesktops(); - if ( button[ StickyButton ] ) - { - TQToolTip::remove - ( button[ StickyButton ] ); - TQToolTip::add - ( button[ StickyButton ], d ? i18n( "Un-Sticky" ) : i18n( "Sticky" ) ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// iconChange() -// ------------ -// The title has changed - -void BaghiraClient::iconChange() -{ - if (noDeco_) - return; - if (BaghiraFactory::drawIcon(currentStyle)) widget()->repaint(ICONX, ICONY, 16, 16, false); -} - -////////////////////////////////////////////////////////////////////////////// -// maximizeChange() -// ---------------- -// Maximized state has changed - -void BaghiraClient::maximizeChange() -{ - if (noDeco_) //shouldn't happen - windo's not maximizable - return; - bool m = ( maximizeMode() == MaximizeFull ); - if (BaghiraFactory::fullSpec() && m){ - if (isActive()){ - BaghiraFactory::deMaximizer().show(); - BaghiraFactory::deMaximizer().setClient(this); - } - } - else { - BaghiraFactory::deMaximizer().setClient(NULL); - BaghiraFactory::deMaximizer().hide(); - } - if ( button[ MaxButton ] ) { - TQToolTip::remove - ( button[ MaxButton ] ); - TQToolTip::add - ( button[ MaxButton ], m ? i18n( "Restore" ) : i18n( "Maximize" ) ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// shadeChange() -// ------------- -// Called when window shading changes - -void BaghiraClient::shadeChange() { - ; -} - -////////////////////////////////////////////////////////////////////////////// -// borders() -// ---------- -// Get the size of the borders - -void BaghiraClient::borders( int &l, int &r, int &t, int &b ) const -{ - if (noDeco_) - { - l = r = t = b = 0; - return; - } - bool m = ( maximizeMode() == MaximizeFull); - t = (BaghiraFactory::fullSpec() && m) ? 0 : titleheight_; - if (m || maximizeMode() == MaximizeHorizontal) - l = r = BaghiraFactory::maxResizable() ? 1 : 0; - else - l = r = BaghiraFactory::borderSize(currentStyle); - if ( m || isShade() || (maximizeMode() == MaximizeVertical)) - b = BaghiraFactory::maxResizable() ? 1 : 0; - else - b = BaghiraFactory::borderSize(currentStyle); -} - -////////////////////////////////////////////////////////////////////////////// -// resize() -// -------- -// Called to resize the window - -void BaghiraClient::resize( const TQSize &size ) -{ - if (noDeco_) - return; - widget() ->resize( size ); -} - -////////////////////////////////////////////////////////////////////////////// -// minimumSize() -// ------------- -// Return the minimum allowable size for this decoration - -TQSize BaghiraClient::minimumSize() const -{ - return TQSize( 100, 60 ); -} - -////////////////////////////////////////////////////////////////////////////// -// mousePosition() -// --------------- -// Return mouse position (for resizing) - -KDecoration::Position BaghiraClient::mousePosition( const TQPoint &point ) const -{ - if (noDeco_) - return PositionCenter; - Position pos = PositionCenter; - if ( point.y() < ( height() - BaghiraFactory::borderSize(currentStyle) ) ) { // inside client - pos = KDecoration::mousePosition( point ); - } else { - if ( point.x() >= ( width() - 16 ) ) - pos = PositionBottomRight; - else if ( point.x() <= 16 ) - pos = PositionBottomLeft; - else - pos = PositionBottom; - } - return pos; -} - - -////////////////////////////////////////////////////////////////////////////// -// maxButtonPressed() -// ----------------- -// Max button was pressed - - -void BaghiraClient::demaxButtonPressed() { - maxButtonPressed(); -} - -void BaghiraClient::maxButtonPressed() { - if ( !BaghiraFactory::fullSpec() || (maximizeMode() != MaximizeFull) && button[ MaxButton ]) { - switch ( button[ MaxButton ] ->lastMousePress() ) { - case MidButton: - maximize( maximizeMode() ^ MaximizeVertical ); - break; - case RightButton: - maximize( maximizeMode() ^ MaximizeHorizontal ); - break; - default: - if ( maximizeMode() == MaximizeFull ) { - maximize( MaximizeRestore ); - } - else { - maximize( MaximizeFull ); - } - } - } - else{ - maximize( MaximizeRestore ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// menuButtonPressed() -// ------------------- -// Menu button was pressed - -void BaghiraClient::menuButtonPressed() { - if ( button[ MenuButton ] ) { - TQPoint pt( button[ MenuButton ] ->rect().bottomLeft().x(), - button[ MenuButton ] ->rect().bottomLeft().y() + 4 ); - KDecorationFactory* f = factory(); - showWindowMenu( button[ MenuButton ] ->mapToGlobal( pt ) ); - if ( !f->exists( this ) ) - return ; // we have been destroyed - button[ MenuButton ] ->setDown( false ); - } -} - -////////////////////////////////////////////////////////////////////////////// -// new stuff - -void BaghiraClient::aboveBelowButtonPressed() -{ - if (keepAbove()) - { - button[ AboveBelowButton ] ->setDown(true); - setKeepAbove(false ); - setKeepBelow(true ); - button[ AboveBelowButton ] ->repaint( false ); - } - else if (keepBelow()) - { - button[ AboveBelowButton ] ->setDown(false); - setKeepBelow(false ); - setKeepAbove(false ); - button[ AboveBelowButton ] ->repaint( false ); - } - else - { - button[ AboveBelowButton ] ->setDown(true); - setKeepBelow(false ); - setKeepAbove(true ); - button[ AboveBelowButton ] ->repaint( false ); - } -} - -void BaghiraClient::shadeButtonPressed(){ - button[ ShadeButton ]->setDown(!isShade()); - setShade( !isShade() ); -} - -////////////////////////////////////////////////////////////////////////////// -// isTool() -// -------- -// Is this a tool window? - -bool BaghiraClient::isTool() const { - static const unsigned long winmask = NET::DesktopMask | NET::DialogMask | - NET::DockMask | NET::MenuMask | - NET::NormalMask | NET::OverrideMask | - NET::SplashMask | NET::ToolbarMask | - NET::TopMenuMask | NET::UtilityMask; - - NET::WindowType type = windowType( winmask ); - return ( type == NET::Menu || type == NET::Toolbar || type == NET::Utility ); -} - -#include "baghiraclient.moc" diff --git a/deco/baghiraclient.cpp b/deco/baghiraclient.cpp new file mode 100644 index 0000000..471e440 --- /dev/null +++ b/deco/baghiraclient.cpp @@ -0,0 +1,2643 @@ +////////////////////////////////////////////////////////////////////////////// +// baghiraclient.h +// ------------------- +// Baghira window decoration for KDE +// ------------------- +// Copyright (c) 2004, 2005 Thomas Lübking +// Please see the header file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +// #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "baghiraclient.h" +#include "pixmaps.h" +#include "masks.h" + +#define COLOR_SPACE(R,G,B) \ + if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \ + if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \ + if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255; + +#define SATURATION_COLOR(R,G,B) \ + grey = (299 * R + 587 * G + 114 * B) / 1000; \ + delta = 255 - grey; \ + grey = (grey *(10 - 5)) / 10; \ + iGrey = 255 - grey;\ + destR = (iGrey * (srcR - delta) + grey * R) / 255; \ + destG = (iGrey * (srcG - delta) + grey * G) / 255; \ + destB = (iGrey * (srcB - delta) + grey * B) / 255; + +#define CLAMP(x,l,u) x < l ? l :\ + x > u ? u :\ + x + +#define SATURATION_COLOR2(S,R,G,B,cR,cG,cB) \ + int max = 255+0.65*(100-S); \ + destR = CLAMP((cR + R - 128), 0, max); \ + destG = CLAMP((cG + G - 128), 0, max); \ + destB = CLAMP((cB + B - 128), 0, max); \ + destR = (S*destR + (100-S)*R)/100; \ + destG = (S*destG + (100-S)*G)/100; \ + destB = (S*destB + (100-S)*B)/100; + +using namespace Baghira; + +static const int BUTTONSIZE = 15; +static const int MENUBUTTONWIDTH = 20; +static const int DECOSIZE = 8; +int TITLESIZE;// = 26; +static const int TITLESIZESMALL = 18; +static const int MARGIN = 6; + +////////////////////////////////////////////////////////////////////////////// +// BaghiraFactory Class // +////////////////////////////////////////////////////////////////////////////// + +bool BaghiraFactory::initialized_ = false; +Baghira::TitlebarType BaghiraFactory::effect_[5][2]; +TQt::AlignmentFlags BaghiraFactory::titlealign_; +TQColor BaghiraFactory::colors_[5][ ColorTypeCount ][ 2 ]; +KPixmap BaghiraFactory::pix_[5][ PixmapTypeCount ][ 2 ][ 2 ]; +int BaghiraFactory::bordersize_[5] = {0,0,6,0,0};//{BorderTiny, BorderTiny, BorderVeryHuge}; +TQPixmap BaghiraFactory::ButtonPixmap_[5][WindowStateAmount][ButtonTypeAmount][ButtonStateAmount][2]; +TQColor BaghiraFactory::brushedMetalColor; +TQColor BaghiraFactory::ButtonColor_[ButtonTypeAmount+1]; +TQPixmap BaghiraFactory::nostalgia_[5][3][2]; +int BaghiraFactory::contrast_; +int BaghiraFactory::_3DImpact_[5]; +int BaghiraFactory::LineImpact_[5]; +bool BaghiraFactory::bgStipple_; +bool BaghiraFactory::comicFrame_; +bool BaghiraFactory::addAutoSpacing_; +bool BaghiraFactory::maxResizable_; +bool BaghiraFactory::shape_ul[5]; +bool BaghiraFactory::shape_ur[5]; +bool BaghiraFactory::shape_ll[5]; +bool BaghiraFactory::shape_lr[5]; +bool BaghiraFactory::allowEasyClosing_; +bool BaghiraFactory::resizeGrip_; +uint BaghiraFactory::defaultMode_; +bool BaghiraFactory::drawIcon_[5]; +bool BaghiraFactory::tintBrush_; +bool BaghiraFactory::showTitle_; +TQColor BaghiraFactory::brushTint; +int BaghiraFactory::minimumTitleHeight_; +ButtonStyle BaghiraFactory::buttonStyle_[5]; + +TQBitmap BaghiraFactory::helpMask; +TQBitmap BaghiraFactory::jaguarDownMask; +TQBitmap BaghiraFactory::jaguarMenuDownMask; +TQBitmap BaghiraFactory::jaguarMenuMask; +TQBitmap BaghiraFactory::jaguarMask; +TQBitmap BaghiraFactory::milkMenuDownMask; +TQBitmap BaghiraFactory::milkMenuMask; +TQBitmap BaghiraFactory::milkMask; +TQBitmap BaghiraFactory::pantherMenuMask; +TQBitmap BaghiraFactory::pantherMask; +TQBitmap BaghiraFactory::milkDownMask; +TQBitmap BaghiraFactory::arrowUp; +TQBitmap BaghiraFactory::arrowDown; +DeMaximizer BaghiraFactory::deMaximizer_; +bool BaghiraFactory::fullSpec_; +bool BaghiraFactory::noModalDeco_; +bool BaghiraFactory::delAppname_; + +Atom baghira_deco_design = XInternAtom(tqt_xdisplay(), "BAGHIRA_DECO_DESIGN", False); + +extern "C" +{ + KDE_EXPORT KDecorationFactory* create_factory() + { + return new Baghira::BaghiraFactory(); + } +} + +DeMaximizer::DeMaximizer() : TQWidget(0, "deMaximizer", TQt::WType_TopLevel | TQt::WStyle_NoBorder | TQt::WX11BypassWM ) +{ + client_ = 0L; + setFixedSize(16,16); + setMouseTracking(TRUE); + setAutoMask(TRUE); + move(TQApplication::desktop()->availableGeometry().right()-17,TQApplication::desktop()->availableGeometry().top()+2); + setBackgroundMode( NoBackground ); +// setBackgroundMode (TQt::X11ParentRelative); +// setPaletteBackgroundColor(TQt::green); +} + +void DeMaximizer::mouseReleaseEvent( TQMouseEvent *) +{ + hasMouse()?setState(1):setState(0); + if (client_) client_->demaxButtonPressed(); +} + +void DeMaximizer::mousePressEvent ( TQMouseEvent *) +{ + setState(2); +} + +void DeMaximizer::enterEvent ( TQEvent *) +{ + setState(1); +} + +void DeMaximizer::leaveEvent ( TQEvent *) +{ + setState(0); +} + +void DeMaximizer::setState(int i) +{ + erase(); + TQPainter p(this); + p.drawPixmap(0,0,pixmap[i]); + p.end(); +} + +void DeMaximizer::setPixmap(int i, TQImage &image ) +{ + pixmap[i] = TQPixmap(image); +} + + +void DeMaximizer::setClient(BaghiraClient *client) +{ + if (client_) + { + TQObject::disconnect ( client_, SIGNAL(hide()), this, SLOT(hide()) ); + client_ = 0L; + } + if (client) + { + client_ = client; + connect ( client_, SIGNAL(hide()), SLOT(hide()) ); + setState(0); + } +// repaint(); +} + +#if KDE_IS_VERSION(3,3,91) +////////////////////////////////////////////////////////////////////////////// +// ResizeHandle() +// --------------- +// Constructor +ResizeHandle::ResizeHandle(BaghiraClient * parent) : TQWidget(parent->widget(), 0, 0) +{ + if (!parent->widget()) + return; + client = parent; + setCursor(TQCursor(TQt::SizeFDiagCursor)); + setFixedSize(16,16); + updateLook(FALSE); + WId root, daddy = 0; + WId *kids = 0L; + uint numKids = 0; + XQueryTree(tqt_xdisplay(), parent->windowId(), &root, &daddy, &kids, &numKids); + if (daddy) + XReparentWindow( tqt_xdisplay(), winId(), daddy, 0, 0 ); + else return; + move(client->width()-2*BaghiraFactory::borderSize(parent->currentStyle)-16,client->height()-client->titleheight_-16); + shape(); + parent->widget()->installEventFilter(this); + raise(); + show(); +} + +void ResizeHandle::updateLook(bool rp) +{ + pix = TQPixmap(16,16); + TQPainter p(&pix); + p.fillRect(pix.rect(), BaghiraFactory::effect(client->currentStyle, client->isActive()) == Baghira::Brushed ? BaghiraFactory::BrushedMetalColor().light(110):paletteBackgroundColor()); + p.setPen( BaghiraFactory::effect(client->currentStyle, client->isActive()) == Baghira::Brushed ? TQt::black:paletteForegroundColor() ); + p.drawLine(0,16,16,0); + p.drawLine(4,16,16,4); + p.drawLine(8,16,16,8); + p.drawLine(12,16,16,12); + p.end(); + setPaletteBackgroundPixmap(pix); + if (rp) repaint(); +} + +void ResizeHandle::shape() +{ + XRectangle* xrects = new XRectangle[16]; + for (int i = 0; i < 16; i++) + { + xrects[ i ].x = 15-i; + xrects[ i ].y = i; + xrects[ i ].width = i+1; + xrects[ i ].height = 1; + } + XShapeCombineRectangles( tqt_xdisplay(), winId(), ShapeBounding, 0, 0, + xrects, 16, ShapeSet, 0 ); + delete[] xrects; +} + +bool ResizeHandle::eventFilter(TQObject *obj, TQEvent *e) +{ + if ( obj != parent() ) + return false; + if ( e->type() == TQEvent::Resize) + { + if (client->maximizeMode() == BaghiraClient::MaximizeFull) + move(client->width() - 16, client->height() - client->titleheight_ - 16); + else + move(client->width() - 2*BaghiraFactory::borderSize(client->currentStyle) - 16, client->height() - client->titleheight_ - BaghiraFactory::borderSize(client->currentStyle) - 16); +// shape(); + return FALSE; + } + return FALSE; +} + +void ResizeHandle::mousePressEvent ( TQMouseEvent * ) +{ + client->performWindowOperation(/*Unrestricted*/KDecoration::ResizeOp); +} +void ResizeHandle::mouseReleaseEvent ( TQMouseEvent * ) +{ + client->performWindowOperation(KDecoration::NoOp); + repaint(TRUE); +} +void ResizeHandle::paintEvent ( TQPaintEvent * ) +{ + TQPainter p(this); + p.drawPixmap(0,0,pix); +} + +#endif + +////////////////////////////////////////////////////////////////////////////// +// BaghiraFactory() +// --------------- +// Constructor + +BaghiraFactory::BaghiraFactory() { + helpMask = TQBitmap( 14, 15, help_bits, true ); + jaguarDownMask = TQBitmap( 14, 15, jaguar2_bits, true ); + jaguarMenuDownMask = TQBitmap( 20, 15, jaguar_menu_down_bits, true ); + jaguarMenuMask = TQBitmap( 20, 15, jaguar_menu_bits, true ); + jaguarMask = TQBitmap( 14, 15, jaguar_bits, true ); + milkMenuDownMask = TQBitmap( 20, 15, milk_menu_down_bits, true ); + milkMenuMask = TQBitmap( 20, 15, milk_menu_bits, true ); + milkMask = TQBitmap( 14, 15, milk_bits, true ); + pantherMenuMask = TQBitmap( 20, 15, panther_menu_bits, true ); + pantherMask = TQBitmap( 14, 15, panther_bits, true ); + milkDownMask = TQBitmap( 14, 15, milk_pressed_bits, true ); + arrowUp = TQBitmap( 8, 4, arrowUp_bits, true ); + arrowUp.setMask( arrowUp ); + arrowDown = TQBitmap( 8, 4, arrowDown_bits, true ); + arrowDown.setMask( arrowDown ); + readConfig(); + createPixmaps(); + initialized_ = true; +} + +////////////////////////////////////////////////////////////////////////////// +// ~BaghiraFactory() +// ---------------- +// Destructor + +BaghiraFactory::~BaghiraFactory() +{ + deMaximizer_.setClient(NULL); + initialized_ = false; +} + +////////////////////////////////////////////////////////////////////////////// +// createDecoration() +// ------------------ +// Create the decoration + +KDecoration* BaghiraFactory::createDecoration( KDecorationBridge* b ) { + return new BaghiraClient( b, this ); +} + +////////////////////////////////////////////////////////////////////////////// +// reset() +// ------- +// Reset the handler. Returns true if decorations need to be remade + +TQString BaghiraFactory::indexedString(TQString s, int i){ + TQString result; + result.setNum(i+1); + result.prepend("_"); + result.prepend(s); +// tqWarning("%s",result.ascii()); + return result; +} + +bool BaghiraFactory::reset( unsigned long changed ) { + initialized_ = false; + changed |= readConfig(); + if ( changed & ( SettingColors | SettingDecoration | SettingBorder ) ) { + createPixmaps(); + } + initialized_ = true; + + if ( changed & ( SettingColors | SettingDecoration | SettingFont | + SettingButtons | SettingBorder ) ) { + return true; + } else { + resetDecorations( changed ); + return false; + } +} + +////////////////////////////////////////////////////////////////////////////// +// readConfig() +// ------------ +// Read in the configuration file + +unsigned long BaghiraFactory::readConfig() { + + TQSettings config; + config.beginGroup("/baghira/Style"); +// TDEConfig config( "baghirarc" ); +// config.setGroup( "Style" ); + bgStipple_ = config.readBoolEntry( "Design_StippleBackground", false); + contrast_ = config.readNumEntry( "Design_StippleContrast", 30 ); + tintBrush_ = config.readBoolEntry( "Colors_TintBrushedMetal", false ); + if (tintBrush_) + brushTint.setRgb( config.readNumEntry( "Colors_BrushTint")); + + TQColor oldcolor; + unsigned long changed = 0; + oldcolor = colors_[3][ Baghira::ColorTitleBar ][ false ]; + colors_[3][ Baghira::ColorTitleBar ][ false ] = tqApp->palette().active().background(); + if ( oldcolor != colors_[3][ Baghira::ColorTitleBar ][ false ] ) + changed |= SettingColors; + + oldcolor = colors_[3][ Baghira::ColorTitleBlend ][ false ]; + colors_[3][ Baghira::ColorTitleBlend ][ false ] = colors_[3][ Baghira::ColorTitleBar ][ false ].dark(100 + config.readNumEntry( "Design_StippleContrast", 3)); + if ( oldcolor != colors_[3][ Baghira::ColorTitleBlend ][ false ] ) + changed |= SettingColors; + + config.endGroup(); + config.beginGroup( "/baghira/Deco" ); + + + // common settings + + bool oldNoModalDeco = noModalDeco_; + noModalDeco_ = config.readBoolEntry( "NoModalDeco", false ); + if (oldNoModalDeco != noModalDeco_) + changed |= SettingDecoration; + + bool oldDelAppname = delAppname_; + delAppname_ = config.readBoolEntry( "RemoveAppname", true ); + if (oldDelAppname != delAppname_) + changed |= SettingDecoration; + + int oldMinTH = minimumTitleHeight_; + minimumTitleHeight_ = (ButtonStyle) config.readNumEntry( "minimumTitleHeight", 18 ); + if ( oldMinTH != minimumTitleHeight_ ) + { + TQFontMetrics fm(options()->font(true, false)); + TITLESIZE = TQMAX(minimumTitleHeight_, fm.height()); + changed |= SettingFont; + changed |= SettingDecoration; + } + + bool allowEasyClosing__ = allowEasyClosing_; + allowEasyClosing_ = config.readBoolEntry( "allowEasyClosing", false ); + if ( allowEasyClosing__ != allowEasyClosing_ ) + changed |= SettingDecoration; + + bool resizeGrip__ = resizeGrip_; + resizeGrip_ = config.readBoolEntry( "ResizeGrip", false ); + if ( resizeGrip__ != resizeGrip_ ) + changed |= SettingDecoration; + + bool defaultMode__ = defaultMode_; + defaultMode_ = config.readNumEntry( "defaultMode", 1 ); + if ( defaultMode__ != defaultMode_ ) + changed |= SettingDecoration; + + TQt::AlignmentFlags oldalign = titlealign_; + TQString value = config.readEntry( "TitleAlignment", "AlignHCenter" ); + showTitle_ = TRUE; + if ( value == "AlignLeft" ) + titlealign_ = TQt::AlignLeft; + else if ( value == "AlignHCenter" ) + titlealign_ = TQt::AlignHCenter; + else if ( value == "AlignRight" ) + titlealign_ = TQt::AlignRight; + else if ( value == "noTitle" ) + { + showTitle_ = FALSE; + titlealign_ = TQt::AlignAuto; + } + if ( oldalign != titlealign_ ) + changed |= SettingFont; + + bool oldComic = comicFrame_; + comicFrame_ = config.readBoolEntry( "DrawComicFrame", false ); + if ( oldComic != comicFrame_ ) + changed |= SettingBorder; changed |= SettingDecoration; + + bool oldAutoSpacing = addAutoSpacing_; + addAutoSpacing_ = config.readBoolEntry( "AddAutoSpacing", true ); + if ( oldAutoSpacing != addAutoSpacing_ ) + changed |= SettingDecoration; + + bool oldMaxResizable = maxResizable_; + maxResizable_ = config.readBoolEntry( "MaxResizable", true ); + if ( oldMaxResizable != maxResizable_ ) + changed |= SettingDecoration; + + bool oldSpec = fullSpec_; + fullSpec_ = config.readBoolEntry( "FullSpec", false ); + if ( oldSpec != fullSpec_ ) + changed |= SettingDecoration; + + // custom settings + + for (int i = 0; i < 5; i++){ + + int oldbordersize = bordersize_[i]; + bordersize_[i] = config.readNumEntry( indexedString("BorderSize",i), i == 2 ? 6 : 0 ); + if ( oldbordersize != bordersize_[i] ) + changed |= SettingBorder; + + ButtonStyle oldButtons = buttonStyle_[i]; + buttonStyle_[i] = (ButtonStyle) config.readNumEntry( indexedString("ButtonStyle",i), i == 0 ? 1 : 0 ); + if ( oldButtons != buttonStyle_[i] ) + changed |= SettingDecoration; + + + bool oldShUL = shape_ul[i]; + shape_ul[i] = config.readBoolEntry( indexedString("ShapeUL",i), true ); + if ( oldShUL != shape_ul[i] ){ + changed |= SettingBorder; changed |= SettingDecoration; + } + + bool oldShUR = shape_ur[i]; + shape_ur[i] = config.readBoolEntry( indexedString("ShapeUR",i), true ); + if ( oldShUR != shape_ur[i] ){ + changed |= SettingBorder; changed |= SettingDecoration; + } + + bool oldShLL = shape_ll[i]; + shape_ll[i] = config.readBoolEntry( indexedString("ShapeLL",i), i == 2 ); + if ( oldShLL != shape_ll[i] ){ + changed |= SettingBorder; changed |= SettingDecoration; + } + + bool oldShLR = shape_lr[i]; + shape_lr[i] = config.readBoolEntry( indexedString("ShapeLR",i), i == 2 ); + if ( oldShLR != shape_lr[i] ){ + changed |= SettingBorder; changed |= SettingDecoration; + } + + + bool oldDrawIcon_ = drawIcon_[i]; + drawIcon_[i] = config.readBoolEntry( indexedString("drawIcon",i), true ); + if ( oldDrawIcon_ = drawIcon_[i] ) + changed |= SettingFont; + changed |= SettingDecoration; + + if (i != 3) + { + Baghira::TitlebarType oldeffect = effect_[i][1]; + effect_[i][1] = ( Baghira::TitlebarType ) config.readNumEntry( indexedString("TitleEffect",i), i == 0 ? Baghira::Stipples : (i == 1 || i == 4) ? Baghira::Gradient : Baghira::Brushed); + // tqWarning("%d",effect_[i]); + if ( oldeffect != effect_[i][1] ) + changed |= SettingDecoration; + + oldeffect = effect_[i][0]; + effect_[i][0] = ( Baghira::TitlebarType ) config.readNumEntry( indexedString("inactiveTitleEffect",i), i == 0 ? Baghira::Stipples : (i == 1 || i == 4) ? Baghira::Gradient : Baghira::Brushed); + // tqWarning("%d",effect_[i]); + if ( oldeffect != effect_[i][0] ) + changed |= SettingDecoration; + + int oldLineImpact = LineImpact_[i]; + LineImpact_[i] = config.readNumEntry( indexedString("LineImpact",i), i == 2 ? 0 : 40 ); + if ( oldLineImpact != LineImpact_[i] ) + changed |= SettingDecoration; + + oldcolor = colors_[i][ Baghira::ColorTitleBar ][ false ]; + colors_[i][ Baghira::ColorTitleBar ][ false ].setRgb((unsigned int)config.readNumEntry( indexedString("inactiveColor1",i), i == 0 ? TQColor(204,214,230).rgb() : i == 1 ? TQColor(246,242,246).rgb() : i == 3 ? TQColor(200,200,200).rgb() : TQColor(230,230,230).rgb())); + if ( oldcolor != colors_[i][ Baghira::ColorTitleBar ][ false ] ) + changed |= SettingColors; + + oldcolor = colors_[i][ Baghira::ColorTitleBlend ][ false ]; + colors_[i][ Baghira::ColorTitleBlend ][ false ].setRgb((unsigned int)config.readNumEntry( indexedString("inactiveColor2",i), i == 0 ? TQColor(194,196,211).rgb() : i == 1 ? TQColor(238,238,238).rgb() : i == 3 ? TQColor(150,150,150).rgb() : TQColor(250,250,250).rgb())); + if ( oldcolor != colors_[i][ Baghira::ColorTitleBlend ][ false ] ) + changed |= SettingColors; + } + else + { + effect_[3][1] = Baghira::Gradient; + effect_[3][0] = Baghira::FlatStipples; + LineImpact_[3] = 0; + } + + int old3DImpact = _3DImpact_[i]; + _3DImpact_[i] = config.readNumEntry( indexedString("3DImpact",i), 20 ); + if ( old3DImpact != _3DImpact_[i] ) + changed |= SettingDecoration; + + oldcolor = colors_[i][ Baghira::ColorTitleBar ][ true ]; + colors_[i][ Baghira::ColorTitleBar ][ true ].setRgb((unsigned int)config.readNumEntry( indexedString("activeColor1",i), i == 0 ? TQColor(255,255,255).rgb() : i == 1 ? TQColor(238,238,238).rgb() : i == 2 ? TQColor(202,202,202).rgb() : i == 3 ? TQColor(238,238,238).rgb() : TQColor(250,250,250).rgb())); + if ( oldcolor != colors_[i][ Baghira::ColorTitleBar ][ true ] ) + changed |= SettingColors; + + oldcolor = colors_[i][ Baghira::ColorTitleBlend ][ true ]; + colors_[i][ Baghira::ColorTitleBlend ][ true ].setRgb((unsigned int)config.readNumEntry( indexedString("activeColor2",i), i == 0 ? TQColor(238,234,238).rgb() : i == 1 ? TQColor(205,202,205).rgb() : i == 2 ? TQColor(150,150,150).rgb() : i == 3 ? TQColor(211,208,211).rgb() : TQColor(230,230,230).rgb())); + if ( oldcolor != colors_[i][ Baghira::ColorTitleBlend ][ true ] ) + changed |= SettingColors; + + } + + oldcolor = ButtonColor_[MinButton]; + ButtonColor_[MinButton].setRgb((unsigned int)config.readNumEntry( "MinButtonColor", TQColor(230,155,40).rgb() )); + if ( oldcolor != ButtonColor_[MinButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[MaxButton]; + ButtonColor_[MaxButton].setRgb((unsigned int)config.readNumEntry( "MaxButtonColor", TQColor(121,180,54).rgb() )); + if ( oldcolor != ButtonColor_[MaxButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[CloseButton]; + ButtonColor_[CloseButton].setRgb((unsigned int)config.readNumEntry( "CloseButtonColor", TQColor(200,85,70).rgb() )); + if ( oldcolor != ButtonColor_[CloseButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[StickyButton]; + ButtonColor_[StickyButton].setRgb((unsigned int)config.readNumEntry( "StickyButtonColor", TQColor(74,140,242).rgb() )); + if ( oldcolor != ButtonColor_[StickyButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[AboveBelowButton]; + ButtonColor_[AboveBelowButton].setRgb((unsigned int)config.readNumEntry( "AboveButtonColor", TQColor(74,140,242).rgb() )); + if ( oldcolor != ButtonColor_[AboveBelowButton] ) + changed |= SettingColors; + oldcolor = ButtonColor_[ShadeButton]; + ButtonColor_[ShadeButton].setRgb((unsigned int)config.readNumEntry( "ShadeButtonColor", TQColor(74,140,242).rgb() )); + if ( oldcolor != ButtonColor_[ShadeButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[MenuButton]; + ButtonColor_[MenuButton].setRgb((unsigned int)config.readNumEntry( "MenuButtonColor", TQColor(74,140,242).rgb() )); + if ( oldcolor != ButtonColor_[MenuButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[HelpButton]; + ButtonColor_[HelpButton].setRgb((unsigned int)config.readNumEntry( "HelpButtonColor", TQColor(0,0,0).rgb() )); + if ( oldcolor != ButtonColor_[HelpButton] ) + changed |= SettingColors; + + oldcolor = ButtonColor_[InactiveButton]; + ButtonColor_[InactiveButton].setRgb((unsigned int)config.readNumEntry( "InactiveButtonColor", TQColor(255,255,255).rgb() )); + if ( oldcolor != ButtonColor_[InactiveButton] ) + changed |= SettingColors; + + + config.endGroup(); + return changed; +} + +TQImage* BaghiraFactory::tintGlossy( const TQImage &src, const TQColor &c ) const +{ + TQImage *dest = new TQImage( src.width(), src.height(), 32); + dest->setAlphaBuffer( true ); + unsigned int *data = ( unsigned int * ) src.bits(); + unsigned int *destData = ( unsigned int* ) dest->bits(); + int total = src.width() * src.height(); + int u3rd = src.width()*4; + int red, green, blue; + int destR, destG, destB, alpha; + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + int hue, s, v; + c.getHsv( &hue, &s, &v ); + int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); + // float srcPercent, destPercent; + for ( int current = 0 ; current < total ; ++current ) { + alpha = tqAlpha( data[ current ] ); + if (alpha < 230){ + destData[ current ] = data[ current ]; + continue; //do not handle translucent parts to not affect blending + } + red = tqRed( data[ current ] ); + green = tqGreen( data[ current ] ); + blue = tqBlue( data[ current ] ); + if ( current > u3rd || red < 223 ){ + SATURATION_COLOR2(sq, red, green, blue, srcR, srcG, srcB) + } else { + SATURATION_COLOR2(sq, red, green, blue, 255, 255, 255); + } + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = tqRgba( destR, destG, destB, alpha ); + } + return ( dest ); +} + +TQImage* BaghiraFactory::tintBrush( const TQImage &img, const TQColor &c ) const +{ + +// if ( img.depth() != 32 ) +// img = img.convertDepth( 32 ); + TQImage *dest = new TQImage( img.width(), img.height(), 32); + unsigned int *data = ( unsigned int * ) img.bits(); + unsigned int *destData = ( unsigned int* ) dest->bits(); + int total = img.width() * img.height(); + int current; + int delta; + int red, green, blue, grey, iGrey; + int destR, destG, destB, alpha; + + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + + SATURATION_COLOR(180, 180, 180); + COLOR_SPACE(destR, destG, destB); + brushedMetalColor = TQColor(destR, destG, destB); + + // float srcPercent, destPercent; + for ( current = 0 ; current < total ; ++current ) { + alpha = tqAlpha( data[ current ] ); + blue = tqBlue( data[ current ] ); + red = tqRed( data[ current ] ); + green = tqGreen( data[ current ] ); + SATURATION_COLOR(red, green, blue); + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = tqRgba( destR, destG, destB, alpha ); + } + return ( dest ); +} + +void BaghiraFactory::createOS8Buttons(int style){ + TQPainter p; + TQColor initColor; + for ( int active = 0; active <= 1; ++active ){ + for (int t = 0; t < 3; t++){ + initColor = TQColor(color(style, Baghira::ColorTitleBar, active ).dark(100 + t*15)); + nostalgia_[style][t][active] = TQPixmap(BUTTONSIZE, BUTTONSIZE); + p.begin(&nostalgia_[style][t][active]); + p.setPen(color(style, Baghira::ColorTitleBar, active )); + p.drawPoint(0,BUTTONSIZE-1); + p.drawPoint(BUTTONSIZE-1,0); + p.setPen(initColor); + // dark color + // outer relief =============================== + p.drawLine(0,0,0,BUTTONSIZE-2); + p.drawLine(0,0,BUTTONSIZE-2,0); + // ============================================= + // inner relief ================================ + if (t < 2){ + p.drawLine(3,BUTTONSIZE-3,BUTTONSIZE-3,BUTTONSIZE-3); + p.drawLine(BUTTONSIZE-3,3,BUTTONSIZE-3,BUTTONSIZE-3); + } + else{ + p.drawLine(2,2,2,BUTTONSIZE-4); + p.drawLine(2,2,BUTTONSIZE-4,2); + } + // ======================================== + for (int i = 0; i < BUTTONSIZE - 6; i++){ + if (i == BUTTONSIZE - 7){ + p.drawPoint(2, BUTTONSIZE - 3); + p.drawPoint(BUTTONSIZE - 3, 2); + } + for (int j = 0; j < i+1; j++){ + p.setPen(initColor.light(100 + (i + j)*3)); + p.drawPoint(i+3,j+3); + if (i != j) p.drawPoint(j+3,i+3); + } + } + // Color is now Bright ;-) + // inner relief =============================== + if (t < 2){ + p.drawLine(2,2,2,BUTTONSIZE-4); + p.drawLine(2,2,BUTTONSIZE-4,2); + } + else{ + p.drawLine(3,BUTTONSIZE-3,BUTTONSIZE-3,BUTTONSIZE-3); + p.drawLine(BUTTONSIZE-3,3,BUTTONSIZE-3,BUTTONSIZE-3); + } + // ================================ + // outer relief ====================================== + p.drawLine(1,BUTTONSIZE-1,BUTTONSIZE-1,BUTTONSIZE-1); + p.drawLine(BUTTONSIZE-1,1,BUTTONSIZE-1,BUTTONSIZE-1); + //================================== + // black frame + p.setPen(TQt::black); + p.drawRect(1,1,BUTTONSIZE-2,BUTTONSIZE-2); + p.end(); + } + } +} + +TQPixmap &BaghiraFactory::ButtonPixmap( Baghira::WindowState wState, + Baghira::ButtonType type, Baghira::ButtonState state, int style, bool small ) { + return ButtonPixmap_[style][ wState ][ type ][ state ][small]; +} + +TQImage* BaghiraFactory::DecoImage( TQPixmap *pix, int x, int y, int width, int height ) { + TQPixmap tmpPix( width, height ); + bitBlt ( &tmpPix, 0, 0, pix, x, y, width, height ); + TQImage *returnImage = new TQImage( tmpPix.convertToImage() ); + return returnImage; +} + +/////////////////////////////////////////////////////////////////////////// +// createGradient() +// ---------------- +// Create a gradient + +void BaghiraFactory::createGradient(KPixmap &pix, const TQColor &light, const TQColor &dark, Baghira::TitlebarType effect) +{ + if (pix.width() == 0) return; + + TQPainter p; + switch( effect ){ + case Baghira::Stipples: + KPixmapEffect::unbalancedGradient(pix, light, light.dark(110), KPixmapEffect::VerticalGradient, 0); + p.begin(&pix); + p.setPen(dark); + for( int i = 0; i < pix.height(); i+=4 ){ + p.drawLine(0,i,pix.width(),i); + p.drawLine(0,i+1,pix.width(),i+1); + } + p.end(); + break; + case Baghira::FlatStipples: + { + p.begin(&pix); + p.fillRect(pix.rect(),light); + TQColor mid; + mid.setRgb((light.red()+2*dark.red())/3,(light.green()+2*dark.green())/3,(light.blue()+2*dark.blue())/3); + p.setPen(mid); + for( int i = pix.height() - 1; i > 0; i-=4 ) + { + p.drawLine(0,i,pix.width(),i); + p.drawLine(0,i-2,pix.width(),i-2); + } + p.setPen(dark); + for( int i = pix.height() - 2; i > 0; i-=4 ) + { + p.drawLine(0,i,pix.width(),i); + } + p.end(); + break; + } + case Baghira::Nostalgia: + p.begin(&pix); + p.fillRect(pix.rect(),light); + p.setPen(light.light(120)); + for (int i = (pix.height() - 1) / 4; i < (pix.height() - 1) / 4 * 3 + 1; i +=2) + p.drawLine(0,i,pix.width()-1,i); + p.setPen(light.dark(120)); + for (int i = (pix.height() - 1) / 4; i < (pix.height() - 1) / 4 * 3 + 1; i +=2) + p.drawLine(0,i+1,pix.width()-1,i+1); + p.end(); + break; + case Baghira::Gradient: + default: + KPixmapEffect::gradient(pix, light, dark, KPixmapEffect::VerticalGradient, 0); + break; + } +} + +static bool blend( const TQImage & upper, const TQImage & lower, TQImage & output) +// adopted from kimageeffect::blend - what is not endian safe... +{ + if + ( + upper.width() > lower.width() || + upper.height() > lower.height() || + upper.depth() != 32 || + lower.depth() != 32 + ) + return false; + + output = lower.copy(); + + uchar *i, *o; + int a; + int col; + int w = upper.width(); + int row(upper.height() - 1); + + do + { + i = upper.scanLine(row); + o = output.scanLine(row); + + col = w << 2; + + --col; + + do + { +#ifdef WORDS_BIGENDIAN + while (!(a = i[col-3]) && (col != 3)) +#else + while (!(a = i[col]) && (col != 3)) +#endif + { + --col; --col; --col; --col; + } +#ifndef WORDS_BIGENDIAN + --col; +#endif + o[col] += ((i[col] - o[col]) * a) >> 8; + + --col; + o[col] += ((i[col] - o[col]) * a) >> 8; + + --col; + o[col] += ((i[col] - o[col]) * a) >> 8; + +#ifdef WORDS_BIGENDIAN + --col; +#endif + + } while (col--); + } while (row--); + return true; +} + +////////////////////////////////////////////////////////////////////////////// +// createPixmaps() +// --------------- +// Create all our pixmaps +void BaghiraFactory::createPixmaps() { +// TQPainter painter; + TQColorGroup group; + TQPainter icyAPainter; + TQImage tmpResult; + TQImage tmpResult2; + TQImage tmpDeco; + TQImage buttonImage; + TQImage btnIcons[MenuButton]; + btnIcons[AboveBelowButton] = TQImage(); + // load icon images - useless for nostalgia style, but i assume they'll be used at least once ;) + btnIcons[MinButton] = uic_findImage( "icon_minimize" ); + btnIcons[MaxButton] = uic_findImage( "icon_maximize" ); + btnIcons[CloseButton] = uic_findImage( "icon_close" ); + btnIcons[StickyButton] = uic_findImage( "icon_sticky" ); +// btnIcons[AboveBelowButton] = uic_findImage( "icon_above" ); + btnIcons[ShadeButton] = uic_findImage( "icon_shade" ); + + int B_3 = 0; + int B_6 = 0; +// int bt, bs; + int xoff = 0; + int yoff = 1; + bool brushedMode; + + for (int style = 0; style < 5; style++){ + for ( int active = 0; active <= 1; ++active ) { + for ( int small = 0; small <= 1; ++small ) { + KPixmap &tbar = pix_[style][ TitleBar ][ active ][ small ]; + KPixmap &tcenter = pix_[style][ TitleCenter ][ active ][ small ]; + brushedMode = effect_[style][active] == Baghira::Brushed; + + // create gradients and fills + // if (effect_ == Baghira::Gradient || effect_ == Baghira::Stipples /*|| effect_ == Baghira::Glossy * / + if (effect_[style][active] < Baghira::Glossy || effect_[style][active] == Baghira::FlatStipples){ + // resize pixmap + tbar.resize( 100, small ? TITLESIZESMALL : TITLESIZE ); + createGradient( tbar, color(style, Baghira::ColorTitleBar, active ), color(style, Baghira::ColorTitleBlend, active ), effect_[style][active] ); + } + else if (brushedMode){ + TQPixmap brushTile; + TQPixmap brushGradient; + if (tintBrush_){ + brushTile = TQPixmap(*tintBrush(uic_findImage( "brushed-tile" ), brushTint)); + brushGradient = TQPixmap(*tintBrush(uic_findImage( "brushed-gradient" ), brushTint)); + } + else{ + brushTile = uic_findImage( "brushed-tile" ); + brushGradient = uic_findImage( "brushed-gradient" ); + brushedMetalColor = TQColor(180,180,180); + } + // resize pixmap + tbar.resize( 256, small ? TITLESIZESMALL : TITLESIZE ); + tcenter.resize( 1024, small ? TITLESIZESMALL : TITLESIZE ); + TQPainter painter(&tbar); + painter.drawTiledPixmap( 0,0, tbar.width(), tbar.height(), brushTile ); + painter.end(); + painter.begin(&tcenter); + painter.drawTiledPixmap( 0,0, tcenter.width(), tcenter.height(), brushGradient ); + } + else{ + tbar.resize( 32, small ? TITLESIZESMALL : TITLESIZE); + KPixmap tmp = TQPixmap(*tintGlossy(uic_findImage( "deco_glossy" ), color(style, Baghira::ColorTitleBar, active ))); + if (tbar.height() > 18){ + for (int i = 8; i < tbar.height() - 10; i++){ + bitBlt(&tbar, 0, i, &tmp, 0, 8, 32, 1); + } + } + bitBlt(&tbar, 0, tbar.height() - 11, &tmp, 0, 9, 32, 10); + bitBlt(&tbar, 0, 0, &tmp, 0, 0, 32, 8); + } + + switch ( buttonStyle_[style] ) { + + // Load Jaguar Buttons ========================================================================= + + case Jaguar: + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); + + // unpressed buttons + buttonImage = uic_findImage( "button_jaguar"); + + for (int bt = MinButton; bt < MenuButton; bt++){ + for (int bs = ButtonInactive; bs < Pressed; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? + ButtonColor_[InactiveButton] : + ButtonColor_[bt] ); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + if (bs > ButtonActive) blend( btnIcons[bt], tmpResult, tmpResult ); + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); + } + } + + // pressed buttons // as jaguar buttons shift + buttonImage = uic_findImage( "button_jaguar_down"); + + for (int bt = MinButton; bt < MenuButton; bt++){ + tmpResult2 = *tintGlossy( buttonImage, ButtonColor_[bt].dark(120)); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + KImageEffect::blendOnLower( xoff, yoff, btnIcons[bt], tmpResult); // must shift as well + ButtonPixmap_[style][ active ][ bt ][ Pressed ][small] = TQPixmap( tmpResult ); + } + + + // HelpButton + buttonImage = uic_findImage( "icon_help"); + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? + ButtonColor_[InactiveButton] : + bs == Hovered ? + ButtonColor_[HelpButton].light(120) : + bs == Pressed ? + ButtonColor_[HelpButton].dark(120) : + ButtonColor_[HelpButton] ); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); + } + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); + + // MenuButton + buttonImage = uic_findImage( "button_jaguar_menu"); + for (int bs = ButtonInactive; bs < Pressed; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs < Hovered ? + ButtonColor_[InactiveButton] : + ButtonColor_[MenuButton] ); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); + } + + + + // pressed MenuButton // as jaguar buttons shift + buttonImage = uic_findImage( "button_jaguar_menu_down"); + tmpResult2 = *tintGlossy( buttonImage, ButtonColor_[MenuButton].dark(120)); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ MenuButton ][ Pressed ][small] = TQPixmap( tmpResult ); + + + break; + + // Load Milk Buttons ========================================================================= + + case Milk: + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); + + // unpressed buttons + buttonImage = uic_findImage( "button_milk"); + + + for (int bt = MinButton; bt < MenuButton; bt++){ + for (int bs = ButtonInactive; bs < Pressed; bs++){ + /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); + if (bs > ButtonActive) blend( btnIcons[bt], tmpResult, tmpResult ); + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); + } + } + + // pressed buttons // as pressed milk buttons differ + buttonImage = uic_findImage( "button_milk_down"); + for (int bt = MinButton; bt < MenuButton; bt++){ + /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); + blend( btnIcons[bt], tmpResult, tmpResult ); + ButtonPixmap_[style][ active ][ bt ][ Pressed ][small] = TQPixmap( tmpResult ); + } + + // HelpButton + buttonImage = uic_findImage( "icon_help"); + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); + } + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); + + // MenuButton + buttonImage = uic_findImage( "button_milk_menu"); + for (int bs = ButtonInactive; bs < Pressed; bs++){ + /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); + } + + // pressed MenuButton // as pressed milk buttons differ + buttonImage = uic_findImage( "button_milk_menu_down"); + /*brushedMode ? blend( buttonImage, tmpDeco, tmpResult ) : */blend( buttonImage, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ MenuButton ][ Pressed ][small] = TQPixmap( tmpResult ); + + break; + + // Create Nostalgia Buttons ========================================================================= + + case NostalgiaButton: + createOS8Buttons(style); + B_3 = (int)((BUTTONSIZE -1 )/ 3); + B_6 = B_3*2; + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); + + for (int bt = MinButton; bt < ButtonTypeAmount; bt++){ + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + if (bs < Hovered) + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][1][active] ); + else if (bs == Hovered) + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][0][active] ); + else + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( nostalgia_[style][2][active] ); + if (bs > ButtonInactive){ + icyAPainter.begin(&ButtonPixmap_[style][ active ][ bt ][ bs ][small]); + icyAPainter.setPen(TQt::black); + if (bt == MinButton){ + icyAPainter.drawLine(2,B_3,BUTTONSIZE - 3,B_3); + icyAPainter.drawLine(2,B_6,BUTTONSIZE - 3,B_6); + icyAPainter.end(); + continue; + } + if (bt == MaxButton){ + icyAPainter.drawLine(2,B_6,B_6,B_6); + icyAPainter.drawLine(B_6,2,B_6,B_6); + icyAPainter.end(); + continue; + } + if (bt == StickyButton){ + icyAPainter.fillRect(BUTTONSIZE/2-1,BUTTONSIZE/2-1,2,2,TQt::black); + icyAPainter.end(); + continue; + } + if (bt == ShadeButton){ + icyAPainter.drawLine(2,B_3,BUTTONSIZE-3,B_3); + icyAPainter.drawLine(2,B_3+3,BUTTONSIZE-3,B_3+3); + icyAPainter.drawLine(2,B_3+6,BUTTONSIZE-3,B_3+6); + icyAPainter.end(); + continue; + } + if (bt == HelpButton){ + TQFont tmpFont = TQFont(options() ->font( true, false )); + tmpFont.setPixelSize(BUTTONSIZE - 4); + icyAPainter.setFont(tmpFont); + icyAPainter.drawText( 0, 0, BUTTONSIZE, BUTTONSIZE, TQt::AlignHCenter | TQt::AlignVCenter, "?" ); + icyAPainter.end(); + continue; + } + if (bt == MenuButton){ + icyAPainter.drawLine(2,B_3,BUTTONSIZE-3,B_3); + icyAPainter.end(); + + } + icyAPainter.end(); + } + if (bt == MenuButton){ + buttonImage = ButtonPixmap_[style][ active ][ bt ][ bs ][small].convertToImage(); + blend( buttonImage , tmpDeco, tmpDeco ); + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap(tmpDeco); + } + } + } + break; + + // Load Panther Buttons ========================================================================= + + case Panther: + default: + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, BUTTONSIZE, BUTTONSIZE ); + + // unpressed buttons + buttonImage = uic_findImage( "button_panther"); + + for (int bt = MinButton; bt < MenuButton; bt++){ + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? + ButtonColor_[InactiveButton] : + bs == Pressed ? + ButtonColor_[bt].dark(120) : + ButtonColor_[bt] ); + if (bs > ButtonActive) blend( btnIcons[bt], tmpResult2, tmpResult2 ); + if (bt == MaxButton && bs > ButtonInactive) deMaximizer_.setPixmap(bs - 1, tmpResult2); + blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ bt ][ bs ][small] = TQPixmap( tmpResult ); + } + } + + + // HelpButton + buttonImage = uic_findImage( "icon_help"); + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs == ButtonInactive ? + ButtonColor_[InactiveButton] : + bs == Hovered ? + ButtonColor_[HelpButton].light(120) : + bs == Pressed ? + ButtonColor_[HelpButton].dark(120) : + ButtonColor_[HelpButton] ); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ HelpButton ][ bs ][small] = TQPixmap( tmpResult ); + } + + tmpDeco = *DecoImage( &tbar, 0, ( tbar.height() - BUTTONSIZE ) / 2, MENUBUTTONWIDTH, BUTTONSIZE ); + + // MenuButton + buttonImage = uic_findImage( "button_panther_menu"); + for (int bs = ButtonInactive; bs < ButtonStateAmount; bs++){ + tmpResult2 = *tintGlossy( buttonImage, bs < Hovered ? + ButtonColor_[InactiveButton] : + bs == Pressed ? + ButtonColor_[MenuButton].dark(120) : + ButtonColor_[MenuButton] ); + /*brushedMode ? blend( tmpResult2, tmpDeco, tmpResult ) : */blend( tmpResult2, tmpDeco, tmpResult ); + ButtonPixmap_[style][ active ][ MenuButton ][ bs ][small] = TQPixmap( tmpResult ); + } + } + } + } + } +} + +////////////////////////////////////////////////////////////////////////////// +// borderSizes() +// ------------- +// Return list of valid border sizes + +TQValueList BaghiraFactory::borderSizes() const { + return TQValueList() << BorderTiny << BorderNormal + << BorderLarge << BorderVeryLarge + << BorderHuge << BorderVeryHuge; +} + +////////////////////////////////////////////////////////////////////////////// +// BaghiraButton Class // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// BaghiraButton() +// -------------- +// Constructor + +BaghiraButton::BaghiraButton( BaghiraClient *parent, const char *name, const TQString& tip, bool small, ButtonType type, int style ) +: TQButton( parent->widget(), name ), client_( parent ), type_( type ), deco_( 0 ), icon_(), small_( small ), lastmouse_( 0 ), mouseover_( false ), _blocked(false) { + setBackgroundMode( NoBackground ); + setCursor( arrowCursor ); + TQToolTip::add( this, tip ); + down_ = false; + mouseover_ = false; + mask = NULL; + maskDown = NULL; + + setFixedSize( type == Baghira::MenuButton ? MENUBUTTONWIDTH : BUTTONSIZE, BUTTONSIZE ); + for ( int bs = Baghira::ButtonInactive; bs <= Baghira::Pressed; bs++ ) { + pixmap[ Baghira::WindowInactive ][ ( Baghira::ButtonState ) bs ] = + &BaghiraFactory::ButtonPixmap( Baghira::WindowInactive, type, + ( Baghira::ButtonState ) bs, style, small ); + pixmap[ Baghira::WindowActive ][ ( Baghira::ButtonState ) bs ] = + &BaghiraFactory::ButtonPixmap( Baghira::WindowActive, type, + ( Baghira::ButtonState ) bs, style, small ); + } +} + +BaghiraButton::~BaghiraButton() +{ + if ( deco_ ) + delete deco_; +} + + +////////////////////////////////////////////////////////////////////////////// +// sizeHint() +// ---------- +// Return size hint + +TQSize BaghiraButton::sizeHint() const { + return TQSize( BUTTONSIZE, BUTTONSIZE ); +} + +////////////////////////////////////////////////////////////////////////////// +// enterEvent() +// ------------ +// Mouse has entered the button + +void BaghiraButton::enterEvent( TQEvent *e ) { +#if 0 + if (type_ == CloseButton) + { + _blocked = true; + TQTimer::singleShot(250,this,SLOT(delayedEnterEvent())); + TQButton::enterEvent( e ); + return; + } +#endif + mouseover_ = true; + repaint( false ); + TQButton::enterEvent( e ); +} + +void BaghiraButton::delayedEnterEvent() +{ + if (hasMouse()) + { + _blocked = false; + mouseover_ = true; + repaint( false ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// leaveEvent() +// ------------ +// Mouse has left the button + +void BaghiraButton::leaveEvent( TQEvent *e ) +{ + mouseover_ = false; + if ( type_ == Baghira::MenuButton ) + down_ = false; + repaint( false ); + TQButton::leaveEvent( e ); +} + +////////////////////////////////////////////////////////////////////////////// +// mousePressEvent() +// ----------------- +// Button has been pressed + +void BaghiraButton::mousePressEvent( TQMouseEvent* e ) +{ + if (_blocked && !(e->state() & TQt::ControlButton)) + return; + lastmouse_ = e->button(); + + //update mask + if (maskDown) + { + clearMask(); + setMask(*maskDown); + } + // translate and pass on mouse event + int button = LeftButton; + if ( ( type_ != MaxButton ) && ( e->button() != LeftButton ) ) + { + button = NoButton; // middle & right buttons inappropriate + } + down_ = true; + TQMouseEvent me( e->type(), e->pos(), e->globalPos(), button, e->state() ); + repaint( false ); + TQButton::mousePressEvent( &me ); +} + +// void BaghiraButton::setOn(bool on) +// { +// TQButton::setOn(on); +// } + +////////////////////////////////////////////////////////////////////////////// +// mouseReleaseEvent() +// ----------------- +// Button has been released + +void BaghiraButton::mouseReleaseEvent( TQMouseEvent* e ) { + lastmouse_ = e->button(); + + if (mask){ + clearMask(); + setMask(*mask); + } + // translate and pass on mouse event + int button = LeftButton; + if ( ( type_ != MaxButton ) && ( e->button() != LeftButton ) ) { + button = NoButton; // middle & right buttons inappropriate + } + down_ = false; + TQMouseEvent me( e->type(), e->pos(), e->globalPos(), button, e->state() ); + repaint( false ); + TQButton::mouseReleaseEvent( &me ); +} + +inline ButtonState BaghiraButton::state() { + if ( down_ || isDown() ) + return Pressed; + else if ( mouseover_ ) + return Hovered; + else if ( client_->isActive() ) + return ButtonActive; + else + return ButtonInactive; +} + +////////////////////////////////////////////////////////////////////////////// +// drawButton() +// ------------ +// Draw the button + +void BaghiraButton::drawButton( TQPainter *painter ) { + if ( !BaghiraFactory::initialized() ) + return ; + + bool active = client_->isActive(); + + if ( type_ == Baghira::StickyButton && client_->isOnAllDesktops() ) + painter->drawPixmap( 0, 0, BaghiraFactory::ButtonPixmap( ( Baghira::WindowState ) active, type_, state() == Pressed ? Pressed : Hovered, client_->currentStyle, client_->isTool() )); + else + painter->drawPixmap( 0, 0, BaghiraFactory::ButtonPixmap( ( Baghira::WindowState ) active, type_, state() , client_->currentStyle, client_->isTool() )); + + if (type_ == Baghira::AboveBelowButton) + { + if (client_->keepAbove()) + { + painter->drawPixmap((width()-8)/2,height()/2-4,BaghiraFactory::arrowUp); + } + else if (client_->keepBelow()) + { + painter->drawPixmap((width()-8)/2,height()/2,BaghiraFactory::arrowDown); + } + } +} + +void BaghiraButton::setMasks(TQBitmap *bitmask, TQBitmap *bitmaskDown){ + clearMask(); + mask = bitmask; + maskDown = bitmaskDown; + if (mask) setMask(*mask); +} +////////////////////////////////////////////////////////////////////////////// +// BaghiraClient Class // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// BaghiraClient() +// ------------- +// Constructor + +BaghiraClient::BaghiraClient( KDecorationBridge *b, KDecorationFactory *f ) + : KDecoration( b, f ) +{ + ; +} + +BaghiraClient::~BaghiraClient() +{ + if (noDeco_) + return; + BaghiraFactory::deMaximizer().setClient(NULL); + for ( int n = 0; n < ButtonTypeAmount; n++ ) + { + if ( button[ n ] ) + delete button[ n ]; + } +} + +////////////////////////////////////////////////////////////////////////////// +// init() +// ------ +// Real initialization + +void BaghiraClient::init() +{ + if (BaghiraFactory::noModalDeco() && isModal() && !isMinimizable() && !isResizable()) + { + noDeco_ = true; + createMainWidget( WResizeNoErase | WRepaintNoErase ); + widget() ->setBackgroundMode( NoBackground ); + return; + } + noDeco_ = false; +#if KDE_IS_VERSION(3,3,91) + //first try if there's an X setting + unsigned char *data = 0; + Atom actual; + int format, result; + unsigned long n, left; + currentStyle = BaghiraFactory::defaultMode(); + result = XGetWindowProperty(tqt_xdisplay(), windowId(), baghira_deco_design, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, &data); + if (result == Success && data != None) // found set design + { + memcpy (¤tStyle, data, sizeof (unsigned int)); + currentStyle = currentStyle>4?4:currentStyle; + } + else // try if there's a definition file + { + XClassHint classHint; + FILE *file = NULL; + if ( XGetClassHint( tqt_xdisplay(), windowId(), &classHint ) ) + { + TQString tmpString; + // overwrite file from bab starter? - don't worry, if there's been one and deleted by the style we've got the X setting (much better as it will take care of all subwindows) + tmpString = TQDir::homeDirPath() + "/.baghira/.bab/" + TQString( classHint.res_class ).lower(); + if( (file = fopen(tmpString.latin1(), "r")) != NULL ) + { + fscanf(file,"%d\n%d\n", &format, ¤tStyle); + fclose(file); + remove(tmpString.latin1()); // this is only temporary + } + else + { + tmpString = TQDir::homeDirPath() + "/.baghira/" + TQString( classHint.res_class ).lower(); + if( (file = fopen(tmpString.latin1(), "r")) != NULL ) + { + fscanf(file,"%d\n%d\n", &format, ¤tStyle); + fclose(file); + } + } + XFree( classHint.res_name ); + XFree( classHint.res_class ); + } + if (file == NULL) + { + TQString tmpString = TQDir::homeDirPath() + "/.baghira/.bab/.deco"; + if( (file = fopen(tmpString.latin1(), "r")) != NULL ) + { + fscanf(file,"%d\n%d\n", &format, ¤tStyle); + fclose(file); + } + } + } + if (currentStyle > 4) + currentStyle = BaghiraFactory::defaultMode(); +#else + TQSettings config; + config.beginGroup("/baghira/Style"); + if (config.readBoolEntry( "Design_Default", 1 ) == 2) + { + currentStyle = 2; + config.endGroup(); + } + else + { + config.endGroup(); + config.beginGroup("/baghira/Deco"); + int tmp = config.readNumEntry( "defaultMode", 1 ); + currentStyle = (tmp > -1 && tmp < 5) ? tmp : 1; + config.endGroup(); + } +#endif + createMainWidget( WResizeNoErase | WRepaintNoErase ); + widget() ->installEventFilter( this ); + widget() ->setBackgroundMode( NoBackground ); + + if ( isTool() ) // tool windows have tiny titlebars + titleheight_ = TITLESIZESMALL; + else + titleheight_ = TITLESIZE; + + // setup layout + TQVBoxLayout *mainlayout = new TQVBoxLayout( widget() ); + TQHBoxLayout *titlelayout = new TQHBoxLayout(); + windowlayout = new TQHBoxLayout(); + + titlebar_ = new TQSpacerItem( 1, titleheight_, TQSizePolicy::Expanding, TQSizePolicy::Fixed ); + mainlayout->setResizeMode( TQLayout::FreeResize ); + mainlayout->addLayout( titlelayout ); + mainlayout->addLayout( windowlayout ); + + windowlayout->addSpacing( BaghiraFactory::borderSize(currentStyle) ); + if ( isPreview() ) + windowlayout->addWidget( new TQLabel( i18n( "
Baghira preview
" ), widget() ) ); + else + windowlayout->addItem( new TQSpacerItem( 0, 18 ) ); + + windowlayout->addSpacing( BaghiraFactory::borderSize(currentStyle) ); + + leftClose = false; + rightClose = false; + performEasyClose = false; + + // setup titlebar + for ( int n = 0; n < ButtonTypeAmount; n++ ) + button[ n ] = 0; + plusminus = 1; + addButtons( titlelayout, options() ->titleButtonsLeft() ); + titlelayout->addItem( titlebar_ ); + plusminus = -1; + isFaded = false; + addButtons( titlelayout, options() ->titleButtonsRight() ); +#if KDE_IS_VERSION(3,3,91) + grip = 0; +#endif + + if (BaghiraFactory::effect(currentStyle, true) >= Baghira::Brushed || BaghiraFactory::effect(currentStyle, false) >= Baghira::Brushed) + HandlePix = TQPixmap(BaghiraFactory::pix(currentStyle, TitleBar, isActive(), false )); + else if ( BaghiraFactory::bgStipple() ) + { + HandlePix = TQPixmap( 32, 32); + TQPainter painter; + TQColor c = widget()->colorGroup().background(); + HandlePix.fill(c); + painter.begin( &HandlePix ); + painter.setPen( c.dark( 100 + (BaghiraFactory::contrast()/2) ) ); + + for ( int i = 1; i < 32; i += 4 ) + { + painter.drawLine( 0, i, 31, i ); + painter.drawLine( 0, i+2, 31, i+2 ); + } + + painter.setPen( c.dark( 100 + BaghiraFactory::contrast() ) ); + + for ( int i = 2; i < 31; i += 4 ) + painter.drawLine( 0, i, 31, i ); + + painter.end(); + } +} + +TQString BaghiraClient::caption() const +{ + if (!BaghiraFactory::delAppname()) + return KDecoration::caption(); + if (caption_.isNull()) + // generate first + { + const_cast( this )->caption_ = KDecoration::caption(); + int pos; + if (caption_.startsWith( "tvtime" )) + { + pos = caption_.find(": "); + if (pos > -1) + const_cast( this )->caption_ = const_cast( this )->caption_.remove(0, pos+1); + } + else + { + pos = caption_.findRev(" - "); + if (pos > -1) + const_cast( this )->caption_ = caption_.left(pos); + } + } + return caption_; +} + +////////////////////////////////////////////////////////////////////////////// +// addButtons() +// ------------ +// Add buttons to title layout + +void BaghiraClient::addButtons( TQBoxLayout *layout, const TQString& s ) +{ + if (noDeco_) + return; + // const unsigned char *bitmap; + TQString tip; + TQBitmap *m = NULL; + TQBitmap *mn = NULL; + TQBitmap *mD = NULL; + TQBitmap *mnD = NULL; + TQBitmap *mH = NULL; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed){ + m = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + &BaghiraFactory::pantherMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMask : + NULL; + mn = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + &BaghiraFactory::pantherMenuMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMenuMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMenuMask : + NULL; + mD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + NULL : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarDownMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkDownMask : + NULL; + mnD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + NULL : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMenuDownMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMenuDownMask : + NULL; + mH = &BaghiraFactory::helpMask; + } + if ( s.length() > 0 ) { +// tqWarning("%s",s.ascii()); + layout->addSpacing( MARGIN ); + excursion = excursion + plusminus * MARGIN; + bool buttonAdded; + for ( unsigned n = 0; n < s.length(); n++ ) { + buttonAdded = false; + switch ( s[ n ].latin1() ) { + case 'M': // Menu button + if ( !button[ MenuButton ] ) { + button[ MenuButton ] = new BaghiraButton( this, "menu", + i18n( "Menu" ), isTool(), MenuButton ); + connect( button[ MenuButton ], SIGNAL( pressed() ), this, + SLOT( menuButtonPressed() ) ); + layout->addWidget( button[ MenuButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * MENUBUTTONWIDTH; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MenuButton ]->setMasks(mn, mnD); + } + break; + + case 'S': // Sticky button + if ( !button[ StickyButton ] ) { + if ( isOnAllDesktops() ) { + tip = i18n( "Un-Sticky" ); + } else { + tip = i18n( "Sticky" ); + } + button[ StickyButton ] = new BaghiraButton( this, "sticky", + tip, isTool(), StickyButton ); + connect( button[ StickyButton ], SIGNAL( clicked() ), this, + SLOT( toggleOnAllDesktops() ) ); + layout->addWidget( button[ StickyButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ StickyButton ]->setMasks(m, mD); + } + break; + + case 'H': // Help button + if ( ( !button[ HelpButton ] ) && providesContextHelp() ) { + button[ HelpButton ] = new BaghiraButton( this, "help", + i18n( "Help" ), isTool(), HelpButton ); + connect( button[ HelpButton ], SIGNAL( clicked() ), this, + SLOT( showContextHelp() ) ); + layout->addWidget( button[ HelpButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ HelpButton ]->setMasks(mH, NULL); + } + break; + + case 'I': // Minimize button + if ( ( !button[ MinButton ] ) && isMinimizable() ) { + button[ MinButton ] = new BaghiraButton( this, "iconify", + i18n( "Minimize" ), isTool(), MinButton ); + connect( button[ MinButton ], SIGNAL( clicked() ), this, + SLOT( minimize() ) ); + layout->addWidget( button[ MinButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MinButton ]->setMasks(m, mD); + } + break; + + case 'A': // Maximize button + if ( ( !button[ MaxButton ] ) && isMaximizable() ) { + if ( maximizeMode() == MaximizeFull ) { + tip = i18n( "Restore" ); + } else { + tip = i18n( "Maximize" ); + } + button[ MaxButton ] = new BaghiraButton( this, "maximize", + tip, isTool(), MaxButton ); + connect( button[ MaxButton ], SIGNAL( clicked() ), this, + SLOT( maxButtonPressed() ) ); + layout->addWidget( button[ MaxButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ MaxButton ]->setMasks(m, mD); + } + break; + + case 'X': // Close button + if ( ( !button[ CloseButton ] ) && isCloseable() ) { + button[ CloseButton ] = new BaghiraButton( this, "close", + i18n( "Close" ), isTool(), CloseButton ); + connect( button[ CloseButton ], SIGNAL( clicked() ), this, + SLOT( closeWindow() ) ); + layout->addWidget( button[ CloseButton ] ); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (plusminus == 1 && n == 0) // left Button + leftClose = true; + if (plusminus == -1 && n == s.length() - 1) // right Button + rightClose = true; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ CloseButton ]->setMasks(m, mD); + } + break; + + case 'F': // Above button + case 'B': // Below button + if ((!button[AboveBelowButton])) + { + button[AboveBelowButton] = new BaghiraButton(this, "above", i18n("Keep Above/Below Others"), isTool(), AboveBelowButton); + button[AboveBelowButton]->setDown( keepAbove() || keepBelow() ); + connect(button[AboveBelowButton], SIGNAL(clicked()), this, SLOT(aboveBelowButtonPressed())); + layout->addWidget(button[AboveBelowButton]); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ AboveBelowButton ]->setMasks(m, mD); + } + break; + case 'L': // Shade button + if ((!button[ShadeButton] && isShadeable())) { + button[ShadeButton] = new BaghiraButton(this, "shade", isSetShade() ? tip = i18n("Unshade") : tip = i18n("Shade"), isTool(), ShadeButton); + button[ShadeButton]->setDown( isShade() ); + connect(button[ShadeButton], SIGNAL(clicked()), this, SLOT(shadeButtonPressed())); + layout->addWidget(button[ShadeButton]); + buttonAdded = true; + excursion = excursion + plusminus * BUTTONSIZE; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ ShadeButton ]->setMasks(m, mD); + } + break; +// case 'R': // Shade button +// if ((!button[ShadeButton] && isShadeable())) { +// button[ShadeButton] = new BaghiraButton(this, "shade", isSetShade() ? tip = i18n("Unshade") : tip = i18n("Shade"), isTool(), ShadeButton); +// button[ShadeButton]->setDown( isShade() ); +// connect(button[ShadeButton], SIGNAL(clicked()), this, SLOT(shadeButtonPressed())); +// layout->addWidget(button[ShadeButton]); +// buttonAdded = true; +// excursion = excursion + plusminus * BUTTONSIZE; +// if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed) button[ ShadeButton ]->setMasks(m, mD); +// } +// break; + + case '_': // Spacer item + layout->addSpacing( MARGIN ); + excursion = excursion + plusminus * MARGIN; + } + if (BaghiraFactory::addAutoSpacing() && buttonAdded){ + layout->addSpacing( MARGIN ); + excursion = excursion + plusminus * MARGIN; + } + } + } +} + +////////////////////////////////////////////////////////////////////////////// +// eventFilter() +// ------------- +// Event filter + +bool BaghiraClient::eventFilter( TQObject *obj, TQEvent *e ) +{ + if ( obj != widget() ) + return false; + + switch ( e->type() ) { + case TQEvent::MouseButtonDblClick: { + mouseDoubleClickEvent( static_cast( e ) ); + return true; + } + case TQEvent::MouseButtonPress: { + if (titlebar_->geometry().contains( static_cast(e)->pos() ) && static_cast(e)->state() == TQt::ControlButton){ + currentStyle < 4 ? currentStyle++ : currentStyle = 0; +#if KDE_IS_VERSION(3,3,91) + unsigned long wmDesign = currentStyle; + XChangeProperty(tqt_xdisplay(), windowId(), baghira_deco_design, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &wmDesign, 1L); +#endif + widget()->repaint(); + TQBitmap *m = NULL; + TQBitmap *mn = NULL; + TQBitmap *mD = NULL; + TQBitmap *mnD = NULL; + TQBitmap *mH = NULL; + if (BaghiraFactory::effect(currentStyle, true) == Baghira::Brushed){ + m = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + &BaghiraFactory::pantherMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMask : + NULL; + mn = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + &BaghiraFactory::pantherMenuMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMenuMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMenuMask : + NULL; + mD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + NULL : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarDownMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkDownMask : + NULL; + mnD = BaghiraFactory::buttonStyle(currentStyle) == Baghira::Panther ? + NULL : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Jaguar ? + &BaghiraFactory::jaguarMenuDownMask : + BaghiraFactory::buttonStyle(currentStyle) == Baghira::Milk ? + &BaghiraFactory::milkMenuDownMask : + NULL; + mH = &BaghiraFactory::helpMask; + } + for (int i = 0; i < ButtonTypeAmount; i++){ + if (button[i]){ + button[i]->setMasks(i < Baghira::MenuButton ? m : + i == Baghira::MenuButton ? mn : + mH, i < Baghira::MenuButton ? mD : + i == Baghira::MenuButton ? mnD : + NULL); + button[i]->repaint(); + } + } +#if KDE_IS_VERSION(3,3,91) + if (grip) + grip->updateLook(TRUE); +#endif + doShape(); + return true; + } + if (BaghiraFactory::allowEasyClosing()){ + if (maximizeMode() == MaximizeFull && isActive() && (leftClose && static_cast( e )->x() == 0 && static_cast( e )->y() == 0) || (rightClose && static_cast( e )->x() == ((TQWidget *)obj)->width() -1 && static_cast( e )->y() == 0)) + performEasyClose = true; + else processMousePressEvent( static_cast( e ) ); + } + else processMousePressEvent( static_cast( e ) ); + return true; + } + case TQEvent::MouseButtonRelease:{ + if (performEasyClose && maximizeMode() == MaximizeFull && (leftClose && static_cast( e )->x() == 0 && static_cast( e )->y() == 0) || (rightClose && static_cast( e )->x() == ((TQWidget *)obj)->width() -1 && static_cast( e )->y() == 0)){ + closeWindow(); + performEasyClose = false; + return true; + } + return FALSE; + } + case TQEvent::Paint: { + paintEvent( static_cast( e ) ); + return true; + } + case TQEvent::Resize: { + resizeEvent( static_cast( e ) ); + return true; + } + case TQEvent::Show: { +#if KDE_IS_VERSION(3,3,91) + if (!grip && BaghiraFactory::resizeGrip() && isResizable()) grip = new ResizeHandle(this); +#endif + showEvent( static_cast( e ) ); + return true; + } + case TQEvent::Hide: { + emit hide(); + } + case TQEvent::Wheel: { + wheelEvent(static_cast( e )); + return true; + } + default: { + return false; + } + } + + return false; +} + +////////////////////////////////////////////////////////////////////////////// +// mouseCoubleClickEvent() +// ----------------------- +// Doubleclick on title + +void BaghiraClient::mouseDoubleClickEvent( TQMouseEvent *e ) +{ + if ( titlebar_->geometry().contains( e->pos() ) ) + titlebarDblClickOperation(); +} + +void BaghiraClient::wheelEvent( TQWheelEvent *e ) +{ + if (titlebar_->geometry().contains( e->pos() ) && e->state() == TQt::ControlButton){ + // surf through the desktops :) + int target, cD; + if (e->delta() > 0){ + (cD = KWin::currentDesktop()) == KWin::numberOfDesktops() ? target = 1 : target = cD + 1; + } + else{ + (cD = KWin::currentDesktop()) == 1 ? target = KWin::numberOfDesktops() : target = cD - 1; + } + setDesktop (target); + KWin::setCurrentDesktop (target); + } +} + +////////////////////////////////////////////////////////////////////////////// +// paintEvent() +// ------------ +// Repaint the window + +void BaghiraClient::paintEvent( TQPaintEvent* ) +{ + if ( !BaghiraFactory::initialized() || noDeco_) + return ; + + TQPainter painter( widget() ); + TQColorGroup group; + + TQRect title( 0, 0, width(), titlebar_->geometry().height() ); + TQRect left( 0, title.height(), BaghiraFactory::borderSize(currentStyle), height() - + title.height() ); + TQRect right( width() - BaghiraFactory::borderSize(currentStyle), title.height(), + BaghiraFactory::borderSize(currentStyle), height() - title.height() ); + TQRect handle( 0, height() - BaghiraFactory::borderSize(currentStyle), + width(), BaghiraFactory::borderSize(currentStyle) ); + + int x, y, x2, y2, h, w; + + title.rect( &x, &y, &w, &h ); + + // draw title bar + if (BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Brushed) + { + if (w > 1024) + { + int w1 = (w - 1024)/2; + int w2 = w - 1024 - w1; + painter.drawTiledPixmap( 0,0, w1, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ),256-w1,0 ); + painter.drawPixmap( w1, 0/*, 1024, h*/, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ) ); + painter.drawTiledPixmap( w1 + 1024, 0, w2, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); + } + else + painter.drawTiledPixmap( 0, 0, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-w)/2, 0 ); + } + else + painter.drawTiledPixmap( title, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); + + x2 = title.right(); + y2 = title.bottom(); + int shapeW = w; + + const TQColor *ttbar = &(BaghiraFactory::color(currentStyle, Baghira::ColorTitleBar, isActive())); + + int tmp3Dimpact_ = 100 + BaghiraFactory::_3DImpact(currentStyle); + + painter.setPen( ttbar->light(tmp3Dimpact_)); + painter.drawLine( x+1, y+1, x2-1, y+1 ); + + if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) + { + // draw around the corners ;-) + if (BaghiraFactory::shapeUL(currentStyle)) + { + // Draw edge of top-left corner inside the area removed by the mask. + painter.drawPoint( 3, 2 ); + painter.drawPoint( 4, 2 ); + painter.drawPoint( 2, 3 ); + painter.drawPoint( 2, 4 ); + } + if (BaghiraFactory::shapeUR(currentStyle)) + { + // Draw edge of top-right corner inside the area removed by the mask. + painter.drawPoint( shapeW - 5, 2 ); + painter.drawPoint( shapeW - 4, 2 ); + painter.drawPoint( shapeW - 3, 3 ); + painter.drawPoint( shapeW - 3, 4 ); + } + } + + + painter.setPen( ttbar->dark(tmp3Dimpact_) ); + if (BaghiraFactory::drawComicFrame() && !(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) + { + painter.drawLine(x,y,x, y2); + painter.drawLine(x2,y,x2, y2); + } + painter.drawLine( x, y, x2, y ); + + if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)) + { + // draw around the corners ;-) + if (BaghiraFactory::shapeUL(currentStyle)) + { + // Draw edge of top-left corner inside the area removed by the mask. + painter.drawPoint( 3, 1 ); + painter.drawPoint( 4, 1 ); + painter.drawPoint( 2, 2 ); + painter.drawPoint( 1, 3 ); + painter.drawPoint( 1, 4 ); + } + if (BaghiraFactory::shapeUR(currentStyle)) + { + // Draw edge of top-right corner inside the area removed by the mask. + painter.drawPoint( shapeW - 5, 1 ); + painter.drawPoint( shapeW - 4, 1 ); + painter.drawPoint( shapeW - 3, 2 ); + painter.drawPoint( shapeW - 2, 3 ); + painter.drawPoint( shapeW - 2, 4 ); + } + } + + const TQColor *ttblend = &(BaghiraFactory::color(currentStyle, Baghira::ColorTitleBlend, isActive())); + + if (BaghiraFactory::LineImpact(currentStyle) > 0) + { + painter.setPen( ttblend->dark(100 + BaghiraFactory::LineImpact(currentStyle)) ); + painter.drawLine( x, y2, x2, y2 ); + } + + // draw title text + titlebar_->geometry().rect( &x, &y, &w, &h ); + int iconLeft; + int iconWidth; + if (BaghiraFactory::showTitle()) + { + painter.setFont( options() ->font( isActive(), isTool() ) ); + painter.setPen( options()->color( ColorFont, isActive() ) ); + BaghiraFactory::drawIcon(currentStyle) ? iconWidth = 16 : iconWidth = 0; + if (BaghiraFactory::drawIcon(currentStyle) || BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Nostalgia) + { + TQRect textBound = painter.boundingRect ( x + 2 * MARGIN + iconWidth, y, w - MARGIN * 2 - iconWidth, h, BaghiraFactory::titleAlign() | AlignVCenter, caption() ); + iconLeft = textBound.x() - MARGIN - iconWidth; + if ( iconLeft < x + MARGIN ) iconLeft = x + MARGIN; + + if (BaghiraFactory::drawIcon(currentStyle)) + { + ICONX = iconLeft; + ICONY = y + ( titleheight_ - 16 ) / 2; + painter.drawPixmap( ICONX, ICONY, icon().pixmap( TQIconSet::Small, TQIconSet::Normal ) ); + } + + if (BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Nostalgia) + { + painter.fillRect( iconLeft - 5, y + 1, textBound.right() - iconLeft + 10, h - 2, BaghiraFactory::color(currentStyle, Baghira::ColorTitleBar, isActive() ) ); + painter.fillRect( title.x(), y + 1, x - title.x()+5, h - 2, *ttbar ); + painter.fillRect( x+w-5, y + 1, title.right() - w + 5, h - 2, *ttbar ); + } + } + painter.drawText( x + 2 * MARGIN + iconWidth, y, w - MARGIN * 2 - iconWidth, h, BaghiraFactory::titleAlign() | AlignVCenter, caption() ); + } + else if (BaghiraFactory::drawIcon(currentStyle)) + { + iconLeft = (width()-16)/2; + if ( iconLeft < x + MARGIN ) + iconLeft = x + MARGIN; + ICONX = iconLeft; + ICONY = y + ( titleheight_ - 16 ) / 2; + painter.drawPixmap( ICONX, ICONY, icon().pixmap( TQIconSet::Small, TQIconSet::Normal ) ); + } + + // draw outer frame + if ( !isShade() ) + { + TQColor background = widget() ->colorGroup().background(); + + // left side + left.rect( &x, &y, &w, &h ); + if (w > 0){ + if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed) + { + width() > 1024 ? + painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ) : + painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-width())/2 ); + } + else + { + BaghiraFactory::bgStipple() ? + painter.drawTiledPixmap( x, y, w, h, HandlePix ) : + painter.fillRect( x, y, w, h, background ); + } + } + + // right side + right.rect( &x, &y, &w, &h ); + if (w > 0){ + if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed) + { + width() > 1024 ? + painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ) : + painter.drawTiledPixmap( x, y, w, h, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-width())/2+width()-w ); + } + else + { + BaghiraFactory::bgStipple() ? + painter.drawTiledPixmap( x, y, w, h, HandlePix ) : + painter.fillRect( x, y, w, h, background ); + } + } + + // draw handle ===================================================== + // bottom bar + // handle middle + handle.rect( &x, &y, &w, &h ); + if (BaghiraFactory::effect(currentStyle,isActive()) == Baghira::Brushed){ + if (w > 1024){ + int w1 = (w - 1024)/2; + int w2 = w - 1024 - w1; + painter.drawTiledPixmap( 0, y, w1, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); + painter.drawPixmap( w1, y, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ) ); + painter.drawTiledPixmap( w1 + 1024, y, w2, h, BaghiraFactory::pix(currentStyle, TitleBar, isActive(), isTool() ) ); + } + else{ + painter.drawPixmap( x, y, BaghiraFactory::pix(currentStyle, TitleCenter, isActive(), isTool() ), (1024-w)/2, 0, w, h ); + } + + int b = handle.bottom() - 1; +// painter.setPen( ttbar->light(tmp3Dimpact_)); + painter.setPen( ttbar->dark(tmp3Dimpact_*1.1) ); + painter.drawLine( x, b, w-1, b ); + if (maximizeMode() != MaximizeFull) + { + if (BaghiraFactory::shapeLL(currentStyle)){ + // Draw edge of bottom-left corner inside the area removed by the mask. + painter.drawPoint(3, b); + painter.drawPoint(4, b); + painter.drawPoint(2, b-1); + painter.drawPoint(1, b-2); + painter.drawPoint(1, b-3); + painter.drawPoint(0, b-4); + } + if (BaghiraFactory::shapeLR(currentStyle)){ + // Draw edge of bottom-right corner inside the area removed by the mask. + painter.drawPoint(shapeW - 5, b); + painter.drawPoint(shapeW - 4, b); + painter.drawPoint(shapeW - 3, b-1); + painter.drawPoint(shapeW - 2, b-2); + painter.drawPoint(shapeW - 2, b-3); + painter.drawPoint(shapeW - 1, b-4); + } + } + painter.setPen( ttbar->dark(tmp3Dimpact_*1.3) ); + painter.drawLine( x+1, b+1, w-2, b+1 ); + if (maximizeMode() != MaximizeFull) + { + if (BaghiraFactory::shapeLL(currentStyle)){ + // Draw edge of bottom-left corner inside the area removed by the mask. + painter.drawPoint(4, b); + painter.drawPoint(5, b); + painter.drawPoint(3, b-1); + painter.drawPoint(2, b-2); +// painter.drawPoint(2, b-3); + } + if (BaghiraFactory::shapeLR(currentStyle)){ + // Draw edge of bottom-right corner inside the area removed by the mask. + painter.drawPoint(shapeW - 6, b); + painter.drawPoint(shapeW - 5, b); + painter.drawPoint(shapeW - 4, b-1); + painter.drawPoint(shapeW - 3, b-2); +// painter.drawPoint(shapeW - 3, b-3); + } + } + if (BaghiraFactory::drawComicFrame()) + { + painter.drawLine(x,title.y(),x, b); + painter.drawLine(handle.right(),title.y(),x2, b); + } + } + else{ + BaghiraFactory::bgStipple() ? painter.drawTiledPixmap( x, y, w, h, HandlePix ) : + painter.fillRect( x, y, w, h, background ); + + x2 = handle.right(); + y2 = handle.bottom(); + if (BaghiraFactory::drawComicFrame() && maximizeMode() != MaximizeFull){ + painter.setPen(ttblend->dark(tmp3Dimpact_)); + painter.drawLine( handle.x()/*+7*/, y2, x2/*-7*/, y2 ); + painter.drawLine(0,title.bottom(),0, y2); + painter.drawLine(x2,title.bottom(),x2, y2); + } + } + if (BaghiraFactory::drawComicFrame() && maximizeMode() != MaximizeFull){ + int b = handle.bottom() - 1; + if (BaghiraFactory::shapeLL(currentStyle)){ + // Draw edge of bottom-left corner inside the area removed by the mask. + painter.drawPoint(3, b); + painter.drawPoint(4, b); + painter.drawPoint(2, b-1); + painter.drawPoint(1, b-2); + painter.drawPoint(1, b-3); + } + if (BaghiraFactory::shapeLR(currentStyle)){ + // Draw edge of bottom-right corner inside the area removed by the mask. + painter.drawPoint(shapeW - 5, b); + painter.drawPoint(shapeW - 4, b); + painter.drawPoint(shapeW - 3, b-1); + painter.drawPoint(shapeW - 2, b-2); + painter.drawPoint(shapeW - 2, b-3); + } + } + } +} + +////////////////////////////////////////////////////////////////////////////// +// resizeEvent() +// ------------- +// Window is being resized + +void BaghiraClient::resizeEvent( TQResizeEvent* ) +{ + if (noDeco_) + return; + /*if ( widget() ->isShown() ) { + TQRegion region = widget() ->rect(); + region = region.subtract( titlebar_->geometry() ); + widget() ->erase( region ); + }*/ +// widget()->repaint(); + doShape(); +} + +///////////////////////////////////////////////////////////////////////////// +// shape Corners +// =) ==================================================================0 + +void BaghiraClient::doShape() +{ +// return; + TQRegion mask; + + if (!(BaghiraFactory::allowEasyClosing() && maximizeMode() == MaximizeFull)){ + int r = width(); + int b = height() - 1; + mask = TQRegion( 0, 0, r, b+1 ); + + if (BaghiraFactory::shapeUL(currentStyle)){ + // Remove top-left corner. + mask -= TQRegion( 0, 0, 5, 1 ); + mask -= TQRegion( 0, 1, 3, 1 ); + mask -= TQRegion( 0, 2, 2, 1 ); + mask -= TQRegion( 0, 3, 1, 2 ); + } + if (BaghiraFactory::shapeUR(currentStyle)){ + // Remove top-right corner. + mask -= TQRegion( r - 5, 0, 5, 1 ); + mask -= TQRegion( r - 3, 1, 3, 1 ); + mask -= TQRegion( r - 2, 2, 2, 1 ); + mask -= TQRegion( r - 1, 3, 1, 2 ); + } + + if (BaghiraFactory::shapeLL(currentStyle)){ + // Remove bottom-left corner. + mask -= TQRegion(0, b-0, 5, 1); + mask -= TQRegion(0, b-1, 3, 1); + mask -= TQRegion(0, b-2, 2, 1); + mask -= TQRegion(0, b-4, 1, 2); + } + if (BaghiraFactory::shapeLR(currentStyle)){ + // Remove bottom-right corner. + mask -= TQRegion(r - 5, b-0, 5, 1); + mask -= TQRegion(r - 3, b-1, 3, 1); + mask -= TQRegion(r - 2, b-2, 2, 1); + mask -= TQRegion(r - 1, b-4, 1, 2); + } + } + setMask( mask, 1 ); +} + + +////////////////////////////////////////////////////////////////////////////// +// showEvent() +// ----------- +// Window is being shown + +void BaghiraClient::showEvent( TQShowEvent* ) +{ + if (noDeco_) + return; + doShape(); + widget() ->repaint(); +} + +////////////////////////////////////////////////////////////////////////////// +// activeChange() +// -------------- +// window active state has changed + +void BaghiraClient::activeChange() +{ + if (noDeco_) + return; + if (BaghiraFactory::fullSpec() && maximizeMode() == MaximizeFull) + { + if (isActive()) + { + BaghiraFactory::deMaximizer().show(); + BaghiraFactory::deMaximizer().setClient(this); + } + } + else + { + BaghiraFactory::deMaximizer().hide(); + for ( int n = 0; n < ButtonTypeAmount; n++ ) + { + if ( button[ n ] ) + { + button[n]->setAutoMask( BaghiraFactory::effect(currentStyle, isActive()) == Baghira::Brushed); + button[ n ] ->reset(); + } + } + widget() ->repaint( false ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// captionChange() +// --------------- +// The title has changed + +void BaghiraClient::captionChange() +{ + if (noDeco_) + return; + if (BaghiraFactory::showTitle()) + { + if (BaghiraFactory::delAppname()) + { + caption_ = KDecoration::caption(); + int pos; + if (caption_.startsWith( "tvtime" )) + { + pos = caption_.find(": "); + if (pos > -1) + caption_ = caption_.remove(0, pos+1); + } + else + { + pos = caption_.findRev(" - "); + if (pos > -1) + caption_ = caption_.left(pos); + } + } + widget() ->repaint( titlebar_->geometry(), false ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// desktopChange() +// --------------- +// Sticky state has changed + +void BaghiraClient::desktopChange() +{ + if (noDeco_) + return; + bool d = isOnAllDesktops(); + if ( button[ StickyButton ] ) + { + TQToolTip::remove + ( button[ StickyButton ] ); + TQToolTip::add + ( button[ StickyButton ], d ? i18n( "Un-Sticky" ) : i18n( "Sticky" ) ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// iconChange() +// ------------ +// The title has changed + +void BaghiraClient::iconChange() +{ + if (noDeco_) + return; + if (BaghiraFactory::drawIcon(currentStyle)) widget()->repaint(ICONX, ICONY, 16, 16, false); +} + +////////////////////////////////////////////////////////////////////////////// +// maximizeChange() +// ---------------- +// Maximized state has changed + +void BaghiraClient::maximizeChange() +{ + if (noDeco_) //shouldn't happen - windo's not maximizable + return; + bool m = ( maximizeMode() == MaximizeFull ); + if (BaghiraFactory::fullSpec() && m){ + if (isActive()){ + BaghiraFactory::deMaximizer().show(); + BaghiraFactory::deMaximizer().setClient(this); + } + } + else { + BaghiraFactory::deMaximizer().setClient(NULL); + BaghiraFactory::deMaximizer().hide(); + } + if ( button[ MaxButton ] ) { + TQToolTip::remove + ( button[ MaxButton ] ); + TQToolTip::add + ( button[ MaxButton ], m ? i18n( "Restore" ) : i18n( "Maximize" ) ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// shadeChange() +// ------------- +// Called when window shading changes + +void BaghiraClient::shadeChange() { + ; +} + +////////////////////////////////////////////////////////////////////////////// +// borders() +// ---------- +// Get the size of the borders + +void BaghiraClient::borders( int &l, int &r, int &t, int &b ) const +{ + if (noDeco_) + { + l = r = t = b = 0; + return; + } + bool m = ( maximizeMode() == MaximizeFull); + t = (BaghiraFactory::fullSpec() && m) ? 0 : titleheight_; + if (m || maximizeMode() == MaximizeHorizontal) + l = r = BaghiraFactory::maxResizable() ? 1 : 0; + else + l = r = BaghiraFactory::borderSize(currentStyle); + if ( m || isShade() || (maximizeMode() == MaximizeVertical)) + b = BaghiraFactory::maxResizable() ? 1 : 0; + else + b = BaghiraFactory::borderSize(currentStyle); +} + +////////////////////////////////////////////////////////////////////////////// +// resize() +// -------- +// Called to resize the window + +void BaghiraClient::resize( const TQSize &size ) +{ + if (noDeco_) + return; + widget() ->resize( size ); +} + +////////////////////////////////////////////////////////////////////////////// +// minimumSize() +// ------------- +// Return the minimum allowable size for this decoration + +TQSize BaghiraClient::minimumSize() const +{ + return TQSize( 100, 60 ); +} + +////////////////////////////////////////////////////////////////////////////// +// mousePosition() +// --------------- +// Return mouse position (for resizing) + +KDecoration::Position BaghiraClient::mousePosition( const TQPoint &point ) const +{ + if (noDeco_) + return PositionCenter; + Position pos = PositionCenter; + if ( point.y() < ( height() - BaghiraFactory::borderSize(currentStyle) ) ) { // inside client + pos = KDecoration::mousePosition( point ); + } else { + if ( point.x() >= ( width() - 16 ) ) + pos = PositionBottomRight; + else if ( point.x() <= 16 ) + pos = PositionBottomLeft; + else + pos = PositionBottom; + } + return pos; +} + + +////////////////////////////////////////////////////////////////////////////// +// maxButtonPressed() +// ----------------- +// Max button was pressed + + +void BaghiraClient::demaxButtonPressed() { + maxButtonPressed(); +} + +void BaghiraClient::maxButtonPressed() { + if ( !BaghiraFactory::fullSpec() || (maximizeMode() != MaximizeFull) && button[ MaxButton ]) { + switch ( button[ MaxButton ] ->lastMousePress() ) { + case MidButton: + maximize( maximizeMode() ^ MaximizeVertical ); + break; + case RightButton: + maximize( maximizeMode() ^ MaximizeHorizontal ); + break; + default: + if ( maximizeMode() == MaximizeFull ) { + maximize( MaximizeRestore ); + } + else { + maximize( MaximizeFull ); + } + } + } + else{ + maximize( MaximizeRestore ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// menuButtonPressed() +// ------------------- +// Menu button was pressed + +void BaghiraClient::menuButtonPressed() { + if ( button[ MenuButton ] ) { + TQPoint pt( button[ MenuButton ] ->rect().bottomLeft().x(), + button[ MenuButton ] ->rect().bottomLeft().y() + 4 ); + KDecorationFactory* f = factory(); + showWindowMenu( button[ MenuButton ] ->mapToGlobal( pt ) ); + if ( !f->exists( this ) ) + return ; // we have been destroyed + button[ MenuButton ] ->setDown( false ); + } +} + +////////////////////////////////////////////////////////////////////////////// +// new stuff + +void BaghiraClient::aboveBelowButtonPressed() +{ + if (keepAbove()) + { + button[ AboveBelowButton ] ->setDown(true); + setKeepAbove(false ); + setKeepBelow(true ); + button[ AboveBelowButton ] ->repaint( false ); + } + else if (keepBelow()) + { + button[ AboveBelowButton ] ->setDown(false); + setKeepBelow(false ); + setKeepAbove(false ); + button[ AboveBelowButton ] ->repaint( false ); + } + else + { + button[ AboveBelowButton ] ->setDown(true); + setKeepBelow(false ); + setKeepAbove(true ); + button[ AboveBelowButton ] ->repaint( false ); + } +} + +void BaghiraClient::shadeButtonPressed(){ + button[ ShadeButton ]->setDown(!isShade()); + setShade( !isShade() ); +} + +////////////////////////////////////////////////////////////////////////////// +// isTool() +// -------- +// Is this a tool window? + +bool BaghiraClient::isTool() const { + static const unsigned long winmask = NET::DesktopMask | NET::DialogMask | + NET::DockMask | NET::MenuMask | + NET::NormalMask | NET::OverrideMask | + NET::SplashMask | NET::ToolbarMask | + NET::TopMenuMask | NET::UtilityMask; + + NET::WindowType type = windowType( winmask ); + return ( type == NET::Menu || type == NET::Toolbar || type == NET::Utility ); +} + +#include "baghiraclient.moc" diff --git a/deco/config/CMakeLists.txt b/deco/config/CMakeLists.txt index 5a4a344..dbd3adb 100644 --- a/deco/config/CMakeLists.txt +++ b/deco/config/CMakeLists.txt @@ -32,7 +32,7 @@ add_custom_command( ##### twin_baghira_config (kpart) set_source_files_properties( - baghiraconfig.cc + baghiraconfig.cpp PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_header} ) @@ -40,9 +40,9 @@ tde_add_kpart( twin_baghira_config AUTOMOC SOURCES configdialog.ui - baghiraconfig.cc - aquariusbutton.cc - colorpicker.cc + baghiraconfig.cpp + aquariusbutton.cpp + colorpicker.cpp LINK tdecore-shared tdeui-shared diff --git a/deco/config/Makefile.am b/deco/config/Makefile.am index d741389..534e239 100644 --- a/deco/config/Makefile.am +++ b/deco/config/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = $(all_includes) -I$(srcdir)/../../config noinst_HEADERS = baghiraconfig.h aquariusbutton.h colorpicker.h pixmaps.h kde_module_LTLIBRARIES = twin_baghira_config.la -twin_baghira_config_la_SOURCES = baghiraconfig.cc aquariusbutton.cc colorpicker.cc configdialog.ui +twin_baghira_config_la_SOURCES = baghiraconfig.cpp aquariusbutton.cpp colorpicker.cpp configdialog.ui twin_baghira_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module twin_baghira_config_la_LIBADD = $(LIB_TQT) $(LIB_TDECORE) $(LIB_TDEUI) twin_baghira_config_la_METASOURCES = AUTO diff --git a/deco/config/aquariusbutton.cc b/deco/config/aquariusbutton.cc deleted file mode 100644 index 9cf1b0e..0000000 --- a/deco/config/aquariusbutton.cc +++ /dev/null @@ -1,166 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "aquariusbutton.h" -#include -#include -#include -#include - -#define COLOR_SPACE(R,G,B) \ - if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \ - if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \ - if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255; - -#define SATURATION_COLOR(R,G,B) \ - grey = (299 * R + 587 * G + 114 * B) / 1000; \ - delta = 255 - grey; \ - grey = (grey *(10 - 5)) / 10; \ - iGrey = 255 - grey;\ - destR = (iGrey * (srcR - delta) + grey * R) / 255; \ - destG = (iGrey * (srcG - delta) + grey * G) / 255; \ - destB = (iGrey * (srcB - delta) + grey * B) / 255; - -#define CLAMP(x,l,u) x < l ? l :\ - x > u ? u :\ - x - -#define SATURATION_COLOR2(S,R,G,B) \ - int max = 255+0.65*(100-S); \ - destR = CLAMP((srcR + R - 128), 0, max); \ - destG = CLAMP((srcG + G - 128), 0, max); \ - destB = CLAMP((srcB + B - 128), 0, max); \ - destR = (S*destR + (100-S)*R)/100; \ - destG = (S*destG + (100-S)*G)/100; \ - destB = (S*destB + (100-S)*B)/100; - -static bool blend( const TQImage & upper, const TQImage & lower, TQImage & output) -// adopted from kimageeffect::blend - what is not endian safe... -{ - if - ( - upper.width() > lower.width() || - upper.height() > lower.height() || - upper.depth() != 32 || - lower.depth() != 32 - ) - return false; - - output = lower.copy(); - - uchar *i, *o; - int a; - int col; - int w = upper.width(); - int row(upper.height() - 1); - - do - { - i = upper.scanLine(row); - o = output.scanLine(row); - - col = w << 2; - - --col; - - do - { -#ifdef WORDS_BIGENDIAN - while (!(a = i[col-3]) && (col != 3)) -#else - while (!(a = i[col]) && (col != 3)) -#endif - { - --col; --col; --col; --col; - } -#ifndef WORDS_BIGENDIAN - --col; -#endif - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - - --col; - o[col] += ((i[col] - o[col]) * a) >> 8; - -#ifdef WORDS_BIGENDIAN - --col; -#endif - - } while (col--); - } while (row--); - return true; -} - -AquariusButton::AquariusButton( TQPixmap &pixmap, TQWidget* parent, const char* name) : TQWidget( parent, name){ - pixmap = pixmap; - image = pixmap.convertToImage(); - setFixedSize( pixmap.size() ); -} - -AquariusButton::~AquariusButton(){ -} - -TQColor AquariusButton::Color(){ - return color; -} - -void AquariusButton::setColor(TQColor c){ - color = c; - tint(color); - repaint(false); -} - -void AquariusButton::tint(TQColor &c){ - TQImage dest( image.width(), image.height(), 32, 0 ); - dest.setAlphaBuffer( true ); - unsigned int *data = ( unsigned int * ) image.bits(); - unsigned int *destData = ( unsigned int* ) dest.bits(); - int total = image.width() * image.height(); - int red, green, blue; - int destR, destG, destB, alpha; - int srcR = c.red(); - int srcG = c.green(); - int srcB = c.blue(); - int hue, s, v; - c.getHsv( &hue, &s, &v ); - int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); - // float srcPercent, destPercent; - for ( int current = 0 ; current < total ; ++current ) { - alpha = tqAlpha( data[ current ] ); - if (alpha < 230){ - destData[ current ] = data[ current ]; - continue; //do not handle translucent parts to not affect blending - } - red = tqRed( data[ current ] ); - green = tqGreen( data[ current ] ); - blue = tqBlue( data[ current ] ); - SATURATION_COLOR2(sq, red, green, blue); - // force back to valid colorspace ! - COLOR_SPACE(destR, destG, destB); - destData[ current ] = tqRgba( destR, destG, destB, alpha ); - } - TQPixmap backPix = TQPixmap(dest.size()); - TQPainter tmpPainter(&backPix); - tmpPainter.fillRect(0, 0, dest.width(),dest.height(), backgroundBrush()); - tmpPainter.end(); - TQImage back = backPix.convertToImage(); - blend(dest,back,back); - pixmap = TQPixmap(back); -} - -void AquariusButton::mousePressEvent( TQMouseEvent *e ){ - emit clicked(); -} - -void AquariusButton::paintEvent( TQPaintEvent *e){ - TQPainter tmpPainter(this); - tmpPainter.drawPixmap(0,0, pixmap); -} - -// void AquariusButton::clicked(){ -// } - -#include "aquariusbutton.moc" diff --git a/deco/config/aquariusbutton.cpp b/deco/config/aquariusbutton.cpp new file mode 100644 index 0000000..9cf1b0e --- /dev/null +++ b/deco/config/aquariusbutton.cpp @@ -0,0 +1,166 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "aquariusbutton.h" +#include +#include +#include +#include + +#define COLOR_SPACE(R,G,B) \ + if ( R < 0 ) R = 0; else if ( R > 255 ) R = 255; \ + if ( G < 0 ) G = 0; else if ( G > 255 ) G = 255; \ + if ( B < 0 ) B = 0; else if ( B > 255 ) B = 255; + +#define SATURATION_COLOR(R,G,B) \ + grey = (299 * R + 587 * G + 114 * B) / 1000; \ + delta = 255 - grey; \ + grey = (grey *(10 - 5)) / 10; \ + iGrey = 255 - grey;\ + destR = (iGrey * (srcR - delta) + grey * R) / 255; \ + destG = (iGrey * (srcG - delta) + grey * G) / 255; \ + destB = (iGrey * (srcB - delta) + grey * B) / 255; + +#define CLAMP(x,l,u) x < l ? l :\ + x > u ? u :\ + x + +#define SATURATION_COLOR2(S,R,G,B) \ + int max = 255+0.65*(100-S); \ + destR = CLAMP((srcR + R - 128), 0, max); \ + destG = CLAMP((srcG + G - 128), 0, max); \ + destB = CLAMP((srcB + B - 128), 0, max); \ + destR = (S*destR + (100-S)*R)/100; \ + destG = (S*destG + (100-S)*G)/100; \ + destB = (S*destB + (100-S)*B)/100; + +static bool blend( const TQImage & upper, const TQImage & lower, TQImage & output) +// adopted from kimageeffect::blend - what is not endian safe... +{ + if + ( + upper.width() > lower.width() || + upper.height() > lower.height() || + upper.depth() != 32 || + lower.depth() != 32 + ) + return false; + + output = lower.copy(); + + uchar *i, *o; + int a; + int col; + int w = upper.width(); + int row(upper.height() - 1); + + do + { + i = upper.scanLine(row); + o = output.scanLine(row); + + col = w << 2; + + --col; + + do + { +#ifdef WORDS_BIGENDIAN + while (!(a = i[col-3]) && (col != 3)) +#else + while (!(a = i[col]) && (col != 3)) +#endif + { + --col; --col; --col; --col; + } +#ifndef WORDS_BIGENDIAN + --col; +#endif + o[col] += ((i[col] - o[col]) * a) >> 8; + + --col; + o[col] += ((i[col] - o[col]) * a) >> 8; + + --col; + o[col] += ((i[col] - o[col]) * a) >> 8; + +#ifdef WORDS_BIGENDIAN + --col; +#endif + + } while (col--); + } while (row--); + return true; +} + +AquariusButton::AquariusButton( TQPixmap &pixmap, TQWidget* parent, const char* name) : TQWidget( parent, name){ + pixmap = pixmap; + image = pixmap.convertToImage(); + setFixedSize( pixmap.size() ); +} + +AquariusButton::~AquariusButton(){ +} + +TQColor AquariusButton::Color(){ + return color; +} + +void AquariusButton::setColor(TQColor c){ + color = c; + tint(color); + repaint(false); +} + +void AquariusButton::tint(TQColor &c){ + TQImage dest( image.width(), image.height(), 32, 0 ); + dest.setAlphaBuffer( true ); + unsigned int *data = ( unsigned int * ) image.bits(); + unsigned int *destData = ( unsigned int* ) dest.bits(); + int total = image.width() * image.height(); + int red, green, blue; + int destR, destG, destB, alpha; + int srcR = c.red(); + int srcG = c.green(); + int srcB = c.blue(); + int hue, s, v; + c.getHsv( &hue, &s, &v ); + int sq = CLAMP((int)((45.0/128.0)*s+55),0,100); + // float srcPercent, destPercent; + for ( int current = 0 ; current < total ; ++current ) { + alpha = tqAlpha( data[ current ] ); + if (alpha < 230){ + destData[ current ] = data[ current ]; + continue; //do not handle translucent parts to not affect blending + } + red = tqRed( data[ current ] ); + green = tqGreen( data[ current ] ); + blue = tqBlue( data[ current ] ); + SATURATION_COLOR2(sq, red, green, blue); + // force back to valid colorspace ! + COLOR_SPACE(destR, destG, destB); + destData[ current ] = tqRgba( destR, destG, destB, alpha ); + } + TQPixmap backPix = TQPixmap(dest.size()); + TQPainter tmpPainter(&backPix); + tmpPainter.fillRect(0, 0, dest.width(),dest.height(), backgroundBrush()); + tmpPainter.end(); + TQImage back = backPix.convertToImage(); + blend(dest,back,back); + pixmap = TQPixmap(back); +} + +void AquariusButton::mousePressEvent( TQMouseEvent *e ){ + emit clicked(); +} + +void AquariusButton::paintEvent( TQPaintEvent *e){ + TQPainter tmpPainter(this); + tmpPainter.drawPixmap(0,0, pixmap); +} + +// void AquariusButton::clicked(){ +// } + +#include "aquariusbutton.moc" diff --git a/deco/config/baghiraconfig.cc b/deco/config/baghiraconfig.cc deleted file mode 100644 index 7c5996c..0000000 --- a/deco/config/baghiraconfig.cc +++ /dev/null @@ -1,729 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// baghiraconfig.cc -// ------------------- -// Config module for Baghira window decoration -// ------------------- -// Copyright (c) 2004 Thomas Lübking -// Please see the header file for copyright and license information. -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "baghiraconfig.h" -#include "configdialog.h" -#include "pixmaps.h" - -////////////////////////////////////////////////////////////////////////////// -// BaghiraConfig Class // -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -// BaghiraConfig() -// ------------- -// Constructor - -BaghiraConfig::BaghiraConfig(TDEConfig*, TQWidget* parent) - : TQObject(parent), /*config_(0),*/ dialog_(0) -{ -// config_ = new TDEConfig("baghirarc"); -// config_ = new TQSettings; -// config_->beginGroup("/baghira/Deco"); - TDEGlobal::locale()->insertCatalogue("twin_baghira_config"); - - dialog_ = new ConfigDialog(parent); - buttonDialog_ = new ButtonColors(parent, "Button Colors"); - load(0L); - - dialog_->show(); - - connect(dialog_->ButtonColorConfig, SIGNAL(clicked()), buttonDialog_, SLOT(exec())); - connect(buttonDialog_->ok, SIGNAL(clicked()), SIGNAL(changed())); - - // connections - connect(dialog_->titlealign, SIGNAL(clicked(int)), SIGNAL(changed())); - connect(dialog_->drawComicFrame, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->addAutoSpacing, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->allowEasyClosing, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->ResizeGrip, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->maxResizable, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->fullSpec, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->noModalDeco, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->delAppname, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->defaultMode, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->minTH, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_T, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_T, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_T, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->_3DImpact_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); -// config_->endGroup(); - -} - -////////////////////////////////////////////////////////////////////////////// -// ~BaghiraConfig() -// -------------- -// Destructor - -BaghiraConfig::~BaghiraConfig() -{ - if (dialog_) delete dialog_; -// if (config_) delete config_; -} - -////////////////////////////////////////////////////////////////////////////// -// load() -// ------ -// Load configuration data - -void BaghiraConfig::load(TDEConfig*) -{ - TQSettings *config_ = new TQSettings; - config_->beginGroup("/baghira/Deco"); - - TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign-> - child((const char *)value.latin1()); - if (button) button->setChecked(true); - - dialog_->minTH->setValue(config_->readNumEntry("minimumTitleHeight",18)); - dialog_->ResizeGrip->setChecked(config_->readBoolEntry("ResizeGrip",false)); - dialog_->allowEasyClosing->setChecked(config_->readBoolEntry("allowEasyClosing",false)); - dialog_->drawComicFrame->setChecked(config_->readBoolEntry("DrawComicFrame",false)); - dialog_->maxResizable->setChecked(config_->readBoolEntry("MaxResizable",false)); - dialog_->fullSpec->setChecked(config_->readBoolEntry("FullSpec",false)); - dialog_->addAutoSpacing->setChecked(config_->readBoolEntry("AddAutoSpacing",true)); - dialog_->defaultMode->setCurrentItem(config_->readNumEntry("defaultMode",1)); - dialog_->noModalDeco->setChecked(config_->readBoolEntry("NoModalDeco",false)); - dialog_->delAppname->setChecked(config_->readBoolEntry("RemoveAppname",false)); - - dialog_->activeColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_1",TQColor(255,255,255).rgb()))); - dialog_->inactiveColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_1",TQColor(204,214,230).rgb()))); - dialog_->activeColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_1",TQColor(238,234,238).rgb()))); - dialog_->inactiveColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_1",TQColor(194,196,211).rgb()))); - dialog_->buttonStyle_J->setCurrentItem(config_->readNumEntry("ButtonStyle_1",1)); - dialog_->titleeffect_J->setCurrentItem(config_->readNumEntry("TitleEffect_1", 1)); - dialog_->i_titleeffect_J->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_1", 1)); - dialog_->shapeUL_J->setChecked(config_->readBoolEntry("ShapeUL_1",true)); - dialog_->shapeUR_J->setChecked(config_->readBoolEntry("ShapeUR_1",true)); - dialog_->shapeLL_J->setChecked(config_->readBoolEntry("ShapeLL_1",false)); - dialog_->shapeLR_J->setChecked(config_->readBoolEntry("ShapeLR_1",false)); - dialog_->drawIcon_J->setChecked(config_->readBoolEntry("drawIcon_1",true)); - dialog_->_3DImpact_J->setValue(config_->readNumEntry("3DImpact_1",20)); - dialog_->LineImpact_J->setValue(config_->readNumEntry("LineImpact_1",40)); - dialog_->borderSize_J->setValue(config_->readNumEntry("BorderSize_1",0)); - - dialog_->activeColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_2",TQColor(238,238,238).rgb()))); - dialog_->inactiveColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_2",TQColor(246,242,246).rgb()))); - dialog_->activeColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_2",TQColor(205,202,205).rgb()))); - dialog_->inactiveColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_2",TQColor(238,238,238).rgb()))); - dialog_->buttonStyle_P->setCurrentItem(config_->readNumEntry("ButtonStyle_2",0)); - dialog_->titleeffect_P->setCurrentItem(config_->readNumEntry("TitleEffect_2", 0)); - dialog_->i_titleeffect_P->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_2", 0)); - dialog_->shapeUL_P->setChecked(config_->readBoolEntry("ShapeUL_2",true)); - dialog_->shapeUR_P->setChecked(config_->readBoolEntry("ShapeUR_2",true)); - dialog_->shapeLL_P->setChecked(config_->readBoolEntry("ShapeLL_2",false)); - dialog_->shapeLR_P->setChecked(config_->readBoolEntry("ShapeLR_2",false)); - dialog_->drawIcon_P->setChecked(config_->readBoolEntry("drawIcon_2",true)); - dialog_->_3DImpact_P->setValue(config_->readNumEntry("3DImpact_2",20)); - dialog_->LineImpact_P->setValue(config_->readNumEntry("LineImpact_2",40)); - dialog_->borderSize_P->setValue(config_->readNumEntry("BorderSize_2",0)); - - dialog_->activeColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_3",TQColor(202,202,202).rgb()))); - dialog_->inactiveColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_3",TQColor(200,200,200).rgb()))); - dialog_->activeColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_3",TQColor(150,150,150).rgb()))); - dialog_->inactiveColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_3",TQColor(150,150,150).rgb()))); - dialog_->buttonStyle_B->setCurrentItem(config_->readNumEntry("ButtonStyle_3",0)); - dialog_->titleeffect_B->setCurrentItem(config_->readNumEntry("TitleEffect_3", 4)); - dialog_->i_titleeffect_B->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_3", 4)); - dialog_->shapeUL_B->setChecked(config_->readBoolEntry("ShapeUL_3",true)); - dialog_->shapeUR_B->setChecked(config_->readBoolEntry("ShapeUR_3",true)); - dialog_->shapeLL_B->setChecked(config_->readBoolEntry("ShapeLL_3",true)); - dialog_->shapeLR_B->setChecked(config_->readBoolEntry("ShapeLR_3",true)); - dialog_->drawIcon_B->setChecked(config_->readBoolEntry("drawIcon_3",true)); - dialog_->_3DImpact_B->setValue(config_->readNumEntry("3DImpact_3",20)); - dialog_->LineImpact_B->setValue(config_->readNumEntry("LineImpact_3",0)); - dialog_->borderSize_B->setValue(config_->readNumEntry("BorderSize_3",6)); - - dialog_->activeColor1_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_4",TQColor(238,238,238).rgb()))); - dialog_->activeColor2_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_4",TQColor(205,202,205).rgb()))); - dialog_->buttonStyle_T->setCurrentItem(config_->readNumEntry("ButtonStyle_4",0)); - dialog_->shapeUL_T->setChecked(config_->readBoolEntry("ShapeUL_4",true)); - dialog_->shapeUR_T->setChecked(config_->readBoolEntry("ShapeUR_4",true)); - dialog_->shapeLL_T->setChecked(config_->readBoolEntry("ShapeLL_4",false)); - dialog_->shapeLR_T->setChecked(config_->readBoolEntry("ShapeLR_4",false)); - dialog_->drawIcon_T->setChecked(config_->readBoolEntry("drawIcon_4",true)); - dialog_->_3DImpact_T->setValue(config_->readNumEntry("3DImpact_4",20)); - dialog_->borderSize_T->setValue(config_->readNumEntry("BorderSize_4",0)); - - dialog_->activeColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_5",TQColor(250,250,250).rgb()))); - dialog_->inactiveColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_5",TQColor(230,230,230).rgb()))); - dialog_->activeColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_5",TQColor(230,230,230).rgb()))); - dialog_->inactiveColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_5",TQColor(250,250,250).rgb()))); - dialog_->buttonStyle_S->setCurrentItem(config_->readNumEntry("ButtonStyle_5",0)); - dialog_->titleeffect_S->setCurrentItem(config_->readNumEntry("TitleEffect_5", 0)); - dialog_->i_titleeffect_S->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_5", 0)); - dialog_->shapeUL_S->setChecked(config_->readBoolEntry("ShapeUL_5",true)); - dialog_->shapeUR_S->setChecked(config_->readBoolEntry("ShapeUR_5",true)); - dialog_->shapeLL_S->setChecked(config_->readBoolEntry("ShapeLL_5",false)); - dialog_->shapeLR_S->setChecked(config_->readBoolEntry("ShapeLR_5",false)); - dialog_->drawIcon_S->setChecked(config_->readBoolEntry("drawIcon_5",true)); - dialog_->_3DImpact_S->setValue(config_->readNumEntry("3DImpact_5",20)); - dialog_->LineImpact_S->setValue(config_->readNumEntry("LineImpact_5",30)); - dialog_->borderSize_S->setValue(config_->readNumEntry("BorderSize_5",0)); - - buttonDialog_->inactiveColor->setColor(TQColor((unsigned int)config_->readNumEntry("InactiveButtonColor", TQColor(255,255,255).rgb()))); - buttonDialog_->closeColor->setColor(TQColor((unsigned int)config_->readNumEntry("CloseButtonColor", TQColor(200,85,70).rgb()))); - buttonDialog_->minColor->setColor(TQColor((unsigned int)config_->readNumEntry("MinButtonColor", TQColor(230,155,40).rgb()))); - buttonDialog_-> maxColor->setColor(TQColor((unsigned int)config_->readNumEntry("MaxButtonColor", TQColor(121,180,54).rgb()))); - buttonDialog_->menuColor->setColor(TQColor((unsigned int)config_->readNumEntry("MenuButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->helpColor->setColor(TQColor((unsigned int)config_->readNumEntry("HelpButtonColor", TQColor(0,0,0).rgb()))); - buttonDialog_->stickyColor->setColor(TQColor((unsigned int)config_->readNumEntry("StickyButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->aboveColor->setColor(TQColor((unsigned int)config_->readNumEntry("AboveButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->behindColor->setColor(TQColor((unsigned int)config_->readNumEntry("BehindButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->shadeColor->setColor(TQColor((unsigned int)config_->readNumEntry("ShadeButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->init(); - config_->endGroup(); - delete config_; - -} - -////////////////////////////////////////////////////////////////////////////// -// save() -// ------ -// Save configuration data - -void BaghiraConfig::save(TDEConfig*) -{ - TQSettings *config_ = new TQSettings; - config_->beginGroup("/baghira/Deco"); - - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); - if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); - config_->writeEntry("DrawComicFrame", dialog_->drawComicFrame->isChecked()); - config_->writeEntry("AddAutoSpacing", dialog_->addAutoSpacing->isChecked()); - config_->writeEntry("ResizeGrip", dialog_->ResizeGrip->isChecked()); - config_->writeEntry("allowEasyClosing", dialog_->allowEasyClosing->isChecked()); - config_->writeEntry("MaxResizable", dialog_->maxResizable->isChecked()); - config_->writeEntry("FullSpec", dialog_->fullSpec->isChecked()); - config_->writeEntry("defaultMode", dialog_->defaultMode->currentItem()); - config_->writeEntry("minimumTitleHeight", dialog_->minTH->value()); - config_->writeEntry("NoModalDeco", dialog_->noModalDeco->isChecked()); - config_->writeEntry("RemoveAppname", dialog_->delAppname->isChecked()); - - config_->writeEntry("activeColor1_1", (int)dialog_->activeColor1_J->color().rgb()); - config_->writeEntry("activeColor2_1", (int)dialog_->activeColor2_J->color().rgb()); - config_->writeEntry("inactiveColor1_1", (int)dialog_->inactiveColor1_J->color().rgb()); - config_->writeEntry("inactiveColor2_1", (int)dialog_->inactiveColor2_J->color().rgb()); - config_->writeEntry("ButtonStyle_1", dialog_->buttonStyle_J->currentItem()); - config_->writeEntry("TitleEffect_1", dialog_->titleeffect_J->currentItem()); - config_->writeEntry("inactiveTitleEffect_1", dialog_->i_titleeffect_J->currentItem()); - config_->writeEntry("ShapeUL_1", dialog_->shapeUL_J->isChecked()); - config_->writeEntry("ShapeUR_1", dialog_->shapeUR_J->isChecked()); - config_->writeEntry("ShapeLL_1", dialog_->shapeLL_J->isChecked()); - config_->writeEntry("ShapeLR_1", dialog_->shapeLR_J->isChecked()); - config_->writeEntry("drawIcon_1", dialog_->drawIcon_J->isChecked()); - config_->writeEntry("3DImpact_1", dialog_->_3DImpact_J->value()); - config_->writeEntry("LineImpact_1", dialog_->LineImpact_J->value()); - config_->writeEntry("BorderSize_1", dialog_->borderSize_J->value()); - - config_->writeEntry("activeColor1_2", (int)dialog_->activeColor1_P->color().rgb()); - config_->writeEntry("activeColor2_2", (int)dialog_->activeColor2_P->color().rgb()); - config_->writeEntry("inactiveColor1_2", (int)dialog_->inactiveColor1_P->color().rgb()); - config_->writeEntry("inactiveColor2_2", (int)dialog_->inactiveColor2_P->color().rgb()); - config_->writeEntry("ButtonStyle_2", dialog_->buttonStyle_P->currentItem()); - config_->writeEntry("TitleEffect_2", dialog_->titleeffect_P->currentItem()); - config_->writeEntry("inactiveTitleEffect_2", dialog_->i_titleeffect_P->currentItem()); - config_->writeEntry("ShapeUL_2", dialog_->shapeUL_P->isChecked()); - config_->writeEntry("ShapeUR_2", dialog_->shapeUR_P->isChecked()); - config_->writeEntry("ShapeLL_2", dialog_->shapeLL_P->isChecked()); - config_->writeEntry("ShapeLR_2", dialog_->shapeLR_P->isChecked()); - config_->writeEntry("drawIcon_2", dialog_->drawIcon_P->isChecked()); - config_->writeEntry("3DImpact_2", dialog_->_3DImpact_P->value()); - config_->writeEntry("LineImpact_2", dialog_->LineImpact_P->value()); - config_->writeEntry("BorderSize_2", dialog_->borderSize_P->value()); - - config_->writeEntry("activeColor1_3", (int)dialog_->activeColor1_B->color().rgb()); - config_->writeEntry("activeColor2_3", (int)dialog_->activeColor2_B->color().rgb()); - config_->writeEntry("inactiveColor1_3", (int)dialog_->inactiveColor1_B->color().rgb()); - config_->writeEntry("inactiveColor2_3", (int)dialog_->inactiveColor2_B->color().rgb()); - config_->writeEntry("ButtonStyle_3", dialog_->buttonStyle_B->currentItem()); - config_->writeEntry("TitleEffect_3", dialog_->titleeffect_B->currentItem()); - config_->writeEntry("inactiveTitleEffect_3", dialog_->i_titleeffect_B->currentItem()); - config_->writeEntry("ShapeUL_3", dialog_->shapeUL_B->isChecked()); - config_->writeEntry("ShapeUR_3", dialog_->shapeUR_B->isChecked()); - config_->writeEntry("ShapeLL_3", dialog_->shapeLL_B->isChecked()); - config_->writeEntry("ShapeLR_3", dialog_->shapeLR_B->isChecked()); - config_->writeEntry("drawIcon_3", dialog_->drawIcon_B->isChecked()); - config_->writeEntry("3DImpact_3", dialog_->_3DImpact_B->value()); - config_->writeEntry("LineImpact_3", dialog_->LineImpact_B->value()); - config_->writeEntry("BorderSize_3", dialog_->borderSize_B->value()); - - config_->writeEntry("activeColor1_4", (int)dialog_->activeColor1_T->color().rgb()); - config_->writeEntry("activeColor2_4", (int)dialog_->activeColor2_T->color().rgb()); - config_->writeEntry("ButtonStyle_4", dialog_->buttonStyle_T->currentItem()); - config_->writeEntry("ShapeUL_4", dialog_->shapeUL_T->isChecked()); - config_->writeEntry("ShapeUR_4", dialog_->shapeUR_T->isChecked()); - config_->writeEntry("ShapeLL_4", dialog_->shapeLL_T->isChecked()); - config_->writeEntry("ShapeLR_4", dialog_->shapeLR_T->isChecked()); - config_->writeEntry("drawIcon_4", dialog_->drawIcon_T->isChecked()); - config_->writeEntry("3DImpact_4", dialog_->_3DImpact_T->value()); - config_->writeEntry("BorderSize_4", dialog_->borderSize_T->value()); - - config_->writeEntry("activeColor1_5", (int)dialog_->activeColor1_S->color().rgb()); - config_->writeEntry("activeColor2_5", (int)dialog_->activeColor2_S->color().rgb()); - config_->writeEntry("inactiveColor1_5", (int)dialog_->inactiveColor1_S->color().rgb()); - config_->writeEntry("inactiveColor2_5", (int)dialog_->inactiveColor2_S->color().rgb()); - config_->writeEntry("ButtonStyle_5", dialog_->buttonStyle_S->currentItem()); - config_->writeEntry("TitleEffect_5", dialog_->titleeffect_S->currentItem()); - config_->writeEntry("inactiveTitleEffect_5", dialog_->i_titleeffect_S->currentItem()); - config_->writeEntry("ShapeUL_5", dialog_->shapeUL_S->isChecked()); - config_->writeEntry("ShapeUR_5", dialog_->shapeUR_S->isChecked()); - config_->writeEntry("ShapeLL_5", dialog_->shapeLL_S->isChecked()); - config_->writeEntry("ShapeLR_5", dialog_->shapeLR_S->isChecked()); - config_->writeEntry("drawIcon_5", dialog_->drawIcon_S->isChecked()); - config_->writeEntry("3DImpact_5", dialog_->_3DImpact_S->value()); - config_->writeEntry("LineImpact_5", dialog_->LineImpact_S->value()); - config_->writeEntry("BorderSize_5", dialog_->borderSize_S->value()); - - if (buttonDialog_->save){ - config_->writeEntry("InactiveButtonColor", (int)buttonDialog_->inactiveColor->Color().rgb()); - config_->writeEntry("CloseButtonColor", (int)buttonDialog_->closeColor->Color().rgb()); - config_->writeEntry("MinButtonColor", (int)buttonDialog_->minColor->Color().rgb()); - config_->writeEntry("MaxButtonColor", (int)buttonDialog_->maxColor->Color().rgb()); - config_->writeEntry("MenuButtonColor", (int)buttonDialog_->menuColor->Color().rgb()); - config_->writeEntry("HelpButtonColor", (int)buttonDialog_->helpColor->Color().rgb()); - config_->writeEntry("StickyButtonColor", (int)buttonDialog_->stickyColor->Color().rgb()); - config_->writeEntry("AboveButtonColor", (int)buttonDialog_->aboveColor->Color().rgb()); - config_->writeEntry("BehindButtonColor", (int)buttonDialog_->behindColor->Color().rgb()); - config_->writeEntry("ShadeButtonColor", (int)buttonDialog_->shadeColor->Color().rgb()); - } - config_->endGroup(); - delete config_; - -// config_->sync(); -} - -////////////////////////////////////////////////////////////////////////////// -// defaults() -// ---------- -// Set configuration defaults - -void BaghiraConfig::defaults() -{ - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); - if (button) button->setChecked(true); - dialog_->allowEasyClosing->setChecked(false); - dialog_->minTH->setValue(22); - dialog_->ResizeGrip->setChecked(false); - dialog_->drawComicFrame->setChecked(false); - dialog_->addAutoSpacing->setChecked(true); - dialog_->maxResizable->setChecked(false); - dialog_->fullSpec->setChecked(false); - dialog_->defaultMode->setCurrentItem(1); - dialog_->noModalDeco->setChecked(false); - dialog_->delAppname->setChecked(false); - - dialog_->activeColor1_J->setColor(TQColor(255,255,255)); - dialog_->inactiveColor1_J->setColor(TQColor(204,214,230)); - dialog_->activeColor2_J->setColor(TQColor(238,234,238)); - dialog_->inactiveColor2_J->setColor(TQColor(194,196,211)); - dialog_->buttonStyle_J->setCurrentItem(1); - dialog_->titleeffect_J->setCurrentItem(1); - dialog_->i_titleeffect_J->setCurrentItem(1); - dialog_->shapeUL_J->setChecked(true); - dialog_->shapeUR_J->setChecked(true); - dialog_->shapeLL_J->setChecked(false); - dialog_->shapeLR_J->setChecked(false); - dialog_->drawIcon_J->setChecked(true); - dialog_->_3DImpact_J->setValue(20); - dialog_->LineImpact_J->setValue(40); - dialog_->borderSize_J->setValue(0); - - dialog_->activeColor1_P->setColor(TQColor(238,238,238)); - dialog_->inactiveColor1_P->setColor(TQColor(246,242,246)); - dialog_->activeColor2_P->setColor(TQColor(205,202,205)); - dialog_->inactiveColor2_P->setColor(TQColor(238,238,238)); - dialog_->buttonStyle_P->setCurrentItem(0); - dialog_->titleeffect_P->setCurrentItem(0); - dialog_->i_titleeffect_P->setCurrentItem(0); - dialog_->shapeUL_P->setChecked(true); - dialog_->shapeUR_P->setChecked(true); - dialog_->shapeLL_P->setChecked(false); - dialog_->shapeLR_P->setChecked(false); - dialog_->drawIcon_P->setChecked(true); - dialog_->_3DImpact_P->setValue(20); - dialog_->LineImpact_P->setValue(30); - dialog_->borderSize_P->setValue(0); - - dialog_->activeColor1_B->setColor(TQColor(210,210,210)); - dialog_->inactiveColor1_B->setColor(TQColor(200,200,200)); - dialog_->activeColor2_B->setColor(TQColor(150,150,150)); - dialog_->inactiveColor2_B->setColor(TQColor(140,140,140)); - dialog_->buttonStyle_B->setCurrentItem(0); - dialog_->titleeffect_B->setCurrentItem(4); - dialog_->i_titleeffect_B->setCurrentItem(4); - dialog_->shapeUL_B->setChecked(true); - dialog_->shapeUR_B->setChecked(true); - dialog_->shapeLL_B->setChecked(false); - dialog_->shapeLR_B->setChecked(false); - dialog_->drawIcon_B->setChecked(true); - dialog_->_3DImpact_B->setValue(20); - dialog_->LineImpact_B->setValue(0); - dialog_->borderSize_B->setValue(6); - - dialog_->activeColor1_T->setColor(TQColor(238,238,238)); - dialog_->activeColor2_T->setColor(TQColor(211,208,211)); - dialog_->buttonStyle_T->setCurrentItem(0); - dialog_->shapeUL_T->setChecked(true); - dialog_->shapeUR_T->setChecked(true); - dialog_->shapeLL_T->setChecked(false); - dialog_->shapeLR_T->setChecked(false); - dialog_->drawIcon_T->setChecked(true); - dialog_->_3DImpact_T->setValue(20); - dialog_->borderSize_T->setValue(0); - - dialog_->activeColor1_S->setColor(TQColor(250,250,250)); - dialog_->inactiveColor1_S->setColor(TQColor(230,230,230)); - dialog_->activeColor2_S->setColor(TQColor(230,230,230)); - dialog_->inactiveColor2_S->setColor(TQColor(250,250,250)); - dialog_->buttonStyle_S->setCurrentItem(0); - dialog_->titleeffect_S->setCurrentItem(0); - dialog_->i_titleeffect_S->setCurrentItem(0); - dialog_->shapeUL_S->setChecked(true); - dialog_->shapeUR_S->setChecked(true); - dialog_->shapeLL_S->setChecked(false); - dialog_->shapeLR_S->setChecked(false); - dialog_->drawIcon_S->setChecked(true); - dialog_->_3DImpact_S->setValue(20); - dialog_->LineImpact_S->setValue(30); - dialog_->borderSize_S->setValue(0); - -// buttonDialog_->defaults(); - - -} - -enum ColorPresets{Aqua = 0, Graphite, GraphiteDark, NUMBEROFCOLORS}; - -const char * presetColorName[NUMBEROFCOLORS] = {"Aqua", "Graphite", "Graphite (Dark)" }; - -typedef int ColorTable[10][3]; - -const int aquaPreset[10][3] = {{255,255,255},{200,85,70},{230,155,40},{121,180,54},{74,140,242},{0,0,0},{74,140,242},{74,140,242},{74,140,242},{74,140,242}}; -const int graphitePreset[10][3] = {{255,255,255},{130,170,190},{130,170,190},{130,170,190},{130,170,190},{0,0,0},{130,170,190},{130,170,190},{130,170,190},{130,170,190}}; -const int graphiteDarkPreset[10][3] = {{255,255,255},{103,118,134},{103,118,134},{103,118,134},{103,118,134},{0,0,0},{103,118,134},{103,118,134},{103,118,134},{103,118,134}}; -const ColorTable* presetColors[NUMBEROFCOLORS] = {&aquaPreset, &graphitePreset, &graphiteDarkPreset}; - - -ButtonColors::ButtonColors(TQWidget *parent, const char * name) : TQDialog(parent, name){ - save = false; - layout = new TQGridLayout(this,2,2,11,6, "Grid"); - buttonLayout = new TQVBoxLayout(0,0,6); - - TQPixmap tmpPix = TQPixmap(uic_findImage("preview")); - inactiveButton = new AquariusButton(tmpPix,this, "Inactive Button"); - buttonLayout->addWidget(inactiveButton); - closeButton = new AquariusButton(tmpPix,this, "Close Button"); - buttonLayout->addWidget(closeButton); - minButton = new AquariusButton(tmpPix,this, "Minimize Button"); - buttonLayout->addWidget(minButton); - maxButton = new AquariusButton(tmpPix,this, "Maximize Button"); - buttonLayout->addWidget(maxButton); - stickyButton = new AquariusButton(tmpPix,this, "Sticky Button"); - buttonLayout->addWidget(stickyButton); - aboveButton = new AquariusButton(tmpPix,this, "Above Button"); - buttonLayout->addWidget(aboveButton); - behindButton = new AquariusButton(tmpPix,this, "Behind Button"); - buttonLayout->addWidget(behindButton); - shadeButton = new AquariusButton(tmpPix,this, "Shade Button"); - buttonLayout->addWidget(shadeButton); - tmpPix = TQPixmap(uic_findImage("preview-menu")); - menuButton = new AquariusButton(tmpPix,this, "Menu Button"); - buttonLayout->addWidget(menuButton); - tmpPix = TQPixmap(uic_findImage("icon_help")); - helpButton = new AquariusButton(tmpPix,this, "Help Button"); - buttonLayout->addWidget(helpButton); - - - twoButts = new TQHBoxLayout(0,0,6); - presets_ = new TQComboBox(this); - for (int i = 0; i < NUMBEROFCOLORS; i++) - presets_->insertItem ( presetColorName[i], i ); - twoButts->addWidget(presets_); - cancel = new TQPushButton("Cancel", this); - cancel->setDefault( true ); - twoButts->addWidget(cancel); - twoButts->addStretch(); - layout->addLayout(twoButts,1,0); - ok = new TQPushButton("OK", this); - layout->addWidget(ok,1,1); - - layout->addLayout(buttonLayout,0,1); - - pickerLayout = new TQVBoxLayout(0,0,6,0); - - indicator = new TQLabel(inactiveButton->name(), this); - indicator->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter | TQt::ExpandTabs); - TQFont tmpFont = font(); - tmpFont.setBold( true ); - tmpFont.setPointSize( 24 ); - indicator->setFont(tmpFont); - pickerLayout->addWidget(indicator); - - inactiveColor = new ColorPicker(this); - pickerLayout->addWidget(inactiveColor); - currentPicker = inactiveColor; - closeColor = new ColorPicker(this); - pickerLayout->addWidget(closeColor); - closeColor->hide(); - minColor = new ColorPicker(this); - pickerLayout->addWidget(minColor); - minColor->hide(); - maxColor = new ColorPicker(this); - pickerLayout->addWidget(maxColor); - maxColor->hide(); - menuColor = new ColorPicker(this); - pickerLayout->addWidget(menuColor); - menuColor->hide(); - helpColor = new ColorPicker(this); - pickerLayout->addWidget(helpColor); - helpColor->hide(); - stickyColor = new ColorPicker(this); - pickerLayout->addWidget(stickyColor); - stickyColor->hide(); - aboveColor = new ColorPicker(this); - pickerLayout->addWidget(aboveColor); - aboveColor->hide(); - behindColor = new ColorPicker(this); - pickerLayout->addWidget(behindColor); - behindColor->hide(); - shadeColor = new ColorPicker(this); - pickerLayout->addWidget(shadeColor); - shadeColor->hide(); - - indicator->lower(); - - layout->addLayout(pickerLayout,0,0); - - resize( TQSize(485, 177).expandedTo(minimumSizeHint()) ); - clearWState( WState_Polished ); - - connect(presets_,SIGNAL(activated(int)), this, SLOT(setColorGroup(int))); - connect(ok, SIGNAL(clicked()), this, SLOT(setSave())); - connect(ok, SIGNAL(clicked()), this, SLOT(close()) ); - connect(ok, SIGNAL(clicked()), this, SLOT(init()) ); - connect(cancel, SIGNAL(clicked()), this, SLOT(close()) ); - connect(cancel, SIGNAL(clicked()), this, SLOT(reset()) ); - - connect(inactiveButton, SIGNAL(clicked()), this, SLOT(activateInactive()) ); - connect(closeButton, SIGNAL(clicked()), this, SLOT(activateClose()) ); - connect(minButton, SIGNAL(clicked()), this, SLOT(activateMin()) ); - connect(maxButton, SIGNAL(clicked()), this, SLOT(activateMax()) ); - connect(menuButton, SIGNAL(clicked()), this, SLOT(activateMenu()) ); - connect(helpButton, SIGNAL(clicked()), this, SLOT(activateHelp()) ); - connect(stickyButton, SIGNAL(clicked()), this, SLOT(activateSticky()) ); - connect(aboveButton, SIGNAL(clicked()), this, SLOT(activateAbove()) ); - connect(behindButton, SIGNAL(clicked()), this, SLOT(activateBehind()) ); - connect(shadeButton, SIGNAL(clicked()), this, SLOT(activateShade()) ); - - connect(inactiveColor, SIGNAL(colorChanged(TQColor)), inactiveButton, SLOT(setColor(TQColor)) ); - connect(closeColor, SIGNAL(colorChanged(TQColor)), closeButton, SLOT(setColor(TQColor)) ); - connect(minColor, SIGNAL(colorChanged(TQColor)), minButton, SLOT(setColor(TQColor)) ); - connect(maxColor, SIGNAL(colorChanged(TQColor)), maxButton, SLOT(setColor(TQColor)) ); - connect(menuColor, SIGNAL(colorChanged(TQColor)), menuButton, SLOT(setColor(TQColor)) ); - connect(helpColor, SIGNAL(colorChanged(TQColor)), helpButton, SLOT(setColor(TQColor)) ); - connect(stickyColor, SIGNAL(colorChanged(TQColor)), stickyButton, SLOT(setColor(TQColor)) ); - connect(aboveColor, SIGNAL(colorChanged(TQColor)), aboveButton, SLOT(setColor(TQColor)) ); - connect(behindColor, SIGNAL(colorChanged(TQColor)), behindButton, SLOT(setColor(TQColor)) ); - connect(shadeColor, SIGNAL(colorChanged(TQColor)), shadeButton, SLOT(setColor(TQColor)) ); - -} - -ButtonColors::~ButtonColors(){ -} - -void ButtonColors::setColorGroup(int i){ - inactiveColor->setColor(TQColor((*presetColors[i])[0][0],(*presetColors[i])[0][1],(*presetColors[i])[0][2]).rgb()); - closeColor->setColor(TQColor((*presetColors[i])[1][0],(*presetColors[i])[1][1],(*presetColors[i])[1][2]).rgb()); - minColor->setColor(TQColor((*presetColors[i])[2][0],(*presetColors[i])[2][1],(*presetColors[i])[2][2]).rgb()); - maxColor->setColor(TQColor((*presetColors[i])[3][0],(*presetColors[i])[3][1],(*presetColors[i])[3][2]).rgb()); - menuColor->setColor(TQColor((*presetColors[i])[4][0],(*presetColors[i])[4][1],(*presetColors[i])[4][2]).rgb()); - helpColor->setColor(TQColor((*presetColors[i])[5][0],(*presetColors[i])[5][1],(*presetColors[i])[5][2]).rgb()); - stickyColor->setColor(TQColor((*presetColors[i])[6][0],(*presetColors[i])[6][1],(*presetColors[i])[6][2]).rgb()); - aboveColor->setColor(TQColor((*presetColors[i])[7][0],(*presetColors[i])[7][1],(*presetColors[i])[7][2]).rgb()); - behindColor->setColor(TQColor((*presetColors[i])[8][0],(*presetColors[i])[8][1],(*presetColors[i])[8][2]).rgb()); - shadeColor->setColor(TQColor((*presetColors[i])[9][0],(*presetColors[i])[9][1],(*presetColors[i])[9][2]).rgb()); -} - -void ButtonColors::setPicker(ColorPicker *picker){ - if (currentPicker) currentPicker->hide(); - currentPicker = picker; - currentPicker->show(); -} - -void ButtonColors::activateInactive(){ - setPicker(inactiveColor); - indicator->setText( inactiveButton->name() ); -} -void ButtonColors::activateClose(){ - setPicker(closeColor); - indicator->setText( closeButton->name() ); -} -void ButtonColors::activateMin(){ - setPicker(minColor); - indicator->setText( minButton->name() ); -} -void ButtonColors::activateMax(){ - setPicker(maxColor); - indicator->setText( maxButton->name() ); -} -void ButtonColors::activateMenu(){ - setPicker(menuColor); - indicator->setText( menuButton->name() ); -} -void ButtonColors::activateHelp(){ - setPicker(helpColor); - indicator->setText( helpButton->name() ); -} -void ButtonColors::activateSticky(){ - setPicker(stickyColor); - indicator->setText( stickyButton->name() ); -} -void ButtonColors::activateAbove(){ - setPicker(aboveColor); - indicator->setText( aboveButton->name() ); -} -void ButtonColors::activateBehind(){ - setPicker(behindColor); - indicator->setText( behindButton->name() ); -} -void ButtonColors::activateShade(){ - setPicker(shadeColor); - indicator->setText( shadeButton->name() ); -} - -void ButtonColors::reset(){ - inactiveColor->reset(); - closeColor->reset(); - minColor->reset(); - maxColor->reset(); - menuColor->reset(); - helpColor->reset(); - stickyColor->reset(); - aboveColor->reset(); - behindColor->reset(); - shadeColor->reset(); -} - -void ButtonColors::init(){ - inactiveColor->init(); - closeColor->init(); - minColor->init(); - maxColor->init(); - menuColor->init(); - helpColor->init(); - stickyColor->init(); - aboveColor->init(); - behindColor->init(); - shadeColor->init(); -} - -////////////////////////////////////////////////////////////////////////////// -// Plugin Stuff // -////////////////////////////////////////////////////////////////////////////// - -extern "C" -{ - KDE_EXPORT TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { - return(new BaghiraConfig(config, parent)); - } -} - -#include "baghiraconfig.moc" diff --git a/deco/config/baghiraconfig.cc.new b/deco/config/baghiraconfig.cc.new deleted file mode 100644 index b0f507b..0000000 --- a/deco/config/baghiraconfig.cc.new +++ /dev/null @@ -1,730 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// baghiraconfig.cc -// ------------------- -// Config module for Baghira window decoration -// ------------------- -// Copyright (c) 2004 Thomas Lübking -// Please see the header file for copyright and license information. -////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "baghiraconfig.h" -#include "configdialog.h" -#include "customdecosettings.h" -#include "pixmaps.h" - -////////////////////////////////////////////////////////////////////////////// -// BaghiraConfig Class // -////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////////// -// BaghiraConfig() -// ------------- -// Constructor - -BaghiraConfig::BaghiraConfig(TDEConfig*, TQWidget* parent) - : TQObject(parent), /*config_(0),*/ dialog_(0) -{ -// config_ = new TDEConfig("baghirarc"); -// config_ = new TQSettings; -// config_->beginGroup("/baghira/Deco"); - TDEGlobal::locale()->insertCatalogue("twin_baghira_config"); - - dialog_ = new ConfigDialog(parent); - buttonDialog_ = new ButtonColors(parent, "Button Colors"); - load(0L); - - dialog_->show(); - - connect(dialog_->ButtonColorConfig, SIGNAL(clicked()), buttonDialog_, SLOT(exec())); - connect(buttonDialog_->ok, SIGNAL(clicked()), SIGNAL(changed())); - - // connections - connect(dialog_->titlealign, SIGNAL(clicked(int)), SIGNAL(changed())); - connect(dialog_->drawComicFrame, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->addAutoSpacing, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->allowEasyClosing, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->ResizeGrip, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->maxResizable, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->fullSpec, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->noModalDeco, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->delAppname, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->defaultMode, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->minTH, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_J, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_J, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_P, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_P, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_B, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_B, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_T, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_T, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_T, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_T, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->_3DImpact_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); - - connect(dialog_->activeColor1_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->activeColor2_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor1_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->inactiveColor2_S, SIGNAL(clicked()), SIGNAL(changed())); - connect(dialog_->buttonStyle_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->shapeUL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeUR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->shapeLR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->drawIcon_S, SIGNAL(toggled(bool)), SIGNAL(changed())); - connect(dialog_->titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->i_titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); - connect(dialog_->_3DImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->LineImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); - connect(dialog_->borderSize_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); -// config_->endGroup(); - -} - -////////////////////////////////////////////////////////////////////////////// -// ~BaghiraConfig() -// -------------- -// Destructor - -BaghiraConfig::~BaghiraConfig() -{ - if (dialog_) delete dialog_; -// if (config_) delete config_; -} - -////////////////////////////////////////////////////////////////////////////// -// load() -// ------ -// Load configuration data - -void BaghiraConfig::load(TDEConfig*) -{ - TQSettings *config_ = new TQSettings; - config_->beginGroup("/baghira/Deco"); - - TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign-> - child((const char *)value.latin1()); - if (button) button->setChecked(true); - - dialog_->minTH->setValue(config_->readNumEntry("minimumTitleHeight",18)); - dialog_->ResizeGrip->setChecked(config_->readBoolEntry("ResizeGrip",false)); - dialog_->allowEasyClosing->setChecked(config_->readBoolEntry("allowEasyClosing",false)); - dialog_->drawComicFrame->setChecked(config_->readBoolEntry("DrawComicFrame",false)); - dialog_->maxResizable->setChecked(config_->readBoolEntry("MaxResizable",false)); - dialog_->fullSpec->setChecked(config_->readBoolEntry("FullSpec",false)); - dialog_->addAutoSpacing->setChecked(config_->readBoolEntry("AddAutoSpacing",true)); - dialog_->defaultMode->setCurrentItem(config_->readNumEntry("defaultMode",1)); - dialog_->noModalDeco->setChecked(config_->readBoolEntry("NoModalDeco",false)); - dialog_->delAppname->setChecked(config_->readBoolEntry("RemoveAppname",false)); - - dialog_->activeColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_1",TQColor(255,255,255).rgb()))); - dialog_->inactiveColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_1",TQColor(204,214,230).rgb()))); - dialog_->activeColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_1",TQColor(238,234,238).rgb()))); - dialog_->inactiveColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_1",TQColor(194,196,211).rgb()))); - dialog_->buttonStyle_J->setCurrentItem(config_->readNumEntry("ButtonStyle_1",1)); - dialog_->titleeffect_J->setCurrentItem(config_->readNumEntry("TitleEffect_1", 1)); - dialog_->i_titleeffect_J->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_1", 1)); - dialog_->shapeUL_J->setChecked(config_->readBoolEntry("ShapeUL_1",true)); - dialog_->shapeUR_J->setChecked(config_->readBoolEntry("ShapeUR_1",true)); - dialog_->shapeLL_J->setChecked(config_->readBoolEntry("ShapeLL_1",false)); - dialog_->shapeLR_J->setChecked(config_->readBoolEntry("ShapeLR_1",false)); - dialog_->drawIcon_J->setChecked(config_->readBoolEntry("drawIcon_1",true)); - dialog_->_3DImpact_J->setValue(config_->readNumEntry("3DImpact_1",20)); - dialog_->LineImpact_J->setValue(config_->readNumEntry("LineImpact_1",40)); - dialog_->borderSize_J->setValue(config_->readNumEntry("BorderSize_1",0)); - - dialog_->activeColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_2",TQColor(238,238,238).rgb()))); - dialog_->inactiveColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_2",TQColor(246,242,246).rgb()))); - dialog_->activeColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_2",TQColor(205,202,205).rgb()))); - dialog_->inactiveColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_2",TQColor(238,238,238).rgb()))); - dialog_->buttonStyle_P->setCurrentItem(config_->readNumEntry("ButtonStyle_2",0)); - dialog_->titleeffect_P->setCurrentItem(config_->readNumEntry("TitleEffect_2", 0)); - dialog_->i_titleeffect_P->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_2", 0)); - dialog_->shapeUL_P->setChecked(config_->readBoolEntry("ShapeUL_2",true)); - dialog_->shapeUR_P->setChecked(config_->readBoolEntry("ShapeUR_2",true)); - dialog_->shapeLL_P->setChecked(config_->readBoolEntry("ShapeLL_2",false)); - dialog_->shapeLR_P->setChecked(config_->readBoolEntry("ShapeLR_2",false)); - dialog_->drawIcon_P->setChecked(config_->readBoolEntry("drawIcon_2",true)); - dialog_->_3DImpact_P->setValue(config_->readNumEntry("3DImpact_2",20)); - dialog_->LineImpact_P->setValue(config_->readNumEntry("LineImpact_2",40)); - dialog_->borderSize_P->setValue(config_->readNumEntry("BorderSize_2",0)); - - dialog_->activeColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_3",TQColor(202,202,202).rgb()))); - dialog_->inactiveColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_3",TQColor(200,200,200).rgb()))); - dialog_->activeColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_3",TQColor(150,150,150).rgb()))); - dialog_->inactiveColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_3",TQColor(150,150,150).rgb()))); - dialog_->buttonStyle_B->setCurrentItem(config_->readNumEntry("ButtonStyle_3",0)); - dialog_->titleeffect_B->setCurrentItem(config_->readNumEntry("TitleEffect_3", 4)); - dialog_->i_titleeffect_B->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_3", 4)); - dialog_->shapeUL_B->setChecked(config_->readBoolEntry("ShapeUL_3",true)); - dialog_->shapeUR_B->setChecked(config_->readBoolEntry("ShapeUR_3",true)); - dialog_->shapeLL_B->setChecked(config_->readBoolEntry("ShapeLL_3",true)); - dialog_->shapeLR_B->setChecked(config_->readBoolEntry("ShapeLR_3",true)); - dialog_->drawIcon_B->setChecked(config_->readBoolEntry("drawIcon_3",true)); - dialog_->_3DImpact_B->setValue(config_->readNumEntry("3DImpact_3",20)); - dialog_->LineImpact_B->setValue(config_->readNumEntry("LineImpact_3",0)); - dialog_->borderSize_B->setValue(config_->readNumEntry("BorderSize_3",6)); - - dialog_->activeColor1_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_4",TQColor(238,238,238).rgb()))); - dialog_->activeColor2_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_4",TQColor(205,202,205).rgb()))); - dialog_->buttonStyle_T->setCurrentItem(config_->readNumEntry("ButtonStyle_4",0)); - dialog_->shapeUL_T->setChecked(config_->readBoolEntry("ShapeUL_4",true)); - dialog_->shapeUR_T->setChecked(config_->readBoolEntry("ShapeUR_4",true)); - dialog_->shapeLL_T->setChecked(config_->readBoolEntry("ShapeLL_4",false)); - dialog_->shapeLR_T->setChecked(config_->readBoolEntry("ShapeLR_4",false)); - dialog_->drawIcon_T->setChecked(config_->readBoolEntry("drawIcon_4",true)); - dialog_->_3DImpact_T->setValue(config_->readNumEntry("3DImpact_4",20)); - dialog_->borderSize_T->setValue(config_->readNumEntry("BorderSize_4",0)); - - dialog_->activeColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_5",TQColor(250,250,250).rgb()))); - dialog_->inactiveColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_5",TQColor(230,230,230).rgb()))); - dialog_->activeColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_5",TQColor(230,230,230).rgb()))); - dialog_->inactiveColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_5",TQColor(250,250,250).rgb()))); - dialog_->buttonStyle_S->setCurrentItem(config_->readNumEntry("ButtonStyle_5",0)); - dialog_->titleeffect_S->setCurrentItem(config_->readNumEntry("TitleEffect_5", 0)); - dialog_->i_titleeffect_S->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_5", 0)); - dialog_->shapeUL_S->setChecked(config_->readBoolEntry("ShapeUL_5",true)); - dialog_->shapeUR_S->setChecked(config_->readBoolEntry("ShapeUR_5",true)); - dialog_->shapeLL_S->setChecked(config_->readBoolEntry("ShapeLL_5",false)); - dialog_->shapeLR_S->setChecked(config_->readBoolEntry("ShapeLR_5",false)); - dialog_->drawIcon_S->setChecked(config_->readBoolEntry("drawIcon_5",true)); - dialog_->_3DImpact_S->setValue(config_->readNumEntry("3DImpact_5",20)); - dialog_->LineImpact_S->setValue(config_->readNumEntry("LineImpact_5",30)); - dialog_->borderSize_S->setValue(config_->readNumEntry("BorderSize_5",0)); - - buttonDialog_->inactiveColor->setColor(TQColor((unsigned int)config_->readNumEntry("InactiveButtonColor", TQColor(255,255,255).rgb()))); - buttonDialog_->closeColor->setColor(TQColor((unsigned int)config_->readNumEntry("CloseButtonColor", TQColor(200,85,70).rgb()))); - buttonDialog_->minColor->setColor(TQColor((unsigned int)config_->readNumEntry("MinButtonColor", TQColor(230,155,40).rgb()))); - buttonDialog_-> maxColor->setColor(TQColor((unsigned int)config_->readNumEntry("MaxButtonColor", TQColor(121,180,54).rgb()))); - buttonDialog_->menuColor->setColor(TQColor((unsigned int)config_->readNumEntry("MenuButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->helpColor->setColor(TQColor((unsigned int)config_->readNumEntry("HelpButtonColor", TQColor(0,0,0).rgb()))); - buttonDialog_->stickyColor->setColor(TQColor((unsigned int)config_->readNumEntry("StickyButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->aboveColor->setColor(TQColor((unsigned int)config_->readNumEntry("AboveButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->behindColor->setColor(TQColor((unsigned int)config_->readNumEntry("BehindButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->shadeColor->setColor(TQColor((unsigned int)config_->readNumEntry("ShadeButtonColor", TQColor(74,140,242).rgb()))); - buttonDialog_->init(); - config_->endGroup(); - delete config_; - -} - -////////////////////////////////////////////////////////////////////////////// -// save() -// ------ -// Save configuration data - -void BaghiraConfig::save(TDEConfig*) -{ - TQSettings *config_ = new TQSettings; - config_->beginGroup("/baghira/Deco"); - - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); - if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); - config_->writeEntry("DrawComicFrame", dialog_->drawComicFrame->isChecked()); - config_->writeEntry("AddAutoSpacing", dialog_->addAutoSpacing->isChecked()); - config_->writeEntry("ResizeGrip", dialog_->ResizeGrip->isChecked()); - config_->writeEntry("allowEasyClosing", dialog_->allowEasyClosing->isChecked()); - config_->writeEntry("MaxResizable", dialog_->maxResizable->isChecked()); - config_->writeEntry("FullSpec", dialog_->fullSpec->isChecked()); - config_->writeEntry("defaultMode", dialog_->defaultMode->currentItem()); - config_->writeEntry("minimumTitleHeight", dialog_->minTH->value()); - config_->writeEntry("NoModalDeco", dialog_->noModalDeco->isChecked()); - config_->writeEntry("RemoveAppname", dialog_->delAppname->isChecked()); - - config_->writeEntry("activeColor1_1", (int)dialog_->activeColor1_J->color().rgb()); - config_->writeEntry("activeColor2_1", (int)dialog_->activeColor2_J->color().rgb()); - config_->writeEntry("inactiveColor1_1", (int)dialog_->inactiveColor1_J->color().rgb()); - config_->writeEntry("inactiveColor2_1", (int)dialog_->inactiveColor2_J->color().rgb()); - config_->writeEntry("ButtonStyle_1", dialog_->buttonStyle_J->currentItem()); - config_->writeEntry("TitleEffect_1", dialog_->titleeffect_J->currentItem()); - config_->writeEntry("inactiveTitleEffect_1", dialog_->i_titleeffect_J->currentItem()); - config_->writeEntry("ShapeUL_1", dialog_->shapeUL_J->isChecked()); - config_->writeEntry("ShapeUR_1", dialog_->shapeUR_J->isChecked()); - config_->writeEntry("ShapeLL_1", dialog_->shapeLL_J->isChecked()); - config_->writeEntry("ShapeLR_1", dialog_->shapeLR_J->isChecked()); - config_->writeEntry("drawIcon_1", dialog_->drawIcon_J->isChecked()); - config_->writeEntry("3DImpact_1", dialog_->_3DImpact_J->value()); - config_->writeEntry("LineImpact_1", dialog_->LineImpact_J->value()); - config_->writeEntry("BorderSize_1", dialog_->borderSize_J->value()); - - config_->writeEntry("activeColor1_2", (int)dialog_->activeColor1_P->color().rgb()); - config_->writeEntry("activeColor2_2", (int)dialog_->activeColor2_P->color().rgb()); - config_->writeEntry("inactiveColor1_2", (int)dialog_->inactiveColor1_P->color().rgb()); - config_->writeEntry("inactiveColor2_2", (int)dialog_->inactiveColor2_P->color().rgb()); - config_->writeEntry("ButtonStyle_2", dialog_->buttonStyle_P->currentItem()); - config_->writeEntry("TitleEffect_2", dialog_->titleeffect_P->currentItem()); - config_->writeEntry("inactiveTitleEffect_2", dialog_->i_titleeffect_P->currentItem()); - config_->writeEntry("ShapeUL_2", dialog_->shapeUL_P->isChecked()); - config_->writeEntry("ShapeUR_2", dialog_->shapeUR_P->isChecked()); - config_->writeEntry("ShapeLL_2", dialog_->shapeLL_P->isChecked()); - config_->writeEntry("ShapeLR_2", dialog_->shapeLR_P->isChecked()); - config_->writeEntry("drawIcon_2", dialog_->drawIcon_P->isChecked()); - config_->writeEntry("3DImpact_2", dialog_->_3DImpact_P->value()); - config_->writeEntry("LineImpact_2", dialog_->LineImpact_P->value()); - config_->writeEntry("BorderSize_2", dialog_->borderSize_P->value()); - - config_->writeEntry("activeColor1_3", (int)dialog_->activeColor1_B->color().rgb()); - config_->writeEntry("activeColor2_3", (int)dialog_->activeColor2_B->color().rgb()); - config_->writeEntry("inactiveColor1_3", (int)dialog_->inactiveColor1_B->color().rgb()); - config_->writeEntry("inactiveColor2_3", (int)dialog_->inactiveColor2_B->color().rgb()); - config_->writeEntry("ButtonStyle_3", dialog_->buttonStyle_B->currentItem()); - config_->writeEntry("TitleEffect_3", dialog_->titleeffect_B->currentItem()); - config_->writeEntry("inactiveTitleEffect_3", dialog_->i_titleeffect_B->currentItem()); - config_->writeEntry("ShapeUL_3", dialog_->shapeUL_B->isChecked()); - config_->writeEntry("ShapeUR_3", dialog_->shapeUR_B->isChecked()); - config_->writeEntry("ShapeLL_3", dialog_->shapeLL_B->isChecked()); - config_->writeEntry("ShapeLR_3", dialog_->shapeLR_B->isChecked()); - config_->writeEntry("drawIcon_3", dialog_->drawIcon_B->isChecked()); - config_->writeEntry("3DImpact_3", dialog_->_3DImpact_B->value()); - config_->writeEntry("LineImpact_3", dialog_->LineImpact_B->value()); - config_->writeEntry("BorderSize_3", dialog_->borderSize_B->value()); - - config_->writeEntry("activeColor1_4", (int)dialog_->activeColor1_T->color().rgb()); - config_->writeEntry("activeColor2_4", (int)dialog_->activeColor2_T->color().rgb()); - config_->writeEntry("ButtonStyle_4", dialog_->buttonStyle_T->currentItem()); - config_->writeEntry("ShapeUL_4", dialog_->shapeUL_T->isChecked()); - config_->writeEntry("ShapeUR_4", dialog_->shapeUR_T->isChecked()); - config_->writeEntry("ShapeLL_4", dialog_->shapeLL_T->isChecked()); - config_->writeEntry("ShapeLR_4", dialog_->shapeLR_T->isChecked()); - config_->writeEntry("drawIcon_4", dialog_->drawIcon_T->isChecked()); - config_->writeEntry("3DImpact_4", dialog_->_3DImpact_T->value()); - config_->writeEntry("BorderSize_4", dialog_->borderSize_T->value()); - - config_->writeEntry("activeColor1_5", (int)dialog_->activeColor1_S->color().rgb()); - config_->writeEntry("activeColor2_5", (int)dialog_->activeColor2_S->color().rgb()); - config_->writeEntry("inactiveColor1_5", (int)dialog_->inactiveColor1_S->color().rgb()); - config_->writeEntry("inactiveColor2_5", (int)dialog_->inactiveColor2_S->color().rgb()); - config_->writeEntry("ButtonStyle_5", dialog_->buttonStyle_S->currentItem()); - config_->writeEntry("TitleEffect_5", dialog_->titleeffect_S->currentItem()); - config_->writeEntry("inactiveTitleEffect_5", dialog_->i_titleeffect_S->currentItem()); - config_->writeEntry("ShapeUL_5", dialog_->shapeUL_S->isChecked()); - config_->writeEntry("ShapeUR_5", dialog_->shapeUR_S->isChecked()); - config_->writeEntry("ShapeLL_5", dialog_->shapeLL_S->isChecked()); - config_->writeEntry("ShapeLR_5", dialog_->shapeLR_S->isChecked()); - config_->writeEntry("drawIcon_5", dialog_->drawIcon_S->isChecked()); - config_->writeEntry("3DImpact_5", dialog_->_3DImpact_S->value()); - config_->writeEntry("LineImpact_5", dialog_->LineImpact_S->value()); - config_->writeEntry("BorderSize_5", dialog_->borderSize_S->value()); - - if (buttonDialog_->save){ - config_->writeEntry("InactiveButtonColor", (int)buttonDialog_->inactiveColor->Color().rgb()); - config_->writeEntry("CloseButtonColor", (int)buttonDialog_->closeColor->Color().rgb()); - config_->writeEntry("MinButtonColor", (int)buttonDialog_->minColor->Color().rgb()); - config_->writeEntry("MaxButtonColor", (int)buttonDialog_->maxColor->Color().rgb()); - config_->writeEntry("MenuButtonColor", (int)buttonDialog_->menuColor->Color().rgb()); - config_->writeEntry("HelpButtonColor", (int)buttonDialog_->helpColor->Color().rgb()); - config_->writeEntry("StickyButtonColor", (int)buttonDialog_->stickyColor->Color().rgb()); - config_->writeEntry("AboveButtonColor", (int)buttonDialog_->aboveColor->Color().rgb()); - config_->writeEntry("BehindButtonColor", (int)buttonDialog_->behindColor->Color().rgb()); - config_->writeEntry("ShadeButtonColor", (int)buttonDialog_->shadeColor->Color().rgb()); - } - config_->endGroup(); - delete config_; - -// config_->sync(); -} - -////////////////////////////////////////////////////////////////////////////// -// defaults() -// ---------- -// Set configuration defaults - -void BaghiraConfig::defaults() -{ - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); - if (button) button->setChecked(true); - dialog_->allowEasyClosing->setChecked(false); - dialog_->minTH->setValue(22); - dialog_->ResizeGrip->setChecked(false); - dialog_->drawComicFrame->setChecked(false); - dialog_->addAutoSpacing->setChecked(true); - dialog_->maxResizable->setChecked(false); - dialog_->fullSpec->setChecked(false); - dialog_->defaultMode->setCurrentItem(1); - dialog_->noModalDeco->setChecked(false); - dialog_->delAppname->setChecked(false); - - dialog_->activeColor1_J->setColor(TQColor(255,255,255)); - dialog_->inactiveColor1_J->setColor(TQColor(204,214,230)); - dialog_->activeColor2_J->setColor(TQColor(238,234,238)); - dialog_->inactiveColor2_J->setColor(TQColor(194,196,211)); - dialog_->buttonStyle_J->setCurrentItem(1); - dialog_->titleeffect_J->setCurrentItem(1); - dialog_->i_titleeffect_J->setCurrentItem(1); - dialog_->shapeUL_J->setChecked(true); - dialog_->shapeUR_J->setChecked(true); - dialog_->shapeLL_J->setChecked(false); - dialog_->shapeLR_J->setChecked(false); - dialog_->drawIcon_J->setChecked(true); - dialog_->_3DImpact_J->setValue(20); - dialog_->LineImpact_J->setValue(40); - dialog_->borderSize_J->setValue(0); - - dialog_->activeColor1_P->setColor(TQColor(238,238,238)); - dialog_->inactiveColor1_P->setColor(TQColor(246,242,246)); - dialog_->activeColor2_P->setColor(TQColor(205,202,205)); - dialog_->inactiveColor2_P->setColor(TQColor(238,238,238)); - dialog_->buttonStyle_P->setCurrentItem(0); - dialog_->titleeffect_P->setCurrentItem(0); - dialog_->i_titleeffect_P->setCurrentItem(0); - dialog_->shapeUL_P->setChecked(true); - dialog_->shapeUR_P->setChecked(true); - dialog_->shapeLL_P->setChecked(false); - dialog_->shapeLR_P->setChecked(false); - dialog_->drawIcon_P->setChecked(true); - dialog_->_3DImpact_P->setValue(20); - dialog_->LineImpact_P->setValue(30); - dialog_->borderSize_P->setValue(0); - - dialog_->activeColor1_B->setColor(TQColor(210,210,210)); - dialog_->inactiveColor1_B->setColor(TQColor(200,200,200)); - dialog_->activeColor2_B->setColor(TQColor(150,150,150)); - dialog_->inactiveColor2_B->setColor(TQColor(140,140,140)); - dialog_->buttonStyle_B->setCurrentItem(0); - dialog_->titleeffect_B->setCurrentItem(4); - dialog_->i_titleeffect_B->setCurrentItem(4); - dialog_->shapeUL_B->setChecked(true); - dialog_->shapeUR_B->setChecked(true); - dialog_->shapeLL_B->setChecked(false); - dialog_->shapeLR_B->setChecked(false); - dialog_->drawIcon_B->setChecked(true); - dialog_->_3DImpact_B->setValue(20); - dialog_->LineImpact_B->setValue(0); - dialog_->borderSize_B->setValue(6); - - dialog_->activeColor1_T->setColor(TQColor(238,238,238)); - dialog_->activeColor2_T->setColor(TQColor(211,208,211)); - dialog_->buttonStyle_T->setCurrentItem(0); - dialog_->shapeUL_T->setChecked(true); - dialog_->shapeUR_T->setChecked(true); - dialog_->shapeLL_T->setChecked(false); - dialog_->shapeLR_T->setChecked(false); - dialog_->drawIcon_T->setChecked(true); - dialog_->_3DImpact_T->setValue(20); - dialog_->borderSize_T->setValue(0); - - dialog_->activeColor1_S->setColor(TQColor(250,250,250)); - dialog_->inactiveColor1_S->setColor(TQColor(230,230,230)); - dialog_->activeColor2_S->setColor(TQColor(230,230,230)); - dialog_->inactiveColor2_S->setColor(TQColor(250,250,250)); - dialog_->buttonStyle_S->setCurrentItem(0); - dialog_->titleeffect_S->setCurrentItem(0); - dialog_->i_titleeffect_S->setCurrentItem(0); - dialog_->shapeUL_S->setChecked(true); - dialog_->shapeUR_S->setChecked(true); - dialog_->shapeLL_S->setChecked(false); - dialog_->shapeLR_S->setChecked(false); - dialog_->drawIcon_S->setChecked(true); - dialog_->_3DImpact_S->setValue(20); - dialog_->LineImpact_S->setValue(30); - dialog_->borderSize_S->setValue(0); - -// buttonDialog_->defaults(); - - -} - -enum ColorPresets{Aqua = 0, Graphite, GraphiteDark, NUMBEROFCOLORS}; - -const char * presetColorName[NUMBEROFCOLORS] = {"Aqua", "Graphite", "Graphite (Dark)" }; - -typedef int ColorTable[10][3]; - -const int aquaPreset[10][3] = {{255,255,255},{200,85,70},{230,155,40},{121,180,54},{74,140,242},{0,0,0},{74,140,242},{74,140,242},{74,140,242},{74,140,242}}; -const int graphitePreset[10][3] = {{255,255,255},{130,170,190},{130,170,190},{130,170,190},{130,170,190},{0,0,0},{130,170,190},{130,170,190},{130,170,190},{130,170,190}}; -const int graphiteDarkPreset[10][3] = {{255,255,255},{103,118,134},{103,118,134},{103,118,134},{103,118,134},{0,0,0},{103,118,134},{103,118,134},{103,118,134},{103,118,134}}; -const ColorTable* presetColors[NUMBEROFCOLORS] = {&aquaPreset, &graphitePreset, &graphiteDarkPreset}; - - -ButtonColors::ButtonColors(TQWidget *parent, const char * name) : TQDialog(parent, name){ - save = false; - layout = new TQGridLayout(this,2,2,11,6, "Grid"); - buttonLayout = new TQVBoxLayout(0,0,6); - - TQPixmap tmpPix = TQPixmap(uic_findImage("preview")); - inactiveButton = new AquariusButton(tmpPix,this, "Inactive Button"); - buttonLayout->addWidget(inactiveButton); - closeButton = new AquariusButton(tmpPix,this, "Close Button"); - buttonLayout->addWidget(closeButton); - minButton = new AquariusButton(tmpPix,this, "Minimize Button"); - buttonLayout->addWidget(minButton); - maxButton = new AquariusButton(tmpPix,this, "Maximize Button"); - buttonLayout->addWidget(maxButton); - stickyButton = new AquariusButton(tmpPix,this, "Sticky Button"); - buttonLayout->addWidget(stickyButton); - aboveButton = new AquariusButton(tmpPix,this, "Above Button"); - buttonLayout->addWidget(aboveButton); - behindButton = new AquariusButton(tmpPix,this, "Behind Button"); - buttonLayout->addWidget(behindButton); - shadeButton = new AquariusButton(tmpPix,this, "Shade Button"); - buttonLayout->addWidget(shadeButton); - tmpPix = TQPixmap(uic_findImage("preview-menu")); - menuButton = new AquariusButton(tmpPix,this, "Menu Button"); - buttonLayout->addWidget(menuButton); - tmpPix = TQPixmap(uic_findImage("icon_help")); - helpButton = new AquariusButton(tmpPix,this, "Help Button"); - buttonLayout->addWidget(helpButton); - - - twoButts = new TQHBoxLayout(0,0,6); - presets_ = new TQComboBox(this); - for (int i = 0; i < NUMBEROFCOLORS; i++) - presets_->insertItem ( presetColorName[i], i ); - twoButts->addWidget(presets_); - cancel = new TQPushButton("Cancel", this); - cancel->setDefault( true ); - twoButts->addWidget(cancel); - twoButts->addStretch(); - layout->addLayout(twoButts,1,0); - ok = new TQPushButton("OK", this); - layout->addWidget(ok,1,1); - - layout->addLayout(buttonLayout,0,1); - - pickerLayout = new TQVBoxLayout(0,0,6,0); - - indicator = new TQLabel(inactiveButton->name(), this); - indicator->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter | TQt::ExpandTabs); - TQFont tmpFont = font(); - tmpFont.setBold( true ); - tmpFont.setPointSize( 24 ); - indicator->setFont(tmpFont); - pickerLayout->addWidget(indicator); - - inactiveColor = new ColorPicker(this); - pickerLayout->addWidget(inactiveColor); - currentPicker = inactiveColor; - closeColor = new ColorPicker(this); - pickerLayout->addWidget(closeColor); - closeColor->hide(); - minColor = new ColorPicker(this); - pickerLayout->addWidget(minColor); - minColor->hide(); - maxColor = new ColorPicker(this); - pickerLayout->addWidget(maxColor); - maxColor->hide(); - menuColor = new ColorPicker(this); - pickerLayout->addWidget(menuColor); - menuColor->hide(); - helpColor = new ColorPicker(this); - pickerLayout->addWidget(helpColor); - helpColor->hide(); - stickyColor = new ColorPicker(this); - pickerLayout->addWidget(stickyColor); - stickyColor->hide(); - aboveColor = new ColorPicker(this); - pickerLayout->addWidget(aboveColor); - aboveColor->hide(); - behindColor = new ColorPicker(this); - pickerLayout->addWidget(behindColor); - behindColor->hide(); - shadeColor = new ColorPicker(this); - pickerLayout->addWidget(shadeColor); - shadeColor->hide(); - - indicator->lower(); - - layout->addLayout(pickerLayout,0,0); - - resize( TQSize(485, 177).expandedTo(minimumSizeHint()) ); - clearWState( WState_Polished ); - - connect(presets_,SIGNAL(activated(int)), this, SLOT(setColorGroup(int))); - connect(ok, SIGNAL(clicked()), this, SLOT(setSave())); - connect(ok, SIGNAL(clicked()), this, SLOT(close()) ); - connect(ok, SIGNAL(clicked()), this, SLOT(init()) ); - connect(cancel, SIGNAL(clicked()), this, SLOT(close()) ); - connect(cancel, SIGNAL(clicked()), this, SLOT(reset()) ); - - connect(inactiveButton, SIGNAL(clicked()), this, SLOT(activateInactive()) ); - connect(closeButton, SIGNAL(clicked()), this, SLOT(activateClose()) ); - connect(minButton, SIGNAL(clicked()), this, SLOT(activateMin()) ); - connect(maxButton, SIGNAL(clicked()), this, SLOT(activateMax()) ); - connect(menuButton, SIGNAL(clicked()), this, SLOT(activateMenu()) ); - connect(helpButton, SIGNAL(clicked()), this, SLOT(activateHelp()) ); - connect(stickyButton, SIGNAL(clicked()), this, SLOT(activateSticky()) ); - connect(aboveButton, SIGNAL(clicked()), this, SLOT(activateAbove()) ); - connect(behindButton, SIGNAL(clicked()), this, SLOT(activateBehind()) ); - connect(shadeButton, SIGNAL(clicked()), this, SLOT(activateShade()) ); - - connect(inactiveColor, SIGNAL(colorChanged(TQColor)), inactiveButton, SLOT(setColor(TQColor)) ); - connect(closeColor, SIGNAL(colorChanged(TQColor)), closeButton, SLOT(setColor(TQColor)) ); - connect(minColor, SIGNAL(colorChanged(TQColor)), minButton, SLOT(setColor(TQColor)) ); - connect(maxColor, SIGNAL(colorChanged(TQColor)), maxButton, SLOT(setColor(TQColor)) ); - connect(menuColor, SIGNAL(colorChanged(TQColor)), menuButton, SLOT(setColor(TQColor)) ); - connect(helpColor, SIGNAL(colorChanged(TQColor)), helpButton, SLOT(setColor(TQColor)) ); - connect(stickyColor, SIGNAL(colorChanged(TQColor)), stickyButton, SLOT(setColor(TQColor)) ); - connect(aboveColor, SIGNAL(colorChanged(TQColor)), aboveButton, SLOT(setColor(TQColor)) ); - connect(behindColor, SIGNAL(colorChanged(TQColor)), behindButton, SLOT(setColor(TQColor)) ); - connect(shadeColor, SIGNAL(colorChanged(TQColor)), shadeButton, SLOT(setColor(TQColor)) ); - -} - -ButtonColors::~ButtonColors(){ -} - -void ButtonColors::setColorGroup(int i){ - inactiveColor->setColor(TQColor((*presetColors[i])[0][0],(*presetColors[i])[0][1],(*presetColors[i])[0][2]).rgb()); - closeColor->setColor(TQColor((*presetColors[i])[1][0],(*presetColors[i])[1][1],(*presetColors[i])[1][2]).rgb()); - minColor->setColor(TQColor((*presetColors[i])[2][0],(*presetColors[i])[2][1],(*presetColors[i])[2][2]).rgb()); - maxColor->setColor(TQColor((*presetColors[i])[3][0],(*presetColors[i])[3][1],(*presetColors[i])[3][2]).rgb()); - menuColor->setColor(TQColor((*presetColors[i])[4][0],(*presetColors[i])[4][1],(*presetColors[i])[4][2]).rgb()); - helpColor->setColor(TQColor((*presetColors[i])[5][0],(*presetColors[i])[5][1],(*presetColors[i])[5][2]).rgb()); - stickyColor->setColor(TQColor((*presetColors[i])[6][0],(*presetColors[i])[6][1],(*presetColors[i])[6][2]).rgb()); - aboveColor->setColor(TQColor((*presetColors[i])[7][0],(*presetColors[i])[7][1],(*presetColors[i])[7][2]).rgb()); - behindColor->setColor(TQColor((*presetColors[i])[8][0],(*presetColors[i])[8][1],(*presetColors[i])[8][2]).rgb()); - shadeColor->setColor(TQColor((*presetColors[i])[9][0],(*presetColors[i])[9][1],(*presetColors[i])[9][2]).rgb()); -} - -void ButtonColors::setPicker(ColorPicker *picker){ - if (currentPicker) currentPicker->hide(); - currentPicker = picker; - currentPicker->show(); -} - -void ButtonColors::activateInactive(){ - setPicker(inactiveColor); - indicator->setText( inactiveButton->name() ); -} -void ButtonColors::activateClose(){ - setPicker(closeColor); - indicator->setText( closeButton->name() ); -} -void ButtonColors::activateMin(){ - setPicker(minColor); - indicator->setText( minButton->name() ); -} -void ButtonColors::activateMax(){ - setPicker(maxColor); - indicator->setText( maxButton->name() ); -} -void ButtonColors::activateMenu(){ - setPicker(menuColor); - indicator->setText( menuButton->name() ); -} -void ButtonColors::activateHelp(){ - setPicker(helpColor); - indicator->setText( helpButton->name() ); -} -void ButtonColors::activateSticky(){ - setPicker(stickyColor); - indicator->setText( stickyButton->name() ); -} -void ButtonColors::activateAbove(){ - setPicker(aboveColor); - indicator->setText( aboveButton->name() ); -} -void ButtonColors::activateBehind(){ - setPicker(behindColor); - indicator->setText( behindButton->name() ); -} -void ButtonColors::activateShade(){ - setPicker(shadeColor); - indicator->setText( shadeButton->name() ); -} - -void ButtonColors::reset(){ - inactiveColor->reset(); - closeColor->reset(); - minColor->reset(); - maxColor->reset(); - menuColor->reset(); - helpColor->reset(); - stickyColor->reset(); - aboveColor->reset(); - behindColor->reset(); - shadeColor->reset(); -} - -void ButtonColors::init(){ - inactiveColor->init(); - closeColor->init(); - minColor->init(); - maxColor->init(); - menuColor->init(); - helpColor->init(); - stickyColor->init(); - aboveColor->init(); - behindColor->init(); - shadeColor->init(); -} - -////////////////////////////////////////////////////////////////////////////// -// Plugin Stuff // -////////////////////////////////////////////////////////////////////////////// - -extern "C" -{ - KDE_EXPORT TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { - return(new BaghiraConfig(config, parent)); - } -} - -#include "baghiraconfig.moc" diff --git a/deco/config/baghiraconfig.cpp b/deco/config/baghiraconfig.cpp new file mode 100644 index 0000000..5d1c14d --- /dev/null +++ b/deco/config/baghiraconfig.cpp @@ -0,0 +1,729 @@ +////////////////////////////////////////////////////////////////////////////// +// baghiraconfig.cpp +// ------------------- +// Config module for Baghira window decoration +// ------------------- +// Copyright (c) 2004 Thomas Lübking +// Please see the header file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "baghiraconfig.h" +#include "configdialog.h" +#include "pixmaps.h" + +////////////////////////////////////////////////////////////////////////////// +// BaghiraConfig Class // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// BaghiraConfig() +// ------------- +// Constructor + +BaghiraConfig::BaghiraConfig(TDEConfig*, TQWidget* parent) + : TQObject(parent), /*config_(0),*/ dialog_(0) +{ +// config_ = new TDEConfig("baghirarc"); +// config_ = new TQSettings; +// config_->beginGroup("/baghira/Deco"); + TDEGlobal::locale()->insertCatalogue("twin_baghira_config"); + + dialog_ = new ConfigDialog(parent); + buttonDialog_ = new ButtonColors(parent, "Button Colors"); + load(0L); + + dialog_->show(); + + connect(dialog_->ButtonColorConfig, SIGNAL(clicked()), buttonDialog_, SLOT(exec())); + connect(buttonDialog_->ok, SIGNAL(clicked()), SIGNAL(changed())); + + // connections + connect(dialog_->titlealign, SIGNAL(clicked(int)), SIGNAL(changed())); + connect(dialog_->drawComicFrame, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->addAutoSpacing, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->allowEasyClosing, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->ResizeGrip, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->maxResizable, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->fullSpec, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->noModalDeco, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->delAppname, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->defaultMode, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->minTH, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_T, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_T, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_T, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->_3DImpact_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); +// config_->endGroup(); + +} + +////////////////////////////////////////////////////////////////////////////// +// ~BaghiraConfig() +// -------------- +// Destructor + +BaghiraConfig::~BaghiraConfig() +{ + if (dialog_) delete dialog_; +// if (config_) delete config_; +} + +////////////////////////////////////////////////////////////////////////////// +// load() +// ------ +// Load configuration data + +void BaghiraConfig::load(TDEConfig*) +{ + TQSettings *config_ = new TQSettings; + config_->beginGroup("/baghira/Deco"); + + TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign-> + child((const char *)value.latin1()); + if (button) button->setChecked(true); + + dialog_->minTH->setValue(config_->readNumEntry("minimumTitleHeight",18)); + dialog_->ResizeGrip->setChecked(config_->readBoolEntry("ResizeGrip",false)); + dialog_->allowEasyClosing->setChecked(config_->readBoolEntry("allowEasyClosing",false)); + dialog_->drawComicFrame->setChecked(config_->readBoolEntry("DrawComicFrame",false)); + dialog_->maxResizable->setChecked(config_->readBoolEntry("MaxResizable",false)); + dialog_->fullSpec->setChecked(config_->readBoolEntry("FullSpec",false)); + dialog_->addAutoSpacing->setChecked(config_->readBoolEntry("AddAutoSpacing",true)); + dialog_->defaultMode->setCurrentItem(config_->readNumEntry("defaultMode",1)); + dialog_->noModalDeco->setChecked(config_->readBoolEntry("NoModalDeco",false)); + dialog_->delAppname->setChecked(config_->readBoolEntry("RemoveAppname",false)); + + dialog_->activeColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_1",TQColor(255,255,255).rgb()))); + dialog_->inactiveColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_1",TQColor(204,214,230).rgb()))); + dialog_->activeColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_1",TQColor(238,234,238).rgb()))); + dialog_->inactiveColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_1",TQColor(194,196,211).rgb()))); + dialog_->buttonStyle_J->setCurrentItem(config_->readNumEntry("ButtonStyle_1",1)); + dialog_->titleeffect_J->setCurrentItem(config_->readNumEntry("TitleEffect_1", 1)); + dialog_->i_titleeffect_J->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_1", 1)); + dialog_->shapeUL_J->setChecked(config_->readBoolEntry("ShapeUL_1",true)); + dialog_->shapeUR_J->setChecked(config_->readBoolEntry("ShapeUR_1",true)); + dialog_->shapeLL_J->setChecked(config_->readBoolEntry("ShapeLL_1",false)); + dialog_->shapeLR_J->setChecked(config_->readBoolEntry("ShapeLR_1",false)); + dialog_->drawIcon_J->setChecked(config_->readBoolEntry("drawIcon_1",true)); + dialog_->_3DImpact_J->setValue(config_->readNumEntry("3DImpact_1",20)); + dialog_->LineImpact_J->setValue(config_->readNumEntry("LineImpact_1",40)); + dialog_->borderSize_J->setValue(config_->readNumEntry("BorderSize_1",0)); + + dialog_->activeColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_2",TQColor(238,238,238).rgb()))); + dialog_->inactiveColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_2",TQColor(246,242,246).rgb()))); + dialog_->activeColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_2",TQColor(205,202,205).rgb()))); + dialog_->inactiveColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_2",TQColor(238,238,238).rgb()))); + dialog_->buttonStyle_P->setCurrentItem(config_->readNumEntry("ButtonStyle_2",0)); + dialog_->titleeffect_P->setCurrentItem(config_->readNumEntry("TitleEffect_2", 0)); + dialog_->i_titleeffect_P->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_2", 0)); + dialog_->shapeUL_P->setChecked(config_->readBoolEntry("ShapeUL_2",true)); + dialog_->shapeUR_P->setChecked(config_->readBoolEntry("ShapeUR_2",true)); + dialog_->shapeLL_P->setChecked(config_->readBoolEntry("ShapeLL_2",false)); + dialog_->shapeLR_P->setChecked(config_->readBoolEntry("ShapeLR_2",false)); + dialog_->drawIcon_P->setChecked(config_->readBoolEntry("drawIcon_2",true)); + dialog_->_3DImpact_P->setValue(config_->readNumEntry("3DImpact_2",20)); + dialog_->LineImpact_P->setValue(config_->readNumEntry("LineImpact_2",40)); + dialog_->borderSize_P->setValue(config_->readNumEntry("BorderSize_2",0)); + + dialog_->activeColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_3",TQColor(202,202,202).rgb()))); + dialog_->inactiveColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_3",TQColor(200,200,200).rgb()))); + dialog_->activeColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_3",TQColor(150,150,150).rgb()))); + dialog_->inactiveColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_3",TQColor(150,150,150).rgb()))); + dialog_->buttonStyle_B->setCurrentItem(config_->readNumEntry("ButtonStyle_3",0)); + dialog_->titleeffect_B->setCurrentItem(config_->readNumEntry("TitleEffect_3", 4)); + dialog_->i_titleeffect_B->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_3", 4)); + dialog_->shapeUL_B->setChecked(config_->readBoolEntry("ShapeUL_3",true)); + dialog_->shapeUR_B->setChecked(config_->readBoolEntry("ShapeUR_3",true)); + dialog_->shapeLL_B->setChecked(config_->readBoolEntry("ShapeLL_3",true)); + dialog_->shapeLR_B->setChecked(config_->readBoolEntry("ShapeLR_3",true)); + dialog_->drawIcon_B->setChecked(config_->readBoolEntry("drawIcon_3",true)); + dialog_->_3DImpact_B->setValue(config_->readNumEntry("3DImpact_3",20)); + dialog_->LineImpact_B->setValue(config_->readNumEntry("LineImpact_3",0)); + dialog_->borderSize_B->setValue(config_->readNumEntry("BorderSize_3",6)); + + dialog_->activeColor1_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_4",TQColor(238,238,238).rgb()))); + dialog_->activeColor2_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_4",TQColor(205,202,205).rgb()))); + dialog_->buttonStyle_T->setCurrentItem(config_->readNumEntry("ButtonStyle_4",0)); + dialog_->shapeUL_T->setChecked(config_->readBoolEntry("ShapeUL_4",true)); + dialog_->shapeUR_T->setChecked(config_->readBoolEntry("ShapeUR_4",true)); + dialog_->shapeLL_T->setChecked(config_->readBoolEntry("ShapeLL_4",false)); + dialog_->shapeLR_T->setChecked(config_->readBoolEntry("ShapeLR_4",false)); + dialog_->drawIcon_T->setChecked(config_->readBoolEntry("drawIcon_4",true)); + dialog_->_3DImpact_T->setValue(config_->readNumEntry("3DImpact_4",20)); + dialog_->borderSize_T->setValue(config_->readNumEntry("BorderSize_4",0)); + + dialog_->activeColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_5",TQColor(250,250,250).rgb()))); + dialog_->inactiveColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_5",TQColor(230,230,230).rgb()))); + dialog_->activeColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_5",TQColor(230,230,230).rgb()))); + dialog_->inactiveColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_5",TQColor(250,250,250).rgb()))); + dialog_->buttonStyle_S->setCurrentItem(config_->readNumEntry("ButtonStyle_5",0)); + dialog_->titleeffect_S->setCurrentItem(config_->readNumEntry("TitleEffect_5", 0)); + dialog_->i_titleeffect_S->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_5", 0)); + dialog_->shapeUL_S->setChecked(config_->readBoolEntry("ShapeUL_5",true)); + dialog_->shapeUR_S->setChecked(config_->readBoolEntry("ShapeUR_5",true)); + dialog_->shapeLL_S->setChecked(config_->readBoolEntry("ShapeLL_5",false)); + dialog_->shapeLR_S->setChecked(config_->readBoolEntry("ShapeLR_5",false)); + dialog_->drawIcon_S->setChecked(config_->readBoolEntry("drawIcon_5",true)); + dialog_->_3DImpact_S->setValue(config_->readNumEntry("3DImpact_5",20)); + dialog_->LineImpact_S->setValue(config_->readNumEntry("LineImpact_5",30)); + dialog_->borderSize_S->setValue(config_->readNumEntry("BorderSize_5",0)); + + buttonDialog_->inactiveColor->setColor(TQColor((unsigned int)config_->readNumEntry("InactiveButtonColor", TQColor(255,255,255).rgb()))); + buttonDialog_->closeColor->setColor(TQColor((unsigned int)config_->readNumEntry("CloseButtonColor", TQColor(200,85,70).rgb()))); + buttonDialog_->minColor->setColor(TQColor((unsigned int)config_->readNumEntry("MinButtonColor", TQColor(230,155,40).rgb()))); + buttonDialog_-> maxColor->setColor(TQColor((unsigned int)config_->readNumEntry("MaxButtonColor", TQColor(121,180,54).rgb()))); + buttonDialog_->menuColor->setColor(TQColor((unsigned int)config_->readNumEntry("MenuButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->helpColor->setColor(TQColor((unsigned int)config_->readNumEntry("HelpButtonColor", TQColor(0,0,0).rgb()))); + buttonDialog_->stickyColor->setColor(TQColor((unsigned int)config_->readNumEntry("StickyButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->aboveColor->setColor(TQColor((unsigned int)config_->readNumEntry("AboveButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->behindColor->setColor(TQColor((unsigned int)config_->readNumEntry("BehindButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->shadeColor->setColor(TQColor((unsigned int)config_->readNumEntry("ShadeButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->init(); + config_->endGroup(); + delete config_; + +} + +////////////////////////////////////////////////////////////////////////////// +// save() +// ------ +// Save configuration data + +void BaghiraConfig::save(TDEConfig*) +{ + TQSettings *config_ = new TQSettings; + config_->beginGroup("/baghira/Deco"); + + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); + if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); + config_->writeEntry("DrawComicFrame", dialog_->drawComicFrame->isChecked()); + config_->writeEntry("AddAutoSpacing", dialog_->addAutoSpacing->isChecked()); + config_->writeEntry("ResizeGrip", dialog_->ResizeGrip->isChecked()); + config_->writeEntry("allowEasyClosing", dialog_->allowEasyClosing->isChecked()); + config_->writeEntry("MaxResizable", dialog_->maxResizable->isChecked()); + config_->writeEntry("FullSpec", dialog_->fullSpec->isChecked()); + config_->writeEntry("defaultMode", dialog_->defaultMode->currentItem()); + config_->writeEntry("minimumTitleHeight", dialog_->minTH->value()); + config_->writeEntry("NoModalDeco", dialog_->noModalDeco->isChecked()); + config_->writeEntry("RemoveAppname", dialog_->delAppname->isChecked()); + + config_->writeEntry("activeColor1_1", (int)dialog_->activeColor1_J->color().rgb()); + config_->writeEntry("activeColor2_1", (int)dialog_->activeColor2_J->color().rgb()); + config_->writeEntry("inactiveColor1_1", (int)dialog_->inactiveColor1_J->color().rgb()); + config_->writeEntry("inactiveColor2_1", (int)dialog_->inactiveColor2_J->color().rgb()); + config_->writeEntry("ButtonStyle_1", dialog_->buttonStyle_J->currentItem()); + config_->writeEntry("TitleEffect_1", dialog_->titleeffect_J->currentItem()); + config_->writeEntry("inactiveTitleEffect_1", dialog_->i_titleeffect_J->currentItem()); + config_->writeEntry("ShapeUL_1", dialog_->shapeUL_J->isChecked()); + config_->writeEntry("ShapeUR_1", dialog_->shapeUR_J->isChecked()); + config_->writeEntry("ShapeLL_1", dialog_->shapeLL_J->isChecked()); + config_->writeEntry("ShapeLR_1", dialog_->shapeLR_J->isChecked()); + config_->writeEntry("drawIcon_1", dialog_->drawIcon_J->isChecked()); + config_->writeEntry("3DImpact_1", dialog_->_3DImpact_J->value()); + config_->writeEntry("LineImpact_1", dialog_->LineImpact_J->value()); + config_->writeEntry("BorderSize_1", dialog_->borderSize_J->value()); + + config_->writeEntry("activeColor1_2", (int)dialog_->activeColor1_P->color().rgb()); + config_->writeEntry("activeColor2_2", (int)dialog_->activeColor2_P->color().rgb()); + config_->writeEntry("inactiveColor1_2", (int)dialog_->inactiveColor1_P->color().rgb()); + config_->writeEntry("inactiveColor2_2", (int)dialog_->inactiveColor2_P->color().rgb()); + config_->writeEntry("ButtonStyle_2", dialog_->buttonStyle_P->currentItem()); + config_->writeEntry("TitleEffect_2", dialog_->titleeffect_P->currentItem()); + config_->writeEntry("inactiveTitleEffect_2", dialog_->i_titleeffect_P->currentItem()); + config_->writeEntry("ShapeUL_2", dialog_->shapeUL_P->isChecked()); + config_->writeEntry("ShapeUR_2", dialog_->shapeUR_P->isChecked()); + config_->writeEntry("ShapeLL_2", dialog_->shapeLL_P->isChecked()); + config_->writeEntry("ShapeLR_2", dialog_->shapeLR_P->isChecked()); + config_->writeEntry("drawIcon_2", dialog_->drawIcon_P->isChecked()); + config_->writeEntry("3DImpact_2", dialog_->_3DImpact_P->value()); + config_->writeEntry("LineImpact_2", dialog_->LineImpact_P->value()); + config_->writeEntry("BorderSize_2", dialog_->borderSize_P->value()); + + config_->writeEntry("activeColor1_3", (int)dialog_->activeColor1_B->color().rgb()); + config_->writeEntry("activeColor2_3", (int)dialog_->activeColor2_B->color().rgb()); + config_->writeEntry("inactiveColor1_3", (int)dialog_->inactiveColor1_B->color().rgb()); + config_->writeEntry("inactiveColor2_3", (int)dialog_->inactiveColor2_B->color().rgb()); + config_->writeEntry("ButtonStyle_3", dialog_->buttonStyle_B->currentItem()); + config_->writeEntry("TitleEffect_3", dialog_->titleeffect_B->currentItem()); + config_->writeEntry("inactiveTitleEffect_3", dialog_->i_titleeffect_B->currentItem()); + config_->writeEntry("ShapeUL_3", dialog_->shapeUL_B->isChecked()); + config_->writeEntry("ShapeUR_3", dialog_->shapeUR_B->isChecked()); + config_->writeEntry("ShapeLL_3", dialog_->shapeLL_B->isChecked()); + config_->writeEntry("ShapeLR_3", dialog_->shapeLR_B->isChecked()); + config_->writeEntry("drawIcon_3", dialog_->drawIcon_B->isChecked()); + config_->writeEntry("3DImpact_3", dialog_->_3DImpact_B->value()); + config_->writeEntry("LineImpact_3", dialog_->LineImpact_B->value()); + config_->writeEntry("BorderSize_3", dialog_->borderSize_B->value()); + + config_->writeEntry("activeColor1_4", (int)dialog_->activeColor1_T->color().rgb()); + config_->writeEntry("activeColor2_4", (int)dialog_->activeColor2_T->color().rgb()); + config_->writeEntry("ButtonStyle_4", dialog_->buttonStyle_T->currentItem()); + config_->writeEntry("ShapeUL_4", dialog_->shapeUL_T->isChecked()); + config_->writeEntry("ShapeUR_4", dialog_->shapeUR_T->isChecked()); + config_->writeEntry("ShapeLL_4", dialog_->shapeLL_T->isChecked()); + config_->writeEntry("ShapeLR_4", dialog_->shapeLR_T->isChecked()); + config_->writeEntry("drawIcon_4", dialog_->drawIcon_T->isChecked()); + config_->writeEntry("3DImpact_4", dialog_->_3DImpact_T->value()); + config_->writeEntry("BorderSize_4", dialog_->borderSize_T->value()); + + config_->writeEntry("activeColor1_5", (int)dialog_->activeColor1_S->color().rgb()); + config_->writeEntry("activeColor2_5", (int)dialog_->activeColor2_S->color().rgb()); + config_->writeEntry("inactiveColor1_5", (int)dialog_->inactiveColor1_S->color().rgb()); + config_->writeEntry("inactiveColor2_5", (int)dialog_->inactiveColor2_S->color().rgb()); + config_->writeEntry("ButtonStyle_5", dialog_->buttonStyle_S->currentItem()); + config_->writeEntry("TitleEffect_5", dialog_->titleeffect_S->currentItem()); + config_->writeEntry("inactiveTitleEffect_5", dialog_->i_titleeffect_S->currentItem()); + config_->writeEntry("ShapeUL_5", dialog_->shapeUL_S->isChecked()); + config_->writeEntry("ShapeUR_5", dialog_->shapeUR_S->isChecked()); + config_->writeEntry("ShapeLL_5", dialog_->shapeLL_S->isChecked()); + config_->writeEntry("ShapeLR_5", dialog_->shapeLR_S->isChecked()); + config_->writeEntry("drawIcon_5", dialog_->drawIcon_S->isChecked()); + config_->writeEntry("3DImpact_5", dialog_->_3DImpact_S->value()); + config_->writeEntry("LineImpact_5", dialog_->LineImpact_S->value()); + config_->writeEntry("BorderSize_5", dialog_->borderSize_S->value()); + + if (buttonDialog_->save){ + config_->writeEntry("InactiveButtonColor", (int)buttonDialog_->inactiveColor->Color().rgb()); + config_->writeEntry("CloseButtonColor", (int)buttonDialog_->closeColor->Color().rgb()); + config_->writeEntry("MinButtonColor", (int)buttonDialog_->minColor->Color().rgb()); + config_->writeEntry("MaxButtonColor", (int)buttonDialog_->maxColor->Color().rgb()); + config_->writeEntry("MenuButtonColor", (int)buttonDialog_->menuColor->Color().rgb()); + config_->writeEntry("HelpButtonColor", (int)buttonDialog_->helpColor->Color().rgb()); + config_->writeEntry("StickyButtonColor", (int)buttonDialog_->stickyColor->Color().rgb()); + config_->writeEntry("AboveButtonColor", (int)buttonDialog_->aboveColor->Color().rgb()); + config_->writeEntry("BehindButtonColor", (int)buttonDialog_->behindColor->Color().rgb()); + config_->writeEntry("ShadeButtonColor", (int)buttonDialog_->shadeColor->Color().rgb()); + } + config_->endGroup(); + delete config_; + +// config_->sync(); +} + +////////////////////////////////////////////////////////////////////////////// +// defaults() +// ---------- +// Set configuration defaults + +void BaghiraConfig::defaults() +{ + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); + if (button) button->setChecked(true); + dialog_->allowEasyClosing->setChecked(false); + dialog_->minTH->setValue(22); + dialog_->ResizeGrip->setChecked(false); + dialog_->drawComicFrame->setChecked(false); + dialog_->addAutoSpacing->setChecked(true); + dialog_->maxResizable->setChecked(false); + dialog_->fullSpec->setChecked(false); + dialog_->defaultMode->setCurrentItem(1); + dialog_->noModalDeco->setChecked(false); + dialog_->delAppname->setChecked(false); + + dialog_->activeColor1_J->setColor(TQColor(255,255,255)); + dialog_->inactiveColor1_J->setColor(TQColor(204,214,230)); + dialog_->activeColor2_J->setColor(TQColor(238,234,238)); + dialog_->inactiveColor2_J->setColor(TQColor(194,196,211)); + dialog_->buttonStyle_J->setCurrentItem(1); + dialog_->titleeffect_J->setCurrentItem(1); + dialog_->i_titleeffect_J->setCurrentItem(1); + dialog_->shapeUL_J->setChecked(true); + dialog_->shapeUR_J->setChecked(true); + dialog_->shapeLL_J->setChecked(false); + dialog_->shapeLR_J->setChecked(false); + dialog_->drawIcon_J->setChecked(true); + dialog_->_3DImpact_J->setValue(20); + dialog_->LineImpact_J->setValue(40); + dialog_->borderSize_J->setValue(0); + + dialog_->activeColor1_P->setColor(TQColor(238,238,238)); + dialog_->inactiveColor1_P->setColor(TQColor(246,242,246)); + dialog_->activeColor2_P->setColor(TQColor(205,202,205)); + dialog_->inactiveColor2_P->setColor(TQColor(238,238,238)); + dialog_->buttonStyle_P->setCurrentItem(0); + dialog_->titleeffect_P->setCurrentItem(0); + dialog_->i_titleeffect_P->setCurrentItem(0); + dialog_->shapeUL_P->setChecked(true); + dialog_->shapeUR_P->setChecked(true); + dialog_->shapeLL_P->setChecked(false); + dialog_->shapeLR_P->setChecked(false); + dialog_->drawIcon_P->setChecked(true); + dialog_->_3DImpact_P->setValue(20); + dialog_->LineImpact_P->setValue(30); + dialog_->borderSize_P->setValue(0); + + dialog_->activeColor1_B->setColor(TQColor(210,210,210)); + dialog_->inactiveColor1_B->setColor(TQColor(200,200,200)); + dialog_->activeColor2_B->setColor(TQColor(150,150,150)); + dialog_->inactiveColor2_B->setColor(TQColor(140,140,140)); + dialog_->buttonStyle_B->setCurrentItem(0); + dialog_->titleeffect_B->setCurrentItem(4); + dialog_->i_titleeffect_B->setCurrentItem(4); + dialog_->shapeUL_B->setChecked(true); + dialog_->shapeUR_B->setChecked(true); + dialog_->shapeLL_B->setChecked(false); + dialog_->shapeLR_B->setChecked(false); + dialog_->drawIcon_B->setChecked(true); + dialog_->_3DImpact_B->setValue(20); + dialog_->LineImpact_B->setValue(0); + dialog_->borderSize_B->setValue(6); + + dialog_->activeColor1_T->setColor(TQColor(238,238,238)); + dialog_->activeColor2_T->setColor(TQColor(211,208,211)); + dialog_->buttonStyle_T->setCurrentItem(0); + dialog_->shapeUL_T->setChecked(true); + dialog_->shapeUR_T->setChecked(true); + dialog_->shapeLL_T->setChecked(false); + dialog_->shapeLR_T->setChecked(false); + dialog_->drawIcon_T->setChecked(true); + dialog_->_3DImpact_T->setValue(20); + dialog_->borderSize_T->setValue(0); + + dialog_->activeColor1_S->setColor(TQColor(250,250,250)); + dialog_->inactiveColor1_S->setColor(TQColor(230,230,230)); + dialog_->activeColor2_S->setColor(TQColor(230,230,230)); + dialog_->inactiveColor2_S->setColor(TQColor(250,250,250)); + dialog_->buttonStyle_S->setCurrentItem(0); + dialog_->titleeffect_S->setCurrentItem(0); + dialog_->i_titleeffect_S->setCurrentItem(0); + dialog_->shapeUL_S->setChecked(true); + dialog_->shapeUR_S->setChecked(true); + dialog_->shapeLL_S->setChecked(false); + dialog_->shapeLR_S->setChecked(false); + dialog_->drawIcon_S->setChecked(true); + dialog_->_3DImpact_S->setValue(20); + dialog_->LineImpact_S->setValue(30); + dialog_->borderSize_S->setValue(0); + +// buttonDialog_->defaults(); + + +} + +enum ColorPresets{Aqua = 0, Graphite, GraphiteDark, NUMBEROFCOLORS}; + +const char * presetColorName[NUMBEROFCOLORS] = {"Aqua", "Graphite", "Graphite (Dark)" }; + +typedef int ColorTable[10][3]; + +const int aquaPreset[10][3] = {{255,255,255},{200,85,70},{230,155,40},{121,180,54},{74,140,242},{0,0,0},{74,140,242},{74,140,242},{74,140,242},{74,140,242}}; +const int graphitePreset[10][3] = {{255,255,255},{130,170,190},{130,170,190},{130,170,190},{130,170,190},{0,0,0},{130,170,190},{130,170,190},{130,170,190},{130,170,190}}; +const int graphiteDarkPreset[10][3] = {{255,255,255},{103,118,134},{103,118,134},{103,118,134},{103,118,134},{0,0,0},{103,118,134},{103,118,134},{103,118,134},{103,118,134}}; +const ColorTable* presetColors[NUMBEROFCOLORS] = {&aquaPreset, &graphitePreset, &graphiteDarkPreset}; + + +ButtonColors::ButtonColors(TQWidget *parent, const char * name) : TQDialog(parent, name){ + save = false; + layout = new TQGridLayout(this,2,2,11,6, "Grid"); + buttonLayout = new TQVBoxLayout(0,0,6); + + TQPixmap tmpPix = TQPixmap(uic_findImage("preview")); + inactiveButton = new AquariusButton(tmpPix,this, "Inactive Button"); + buttonLayout->addWidget(inactiveButton); + closeButton = new AquariusButton(tmpPix,this, "Close Button"); + buttonLayout->addWidget(closeButton); + minButton = new AquariusButton(tmpPix,this, "Minimize Button"); + buttonLayout->addWidget(minButton); + maxButton = new AquariusButton(tmpPix,this, "Maximize Button"); + buttonLayout->addWidget(maxButton); + stickyButton = new AquariusButton(tmpPix,this, "Sticky Button"); + buttonLayout->addWidget(stickyButton); + aboveButton = new AquariusButton(tmpPix,this, "Above Button"); + buttonLayout->addWidget(aboveButton); + behindButton = new AquariusButton(tmpPix,this, "Behind Button"); + buttonLayout->addWidget(behindButton); + shadeButton = new AquariusButton(tmpPix,this, "Shade Button"); + buttonLayout->addWidget(shadeButton); + tmpPix = TQPixmap(uic_findImage("preview-menu")); + menuButton = new AquariusButton(tmpPix,this, "Menu Button"); + buttonLayout->addWidget(menuButton); + tmpPix = TQPixmap(uic_findImage("icon_help")); + helpButton = new AquariusButton(tmpPix,this, "Help Button"); + buttonLayout->addWidget(helpButton); + + + twoButts = new TQHBoxLayout(0,0,6); + presets_ = new TQComboBox(this); + for (int i = 0; i < NUMBEROFCOLORS; i++) + presets_->insertItem ( presetColorName[i], i ); + twoButts->addWidget(presets_); + cancel = new TQPushButton("Cancel", this); + cancel->setDefault( true ); + twoButts->addWidget(cancel); + twoButts->addStretch(); + layout->addLayout(twoButts,1,0); + ok = new TQPushButton("OK", this); + layout->addWidget(ok,1,1); + + layout->addLayout(buttonLayout,0,1); + + pickerLayout = new TQVBoxLayout(0,0,6,0); + + indicator = new TQLabel(inactiveButton->name(), this); + indicator->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter | TQt::ExpandTabs); + TQFont tmpFont = font(); + tmpFont.setBold( true ); + tmpFont.setPointSize( 24 ); + indicator->setFont(tmpFont); + pickerLayout->addWidget(indicator); + + inactiveColor = new ColorPicker(this); + pickerLayout->addWidget(inactiveColor); + currentPicker = inactiveColor; + closeColor = new ColorPicker(this); + pickerLayout->addWidget(closeColor); + closeColor->hide(); + minColor = new ColorPicker(this); + pickerLayout->addWidget(minColor); + minColor->hide(); + maxColor = new ColorPicker(this); + pickerLayout->addWidget(maxColor); + maxColor->hide(); + menuColor = new ColorPicker(this); + pickerLayout->addWidget(menuColor); + menuColor->hide(); + helpColor = new ColorPicker(this); + pickerLayout->addWidget(helpColor); + helpColor->hide(); + stickyColor = new ColorPicker(this); + pickerLayout->addWidget(stickyColor); + stickyColor->hide(); + aboveColor = new ColorPicker(this); + pickerLayout->addWidget(aboveColor); + aboveColor->hide(); + behindColor = new ColorPicker(this); + pickerLayout->addWidget(behindColor); + behindColor->hide(); + shadeColor = new ColorPicker(this); + pickerLayout->addWidget(shadeColor); + shadeColor->hide(); + + indicator->lower(); + + layout->addLayout(pickerLayout,0,0); + + resize( TQSize(485, 177).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); + + connect(presets_,SIGNAL(activated(int)), this, SLOT(setColorGroup(int))); + connect(ok, SIGNAL(clicked()), this, SLOT(setSave())); + connect(ok, SIGNAL(clicked()), this, SLOT(close()) ); + connect(ok, SIGNAL(clicked()), this, SLOT(init()) ); + connect(cancel, SIGNAL(clicked()), this, SLOT(close()) ); + connect(cancel, SIGNAL(clicked()), this, SLOT(reset()) ); + + connect(inactiveButton, SIGNAL(clicked()), this, SLOT(activateInactive()) ); + connect(closeButton, SIGNAL(clicked()), this, SLOT(activateClose()) ); + connect(minButton, SIGNAL(clicked()), this, SLOT(activateMin()) ); + connect(maxButton, SIGNAL(clicked()), this, SLOT(activateMax()) ); + connect(menuButton, SIGNAL(clicked()), this, SLOT(activateMenu()) ); + connect(helpButton, SIGNAL(clicked()), this, SLOT(activateHelp()) ); + connect(stickyButton, SIGNAL(clicked()), this, SLOT(activateSticky()) ); + connect(aboveButton, SIGNAL(clicked()), this, SLOT(activateAbove()) ); + connect(behindButton, SIGNAL(clicked()), this, SLOT(activateBehind()) ); + connect(shadeButton, SIGNAL(clicked()), this, SLOT(activateShade()) ); + + connect(inactiveColor, SIGNAL(colorChanged(TQColor)), inactiveButton, SLOT(setColor(TQColor)) ); + connect(closeColor, SIGNAL(colorChanged(TQColor)), closeButton, SLOT(setColor(TQColor)) ); + connect(minColor, SIGNAL(colorChanged(TQColor)), minButton, SLOT(setColor(TQColor)) ); + connect(maxColor, SIGNAL(colorChanged(TQColor)), maxButton, SLOT(setColor(TQColor)) ); + connect(menuColor, SIGNAL(colorChanged(TQColor)), menuButton, SLOT(setColor(TQColor)) ); + connect(helpColor, SIGNAL(colorChanged(TQColor)), helpButton, SLOT(setColor(TQColor)) ); + connect(stickyColor, SIGNAL(colorChanged(TQColor)), stickyButton, SLOT(setColor(TQColor)) ); + connect(aboveColor, SIGNAL(colorChanged(TQColor)), aboveButton, SLOT(setColor(TQColor)) ); + connect(behindColor, SIGNAL(colorChanged(TQColor)), behindButton, SLOT(setColor(TQColor)) ); + connect(shadeColor, SIGNAL(colorChanged(TQColor)), shadeButton, SLOT(setColor(TQColor)) ); + +} + +ButtonColors::~ButtonColors(){ +} + +void ButtonColors::setColorGroup(int i){ + inactiveColor->setColor(TQColor((*presetColors[i])[0][0],(*presetColors[i])[0][1],(*presetColors[i])[0][2]).rgb()); + closeColor->setColor(TQColor((*presetColors[i])[1][0],(*presetColors[i])[1][1],(*presetColors[i])[1][2]).rgb()); + minColor->setColor(TQColor((*presetColors[i])[2][0],(*presetColors[i])[2][1],(*presetColors[i])[2][2]).rgb()); + maxColor->setColor(TQColor((*presetColors[i])[3][0],(*presetColors[i])[3][1],(*presetColors[i])[3][2]).rgb()); + menuColor->setColor(TQColor((*presetColors[i])[4][0],(*presetColors[i])[4][1],(*presetColors[i])[4][2]).rgb()); + helpColor->setColor(TQColor((*presetColors[i])[5][0],(*presetColors[i])[5][1],(*presetColors[i])[5][2]).rgb()); + stickyColor->setColor(TQColor((*presetColors[i])[6][0],(*presetColors[i])[6][1],(*presetColors[i])[6][2]).rgb()); + aboveColor->setColor(TQColor((*presetColors[i])[7][0],(*presetColors[i])[7][1],(*presetColors[i])[7][2]).rgb()); + behindColor->setColor(TQColor((*presetColors[i])[8][0],(*presetColors[i])[8][1],(*presetColors[i])[8][2]).rgb()); + shadeColor->setColor(TQColor((*presetColors[i])[9][0],(*presetColors[i])[9][1],(*presetColors[i])[9][2]).rgb()); +} + +void ButtonColors::setPicker(ColorPicker *picker){ + if (currentPicker) currentPicker->hide(); + currentPicker = picker; + currentPicker->show(); +} + +void ButtonColors::activateInactive(){ + setPicker(inactiveColor); + indicator->setText( inactiveButton->name() ); +} +void ButtonColors::activateClose(){ + setPicker(closeColor); + indicator->setText( closeButton->name() ); +} +void ButtonColors::activateMin(){ + setPicker(minColor); + indicator->setText( minButton->name() ); +} +void ButtonColors::activateMax(){ + setPicker(maxColor); + indicator->setText( maxButton->name() ); +} +void ButtonColors::activateMenu(){ + setPicker(menuColor); + indicator->setText( menuButton->name() ); +} +void ButtonColors::activateHelp(){ + setPicker(helpColor); + indicator->setText( helpButton->name() ); +} +void ButtonColors::activateSticky(){ + setPicker(stickyColor); + indicator->setText( stickyButton->name() ); +} +void ButtonColors::activateAbove(){ + setPicker(aboveColor); + indicator->setText( aboveButton->name() ); +} +void ButtonColors::activateBehind(){ + setPicker(behindColor); + indicator->setText( behindButton->name() ); +} +void ButtonColors::activateShade(){ + setPicker(shadeColor); + indicator->setText( shadeButton->name() ); +} + +void ButtonColors::reset(){ + inactiveColor->reset(); + closeColor->reset(); + minColor->reset(); + maxColor->reset(); + menuColor->reset(); + helpColor->reset(); + stickyColor->reset(); + aboveColor->reset(); + behindColor->reset(); + shadeColor->reset(); +} + +void ButtonColors::init(){ + inactiveColor->init(); + closeColor->init(); + minColor->init(); + maxColor->init(); + menuColor->init(); + helpColor->init(); + stickyColor->init(); + aboveColor->init(); + behindColor->init(); + shadeColor->init(); +} + +////////////////////////////////////////////////////////////////////////////// +// Plugin Stuff // +////////////////////////////////////////////////////////////////////////////// + +extern "C" +{ + KDE_EXPORT TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { + return(new BaghiraConfig(config, parent)); + } +} + +#include "baghiraconfig.moc" diff --git a/deco/config/baghiraconfig.cpp.new b/deco/config/baghiraconfig.cpp.new new file mode 100644 index 0000000..5f2a29f --- /dev/null +++ b/deco/config/baghiraconfig.cpp.new @@ -0,0 +1,730 @@ +////////////////////////////////////////////////////////////////////////////// +// baghiraconfig.cpp +// ------------------- +// Config module for Baghira window decoration +// ------------------- +// Copyright (c) 2004 Thomas Lübking +// Please see the header file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "baghiraconfig.h" +#include "configdialog.h" +#include "customdecosettings.h" +#include "pixmaps.h" + +////////////////////////////////////////////////////////////////////////////// +// BaghiraConfig Class // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// BaghiraConfig() +// ------------- +// Constructor + +BaghiraConfig::BaghiraConfig(TDEConfig*, TQWidget* parent) + : TQObject(parent), /*config_(0),*/ dialog_(0) +{ +// config_ = new TDEConfig("baghirarc"); +// config_ = new TQSettings; +// config_->beginGroup("/baghira/Deco"); + TDEGlobal::locale()->insertCatalogue("twin_baghira_config"); + + dialog_ = new ConfigDialog(parent); + buttonDialog_ = new ButtonColors(parent, "Button Colors"); + load(0L); + + dialog_->show(); + + connect(dialog_->ButtonColorConfig, SIGNAL(clicked()), buttonDialog_, SLOT(exec())); + connect(buttonDialog_->ok, SIGNAL(clicked()), SIGNAL(changed())); + + // connections + connect(dialog_->titlealign, SIGNAL(clicked(int)), SIGNAL(changed())); + connect(dialog_->drawComicFrame, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->addAutoSpacing, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->allowEasyClosing, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->ResizeGrip, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->maxResizable, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->fullSpec, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->noModalDeco, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->delAppname, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->defaultMode, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->minTH, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_J, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_J, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_J, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_J, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_P, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_P, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_P, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_P, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_B, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_B, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_B, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_B, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_T, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_T, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_T, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_T, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->_3DImpact_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_T, SIGNAL(valueChanged(int)), SIGNAL(changed())); + + connect(dialog_->activeColor1_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->activeColor2_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor1_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->inactiveColor2_S, SIGNAL(clicked()), SIGNAL(changed())); + connect(dialog_->buttonStyle_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->shapeUL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeUR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLL_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->shapeLR_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->drawIcon_S, SIGNAL(toggled(bool)), SIGNAL(changed())); + connect(dialog_->titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->i_titleeffect_S, SIGNAL(activated(int)), SIGNAL(changed())); + connect(dialog_->_3DImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->LineImpact_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); + connect(dialog_->borderSize_S, SIGNAL(valueChanged(int)), SIGNAL(changed())); +// config_->endGroup(); + +} + +////////////////////////////////////////////////////////////////////////////// +// ~BaghiraConfig() +// -------------- +// Destructor + +BaghiraConfig::~BaghiraConfig() +{ + if (dialog_) delete dialog_; +// if (config_) delete config_; +} + +////////////////////////////////////////////////////////////////////////////// +// load() +// ------ +// Load configuration data + +void BaghiraConfig::load(TDEConfig*) +{ + TQSettings *config_ = new TQSettings; + config_->beginGroup("/baghira/Deco"); + + TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign-> + child((const char *)value.latin1()); + if (button) button->setChecked(true); + + dialog_->minTH->setValue(config_->readNumEntry("minimumTitleHeight",18)); + dialog_->ResizeGrip->setChecked(config_->readBoolEntry("ResizeGrip",false)); + dialog_->allowEasyClosing->setChecked(config_->readBoolEntry("allowEasyClosing",false)); + dialog_->drawComicFrame->setChecked(config_->readBoolEntry("DrawComicFrame",false)); + dialog_->maxResizable->setChecked(config_->readBoolEntry("MaxResizable",false)); + dialog_->fullSpec->setChecked(config_->readBoolEntry("FullSpec",false)); + dialog_->addAutoSpacing->setChecked(config_->readBoolEntry("AddAutoSpacing",true)); + dialog_->defaultMode->setCurrentItem(config_->readNumEntry("defaultMode",1)); + dialog_->noModalDeco->setChecked(config_->readBoolEntry("NoModalDeco",false)); + dialog_->delAppname->setChecked(config_->readBoolEntry("RemoveAppname",false)); + + dialog_->activeColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_1",TQColor(255,255,255).rgb()))); + dialog_->inactiveColor1_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_1",TQColor(204,214,230).rgb()))); + dialog_->activeColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_1",TQColor(238,234,238).rgb()))); + dialog_->inactiveColor2_J->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_1",TQColor(194,196,211).rgb()))); + dialog_->buttonStyle_J->setCurrentItem(config_->readNumEntry("ButtonStyle_1",1)); + dialog_->titleeffect_J->setCurrentItem(config_->readNumEntry("TitleEffect_1", 1)); + dialog_->i_titleeffect_J->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_1", 1)); + dialog_->shapeUL_J->setChecked(config_->readBoolEntry("ShapeUL_1",true)); + dialog_->shapeUR_J->setChecked(config_->readBoolEntry("ShapeUR_1",true)); + dialog_->shapeLL_J->setChecked(config_->readBoolEntry("ShapeLL_1",false)); + dialog_->shapeLR_J->setChecked(config_->readBoolEntry("ShapeLR_1",false)); + dialog_->drawIcon_J->setChecked(config_->readBoolEntry("drawIcon_1",true)); + dialog_->_3DImpact_J->setValue(config_->readNumEntry("3DImpact_1",20)); + dialog_->LineImpact_J->setValue(config_->readNumEntry("LineImpact_1",40)); + dialog_->borderSize_J->setValue(config_->readNumEntry("BorderSize_1",0)); + + dialog_->activeColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_2",TQColor(238,238,238).rgb()))); + dialog_->inactiveColor1_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_2",TQColor(246,242,246).rgb()))); + dialog_->activeColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_2",TQColor(205,202,205).rgb()))); + dialog_->inactiveColor2_P->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_2",TQColor(238,238,238).rgb()))); + dialog_->buttonStyle_P->setCurrentItem(config_->readNumEntry("ButtonStyle_2",0)); + dialog_->titleeffect_P->setCurrentItem(config_->readNumEntry("TitleEffect_2", 0)); + dialog_->i_titleeffect_P->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_2", 0)); + dialog_->shapeUL_P->setChecked(config_->readBoolEntry("ShapeUL_2",true)); + dialog_->shapeUR_P->setChecked(config_->readBoolEntry("ShapeUR_2",true)); + dialog_->shapeLL_P->setChecked(config_->readBoolEntry("ShapeLL_2",false)); + dialog_->shapeLR_P->setChecked(config_->readBoolEntry("ShapeLR_2",false)); + dialog_->drawIcon_P->setChecked(config_->readBoolEntry("drawIcon_2",true)); + dialog_->_3DImpact_P->setValue(config_->readNumEntry("3DImpact_2",20)); + dialog_->LineImpact_P->setValue(config_->readNumEntry("LineImpact_2",40)); + dialog_->borderSize_P->setValue(config_->readNumEntry("BorderSize_2",0)); + + dialog_->activeColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_3",TQColor(202,202,202).rgb()))); + dialog_->inactiveColor1_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_3",TQColor(200,200,200).rgb()))); + dialog_->activeColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_3",TQColor(150,150,150).rgb()))); + dialog_->inactiveColor2_B->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_3",TQColor(150,150,150).rgb()))); + dialog_->buttonStyle_B->setCurrentItem(config_->readNumEntry("ButtonStyle_3",0)); + dialog_->titleeffect_B->setCurrentItem(config_->readNumEntry("TitleEffect_3", 4)); + dialog_->i_titleeffect_B->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_3", 4)); + dialog_->shapeUL_B->setChecked(config_->readBoolEntry("ShapeUL_3",true)); + dialog_->shapeUR_B->setChecked(config_->readBoolEntry("ShapeUR_3",true)); + dialog_->shapeLL_B->setChecked(config_->readBoolEntry("ShapeLL_3",true)); + dialog_->shapeLR_B->setChecked(config_->readBoolEntry("ShapeLR_3",true)); + dialog_->drawIcon_B->setChecked(config_->readBoolEntry("drawIcon_3",true)); + dialog_->_3DImpact_B->setValue(config_->readNumEntry("3DImpact_3",20)); + dialog_->LineImpact_B->setValue(config_->readNumEntry("LineImpact_3",0)); + dialog_->borderSize_B->setValue(config_->readNumEntry("BorderSize_3",6)); + + dialog_->activeColor1_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_4",TQColor(238,238,238).rgb()))); + dialog_->activeColor2_T->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_4",TQColor(205,202,205).rgb()))); + dialog_->buttonStyle_T->setCurrentItem(config_->readNumEntry("ButtonStyle_4",0)); + dialog_->shapeUL_T->setChecked(config_->readBoolEntry("ShapeUL_4",true)); + dialog_->shapeUR_T->setChecked(config_->readBoolEntry("ShapeUR_4",true)); + dialog_->shapeLL_T->setChecked(config_->readBoolEntry("ShapeLL_4",false)); + dialog_->shapeLR_T->setChecked(config_->readBoolEntry("ShapeLR_4",false)); + dialog_->drawIcon_T->setChecked(config_->readBoolEntry("drawIcon_4",true)); + dialog_->_3DImpact_T->setValue(config_->readNumEntry("3DImpact_4",20)); + dialog_->borderSize_T->setValue(config_->readNumEntry("BorderSize_4",0)); + + dialog_->activeColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor1_5",TQColor(250,250,250).rgb()))); + dialog_->inactiveColor1_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor1_5",TQColor(230,230,230).rgb()))); + dialog_->activeColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("activeColor2_5",TQColor(230,230,230).rgb()))); + dialog_->inactiveColor2_S->setColor(TQColor((unsigned int)config_->readNumEntry("inactiveColor2_5",TQColor(250,250,250).rgb()))); + dialog_->buttonStyle_S->setCurrentItem(config_->readNumEntry("ButtonStyle_5",0)); + dialog_->titleeffect_S->setCurrentItem(config_->readNumEntry("TitleEffect_5", 0)); + dialog_->i_titleeffect_S->setCurrentItem(config_->readNumEntry("inactiveTitleEffect_5", 0)); + dialog_->shapeUL_S->setChecked(config_->readBoolEntry("ShapeUL_5",true)); + dialog_->shapeUR_S->setChecked(config_->readBoolEntry("ShapeUR_5",true)); + dialog_->shapeLL_S->setChecked(config_->readBoolEntry("ShapeLL_5",false)); + dialog_->shapeLR_S->setChecked(config_->readBoolEntry("ShapeLR_5",false)); + dialog_->drawIcon_S->setChecked(config_->readBoolEntry("drawIcon_5",true)); + dialog_->_3DImpact_S->setValue(config_->readNumEntry("3DImpact_5",20)); + dialog_->LineImpact_S->setValue(config_->readNumEntry("LineImpact_5",30)); + dialog_->borderSize_S->setValue(config_->readNumEntry("BorderSize_5",0)); + + buttonDialog_->inactiveColor->setColor(TQColor((unsigned int)config_->readNumEntry("InactiveButtonColor", TQColor(255,255,255).rgb()))); + buttonDialog_->closeColor->setColor(TQColor((unsigned int)config_->readNumEntry("CloseButtonColor", TQColor(200,85,70).rgb()))); + buttonDialog_->minColor->setColor(TQColor((unsigned int)config_->readNumEntry("MinButtonColor", TQColor(230,155,40).rgb()))); + buttonDialog_-> maxColor->setColor(TQColor((unsigned int)config_->readNumEntry("MaxButtonColor", TQColor(121,180,54).rgb()))); + buttonDialog_->menuColor->setColor(TQColor((unsigned int)config_->readNumEntry("MenuButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->helpColor->setColor(TQColor((unsigned int)config_->readNumEntry("HelpButtonColor", TQColor(0,0,0).rgb()))); + buttonDialog_->stickyColor->setColor(TQColor((unsigned int)config_->readNumEntry("StickyButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->aboveColor->setColor(TQColor((unsigned int)config_->readNumEntry("AboveButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->behindColor->setColor(TQColor((unsigned int)config_->readNumEntry("BehindButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->shadeColor->setColor(TQColor((unsigned int)config_->readNumEntry("ShadeButtonColor", TQColor(74,140,242).rgb()))); + buttonDialog_->init(); + config_->endGroup(); + delete config_; + +} + +////////////////////////////////////////////////////////////////////////////// +// save() +// ------ +// Save configuration data + +void BaghiraConfig::save(TDEConfig*) +{ + TQSettings *config_ = new TQSettings; + config_->beginGroup("/baghira/Deco"); + + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); + if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); + config_->writeEntry("DrawComicFrame", dialog_->drawComicFrame->isChecked()); + config_->writeEntry("AddAutoSpacing", dialog_->addAutoSpacing->isChecked()); + config_->writeEntry("ResizeGrip", dialog_->ResizeGrip->isChecked()); + config_->writeEntry("allowEasyClosing", dialog_->allowEasyClosing->isChecked()); + config_->writeEntry("MaxResizable", dialog_->maxResizable->isChecked()); + config_->writeEntry("FullSpec", dialog_->fullSpec->isChecked()); + config_->writeEntry("defaultMode", dialog_->defaultMode->currentItem()); + config_->writeEntry("minimumTitleHeight", dialog_->minTH->value()); + config_->writeEntry("NoModalDeco", dialog_->noModalDeco->isChecked()); + config_->writeEntry("RemoveAppname", dialog_->delAppname->isChecked()); + + config_->writeEntry("activeColor1_1", (int)dialog_->activeColor1_J->color().rgb()); + config_->writeEntry("activeColor2_1", (int)dialog_->activeColor2_J->color().rgb()); + config_->writeEntry("inactiveColor1_1", (int)dialog_->inactiveColor1_J->color().rgb()); + config_->writeEntry("inactiveColor2_1", (int)dialog_->inactiveColor2_J->color().rgb()); + config_->writeEntry("ButtonStyle_1", dialog_->buttonStyle_J->currentItem()); + config_->writeEntry("TitleEffect_1", dialog_->titleeffect_J->currentItem()); + config_->writeEntry("inactiveTitleEffect_1", dialog_->i_titleeffect_J->currentItem()); + config_->writeEntry("ShapeUL_1", dialog_->shapeUL_J->isChecked()); + config_->writeEntry("ShapeUR_1", dialog_->shapeUR_J->isChecked()); + config_->writeEntry("ShapeLL_1", dialog_->shapeLL_J->isChecked()); + config_->writeEntry("ShapeLR_1", dialog_->shapeLR_J->isChecked()); + config_->writeEntry("drawIcon_1", dialog_->drawIcon_J->isChecked()); + config_->writeEntry("3DImpact_1", dialog_->_3DImpact_J->value()); + config_->writeEntry("LineImpact_1", dialog_->LineImpact_J->value()); + config_->writeEntry("BorderSize_1", dialog_->borderSize_J->value()); + + config_->writeEntry("activeColor1_2", (int)dialog_->activeColor1_P->color().rgb()); + config_->writeEntry("activeColor2_2", (int)dialog_->activeColor2_P->color().rgb()); + config_->writeEntry("inactiveColor1_2", (int)dialog_->inactiveColor1_P->color().rgb()); + config_->writeEntry("inactiveColor2_2", (int)dialog_->inactiveColor2_P->color().rgb()); + config_->writeEntry("ButtonStyle_2", dialog_->buttonStyle_P->currentItem()); + config_->writeEntry("TitleEffect_2", dialog_->titleeffect_P->currentItem()); + config_->writeEntry("inactiveTitleEffect_2", dialog_->i_titleeffect_P->currentItem()); + config_->writeEntry("ShapeUL_2", dialog_->shapeUL_P->isChecked()); + config_->writeEntry("ShapeUR_2", dialog_->shapeUR_P->isChecked()); + config_->writeEntry("ShapeLL_2", dialog_->shapeLL_P->isChecked()); + config_->writeEntry("ShapeLR_2", dialog_->shapeLR_P->isChecked()); + config_->writeEntry("drawIcon_2", dialog_->drawIcon_P->isChecked()); + config_->writeEntry("3DImpact_2", dialog_->_3DImpact_P->value()); + config_->writeEntry("LineImpact_2", dialog_->LineImpact_P->value()); + config_->writeEntry("BorderSize_2", dialog_->borderSize_P->value()); + + config_->writeEntry("activeColor1_3", (int)dialog_->activeColor1_B->color().rgb()); + config_->writeEntry("activeColor2_3", (int)dialog_->activeColor2_B->color().rgb()); + config_->writeEntry("inactiveColor1_3", (int)dialog_->inactiveColor1_B->color().rgb()); + config_->writeEntry("inactiveColor2_3", (int)dialog_->inactiveColor2_B->color().rgb()); + config_->writeEntry("ButtonStyle_3", dialog_->buttonStyle_B->currentItem()); + config_->writeEntry("TitleEffect_3", dialog_->titleeffect_B->currentItem()); + config_->writeEntry("inactiveTitleEffect_3", dialog_->i_titleeffect_B->currentItem()); + config_->writeEntry("ShapeUL_3", dialog_->shapeUL_B->isChecked()); + config_->writeEntry("ShapeUR_3", dialog_->shapeUR_B->isChecked()); + config_->writeEntry("ShapeLL_3", dialog_->shapeLL_B->isChecked()); + config_->writeEntry("ShapeLR_3", dialog_->shapeLR_B->isChecked()); + config_->writeEntry("drawIcon_3", dialog_->drawIcon_B->isChecked()); + config_->writeEntry("3DImpact_3", dialog_->_3DImpact_B->value()); + config_->writeEntry("LineImpact_3", dialog_->LineImpact_B->value()); + config_->writeEntry("BorderSize_3", dialog_->borderSize_B->value()); + + config_->writeEntry("activeColor1_4", (int)dialog_->activeColor1_T->color().rgb()); + config_->writeEntry("activeColor2_4", (int)dialog_->activeColor2_T->color().rgb()); + config_->writeEntry("ButtonStyle_4", dialog_->buttonStyle_T->currentItem()); + config_->writeEntry("ShapeUL_4", dialog_->shapeUL_T->isChecked()); + config_->writeEntry("ShapeUR_4", dialog_->shapeUR_T->isChecked()); + config_->writeEntry("ShapeLL_4", dialog_->shapeLL_T->isChecked()); + config_->writeEntry("ShapeLR_4", dialog_->shapeLR_T->isChecked()); + config_->writeEntry("drawIcon_4", dialog_->drawIcon_T->isChecked()); + config_->writeEntry("3DImpact_4", dialog_->_3DImpact_T->value()); + config_->writeEntry("BorderSize_4", dialog_->borderSize_T->value()); + + config_->writeEntry("activeColor1_5", (int)dialog_->activeColor1_S->color().rgb()); + config_->writeEntry("activeColor2_5", (int)dialog_->activeColor2_S->color().rgb()); + config_->writeEntry("inactiveColor1_5", (int)dialog_->inactiveColor1_S->color().rgb()); + config_->writeEntry("inactiveColor2_5", (int)dialog_->inactiveColor2_S->color().rgb()); + config_->writeEntry("ButtonStyle_5", dialog_->buttonStyle_S->currentItem()); + config_->writeEntry("TitleEffect_5", dialog_->titleeffect_S->currentItem()); + config_->writeEntry("inactiveTitleEffect_5", dialog_->i_titleeffect_S->currentItem()); + config_->writeEntry("ShapeUL_5", dialog_->shapeUL_S->isChecked()); + config_->writeEntry("ShapeUR_5", dialog_->shapeUR_S->isChecked()); + config_->writeEntry("ShapeLL_5", dialog_->shapeLL_S->isChecked()); + config_->writeEntry("ShapeLR_5", dialog_->shapeLR_S->isChecked()); + config_->writeEntry("drawIcon_5", dialog_->drawIcon_S->isChecked()); + config_->writeEntry("3DImpact_5", dialog_->_3DImpact_S->value()); + config_->writeEntry("LineImpact_5", dialog_->LineImpact_S->value()); + config_->writeEntry("BorderSize_5", dialog_->borderSize_S->value()); + + if (buttonDialog_->save){ + config_->writeEntry("InactiveButtonColor", (int)buttonDialog_->inactiveColor->Color().rgb()); + config_->writeEntry("CloseButtonColor", (int)buttonDialog_->closeColor->Color().rgb()); + config_->writeEntry("MinButtonColor", (int)buttonDialog_->minColor->Color().rgb()); + config_->writeEntry("MaxButtonColor", (int)buttonDialog_->maxColor->Color().rgb()); + config_->writeEntry("MenuButtonColor", (int)buttonDialog_->menuColor->Color().rgb()); + config_->writeEntry("HelpButtonColor", (int)buttonDialog_->helpColor->Color().rgb()); + config_->writeEntry("StickyButtonColor", (int)buttonDialog_->stickyColor->Color().rgb()); + config_->writeEntry("AboveButtonColor", (int)buttonDialog_->aboveColor->Color().rgb()); + config_->writeEntry("BehindButtonColor", (int)buttonDialog_->behindColor->Color().rgb()); + config_->writeEntry("ShadeButtonColor", (int)buttonDialog_->shadeColor->Color().rgb()); + } + config_->endGroup(); + delete config_; + +// config_->sync(); +} + +////////////////////////////////////////////////////////////////////////////// +// defaults() +// ---------- +// Set configuration defaults + +void BaghiraConfig::defaults() +{ + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); + if (button) button->setChecked(true); + dialog_->allowEasyClosing->setChecked(false); + dialog_->minTH->setValue(22); + dialog_->ResizeGrip->setChecked(false); + dialog_->drawComicFrame->setChecked(false); + dialog_->addAutoSpacing->setChecked(true); + dialog_->maxResizable->setChecked(false); + dialog_->fullSpec->setChecked(false); + dialog_->defaultMode->setCurrentItem(1); + dialog_->noModalDeco->setChecked(false); + dialog_->delAppname->setChecked(false); + + dialog_->activeColor1_J->setColor(TQColor(255,255,255)); + dialog_->inactiveColor1_J->setColor(TQColor(204,214,230)); + dialog_->activeColor2_J->setColor(TQColor(238,234,238)); + dialog_->inactiveColor2_J->setColor(TQColor(194,196,211)); + dialog_->buttonStyle_J->setCurrentItem(1); + dialog_->titleeffect_J->setCurrentItem(1); + dialog_->i_titleeffect_J->setCurrentItem(1); + dialog_->shapeUL_J->setChecked(true); + dialog_->shapeUR_J->setChecked(true); + dialog_->shapeLL_J->setChecked(false); + dialog_->shapeLR_J->setChecked(false); + dialog_->drawIcon_J->setChecked(true); + dialog_->_3DImpact_J->setValue(20); + dialog_->LineImpact_J->setValue(40); + dialog_->borderSize_J->setValue(0); + + dialog_->activeColor1_P->setColor(TQColor(238,238,238)); + dialog_->inactiveColor1_P->setColor(TQColor(246,242,246)); + dialog_->activeColor2_P->setColor(TQColor(205,202,205)); + dialog_->inactiveColor2_P->setColor(TQColor(238,238,238)); + dialog_->buttonStyle_P->setCurrentItem(0); + dialog_->titleeffect_P->setCurrentItem(0); + dialog_->i_titleeffect_P->setCurrentItem(0); + dialog_->shapeUL_P->setChecked(true); + dialog_->shapeUR_P->setChecked(true); + dialog_->shapeLL_P->setChecked(false); + dialog_->shapeLR_P->setChecked(false); + dialog_->drawIcon_P->setChecked(true); + dialog_->_3DImpact_P->setValue(20); + dialog_->LineImpact_P->setValue(30); + dialog_->borderSize_P->setValue(0); + + dialog_->activeColor1_B->setColor(TQColor(210,210,210)); + dialog_->inactiveColor1_B->setColor(TQColor(200,200,200)); + dialog_->activeColor2_B->setColor(TQColor(150,150,150)); + dialog_->inactiveColor2_B->setColor(TQColor(140,140,140)); + dialog_->buttonStyle_B->setCurrentItem(0); + dialog_->titleeffect_B->setCurrentItem(4); + dialog_->i_titleeffect_B->setCurrentItem(4); + dialog_->shapeUL_B->setChecked(true); + dialog_->shapeUR_B->setChecked(true); + dialog_->shapeLL_B->setChecked(false); + dialog_->shapeLR_B->setChecked(false); + dialog_->drawIcon_B->setChecked(true); + dialog_->_3DImpact_B->setValue(20); + dialog_->LineImpact_B->setValue(0); + dialog_->borderSize_B->setValue(6); + + dialog_->activeColor1_T->setColor(TQColor(238,238,238)); + dialog_->activeColor2_T->setColor(TQColor(211,208,211)); + dialog_->buttonStyle_T->setCurrentItem(0); + dialog_->shapeUL_T->setChecked(true); + dialog_->shapeUR_T->setChecked(true); + dialog_->shapeLL_T->setChecked(false); + dialog_->shapeLR_T->setChecked(false); + dialog_->drawIcon_T->setChecked(true); + dialog_->_3DImpact_T->setValue(20); + dialog_->borderSize_T->setValue(0); + + dialog_->activeColor1_S->setColor(TQColor(250,250,250)); + dialog_->inactiveColor1_S->setColor(TQColor(230,230,230)); + dialog_->activeColor2_S->setColor(TQColor(230,230,230)); + dialog_->inactiveColor2_S->setColor(TQColor(250,250,250)); + dialog_->buttonStyle_S->setCurrentItem(0); + dialog_->titleeffect_S->setCurrentItem(0); + dialog_->i_titleeffect_S->setCurrentItem(0); + dialog_->shapeUL_S->setChecked(true); + dialog_->shapeUR_S->setChecked(true); + dialog_->shapeLL_S->setChecked(false); + dialog_->shapeLR_S->setChecked(false); + dialog_->drawIcon_S->setChecked(true); + dialog_->_3DImpact_S->setValue(20); + dialog_->LineImpact_S->setValue(30); + dialog_->borderSize_S->setValue(0); + +// buttonDialog_->defaults(); + + +} + +enum ColorPresets{Aqua = 0, Graphite, GraphiteDark, NUMBEROFCOLORS}; + +const char * presetColorName[NUMBEROFCOLORS] = {"Aqua", "Graphite", "Graphite (Dark)" }; + +typedef int ColorTable[10][3]; + +const int aquaPreset[10][3] = {{255,255,255},{200,85,70},{230,155,40},{121,180,54},{74,140,242},{0,0,0},{74,140,242},{74,140,242},{74,140,242},{74,140,242}}; +const int graphitePreset[10][3] = {{255,255,255},{130,170,190},{130,170,190},{130,170,190},{130,170,190},{0,0,0},{130,170,190},{130,170,190},{130,170,190},{130,170,190}}; +const int graphiteDarkPreset[10][3] = {{255,255,255},{103,118,134},{103,118,134},{103,118,134},{103,118,134},{0,0,0},{103,118,134},{103,118,134},{103,118,134},{103,118,134}}; +const ColorTable* presetColors[NUMBEROFCOLORS] = {&aquaPreset, &graphitePreset, &graphiteDarkPreset}; + + +ButtonColors::ButtonColors(TQWidget *parent, const char * name) : TQDialog(parent, name){ + save = false; + layout = new TQGridLayout(this,2,2,11,6, "Grid"); + buttonLayout = new TQVBoxLayout(0,0,6); + + TQPixmap tmpPix = TQPixmap(uic_findImage("preview")); + inactiveButton = new AquariusButton(tmpPix,this, "Inactive Button"); + buttonLayout->addWidget(inactiveButton); + closeButton = new AquariusButton(tmpPix,this, "Close Button"); + buttonLayout->addWidget(closeButton); + minButton = new AquariusButton(tmpPix,this, "Minimize Button"); + buttonLayout->addWidget(minButton); + maxButton = new AquariusButton(tmpPix,this, "Maximize Button"); + buttonLayout->addWidget(maxButton); + stickyButton = new AquariusButton(tmpPix,this, "Sticky Button"); + buttonLayout->addWidget(stickyButton); + aboveButton = new AquariusButton(tmpPix,this, "Above Button"); + buttonLayout->addWidget(aboveButton); + behindButton = new AquariusButton(tmpPix,this, "Behind Button"); + buttonLayout->addWidget(behindButton); + shadeButton = new AquariusButton(tmpPix,this, "Shade Button"); + buttonLayout->addWidget(shadeButton); + tmpPix = TQPixmap(uic_findImage("preview-menu")); + menuButton = new AquariusButton(tmpPix,this, "Menu Button"); + buttonLayout->addWidget(menuButton); + tmpPix = TQPixmap(uic_findImage("icon_help")); + helpButton = new AquariusButton(tmpPix,this, "Help Button"); + buttonLayout->addWidget(helpButton); + + + twoButts = new TQHBoxLayout(0,0,6); + presets_ = new TQComboBox(this); + for (int i = 0; i < NUMBEROFCOLORS; i++) + presets_->insertItem ( presetColorName[i], i ); + twoButts->addWidget(presets_); + cancel = new TQPushButton("Cancel", this); + cancel->setDefault( true ); + twoButts->addWidget(cancel); + twoButts->addStretch(); + layout->addLayout(twoButts,1,0); + ok = new TQPushButton("OK", this); + layout->addWidget(ok,1,1); + + layout->addLayout(buttonLayout,0,1); + + pickerLayout = new TQVBoxLayout(0,0,6,0); + + indicator = new TQLabel(inactiveButton->name(), this); + indicator->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter | TQt::ExpandTabs); + TQFont tmpFont = font(); + tmpFont.setBold( true ); + tmpFont.setPointSize( 24 ); + indicator->setFont(tmpFont); + pickerLayout->addWidget(indicator); + + inactiveColor = new ColorPicker(this); + pickerLayout->addWidget(inactiveColor); + currentPicker = inactiveColor; + closeColor = new ColorPicker(this); + pickerLayout->addWidget(closeColor); + closeColor->hide(); + minColor = new ColorPicker(this); + pickerLayout->addWidget(minColor); + minColor->hide(); + maxColor = new ColorPicker(this); + pickerLayout->addWidget(maxColor); + maxColor->hide(); + menuColor = new ColorPicker(this); + pickerLayout->addWidget(menuColor); + menuColor->hide(); + helpColor = new ColorPicker(this); + pickerLayout->addWidget(helpColor); + helpColor->hide(); + stickyColor = new ColorPicker(this); + pickerLayout->addWidget(stickyColor); + stickyColor->hide(); + aboveColor = new ColorPicker(this); + pickerLayout->addWidget(aboveColor); + aboveColor->hide(); + behindColor = new ColorPicker(this); + pickerLayout->addWidget(behindColor); + behindColor->hide(); + shadeColor = new ColorPicker(this); + pickerLayout->addWidget(shadeColor); + shadeColor->hide(); + + indicator->lower(); + + layout->addLayout(pickerLayout,0,0); + + resize( TQSize(485, 177).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); + + connect(presets_,SIGNAL(activated(int)), this, SLOT(setColorGroup(int))); + connect(ok, SIGNAL(clicked()), this, SLOT(setSave())); + connect(ok, SIGNAL(clicked()), this, SLOT(close()) ); + connect(ok, SIGNAL(clicked()), this, SLOT(init()) ); + connect(cancel, SIGNAL(clicked()), this, SLOT(close()) ); + connect(cancel, SIGNAL(clicked()), this, SLOT(reset()) ); + + connect(inactiveButton, SIGNAL(clicked()), this, SLOT(activateInactive()) ); + connect(closeButton, SIGNAL(clicked()), this, SLOT(activateClose()) ); + connect(minButton, SIGNAL(clicked()), this, SLOT(activateMin()) ); + connect(maxButton, SIGNAL(clicked()), this, SLOT(activateMax()) ); + connect(menuButton, SIGNAL(clicked()), this, SLOT(activateMenu()) ); + connect(helpButton, SIGNAL(clicked()), this, SLOT(activateHelp()) ); + connect(stickyButton, SIGNAL(clicked()), this, SLOT(activateSticky()) ); + connect(aboveButton, SIGNAL(clicked()), this, SLOT(activateAbove()) ); + connect(behindButton, SIGNAL(clicked()), this, SLOT(activateBehind()) ); + connect(shadeButton, SIGNAL(clicked()), this, SLOT(activateShade()) ); + + connect(inactiveColor, SIGNAL(colorChanged(TQColor)), inactiveButton, SLOT(setColor(TQColor)) ); + connect(closeColor, SIGNAL(colorChanged(TQColor)), closeButton, SLOT(setColor(TQColor)) ); + connect(minColor, SIGNAL(colorChanged(TQColor)), minButton, SLOT(setColor(TQColor)) ); + connect(maxColor, SIGNAL(colorChanged(TQColor)), maxButton, SLOT(setColor(TQColor)) ); + connect(menuColor, SIGNAL(colorChanged(TQColor)), menuButton, SLOT(setColor(TQColor)) ); + connect(helpColor, SIGNAL(colorChanged(TQColor)), helpButton, SLOT(setColor(TQColor)) ); + connect(stickyColor, SIGNAL(colorChanged(TQColor)), stickyButton, SLOT(setColor(TQColor)) ); + connect(aboveColor, SIGNAL(colorChanged(TQColor)), aboveButton, SLOT(setColor(TQColor)) ); + connect(behindColor, SIGNAL(colorChanged(TQColor)), behindButton, SLOT(setColor(TQColor)) ); + connect(shadeColor, SIGNAL(colorChanged(TQColor)), shadeButton, SLOT(setColor(TQColor)) ); + +} + +ButtonColors::~ButtonColors(){ +} + +void ButtonColors::setColorGroup(int i){ + inactiveColor->setColor(TQColor((*presetColors[i])[0][0],(*presetColors[i])[0][1],(*presetColors[i])[0][2]).rgb()); + closeColor->setColor(TQColor((*presetColors[i])[1][0],(*presetColors[i])[1][1],(*presetColors[i])[1][2]).rgb()); + minColor->setColor(TQColor((*presetColors[i])[2][0],(*presetColors[i])[2][1],(*presetColors[i])[2][2]).rgb()); + maxColor->setColor(TQColor((*presetColors[i])[3][0],(*presetColors[i])[3][1],(*presetColors[i])[3][2]).rgb()); + menuColor->setColor(TQColor((*presetColors[i])[4][0],(*presetColors[i])[4][1],(*presetColors[i])[4][2]).rgb()); + helpColor->setColor(TQColor((*presetColors[i])[5][0],(*presetColors[i])[5][1],(*presetColors[i])[5][2]).rgb()); + stickyColor->setColor(TQColor((*presetColors[i])[6][0],(*presetColors[i])[6][1],(*presetColors[i])[6][2]).rgb()); + aboveColor->setColor(TQColor((*presetColors[i])[7][0],(*presetColors[i])[7][1],(*presetColors[i])[7][2]).rgb()); + behindColor->setColor(TQColor((*presetColors[i])[8][0],(*presetColors[i])[8][1],(*presetColors[i])[8][2]).rgb()); + shadeColor->setColor(TQColor((*presetColors[i])[9][0],(*presetColors[i])[9][1],(*presetColors[i])[9][2]).rgb()); +} + +void ButtonColors::setPicker(ColorPicker *picker){ + if (currentPicker) currentPicker->hide(); + currentPicker = picker; + currentPicker->show(); +} + +void ButtonColors::activateInactive(){ + setPicker(inactiveColor); + indicator->setText( inactiveButton->name() ); +} +void ButtonColors::activateClose(){ + setPicker(closeColor); + indicator->setText( closeButton->name() ); +} +void ButtonColors::activateMin(){ + setPicker(minColor); + indicator->setText( minButton->name() ); +} +void ButtonColors::activateMax(){ + setPicker(maxColor); + indicator->setText( maxButton->name() ); +} +void ButtonColors::activateMenu(){ + setPicker(menuColor); + indicator->setText( menuButton->name() ); +} +void ButtonColors::activateHelp(){ + setPicker(helpColor); + indicator->setText( helpButton->name() ); +} +void ButtonColors::activateSticky(){ + setPicker(stickyColor); + indicator->setText( stickyButton->name() ); +} +void ButtonColors::activateAbove(){ + setPicker(aboveColor); + indicator->setText( aboveButton->name() ); +} +void ButtonColors::activateBehind(){ + setPicker(behindColor); + indicator->setText( behindButton->name() ); +} +void ButtonColors::activateShade(){ + setPicker(shadeColor); + indicator->setText( shadeButton->name() ); +} + +void ButtonColors::reset(){ + inactiveColor->reset(); + closeColor->reset(); + minColor->reset(); + maxColor->reset(); + menuColor->reset(); + helpColor->reset(); + stickyColor->reset(); + aboveColor->reset(); + behindColor->reset(); + shadeColor->reset(); +} + +void ButtonColors::init(){ + inactiveColor->init(); + closeColor->init(); + minColor->init(); + maxColor->init(); + menuColor->init(); + helpColor->init(); + stickyColor->init(); + aboveColor->init(); + behindColor->init(); + shadeColor->init(); +} + +////////////////////////////////////////////////////////////////////////////// +// Plugin Stuff // +////////////////////////////////////////////////////////////////////////////// + +extern "C" +{ + KDE_EXPORT TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { + return(new BaghiraConfig(config, parent)); + } +} + +#include "baghiraconfig.moc" diff --git a/deco/config/colorpicker.cc b/deco/config/colorpicker.cc deleted file mode 100644 index c5301c1..0000000 --- a/deco/config/colorpicker.cc +++ /dev/null @@ -1,126 +0,0 @@ -#include "colorpicker.h" -#include -#include -#include -#include - -ColorPicker::ColorPicker(TQWidget* parent, const char* name) : TQGroupBox( parent, name){ -// box = new TQGroupBox(parent); -// setFrameShape(TQFrame::GroupBoxPanel); -// setFrameShadow(TQFrame::Sunken); - setColumnLayout(0, TQt::Vertical ); - layout()->setSpacing( 6 ); - layout()->setMargin( 11 ); - - TQVBoxLayout *vLayout = new TQVBoxLayout(layout()); -// gridLayout->setAlignment( TQt::AlignTop ); - - TQHBoxLayout *redLayout = new TQHBoxLayout(); - redSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "redSlider"); - redLayout->addWidget(redSlider); - - redValue = new TQSpinBox(0,255,1,this); - redValue->setValue(0); - redLayout->addWidget(redValue); - - vLayout->addLayout(redLayout); - - TQHBoxLayout *greenLayout = new TQHBoxLayout(); - greenSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "greenSlider"); - greenLayout->addWidget(greenSlider); - - greenValue = new TQSpinBox(0,255,1,this); - greenValue->setValue(0); - greenLayout->addWidget(greenValue); - - vLayout->addLayout(greenLayout); - - TQHBoxLayout *blueLayout = new TQHBoxLayout(); - blueSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "blueSlider"); - blueLayout->addWidget(blueSlider); - - blueValue = new TQSpinBox(0,255,1,this); - blueValue->setValue(0); - blueLayout->addWidget(blueValue); - - vLayout->addLayout(blueLayout); - -// resize( TQSize(350, 100).expandedTo(minimumSizeHint()) ); - - //connections - connect(redSlider, SIGNAL(valueChanged (int)), this, SLOT(setRed(int))); - connect(greenSlider, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int))); - connect(blueSlider, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int))); - connect(redValue, SIGNAL(valueChanged (int)), this, SLOT(setRed(int))); - connect(greenValue, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int))); - connect(blueValue, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int))); -} - -ColorPicker::~ColorPicker(){ -} - -void ColorPicker::setColor(TQColor color){ - redSlider->blockSignals(true); - redSlider->setValue( color.red() ); - redSlider->blockSignals(false); - redValue->blockSignals(true); - redValue->setValue(redSlider->value()); - redValue->blockSignals(false); - greenSlider->blockSignals(true); - greenSlider->setValue( color.green() ); - greenSlider->blockSignals(false); - greenValue->blockSignals(true); - greenValue->setValue(greenSlider->value()); - greenValue->blockSignals(false); - blueSlider->blockSignals(true); - blueSlider->setValue( color.blue() ); - blueSlider->blockSignals(false); - blueValue->blockSignals(true); - blueValue->setValue(blueSlider->value()); - blueValue->blockSignals(false); - emit colorChanged(color); -} - -void ColorPicker::setRed(int red){ - redSlider->blockSignals(true); - redSlider->setValue( red ); - redSlider->blockSignals(false); - redValue->blockSignals(true); - redValue->setValue(red); - redValue->blockSignals(false); - emit colorChanged(TQColor(red, greenSlider->value(), blueSlider->value())); -} - -void ColorPicker::setGreen(int green){ - greenSlider->blockSignals(true); - greenSlider->setValue( green ); - greenSlider->blockSignals(false); - greenValue->blockSignals(true); - greenValue->setValue(green); - greenValue->blockSignals(false); - emit colorChanged(TQColor(redSlider->value(), green, blueSlider->value())); -} - -void ColorPicker::setBlue(int blue){ - blueSlider->blockSignals(true); - blueSlider->setValue( blue ); - blueSlider->blockSignals(false); - blueValue->blockSignals(true); - blueValue->setValue(blue); - blueValue->blockSignals(false); - emit colorChanged(TQColor(redSlider->value(), greenSlider->value(), blue)); -} - -TQColor ColorPicker::Color(){ - return TQColor(redSlider->value(), greenSlider->value(), blueSlider->value()); -} - -void ColorPicker::reset(){ - setColor(color_); -} - -void ColorPicker::init(){ - color_ = Color(); -} - -#include "colorpicker.moc" diff --git a/deco/config/colorpicker.cpp b/deco/config/colorpicker.cpp new file mode 100644 index 0000000..c5301c1 --- /dev/null +++ b/deco/config/colorpicker.cpp @@ -0,0 +1,126 @@ +#include "colorpicker.h" +#include +#include +#include +#include + +ColorPicker::ColorPicker(TQWidget* parent, const char* name) : TQGroupBox( parent, name){ +// box = new TQGroupBox(parent); +// setFrameShape(TQFrame::GroupBoxPanel); +// setFrameShadow(TQFrame::Sunken); + setColumnLayout(0, TQt::Vertical ); + layout()->setSpacing( 6 ); + layout()->setMargin( 11 ); + + TQVBoxLayout *vLayout = new TQVBoxLayout(layout()); +// gridLayout->setAlignment( TQt::AlignTop ); + + TQHBoxLayout *redLayout = new TQHBoxLayout(); + redSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "redSlider"); + redLayout->addWidget(redSlider); + + redValue = new TQSpinBox(0,255,1,this); + redValue->setValue(0); + redLayout->addWidget(redValue); + + vLayout->addLayout(redLayout); + + TQHBoxLayout *greenLayout = new TQHBoxLayout(); + greenSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "greenSlider"); + greenLayout->addWidget(greenSlider); + + greenValue = new TQSpinBox(0,255,1,this); + greenValue->setValue(0); + greenLayout->addWidget(greenValue); + + vLayout->addLayout(greenLayout); + + TQHBoxLayout *blueLayout = new TQHBoxLayout(); + blueSlider = new TQSlider(0, 255, 1, 0, TQt::Horizontal, this, "blueSlider"); + blueLayout->addWidget(blueSlider); + + blueValue = new TQSpinBox(0,255,1,this); + blueValue->setValue(0); + blueLayout->addWidget(blueValue); + + vLayout->addLayout(blueLayout); + +// resize( TQSize(350, 100).expandedTo(minimumSizeHint()) ); + + //connections + connect(redSlider, SIGNAL(valueChanged (int)), this, SLOT(setRed(int))); + connect(greenSlider, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int))); + connect(blueSlider, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int))); + connect(redValue, SIGNAL(valueChanged (int)), this, SLOT(setRed(int))); + connect(greenValue, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int))); + connect(blueValue, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int))); +} + +ColorPicker::~ColorPicker(){ +} + +void ColorPicker::setColor(TQColor color){ + redSlider->blockSignals(true); + redSlider->setValue( color.red() ); + redSlider->blockSignals(false); + redValue->blockSignals(true); + redValue->setValue(redSlider->value()); + redValue->blockSignals(false); + greenSlider->blockSignals(true); + greenSlider->setValue( color.green() ); + greenSlider->blockSignals(false); + greenValue->blockSignals(true); + greenValue->setValue(greenSlider->value()); + greenValue->blockSignals(false); + blueSlider->blockSignals(true); + blueSlider->setValue( color.blue() ); + blueSlider->blockSignals(false); + blueValue->blockSignals(true); + blueValue->setValue(blueSlider->value()); + blueValue->blockSignals(false); + emit colorChanged(color); +} + +void ColorPicker::setRed(int red){ + redSlider->blockSignals(true); + redSlider->setValue( red ); + redSlider->blockSignals(false); + redValue->blockSignals(true); + redValue->setValue(red); + redValue->blockSignals(false); + emit colorChanged(TQColor(red, greenSlider->value(), blueSlider->value())); +} + +void ColorPicker::setGreen(int green){ + greenSlider->blockSignals(true); + greenSlider->setValue( green ); + greenSlider->blockSignals(false); + greenValue->blockSignals(true); + greenValue->setValue(green); + greenValue->blockSignals(false); + emit colorChanged(TQColor(redSlider->value(), green, blueSlider->value())); +} + +void ColorPicker::setBlue(int blue){ + blueSlider->blockSignals(true); + blueSlider->setValue( blue ); + blueSlider->blockSignals(false); + blueValue->blockSignals(true); + blueValue->setValue(blue); + blueValue->blockSignals(false); + emit colorChanged(TQColor(redSlider->value(), greenSlider->value(), blue)); +} + +TQColor ColorPicker::Color(){ + return TQColor(redSlider->value(), greenSlider->value(), blueSlider->value()); +} + +void ColorPicker::reset(){ + setColor(color_); +} + +void ColorPicker::init(){ + color_ = Color(); +} + +#include "colorpicker.moc" -- cgit v1.2.1