diff options
author | rjb330 <122177540+rjb330@users.noreply.github.com> | 2024-11-11 18:53:29 -0800 |
---|---|---|
committer | rjb330 <122177540+rjb330@users.noreply.github.com> | 2024-11-14 04:25:43 -0800 |
commit | ae5e4d76b139f8bf5d235ab7ed8f4857f20ea512 (patch) | |
tree | c29c7d1a759da347819f50e31bdc72ec699b0c54 | |
parent | a5953b11fadd6352f955d051c5e7461cb00fd689 (diff) | |
download | twin-style-dekorator-ae5e4d76b139f8bf5d235ab7ed8f4857f20ea512.tar.gz twin-style-dekorator-ae5e4d76b139f8bf5d235ab7ed8f4857f20ea512.zip |
Add pseudotransparency for DeKorator themes with transparent pixmaps
Signed-off-by: rjb330 <122177540+rjb330@users.noreply.github.com>
-rw-r--r-- | client/CMakeLists.txt | 2 | ||||
-rw-r--r-- | client/config/configdialog.ui | 27 | ||||
-rw-r--r-- | client/config/deKoratorconfig.cpp | 36 | ||||
-rw-r--r-- | client/deKoratorclient.cpp | 102 | ||||
-rw-r--r-- | client/deKoratorclient.h | 8 | ||||
-rw-r--r-- | client/imageholder.cpp | 137 | ||||
-rw-r--r-- | client/imageholder.h | 63 | ||||
-rw-r--r-- | client/myrootpixmap.cpp | 258 | ||||
-rw-r--r-- | client/myrootpixmap.h | 116 |
9 files changed, 706 insertions, 43 deletions
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index ae7e6d5..ded1c7e 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -22,6 +22,8 @@ tde_add_kpart( twin_deKorator AUTOMOC SOURCES deKoratorclient.cpp + myrootpixmap.cpp + imageholder.cpp shadow.cpp LINK tdecore-shared diff --git a/client/config/configdialog.ui b/client/config/configdialog.ui index 3de1a43..07997a7 100644 --- a/client/config/configdialog.ui +++ b/client/config/configdialog.ui @@ -8,8 +8,8 @@ <rect> <x>0</x> <y>0</y> - <width>471</width> - <height>525</height> + <width>481</width> + <height>568</height> </rect> </property> <property name="caption"> @@ -39,7 +39,7 @@ <cstring>generalbox</cstring> </property> <property name="frameShape"> - <enum>GroupBoxPanel</enum> + <enum>NoFrame</enum> </property> <property name="frameShadow"> <enum>Sunken</enum> @@ -509,11 +509,22 @@ <property name="title"> <string>Colors</string> </property> - <vbox> + <grid> <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="TQLayoutWidget"> + <widget class="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>transparencyChkBox</cstring> + </property> + <property name="text"> + <string>Enable transparency</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + <widget class="TQLayoutWidget" row="1" column="0"> <property name="name"> <cstring>layout19</cstring> </property> @@ -581,7 +592,7 @@ </widget> </hbox> </widget> - </vbox> + </grid> </widget> <widget class="TQButtonGroup"> <property name="name"> @@ -1943,8 +1954,6 @@ Email: <a href="mailto:moty.rahamim@gmail.com"><font color="#ff0000"> </widget> </vbox> </widget> -<customwidgets> -</customwidgets> <connections> <connection> <sender>useMasks_Chkbox</sender> @@ -2085,7 +2094,6 @@ Email: <a href="mailto:moty.rahamim@gmail.com"><font color="#ff0000"> <slot>setEnabled(bool)</slot> </connection> </connections> -<layoutdefaults spacing="6" margin="11"/> <includes> <include location="global" impldecl="in implementation">kactivelabel.h</include> <include location="global" impldecl="in implementation">kcolorbutton.h</include> @@ -2094,4 +2102,5 @@ Email: <a href="mailto:moty.rahamim@gmail.com"><font color="#ff0000"> <include location="global" impldecl="in implementation">kurlrequester.h</include> <include location="global" impldecl="in implementation">tdelistview.h</include> </includes> +<layoutdefaults spacing="6" margin="11"/> </UI> diff --git a/client/config/deKoratorconfig.cpp b/client/config/deKoratorconfig.cpp index 9543688..1bd5257 100644 --- a/client/config/deKoratorconfig.cpp +++ b/client/config/deKoratorconfig.cpp @@ -102,6 +102,7 @@ DeKoratorConfig::DeKoratorConfig( TDEConfig* config, TQWidget* parent ) // colors + connect( dialog_->transparencyChkBox, TQ_SIGNAL( clicked() ), TQ_SIGNAL( changed() ) ); connect( dialog_->colorizeActFramesChkBox, TQ_SIGNAL( clicked() ), TQ_SIGNAL( changed() ) ); connect( dialog_->colorizeActButtonsChkBox, TQ_SIGNAL( clicked() ), TQ_SIGNAL( changed() ) ); connect( dialog_->colorizeInActFramesChkBox, TQ_SIGNAL( clicked() ), TQ_SIGNAL( changed() ) ); @@ -193,13 +194,13 @@ void DeKoratorConfig::load( TDEConfig* ) TQString value = config_->readEntry( "TitleAlignment", "AlignHCenter" ); TQRadioButton *button = ( TQRadioButton* ) dialog_->titlealign->child( value ); - if ( button ) button->setChecked( TRUE ); - dialog_->useMenuImageChkBox->setChecked( config_->readBoolEntry( "UseMenuImage", FALSE ) ); - dialog_->ignoreAppIcnCol->setChecked( config_->readBoolEntry( "IgnoreAppIconCol", FALSE ) ); - dialog_->dblClkCloseChkBox->setChecked( config_->readBoolEntry( "DblClkClose", FALSE ) ); - dialog_->showBtmBorderChkBox->setChecked( config_->readBoolEntry( "ShowBtmBorder", FALSE ) ); + if ( button ) button->setChecked( true ); + dialog_->useMenuImageChkBox->setChecked( config_->readBoolEntry( "UseMenuImage", false ) ); + dialog_->ignoreAppIcnCol->setChecked( config_->readBoolEntry( "IgnoreAppIconCol", false ) ); + dialog_->dblClkCloseChkBox->setChecked( config_->readBoolEntry( "DblClkClose", false ) ); + dialog_->showBtmBorderChkBox->setChecked( config_->readBoolEntry( "ShowBtmBorder", false ) ); TQColor color = TQColor( 50, 50, 50 ); - dialog_->useShdtextChkBox->setChecked( config_->readBoolEntry( "UseShdtext", TRUE ) ); + dialog_->useShdtextChkBox->setChecked( config_->readBoolEntry( "UseShdtext", true ) ); dialog_->activeShdtextXSpinBox->setValue( config_->readNumEntry( "ActiveShdtextX", 1 ) ); dialog_->activeShdtextYSpinBox->setValue( config_->readNumEntry( "ActiveShdtextY", 1 ) ); dialog_->activeShdColBtn->setColor( config_->readColorEntry( "ActiveShadowColor", &color ) ); @@ -213,16 +214,17 @@ void DeKoratorConfig::load( TDEConfig* ) // colors config_->setGroup( "COLORS" ); - dialog_->colorizeActFramesChkBox->setChecked( config_->readBoolEntry( "ColorizeActFrames", FALSE ) ); - dialog_->colorizeActButtonsChkBox->setChecked( config_->readBoolEntry( "ColorizeActButtons", FALSE ) ); - dialog_->colorizeInActFramesChkBox->setChecked( config_->readBoolEntry( "ColorizeInActFrames", FALSE ) ); - dialog_->colorizeInActButtonsChkBox->setChecked( config_->readBoolEntry( "ColorizeInActButtons", FALSE ) ); - dialog_->useAnimChkBox->setChecked( config_->readBoolEntry( "UseAnimation", FALSE ) ); + dialog_->transparencyChkBox->setChecked( config_->readBoolEntry( "Transparency", false ) ); + dialog_->colorizeActFramesChkBox->setChecked( config_->readBoolEntry( "ColorizeActFrames", false ) ); + dialog_->colorizeActButtonsChkBox->setChecked( config_->readBoolEntry( "ColorizeActButtons", false ) ); + dialog_->colorizeInActFramesChkBox->setChecked( config_->readBoolEntry( "ColorizeInActFrames", false ) ); + dialog_->colorizeInActButtonsChkBox->setChecked( config_->readBoolEntry( "ColorizeInActButtons", false ) ); + dialog_->useAnimChkBox->setChecked( config_->readBoolEntry( "UseAnimation", false ) ); dialog_->animateEfeectsCombo->setCurrentText( config_->readEntry( "AnimationType", "Intensity" ) ); dialog_->stepsSpinBox->setValue( config_->readNumEntry( "AnimSteps", 5 ) ); dialog_->intervalSpinBox->setValue( config_->readNumEntry( "AnimInterval", 30 ) ); - dialog_->KeepAnimateChkBox->setChecked( config_->readBoolEntry( "KeepAnimating", FALSE ) ); + dialog_->KeepAnimateChkBox->setChecked( config_->readBoolEntry( "KeepAnimating", false ) ); dialog_->activeHighlightClrBtn->setColor( config_->readColorEntry( "ActiveHighlightColor", &color ) ); dialog_->inActiveHighlightClrBtn->setColor( config_->readColorEntry( "InActiveHighlightColor", &color ) ); @@ -235,9 +237,9 @@ void DeKoratorConfig::load( TDEConfig* ) // buttons config_->setGroup( "BUTTONS" ); - dialog_->useCusBtnClrChkBox->setChecked( config_->readBoolEntry( "UseCustomButtonsColors", FALSE ) ); - dialog_->cusColActBtnChkBox->setChecked( config_->readBoolEntry( "customColorsActiveButtons", FALSE ) ); - dialog_->cusColInActBtnChkBox->setChecked( config_->readBoolEntry( "customColorsInActiveButtons", FALSE ) ); + dialog_->useCusBtnClrChkBox->setChecked( config_->readBoolEntry( "UseCustomButtonsColors", false ) ); + dialog_->cusColActBtnChkBox->setChecked( config_->readBoolEntry( "customColorsActiveButtons", false ) ); + dialog_->cusColInActBtnChkBox->setChecked( config_->readBoolEntry( "customColorsInActiveButtons", false ) ); dialog_->closeClrBtn->setColor( config_->readColorEntry( "CloseButtonColor", &color ) ); dialog_->minClrBtn->setColor( config_->readColorEntry( "MinButtonColor", &color ) ); dialog_->maxClrBtn->setColor( config_->readColorEntry( "MaxButtonColor", &color ) ); @@ -262,7 +264,7 @@ void DeKoratorConfig::load( TDEConfig* ) dialog_->framesPathKurl->setURL( config_->readEntry( "FramesPath", (deftheme.isNull() ? "" : deftheme + "deco") ) ); dialog_->buttonsPathKurl->setURL( config_->readEntry( "ButtonsPath", (deftheme.isNull() ? "" : deftheme + "buttons") ) ); - dialog_->useMasks_Chkbox->setChecked( config_->readBoolEntry( "UseMasks", TRUE ) ); + dialog_->useMasks_Chkbox->setChecked( config_->readBoolEntry( "UseMasks", true ) ); dialog_->masksPathKurl->setURL( config_->readEntry( "MasksPath", (deftheme.isNull() ? "" : deftheme + "masks") ) ); // Find and preselect current theme @@ -304,6 +306,7 @@ void DeKoratorConfig::save( TDEConfig* ) // colors config_->setGroup( "COLORS" ); + config_->writeEntry( "Transparency", dialog_->transparencyChkBox->isChecked() ); config_->writeEntry( "ColorizeActFrames", dialog_->colorizeActFramesChkBox->isChecked() ); config_->writeEntry( "ColorizeActButtons", dialog_->colorizeActButtonsChkBox->isChecked() ); config_->writeEntry( "ColorizeInActFrames", dialog_->colorizeInActFramesChkBox->isChecked() ); @@ -385,6 +388,7 @@ void DeKoratorConfig::defaults() dialog_->btnShiftYSpinBox->setValue( 0 ); // colors + dialog_->transparencyChkBox->setChecked( FALSE ); dialog_->colorizeActFramesChkBox->setChecked( FALSE ); dialog_->colorizeActButtonsChkBox->setChecked( FALSE ); dialog_->colorizeInActFramesChkBox->setChecked( FALSE ); diff --git a/client/deKoratorclient.cpp b/client/deKoratorclient.cpp index 5c312fc..dc14eeb 100644 --- a/client/deKoratorclient.cpp +++ b/client/deKoratorclient.cpp @@ -36,6 +36,7 @@ #endif #include "deKoratorclient.h" +#include "imageholder.h" #include <tqsettings.h> @@ -175,6 +176,7 @@ TQString DeKoratorFactory::framesPath_ = ""; TQString DeKoratorFactory::buttonsPath_ = ""; TQString DeKoratorFactory::masksPath_ = ""; +bool DeKoratorFactory::transparency_ = FALSE; extern "C" { @@ -196,6 +198,11 @@ DeKoratorFactory::DeKoratorFactory() readConfig(); initialized_ = TRUE; + if (transparency_) + imageHolder = new QImageHolder(TQImage(), TQImage()); + else + imageHolder = nullptr; + initPixmaps(); loadPixmaps(); @@ -226,6 +233,9 @@ DeKoratorFactory::~DeKoratorFactory() initialized_ = FALSE; int i, j, k; + if (imageHolder) + delete imageHolder; + for ( i = 0; i < decoCount; i++ ) { for ( j = 0; j < pixTypeCount; j++ ) @@ -351,19 +361,19 @@ bool DeKoratorFactory::readConfig() TITLEALIGN = TQt::AlignRight; bool oldUseMenuImage = USEMENUEIMAGE; - USEMENUEIMAGE = config.readBoolEntry( "UseMenuImage", "false" ); + USEMENUEIMAGE = config.readBoolEntry( "UseMenuImage", false ); bool oldIgnoreAppIcnCol = IGNOREAPPICNCOL; - IGNOREAPPICNCOL = config.readBoolEntry( "IgnoreAppIconCol", "false" ); + IGNOREAPPICNCOL = config.readBoolEntry( "IgnoreAppIconCol", false ); // bool oldDblClkClose = DBLCLKCLOSE; - DBLCLKCLOSE = config.readBoolEntry( "DblClkClose", "false" ); + DBLCLKCLOSE = config.readBoolEntry( "DblClkClose", false ); bool oldShowBtmBorder = SHOWBTMBORDER; - SHOWBTMBORDER = config.readBoolEntry( "ShowBtmBorder", "false" ); + SHOWBTMBORDER = config.readBoolEntry( "ShowBtmBorder", false ); bool oldUseShdtext = USESHDTEXT; - USESHDTEXT = config.readBoolEntry( "UseShdtext", "false" ); + USESHDTEXT = config.readBoolEntry( "UseShdtext", false ); int oldActiveShdtextX = ACTIVESHDTEXTX; ACTIVESHDTEXTX = config.readNumEntry( "ActiveShdtextX", 0 ); @@ -394,25 +404,28 @@ bool DeKoratorFactory::readConfig() // color's settings config.setGroup( "COLORS" ); + bool oldTransparency = DeKoratorFactory::transparency_; + DeKoratorFactory::transparency_ = config.readBoolEntry( "Transparency", false ); + bool oldColorizeActFrames = DeKoratorFactory::colorizeActFrames_; - DeKoratorFactory::colorizeActFrames_ = config.readBoolEntry( "ColorizeActFrames", "false" ); + DeKoratorFactory::colorizeActFrames_ = config.readBoolEntry( "ColorizeActFrames", false ); bool oldColorizeActButtons = DeKoratorFactory::colorizeActButtons_; - DeKoratorFactory::colorizeActButtons_ = config.readBoolEntry( "ColorizeActButtons", "false" ); + DeKoratorFactory::colorizeActButtons_ = config.readBoolEntry( "ColorizeActButtons", false ); bool oldColorizeInActFrames = DeKoratorFactory::colorizeInActFrames_; - DeKoratorFactory::colorizeInActFrames_ = config.readBoolEntry( "ColorizeInActFrames", "false" ); + DeKoratorFactory::colorizeInActFrames_ = config.readBoolEntry( "ColorizeInActFrames", false ); bool oldColorizeInActButtons = DeKoratorFactory::colorizeInActButtons_; - DeKoratorFactory::colorizeInActButtons_ = config.readBoolEntry( "ColorizeInActButtons", "false" ); + DeKoratorFactory::colorizeInActButtons_ = config.readBoolEntry( "ColorizeInActButtons", false ); - USEANIMATION = config.readBoolEntry( "UseAnimation", "false" ); + USEANIMATION = config.readBoolEntry( "UseAnimation", false ); ANIMATIONTYPE = config.readEntry( "AnimationType", "Liquid Method" ); STEPS = config.readNumEntry( "AnimSteps", 5 ); INTERVAL = config.readNumEntry( "AnimInterval", 30 ); - KEEPANIMATING = config.readBoolEntry( "KeepAnimating", "false" ); + KEEPANIMATING = config.readBoolEntry( "KeepAnimating", false ); BUTTONHOVERTYPE = config.readEntry( "ButtonsHoverType", "To Gray" ); @@ -435,13 +448,13 @@ bool DeKoratorFactory::readConfig() config.setGroup( "BUTTONS" ); bool oldUseCustomButtonsColors = DeKoratorFactory::useCustomButtonsColors_; - DeKoratorFactory::useCustomButtonsColors_ = config.readBoolEntry( "UseCustomButtonsColors", "false" ); + DeKoratorFactory::useCustomButtonsColors_ = config.readBoolEntry( "UseCustomButtonsColors", false ); bool oldCustomColorsActiveButtons = DeKoratorFactory::customColorsActiveButtons_; - DeKoratorFactory::customColorsActiveButtons_ = config.readBoolEntry( "customColorsActiveButtons", "false" ); + DeKoratorFactory::customColorsActiveButtons_ = config.readBoolEntry( "customColorsActiveButtons", false ); bool oldCustomColorsInActiveButtons = DeKoratorFactory::customColorsInActiveButtons_; - DeKoratorFactory::customColorsInActiveButtons_ = config.readBoolEntry( "customColorsInActiveButtons", "false" ); + DeKoratorFactory::customColorsInActiveButtons_ = config.readBoolEntry( "customColorsInActiveButtons", false ); // load buttons colors TQColor colArr[ buttonTypeAllCount ]; @@ -486,7 +499,7 @@ bool DeKoratorFactory::readConfig() DeKoratorFactory::buttonsPath_ = config.readEntry( "ButtonsPath", "" ); bool oldUseMasks = USEMASKS; - USEMASKS = config.readBoolEntry( "UseMasks", "false" ); + USEMASKS = config.readBoolEntry( "UseMasks", false ); TQString oldMasksPath = DeKoratorFactory::masksPath_; DeKoratorFactory::masksPath_ = config.readEntry( "MasksPath", "" ); @@ -517,6 +530,7 @@ bool DeKoratorFactory::readConfig() oldInActiveShdtextX == INACTIVESHDTEXTX && oldInActiveShdtextY == INACTIVESHDTEXTY && oldInActiveShadeColor == INACTIVESHADECOLOR && + oldTransparency == DeKoratorFactory::transparency_ && oldColorizeActFrames == DeKoratorFactory::colorizeActFrames_ && oldColorizeActButtons == DeKoratorFactory::colorizeActButtons_ && oldColorizeInActFrames == DeKoratorFactory::colorizeInActFrames_ && @@ -551,7 +565,8 @@ bool DeKoratorFactory::readConfig() if ( oldFramesPath != DeKoratorFactory::framesPath_ || oldButtonsPath != DeKoratorFactory::buttonsPath_ || - oldMasksPath != DeKoratorFactory::masksPath_ + oldMasksPath != DeKoratorFactory::masksPath_ || + oldTransparency != DeKoratorFactory::transparency_ ) DeKoratorFactory::needReload_ = TRUE; else @@ -1077,7 +1092,7 @@ void DeKoratorFactory::chooseRightPixmaps() } ////////////////////////////////////////////////////////////////////////////// -// prepareDecoWithBbCol() +// prepareDecoWithBgCol() // void DeKoratorFactory::prepareDecoWithBgCol() { @@ -1092,6 +1107,11 @@ void DeKoratorFactory::prepareDecoWithBgCol() { for ( i = 0 ; i < decoCount ; i++ ) { + if (transparency_) { + //DECOARR[ i ][ actCol ] = DECOARR[ i ][ actCol ]; + continue; + } + tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); tempPix.fill( col ); @@ -1109,6 +1129,11 @@ void DeKoratorFactory::prepareDecoWithBgCol() { for ( i = 0 ; i < decoCount ; i++ ) { + if (transparency_) { + DECOARR[ i ][ normal ] = new TQPixmap(*DECOARR[ i ][ orig ]); + continue; + } + tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); tempPix.fill( col ); @@ -1127,6 +1152,11 @@ void DeKoratorFactory::prepareDecoWithBgCol() { for ( i = 0 ; i < decoCount ; i++ ) { + if (transparency_) { + //DECOARR[ i ][ inActCol ] = DECOARR[ i ][ inActCol ]; + continue; + } + tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); tempPix.fill( col ); @@ -1144,6 +1174,11 @@ void DeKoratorFactory::prepareDecoWithBgCol() { for ( i = 0 ; i < decoCount ; i++ ) { + if (transparency_) { + DECOARR[ i ][ normal ] = new TQPixmap(*DECOARR[ i ][ orig ]); + continue; + } + tempPix.resize( DECOARR[ i ][ orig ] ->width(), DECOARR[ i ][ orig ] ->height() ); tempPix.fill( col ); @@ -1347,6 +1382,14 @@ void DeKoratorButton::drawButton( TQPainter * painter ) int dx = 0, dy = 0; bool act = client_->isActive(); TQImage buttonImgBak; + TQPixmap *background = client_->decoFactory_->imageHolder->image(act); + + if (background && DeKoratorFactory::transparency_) { + TQRect r = rect(); + TQPoint p = mapToGlobal( TQPoint(0,0) ); + r.moveBy( p.x(), p.y() ); + painter->drawPixmap( TQPoint(0,0), *background, r ); + } // fill background if ( isLeft_ ) @@ -1717,6 +1760,12 @@ void DeKoratorClient::init() connect( this, TQ_SIGNAL( keepAboveChanged( bool ) ), TQ_SLOT( keepAboveChange( bool ) ) ); connect( this, TQ_SIGNAL( keepBelowChanged( bool ) ), TQ_SLOT( keepBelowChange( bool ) ) ); + if (DeKoratorFactory::transparency_) + { + connect( decoFactory_->imageHolder, TQ_SIGNAL( repaintNeeded() ), this, TQ_SLOT( repaint() ) ); + connect( &repaintTimer, TQ_SIGNAL( timeout() ), this, TQ_SLOT( repaint() ) ); + } + captionBufferDirty_ = true; //maskDirty_ = true; widget() ->update( titleBarSpacer_->geometry() ); @@ -2312,6 +2361,15 @@ void DeKoratorClient::wheelEvent( TQWheelEvent *e ) titlebarMouseWheelOperation( e->delta() ); } +////////////////////////////////////////////////////////////////////////////// +// repaint() +// ----------------------- +// +void DeKoratorClient::repaint() { + widget()->repaint(); + for (int n=0; n<ButtonTypeCount; n++) + if (button[n]) button[n]->reset(); +} ////////////////////////////////////////////////////////////////////////////// // paintEvent() @@ -2334,11 +2392,19 @@ void DeKoratorClient::paintEvent( TQPaintEvent* ) TQRect rightTitleR( rightTitleBarSpacer_->geometry() ); titleR.rect( &tx, &ty, &tw, &th ); TQRect rect; + TQPixmap* background = decoFactory_->imageHolder->image(isActive()); + TQPoint p = widget()->mapToGlobal(TQPoint(0,0)); + + if (background && DeKoratorFactory::transparency_) + painter.drawPixmap( 0, 0, *background, p.x(), p.y(), w, h ); TQPainter painter2; TQPixmap pix( w, TITLESIZE ); painter2.begin( &pix ); { + if (background && DeKoratorFactory::transparency_) + painter2.drawPixmap( 0, 0, *background, p.x(), p.y(), w, TITLESIZE ); + // topLeftCorner rect.setRect( 0, 0, TOPLEFTCORNERWIDTH, TITLESIZE ); @@ -2584,6 +2650,8 @@ void DeKoratorClient::updateCaptionBuffer() // Window is being resized void DeKoratorClient::resizeEvent( TQResizeEvent *e ) { + if ( !repaintTimer.isActive() && DeKoratorFactory::transparency_ ) + repaintTimer.start(0, true); if ( widget() ->isShown() ) { TQRegion region = widget() ->rect(); diff --git a/client/deKoratorclient.h b/client/deKoratorclient.h index 3147fbd..e74774a 100644 --- a/client/deKoratorclient.h +++ b/client/deKoratorclient.h @@ -58,6 +58,7 @@ #include "shadow.h" +class QImageHolder; class TQSpacerItem; class TQPoint; @@ -160,7 +161,7 @@ private: static bool colorizeActFrames_; static bool colorizeInActFrames_; static bool needInit_; - static bool needReload_; + static bool needReload_; static TQString framesPath_; static TQString buttonsPath_; static TQString masksPath_; @@ -172,6 +173,9 @@ public: static bool colorizeActButtons_; static bool colorizeInActButtons_; static TQColor cusBtnCol_[ buttonTypeAllCount ]; + static bool transparency_; + + QImageHolder *imageHolder; }; inline bool DeKoratorFactory::initialized() @@ -298,6 +302,7 @@ private slots: void keepAboveChange( bool ); void keepBelowChange( bool ); void menuButtonReleased(); + void repaint(); private: DeKoratorButton *button[ ButtonTypeCount ]; @@ -305,6 +310,7 @@ private: TQHBoxLayout *titleLayout_ ; TQHBoxLayout *midLayout_; TQSpacerItem *leftTitleBarSpacer_, *titleBarSpacer_, *rightTitleBarSpacer_, *leftSpacer_, *rightSpacer_, *bottomSpacer_; + TQTimer repaintTimer; bool closing_; TQPixmap *captionBufferPix_; bool captionBufferDirty_; diff --git a/client/imageholder.cpp b/client/imageholder.cpp new file mode 100644 index 0000000..c37026b --- /dev/null +++ b/client/imageholder.cpp @@ -0,0 +1,137 @@ +/*************************************************************************** + * 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 <tdeapplication.h> +#include <tqimage.h> +#include <kimageeffect.h> +#include <tqdesktopwidget.h> +#include "imageholder.h" + + +QImageHolder::QImageHolder(TQImage act,TQImage inact) +:img_active(NULL),img_inactive(NULL) +{ + rootpixmap=NULL; + setUserdefinedPictures( act,inact); + initialized=userdefinedActive && userdefinedInactive; + + emit repaintNeeded(); +} + +QImageHolder::~QImageHolder() +{ + if (rootpixmap)delete rootpixmap; + if (img_active && !userdefinedActive)delete img_active; + if (img_inactive && !userdefinedInactive)delete img_inactive; +} + +void QImageHolder::setUserdefinedPictures( TQImage act,TQImage inact) +{ + int w=TQApplication::desktop()->width(); + int h=TQApplication::desktop()->height(); + if (img_active && !userdefinedActive) + { + delete img_active; + img_active=NULL; + } + if (img_inactive && !userdefinedInactive) + { + delete img_inactive; + img_inactive=NULL; + } + + if (!act.isNull()) + img_active=new TQPixmap(act); + else + img_active=NULL; + if (!inact.isNull()) + img_inactive=new TQPixmap(inact); + else + img_inactive=NULL; + + userdefinedActive=(img_active!=NULL); + userdefinedInactive=(img_inactive!=NULL); + + CheckSanity(); +} + +void QImageHolder::Init() +{ + if (initialized)return; + + rootpixmap=new KMyRootPixmap(NULL/*,this*/); + rootpixmap->start(); + rootpixmap->repaint(true); + connect( rootpixmap,TQ_SIGNAL(backgroundUpdated(const TQImage*)),this, TQ_SLOT(BackgroundUpdated(const TQImage*))); + connect(kapp, TQ_SIGNAL(backgroundChanged(int)),TQ_SLOT(handleDesktopChanged(int))); + + initialized=true; +} + +void QImageHolder::repaint(bool force) +{ + Init(); + if (rootpixmap)rootpixmap->repaint(force); +} + +void QImageHolder::handleDesktopChanged(int) +{ + repaint(true); +} + +void QImageHolder::CheckSanity() +{ + if (!initialized)return; + if (userdefinedActive && userdefinedInactive)return; + if (img_active!=NULL && !userdefinedActive)return; + if (img_inactive!=NULL && !userdefinedInactive)return; + + if (rootpixmap)delete rootpixmap; + rootpixmap=NULL; + + initialized=false; +} + +void QImageHolder::BackgroundUpdated(const TQImage *src) +{ + if (img_active && !userdefinedActive) + { + delete img_active; + img_active=NULL; + } + if (img_inactive && !userdefinedInactive) + { + delete img_inactive; + img_inactive=NULL; + } + + if (src && !src->isNull()) + { + if (!userdefinedInactive) + img_inactive=new TQPixmap(src->copy()); + if (!userdefinedActive) + img_active=new TQPixmap(src->copy()); + } + + emit repaintNeeded(); +} + +#include "imageholder.moc" diff --git a/client/imageholder.h b/client/imageholder.h new file mode 100644 index 0000000..d5dfbc3 --- /dev/null +++ b/client/imageholder.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + + +#ifndef _IMAGEHOLDER_INCLUDED_ +#define _IMAGEHOLDER_INCLUDED_ + + +#include <twinmodule.h> +#include "myrootpixmap.h" + +struct WND_CONFIG; + +class QImageHolder:public TQObject +{ + TQ_OBJECT + +public: + QImageHolder(TQImage act,TQImage inact); + virtual ~QImageHolder(); + + void Init(); + TQPixmap *image(bool active) { Init(); return active?img_active:img_inactive; } + void repaint(bool force); + + void setUserdefinedPictures(TQImage act,TQImage inact); + +private: + bool initialized; + KMyRootPixmap *rootpixmap; + TQPixmap *img_active,*img_inactive; + bool userdefinedActive,userdefinedInactive; + + TQPixmap* ApplyEffect(TQImage &src,WND_CONFIG* cfg,TQColorGroup colorgroup); + +public slots: + void BackgroundUpdated(const TQImage *); + void handleDesktopChanged(int desk); + void CheckSanity(); + +signals: + void repaintNeeded(); +}; + + +#endif diff --git a/client/myrootpixmap.cpp b/client/myrootpixmap.cpp new file mode 100644 index 0000000..1504147 --- /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 <jansen@kde.org> + * + * 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 <kb9vqf@pearsoncomputing.net> */ + +#include <tqwidget.h> +#include <tqtimer.h> +#include <tqrect.h> +#include <tqimage.h> + +#ifndef TQ_WS_TQWS //FIXME +#include <tdeapplication.h> +#include <kimageeffect.h> +#include <kpixmapio.h> +#include <netwm.h> +#include <twin.h> +#include <kdebug.h> +#include <netwm.h> +#include <dcopclient.h> +#include <dcopref.h> +#include <tqpainter.h> + +#include <ksharedpixmap.h> +#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 TQ_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, TQ_SIGNAL(backgroundChanged(int)), TQ_SLOT(slotBackgroundChanged(int))); + connect(m_pPixmap, TQ_SIGNAL(done(bool)), TQ_SLOT(slotDone(bool))); +// connect(m_pTimer, TQ_SIGNAL(timeout()), TQ_SLOT(repaint())); + +#ifdef TQ_WS_X11 + d->twin = new DesktopWallpaperWatcher(); + connect(d->twin, TQ_SIGNAL(currentDesktopChanged(int)), TQ_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 TQ_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.h b/client/myrootpixmap.h new file mode 100644 index 0000000..9c8d649 --- /dev/null +++ b/client/myrootpixmap.h @@ -0,0 +1,116 @@ +/* + * + * $Id: krootpixmap.h,v 1.15 2003/05/19 08:02:48 coolo Exp $ + * This file is part of the KDE project, module kdesktop. + * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> + * + * 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 <kb9vqf@pearsoncomputing.net> */ + +#ifndef __KRootPixmap_h_Included__ +#define __KRootPixmap_h_Included__ + +#include <tqobject.h> +#include <tqwidget.h> +#include <tqcolor.h> + +#ifndef TQ_WS_TQWS //FIXME + +class TQRect; +class TQTimer; +class TDESharedPixmap; +class KMyRootPixmapData; + +class DesktopWallpaperWatcher : public TQWidget +{ + TQ_OBJECT + + public: + DesktopWallpaperWatcher(); + ~DesktopWallpaperWatcher(); + + bool x11Event( XEvent * ev ); + + signals: + void currentDesktopChanged( int desktop); + + private: + int m_old_current_desktop; +}; + +class KMyRootPixmap: public TQObject +{ + TQ_OBJECT + +public: + KMyRootPixmap( TQWidget *target=NULL, const char *name=0 ); + + KMyRootPixmap( TQWidget *target, TQObject *parent, const char *name=0 ); + + virtual ~KMyRootPixmap(); + + bool isAvailable(); + + bool isActive() const { return m_bActive; } + + int currentDesktop() const; + +// bool customPainting() const { return m_bCustomPaint; } + +#ifndef KDE_NO_COMPAT + + bool checkAvailable(bool) { return isAvailable(); } +#endif + +public slots: + virtual void start(); + + virtual void stop(); + +// void setFadeEffect(double strength, const TQColor &color); + + void repaint( bool force ); + + void repaint(); + +// void setCustomPainting( bool enable ) { m_bCustomPaint = enable; } + + void enableExports(); + + static TQString pixmapName(int desk); + +signals: + void backgroundUpdated( const TQImage *pm ); + +protected: +// virtual bool eventFilter(TQObject *, TQEvent *); + + virtual void updateBackground( TDESharedPixmap * ); + +private slots: +// void slotBackgroundChanged(int); + void slotDone(bool); + void desktopChanged(int desktop); + +private: + bool m_bActive, m_bInit/*, m_bCustomPaint*/; + int m_Desk; + +// double m_Fade; +// TQColor m_FadeColor; + + TQRect m_Rect; +// TQWidget *m_pWidget; +// TQTimer *m_pTimer; + TDESharedPixmap *m_pPixmap; + KMyRootPixmapData *d; + + void init(); +}; + +#endif // ! TQ_WS_TQWS +#endif // __KRootPixmap_h_Included__ |