From 3bc70fb6aa1a24467df4aa5be8b6de24892db618 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 20 Feb 2021 16:12:33 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro --- client/Makefile.am | 2 +- client/config/Makefile.am | 4 +- client/config/crystalconfig.cc | 384 --------- client/config/crystalconfig.cpp | 384 +++++++++ client/crystalclient.cc | 1666 --------------------------------------- client/crystalclient.cpp | 1666 +++++++++++++++++++++++++++++++++++++++ client/myrootpixmap.cc | 258 ------ client/myrootpixmap.cpp | 258 ++++++ pics/README | 2 +- 9 files changed, 2312 insertions(+), 2312 deletions(-) delete mode 100644 client/config/crystalconfig.cc create mode 100644 client/config/crystalconfig.cpp delete mode 100644 client/crystalclient.cc create mode 100644 client/crystalclient.cpp delete mode 100644 client/myrootpixmap.cc create mode 100644 client/myrootpixmap.cpp diff --git a/client/Makefile.am b/client/Makefile.am index 3eb3ecb..22d7f32 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -12,7 +12,7 @@ twin_DATA = crystal.desktop noinst_HEADERS = crystalclient.h crystalbutton.h imageholder.h buttonimage.h tiles.h overlays.h kde_module_LTLIBRARIES = twin3_crystal.la -twin3_crystal_la_SOURCES = crystalclient.cc myrootpixmap.cc crystalbutton.cpp \ +twin3_crystal_la_SOURCES = crystalclient.cpp myrootpixmap.cpp crystalbutton.cpp \ imageholder.cpp buttonimage.cpp tiles.h overlays.h twin3_crystal_la_LIBADD = $(kde_libraries)/libtdecorations.la $(LIB_TQT) $(LIB_TDEUI) twin3_crystal_la_LDFLAGS = -module $(all_libraries) $(KDE_PLUGIN) $(LIB_TQT) $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx -lDCOP diff --git a/client/config/Makefile.am b/client/config/Makefile.am index 2b2e03c..a491211 100644 --- a/client/config/Makefile.am +++ b/client/config/Makefile.am @@ -7,14 +7,14 @@ INCLUDES = $(all_includes) noinst_HEADERS = crystalconfig.h kde_module_LTLIBRARIES = twin_crystal_config.la -twin_crystal_config_la_SOURCES = configdialog.ui infodialog.ui crystalconfig.cc crystalconfig.h +twin_crystal_config_la_SOURCES = configdialog.ui infodialog.ui crystalconfig.cpp crystalconfig.h twin_crystal_config_la_LDFLAGS = -module $(all_libraries) $(KDE_PLUGIN) $(LIB_TDECORE) twin_crystal_config_la_LIBADD = $(LIB_TDEUI) $(LIB_TDEIO) $(LIB_TQT) twin_crystal_config_la_METASOURCES = AUTO DISTCLEANFILES = $(twin_crystal_config_la_METASOURCES) -crystalconfig.cc: configdialog.h infodialog.h +crystalconfig.cpp: configdialog.h infodialog.h messages: diff --git a/client/config/crystalconfig.cc b/client/config/crystalconfig.cc deleted file mode 100644 index 117aafc..0000000 --- a/client/config/crystalconfig.cc +++ /dev/null @@ -1,384 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Sascha Hlusiak * - * Spam84@gmx.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "configdialog.h" -#include "infodialog.h" -#include "crystalconfig.h" - - -CrystalConfig::CrystalConfig(TDEConfig*, TQWidget* parent) - : TQObject(parent), config_(0), dialog_(0) -{ - config_ = new TDEConfig("twincrystalrc"); - - dialog_ = new ConfigDialog(parent); - dialog_->show(); - - connect(dialog_->titlealign, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->drawCaption, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->textshadow, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->tooltip,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->wheelTask,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - - connect(dialog_->trackdesktop, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->shade1, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->shade2, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->frame1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->frame2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->frameColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->frameColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - - connect(dialog_->inline1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->inline2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->inlineColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->inlineColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - - connect(dialog_->type1,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->type2,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); - - connect(dialog_->enableTransparency,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - - connect(dialog_->borderwidth, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->titlebarheight, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->tlc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->trc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->blc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->brc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->buttonColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->buttonColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->buttonColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->minColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->minColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->minColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->maxColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->maxColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->maxColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->closeColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->closeColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - connect(dialog_->closeColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); - - connect(dialog_->hover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->animateHover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->buttonTheme, TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->tintButtons, TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(boolChanged(bool))); - connect(dialog_->menuimage, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); - - connect(dialog_->repaintMode, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->updateTime, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); - - connect(dialog_->infoButton, TQT_SIGNAL(clicked(void)),this,TQT_SLOT(infoDialog(void))); - - connect(dialog_->active_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); - connect(dialog_->inactive_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); - - connect(dialog_->userPicture1, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->userPicture2, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->activeFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& ))); - connect(dialog_->inactiveFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& ))); - - - connect(dialog_->overlay_active, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_active_changed(int))); - connect(dialog_->overlay_inactive, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_inactive_changed(int))); - - connect(dialog_->overlay_active_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &))); - connect(dialog_->overlay_inactive_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &))); - - - connect(dialog_->logoEnabled, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->logoFile, TQT_SIGNAL(textChanged(const TQString &)),this, TQT_SLOT(logoTextChanged(const TQString&))); - connect(dialog_->logoStretch, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->logoActive, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); - connect(dialog_->logoDistance,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); - - load(config_); -} - -CrystalConfig::~CrystalConfig() -{ - if (dialog_) delete dialog_; - if (config_) delete config_; -} - -void CrystalConfig::selectionChanged(int) -{ - emit changed(); -} - -void CrystalConfig::load(TDEConfig*) -{ - TQColor color(255,255,255); - - config_->setGroup("General"); - - TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child(value); - if (button) button->setChecked(true); - - dialog_->drawCaption->setChecked(config_->readBoolEntry("DrawCaption",true)); - dialog_->textshadow->setChecked(config_->readBoolEntry("TextShadow",true)); - dialog_->tooltip->setChecked(config_->readBoolEntry("CaptionTooltip",true)); - dialog_->wheelTask->setChecked(config_->readBoolEntry("WheelTask",false)); - - dialog_->enableTransparency->setChecked(config_->readBoolEntry("EnableTransparency",true)); - dialog_->trackdesktop->setChecked(config_->readBoolEntry("TrackDesktop",false)); - - dialog_->frame1->setCurrentItem(config_->readNumEntry("ActiveFrame",1)); - color=TQColor(192,192,192); - dialog_->frameColor1->setColor(config_->readColorEntry("FrameColor1",&color)); - dialog_->frame2->setCurrentItem(config_->readNumEntry("InactiveFrame",1)); - color=TQColor(192,192,192); - dialog_->frameColor2->setColor(config_->readColorEntry("FrameColor2",&color)); - - dialog_->inline1->setCurrentItem(config_->readNumEntry("ActiveInline",0)); - color=TQColor(192,192,192); - dialog_->inlineColor1->setColor(config_->readColorEntry("InlineColor1",&color)); - dialog_->inline2->setCurrentItem(config_->readNumEntry("InactiveInline",0)); - color=TQColor(192,192,192); - dialog_->inlineColor2->setColor(config_->readColorEntry("InlineColor2",&color)); - - - dialog_->borderwidth->setValue(config_->readNumEntry("Borderwidth",5)); - dialog_->titlebarheight->setValue(config_->readNumEntry("Titlebarheight",19)); - - int active=config_->readNumEntry("ActiveShade",30); - dialog_->shade1->setValue(active); - - active=config_->readNumEntry("InactiveShade",-30); - dialog_->shade2->setValue(active); - - dialog_->type1->setCurrentItem(config_->readNumEntry("ActiveMode",0)); - dialog_->type2->setCurrentItem(config_->readNumEntry("InactiveMode",2)); - - int cornersFlag = config_->readNumEntry("RoundCorners",TOP_LEFT & TOP_RIGHT ); - dialog_->tlc->setChecked( cornersFlag & TOP_LEFT ); - dialog_->trc->setChecked( cornersFlag & TOP_RIGHT ); - dialog_->blc->setChecked( cornersFlag & BOT_LEFT ); - dialog_->brc->setChecked( cornersFlag & BOT_RIGHT ); - - dialog_->hover->setChecked(config_->readBoolEntry("HoverEffect",true)); - dialog_->animateHover->setChecked(config_->readBoolEntry("AnimateHover",true)); - dialog_->menuimage->setChecked(config_->readBoolEntry("MenuImage",true)); - - color=TQColor(255,255,255); - dialog_->buttonColor1->setColor(config_->readColorEntry("ButtonColor",&color)); - dialog_->buttonColor2->setColor(config_->readColorEntry("ButtonColor2",&color)); - dialog_->buttonColor3->setColor(config_->readColorEntry("ButtonColor3",&color)); - dialog_->minColor1->setColor(config_->readColorEntry("MinColor",&color)); - dialog_->minColor2->setColor(config_->readColorEntry("MinColor2",&color)); - dialog_->minColor3->setColor(config_->readColorEntry("MinColor3",&color)); - dialog_->maxColor1->setColor(config_->readColorEntry("MaxColor",&color)); - dialog_->maxColor2->setColor(config_->readColorEntry("MaxColor2",&color)); - dialog_->maxColor3->setColor(config_->readColorEntry("MaxColor3",&color)); - dialog_->closeColor1->setColor(config_->readColorEntry("CloseColor",&color)); - dialog_->closeColor2->setColor(config_->readColorEntry("CloseColor2",&color)); - dialog_->closeColor3->setColor(config_->readColorEntry("CloseColor3",&color)); - - dialog_->tintButtons->setChecked(config_->readBoolEntry("TintButtons",dialog_->buttonColor1->color()!=TQColor(255,255,255))); - - dialog_->buttonTheme->setCurrentItem(config_->readNumEntry("ButtonTheme",8)); - - dialog_->updateTime->setValue(config_->readNumEntry("RepaintTime",200)); - button=(TQRadioButton*)dialog_->repaintMode->find(config_->readNumEntry("RepaintMode",1)); - if (button)button->setChecked(true); - - dialog_->active_blur->setValue(config_->readNumEntry("ActiveBlur",0)); - dialog_->inactive_blur->setValue(config_->readNumEntry("InactiveBlur",0)); - - - dialog_->activeFile->setURL(config_->readEntry("ActiveUserdefinedPicture","")); - dialog_->userPicture1->setChecked(config_->readBoolEntry("ActiveUserdefined",false)); - dialog_->inactiveFile->setURL(config_->readEntry("InactiveUserdefinedPicture","")); - dialog_->userPicture2->setChecked(config_->readBoolEntry("InactiveUserdefined",false)); - - - dialog_->overlay_active->setCurrentItem(config_->readNumEntry("OverlayModeActive",0)); - dialog_->overlay_active_file->setURL(config_->readEntry("OverlayFileActive","")); - overlay_active_changed(dialog_->overlay_active->currentItem()); - - dialog_->overlay_inactive->setCurrentItem(config_->readNumEntry("OverlayModeInactive",0)); - dialog_->overlay_inactive_file->setURL(config_->readEntry("OverlayFileInactive","")); - overlay_inactive_changed(dialog_->overlay_inactive->currentItem()); - - dialog_->logoEnabled->setButton(config_->readNumEntry("LogoAlignment",1)); - dialog_->logoFile->setURL(config_->readEntry("LogoFile","")); - dialog_->logoActive->setChecked(config_->readBoolEntry("LogoActive",1)); - dialog_->logoStretch->setCurrentItem(config_->readNumEntry("LogoStretch",0)); - dialog_->logoDistance->setValue(config_->readNumEntry("LogoDistance",0)); - updateLogo(); -} - -void CrystalConfig::save(TDEConfig*) -{ - config_->setGroup("General"); - - TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); - if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); - config_->writeEntry("DrawCaption",dialog_->drawCaption->isChecked()); - config_->writeEntry("TextShadow",dialog_->textshadow->isChecked()); - config_->writeEntry("CaptionTooltip",dialog_->tooltip->isChecked()); - config_->writeEntry("WheelTask",dialog_->wheelTask->isChecked()); - - config_->writeEntry("EnableTransparency",dialog_->enableTransparency->isChecked()); - config_->writeEntry("TrackDesktop",dialog_->trackdesktop->isChecked()); - - config_->writeEntry("Borderwidth",dialog_->borderwidth->value()); - config_->writeEntry("Titlebarheight",dialog_->titlebarheight->value()); - - config_->writeEntry("ActiveShade",dialog_->shade1->value()); - config_->writeEntry("InactiveShade",dialog_->shade2->value()); - config_->writeEntry("ActiveFrame",dialog_->frame1->currentItem()); - config_->writeEntry("FrameColor1",dialog_->frameColor1->color()); - config_->writeEntry("InactiveFrame",dialog_->frame2->currentItem()); - config_->writeEntry("ActiveMode",dialog_->type1->currentItem()); - config_->writeEntry("InactiveMode",dialog_->type2->currentItem()); - config_->writeEntry("FrameColor2",dialog_->frameColor2->color()); - - config_->writeEntry("ActiveInline",dialog_->inline1->currentItem()); - config_->writeEntry("InlineColor1",dialog_->inlineColor1->color()); - config_->writeEntry("InactiveInline",dialog_->inline2->currentItem()); - config_->writeEntry("InlineColor2",dialog_->inlineColor2->color()); - - config_->writeEntry("ButtonColor",dialog_->buttonColor1->color()); - config_->writeEntry("ButtonColor2",dialog_->buttonColor2->color()); - config_->writeEntry("ButtonColor3",dialog_->buttonColor3->color()); - config_->writeEntry("MinColor",dialog_->minColor1->color()); - config_->writeEntry("MinColor2",dialog_->minColor2->color()); - config_->writeEntry("MinColor3",dialog_->minColor3->color()); - config_->writeEntry("MaxColor",dialog_->maxColor1->color()); - config_->writeEntry("MaxColor2",dialog_->maxColor2->color()); - config_->writeEntry("MaxColor3",dialog_->maxColor3->color()); - config_->writeEntry("CloseColor",dialog_->closeColor1->color()); - config_->writeEntry("CloseColor2",dialog_->closeColor2->color()); - config_->writeEntry("CloseColor3",dialog_->closeColor3->color()); - - int cornersFlag = 0; - if(dialog_->tlc->isChecked()) cornersFlag += TOP_LEFT; - if(dialog_->trc->isChecked()) cornersFlag += TOP_RIGHT; - if(dialog_->blc->isChecked()) cornersFlag += BOT_LEFT; - if(dialog_->brc->isChecked()) cornersFlag += BOT_RIGHT; - config_->writeEntry("RoundCorners", cornersFlag ); - - config_->writeEntry("HoverEffect",dialog_->hover->isChecked()); - config_->writeEntry("AnimateHover",dialog_->animateHover->isChecked()); - config_->writeEntry("TintButtons",dialog_->tintButtons->isChecked()); - config_->writeEntry("MenuImage",dialog_->menuimage->isChecked()); - - config_->writeEntry("ButtonTheme",dialog_->buttonTheme->currentItem()); - config_->writeEntry("RepaintMode",dialog_->repaintMode->selectedId()); - config_->writeEntry("RepaintTime",dialog_->updateTime->value()); - - config_->writeEntry("ActiveBlur",dialog_->active_blur->value()); - config_->writeEntry("InactiveBlur",dialog_->inactive_blur->value()); - - config_->writeEntry("ActiveUserdefined",dialog_->userPicture1->isChecked()); - config_->writeEntry("ActiveUserdefinedPicture",dialog_->activeFile->url()); - config_->writeEntry("InactiveUserdefined",dialog_->userPicture2->isChecked()); - config_->writeEntry("InactiveUserdefinedPicture",dialog_->inactiveFile->url()); - - config_->writeEntry("OverlayModeActive",dialog_->overlay_active->currentItem()); - config_->writeEntry("OverlayFileActive",dialog_->overlay_active_file->url()); - config_->writeEntry("OverlayModeInactive",dialog_->overlay_inactive->currentItem()); - config_->writeEntry("OverlayFileInactive",dialog_->overlay_inactive_file->url()); - - config_->writeEntry("LogoAlignment",dialog_->logoEnabled->selectedId()); - config_->writeEntry("LogoFile",dialog_->logoFile->url()); - config_->writeEntry("LogoActive",dialog_->logoActive->isChecked()); - config_->writeEntry("LogoStretch",dialog_->logoStretch->currentItem()); - config_->writeEntry("LogoDistance",dialog_->logoDistance->value()); - - config_->sync(); -} - -void CrystalConfig::infoDialog() -{ - InfoDialog d(dialog_); - connect((TQLabel*)(d.kURLLabel1),TQT_SIGNAL(leftClickedURL(const TQString&)),TDEApplication::kApplication(),TQT_SLOT(invokeBrowser(const TQString &))); - d.exec(); -} - -void CrystalConfig::logoTextChanged(const TQString&) -{ - updateLogo(); - emit changed(); -} - -void CrystalConfig::overlay_active_changed(int a) -{ - dialog_->overlay_active_file->setEnabled(a==4); - emit changed(); -} - -void CrystalConfig::overlay_inactive_changed(int a) -{ - dialog_->overlay_inactive_file->setEnabled(a==4); - emit changed(); -} - -void CrystalConfig::updateLogo() -{ - TQPixmap pic; - pic.load(dialog_->logoFile->url()); - dialog_->logoPreview->setPixmap(pic); -} - -void CrystalConfig::defaults() -{ - TQRadioButton *button = - (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); - if (button) button->setChecked(true); - dialog_->shade1->setValue(50); - dialog_->shade2->setValue(50); -} - -extern "C" -{ - TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { - return (new CrystalConfig(config, parent)); - } -} - -#include "crystalconfig.moc" diff --git a/client/config/crystalconfig.cpp b/client/config/crystalconfig.cpp new file mode 100644 index 0000000..117aafc --- /dev/null +++ b/client/config/crystalconfig.cpp @@ -0,0 +1,384 @@ +/*************************************************************************** + * Copyright (C) 2006 by Sascha Hlusiak * + * Spam84@gmx.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "configdialog.h" +#include "infodialog.h" +#include "crystalconfig.h" + + +CrystalConfig::CrystalConfig(TDEConfig*, TQWidget* parent) + : TQObject(parent), config_(0), dialog_(0) +{ + config_ = new TDEConfig("twincrystalrc"); + + dialog_ = new ConfigDialog(parent); + dialog_->show(); + + connect(dialog_->titlealign, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->drawCaption, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->textshadow, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->tooltip,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->wheelTask,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + + connect(dialog_->trackdesktop, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->shade1, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->shade2, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->frame1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->frame2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->frameColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->frameColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + + connect(dialog_->inline1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->inline2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->inlineColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->inlineColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + + connect(dialog_->type1,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->type2,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); + + connect(dialog_->enableTransparency,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + + connect(dialog_->borderwidth, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->titlebarheight, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->tlc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->trc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->blc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->brc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->buttonColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->buttonColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->buttonColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->minColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->minColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->minColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->maxColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->maxColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->maxColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->closeColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->closeColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + connect(dialog_->closeColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&))); + + connect(dialog_->hover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->animateHover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->buttonTheme, TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->tintButtons, TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(boolChanged(bool))); + connect(dialog_->menuimage, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int))); + + connect(dialog_->repaintMode, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->updateTime, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int))); + + connect(dialog_->infoButton, TQT_SIGNAL(clicked(void)),this,TQT_SLOT(infoDialog(void))); + + connect(dialog_->active_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); + connect(dialog_->inactive_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); + + connect(dialog_->userPicture1, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->userPicture2, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->activeFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& ))); + connect(dialog_->inactiveFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& ))); + + + connect(dialog_->overlay_active, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_active_changed(int))); + connect(dialog_->overlay_inactive, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_inactive_changed(int))); + + connect(dialog_->overlay_active_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &))); + connect(dialog_->overlay_inactive_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &))); + + + connect(dialog_->logoEnabled, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->logoFile, TQT_SIGNAL(textChanged(const TQString &)),this, TQT_SLOT(logoTextChanged(const TQString&))); + connect(dialog_->logoStretch, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->logoActive, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int))); + connect(dialog_->logoDistance,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int))); + + load(config_); +} + +CrystalConfig::~CrystalConfig() +{ + if (dialog_) delete dialog_; + if (config_) delete config_; +} + +void CrystalConfig::selectionChanged(int) +{ + emit changed(); +} + +void CrystalConfig::load(TDEConfig*) +{ + TQColor color(255,255,255); + + config_->setGroup("General"); + + TQString value = config_->readEntry("TitleAlignment", "AlignHCenter"); + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child(value); + if (button) button->setChecked(true); + + dialog_->drawCaption->setChecked(config_->readBoolEntry("DrawCaption",true)); + dialog_->textshadow->setChecked(config_->readBoolEntry("TextShadow",true)); + dialog_->tooltip->setChecked(config_->readBoolEntry("CaptionTooltip",true)); + dialog_->wheelTask->setChecked(config_->readBoolEntry("WheelTask",false)); + + dialog_->enableTransparency->setChecked(config_->readBoolEntry("EnableTransparency",true)); + dialog_->trackdesktop->setChecked(config_->readBoolEntry("TrackDesktop",false)); + + dialog_->frame1->setCurrentItem(config_->readNumEntry("ActiveFrame",1)); + color=TQColor(192,192,192); + dialog_->frameColor1->setColor(config_->readColorEntry("FrameColor1",&color)); + dialog_->frame2->setCurrentItem(config_->readNumEntry("InactiveFrame",1)); + color=TQColor(192,192,192); + dialog_->frameColor2->setColor(config_->readColorEntry("FrameColor2",&color)); + + dialog_->inline1->setCurrentItem(config_->readNumEntry("ActiveInline",0)); + color=TQColor(192,192,192); + dialog_->inlineColor1->setColor(config_->readColorEntry("InlineColor1",&color)); + dialog_->inline2->setCurrentItem(config_->readNumEntry("InactiveInline",0)); + color=TQColor(192,192,192); + dialog_->inlineColor2->setColor(config_->readColorEntry("InlineColor2",&color)); + + + dialog_->borderwidth->setValue(config_->readNumEntry("Borderwidth",5)); + dialog_->titlebarheight->setValue(config_->readNumEntry("Titlebarheight",19)); + + int active=config_->readNumEntry("ActiveShade",30); + dialog_->shade1->setValue(active); + + active=config_->readNumEntry("InactiveShade",-30); + dialog_->shade2->setValue(active); + + dialog_->type1->setCurrentItem(config_->readNumEntry("ActiveMode",0)); + dialog_->type2->setCurrentItem(config_->readNumEntry("InactiveMode",2)); + + int cornersFlag = config_->readNumEntry("RoundCorners",TOP_LEFT & TOP_RIGHT ); + dialog_->tlc->setChecked( cornersFlag & TOP_LEFT ); + dialog_->trc->setChecked( cornersFlag & TOP_RIGHT ); + dialog_->blc->setChecked( cornersFlag & BOT_LEFT ); + dialog_->brc->setChecked( cornersFlag & BOT_RIGHT ); + + dialog_->hover->setChecked(config_->readBoolEntry("HoverEffect",true)); + dialog_->animateHover->setChecked(config_->readBoolEntry("AnimateHover",true)); + dialog_->menuimage->setChecked(config_->readBoolEntry("MenuImage",true)); + + color=TQColor(255,255,255); + dialog_->buttonColor1->setColor(config_->readColorEntry("ButtonColor",&color)); + dialog_->buttonColor2->setColor(config_->readColorEntry("ButtonColor2",&color)); + dialog_->buttonColor3->setColor(config_->readColorEntry("ButtonColor3",&color)); + dialog_->minColor1->setColor(config_->readColorEntry("MinColor",&color)); + dialog_->minColor2->setColor(config_->readColorEntry("MinColor2",&color)); + dialog_->minColor3->setColor(config_->readColorEntry("MinColor3",&color)); + dialog_->maxColor1->setColor(config_->readColorEntry("MaxColor",&color)); + dialog_->maxColor2->setColor(config_->readColorEntry("MaxColor2",&color)); + dialog_->maxColor3->setColor(config_->readColorEntry("MaxColor3",&color)); + dialog_->closeColor1->setColor(config_->readColorEntry("CloseColor",&color)); + dialog_->closeColor2->setColor(config_->readColorEntry("CloseColor2",&color)); + dialog_->closeColor3->setColor(config_->readColorEntry("CloseColor3",&color)); + + dialog_->tintButtons->setChecked(config_->readBoolEntry("TintButtons",dialog_->buttonColor1->color()!=TQColor(255,255,255))); + + dialog_->buttonTheme->setCurrentItem(config_->readNumEntry("ButtonTheme",8)); + + dialog_->updateTime->setValue(config_->readNumEntry("RepaintTime",200)); + button=(TQRadioButton*)dialog_->repaintMode->find(config_->readNumEntry("RepaintMode",1)); + if (button)button->setChecked(true); + + dialog_->active_blur->setValue(config_->readNumEntry("ActiveBlur",0)); + dialog_->inactive_blur->setValue(config_->readNumEntry("InactiveBlur",0)); + + + dialog_->activeFile->setURL(config_->readEntry("ActiveUserdefinedPicture","")); + dialog_->userPicture1->setChecked(config_->readBoolEntry("ActiveUserdefined",false)); + dialog_->inactiveFile->setURL(config_->readEntry("InactiveUserdefinedPicture","")); + dialog_->userPicture2->setChecked(config_->readBoolEntry("InactiveUserdefined",false)); + + + dialog_->overlay_active->setCurrentItem(config_->readNumEntry("OverlayModeActive",0)); + dialog_->overlay_active_file->setURL(config_->readEntry("OverlayFileActive","")); + overlay_active_changed(dialog_->overlay_active->currentItem()); + + dialog_->overlay_inactive->setCurrentItem(config_->readNumEntry("OverlayModeInactive",0)); + dialog_->overlay_inactive_file->setURL(config_->readEntry("OverlayFileInactive","")); + overlay_inactive_changed(dialog_->overlay_inactive->currentItem()); + + dialog_->logoEnabled->setButton(config_->readNumEntry("LogoAlignment",1)); + dialog_->logoFile->setURL(config_->readEntry("LogoFile","")); + dialog_->logoActive->setChecked(config_->readBoolEntry("LogoActive",1)); + dialog_->logoStretch->setCurrentItem(config_->readNumEntry("LogoStretch",0)); + dialog_->logoDistance->setValue(config_->readNumEntry("LogoDistance",0)); + updateLogo(); +} + +void CrystalConfig::save(TDEConfig*) +{ + config_->setGroup("General"); + + TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected(); + if (button) config_->writeEntry("TitleAlignment", TQString(button->name())); + config_->writeEntry("DrawCaption",dialog_->drawCaption->isChecked()); + config_->writeEntry("TextShadow",dialog_->textshadow->isChecked()); + config_->writeEntry("CaptionTooltip",dialog_->tooltip->isChecked()); + config_->writeEntry("WheelTask",dialog_->wheelTask->isChecked()); + + config_->writeEntry("EnableTransparency",dialog_->enableTransparency->isChecked()); + config_->writeEntry("TrackDesktop",dialog_->trackdesktop->isChecked()); + + config_->writeEntry("Borderwidth",dialog_->borderwidth->value()); + config_->writeEntry("Titlebarheight",dialog_->titlebarheight->value()); + + config_->writeEntry("ActiveShade",dialog_->shade1->value()); + config_->writeEntry("InactiveShade",dialog_->shade2->value()); + config_->writeEntry("ActiveFrame",dialog_->frame1->currentItem()); + config_->writeEntry("FrameColor1",dialog_->frameColor1->color()); + config_->writeEntry("InactiveFrame",dialog_->frame2->currentItem()); + config_->writeEntry("ActiveMode",dialog_->type1->currentItem()); + config_->writeEntry("InactiveMode",dialog_->type2->currentItem()); + config_->writeEntry("FrameColor2",dialog_->frameColor2->color()); + + config_->writeEntry("ActiveInline",dialog_->inline1->currentItem()); + config_->writeEntry("InlineColor1",dialog_->inlineColor1->color()); + config_->writeEntry("InactiveInline",dialog_->inline2->currentItem()); + config_->writeEntry("InlineColor2",dialog_->inlineColor2->color()); + + config_->writeEntry("ButtonColor",dialog_->buttonColor1->color()); + config_->writeEntry("ButtonColor2",dialog_->buttonColor2->color()); + config_->writeEntry("ButtonColor3",dialog_->buttonColor3->color()); + config_->writeEntry("MinColor",dialog_->minColor1->color()); + config_->writeEntry("MinColor2",dialog_->minColor2->color()); + config_->writeEntry("MinColor3",dialog_->minColor3->color()); + config_->writeEntry("MaxColor",dialog_->maxColor1->color()); + config_->writeEntry("MaxColor2",dialog_->maxColor2->color()); + config_->writeEntry("MaxColor3",dialog_->maxColor3->color()); + config_->writeEntry("CloseColor",dialog_->closeColor1->color()); + config_->writeEntry("CloseColor2",dialog_->closeColor2->color()); + config_->writeEntry("CloseColor3",dialog_->closeColor3->color()); + + int cornersFlag = 0; + if(dialog_->tlc->isChecked()) cornersFlag += TOP_LEFT; + if(dialog_->trc->isChecked()) cornersFlag += TOP_RIGHT; + if(dialog_->blc->isChecked()) cornersFlag += BOT_LEFT; + if(dialog_->brc->isChecked()) cornersFlag += BOT_RIGHT; + config_->writeEntry("RoundCorners", cornersFlag ); + + config_->writeEntry("HoverEffect",dialog_->hover->isChecked()); + config_->writeEntry("AnimateHover",dialog_->animateHover->isChecked()); + config_->writeEntry("TintButtons",dialog_->tintButtons->isChecked()); + config_->writeEntry("MenuImage",dialog_->menuimage->isChecked()); + + config_->writeEntry("ButtonTheme",dialog_->buttonTheme->currentItem()); + config_->writeEntry("RepaintMode",dialog_->repaintMode->selectedId()); + config_->writeEntry("RepaintTime",dialog_->updateTime->value()); + + config_->writeEntry("ActiveBlur",dialog_->active_blur->value()); + config_->writeEntry("InactiveBlur",dialog_->inactive_blur->value()); + + config_->writeEntry("ActiveUserdefined",dialog_->userPicture1->isChecked()); + config_->writeEntry("ActiveUserdefinedPicture",dialog_->activeFile->url()); + config_->writeEntry("InactiveUserdefined",dialog_->userPicture2->isChecked()); + config_->writeEntry("InactiveUserdefinedPicture",dialog_->inactiveFile->url()); + + config_->writeEntry("OverlayModeActive",dialog_->overlay_active->currentItem()); + config_->writeEntry("OverlayFileActive",dialog_->overlay_active_file->url()); + config_->writeEntry("OverlayModeInactive",dialog_->overlay_inactive->currentItem()); + config_->writeEntry("OverlayFileInactive",dialog_->overlay_inactive_file->url()); + + config_->writeEntry("LogoAlignment",dialog_->logoEnabled->selectedId()); + config_->writeEntry("LogoFile",dialog_->logoFile->url()); + config_->writeEntry("LogoActive",dialog_->logoActive->isChecked()); + config_->writeEntry("LogoStretch",dialog_->logoStretch->currentItem()); + config_->writeEntry("LogoDistance",dialog_->logoDistance->value()); + + config_->sync(); +} + +void CrystalConfig::infoDialog() +{ + InfoDialog d(dialog_); + connect((TQLabel*)(d.kURLLabel1),TQT_SIGNAL(leftClickedURL(const TQString&)),TDEApplication::kApplication(),TQT_SLOT(invokeBrowser(const TQString &))); + d.exec(); +} + +void CrystalConfig::logoTextChanged(const TQString&) +{ + updateLogo(); + emit changed(); +} + +void CrystalConfig::overlay_active_changed(int a) +{ + dialog_->overlay_active_file->setEnabled(a==4); + emit changed(); +} + +void CrystalConfig::overlay_inactive_changed(int a) +{ + dialog_->overlay_inactive_file->setEnabled(a==4); + emit changed(); +} + +void CrystalConfig::updateLogo() +{ + TQPixmap pic; + pic.load(dialog_->logoFile->url()); + dialog_->logoPreview->setPixmap(pic); +} + +void CrystalConfig::defaults() +{ + TQRadioButton *button = + (TQRadioButton*)dialog_->titlealign->child("AlignHCenter"); + if (button) button->setChecked(true); + dialog_->shade1->setValue(50); + dialog_->shade2->setValue(50); +} + +extern "C" +{ + TQObject* allocate_config(TDEConfig* config, TQWidget* parent) { + return (new CrystalConfig(config, parent)); + } +} + +#include "crystalconfig.moc" diff --git a/client/crystalclient.cc b/client/crystalclient.cc deleted file mode 100644 index 90b3429..0000000 --- a/client/crystalclient.cc +++ /dev/null @@ -1,1666 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Sascha Hlusiak * - * Spam84@gmx.de * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "config.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "crystalclient.h" -#include "crystalbutton.h" -#include "buttonimage.h" -#include "imageholder.h" -#include "overlays.h" - -#include -#include - -// Button themes -#include "tiles.h" - - -CrystalFactory* factory=NULL; - -bool CrystalFactory::initialized_ = false; -TQt::AlignmentFlags CrystalFactory::titlealign_ = TQt::AlignHCenter; - - -extern "C" KDecorationFactory* create_factory() -{ - return new CrystalFactory(); -} - - -/***************** - * Tooltip class for the titlebar - **/ -class CCrystalTooltip:public TQToolTip -{ -private: - CrystalClient *client; -public: - CCrystalTooltip(TQWidget *widget,CrystalClient *vc):TQToolTip(widget),client(vc) {} - virtual void maybeTip(const TQPoint& p) - { - if (client->titlebar_->geometry().contains(p)) - { - tip(client->titlebar_->geometry(),client->caption()); - } - } -}; - - - - -CrystalFactory::CrystalFactory() -{ - for (int i=0;isetUserdefinedPictures(active.userdefinedPicture,inactive.userdefinedPicture); - image_holder->repaint(true); - }else{ - if (image_holder)delete image_holder; - image_holder=NULL; - } - CreateButtonImages(); - - return true; -} - -bool CrystalFactory::supports(Ability ability) -{ - switch (ability) - { -#if KDE_IS_VERSION(3,4,0) - case AbilityButtonResize: return false; -#endif - default: - return true; - } -} - -void setupOverlay(WND_CONFIG *cfg,int mode,TQString filename) -{ - cfg->overlay.resize(0,0); - switch(mode) - { - case 0: break; - case 1:{ - cfg->overlay.resize(0,0); - TQImage img=TQImage((uchar*)lighting_overlay_data,1,60,32,NULL,0,TQImage::LittleEndian); - img.setAlphaBuffer(true); - cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); - break; - } - case 2:{ - cfg->overlay.resize(0,0); - TQImage img=TQImage((uchar*)glass_overlay_data,20,64,32,NULL,0,TQImage::LittleEndian); - img.setAlphaBuffer(true); - cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); - break; - } - case 3:{ - cfg->overlay.resize(0,0); - TQImage img=TQImage((uchar*)steel_overlay_data,28,64,32,NULL,0,TQImage::LittleEndian); - img.setAlphaBuffer(true); - cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); - break; - } - case 4:{ - TQImage img; - if (img.load(filename)) - { - img.setAlphaBuffer(true); - cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); - } - break; - } - } -} - -bool CrystalFactory::readConfig() -{ - // create a config object - TDEConfig config("twincrystalrc"); - config.setGroup("General"); - TQColor c; - - TQString value = config.readEntry("TitleAlignment", "AlignHCenter"); - if (value == "AlignLeft") titlealign_ = TQt::AlignLeft; - else if (value == "AlignHCenter") titlealign_ = TQt::AlignHCenter; - else if (value == "AlignRight") titlealign_ = TQt::AlignRight; - - drawcaption=(bool)config.readBoolEntry("DrawCaption",true); - textshadow=(bool)config.readBoolEntry("TextShadow",true); - captiontooltip=(bool)config.readBoolEntry("CaptionTooltip",true); - wheelTask=(bool)config.readBoolEntry("WheelTask",false); - transparency=(bool)config.readBoolEntry("EnableTransparency",true); - trackdesktop=(bool)config.readBoolEntry("TrackDesktop",false); - - active.mode=config.readNumEntry("ActiveMode",0); - inactive.mode=config.readNumEntry("InactiveMode",1); - active.amount=(double)config.readNumEntry("ActiveShade",30)/100.0; - inactive.amount=(double)config.readNumEntry("InactiveShade",-30)/100.0; - active.outlineMode=(int)config.readNumEntry("ActiveFrame",1); - inactive.outlineMode=(int)config.readNumEntry("InactiveFrame",1); - c=TQColor(160,160,160); - active.frameColor=config.readColorEntry("FrameColor1",&c); - c=TQColor(128,128,128); - inactive.frameColor=config.readColorEntry("FrameColor2",&c); - - active.inlineMode=(int)config.readNumEntry("ActiveInline",0); - inactive.inlineMode=(int)config.readNumEntry("InactiveInline",0); - c=TQColor(160,160,160); - active.inlineColor=config.readColorEntry("InlineColor1",&c); - c=TQColor(160,160,160); - inactive.inlineColor=config.readColorEntry("InlineColor2",&c); - - active.blur=config.readNumEntry("ActiveBlur",0); - inactive.blur=config.readNumEntry("InactiveBlur",0); - - active.userdefinedPicture=TQImage(); - inactive.userdefinedPicture=TQImage(); - if ((bool)config.readBoolEntry("ActiveUserdefined",false)) - { - active.userdefinedPicture.load(config.readEntry("ActiveUserdefinedPicture")); - } - if ((bool)config.readBoolEntry("InactiveUserdefined",false)) - { - inactive.userdefinedPicture.load(config.readEntry("InactiveUserdefinedPicture")); - } - - borderwidth=config.readNumEntry("Borderwidth",5); - titlesize=config.readNumEntry("Titlebarheight",21); - - buttonColor_normal=TQColor(255,255,255); - buttonColor_normal=config.readColorEntry("ButtonColor",&buttonColor_normal); - buttonColor_hovered=config.readColorEntry("ButtonColor2",&buttonColor_normal); - buttonColor_pressed=config.readColorEntry("ButtonColor3",&buttonColor_normal); - minColor_normal=TQColor(255,255,255); - minColor_normal=config.readColorEntry("MinColor",&buttonColor_normal); - minColor_hovered=config.readColorEntry("MinColor2",&buttonColor_normal); - minColor_pressed=config.readColorEntry("MinColor3",&buttonColor_normal); - maxColor_normal=TQColor(255,255,255); - maxColor_normal=config.readColorEntry("MaxColor",&buttonColor_normal); - maxColor_hovered=config.readColorEntry("MaxColor2",&buttonColor_normal); - maxColor_pressed=config.readColorEntry("MaxColor3",&buttonColor_normal); - closeColor_normal=TQColor(255,255,255); - closeColor_normal=config.readColorEntry("CloseColor",&closeColor_normal); - closeColor_hovered=config.readColorEntry("CloseColor2",&closeColor_normal); - closeColor_pressed=config.readColorEntry("CloseColor3",&closeColor_normal); - - roundCorners=config.readNumEntry("RoundCorners",TOP_LEFT & TOP_RIGHT); - - hovereffect=config.readBoolEntry("HoverEffect",true); - animateHover=config.readBoolEntry("AnimateHover",true); - tintButtons=config.readBoolEntry("TintButtons",false); - menuImage=config.readBoolEntry("MenuImage",true); - repaintMode=config.readNumEntry("RepaintMode",1); - repaintTime=config.readNumEntry("RepaintTime",200); - buttontheme=config.readNumEntry("ButtonTheme",8); - - - setupOverlay(&active,config.readNumEntry("OverlayModeActive",0),config.readEntry("OverlayFileActive","")); - setupOverlay(&inactive,config.readNumEntry("OverlayModeInactive",0),config.readEntry("OverlayFileInactive","")); - - logoEnabled=config.readNumEntry("LogoAlignment",1); - logoStretch=config.readNumEntry("LogoStretch",0); - logoActive=config.readBoolEntry("LogoActive",0); - logoDistance=config.readNumEntry("LogoDistance",0); - TQString filename=config.readEntry("LogoFile",""); - if (!filename.isNull() && logoEnabled!=1) - { - if (logo.load(filename)) - { - if (logoStretch==0) - { - logo=logo.convertToImage().smoothScale((titlesize*logo.width())/logo.height(),titlesize); - } - }else logoEnabled=1; - }else logo.resize(0,0); - return true; -} - -void CrystalFactory::CreateButtonImages() -{ - for (int i=0;ireset(); else - buttonImages[i]=new ButtonImage; - if (!tintButtons)buttonImages[i]->setColors(TQt::white,TQt::white,TQt::white); - else switch(i) - { - case ButtonImageMin: - buttonImages[i]->setColors(minColor_normal,minColor_hovered,minColor_pressed); - break; - case ButtonImageMax: - buttonImages[i]->setColors(maxColor_normal,maxColor_hovered,maxColor_pressed); - break; - case ButtonImageClose: - buttonImages[i]->setColors(closeColor_normal,closeColor_hovered,closeColor_pressed); - break; - - default: - buttonImages[i]->setColors(buttonColor_normal,buttonColor_hovered,buttonColor_pressed); - break; - } - } - - switch(buttontheme) - { - default: - case 0: // Crystal default - buttonImages[ButtonImageMenu]->SetNormal(crystal_menu_data); - buttonImages[ButtonImageHelp]->SetNormal(crystal_help_data); - buttonImages[ButtonImageMax]->SetNormal(crystal_max_data); - buttonImages[ButtonImageRestore]->SetNormal(crystal_restore_data); - buttonImages[ButtonImageMin]->SetNormal(crystal_min_data); - buttonImages[ButtonImageClose]->SetNormal(crystal_close_data); - buttonImages[ButtonImageSticky]->SetNormal(crystal_sticky_data); - buttonImages[ButtonImageUnSticky]->SetNormal(crystal_un_sticky_data); - buttonImages[ButtonImageShade]->SetNormal(crystal_shade_data); - buttonImages[ButtonImageUnShade]->SetNormal(crystal_shade_data); - - buttonImages[ButtonImageAbove]->SetNormal(crystal_above_data); - buttonImages[ButtonImageUnAbove]->SetNormal(crystal_unabove_data); - buttonImages[ButtonImageBelow]->SetNormal(crystal_below_data); - buttonImages[ButtonImageUnBelow]->SetNormal(crystal_unbelow_data); - break; - case 1: // Aqua buttons - buttonImages[ButtonImageMenu]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageHelp]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageMax]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageRestore]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageMin]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageClose]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageSticky]->SetNormal(aqua_sticky_data,16,16); - buttonImages[ButtonImageUnSticky]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageShade]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageUnShade]->SetNormal(aqua_default_data,16,16); - - buttonImages[ButtonImageAbove]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageUnAbove]->SetNormal(aqua_above_data,16,16); - buttonImages[ButtonImageBelow]->SetNormal(aqua_default_data,16,16); - buttonImages[ButtonImageUnBelow]->SetNormal(aqua_below_data,16,16); - - buttonImages[ButtonImageClose]->SetHovered(aqua_close_data); - buttonImages[ButtonImageMax]->SetHovered(aqua_max_data); - buttonImages[ButtonImageMin]->SetHovered(aqua_min_data); - buttonImages[ButtonImageRestore]->SetHovered(aqua_max_data); - buttonImages[ButtonImageUnSticky]->SetHovered(aqua_un_sticky_data); - buttonImages[ButtonImageHelp]->SetHovered(aqua_help_data); - buttonImages[ButtonImageAbove]->SetHovered(aqua_above_data); - buttonImages[ButtonImageBelow]->SetHovered(aqua_below_data); - buttonImages[ButtonImageShade]->SetHovered(aqua_shade_data); - buttonImages[ButtonImageUnShade]->SetHovered(aqua_shade_data); - break; - case 2: // Knifty buttons - buttonImages[ButtonImageHelp]->SetNormal(knifty_help_data); - buttonImages[ButtonImageMax]->SetNormal(knifty_max_data); - buttonImages[ButtonImageRestore]->SetNormal(knifty_restore_data); - buttonImages[ButtonImageMin]->SetNormal(knifty_min_data); - buttonImages[ButtonImageClose]->SetNormal(knifty_close_data); - buttonImages[ButtonImageSticky]->SetNormal(knifty_sticky_data); - buttonImages[ButtonImageUnSticky]->SetNormal(knifty_un_sticky_data); - buttonImages[ButtonImageShade]->SetNormal(knifty_shade_data); - buttonImages[ButtonImageUnShade]->SetNormal(knifty_shade_data); - - buttonImages[ButtonImageAbove]->SetNormal(knifty_above_data); - buttonImages[ButtonImageUnAbove]->SetNormal(knifty_unabove_data); - buttonImages[ButtonImageBelow]->SetNormal(knifty_below_data); - buttonImages[ButtonImageUnBelow]->SetNormal(knifty_unbelow_data); - break; - - case 3: // Handpainted - buttonImages[ButtonImageHelp]->SetNormal(handpainted_help_data); - buttonImages[ButtonImageMax]->SetNormal(handpainted_max_data); - buttonImages[ButtonImageRestore]->SetNormal(handpainted_restore_data); - buttonImages[ButtonImageMin]->SetNormal(handpainted_min_data); - buttonImages[ButtonImageClose]->SetNormal(handpainted_close_data); - buttonImages[ButtonImageSticky]->SetNormal(handpainted_sticky_data); - buttonImages[ButtonImageUnSticky]->SetNormal(handpainted_un_sticky_data); - buttonImages[ButtonImageShade]->SetNormal(handpainted_shade_data); - buttonImages[ButtonImageUnShade]->SetNormal(handpainted_un_shade_data); - - buttonImages[ButtonImageAbove]->SetNormal(handpainted_above_data); - buttonImages[ButtonImageUnAbove]->SetNormal(handpainted_unabove_data); - buttonImages[ButtonImageBelow]->SetNormal(handpainted_below_data); - buttonImages[ButtonImageUnBelow]->SetNormal(handpainted_unbelow_data); - break; - case 4: // SVG - buttonImages[ButtonImageMenu]->SetNormal(svg_menu_data); - buttonImages[ButtonImageHelp]->SetNormal(svg_help_data); - buttonImages[ButtonImageMax]->SetNormal(svg_max_data); - buttonImages[ButtonImageRestore]->SetNormal(svg_restore_data); - buttonImages[ButtonImageMin]->SetNormal(svg_min_data); - buttonImages[ButtonImageClose]->SetNormal(svg_close_data); - buttonImages[ButtonImageSticky]->SetNormal(svg_sticky_data); - buttonImages[ButtonImageUnSticky]->SetNormal(svg_unsticky_data); - buttonImages[ButtonImageShade]->SetNormal(svg_shade_data); - buttonImages[ButtonImageUnShade]->SetNormal(svg_shade_data); - - buttonImages[ButtonImageAbove]->SetNormal(svg_above_data); - buttonImages[ButtonImageUnAbove]->SetNormal(svg_above_data); - buttonImages[ButtonImageBelow]->SetNormal(svg_below_data); - buttonImages[ButtonImageUnBelow]->SetNormal(svg_below_data); - break; - case 5: // Vista - buttonImages[ButtonImageMenu]->SetNormal(vista_menu_data,26,15); - buttonImages[ButtonImageMenu]->SetHovered(vista_menu_hovered_data); - buttonImages[ButtonImageMenu]->SetPressed(vista_menu_pressed_data); - - buttonImages[ButtonImageHelp]->SetNormal(vista_help_data,26,15); - buttonImages[ButtonImageHelp]->SetHovered(vista_help_hovered_data); - buttonImages[ButtonImageHelp]->SetPressed(vista_help_pressed_data); - - buttonImages[ButtonImageMax]->SetNormal(vista_max_data,27,15); - buttonImages[ButtonImageMax]->SetHovered(vista_max_hovered_data); - buttonImages[ButtonImageMax]->SetPressed(vista_max_pressed_data); - buttonImages[ButtonImageRestore]->SetNormal(vista_restore_data,27,15); - buttonImages[ButtonImageRestore]->SetHovered(vista_restore_hovered_data); - buttonImages[ButtonImageRestore]->SetPressed(vista_restore_pressed_data); - buttonImages[ButtonImageMin]->SetNormal(vista_min_data,26,15); - buttonImages[ButtonImageMin]->SetHovered(vista_min_hovered_data); - buttonImages[ButtonImageMin]->SetPressed(vista_min_pressed_data); - buttonImages[ButtonImageClose]->SetNormal(vista_close_data,40,15); - buttonImages[ButtonImageClose]->SetHovered(vista_close_hovered_data); - buttonImages[ButtonImageClose]->SetPressed(vista_close_pressed_data); - - buttonImages[ButtonImageSticky]->SetNormal(vista_sticky_data,26,15); - buttonImages[ButtonImageSticky]->SetHovered(vista_sticky_hovered_data); - buttonImages[ButtonImageSticky]->SetPressed(vista_sticky_pressed_data); - buttonImages[ButtonImageUnSticky]->SetNormal(vista_un_sticky_data,26,15); - buttonImages[ButtonImageUnSticky]->SetHovered(vista_un_sticky_hovered_data); - buttonImages[ButtonImageUnSticky]->SetPressed(vista_un_sticky_pressed_data); - - buttonImages[ButtonImageAbove]->SetNormal(vista_above_data,26,15); - buttonImages[ButtonImageAbove]->SetHovered(vista_above_hovered_data); - buttonImages[ButtonImageAbove]->SetPressed(vista_above_pressed_data); - buttonImages[ButtonImageUnAbove]->SetNormal(vista_un_above_data,26,15); - buttonImages[ButtonImageUnAbove]->SetHovered(vista_un_above_hovered_data); - buttonImages[ButtonImageUnAbove]->SetPressed(vista_un_above_pressed_data); - - buttonImages[ButtonImageBelow]->SetNormal(vista_below_data,26,15); - buttonImages[ButtonImageBelow]->SetHovered(vista_below_hovered_data); - buttonImages[ButtonImageBelow]->SetPressed(vista_below_pressed_data); - buttonImages[ButtonImageUnBelow]->SetNormal(vista_un_below_data,26,15); - buttonImages[ButtonImageUnBelow]->SetHovered(vista_un_below_hovered_data); - buttonImages[ButtonImageUnBelow]->SetPressed(vista_un_below_pressed_data); - - buttonImages[ButtonImageShade]->SetNormal(vista_shade_data,26,15); - buttonImages[ButtonImageShade]->SetHovered(vista_shade_hovered_data); - buttonImages[ButtonImageShade]->SetPressed(vista_shade_pressed_data); - buttonImages[ButtonImageUnShade]->SetNormal(vista_un_shade_data,26,15); - buttonImages[ButtonImageUnShade]->SetHovered(vista_un_shade_hovered_data); - buttonImages[ButtonImageUnShade]->SetPressed(vista_un_shade_pressed_data); - - for (int i=0;isetSpace(1,0); - buttonImages[i]->setDrawMode(1); - } - buttonImages[ButtonImageMax]->setSpace(0,0); - buttonImages[ButtonImageRestore]->setSpace(0,0); - buttonImages[ButtonImageMin]->setSpace(0,0); - buttonImages[ButtonImageClose]->setSpace(0,0); - - break; - case 6: // Kubuntu Dapper - buttonImages[ButtonImageMenu]->SetNormal(dapper_menu_data,28,17); - buttonImages[ButtonImageMenu]->SetHovered(dapper_menu_hovered_data); - buttonImages[ButtonImageMenu]->SetPressed(dapper_menu_pressed_data); - - buttonImages[ButtonImageHelp]->SetNormal(dapper_help_data,28,17); - buttonImages[ButtonImageHelp]->SetHovered(dapper_help_hovered_data); - buttonImages[ButtonImageHelp]->SetPressed(dapper_help_pressed_data); - - buttonImages[ButtonImageMax]->SetNormal(dapper_max_data,28,17); - buttonImages[ButtonImageMax]->SetHovered(dapper_max_hovered_data); - buttonImages[ButtonImageMax]->SetPressed(dapper_max_pressed_data); - buttonImages[ButtonImageRestore]->SetNormal(dapper_restore_data,28,17); - buttonImages[ButtonImageRestore]->SetHovered(dapper_restore_hovered_data); - buttonImages[ButtonImageRestore]->SetPressed(dapper_restore_pressed_data); - buttonImages[ButtonImageMin]->SetNormal(dapper_min_data,28,17); - buttonImages[ButtonImageMin]->SetHovered(dapper_min_hovered_data); - buttonImages[ButtonImageMin]->SetPressed(dapper_min_pressed_data); - buttonImages[ButtonImageClose]->SetNormal(dapper_close_data,28,17); - buttonImages[ButtonImageClose]->SetHovered(dapper_close_hovered_data); - buttonImages[ButtonImageClose]->SetPressed(dapper_close_pressed_data); - - buttonImages[ButtonImageSticky]->SetNormal(dapper_sticky_data,28,17); - buttonImages[ButtonImageSticky]->SetHovered(dapper_sticky_hovered_data); - buttonImages[ButtonImageSticky]->SetPressed(dapper_sticky_pressed_data); - buttonImages[ButtonImageUnSticky]->SetNormal(dapper_un_sticky_data,28,17); - buttonImages[ButtonImageUnSticky]->SetHovered(dapper_un_sticky_hovered_data); - buttonImages[ButtonImageUnSticky]->SetPressed(dapper_un_sticky_pressed_data); - - buttonImages[ButtonImageAbove]->SetNormal(dapper_above_data,28,17); - buttonImages[ButtonImageAbove]->SetHovered(dapper_above_hovered_data); - buttonImages[ButtonImageAbove]->SetPressed(dapper_above_pressed_data); - buttonImages[ButtonImageUnAbove]->SetNormal(dapper_un_above_data,28,17); - buttonImages[ButtonImageUnAbove]->SetHovered(dapper_un_above_hovered_data); - buttonImages[ButtonImageUnAbove]->SetPressed(dapper_un_above_pressed_data); - - - buttonImages[ButtonImageBelow]->SetNormal(dapper_below_data,28,17); - buttonImages[ButtonImageBelow]->SetHovered(dapper_below_hovered_data); - buttonImages[ButtonImageBelow]->SetPressed(dapper_below_pressed_data); - - buttonImages[ButtonImageUnBelow]->SetNormal(dapper_un_below_data,28,17); - buttonImages[ButtonImageUnBelow]->SetHovered(dapper_un_below_hovered_data); - buttonImages[ButtonImageUnBelow]->SetPressed(dapper_un_below_pressed_data); - - buttonImages[ButtonImageShade]->SetNormal(dapper_shade_data,28,17); - buttonImages[ButtonImageShade]->SetHovered(dapper_shade_hovered_data); - buttonImages[ButtonImageShade]->SetPressed(dapper_shade_pressed_data); - buttonImages[ButtonImageUnShade]->SetNormal(dapper_un_shade_data,28,17); - buttonImages[ButtonImageUnShade]->SetHovered(dapper_un_shade_hovered_data); - buttonImages[ButtonImageUnShade]->SetPressed(dapper_un_shade_pressed_data); - - for (int i=0;isetSpace(1,0); - buttonImages[i]->setDrawMode(0); - } - buttonImages[ButtonImageMax]->setSpace(0,0); - buttonImages[ButtonImageRestore]->setSpace(0,0); - buttonImages[ButtonImageMin]->setSpace(0,0); - buttonImages[ButtonImageClose]->setSpace(0,0); - break; - - case 7: // Kubuntu-Edgy - buttonImages[ButtonImageMenu]->SetNormal(edgy_menu_data,28,17); - buttonImages[ButtonImageMenu]->SetHovered(edgy_menu_hovered_data); - buttonImages[ButtonImageMenu]->SetPressed(edgy_menu_pressed_data); - - buttonImages[ButtonImageHelp]->SetNormal(edgy_help_data,28,17); - buttonImages[ButtonImageHelp]->SetHovered(edgy_help_hovered_data); - buttonImages[ButtonImageHelp]->SetPressed(edgy_help_pressed_data); - - buttonImages[ButtonImageMax]->SetNormal(edgy_max_data,28,17); - buttonImages[ButtonImageMax]->SetHovered(edgy_max_hovered_data); - buttonImages[ButtonImageMax]->SetPressed(edgy_max_pressed_data); - buttonImages[ButtonImageRestore]->SetNormal(edgy_restore_data,28,17); - buttonImages[ButtonImageRestore]->SetHovered(edgy_restore_hovered_data); - buttonImages[ButtonImageRestore]->SetPressed(edgy_restore_pressed_data); - buttonImages[ButtonImageMin]->SetNormal(edgy_min_data,28,17); - buttonImages[ButtonImageMin]->SetHovered(edgy_min_hovered_data); - buttonImages[ButtonImageMin]->SetPressed(edgy_min_pressed_data); - buttonImages[ButtonImageClose]->SetNormal(edgy_close_data,28,17); - buttonImages[ButtonImageClose]->SetHovered(edgy_close_hovered_data); - buttonImages[ButtonImageClose]->SetPressed(edgy_close_pressed_data); - - buttonImages[ButtonImageSticky]->SetNormal(edgy_sticky_data,28,17); - buttonImages[ButtonImageSticky]->SetHovered(edgy_sticky_hovered_data); - buttonImages[ButtonImageSticky]->SetPressed(edgy_sticky_pressed_data); - buttonImages[ButtonImageUnSticky]->SetNormal(edgy_un_sticky_data,28,17); - buttonImages[ButtonImageUnSticky]->SetHovered(edgy_un_sticky_hovered_data); - buttonImages[ButtonImageUnSticky]->SetPressed(edgy_un_sticky_pressed_data); - - buttonImages[ButtonImageAbove]->SetNormal(edgy_above_data,28,17); - buttonImages[ButtonImageAbove]->SetHovered(edgy_above_hovered_data); - buttonImages[ButtonImageAbove]->SetPressed(edgy_above_pressed_data); - buttonImages[ButtonImageUnAbove]->SetNormal(edgy_un_above_data,28,17); - buttonImages[ButtonImageUnAbove]->SetHovered(edgy_un_above_hovered_data); - buttonImages[ButtonImageUnAbove]->SetPressed(edgy_un_above_pressed_data); - - - buttonImages[ButtonImageBelow]->SetNormal(edgy_below_data,28,17); - buttonImages[ButtonImageBelow]->SetHovered(edgy_below_hovered_data); - buttonImages[ButtonImageBelow]->SetPressed(edgy_below_pressed_data); - - buttonImages[ButtonImageUnBelow]->SetNormal(edgy_un_below_data,28,17); - buttonImages[ButtonImageUnBelow]->SetHovered(edgy_un_below_hovered_data); - buttonImages[ButtonImageUnBelow]->SetPressed(edgy_un_below_pressed_data); - - buttonImages[ButtonImageShade]->SetNormal(edgy_shade_data,28,17); - buttonImages[ButtonImageShade]->SetHovered(edgy_shade_hovered_data); - buttonImages[ButtonImageShade]->SetPressed(edgy_shade_pressed_data); - buttonImages[ButtonImageUnShade]->SetNormal(edgy_un_shade_data,28,17); - buttonImages[ButtonImageUnShade]->SetHovered(edgy_un_shade_hovered_data); - buttonImages[ButtonImageUnShade]->SetPressed(edgy_un_shade_pressed_data); - - for (int i=0;isetSpace(1,0); - buttonImages[i]->setDrawMode(0); - } - buttonImages[ButtonImageMax]->setSpace(0,0); - buttonImages[ButtonImageRestore]->setSpace(0,0); - buttonImages[ButtonImageMin]->setSpace(0,0); - buttonImages[ButtonImageClose]->setSpace(0,0); - - break; - case 8: // Kubuntu-Feisty - buttonImages[ButtonImageMenu]->SetNormal(feisty_menu_data,21,17); - buttonImages[ButtonImageMenu]->SetHovered(feisty_menu_hovered_data); - buttonImages[ButtonImageMenu]->SetPressed(feisty_menu_pressed_data); - - buttonImages[ButtonImageHelp]->SetNormal(feisty_help_data,28,17); - buttonImages[ButtonImageHelp]->SetHovered(feisty_help_hovered_data); - buttonImages[ButtonImageHelp]->SetPressed(feisty_help_pressed_data); - - buttonImages[ButtonImageMax]->SetNormal(feisty_max_data,28,17); - buttonImages[ButtonImageMax]->SetHovered(feisty_max_hovered_data); - buttonImages[ButtonImageMax]->SetPressed(feisty_max_pressed_data); - buttonImages[ButtonImageRestore]->SetNormal(feisty_restore_data,28,17); - buttonImages[ButtonImageRestore]->SetHovered(feisty_restore_hovered_data); - buttonImages[ButtonImageRestore]->SetPressed(feisty_restore_pressed_data); - buttonImages[ButtonImageMin]->SetNormal(feisty_min_data,28,17); - buttonImages[ButtonImageMin]->SetHovered(feisty_min_hovered_data); - buttonImages[ButtonImageMin]->SetPressed(feisty_min_pressed_data); - buttonImages[ButtonImageClose]->SetNormal(feisty_close_data,28,17); - buttonImages[ButtonImageClose]->SetHovered(feisty_close_hovered_data); - buttonImages[ButtonImageClose]->SetPressed(feisty_close_pressed_data); - - buttonImages[ButtonImageSticky]->SetNormal(feisty_sticky_data,28,17); - buttonImages[ButtonImageSticky]->SetHovered(feisty_sticky_hovered_data); - buttonImages[ButtonImageSticky]->SetPressed(feisty_sticky_pressed_data); - buttonImages[ButtonImageUnSticky]->SetNormal(feisty_un_sticky_data,28,17); - buttonImages[ButtonImageUnSticky]->SetHovered(feisty_un_sticky_hovered_data); - buttonImages[ButtonImageUnSticky]->SetPressed(feisty_un_sticky_pressed_data); - - buttonImages[ButtonImageAbove]->SetNormal(feisty_above_data,28,17); - buttonImages[ButtonImageAbove]->SetHovered(feisty_above_hovered_data); - buttonImages[ButtonImageAbove]->SetPressed(feisty_above_pressed_data); - buttonImages[ButtonImageUnAbove]->SetNormal(feisty_un_above_data,28,17); - buttonImages[ButtonImageUnAbove]->SetHovered(feisty_un_above_hovered_data); - buttonImages[ButtonImageUnAbove]->SetPressed(feisty_un_above_pressed_data); - - - buttonImages[ButtonImageBelow]->SetNormal(feisty_below_data,28,17); - buttonImages[ButtonImageBelow]->SetHovered(feisty_below_hovered_data); - buttonImages[ButtonImageBelow]->SetPressed(feisty_below_pressed_data); - - buttonImages[ButtonImageUnBelow]->SetNormal(feisty_un_below_data,28,17); - buttonImages[ButtonImageUnBelow]->SetHovered(feisty_un_below_hovered_data); - buttonImages[ButtonImageUnBelow]->SetPressed(feisty_un_below_pressed_data); - - buttonImages[ButtonImageShade]->SetNormal(feisty_shade_data,28,17); - buttonImages[ButtonImageShade]->SetHovered(feisty_shade_hovered_data); - buttonImages[ButtonImageShade]->SetPressed(feisty_shade_pressed_data); - buttonImages[ButtonImageUnShade]->SetNormal(feisty_un_shade_data,28,17); - buttonImages[ButtonImageUnShade]->SetHovered(feisty_un_shade_hovered_data); - buttonImages[ButtonImageUnShade]->SetPressed(feisty_un_shade_pressed_data); - - for (int i=0;isetSpace(1,0); - buttonImages[i]->setDrawMode(0); - } - buttonImages[ButtonImageMax]->setSpace(0,0); - buttonImages[ButtonImageRestore]->setSpace(0,0); - buttonImages[ButtonImageMin]->setSpace(0,0); - buttonImages[ButtonImageClose]->setSpace(0,0); - - break; - case 9: // Kubuntu-hardy - buttonImages[ButtonImageMenu]->SetNormal(hardy_menu_data,28,17); - buttonImages[ButtonImageMenu]->SetHovered(hardy_menu_hovered_data); - buttonImages[ButtonImageMenu]->SetPressed(hardy_menu_pressed_data); - - buttonImages[ButtonImageHelp]->SetNormal(hardy_help_data,28,17); - buttonImages[ButtonImageHelp]->SetHovered(hardy_help_hovered_data); - buttonImages[ButtonImageHelp]->SetPressed(hardy_help_pressed_data); - - buttonImages[ButtonImageMax]->SetNormal(hardy_max_data,28,17); - buttonImages[ButtonImageMax]->SetHovered(hardy_max_hovered_data); - buttonImages[ButtonImageMax]->SetPressed(hardy_max_pressed_data); - buttonImages[ButtonImageRestore]->SetNormal(hardy_restore_data,28,17); - buttonImages[ButtonImageRestore]->SetHovered(hardy_restore_hovered_data); - buttonImages[ButtonImageRestore]->SetPressed(hardy_restore_pressed_data); - buttonImages[ButtonImageMin]->SetNormal(hardy_min_data,28,17); - buttonImages[ButtonImageMin]->SetHovered(hardy_min_hovered_data); - buttonImages[ButtonImageMin]->SetPressed(hardy_min_pressed_data); - buttonImages[ButtonImageClose]->SetNormal(hardy_close_data,28,17); - buttonImages[ButtonImageClose]->SetHovered(hardy_close_hovered_data); - buttonImages[ButtonImageClose]->SetPressed(hardy_close_pressed_data); - - buttonImages[ButtonImageSticky]->SetNormal(hardy_sticky_data,28,17); - buttonImages[ButtonImageSticky]->SetHovered(hardy_sticky_hovered_data); - buttonImages[ButtonImageSticky]->SetPressed(hardy_sticky_pressed_data); - buttonImages[ButtonImageUnSticky]->SetNormal(hardy_un_sticky_data,28,17); - buttonImages[ButtonImageUnSticky]->SetHovered(hardy_un_sticky_hovered_data); - buttonImages[ButtonImageUnSticky]->SetPressed(hardy_un_sticky_pressed_data); - - buttonImages[ButtonImageAbove]->SetNormal(hardy_above_data,28,17); - buttonImages[ButtonImageAbove]->SetHovered(hardy_above_hovered_data); - buttonImages[ButtonImageAbove]->SetPressed(hardy_above_pressed_data); - buttonImages[ButtonImageUnAbove]->SetNormal(hardy_un_above_data,28,17); - buttonImages[ButtonImageUnAbove]->SetHovered(hardy_un_above_hovered_data); - buttonImages[ButtonImageUnAbove]->SetPressed(hardy_un_above_pressed_data); - - - buttonImages[ButtonImageBelow]->SetNormal(hardy_below_data,28,17); - buttonImages[ButtonImageBelow]->SetHovered(hardy_below_hovered_data); - buttonImages[ButtonImageBelow]->SetPressed(hardy_below_pressed_data); - - buttonImages[ButtonImageUnBelow]->SetNormal(hardy_un_below_data,28,17); - buttonImages[ButtonImageUnBelow]->SetHovered(hardy_un_below_hovered_data); - buttonImages[ButtonImageUnBelow]->SetPressed(hardy_un_below_pressed_data); - - buttonImages[ButtonImageShade]->SetNormal(hardy_shade_data,28,17); - buttonImages[ButtonImageShade]->SetHovered(hardy_shade_hovered_data); - buttonImages[ButtonImageShade]->SetPressed(hardy_shade_pressed_data); - buttonImages[ButtonImageUnShade]->SetNormal(hardy_un_shade_data,28,17); - buttonImages[ButtonImageUnShade]->SetHovered(hardy_un_shade_hovered_data); - buttonImages[ButtonImageUnShade]->SetPressed(hardy_un_shade_pressed_data); - - for (int i=0;isetSpace(1,0); - buttonImages[i]->setDrawMode(0); - } - buttonImages[ButtonImageMax]->setSpace(0,0); - buttonImages[ButtonImageRestore]->setSpace(0,0); - buttonImages[ButtonImageMin]->setSpace(0,0); - buttonImages[ButtonImageClose]->setSpace(0,0); - - break; - - } - - - for (int i=0;ifinish(); -} - - - - - - - - -CrystalClient::CrystalClient(KDecorationBridge *b,CrystalFactory *f) -: KDecoration(b,f) -{ - ::factory->clients.append(this); -} - -CrystalClient::~CrystalClient() -{ - ::factory->clients.remove(this); - for (int n=0; ninstallEventFilter(this); - - FullMax=false; - if (!options()->moveResizeMaximizedWindows()) - FullMax=(maximizeMode()==MaximizeFull); - - // for flicker-free redraws - widget()->setBackgroundMode(NoBackground); - - // setup layout - mainlayout = new TQGridLayout(widget(), 4, 3); // 4x3 grid - titlelayout = new TQHBoxLayout(); - titlebar_ = new TQSpacerItem(1, ::factory->titlesize-1, TQSizePolicy::Expanding, - TQSizePolicy::Fixed); - - mainlayout->setResizeMode(TQLayout::FreeResize); - mainlayout->setRowSpacing(0, (::factory->buttontheme==5)?0:1); - mainlayout->setRowSpacing(3, ::factory->borderwidth*1); - - mainlayout->setColSpacing(2,borderSpacing()); - mainlayout->setColSpacing(0,borderSpacing()); - mainlayout->addLayout(titlelayout, 1, 1); - - if (isPreview()) { - char c[512]; - sprintf(c,"
Crystal %s Preview
Built: %s
",VERSION,__DATE__); - mainlayout->addItem(new TQSpacerItem(1, 1,TQSizePolicy::Expanding,TQSizePolicy::Fixed), 0, 1); - mainlayout->addItem(new TQSpacerItem(1, ::factory->borderwidth,TQSizePolicy::Expanding,TQSizePolicy::Expanding), 3, 1); - mainlayout->addWidget(new TQLabel(i18n(c),widget()), 2, 1); - } else { - mainlayout->addItem(new TQSpacerItem(0, 0), 2, 1); - } - - mainlayout->setRowStretch(2, 10); - mainlayout->setColStretch(1, 10); - - updateMask(); - - for (int n=0; ntitleButtonsLeft()); - titlelayout->addItem(titlebar_); - { - CrystalButton* lastbutton=addButtons(titlelayout, options()->titleButtonsRight()); - if (lastbutton)lastbutton->setFirstLast(false,true); - } - - if (::factory->captiontooltip) new CCrystalTooltip(widget(),this); - - connect( this, TQT_SIGNAL( keepAboveChanged( bool )), TQT_SLOT( keepAboveChange( bool ))); - connect( this, TQT_SIGNAL( keepBelowChanged( bool )), TQT_SLOT( keepBelowChange( bool ))); - - if (::factory->transparency)connect ( ::factory->image_holder,TQT_SIGNAL(repaintNeeded()),this,TQT_SLOT(Repaint())); - if (::factory->transparency)connect ( &timer,TQT_SIGNAL(timeout()),this,TQT_SLOT(Repaint())); - - updateLayout(); -} - -void CrystalClient::updateMask() -{ - if ((::factory->roundCorners==0)|| (!options()->moveResizeMaximizedWindows() && maximizeMode() & MaximizeFull ) ) - { - setMask(TQRegion(widget()->rect())); - return; - } - - int cornersFlag = ::factory->roundCorners; - int r(width()); - int b(height()); - TQRegion mask; - - mask=TQRegion(widget()->rect()); - - // Remove top-left corner. - if(cornersFlag & TOP_LEFT) { - mask -= TQRegion(0, 0, 5, 1); - mask -= TQRegion(0, 1, 3, 1); - mask -= TQRegion(0, 2, 2, 1); - mask -= TQRegion(0, 3, 1, 2); - } - // Remove top-right corner. - if(cornersFlag & TOP_RIGHT) { - 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); - } - // Remove bottom-left corner. - if(cornersFlag & BOT_LEFT) { - mask -= TQRegion(0, b - 5, 1, 3); - mask -= TQRegion(0, b - 3, 2, 1); - mask -= TQRegion(0, b - 2, 3, 1); - mask -= TQRegion(0, b - 1, 5, 1); - } - // Remove bottom-right corner. - if(cornersFlag & BOT_RIGHT) { - mask -= TQRegion(r - 5, b - 1, 5, 1); - mask -= TQRegion(r - 3, b - 2, 3, 1); - mask -= TQRegion(r - 2, b - 3, 2, 1); - mask -= TQRegion(r - 1, b - 5, 1, 2); - } - - setMask(mask); -} - -bool CrystalClient::isModalSystemNotification() -{ - unsigned char *data = 0; - Atom actual; - int format, result; - unsigned long n, left; - Atom kde_wm_system_modal_notification; - kde_wm_system_modal_notification = XInternAtom(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); - result = XGetWindowProperty(tqt_xdisplay(), windowId(), kde_wm_system_modal_notification, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, /*(unsigned char **)*/ &data); - if (result == Success && data != None && format == 32 ) - { - return TRUE; - } - return FALSE; -} - -CrystalButton* CrystalClient::addButtons(TQBoxLayout *layout, const TQString& s) -{ - ButtonImage *bitmap; - TQString tip; - CrystalButton *lastone=NULL; - - if (s.length() > 0) - { - for (unsigned n=0; n < s.length(); n++) - { - CrystalButton *current=NULL; - switch (s[n]) { - case 'M': // Menu button - if (!isModalSystemNotification()) { - if (!button[ButtonMenu]) { - button[ButtonMenu] = current = new CrystalButton(this, "menu", i18n("Menu"), ButtonMenu, ::factory->buttonImages[ButtonImageMenu]); - connect(button[ButtonMenu], TQT_SIGNAL(pressed()), this, TQT_SLOT(menuButtonPressed())); - } - } - break; - - case 'S': // Sticky button - if (!isModalSystemNotification()) { - if (!button[ButtonSticky]) { - if (isOnAllDesktops()) { - bitmap = ::factory->buttonImages[ButtonImageSticky]; - tip = i18n("Not on all desktops"); - } else { - bitmap = ::factory->buttonImages[ButtonImageUnSticky]; - tip = i18n("On All Desktops"); - } - button[ButtonSticky] =current=new CrystalButton(this, "sticky", tip,ButtonSticky, bitmap); - connect(button[ButtonSticky], TQT_SIGNAL(clicked()),this, TQT_SLOT(toggleOnAllDesktops())); - } - } - break; - - case 'H': // Help button - if (providesContextHelp()) { - button[ButtonHelp] =current= - new CrystalButton(this, "help", i18n("Help"),ButtonHelp, ::factory->buttonImages[ButtonImageHelp]); - connect(button[ButtonHelp], TQT_SIGNAL(clicked()),this, TQT_SLOT(showContextHelp())); - } - break; - - case 'I': // Minimize button - if ((!button[ButtonMin]) && isMinimizable()) { - button[ButtonMin] =current= - new CrystalButton(this, "iconify", i18n("Minimize"),ButtonMin, ::factory->buttonImages[ButtonImageMin]); - connect(button[ButtonMin], TQT_SIGNAL(clicked()),this, TQT_SLOT(minButtonPressed())); - } - break; - - case 'F': // Above button - if (!button[ButtonAbove]) { - button[ButtonAbove] =current= - new CrystalButton(this, "above", i18n("Keep Above Others"),ButtonAbove, ::factory->buttonImages[keepAbove()?ButtonImageUnAbove:ButtonImageAbove]); - connect(button[ButtonAbove], TQT_SIGNAL(clicked()),this, TQT_SLOT(aboveButtonPressed())); - } - break; - - case 'B': // Below button - if ((!button[ButtonBelow])) { - button[ButtonBelow] =current= - new CrystalButton(this, "below", i18n("Keep Below Others"),ButtonBelow, ::factory->buttonImages[keepBelow()?ButtonImageUnBelow:ButtonImageBelow]); - connect(button[ButtonBelow], TQT_SIGNAL(clicked()),this, TQT_SLOT(belowButtonPressed())); - } - break; - - case 'L': // Shade button - if ((!button[ButtonShade]) && isShadeable()) { - button[ButtonShade] =current= - new CrystalButton(this, "shade", i18n("Shade"),ButtonShade, ::factory->buttonImages[ButtonImageShade]); - connect(button[ButtonShade], TQT_SIGNAL(clicked()),this, TQT_SLOT(shadeButtonPressed())); - } - break; - - case 'A': // Maximize button - if ((!button[ButtonMax]) && isMaximizable()) - { - if (maximizeMode() == MaximizeFull) - { - bitmap = ::factory->buttonImages[ButtonImageRestore]; - tip = i18n("Restore"); - } else { - bitmap = ::factory->buttonImages[ButtonImageMax]; - tip = i18n("Maximize"); - } - button[ButtonMax] =current= - new CrystalButton(this, "maximize", tip,ButtonMax, bitmap); - connect(button[ButtonMax], TQT_SIGNAL(clicked()),this, TQT_SLOT(maxButtonPressed())); - } - break; - - case 'X': // Close button - if (isCloseable()) { - button[ButtonClose] =current= - new CrystalButton(this, "close", i18n("Close"),ButtonClose, ::factory->buttonImages[ButtonImageClose]); - connect(button[ButtonClose], TQT_SIGNAL(clicked()),this, TQT_SLOT(closeButtonPressed())); - } - break; - - case '_': // Spacer item - layout->addSpacing(4); - current=NULL; - break; - } - - if (current) - { - layout->addWidget(current); - if (layout->findWidget(current)==0)current->setFirstLast(true,false); - } - lastone=current; - } - } - return lastone; -} - -void CrystalClient::activeChange() -{ - Repaint(); - if (isActive()) ::factory->clients.at(::factory->clients.find(this)); -} - -void CrystalClient::captionChange() -{ - if (::factory->drawcaption) widget()->repaint(titlebar_->geometry(), false); -} - -void CrystalClient::desktopChange() -{ - bool d = isOnAllDesktops(); - if (button[ButtonSticky]) { - button[ButtonSticky]->setBitmap(::factory->buttonImages[d ? ButtonImageSticky : ButtonImageUnSticky ]); - TQToolTip::remove(button[ButtonSticky]); - TQToolTip::add(button[ButtonSticky], d ? i18n("Not on all desktops") : i18n("On All Desktops")); - } -} - -void CrystalClient::iconChange() -{ - if (button[ButtonMenu]) { - button[ButtonMenu]->setBitmap(::factory->buttonImages[ButtonImageMenu]); - } -} - -void CrystalClient::maximizeChange() -{ - bool m = (maximizeMode() == MaximizeFull); - if (button[ButtonMax]) { - button[ButtonMax]->setBitmap(::factory->buttonImages[ m ? ButtonImageRestore : ButtonImageMax ]); - TQToolTip::remove(button[ButtonMax]); - TQToolTip::add(button[ButtonMax], m ? i18n("Restore") : i18n("Maximize")); - } - - if (!options()->moveResizeMaximizedWindows()) - { - FullMax=m; - updateLayout(); - Repaint(); - } -} - -void CrystalClient::updateLayout() -{ - if (FullMax) - { - mainlayout->setColSpacing(0,0); - mainlayout->setColSpacing(2,0); - }else{ - mainlayout->setColSpacing(2,borderSpacing()); - mainlayout->setColSpacing(0,borderSpacing()); - } - - mainlayout->setRowSpacing(0, (FullMax||::factory->buttontheme==5)?0:1); - for (int i=0;iresetSize(FullMax); - widget()->layout()->activate(); -} - -int CrystalClient::borderSpacing() -{ - if (::factory->roundCorners) - return (::factory->borderwidth<=5)?5: ::factory->borderwidth; - return (::factory->borderwidth<=1)?1: ::factory->borderwidth; -} - -void CrystalClient::shadeChange() -{ - if (button[ButtonShade]) - { - button[ButtonShade]->setBitmap(::factory->buttonImages[isShade()?ButtonImageUnShade:ButtonImageShade]); - } - if (!::factory->transparency)Repaint(); - return; -} - -void CrystalClient::borders(int &l, int &r, int &t, int &b) const -{ - l = r = ::factory->borderwidth; - t = ::factory->titlesize; - if (!isShade())b = ::factory->borderwidth; else b=0; - - if (!options()->moveResizeMaximizedWindows() ) - { - if ( maximizeMode() & MaximizeHorizontal )l=r=1; - if ( maximizeMode() & MaximizeVertical ) - { - b=isShade()?0:1; - if (!isShade() && ( maximizeMode() & MaximizeHorizontal ))b=0; - } - if ( (maximizeMode() & MaximizeFull)==MaximizeFull) - l=r=0; - } -} - -void CrystalClient::resize(const TQSize &size) -{ - widget()->resize(size); -} - -TQSize CrystalClient::minimumSize() const -{ - return widget()->minimumSize(); -} - -KDecoration::Position CrystalClient::mousePosition(const TQPoint &point) const -{ - const int corner = 20; - Position pos; - const int RESIZESIZE=::factory->borderwidth; - - if (isShade() || !isResizable()) pos=PositionCenter; - else if (point.y() <= 3) { - // inside top frame - if (point.x() <= corner) pos = PositionTopLeft; - else if (point.x() >= (width()-corner)) pos = PositionTopRight; - else pos = PositionTop; - } else if (point.y() >= (height()-RESIZESIZE)) { - // inside handle - if (point.x() <= corner) pos = PositionBottomLeft; - else if (point.x() >= (width()-corner)) pos = PositionBottomRight; - else pos = PositionBottom; - } else if (point.x() <= RESIZESIZE) { - // on left frame - if (point.y() <= corner) pos = PositionTopLeft; - else if (point.y() >= (height()-corner)) pos = PositionBottomLeft; - else pos = PositionLeft; - } else if (point.x() >= width()-RESIZESIZE) { - // on right frame - if (point.y() <= corner) pos = PositionTopRight; - else if (point.y() >= (height()-corner)) pos = PositionBottomRight; - else pos = PositionRight; - } else { - // inside the frame - pos = PositionCenter; - } - return pos; -} - -bool CrystalClient::eventFilter(TQObject *obj, TQEvent *e) -{ - if (TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(widget())) return false; - - switch (e->type()) { - case TQEvent::MouseButtonDblClick: - mouseDoubleClickEvent(TQT_TQMOUSEEVENT(e)); - return true; - case TQEvent::MouseButtonPress: - processMousePressEvent(TQT_TQMOUSEEVENT(e)); - return true; - case TQEvent::Paint: - paintEvent(TQT_TQPAINTEVENT(e)); - return true; - case TQEvent::Wheel: - mouseWheelEvent(TQT_TQWHEELEVENT(e)); - return true; - - case TQEvent::Resize: - resizeEvent(TQT_TQRESIZEEVENT(e)); - return true; - - case TQEvent::Show: - showEvent(TQT_TQSHOWEVENT(e)); - return true; - case TQEvent::Move: - moveEvent(TQT_TQMOVEEVENT(e)); - return true; - default:return false; - } - - return false; -} - -void CrystalClient::ClientWindows(Window* v_frame,Window* v_wrapper,Window *v_client) -{ - Window root=0,frame=0,wrapper=0,client=0,parent=0,*children=NULL; - uint numc; - if (v_frame) *v_frame=0; - if (v_wrapper) *v_wrapper=0; - if (v_client) *v_client=0; - // Our Deco is the child of a frame, get our parent - if (XQueryTree(tqt_xdisplay(),widget()->winId(),&root,&frame,&children,&numc) == 0) - return; - if (children!=NULL)XFree(children); - children=NULL; - - // frame has two children, us and a wrapper, get the wrapper - if (XQueryTree(tqt_xdisplay(),frame,&root,&parent,&children,&numc)==0) - return; - - for (uint i=0;iwinId())wrapper=children[i]; - } - if (children!=NULL)XFree(children); - children=NULL; - - // wrapper has only one child, which is the client. We want this!! - if (XQueryTree(tqt_xdisplay(),wrapper,&root,&parent,&children,&numc)==0) - return; - if (numc==1)client=children[0]; - if (children!=NULL)XFree(children); - children=NULL; - if (v_client) *v_client=client; - if (v_wrapper) *v_wrapper=wrapper; - if (v_frame) *v_frame=frame; -} - -void CrystalClient::mouseDoubleClickEvent(TQMouseEvent *e) -{ - if (/*(titlebar_->geometry().contains(e->pos()))&&*/(e->button()==Qt::LeftButton)) titlebarDblClickOperation(); - else { - TQMouseEvent me(TQEvent::MouseButtonPress,e->pos(),e->button(),e->state()); - processMousePressEvent(&me); - } -} - -void CrystalClient::mouseWheelEvent(TQWheelEvent *e) -{ - if (::factory->wheelTask) - { - TQPtrList *l=&(::factory->clients); - - if (l->current()==NULL) for (unsigned int i=0;icount();i++) if ((l->at(i))->isActive()) break; - - CrystalClient *n=this; - Window client,frame,wrapper; - do - { - if(e->delta()>0) - { - n=l->next(); - if (n==NULL)n=l->first(); - }else{ - n=l->prev(); - if (n==NULL)n=l->last(); - } - - n->ClientWindows(&frame,&wrapper,&client); - if (client == 0) { /* FALLBACK */ -#if KDE_IS_VERSION(3,5,0) - titlebarMouseWheelOperation(e->delta()); -#endif - return; - } - KWin::WindowInfo info=KWin::windowInfo(client); - if ((n->desktop()==desktop()) && !info.isMinimized())break; - }while(n!=this); - - KWin::activateWindow(client); - }else{ -#if KDE_IS_VERSION(3,5,0) - titlebarMouseWheelOperation(e->delta()); -#endif - } -} - -void CrystalClient::paintEvent(TQPaintEvent*) -{ - if (!CrystalFactory::initialized()) return; - - TQColorGroup group; - TQPainter painter(widget()); - - // draw the titlebar - group = options()->colorGroup(KDecoration::ColorTitleBar, isActive()); - WND_CONFIG* wndcfg=(isActive()?&::factory->active:&::factory->inactive); - - if (::factory->transparency && ::factory->trackdesktop) - ::factory->image_holder->repaint(false); // If other desktop than the last, regrab the root image - TQPixmap *background=::factory->transparency?::factory->image_holder->image(isActive()):NULL; - int drawFrame; - - { - TQRect r; - TQPoint p=widget()->mapToGlobal(TQPoint(0,0)); - int bl,br,bt,bb; - borders(bl,br,bt,bb); - - TQPixmap pufferPixmap; - pufferPixmap.resize(widget()->width(), bt); - TQPainter pufferPainter(&pufferPixmap); - - r=TQRect(p.x(),p.y(),widget()->width(),bt); - if (background && !background->isNull())pufferPainter.drawPixmap(TQPoint(0,0),*background,r); - else - { - pufferPainter.fillRect(widget()->rect(),group.background()); - } - if (!wndcfg->overlay.isNull()) - { - pufferPainter.drawTiledPixmap(0,0,widget()->width(),bt,wndcfg->overlay); - } - - if (::factory->drawcaption) - { - // draw title text - pufferPainter.setFont(options()->font(isActive(), false)); - - TQColor color=options()->color(KDecoration::ColorFont, isActive()); - r=titlebar_->geometry(); - r.moveBy(0,-1); - int logowidth=::factory->logo.width()+::factory->logoDistance; - if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) - { - r.setWidth(r.width()-logowidth); - if (::factory->logoEnabled==0)r.moveLeft(r.left()+logowidth); - } - TQFontMetrics metrics(options()->font(isActive(), false)); - int textwidth=metrics.width(caption()); - int textalign=CrystalFactory::titleAlign(); - if (textwidth>r.width()) - textalign=AlignLeft, textwidth=r.width(); - if (::factory->textshadow && isActive()) - { - pufferPainter.translate(1,1); - pufferPainter.setPen(color.dark(300)); - pufferPainter.drawText(r,textalign | AlignVCenter,caption()); - pufferPainter.translate(-1,-1); - } - - pufferPainter.setPen(color); - pufferPainter.drawText(r, - textalign | AlignVCenter, - caption()); - - if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) - { - int x=0; - if (::factory->logoEnabled==0 && textalign==AlignLeft)x=r.left()-logowidth; - if (::factory->logoEnabled==2 && textalign==AlignLeft)x=r.left()+textwidth+::factory->logoDistance; - - if (::factory->logoEnabled==0 && textalign==AlignRight)x=r.right()-textwidth-logowidth; - if (::factory->logoEnabled==2 && textalign==AlignRight)x=r.right()+::factory->logoDistance; - - if (::factory->logoEnabled==0 && textalign==AlignHCenter)x=(r.right()+r.left()-textwidth)/2-logowidth; - if (::factory->logoEnabled==2 && textalign==AlignHCenter)x=(r.right()+r.left()+textwidth)/2+::factory->logoDistance; - pufferPainter.drawPixmap(x,(::factory->titlesize-::factory->logo.height())/2,::factory->logo); - } - }else if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) { - int x=0; - r=titlebar_->geometry(); - if (::factory->logoEnabled==0) x=r.left(); - if (::factory->logoEnabled==2) x=r.right()-::factory->logo.width(); - pufferPainter.drawPixmap(x,(::factory->titlesize-::factory->logo.height())/2,::factory->logo); - - } - - pufferPainter.end(); - painter.drawPixmap(0,0,pufferPixmap); - - drawFrame=0; - if (wndcfg->outlineMode && (options()->moveResizeMaximizedWindows() || isShade() || (maximizeMode() & MaximizeFull)!=MaximizeFull)) - drawFrame=1; - - if (::factory->borderwidth>0) - { - if (background && !background->isNull()) - { // Draw the side and bottom of the window with transparency - // Left - r=TQRect(p.x()+drawFrame,p.y()+bt,bl-drawFrame,widget()->height()-bt-drawFrame); - painter.drawPixmap(TQPoint(drawFrame,bt),*background,r); - - // Right - r=TQRect(widget()->width()-br+p.x(),p.y()+bt,br-drawFrame,widget()->height()-bt-drawFrame); - painter.drawPixmap(TQPoint(widget()->width()-br,bt),*background,r); - - // Bottom - r=TQRect(p.x()+bl,p.y()+widget()->height()-bb,widget()->width()-bl-br,bb-drawFrame); - painter.drawPixmap(TQPoint(bl,widget()->height()-bb),*background,r); - }else{ - r=TQRect(drawFrame,bt,bl-drawFrame,widget()->height()-bt-drawFrame); - painter.fillRect(r,group.background()); - - r=TQRect(widget()->width()-br,bt,br-drawFrame,widget()->height()-bt-drawFrame); - painter.fillRect(r,group.background()); - - r=TQRect(bl,widget()->height()-bb,widget()->width()-bl-br,bb-drawFrame); - painter.fillRect(r,group.background()); - } - } - - if (!isShade()) - { - if (wndcfg->inlineMode==1) { - painter.setPen(wndcfg->inlineColor); - painter.drawRect(bl-1,bt-1,widget()->width()-bl-br+2,widget()->height()-bt-bb+2); - } - if (wndcfg->inlineMode==2) { - painter.setPen(wndcfg->inlineColor.dark(150)); - painter.drawLine(bl-1,bt-1,widget()->width()-br,bt-1); - painter.drawLine(bl-1,bt-1,bl-1,widget()->height()-bb); - painter.setPen(wndcfg->inlineColor.light(150)); - painter.drawLine(widget()->width()-br,bt-1,widget()->width()-br,widget()->height()-bb); - painter.drawLine(bl-1,widget()->height()-bb,widget()->width()-br-1,widget()->height()-bb); - } - if (wndcfg->inlineMode==3) { - painter.setPen(wndcfg->inlineColor.light(150)); - painter.drawLine(bl-1,bt-1,widget()->width()-br,bt-1); - painter.drawLine(bl-1,bt-1,bl-1,widget()->height()-bb); - painter.setPen(wndcfg->inlineColor.dark(150)); - painter.drawLine(widget()->width()-br,bt-1,widget()->width()-br,widget()->height()-bb); - painter.drawLine(bl-1,widget()->height()-bb,widget()->width()-br-1,widget()->height()-bb); - } - } - } - if (background==NULL && ::factory->transparency) - { // We don't have a background image, draw a solid rectangle - // And notify image_holder that we need an update asap - if (::factory)if (::factory->image_holder) - // UnInit image_holder, on next Repaint it will be Init'ed again. - TQTimer::singleShot(500,::factory->image_holder,TQT_SLOT(CheckSanity())); - } - - if (drawFrame) - { - // outline the frame - TQRect r=widget()->rect(); - TQColor c1,c2; - c1=c2=wndcfg->frameColor; - if (wndcfg->outlineMode==2)c1=c1.dark(140),c2=c2.light(140); - if (wndcfg->outlineMode==3)c1=c1.light(140),c2=c2.dark(140); - - painter.setPen(c1); - painter.drawLine(r.left(),r.top(),r.right(),r.top()); - painter.drawLine(r.left(),r.top(),r.left(),r.bottom()); - - painter.setPen(c2); - painter.drawLine(r.right(),r.top(),r.right(),r.bottom()); - painter.drawLine(r.left(),r.bottom(),r.right(),r.bottom()); - - if ((::factory->roundCorners) && !(!options()->moveResizeMaximizedWindows() && maximizeMode() & MaximizeFull)) - { - int cornersFlag = ::factory->roundCorners; - int r=(width()); - int b=(height()); - - // Draw edge of top-left corner inside the area removed by the mask. - if(cornersFlag & TOP_LEFT) { - painter.setPen(c1); - painter.drawPoint(3, 1); - painter.drawPoint(4, 1); - painter.drawPoint(2, 2); - painter.drawPoint(1, 3); - painter.drawPoint(1, 4); - } - - // Draw edge of top-right corner inside the area removed by the mask. - if(cornersFlag & TOP_RIGHT) { - painter.setPen(c1); - painter.drawPoint(r - 5, 1); - painter.drawPoint(r - 4, 1); - painter.drawPoint(r - 3, 2); - painter.drawPoint(r - 2, 3); - painter.drawPoint(r - 2, 4); - } - - // Draw edge of bottom-left corner inside the area removed by the mask. - if(cornersFlag & BOT_LEFT) { - painter.setPen(c2); - painter.drawPoint(1, b - 5); - painter.drawPoint(1, b - 4); - painter.drawPoint(2, b - 3); - painter.drawPoint(3, b - 2); - painter.drawPoint(4, b - 2); - } - - // Draw edge of bottom-right corner inside the area removed by the mask. - if(cornersFlag & BOT_RIGHT) { - painter.setPen(c2); - painter.drawPoint(r - 2, b - 5); - painter.drawPoint(r - 2, b - 4); - painter.drawPoint(r - 3, b - 3); - painter.drawPoint(r - 4, b - 2); - painter.drawPoint(r - 5, b - 2); - } - } - } -} - -void CrystalClient::resizeEvent(TQResizeEvent *e) -{ - if (widget()->isShown()) - { - if (!::factory->transparency) ; - else if (::factory->repaintMode==1) - { - if (!timer.isActive())timer.start(0,true); -// Repaint(); - } - // repaint only every xxx ms - else if (::factory->repaintMode==3 || !timer.isActive()) - { - // Repaint only, when mode!=fade || amount<100 - WND_CONFIG* wnd=isActive()?&::factory->active:&::factory->inactive; - if (wnd->mode!=0 || wnd->amount<100) - timer.start(::factory->repaintTime,true); - } - } - if (e->size()!=e->oldSize()) - { - updateMask(); - } -} - -void CrystalClient::moveEvent(TQMoveEvent *) -{ - if (widget()->isShown()) - { - if (!::factory->transparency) return; - else if (::factory->repaintMode==1) - { - Repaint(); - } - // repaint every xxx ms, so constant moving does not take too much CPU - else if (::factory->repaintMode==3 || !timer.isActive()) - { - // Repaint only, when mode!=fade || value<100, because otherwise it is a plain color - WND_CONFIG* wnd=isActive()?&::factory->active:&::factory->inactive; - if (wnd->mode!=0 || wnd->amount<100) - timer.start(::factory->repaintTime,true); - } - } -} - -void CrystalClient::showEvent(TQShowEvent *) -{ - if (widget()->isShown()) - Repaint(); -} - -void CrystalClient::Repaint() -{ - widget()->repaint(false); - for (int n=0; nreset(); -} - -void CrystalClient::maxButtonPressed() -{ - if (button[ButtonMax]) - { - switch (button[ButtonMax]->lastMousePress()) - { - case Qt::MidButton: - maximize(maximizeMode() ^ MaximizeVertical); - break; - case Qt::RightButton: - maximize(maximizeMode() ^ MaximizeHorizontal); - break; - default: - maximize((maximizeMode() == MaximizeFull) ? MaximizeRestore: MaximizeFull); - } - } -} - -void CrystalClient::minButtonPressed() -{ - if (button[ButtonMin]) { - switch (button[ButtonMin]->lastMousePress()) { - case Qt::MidButton:{ - performWindowOperation(LowerOp); - break; - } - case Qt::RightButton: - if (isShadeable()) setShade(!isShade()); - break; - default: - minimize(); - } - } -} - -void CrystalClient::aboveButtonPressed() -{ - setKeepAbove(!keepAbove()); -} - -void CrystalClient::belowButtonPressed() -{ - setKeepBelow(!keepBelow()); -} - -void CrystalClient::keepAboveChange(bool /*set*/) -{ - if (button[ButtonAbove]) - { - button[ButtonAbove]->setBitmap(::factory->buttonImages[keepAbove()?ButtonImageUnAbove:ButtonImageAbove]); - } -} - -void CrystalClient::keepBelowChange(bool /*set*/) -{ - if (button[ButtonBelow]) - { - button[ButtonBelow]->setBitmap(::factory->buttonImages[keepBelow()?ButtonImageUnBelow:ButtonImageBelow]); - } -} - -void CrystalClient::closeButtonPressed() -{ - if (button[ButtonClose]) - switch (button[ButtonClose]->lastMousePress()) { - case Qt::RightButton: - { - Window frame,wrapper,client; - char param[20]; - ClientWindows(&frame,&wrapper,&client); - if (client != 0) { - TDEProcess *proc = new TDEProcess; - - *proc << "kdocker"; - sprintf(param,"0x%lx",client); - *proc << "-d" << "-w" << param; - proc->start(TDEProcess::DontCare); - } else { /* Sorry man */ } - break; - } - default: - closeWindow(); - break; - } -} - -void CrystalClient::shadeButtonPressed() -{ - if (button[ButtonShade]) { - switch (button[ButtonShade]->lastMousePress()) { - case Qt::MidButton: - case Qt::RightButton: - break; - default: - if (isShadeable()) setShade(!isShade()); - } - } -} - -void CrystalClient::menuButtonPressed() -{ - if (!button[ButtonMenu])return; - - static TQTime* t = 0; - static CrystalClient* lastClient = 0; - if (t == 0) - t = new TQTime; - bool dbl = (lastClient == this && t->elapsed() <= TQApplication::doubleClickInterval()); - lastClient = this; - t->start(); - - if (dbl) - { // Double Click on Symbol, close window - closeWindow(); - return; - } - - menuPopUp(); -} - -void CrystalClient::menuPopUp() -{ - TQPoint p(button[ButtonMenu]->rect().bottomLeft().x(), - button[ButtonMenu]->rect().bottomLeft().y()+2); - KDecorationFactory* f = factory(); - showWindowMenu(button[ButtonMenu]->mapToGlobal(p)); - if (!f->exists(this)) return; // decoration was destroyed - button[ButtonMenu]->setDown(false); -} - -#include "crystalclient.moc" diff --git a/client/crystalclient.cpp b/client/crystalclient.cpp new file mode 100644 index 0000000..90b3429 --- /dev/null +++ b/client/crystalclient.cpp @@ -0,0 +1,1666 @@ +/*************************************************************************** + * Copyright (C) 2006 by Sascha Hlusiak * + * Spam84@gmx.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "config.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "crystalclient.h" +#include "crystalbutton.h" +#include "buttonimage.h" +#include "imageholder.h" +#include "overlays.h" + +#include +#include + +// Button themes +#include "tiles.h" + + +CrystalFactory* factory=NULL; + +bool CrystalFactory::initialized_ = false; +TQt::AlignmentFlags CrystalFactory::titlealign_ = TQt::AlignHCenter; + + +extern "C" KDecorationFactory* create_factory() +{ + return new CrystalFactory(); +} + + +/***************** + * Tooltip class for the titlebar + **/ +class CCrystalTooltip:public TQToolTip +{ +private: + CrystalClient *client; +public: + CCrystalTooltip(TQWidget *widget,CrystalClient *vc):TQToolTip(widget),client(vc) {} + virtual void maybeTip(const TQPoint& p) + { + if (client->titlebar_->geometry().contains(p)) + { + tip(client->titlebar_->geometry(),client->caption()); + } + } +}; + + + + +CrystalFactory::CrystalFactory() +{ + for (int i=0;isetUserdefinedPictures(active.userdefinedPicture,inactive.userdefinedPicture); + image_holder->repaint(true); + }else{ + if (image_holder)delete image_holder; + image_holder=NULL; + } + CreateButtonImages(); + + return true; +} + +bool CrystalFactory::supports(Ability ability) +{ + switch (ability) + { +#if KDE_IS_VERSION(3,4,0) + case AbilityButtonResize: return false; +#endif + default: + return true; + } +} + +void setupOverlay(WND_CONFIG *cfg,int mode,TQString filename) +{ + cfg->overlay.resize(0,0); + switch(mode) + { + case 0: break; + case 1:{ + cfg->overlay.resize(0,0); + TQImage img=TQImage((uchar*)lighting_overlay_data,1,60,32,NULL,0,TQImage::LittleEndian); + img.setAlphaBuffer(true); + cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); + break; + } + case 2:{ + cfg->overlay.resize(0,0); + TQImage img=TQImage((uchar*)glass_overlay_data,20,64,32,NULL,0,TQImage::LittleEndian); + img.setAlphaBuffer(true); + cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); + break; + } + case 3:{ + cfg->overlay.resize(0,0); + TQImage img=TQImage((uchar*)steel_overlay_data,28,64,32,NULL,0,TQImage::LittleEndian); + img.setAlphaBuffer(true); + cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); + break; + } + case 4:{ + TQImage img; + if (img.load(filename)) + { + img.setAlphaBuffer(true); + cfg->overlay.convertFromImage(img.smoothScale(256,::factory->titlesize)); + } + break; + } + } +} + +bool CrystalFactory::readConfig() +{ + // create a config object + TDEConfig config("twincrystalrc"); + config.setGroup("General"); + TQColor c; + + TQString value = config.readEntry("TitleAlignment", "AlignHCenter"); + if (value == "AlignLeft") titlealign_ = TQt::AlignLeft; + else if (value == "AlignHCenter") titlealign_ = TQt::AlignHCenter; + else if (value == "AlignRight") titlealign_ = TQt::AlignRight; + + drawcaption=(bool)config.readBoolEntry("DrawCaption",true); + textshadow=(bool)config.readBoolEntry("TextShadow",true); + captiontooltip=(bool)config.readBoolEntry("CaptionTooltip",true); + wheelTask=(bool)config.readBoolEntry("WheelTask",false); + transparency=(bool)config.readBoolEntry("EnableTransparency",true); + trackdesktop=(bool)config.readBoolEntry("TrackDesktop",false); + + active.mode=config.readNumEntry("ActiveMode",0); + inactive.mode=config.readNumEntry("InactiveMode",1); + active.amount=(double)config.readNumEntry("ActiveShade",30)/100.0; + inactive.amount=(double)config.readNumEntry("InactiveShade",-30)/100.0; + active.outlineMode=(int)config.readNumEntry("ActiveFrame",1); + inactive.outlineMode=(int)config.readNumEntry("InactiveFrame",1); + c=TQColor(160,160,160); + active.frameColor=config.readColorEntry("FrameColor1",&c); + c=TQColor(128,128,128); + inactive.frameColor=config.readColorEntry("FrameColor2",&c); + + active.inlineMode=(int)config.readNumEntry("ActiveInline",0); + inactive.inlineMode=(int)config.readNumEntry("InactiveInline",0); + c=TQColor(160,160,160); + active.inlineColor=config.readColorEntry("InlineColor1",&c); + c=TQColor(160,160,160); + inactive.inlineColor=config.readColorEntry("InlineColor2",&c); + + active.blur=config.readNumEntry("ActiveBlur",0); + inactive.blur=config.readNumEntry("InactiveBlur",0); + + active.userdefinedPicture=TQImage(); + inactive.userdefinedPicture=TQImage(); + if ((bool)config.readBoolEntry("ActiveUserdefined",false)) + { + active.userdefinedPicture.load(config.readEntry("ActiveUserdefinedPicture")); + } + if ((bool)config.readBoolEntry("InactiveUserdefined",false)) + { + inactive.userdefinedPicture.load(config.readEntry("InactiveUserdefinedPicture")); + } + + borderwidth=config.readNumEntry("Borderwidth",5); + titlesize=config.readNumEntry("Titlebarheight",21); + + buttonColor_normal=TQColor(255,255,255); + buttonColor_normal=config.readColorEntry("ButtonColor",&buttonColor_normal); + buttonColor_hovered=config.readColorEntry("ButtonColor2",&buttonColor_normal); + buttonColor_pressed=config.readColorEntry("ButtonColor3",&buttonColor_normal); + minColor_normal=TQColor(255,255,255); + minColor_normal=config.readColorEntry("MinColor",&buttonColor_normal); + minColor_hovered=config.readColorEntry("MinColor2",&buttonColor_normal); + minColor_pressed=config.readColorEntry("MinColor3",&buttonColor_normal); + maxColor_normal=TQColor(255,255,255); + maxColor_normal=config.readColorEntry("MaxColor",&buttonColor_normal); + maxColor_hovered=config.readColorEntry("MaxColor2",&buttonColor_normal); + maxColor_pressed=config.readColorEntry("MaxColor3",&buttonColor_normal); + closeColor_normal=TQColor(255,255,255); + closeColor_normal=config.readColorEntry("CloseColor",&closeColor_normal); + closeColor_hovered=config.readColorEntry("CloseColor2",&closeColor_normal); + closeColor_pressed=config.readColorEntry("CloseColor3",&closeColor_normal); + + roundCorners=config.readNumEntry("RoundCorners",TOP_LEFT & TOP_RIGHT); + + hovereffect=config.readBoolEntry("HoverEffect",true); + animateHover=config.readBoolEntry("AnimateHover",true); + tintButtons=config.readBoolEntry("TintButtons",false); + menuImage=config.readBoolEntry("MenuImage",true); + repaintMode=config.readNumEntry("RepaintMode",1); + repaintTime=config.readNumEntry("RepaintTime",200); + buttontheme=config.readNumEntry("ButtonTheme",8); + + + setupOverlay(&active,config.readNumEntry("OverlayModeActive",0),config.readEntry("OverlayFileActive","")); + setupOverlay(&inactive,config.readNumEntry("OverlayModeInactive",0),config.readEntry("OverlayFileInactive","")); + + logoEnabled=config.readNumEntry("LogoAlignment",1); + logoStretch=config.readNumEntry("LogoStretch",0); + logoActive=config.readBoolEntry("LogoActive",0); + logoDistance=config.readNumEntry("LogoDistance",0); + TQString filename=config.readEntry("LogoFile",""); + if (!filename.isNull() && logoEnabled!=1) + { + if (logo.load(filename)) + { + if (logoStretch==0) + { + logo=logo.convertToImage().smoothScale((titlesize*logo.width())/logo.height(),titlesize); + } + }else logoEnabled=1; + }else logo.resize(0,0); + return true; +} + +void CrystalFactory::CreateButtonImages() +{ + for (int i=0;ireset(); else + buttonImages[i]=new ButtonImage; + if (!tintButtons)buttonImages[i]->setColors(TQt::white,TQt::white,TQt::white); + else switch(i) + { + case ButtonImageMin: + buttonImages[i]->setColors(minColor_normal,minColor_hovered,minColor_pressed); + break; + case ButtonImageMax: + buttonImages[i]->setColors(maxColor_normal,maxColor_hovered,maxColor_pressed); + break; + case ButtonImageClose: + buttonImages[i]->setColors(closeColor_normal,closeColor_hovered,closeColor_pressed); + break; + + default: + buttonImages[i]->setColors(buttonColor_normal,buttonColor_hovered,buttonColor_pressed); + break; + } + } + + switch(buttontheme) + { + default: + case 0: // Crystal default + buttonImages[ButtonImageMenu]->SetNormal(crystal_menu_data); + buttonImages[ButtonImageHelp]->SetNormal(crystal_help_data); + buttonImages[ButtonImageMax]->SetNormal(crystal_max_data); + buttonImages[ButtonImageRestore]->SetNormal(crystal_restore_data); + buttonImages[ButtonImageMin]->SetNormal(crystal_min_data); + buttonImages[ButtonImageClose]->SetNormal(crystal_close_data); + buttonImages[ButtonImageSticky]->SetNormal(crystal_sticky_data); + buttonImages[ButtonImageUnSticky]->SetNormal(crystal_un_sticky_data); + buttonImages[ButtonImageShade]->SetNormal(crystal_shade_data); + buttonImages[ButtonImageUnShade]->SetNormal(crystal_shade_data); + + buttonImages[ButtonImageAbove]->SetNormal(crystal_above_data); + buttonImages[ButtonImageUnAbove]->SetNormal(crystal_unabove_data); + buttonImages[ButtonImageBelow]->SetNormal(crystal_below_data); + buttonImages[ButtonImageUnBelow]->SetNormal(crystal_unbelow_data); + break; + case 1: // Aqua buttons + buttonImages[ButtonImageMenu]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageHelp]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageMax]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageRestore]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageMin]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageClose]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageSticky]->SetNormal(aqua_sticky_data,16,16); + buttonImages[ButtonImageUnSticky]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageShade]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageUnShade]->SetNormal(aqua_default_data,16,16); + + buttonImages[ButtonImageAbove]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageUnAbove]->SetNormal(aqua_above_data,16,16); + buttonImages[ButtonImageBelow]->SetNormal(aqua_default_data,16,16); + buttonImages[ButtonImageUnBelow]->SetNormal(aqua_below_data,16,16); + + buttonImages[ButtonImageClose]->SetHovered(aqua_close_data); + buttonImages[ButtonImageMax]->SetHovered(aqua_max_data); + buttonImages[ButtonImageMin]->SetHovered(aqua_min_data); + buttonImages[ButtonImageRestore]->SetHovered(aqua_max_data); + buttonImages[ButtonImageUnSticky]->SetHovered(aqua_un_sticky_data); + buttonImages[ButtonImageHelp]->SetHovered(aqua_help_data); + buttonImages[ButtonImageAbove]->SetHovered(aqua_above_data); + buttonImages[ButtonImageBelow]->SetHovered(aqua_below_data); + buttonImages[ButtonImageShade]->SetHovered(aqua_shade_data); + buttonImages[ButtonImageUnShade]->SetHovered(aqua_shade_data); + break; + case 2: // Knifty buttons + buttonImages[ButtonImageHelp]->SetNormal(knifty_help_data); + buttonImages[ButtonImageMax]->SetNormal(knifty_max_data); + buttonImages[ButtonImageRestore]->SetNormal(knifty_restore_data); + buttonImages[ButtonImageMin]->SetNormal(knifty_min_data); + buttonImages[ButtonImageClose]->SetNormal(knifty_close_data); + buttonImages[ButtonImageSticky]->SetNormal(knifty_sticky_data); + buttonImages[ButtonImageUnSticky]->SetNormal(knifty_un_sticky_data); + buttonImages[ButtonImageShade]->SetNormal(knifty_shade_data); + buttonImages[ButtonImageUnShade]->SetNormal(knifty_shade_data); + + buttonImages[ButtonImageAbove]->SetNormal(knifty_above_data); + buttonImages[ButtonImageUnAbove]->SetNormal(knifty_unabove_data); + buttonImages[ButtonImageBelow]->SetNormal(knifty_below_data); + buttonImages[ButtonImageUnBelow]->SetNormal(knifty_unbelow_data); + break; + + case 3: // Handpainted + buttonImages[ButtonImageHelp]->SetNormal(handpainted_help_data); + buttonImages[ButtonImageMax]->SetNormal(handpainted_max_data); + buttonImages[ButtonImageRestore]->SetNormal(handpainted_restore_data); + buttonImages[ButtonImageMin]->SetNormal(handpainted_min_data); + buttonImages[ButtonImageClose]->SetNormal(handpainted_close_data); + buttonImages[ButtonImageSticky]->SetNormal(handpainted_sticky_data); + buttonImages[ButtonImageUnSticky]->SetNormal(handpainted_un_sticky_data); + buttonImages[ButtonImageShade]->SetNormal(handpainted_shade_data); + buttonImages[ButtonImageUnShade]->SetNormal(handpainted_un_shade_data); + + buttonImages[ButtonImageAbove]->SetNormal(handpainted_above_data); + buttonImages[ButtonImageUnAbove]->SetNormal(handpainted_unabove_data); + buttonImages[ButtonImageBelow]->SetNormal(handpainted_below_data); + buttonImages[ButtonImageUnBelow]->SetNormal(handpainted_unbelow_data); + break; + case 4: // SVG + buttonImages[ButtonImageMenu]->SetNormal(svg_menu_data); + buttonImages[ButtonImageHelp]->SetNormal(svg_help_data); + buttonImages[ButtonImageMax]->SetNormal(svg_max_data); + buttonImages[ButtonImageRestore]->SetNormal(svg_restore_data); + buttonImages[ButtonImageMin]->SetNormal(svg_min_data); + buttonImages[ButtonImageClose]->SetNormal(svg_close_data); + buttonImages[ButtonImageSticky]->SetNormal(svg_sticky_data); + buttonImages[ButtonImageUnSticky]->SetNormal(svg_unsticky_data); + buttonImages[ButtonImageShade]->SetNormal(svg_shade_data); + buttonImages[ButtonImageUnShade]->SetNormal(svg_shade_data); + + buttonImages[ButtonImageAbove]->SetNormal(svg_above_data); + buttonImages[ButtonImageUnAbove]->SetNormal(svg_above_data); + buttonImages[ButtonImageBelow]->SetNormal(svg_below_data); + buttonImages[ButtonImageUnBelow]->SetNormal(svg_below_data); + break; + case 5: // Vista + buttonImages[ButtonImageMenu]->SetNormal(vista_menu_data,26,15); + buttonImages[ButtonImageMenu]->SetHovered(vista_menu_hovered_data); + buttonImages[ButtonImageMenu]->SetPressed(vista_menu_pressed_data); + + buttonImages[ButtonImageHelp]->SetNormal(vista_help_data,26,15); + buttonImages[ButtonImageHelp]->SetHovered(vista_help_hovered_data); + buttonImages[ButtonImageHelp]->SetPressed(vista_help_pressed_data); + + buttonImages[ButtonImageMax]->SetNormal(vista_max_data,27,15); + buttonImages[ButtonImageMax]->SetHovered(vista_max_hovered_data); + buttonImages[ButtonImageMax]->SetPressed(vista_max_pressed_data); + buttonImages[ButtonImageRestore]->SetNormal(vista_restore_data,27,15); + buttonImages[ButtonImageRestore]->SetHovered(vista_restore_hovered_data); + buttonImages[ButtonImageRestore]->SetPressed(vista_restore_pressed_data); + buttonImages[ButtonImageMin]->SetNormal(vista_min_data,26,15); + buttonImages[ButtonImageMin]->SetHovered(vista_min_hovered_data); + buttonImages[ButtonImageMin]->SetPressed(vista_min_pressed_data); + buttonImages[ButtonImageClose]->SetNormal(vista_close_data,40,15); + buttonImages[ButtonImageClose]->SetHovered(vista_close_hovered_data); + buttonImages[ButtonImageClose]->SetPressed(vista_close_pressed_data); + + buttonImages[ButtonImageSticky]->SetNormal(vista_sticky_data,26,15); + buttonImages[ButtonImageSticky]->SetHovered(vista_sticky_hovered_data); + buttonImages[ButtonImageSticky]->SetPressed(vista_sticky_pressed_data); + buttonImages[ButtonImageUnSticky]->SetNormal(vista_un_sticky_data,26,15); + buttonImages[ButtonImageUnSticky]->SetHovered(vista_un_sticky_hovered_data); + buttonImages[ButtonImageUnSticky]->SetPressed(vista_un_sticky_pressed_data); + + buttonImages[ButtonImageAbove]->SetNormal(vista_above_data,26,15); + buttonImages[ButtonImageAbove]->SetHovered(vista_above_hovered_data); + buttonImages[ButtonImageAbove]->SetPressed(vista_above_pressed_data); + buttonImages[ButtonImageUnAbove]->SetNormal(vista_un_above_data,26,15); + buttonImages[ButtonImageUnAbove]->SetHovered(vista_un_above_hovered_data); + buttonImages[ButtonImageUnAbove]->SetPressed(vista_un_above_pressed_data); + + buttonImages[ButtonImageBelow]->SetNormal(vista_below_data,26,15); + buttonImages[ButtonImageBelow]->SetHovered(vista_below_hovered_data); + buttonImages[ButtonImageBelow]->SetPressed(vista_below_pressed_data); + buttonImages[ButtonImageUnBelow]->SetNormal(vista_un_below_data,26,15); + buttonImages[ButtonImageUnBelow]->SetHovered(vista_un_below_hovered_data); + buttonImages[ButtonImageUnBelow]->SetPressed(vista_un_below_pressed_data); + + buttonImages[ButtonImageShade]->SetNormal(vista_shade_data,26,15); + buttonImages[ButtonImageShade]->SetHovered(vista_shade_hovered_data); + buttonImages[ButtonImageShade]->SetPressed(vista_shade_pressed_data); + buttonImages[ButtonImageUnShade]->SetNormal(vista_un_shade_data,26,15); + buttonImages[ButtonImageUnShade]->SetHovered(vista_un_shade_hovered_data); + buttonImages[ButtonImageUnShade]->SetPressed(vista_un_shade_pressed_data); + + for (int i=0;isetSpace(1,0); + buttonImages[i]->setDrawMode(1); + } + buttonImages[ButtonImageMax]->setSpace(0,0); + buttonImages[ButtonImageRestore]->setSpace(0,0); + buttonImages[ButtonImageMin]->setSpace(0,0); + buttonImages[ButtonImageClose]->setSpace(0,0); + + break; + case 6: // Kubuntu Dapper + buttonImages[ButtonImageMenu]->SetNormal(dapper_menu_data,28,17); + buttonImages[ButtonImageMenu]->SetHovered(dapper_menu_hovered_data); + buttonImages[ButtonImageMenu]->SetPressed(dapper_menu_pressed_data); + + buttonImages[ButtonImageHelp]->SetNormal(dapper_help_data,28,17); + buttonImages[ButtonImageHelp]->SetHovered(dapper_help_hovered_data); + buttonImages[ButtonImageHelp]->SetPressed(dapper_help_pressed_data); + + buttonImages[ButtonImageMax]->SetNormal(dapper_max_data,28,17); + buttonImages[ButtonImageMax]->SetHovered(dapper_max_hovered_data); + buttonImages[ButtonImageMax]->SetPressed(dapper_max_pressed_data); + buttonImages[ButtonImageRestore]->SetNormal(dapper_restore_data,28,17); + buttonImages[ButtonImageRestore]->SetHovered(dapper_restore_hovered_data); + buttonImages[ButtonImageRestore]->SetPressed(dapper_restore_pressed_data); + buttonImages[ButtonImageMin]->SetNormal(dapper_min_data,28,17); + buttonImages[ButtonImageMin]->SetHovered(dapper_min_hovered_data); + buttonImages[ButtonImageMin]->SetPressed(dapper_min_pressed_data); + buttonImages[ButtonImageClose]->SetNormal(dapper_close_data,28,17); + buttonImages[ButtonImageClose]->SetHovered(dapper_close_hovered_data); + buttonImages[ButtonImageClose]->SetPressed(dapper_close_pressed_data); + + buttonImages[ButtonImageSticky]->SetNormal(dapper_sticky_data,28,17); + buttonImages[ButtonImageSticky]->SetHovered(dapper_sticky_hovered_data); + buttonImages[ButtonImageSticky]->SetPressed(dapper_sticky_pressed_data); + buttonImages[ButtonImageUnSticky]->SetNormal(dapper_un_sticky_data,28,17); + buttonImages[ButtonImageUnSticky]->SetHovered(dapper_un_sticky_hovered_data); + buttonImages[ButtonImageUnSticky]->SetPressed(dapper_un_sticky_pressed_data); + + buttonImages[ButtonImageAbove]->SetNormal(dapper_above_data,28,17); + buttonImages[ButtonImageAbove]->SetHovered(dapper_above_hovered_data); + buttonImages[ButtonImageAbove]->SetPressed(dapper_above_pressed_data); + buttonImages[ButtonImageUnAbove]->SetNormal(dapper_un_above_data,28,17); + buttonImages[ButtonImageUnAbove]->SetHovered(dapper_un_above_hovered_data); + buttonImages[ButtonImageUnAbove]->SetPressed(dapper_un_above_pressed_data); + + + buttonImages[ButtonImageBelow]->SetNormal(dapper_below_data,28,17); + buttonImages[ButtonImageBelow]->SetHovered(dapper_below_hovered_data); + buttonImages[ButtonImageBelow]->SetPressed(dapper_below_pressed_data); + + buttonImages[ButtonImageUnBelow]->SetNormal(dapper_un_below_data,28,17); + buttonImages[ButtonImageUnBelow]->SetHovered(dapper_un_below_hovered_data); + buttonImages[ButtonImageUnBelow]->SetPressed(dapper_un_below_pressed_data); + + buttonImages[ButtonImageShade]->SetNormal(dapper_shade_data,28,17); + buttonImages[ButtonImageShade]->SetHovered(dapper_shade_hovered_data); + buttonImages[ButtonImageShade]->SetPressed(dapper_shade_pressed_data); + buttonImages[ButtonImageUnShade]->SetNormal(dapper_un_shade_data,28,17); + buttonImages[ButtonImageUnShade]->SetHovered(dapper_un_shade_hovered_data); + buttonImages[ButtonImageUnShade]->SetPressed(dapper_un_shade_pressed_data); + + for (int i=0;isetSpace(1,0); + buttonImages[i]->setDrawMode(0); + } + buttonImages[ButtonImageMax]->setSpace(0,0); + buttonImages[ButtonImageRestore]->setSpace(0,0); + buttonImages[ButtonImageMin]->setSpace(0,0); + buttonImages[ButtonImageClose]->setSpace(0,0); + break; + + case 7: // Kubuntu-Edgy + buttonImages[ButtonImageMenu]->SetNormal(edgy_menu_data,28,17); + buttonImages[ButtonImageMenu]->SetHovered(edgy_menu_hovered_data); + buttonImages[ButtonImageMenu]->SetPressed(edgy_menu_pressed_data); + + buttonImages[ButtonImageHelp]->SetNormal(edgy_help_data,28,17); + buttonImages[ButtonImageHelp]->SetHovered(edgy_help_hovered_data); + buttonImages[ButtonImageHelp]->SetPressed(edgy_help_pressed_data); + + buttonImages[ButtonImageMax]->SetNormal(edgy_max_data,28,17); + buttonImages[ButtonImageMax]->SetHovered(edgy_max_hovered_data); + buttonImages[ButtonImageMax]->SetPressed(edgy_max_pressed_data); + buttonImages[ButtonImageRestore]->SetNormal(edgy_restore_data,28,17); + buttonImages[ButtonImageRestore]->SetHovered(edgy_restore_hovered_data); + buttonImages[ButtonImageRestore]->SetPressed(edgy_restore_pressed_data); + buttonImages[ButtonImageMin]->SetNormal(edgy_min_data,28,17); + buttonImages[ButtonImageMin]->SetHovered(edgy_min_hovered_data); + buttonImages[ButtonImageMin]->SetPressed(edgy_min_pressed_data); + buttonImages[ButtonImageClose]->SetNormal(edgy_close_data,28,17); + buttonImages[ButtonImageClose]->SetHovered(edgy_close_hovered_data); + buttonImages[ButtonImageClose]->SetPressed(edgy_close_pressed_data); + + buttonImages[ButtonImageSticky]->SetNormal(edgy_sticky_data,28,17); + buttonImages[ButtonImageSticky]->SetHovered(edgy_sticky_hovered_data); + buttonImages[ButtonImageSticky]->SetPressed(edgy_sticky_pressed_data); + buttonImages[ButtonImageUnSticky]->SetNormal(edgy_un_sticky_data,28,17); + buttonImages[ButtonImageUnSticky]->SetHovered(edgy_un_sticky_hovered_data); + buttonImages[ButtonImageUnSticky]->SetPressed(edgy_un_sticky_pressed_data); + + buttonImages[ButtonImageAbove]->SetNormal(edgy_above_data,28,17); + buttonImages[ButtonImageAbove]->SetHovered(edgy_above_hovered_data); + buttonImages[ButtonImageAbove]->SetPressed(edgy_above_pressed_data); + buttonImages[ButtonImageUnAbove]->SetNormal(edgy_un_above_data,28,17); + buttonImages[ButtonImageUnAbove]->SetHovered(edgy_un_above_hovered_data); + buttonImages[ButtonImageUnAbove]->SetPressed(edgy_un_above_pressed_data); + + + buttonImages[ButtonImageBelow]->SetNormal(edgy_below_data,28,17); + buttonImages[ButtonImageBelow]->SetHovered(edgy_below_hovered_data); + buttonImages[ButtonImageBelow]->SetPressed(edgy_below_pressed_data); + + buttonImages[ButtonImageUnBelow]->SetNormal(edgy_un_below_data,28,17); + buttonImages[ButtonImageUnBelow]->SetHovered(edgy_un_below_hovered_data); + buttonImages[ButtonImageUnBelow]->SetPressed(edgy_un_below_pressed_data); + + buttonImages[ButtonImageShade]->SetNormal(edgy_shade_data,28,17); + buttonImages[ButtonImageShade]->SetHovered(edgy_shade_hovered_data); + buttonImages[ButtonImageShade]->SetPressed(edgy_shade_pressed_data); + buttonImages[ButtonImageUnShade]->SetNormal(edgy_un_shade_data,28,17); + buttonImages[ButtonImageUnShade]->SetHovered(edgy_un_shade_hovered_data); + buttonImages[ButtonImageUnShade]->SetPressed(edgy_un_shade_pressed_data); + + for (int i=0;isetSpace(1,0); + buttonImages[i]->setDrawMode(0); + } + buttonImages[ButtonImageMax]->setSpace(0,0); + buttonImages[ButtonImageRestore]->setSpace(0,0); + buttonImages[ButtonImageMin]->setSpace(0,0); + buttonImages[ButtonImageClose]->setSpace(0,0); + + break; + case 8: // Kubuntu-Feisty + buttonImages[ButtonImageMenu]->SetNormal(feisty_menu_data,21,17); + buttonImages[ButtonImageMenu]->SetHovered(feisty_menu_hovered_data); + buttonImages[ButtonImageMenu]->SetPressed(feisty_menu_pressed_data); + + buttonImages[ButtonImageHelp]->SetNormal(feisty_help_data,28,17); + buttonImages[ButtonImageHelp]->SetHovered(feisty_help_hovered_data); + buttonImages[ButtonImageHelp]->SetPressed(feisty_help_pressed_data); + + buttonImages[ButtonImageMax]->SetNormal(feisty_max_data,28,17); + buttonImages[ButtonImageMax]->SetHovered(feisty_max_hovered_data); + buttonImages[ButtonImageMax]->SetPressed(feisty_max_pressed_data); + buttonImages[ButtonImageRestore]->SetNormal(feisty_restore_data,28,17); + buttonImages[ButtonImageRestore]->SetHovered(feisty_restore_hovered_data); + buttonImages[ButtonImageRestore]->SetPressed(feisty_restore_pressed_data); + buttonImages[ButtonImageMin]->SetNormal(feisty_min_data,28,17); + buttonImages[ButtonImageMin]->SetHovered(feisty_min_hovered_data); + buttonImages[ButtonImageMin]->SetPressed(feisty_min_pressed_data); + buttonImages[ButtonImageClose]->SetNormal(feisty_close_data,28,17); + buttonImages[ButtonImageClose]->SetHovered(feisty_close_hovered_data); + buttonImages[ButtonImageClose]->SetPressed(feisty_close_pressed_data); + + buttonImages[ButtonImageSticky]->SetNormal(feisty_sticky_data,28,17); + buttonImages[ButtonImageSticky]->SetHovered(feisty_sticky_hovered_data); + buttonImages[ButtonImageSticky]->SetPressed(feisty_sticky_pressed_data); + buttonImages[ButtonImageUnSticky]->SetNormal(feisty_un_sticky_data,28,17); + buttonImages[ButtonImageUnSticky]->SetHovered(feisty_un_sticky_hovered_data); + buttonImages[ButtonImageUnSticky]->SetPressed(feisty_un_sticky_pressed_data); + + buttonImages[ButtonImageAbove]->SetNormal(feisty_above_data,28,17); + buttonImages[ButtonImageAbove]->SetHovered(feisty_above_hovered_data); + buttonImages[ButtonImageAbove]->SetPressed(feisty_above_pressed_data); + buttonImages[ButtonImageUnAbove]->SetNormal(feisty_un_above_data,28,17); + buttonImages[ButtonImageUnAbove]->SetHovered(feisty_un_above_hovered_data); + buttonImages[ButtonImageUnAbove]->SetPressed(feisty_un_above_pressed_data); + + + buttonImages[ButtonImageBelow]->SetNormal(feisty_below_data,28,17); + buttonImages[ButtonImageBelow]->SetHovered(feisty_below_hovered_data); + buttonImages[ButtonImageBelow]->SetPressed(feisty_below_pressed_data); + + buttonImages[ButtonImageUnBelow]->SetNormal(feisty_un_below_data,28,17); + buttonImages[ButtonImageUnBelow]->SetHovered(feisty_un_below_hovered_data); + buttonImages[ButtonImageUnBelow]->SetPressed(feisty_un_below_pressed_data); + + buttonImages[ButtonImageShade]->SetNormal(feisty_shade_data,28,17); + buttonImages[ButtonImageShade]->SetHovered(feisty_shade_hovered_data); + buttonImages[ButtonImageShade]->SetPressed(feisty_shade_pressed_data); + buttonImages[ButtonImageUnShade]->SetNormal(feisty_un_shade_data,28,17); + buttonImages[ButtonImageUnShade]->SetHovered(feisty_un_shade_hovered_data); + buttonImages[ButtonImageUnShade]->SetPressed(feisty_un_shade_pressed_data); + + for (int i=0;isetSpace(1,0); + buttonImages[i]->setDrawMode(0); + } + buttonImages[ButtonImageMax]->setSpace(0,0); + buttonImages[ButtonImageRestore]->setSpace(0,0); + buttonImages[ButtonImageMin]->setSpace(0,0); + buttonImages[ButtonImageClose]->setSpace(0,0); + + break; + case 9: // Kubuntu-hardy + buttonImages[ButtonImageMenu]->SetNormal(hardy_menu_data,28,17); + buttonImages[ButtonImageMenu]->SetHovered(hardy_menu_hovered_data); + buttonImages[ButtonImageMenu]->SetPressed(hardy_menu_pressed_data); + + buttonImages[ButtonImageHelp]->SetNormal(hardy_help_data,28,17); + buttonImages[ButtonImageHelp]->SetHovered(hardy_help_hovered_data); + buttonImages[ButtonImageHelp]->SetPressed(hardy_help_pressed_data); + + buttonImages[ButtonImageMax]->SetNormal(hardy_max_data,28,17); + buttonImages[ButtonImageMax]->SetHovered(hardy_max_hovered_data); + buttonImages[ButtonImageMax]->SetPressed(hardy_max_pressed_data); + buttonImages[ButtonImageRestore]->SetNormal(hardy_restore_data,28,17); + buttonImages[ButtonImageRestore]->SetHovered(hardy_restore_hovered_data); + buttonImages[ButtonImageRestore]->SetPressed(hardy_restore_pressed_data); + buttonImages[ButtonImageMin]->SetNormal(hardy_min_data,28,17); + buttonImages[ButtonImageMin]->SetHovered(hardy_min_hovered_data); + buttonImages[ButtonImageMin]->SetPressed(hardy_min_pressed_data); + buttonImages[ButtonImageClose]->SetNormal(hardy_close_data,28,17); + buttonImages[ButtonImageClose]->SetHovered(hardy_close_hovered_data); + buttonImages[ButtonImageClose]->SetPressed(hardy_close_pressed_data); + + buttonImages[ButtonImageSticky]->SetNormal(hardy_sticky_data,28,17); + buttonImages[ButtonImageSticky]->SetHovered(hardy_sticky_hovered_data); + buttonImages[ButtonImageSticky]->SetPressed(hardy_sticky_pressed_data); + buttonImages[ButtonImageUnSticky]->SetNormal(hardy_un_sticky_data,28,17); + buttonImages[ButtonImageUnSticky]->SetHovered(hardy_un_sticky_hovered_data); + buttonImages[ButtonImageUnSticky]->SetPressed(hardy_un_sticky_pressed_data); + + buttonImages[ButtonImageAbove]->SetNormal(hardy_above_data,28,17); + buttonImages[ButtonImageAbove]->SetHovered(hardy_above_hovered_data); + buttonImages[ButtonImageAbove]->SetPressed(hardy_above_pressed_data); + buttonImages[ButtonImageUnAbove]->SetNormal(hardy_un_above_data,28,17); + buttonImages[ButtonImageUnAbove]->SetHovered(hardy_un_above_hovered_data); + buttonImages[ButtonImageUnAbove]->SetPressed(hardy_un_above_pressed_data); + + + buttonImages[ButtonImageBelow]->SetNormal(hardy_below_data,28,17); + buttonImages[ButtonImageBelow]->SetHovered(hardy_below_hovered_data); + buttonImages[ButtonImageBelow]->SetPressed(hardy_below_pressed_data); + + buttonImages[ButtonImageUnBelow]->SetNormal(hardy_un_below_data,28,17); + buttonImages[ButtonImageUnBelow]->SetHovered(hardy_un_below_hovered_data); + buttonImages[ButtonImageUnBelow]->SetPressed(hardy_un_below_pressed_data); + + buttonImages[ButtonImageShade]->SetNormal(hardy_shade_data,28,17); + buttonImages[ButtonImageShade]->SetHovered(hardy_shade_hovered_data); + buttonImages[ButtonImageShade]->SetPressed(hardy_shade_pressed_data); + buttonImages[ButtonImageUnShade]->SetNormal(hardy_un_shade_data,28,17); + buttonImages[ButtonImageUnShade]->SetHovered(hardy_un_shade_hovered_data); + buttonImages[ButtonImageUnShade]->SetPressed(hardy_un_shade_pressed_data); + + for (int i=0;isetSpace(1,0); + buttonImages[i]->setDrawMode(0); + } + buttonImages[ButtonImageMax]->setSpace(0,0); + buttonImages[ButtonImageRestore]->setSpace(0,0); + buttonImages[ButtonImageMin]->setSpace(0,0); + buttonImages[ButtonImageClose]->setSpace(0,0); + + break; + + } + + + for (int i=0;ifinish(); +} + + + + + + + + +CrystalClient::CrystalClient(KDecorationBridge *b,CrystalFactory *f) +: KDecoration(b,f) +{ + ::factory->clients.append(this); +} + +CrystalClient::~CrystalClient() +{ + ::factory->clients.remove(this); + for (int n=0; ninstallEventFilter(this); + + FullMax=false; + if (!options()->moveResizeMaximizedWindows()) + FullMax=(maximizeMode()==MaximizeFull); + + // for flicker-free redraws + widget()->setBackgroundMode(NoBackground); + + // setup layout + mainlayout = new TQGridLayout(widget(), 4, 3); // 4x3 grid + titlelayout = new TQHBoxLayout(); + titlebar_ = new TQSpacerItem(1, ::factory->titlesize-1, TQSizePolicy::Expanding, + TQSizePolicy::Fixed); + + mainlayout->setResizeMode(TQLayout::FreeResize); + mainlayout->setRowSpacing(0, (::factory->buttontheme==5)?0:1); + mainlayout->setRowSpacing(3, ::factory->borderwidth*1); + + mainlayout->setColSpacing(2,borderSpacing()); + mainlayout->setColSpacing(0,borderSpacing()); + mainlayout->addLayout(titlelayout, 1, 1); + + if (isPreview()) { + char c[512]; + sprintf(c,"
Crystal %s Preview
Built: %s
",VERSION,__DATE__); + mainlayout->addItem(new TQSpacerItem(1, 1,TQSizePolicy::Expanding,TQSizePolicy::Fixed), 0, 1); + mainlayout->addItem(new TQSpacerItem(1, ::factory->borderwidth,TQSizePolicy::Expanding,TQSizePolicy::Expanding), 3, 1); + mainlayout->addWidget(new TQLabel(i18n(c),widget()), 2, 1); + } else { + mainlayout->addItem(new TQSpacerItem(0, 0), 2, 1); + } + + mainlayout->setRowStretch(2, 10); + mainlayout->setColStretch(1, 10); + + updateMask(); + + for (int n=0; ntitleButtonsLeft()); + titlelayout->addItem(titlebar_); + { + CrystalButton* lastbutton=addButtons(titlelayout, options()->titleButtonsRight()); + if (lastbutton)lastbutton->setFirstLast(false,true); + } + + if (::factory->captiontooltip) new CCrystalTooltip(widget(),this); + + connect( this, TQT_SIGNAL( keepAboveChanged( bool )), TQT_SLOT( keepAboveChange( bool ))); + connect( this, TQT_SIGNAL( keepBelowChanged( bool )), TQT_SLOT( keepBelowChange( bool ))); + + if (::factory->transparency)connect ( ::factory->image_holder,TQT_SIGNAL(repaintNeeded()),this,TQT_SLOT(Repaint())); + if (::factory->transparency)connect ( &timer,TQT_SIGNAL(timeout()),this,TQT_SLOT(Repaint())); + + updateLayout(); +} + +void CrystalClient::updateMask() +{ + if ((::factory->roundCorners==0)|| (!options()->moveResizeMaximizedWindows() && maximizeMode() & MaximizeFull ) ) + { + setMask(TQRegion(widget()->rect())); + return; + } + + int cornersFlag = ::factory->roundCorners; + int r(width()); + int b(height()); + TQRegion mask; + + mask=TQRegion(widget()->rect()); + + // Remove top-left corner. + if(cornersFlag & TOP_LEFT) { + mask -= TQRegion(0, 0, 5, 1); + mask -= TQRegion(0, 1, 3, 1); + mask -= TQRegion(0, 2, 2, 1); + mask -= TQRegion(0, 3, 1, 2); + } + // Remove top-right corner. + if(cornersFlag & TOP_RIGHT) { + 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); + } + // Remove bottom-left corner. + if(cornersFlag & BOT_LEFT) { + mask -= TQRegion(0, b - 5, 1, 3); + mask -= TQRegion(0, b - 3, 2, 1); + mask -= TQRegion(0, b - 2, 3, 1); + mask -= TQRegion(0, b - 1, 5, 1); + } + // Remove bottom-right corner. + if(cornersFlag & BOT_RIGHT) { + mask -= TQRegion(r - 5, b - 1, 5, 1); + mask -= TQRegion(r - 3, b - 2, 3, 1); + mask -= TQRegion(r - 2, b - 3, 2, 1); + mask -= TQRegion(r - 1, b - 5, 1, 2); + } + + setMask(mask); +} + +bool CrystalClient::isModalSystemNotification() +{ + unsigned char *data = 0; + Atom actual; + int format, result; + unsigned long n, left; + Atom kde_wm_system_modal_notification; + kde_wm_system_modal_notification = XInternAtom(tqt_xdisplay(), "_TDE_WM_MODAL_SYS_NOTIFICATION", False); + result = XGetWindowProperty(tqt_xdisplay(), windowId(), kde_wm_system_modal_notification, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, /*(unsigned char **)*/ &data); + if (result == Success && data != None && format == 32 ) + { + return TRUE; + } + return FALSE; +} + +CrystalButton* CrystalClient::addButtons(TQBoxLayout *layout, const TQString& s) +{ + ButtonImage *bitmap; + TQString tip; + CrystalButton *lastone=NULL; + + if (s.length() > 0) + { + for (unsigned n=0; n < s.length(); n++) + { + CrystalButton *current=NULL; + switch (s[n]) { + case 'M': // Menu button + if (!isModalSystemNotification()) { + if (!button[ButtonMenu]) { + button[ButtonMenu] = current = new CrystalButton(this, "menu", i18n("Menu"), ButtonMenu, ::factory->buttonImages[ButtonImageMenu]); + connect(button[ButtonMenu], TQT_SIGNAL(pressed()), this, TQT_SLOT(menuButtonPressed())); + } + } + break; + + case 'S': // Sticky button + if (!isModalSystemNotification()) { + if (!button[ButtonSticky]) { + if (isOnAllDesktops()) { + bitmap = ::factory->buttonImages[ButtonImageSticky]; + tip = i18n("Not on all desktops"); + } else { + bitmap = ::factory->buttonImages[ButtonImageUnSticky]; + tip = i18n("On All Desktops"); + } + button[ButtonSticky] =current=new CrystalButton(this, "sticky", tip,ButtonSticky, bitmap); + connect(button[ButtonSticky], TQT_SIGNAL(clicked()),this, TQT_SLOT(toggleOnAllDesktops())); + } + } + break; + + case 'H': // Help button + if (providesContextHelp()) { + button[ButtonHelp] =current= + new CrystalButton(this, "help", i18n("Help"),ButtonHelp, ::factory->buttonImages[ButtonImageHelp]); + connect(button[ButtonHelp], TQT_SIGNAL(clicked()),this, TQT_SLOT(showContextHelp())); + } + break; + + case 'I': // Minimize button + if ((!button[ButtonMin]) && isMinimizable()) { + button[ButtonMin] =current= + new CrystalButton(this, "iconify", i18n("Minimize"),ButtonMin, ::factory->buttonImages[ButtonImageMin]); + connect(button[ButtonMin], TQT_SIGNAL(clicked()),this, TQT_SLOT(minButtonPressed())); + } + break; + + case 'F': // Above button + if (!button[ButtonAbove]) { + button[ButtonAbove] =current= + new CrystalButton(this, "above", i18n("Keep Above Others"),ButtonAbove, ::factory->buttonImages[keepAbove()?ButtonImageUnAbove:ButtonImageAbove]); + connect(button[ButtonAbove], TQT_SIGNAL(clicked()),this, TQT_SLOT(aboveButtonPressed())); + } + break; + + case 'B': // Below button + if ((!button[ButtonBelow])) { + button[ButtonBelow] =current= + new CrystalButton(this, "below", i18n("Keep Below Others"),ButtonBelow, ::factory->buttonImages[keepBelow()?ButtonImageUnBelow:ButtonImageBelow]); + connect(button[ButtonBelow], TQT_SIGNAL(clicked()),this, TQT_SLOT(belowButtonPressed())); + } + break; + + case 'L': // Shade button + if ((!button[ButtonShade]) && isShadeable()) { + button[ButtonShade] =current= + new CrystalButton(this, "shade", i18n("Shade"),ButtonShade, ::factory->buttonImages[ButtonImageShade]); + connect(button[ButtonShade], TQT_SIGNAL(clicked()),this, TQT_SLOT(shadeButtonPressed())); + } + break; + + case 'A': // Maximize button + if ((!button[ButtonMax]) && isMaximizable()) + { + if (maximizeMode() == MaximizeFull) + { + bitmap = ::factory->buttonImages[ButtonImageRestore]; + tip = i18n("Restore"); + } else { + bitmap = ::factory->buttonImages[ButtonImageMax]; + tip = i18n("Maximize"); + } + button[ButtonMax] =current= + new CrystalButton(this, "maximize", tip,ButtonMax, bitmap); + connect(button[ButtonMax], TQT_SIGNAL(clicked()),this, TQT_SLOT(maxButtonPressed())); + } + break; + + case 'X': // Close button + if (isCloseable()) { + button[ButtonClose] =current= + new CrystalButton(this, "close", i18n("Close"),ButtonClose, ::factory->buttonImages[ButtonImageClose]); + connect(button[ButtonClose], TQT_SIGNAL(clicked()),this, TQT_SLOT(closeButtonPressed())); + } + break; + + case '_': // Spacer item + layout->addSpacing(4); + current=NULL; + break; + } + + if (current) + { + layout->addWidget(current); + if (layout->findWidget(current)==0)current->setFirstLast(true,false); + } + lastone=current; + } + } + return lastone; +} + +void CrystalClient::activeChange() +{ + Repaint(); + if (isActive()) ::factory->clients.at(::factory->clients.find(this)); +} + +void CrystalClient::captionChange() +{ + if (::factory->drawcaption) widget()->repaint(titlebar_->geometry(), false); +} + +void CrystalClient::desktopChange() +{ + bool d = isOnAllDesktops(); + if (button[ButtonSticky]) { + button[ButtonSticky]->setBitmap(::factory->buttonImages[d ? ButtonImageSticky : ButtonImageUnSticky ]); + TQToolTip::remove(button[ButtonSticky]); + TQToolTip::add(button[ButtonSticky], d ? i18n("Not on all desktops") : i18n("On All Desktops")); + } +} + +void CrystalClient::iconChange() +{ + if (button[ButtonMenu]) { + button[ButtonMenu]->setBitmap(::factory->buttonImages[ButtonImageMenu]); + } +} + +void CrystalClient::maximizeChange() +{ + bool m = (maximizeMode() == MaximizeFull); + if (button[ButtonMax]) { + button[ButtonMax]->setBitmap(::factory->buttonImages[ m ? ButtonImageRestore : ButtonImageMax ]); + TQToolTip::remove(button[ButtonMax]); + TQToolTip::add(button[ButtonMax], m ? i18n("Restore") : i18n("Maximize")); + } + + if (!options()->moveResizeMaximizedWindows()) + { + FullMax=m; + updateLayout(); + Repaint(); + } +} + +void CrystalClient::updateLayout() +{ + if (FullMax) + { + mainlayout->setColSpacing(0,0); + mainlayout->setColSpacing(2,0); + }else{ + mainlayout->setColSpacing(2,borderSpacing()); + mainlayout->setColSpacing(0,borderSpacing()); + } + + mainlayout->setRowSpacing(0, (FullMax||::factory->buttontheme==5)?0:1); + for (int i=0;iresetSize(FullMax); + widget()->layout()->activate(); +} + +int CrystalClient::borderSpacing() +{ + if (::factory->roundCorners) + return (::factory->borderwidth<=5)?5: ::factory->borderwidth; + return (::factory->borderwidth<=1)?1: ::factory->borderwidth; +} + +void CrystalClient::shadeChange() +{ + if (button[ButtonShade]) + { + button[ButtonShade]->setBitmap(::factory->buttonImages[isShade()?ButtonImageUnShade:ButtonImageShade]); + } + if (!::factory->transparency)Repaint(); + return; +} + +void CrystalClient::borders(int &l, int &r, int &t, int &b) const +{ + l = r = ::factory->borderwidth; + t = ::factory->titlesize; + if (!isShade())b = ::factory->borderwidth; else b=0; + + if (!options()->moveResizeMaximizedWindows() ) + { + if ( maximizeMode() & MaximizeHorizontal )l=r=1; + if ( maximizeMode() & MaximizeVertical ) + { + b=isShade()?0:1; + if (!isShade() && ( maximizeMode() & MaximizeHorizontal ))b=0; + } + if ( (maximizeMode() & MaximizeFull)==MaximizeFull) + l=r=0; + } +} + +void CrystalClient::resize(const TQSize &size) +{ + widget()->resize(size); +} + +TQSize CrystalClient::minimumSize() const +{ + return widget()->minimumSize(); +} + +KDecoration::Position CrystalClient::mousePosition(const TQPoint &point) const +{ + const int corner = 20; + Position pos; + const int RESIZESIZE=::factory->borderwidth; + + if (isShade() || !isResizable()) pos=PositionCenter; + else if (point.y() <= 3) { + // inside top frame + if (point.x() <= corner) pos = PositionTopLeft; + else if (point.x() >= (width()-corner)) pos = PositionTopRight; + else pos = PositionTop; + } else if (point.y() >= (height()-RESIZESIZE)) { + // inside handle + if (point.x() <= corner) pos = PositionBottomLeft; + else if (point.x() >= (width()-corner)) pos = PositionBottomRight; + else pos = PositionBottom; + } else if (point.x() <= RESIZESIZE) { + // on left frame + if (point.y() <= corner) pos = PositionTopLeft; + else if (point.y() >= (height()-corner)) pos = PositionBottomLeft; + else pos = PositionLeft; + } else if (point.x() >= width()-RESIZESIZE) { + // on right frame + if (point.y() <= corner) pos = PositionTopRight; + else if (point.y() >= (height()-corner)) pos = PositionBottomRight; + else pos = PositionRight; + } else { + // inside the frame + pos = PositionCenter; + } + return pos; +} + +bool CrystalClient::eventFilter(TQObject *obj, TQEvent *e) +{ + if (TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(widget())) return false; + + switch (e->type()) { + case TQEvent::MouseButtonDblClick: + mouseDoubleClickEvent(TQT_TQMOUSEEVENT(e)); + return true; + case TQEvent::MouseButtonPress: + processMousePressEvent(TQT_TQMOUSEEVENT(e)); + return true; + case TQEvent::Paint: + paintEvent(TQT_TQPAINTEVENT(e)); + return true; + case TQEvent::Wheel: + mouseWheelEvent(TQT_TQWHEELEVENT(e)); + return true; + + case TQEvent::Resize: + resizeEvent(TQT_TQRESIZEEVENT(e)); + return true; + + case TQEvent::Show: + showEvent(TQT_TQSHOWEVENT(e)); + return true; + case TQEvent::Move: + moveEvent(TQT_TQMOVEEVENT(e)); + return true; + default:return false; + } + + return false; +} + +void CrystalClient::ClientWindows(Window* v_frame,Window* v_wrapper,Window *v_client) +{ + Window root=0,frame=0,wrapper=0,client=0,parent=0,*children=NULL; + uint numc; + if (v_frame) *v_frame=0; + if (v_wrapper) *v_wrapper=0; + if (v_client) *v_client=0; + // Our Deco is the child of a frame, get our parent + if (XQueryTree(tqt_xdisplay(),widget()->winId(),&root,&frame,&children,&numc) == 0) + return; + if (children!=NULL)XFree(children); + children=NULL; + + // frame has two children, us and a wrapper, get the wrapper + if (XQueryTree(tqt_xdisplay(),frame,&root,&parent,&children,&numc)==0) + return; + + for (uint i=0;iwinId())wrapper=children[i]; + } + if (children!=NULL)XFree(children); + children=NULL; + + // wrapper has only one child, which is the client. We want this!! + if (XQueryTree(tqt_xdisplay(),wrapper,&root,&parent,&children,&numc)==0) + return; + if (numc==1)client=children[0]; + if (children!=NULL)XFree(children); + children=NULL; + if (v_client) *v_client=client; + if (v_wrapper) *v_wrapper=wrapper; + if (v_frame) *v_frame=frame; +} + +void CrystalClient::mouseDoubleClickEvent(TQMouseEvent *e) +{ + if (/*(titlebar_->geometry().contains(e->pos()))&&*/(e->button()==Qt::LeftButton)) titlebarDblClickOperation(); + else { + TQMouseEvent me(TQEvent::MouseButtonPress,e->pos(),e->button(),e->state()); + processMousePressEvent(&me); + } +} + +void CrystalClient::mouseWheelEvent(TQWheelEvent *e) +{ + if (::factory->wheelTask) + { + TQPtrList *l=&(::factory->clients); + + if (l->current()==NULL) for (unsigned int i=0;icount();i++) if ((l->at(i))->isActive()) break; + + CrystalClient *n=this; + Window client,frame,wrapper; + do + { + if(e->delta()>0) + { + n=l->next(); + if (n==NULL)n=l->first(); + }else{ + n=l->prev(); + if (n==NULL)n=l->last(); + } + + n->ClientWindows(&frame,&wrapper,&client); + if (client == 0) { /* FALLBACK */ +#if KDE_IS_VERSION(3,5,0) + titlebarMouseWheelOperation(e->delta()); +#endif + return; + } + KWin::WindowInfo info=KWin::windowInfo(client); + if ((n->desktop()==desktop()) && !info.isMinimized())break; + }while(n!=this); + + KWin::activateWindow(client); + }else{ +#if KDE_IS_VERSION(3,5,0) + titlebarMouseWheelOperation(e->delta()); +#endif + } +} + +void CrystalClient::paintEvent(TQPaintEvent*) +{ + if (!CrystalFactory::initialized()) return; + + TQColorGroup group; + TQPainter painter(widget()); + + // draw the titlebar + group = options()->colorGroup(KDecoration::ColorTitleBar, isActive()); + WND_CONFIG* wndcfg=(isActive()?&::factory->active:&::factory->inactive); + + if (::factory->transparency && ::factory->trackdesktop) + ::factory->image_holder->repaint(false); // If other desktop than the last, regrab the root image + TQPixmap *background=::factory->transparency?::factory->image_holder->image(isActive()):NULL; + int drawFrame; + + { + TQRect r; + TQPoint p=widget()->mapToGlobal(TQPoint(0,0)); + int bl,br,bt,bb; + borders(bl,br,bt,bb); + + TQPixmap pufferPixmap; + pufferPixmap.resize(widget()->width(), bt); + TQPainter pufferPainter(&pufferPixmap); + + r=TQRect(p.x(),p.y(),widget()->width(),bt); + if (background && !background->isNull())pufferPainter.drawPixmap(TQPoint(0,0),*background,r); + else + { + pufferPainter.fillRect(widget()->rect(),group.background()); + } + if (!wndcfg->overlay.isNull()) + { + pufferPainter.drawTiledPixmap(0,0,widget()->width(),bt,wndcfg->overlay); + } + + if (::factory->drawcaption) + { + // draw title text + pufferPainter.setFont(options()->font(isActive(), false)); + + TQColor color=options()->color(KDecoration::ColorFont, isActive()); + r=titlebar_->geometry(); + r.moveBy(0,-1); + int logowidth=::factory->logo.width()+::factory->logoDistance; + if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) + { + r.setWidth(r.width()-logowidth); + if (::factory->logoEnabled==0)r.moveLeft(r.left()+logowidth); + } + TQFontMetrics metrics(options()->font(isActive(), false)); + int textwidth=metrics.width(caption()); + int textalign=CrystalFactory::titleAlign(); + if (textwidth>r.width()) + textalign=AlignLeft, textwidth=r.width(); + if (::factory->textshadow && isActive()) + { + pufferPainter.translate(1,1); + pufferPainter.setPen(color.dark(300)); + pufferPainter.drawText(r,textalign | AlignVCenter,caption()); + pufferPainter.translate(-1,-1); + } + + pufferPainter.setPen(color); + pufferPainter.drawText(r, + textalign | AlignVCenter, + caption()); + + if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) + { + int x=0; + if (::factory->logoEnabled==0 && textalign==AlignLeft)x=r.left()-logowidth; + if (::factory->logoEnabled==2 && textalign==AlignLeft)x=r.left()+textwidth+::factory->logoDistance; + + if (::factory->logoEnabled==0 && textalign==AlignRight)x=r.right()-textwidth-logowidth; + if (::factory->logoEnabled==2 && textalign==AlignRight)x=r.right()+::factory->logoDistance; + + if (::factory->logoEnabled==0 && textalign==AlignHCenter)x=(r.right()+r.left()-textwidth)/2-logowidth; + if (::factory->logoEnabled==2 && textalign==AlignHCenter)x=(r.right()+r.left()+textwidth)/2+::factory->logoDistance; + pufferPainter.drawPixmap(x,(::factory->titlesize-::factory->logo.height())/2,::factory->logo); + } + }else if (::factory->logoEnabled!=1 && (isActive()||!::factory->logoActive)) { + int x=0; + r=titlebar_->geometry(); + if (::factory->logoEnabled==0) x=r.left(); + if (::factory->logoEnabled==2) x=r.right()-::factory->logo.width(); + pufferPainter.drawPixmap(x,(::factory->titlesize-::factory->logo.height())/2,::factory->logo); + + } + + pufferPainter.end(); + painter.drawPixmap(0,0,pufferPixmap); + + drawFrame=0; + if (wndcfg->outlineMode && (options()->moveResizeMaximizedWindows() || isShade() || (maximizeMode() & MaximizeFull)!=MaximizeFull)) + drawFrame=1; + + if (::factory->borderwidth>0) + { + if (background && !background->isNull()) + { // Draw the side and bottom of the window with transparency + // Left + r=TQRect(p.x()+drawFrame,p.y()+bt,bl-drawFrame,widget()->height()-bt-drawFrame); + painter.drawPixmap(TQPoint(drawFrame,bt),*background,r); + + // Right + r=TQRect(widget()->width()-br+p.x(),p.y()+bt,br-drawFrame,widget()->height()-bt-drawFrame); + painter.drawPixmap(TQPoint(widget()->width()-br,bt),*background,r); + + // Bottom + r=TQRect(p.x()+bl,p.y()+widget()->height()-bb,widget()->width()-bl-br,bb-drawFrame); + painter.drawPixmap(TQPoint(bl,widget()->height()-bb),*background,r); + }else{ + r=TQRect(drawFrame,bt,bl-drawFrame,widget()->height()-bt-drawFrame); + painter.fillRect(r,group.background()); + + r=TQRect(widget()->width()-br,bt,br-drawFrame,widget()->height()-bt-drawFrame); + painter.fillRect(r,group.background()); + + r=TQRect(bl,widget()->height()-bb,widget()->width()-bl-br,bb-drawFrame); + painter.fillRect(r,group.background()); + } + } + + if (!isShade()) + { + if (wndcfg->inlineMode==1) { + painter.setPen(wndcfg->inlineColor); + painter.drawRect(bl-1,bt-1,widget()->width()-bl-br+2,widget()->height()-bt-bb+2); + } + if (wndcfg->inlineMode==2) { + painter.setPen(wndcfg->inlineColor.dark(150)); + painter.drawLine(bl-1,bt-1,widget()->width()-br,bt-1); + painter.drawLine(bl-1,bt-1,bl-1,widget()->height()-bb); + painter.setPen(wndcfg->inlineColor.light(150)); + painter.drawLine(widget()->width()-br,bt-1,widget()->width()-br,widget()->height()-bb); + painter.drawLine(bl-1,widget()->height()-bb,widget()->width()-br-1,widget()->height()-bb); + } + if (wndcfg->inlineMode==3) { + painter.setPen(wndcfg->inlineColor.light(150)); + painter.drawLine(bl-1,bt-1,widget()->width()-br,bt-1); + painter.drawLine(bl-1,bt-1,bl-1,widget()->height()-bb); + painter.setPen(wndcfg->inlineColor.dark(150)); + painter.drawLine(widget()->width()-br,bt-1,widget()->width()-br,widget()->height()-bb); + painter.drawLine(bl-1,widget()->height()-bb,widget()->width()-br-1,widget()->height()-bb); + } + } + } + if (background==NULL && ::factory->transparency) + { // We don't have a background image, draw a solid rectangle + // And notify image_holder that we need an update asap + if (::factory)if (::factory->image_holder) + // UnInit image_holder, on next Repaint it will be Init'ed again. + TQTimer::singleShot(500,::factory->image_holder,TQT_SLOT(CheckSanity())); + } + + if (drawFrame) + { + // outline the frame + TQRect r=widget()->rect(); + TQColor c1,c2; + c1=c2=wndcfg->frameColor; + if (wndcfg->outlineMode==2)c1=c1.dark(140),c2=c2.light(140); + if (wndcfg->outlineMode==3)c1=c1.light(140),c2=c2.dark(140); + + painter.setPen(c1); + painter.drawLine(r.left(),r.top(),r.right(),r.top()); + painter.drawLine(r.left(),r.top(),r.left(),r.bottom()); + + painter.setPen(c2); + painter.drawLine(r.right(),r.top(),r.right(),r.bottom()); + painter.drawLine(r.left(),r.bottom(),r.right(),r.bottom()); + + if ((::factory->roundCorners) && !(!options()->moveResizeMaximizedWindows() && maximizeMode() & MaximizeFull)) + { + int cornersFlag = ::factory->roundCorners; + int r=(width()); + int b=(height()); + + // Draw edge of top-left corner inside the area removed by the mask. + if(cornersFlag & TOP_LEFT) { + painter.setPen(c1); + painter.drawPoint(3, 1); + painter.drawPoint(4, 1); + painter.drawPoint(2, 2); + painter.drawPoint(1, 3); + painter.drawPoint(1, 4); + } + + // Draw edge of top-right corner inside the area removed by the mask. + if(cornersFlag & TOP_RIGHT) { + painter.setPen(c1); + painter.drawPoint(r - 5, 1); + painter.drawPoint(r - 4, 1); + painter.drawPoint(r - 3, 2); + painter.drawPoint(r - 2, 3); + painter.drawPoint(r - 2, 4); + } + + // Draw edge of bottom-left corner inside the area removed by the mask. + if(cornersFlag & BOT_LEFT) { + painter.setPen(c2); + painter.drawPoint(1, b - 5); + painter.drawPoint(1, b - 4); + painter.drawPoint(2, b - 3); + painter.drawPoint(3, b - 2); + painter.drawPoint(4, b - 2); + } + + // Draw edge of bottom-right corner inside the area removed by the mask. + if(cornersFlag & BOT_RIGHT) { + painter.setPen(c2); + painter.drawPoint(r - 2, b - 5); + painter.drawPoint(r - 2, b - 4); + painter.drawPoint(r - 3, b - 3); + painter.drawPoint(r - 4, b - 2); + painter.drawPoint(r - 5, b - 2); + } + } + } +} + +void CrystalClient::resizeEvent(TQResizeEvent *e) +{ + if (widget()->isShown()) + { + if (!::factory->transparency) ; + else if (::factory->repaintMode==1) + { + if (!timer.isActive())timer.start(0,true); +// Repaint(); + } + // repaint only every xxx ms + else if (::factory->repaintMode==3 || !timer.isActive()) + { + // Repaint only, when mode!=fade || amount<100 + WND_CONFIG* wnd=isActive()?&::factory->active:&::factory->inactive; + if (wnd->mode!=0 || wnd->amount<100) + timer.start(::factory->repaintTime,true); + } + } + if (e->size()!=e->oldSize()) + { + updateMask(); + } +} + +void CrystalClient::moveEvent(TQMoveEvent *) +{ + if (widget()->isShown()) + { + if (!::factory->transparency) return; + else if (::factory->repaintMode==1) + { + Repaint(); + } + // repaint every xxx ms, so constant moving does not take too much CPU + else if (::factory->repaintMode==3 || !timer.isActive()) + { + // Repaint only, when mode!=fade || value<100, because otherwise it is a plain color + WND_CONFIG* wnd=isActive()?&::factory->active:&::factory->inactive; + if (wnd->mode!=0 || wnd->amount<100) + timer.start(::factory->repaintTime,true); + } + } +} + +void CrystalClient::showEvent(TQShowEvent *) +{ + if (widget()->isShown()) + Repaint(); +} + +void CrystalClient::Repaint() +{ + widget()->repaint(false); + for (int n=0; nreset(); +} + +void CrystalClient::maxButtonPressed() +{ + if (button[ButtonMax]) + { + switch (button[ButtonMax]->lastMousePress()) + { + case Qt::MidButton: + maximize(maximizeMode() ^ MaximizeVertical); + break; + case Qt::RightButton: + maximize(maximizeMode() ^ MaximizeHorizontal); + break; + default: + maximize((maximizeMode() == MaximizeFull) ? MaximizeRestore: MaximizeFull); + } + } +} + +void CrystalClient::minButtonPressed() +{ + if (button[ButtonMin]) { + switch (button[ButtonMin]->lastMousePress()) { + case Qt::MidButton:{ + performWindowOperation(LowerOp); + break; + } + case Qt::RightButton: + if (isShadeable()) setShade(!isShade()); + break; + default: + minimize(); + } + } +} + +void CrystalClient::aboveButtonPressed() +{ + setKeepAbove(!keepAbove()); +} + +void CrystalClient::belowButtonPressed() +{ + setKeepBelow(!keepBelow()); +} + +void CrystalClient::keepAboveChange(bool /*set*/) +{ + if (button[ButtonAbove]) + { + button[ButtonAbove]->setBitmap(::factory->buttonImages[keepAbove()?ButtonImageUnAbove:ButtonImageAbove]); + } +} + +void CrystalClient::keepBelowChange(bool /*set*/) +{ + if (button[ButtonBelow]) + { + button[ButtonBelow]->setBitmap(::factory->buttonImages[keepBelow()?ButtonImageUnBelow:ButtonImageBelow]); + } +} + +void CrystalClient::closeButtonPressed() +{ + if (button[ButtonClose]) + switch (button[ButtonClose]->lastMousePress()) { + case Qt::RightButton: + { + Window frame,wrapper,client; + char param[20]; + ClientWindows(&frame,&wrapper,&client); + if (client != 0) { + TDEProcess *proc = new TDEProcess; + + *proc << "kdocker"; + sprintf(param,"0x%lx",client); + *proc << "-d" << "-w" << param; + proc->start(TDEProcess::DontCare); + } else { /* Sorry man */ } + break; + } + default: + closeWindow(); + break; + } +} + +void CrystalClient::shadeButtonPressed() +{ + if (button[ButtonShade]) { + switch (button[ButtonShade]->lastMousePress()) { + case Qt::MidButton: + case Qt::RightButton: + break; + default: + if (isShadeable()) setShade(!isShade()); + } + } +} + +void CrystalClient::menuButtonPressed() +{ + if (!button[ButtonMenu])return; + + static TQTime* t = 0; + static CrystalClient* lastClient = 0; + if (t == 0) + t = new TQTime; + bool dbl = (lastClient == this && t->elapsed() <= TQApplication::doubleClickInterval()); + lastClient = this; + t->start(); + + if (dbl) + { // Double Click on Symbol, close window + closeWindow(); + return; + } + + menuPopUp(); +} + +void CrystalClient::menuPopUp() +{ + TQPoint p(button[ButtonMenu]->rect().bottomLeft().x(), + button[ButtonMenu]->rect().bottomLeft().y()+2); + KDecorationFactory* f = factory(); + showWindowMenu(button[ButtonMenu]->mapToGlobal(p)); + if (!f->exists(this)) return; // decoration was destroyed + button[ButtonMenu]->setDown(false); +} + +#include "crystalclient.moc" diff --git a/client/myrootpixmap.cc b/client/myrootpixmap.cc deleted file mode 100644 index ca3a260..0000000 --- a/client/myrootpixmap.cc +++ /dev/null @@ -1,258 +0,0 @@ -/* - * - * $Id: krootpixmap.cpp,v 1.20 2003/06/01 01:49:31 hadacek Exp $ - * - * This file is part of the KDE project, module tdeui. - * Copyright (C) 1999,2000 Geert Jansen - * - * You can Freely distribute this program under the GNU Library - * General Public License. See the file "COPYING.LIB" for the exact - * licensing terms. - */ - -/* Modified by Sascha Hlusiak */ -/* Further modified 11/18/2014 by Timothy Pearson */ - -#include -#include -#include -#include - -#ifndef TQ_WS_TQWS //FIXME -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "myrootpixmap.h" - -static TQString wallpaperForDesktop(int desktop) -{ - return DCOPRef("kdesktop", "KBackgroundIface").call("currentWallpaper", desktop); -} - -DesktopWallpaperWatcher::DesktopWallpaperWatcher() : TQWidget(), m_old_current_desktop(-1) -{ - kapp->installX11EventFilter( this ); - (void ) kapp->desktop(); //trigger desktop widget creation to select root window events -} - -DesktopWallpaperWatcher::~DesktopWallpaperWatcher() -{ -} - -bool DesktopWallpaperWatcher::x11Event( XEvent * ev ) -{ - if ( ev->xany.window == tqt_xrootwin() ) { - NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop ); - rinfo.activate(); - - if ( rinfo.currentDesktop() != m_old_current_desktop ) { - emit currentDesktopChanged( rinfo.currentDesktop() ); - } - - m_old_current_desktop = rinfo.currentDesktop(); - } - - return false; -} - -class KMyRootPixmapData -{ -public: -#ifdef Q_WS_X11 - DesktopWallpaperWatcher *twin; -#endif -}; - -KMyRootPixmap::KMyRootPixmap( TQWidget * widget, const char *name ) - : TQObject(widget, name ? name : "KMyRootPixmap" ) -{ - init(); -} - -KMyRootPixmap::KMyRootPixmap( TQWidget *, TQObject *parent, const char *name ) - : TQObject( parent, name ? name : "KMyRootPixmap" ) -{ - init(); -} - -void KMyRootPixmap::init() -{ - d = new KMyRootPixmapData; -// m_Fade = 0; - m_pPixmap = new TDESharedPixmap; -// m_pTimer = new TQTimer( this ); - m_bInit = false; - m_bActive = false; - m_Desk=-1; -// m_bCustomPaint = false; - -// connect(kapp, TQT_SIGNAL(backgroundChanged(int)), TQT_SLOT(slotBackgroundChanged(int))); - connect(m_pPixmap, TQT_SIGNAL(done(bool)), TQT_SLOT(slotDone(bool))); -// connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(repaint())); - -#ifdef Q_WS_X11 - d->twin = new DesktopWallpaperWatcher(); - connect(d->twin, TQT_SIGNAL(currentDesktopChanged(int)), TQT_SLOT(desktopChanged(int))); -#endif - -// d->toplevel = m_pWidget->topLevelWidget(); -// d->toplevel->installEventFilter(this); -} - -KMyRootPixmap::~KMyRootPixmap() -{ - delete m_pPixmap; - delete d; -} - -void KMyRootPixmap::desktopChanged(int desktop) -{ - if (wallpaperForDesktop(m_Desk) == wallpaperForDesktop(desktop) && - !wallpaperForDesktop(m_Desk).isNull()) - return; - -// #ifdef Q_WS_X11 -// if (KWin::windowInfo(m_pWidget->topLevelWidget()->winId()).desktop() == NET::OnAllDesktops && -// pixmapName(m_Desk) != pixmapName(desktop)) -// #endif - repaint(true); -} - -int KMyRootPixmap::currentDesktop() const -{ - NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop ); - rinfo.activate(); - return rinfo.currentDesktop(); -} - -void KMyRootPixmap::start() -{ - if (m_bActive) - return; - - m_bActive = true; - enableExports(); - return; -// if (m_bInit) -// repaint(true); -} - -void KMyRootPixmap::stop() -{ - m_bActive = false; -// m_pTimer->stop(); -} - - -void KMyRootPixmap::repaint() -{ - repaint(false); -} - -void KMyRootPixmap::repaint(bool force) -{ -// printf("KMyRootPixmap::repaint(%s)\n",force?"true":"false"); - if ((!force) && (m_Desk==currentDesktop()))return; - - m_Desk = currentDesktop(); - - if (!isAvailable()) - { - emit backgroundUpdated(NULL); - }else{ - // TDESharedPixmap will correctly generate a tile for us. - m_pPixmap->loadFromShared(pixmapName(m_Desk)); - updateBackground( m_pPixmap ); - } -} - -bool KMyRootPixmap::isAvailable() -{ - return m_pPixmap->isAvailable(pixmapName(m_Desk)); -} - -TQString KMyRootPixmap::pixmapName(int desk) -{ - TQString pattern = TQString("DESKTOP%1"); - int screen_number = DefaultScreen(tqt_xdisplay()); - if (screen_number) { - pattern = TQString("SCREEN%1-DESKTOP").arg(screen_number) + "%1"; - } - return pattern.arg( desk ); -} - - -void KMyRootPixmap::enableExports() -{ -// kdDebug(270) << k_lineinfo << "activating background exports.\n"; - DCOPClient *client = kapp->dcopClient(); - if (!client->isAttached()) - client->attach(); - TQByteArray data; - TQDataStream args( data, IO_WriteOnly ); - args << 1; - - TQCString appname( "kdesktop" ); - int screen_number = DefaultScreen(tqt_xdisplay()); - if ( screen_number ) - appname.sprintf("kdesktop-screen-%d", screen_number ); - - client->send( appname, "KBackgroundIface", "setExport(int)", data ); -} - - -void KMyRootPixmap::slotDone(bool success) -{ - if (!success) - { -// kdWarning(270) << k_lineinfo << "loading of desktop background failed.\n"; - return; - } - - // We need to test active as the pixmap might become available - // after the widget has been destroyed. - if ( m_bActive ) - updateBackground( m_pPixmap ); -} - -void KMyRootPixmap::updateBackground( TDESharedPixmap *spm ) -{ -// printf("KMyRootPixmap::updateBackground(%p)\n",spm); - TQPixmap *px=spm; - if (px->isNull() || px->width()==0 || px->height()==0) - { // This is NOT an image, something went wrong, update to plain - emit backgroundUpdated(NULL); - return; - } - KPixmapIO io; - TQSize desktopsize(TQApplication::desktop()->width(),TQApplication::desktop()->height()); - - if (px->rect().size()==desktopsize) - { // Image has already the right dimension, make a quick update - TQImage img = io.convertToImage(*spm); - emit backgroundUpdated(&img); - return; - }else{ // we need to create a tiled pixmap and then the image to update - TQPixmap pix(desktopsize,spm->TQPixmap::depth()); - TQPainter pufferPainter(&pix); - - pufferPainter.drawTiledPixmap(pix.rect(),*spm); - - pufferPainter.end(); - - TQImage img=io.convertToImage(pix); - emit backgroundUpdated(&img); - } -} - -#include "myrootpixmap.moc" -#endif diff --git a/client/myrootpixmap.cpp b/client/myrootpixmap.cpp new file mode 100644 index 0000000..ca3a260 --- /dev/null +++ b/client/myrootpixmap.cpp @@ -0,0 +1,258 @@ +/* + * + * $Id: krootpixmap.cpp,v 1.20 2003/06/01 01:49:31 hadacek Exp $ + * + * This file is part of the KDE project, module tdeui. + * Copyright (C) 1999,2000 Geert Jansen + * + * You can Freely distribute this program under the GNU Library + * General Public License. See the file "COPYING.LIB" for the exact + * licensing terms. + */ + +/* Modified by Sascha Hlusiak */ +/* Further modified 11/18/2014 by Timothy Pearson */ + +#include +#include +#include +#include + +#ifndef TQ_WS_TQWS //FIXME +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "myrootpixmap.h" + +static TQString wallpaperForDesktop(int desktop) +{ + return DCOPRef("kdesktop", "KBackgroundIface").call("currentWallpaper", desktop); +} + +DesktopWallpaperWatcher::DesktopWallpaperWatcher() : TQWidget(), m_old_current_desktop(-1) +{ + kapp->installX11EventFilter( this ); + (void ) kapp->desktop(); //trigger desktop widget creation to select root window events +} + +DesktopWallpaperWatcher::~DesktopWallpaperWatcher() +{ +} + +bool DesktopWallpaperWatcher::x11Event( XEvent * ev ) +{ + if ( ev->xany.window == tqt_xrootwin() ) { + NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop ); + rinfo.activate(); + + if ( rinfo.currentDesktop() != m_old_current_desktop ) { + emit currentDesktopChanged( rinfo.currentDesktop() ); + } + + m_old_current_desktop = rinfo.currentDesktop(); + } + + return false; +} + +class KMyRootPixmapData +{ +public: +#ifdef Q_WS_X11 + DesktopWallpaperWatcher *twin; +#endif +}; + +KMyRootPixmap::KMyRootPixmap( TQWidget * widget, const char *name ) + : TQObject(widget, name ? name : "KMyRootPixmap" ) +{ + init(); +} + +KMyRootPixmap::KMyRootPixmap( TQWidget *, TQObject *parent, const char *name ) + : TQObject( parent, name ? name : "KMyRootPixmap" ) +{ + init(); +} + +void KMyRootPixmap::init() +{ + d = new KMyRootPixmapData; +// m_Fade = 0; + m_pPixmap = new TDESharedPixmap; +// m_pTimer = new TQTimer( this ); + m_bInit = false; + m_bActive = false; + m_Desk=-1; +// m_bCustomPaint = false; + +// connect(kapp, TQT_SIGNAL(backgroundChanged(int)), TQT_SLOT(slotBackgroundChanged(int))); + connect(m_pPixmap, TQT_SIGNAL(done(bool)), TQT_SLOT(slotDone(bool))); +// connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(repaint())); + +#ifdef Q_WS_X11 + d->twin = new DesktopWallpaperWatcher(); + connect(d->twin, TQT_SIGNAL(currentDesktopChanged(int)), TQT_SLOT(desktopChanged(int))); +#endif + +// d->toplevel = m_pWidget->topLevelWidget(); +// d->toplevel->installEventFilter(this); +} + +KMyRootPixmap::~KMyRootPixmap() +{ + delete m_pPixmap; + delete d; +} + +void KMyRootPixmap::desktopChanged(int desktop) +{ + if (wallpaperForDesktop(m_Desk) == wallpaperForDesktop(desktop) && + !wallpaperForDesktop(m_Desk).isNull()) + return; + +// #ifdef Q_WS_X11 +// if (KWin::windowInfo(m_pWidget->topLevelWidget()->winId()).desktop() == NET::OnAllDesktops && +// pixmapName(m_Desk) != pixmapName(desktop)) +// #endif + repaint(true); +} + +int KMyRootPixmap::currentDesktop() const +{ + NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop ); + rinfo.activate(); + return rinfo.currentDesktop(); +} + +void KMyRootPixmap::start() +{ + if (m_bActive) + return; + + m_bActive = true; + enableExports(); + return; +// if (m_bInit) +// repaint(true); +} + +void KMyRootPixmap::stop() +{ + m_bActive = false; +// m_pTimer->stop(); +} + + +void KMyRootPixmap::repaint() +{ + repaint(false); +} + +void KMyRootPixmap::repaint(bool force) +{ +// printf("KMyRootPixmap::repaint(%s)\n",force?"true":"false"); + if ((!force) && (m_Desk==currentDesktop()))return; + + m_Desk = currentDesktop(); + + if (!isAvailable()) + { + emit backgroundUpdated(NULL); + }else{ + // TDESharedPixmap will correctly generate a tile for us. + m_pPixmap->loadFromShared(pixmapName(m_Desk)); + updateBackground( m_pPixmap ); + } +} + +bool KMyRootPixmap::isAvailable() +{ + return m_pPixmap->isAvailable(pixmapName(m_Desk)); +} + +TQString KMyRootPixmap::pixmapName(int desk) +{ + TQString pattern = TQString("DESKTOP%1"); + int screen_number = DefaultScreen(tqt_xdisplay()); + if (screen_number) { + pattern = TQString("SCREEN%1-DESKTOP").arg(screen_number) + "%1"; + } + return pattern.arg( desk ); +} + + +void KMyRootPixmap::enableExports() +{ +// kdDebug(270) << k_lineinfo << "activating background exports.\n"; + DCOPClient *client = kapp->dcopClient(); + if (!client->isAttached()) + client->attach(); + TQByteArray data; + TQDataStream args( data, IO_WriteOnly ); + args << 1; + + TQCString appname( "kdesktop" ); + int screen_number = DefaultScreen(tqt_xdisplay()); + if ( screen_number ) + appname.sprintf("kdesktop-screen-%d", screen_number ); + + client->send( appname, "KBackgroundIface", "setExport(int)", data ); +} + + +void KMyRootPixmap::slotDone(bool success) +{ + if (!success) + { +// kdWarning(270) << k_lineinfo << "loading of desktop background failed.\n"; + return; + } + + // We need to test active as the pixmap might become available + // after the widget has been destroyed. + if ( m_bActive ) + updateBackground( m_pPixmap ); +} + +void KMyRootPixmap::updateBackground( TDESharedPixmap *spm ) +{ +// printf("KMyRootPixmap::updateBackground(%p)\n",spm); + TQPixmap *px=spm; + if (px->isNull() || px->width()==0 || px->height()==0) + { // This is NOT an image, something went wrong, update to plain + emit backgroundUpdated(NULL); + return; + } + KPixmapIO io; + TQSize desktopsize(TQApplication::desktop()->width(),TQApplication::desktop()->height()); + + if (px->rect().size()==desktopsize) + { // Image has already the right dimension, make a quick update + TQImage img = io.convertToImage(*spm); + emit backgroundUpdated(&img); + return; + }else{ // we need to create a tiled pixmap and then the image to update + TQPixmap pix(desktopsize,spm->TQPixmap::depth()); + TQPainter pufferPainter(&pix); + + pufferPainter.drawTiledPixmap(pix.rect(),*spm); + + pufferPainter.end(); + + TQImage img=io.convertToImage(pix); + emit backgroundUpdated(&img); + } +} + +#include "myrootpixmap.moc" +#endif diff --git a/pics/README b/pics/README index 20253b8..d4eb625 100644 --- a/pics/README +++ b/pics/README @@ -10,7 +10,7 @@ Use with 'embedtool file1 file2 > tiles.h', or 'embedtool foo/*.png > bar.h'. 3) A new button theme is much more work: - Add a directory, populate it with png images. List this directory in the ${themes} variable of the Makefile.am - In the top directory run: make -f Makefile.cvs. Now make should include your png images in the tiles.h, which gets included in the crystal source. -- You have to add some logic to the ../client/crystalclient.cc and ../client/config/configdialog.ui file, to really make your button theme available. +- You have to add some logic to the ../client/crystalclient.cpp and ../client/config/configdialog.ui file, to really make your button theme available. -- cgit v1.2.1