diff options
| author | Daniel Würl <trinity@dwrl.de> | 2025-03-24 20:12:39 +0100 |
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-03-26 17:25:27 +0900 |
| commit | 18a83dff1e83c4242f769895a4243f3c2560f67c (patch) | |
| tree | 9036e5234668cf25b3cc6bcc3fbe9f82fa9abf51 | |
| parent | 4028a2816cf973f5149807bc4224aff7abaae708 (diff) | |
| download | twin-style-dekorator-18a83dff.tar.gz twin-style-dekorator-18a83dff.zip | |
Move logic for loading border images into it's own method. The method checks for new and old filenames on each image, and can be extended in the future to handle images for inactive frames as well.
Signed-off-by: Daniel Würl <trinity@dwrl.de>
(cherry picked from commit 80d3473b44407c23f062eee61c24fb27f6c3950e)
| -rw-r--r-- | client/deKoratorclient.cpp | 127 | ||||
| -rw-r--r-- | client/deKoratorclient.h | 1 |
2 files changed, 52 insertions, 76 deletions
diff --git a/client/deKoratorclient.cpp b/client/deKoratorclient.cpp index e5d89d9..9ac8b34 100644 --- a/client/deKoratorclient.cpp +++ b/client/deKoratorclient.cpp @@ -589,6 +589,23 @@ bool DeKoratorFactory::readConfig() } ////////////////////////////////////////////////////////////////////////////// +// loadBorderPixmap() +// ------------ +// Load border pixmaps and try to also get pixmaps for inactive state. +bool DeKoratorFactory::loadBorderPixmap(decoType borderPart, const TQString& newName, const TQString& oldName) { + TQString decoPixDir = DeKoratorFactory::framesPath_; + + bool imgLoaded = DECOARR[ borderPart ][ orig ] ->load( decoPixDir + "/" + newName + "Bg.png" ); + if ( ! imgLoaded ) + imgLoaded = DECOARR[ borderPart ][ orig ] ->load( decoPixDir + "/" + oldName + "Bg.png" ); + + if ( imgLoaded ) + return true; + else + return false; +} + +////////////////////////////////////////////////////////////////////////////// // loadPixmaps() // ------------ // Read in the configuration file @@ -600,82 +617,40 @@ void DeKoratorFactory::loadPixmaps() // deco - // image 'leftUpperCornerFrameBg.png' doesn't exist in the old naming scheme, so we can simply check for that. - bool useNewFileNames = DECOARR[ leftUpperCornerFrame ][ orig ] ->load( decoPixDir + "/leftUpperCornerFrameBg.png" ); - if ( useNewFileNames ) - { - // top frame from left to right - // enable if one of those images exist - bool optLeft = DECOARR[ topLeftFrame ][ orig ] ->load( decoPixDir + "/topLeftFrameBg.png" ); - bool optMid = DECOARR[ topMidFrame ][ orig ] ->load( decoPixDir + "/topMidFrameBg.png" ); - bool optRight = DECOARR[ topRightFrame ][ orig ] ->load( decoPixDir + "/topRightFrameBg.png" ); - HASTOPFRAME = optLeft && optMid && optRight; - - // title bar from left to right - DECOARR[ leftUpperCornerFrame ][ orig ] ->load( decoPixDir + "/leftUpperCornerFrameBg.png" ); - DECOARR[ buttonsLeft ][ orig ] ->load( decoPixDir + "/buttonsLeftBg.png" ); - DECOARR[ titleLeft ][ orig ] ->load( decoPixDir + "/titleLeftBg.png" ); - DECOARR[ titleMid ][ orig ] ->load( decoPixDir + "/titleMidBg.png" ); - DECOARR[ titleRight ][ orig ] ->load( decoPixDir + "/titleRightBg.png" ); - DECOARR[ buttonsRight ][ orig ] ->load( decoPixDir + "/buttonsRightBg.png" ); - DECOARR[ rightUpperCornerFrame ][ orig ] ->load( decoPixDir + "/rightUpperCornerFrameBg.png" ); - // left frame from top to bottom - DECOARR[ leftUpperFrame ][ orig ] ->load( decoPixDir + "/leftUpperFrameBg.png" ); - DECOARR[ leftMidFrame ][ orig ] ->load( decoPixDir + "/leftMidFrameBg.png" ); - DECOARR[ leftLowerCornerFrame ][ orig ] ->load( decoPixDir + "/leftLowerCornerFrameBg.png" ); - // bottom frame from left to right - DECOARR[ bottomLeftFrame ][ orig ] ->load( decoPixDir + "/bottomLeftFrameBg.png" ); - DECOARR[ bottomMidFrame ][ orig ] ->load( decoPixDir + "/bottomMidFrameBg.png" ); - DECOARR[ bottomRightFrame ][ orig ] ->load( decoPixDir + "/bottomRightFrameBg.png" ); - // bottom shaded frame from left to right - // enable if one of those images exist - optLeft = DECOARR[ bottomShadedLeftFrame ][ orig ] ->load( decoPixDir + "/bottomShadedLeftFrameBg.png" ); - optMid = DECOARR[ bottomShadedMidFrame ][ orig ] ->load( decoPixDir + "/bottomShadedMidFrameBg.png" ); - optRight = DECOARR[ bottomShadedRightFrame ][ orig ] ->load( decoPixDir + "/bottomShadedRightFrameBg.png" ); - HASBOTTOMSHADEDFRAME = optLeft && optMid && optRight; - - // right frame from top to bottom - DECOARR[ rightUpperFrame ][ orig ] ->load( decoPixDir + "/rightUpperFrameBg.png" ); - DECOARR[ rightMidFrame ][ orig ] ->load( decoPixDir + "/rightMidFrameBg.png" ); - DECOARR[ rightLowerCornerFrame ][ orig ] ->load( decoPixDir + "/rightLowerCornerFrameBg.png" ); - } - else - { - // top frame from left to right - // enable if one of those images exist - bool optLeft = DECOARR[ topLeftFrame ][ orig ] ->load( decoPixDir + "/leftTopFrameBg.png" ); - bool optMid = DECOARR[ topMidFrame ][ orig ] ->load( decoPixDir + "/midTopFrameBg.png" ); - bool optRight = DECOARR[ topRightFrame ][ orig ] ->load( decoPixDir + "/rightTopFrameBg.png" ); - HASTOPFRAME = optLeft && optMid && optRight; - - // title bar from left to right - DECOARR[ leftUpperCornerFrame ][ orig ] ->load( decoPixDir + "/topLeftCornerBg.png" ); - DECOARR[ buttonsLeft ][ orig ] ->load( decoPixDir + "/leftButtonsBg.png" ); - DECOARR[ titleLeft ][ orig ] ->load( decoPixDir + "/leftTitleBg.png" ); - DECOARR[ titleMid ][ orig ] ->load( decoPixDir + "/midTitleBg.png" ); - DECOARR[ titleRight ][ orig ] ->load( decoPixDir + "/rightTitleBg.png" ); - DECOARR[ buttonsRight ][ orig ] ->load( decoPixDir + "/rightButtonsBg.png" ); - DECOARR[ rightUpperCornerFrame ][ orig ] ->load( decoPixDir + "/topRightCornerBg.png" ); - // left frame from top to bottom - DECOARR[ leftUpperFrame ][ orig ] ->load( decoPixDir + "/topLeftFrameBg.png" ); - DECOARR[ leftMidFrame ][ orig ] ->load( decoPixDir + "/midLeftFrameBg.png" ); - DECOARR[ leftLowerCornerFrame ][ orig ] ->load( decoPixDir + "/bottomLeftFrameBg.png" ); - // bottom frame from left to right - DECOARR[ bottomLeftFrame ][ orig ] ->load( decoPixDir + "/leftBottomFrameBg.png" ); - DECOARR[ bottomMidFrame ][ orig ] ->load( decoPixDir + "/midBottomFrameBg.png" ); - DECOARR[ bottomRightFrame ][ orig ] ->load( decoPixDir + "/rightBottomFrameBg.png" ); - // bottom shaded frame from left to right - // enable if one of those images exist - optLeft = DECOARR[ bottomShadedLeftFrame ][ orig ] ->load( decoPixDir + "/leftBottomShadedFrameBg.png" ); - optMid = DECOARR[ bottomShadedMidFrame ][ orig ] ->load( decoPixDir + "/midBottomShadedFrameBg.png" ); - optRight = DECOARR[ bottomShadedRightFrame ][ orig ] ->load( decoPixDir + "/rightBottomShadedFrameBg.png" ); - HASBOTTOMSHADEDFRAME = optLeft && optMid && optRight; - - // right frame from top to bottom - DECOARR[ rightUpperFrame ][ orig ] ->load( decoPixDir + "/topRightFrameBg.png" ); - DECOARR[ rightMidFrame ][ orig ] ->load( decoPixDir + "/midRightFrameBg.png" ); - DECOARR[ rightLowerCornerFrame ][ orig ] ->load( decoPixDir + "/bottomRightFrameBg.png" ); - } + // top frame from left to right + // enable only if all images exist + bool optLeft = loadBorderPixmap( topLeftFrame, "topLeftFrame", "leftTopFrame"); + bool optMid = loadBorderPixmap( topMidFrame, "topMidFrame", "midTopFrame"); + bool optRight = loadBorderPixmap( topRightFrame, "topRightFrame", "rightTopFrame"); + HASTOPFRAME = optLeft && optMid && optRight; + + // title bar from left to right + loadBorderPixmap( leftUpperCornerFrame, "leftUpperCornerFrame", "topLeftCorner"); + loadBorderPixmap( buttonsLeft, "buttonsLeft", "leftButtons"); + loadBorderPixmap( titleLeft, "titleLeft", "leftTitle"); + loadBorderPixmap( titleMid, "titleMid", "midTitle"); + loadBorderPixmap( titleRight, "titleRight", "rightTitle"); + loadBorderPixmap( buttonsRight, "buttonsRight", "rightButtons"); + loadBorderPixmap( rightUpperCornerFrame, "rightUpperCornerFrame", "topRightCorner"); + // left frame from top to bottom + loadBorderPixmap( leftUpperFrame, "leftUpperFrame", "topLeftFrame"); + loadBorderPixmap( leftMidFrame, "leftMidFrame", "midLeftFrame"); + loadBorderPixmap( leftLowerCornerFrame, "leftLowerCornerFrame", "bottomLeftFrame"); + // bottom frame from left to right + loadBorderPixmap( bottomLeftFrame, "bottomLeftFrame", "leftBottomFrame"); + loadBorderPixmap( bottomMidFrame, "bottomMidFrame", "midBottomFrame"); + loadBorderPixmap( bottomRightFrame, "bottomRightFrame", "rightBottomFrame"); + // bottom shaded frame from left to right + // enable only if all images exist + optLeft = loadBorderPixmap( bottomShadedLeftFrame, "bottomShadedLeftFrame", "leftBottomShadedFrame"); + optMid = loadBorderPixmap( bottomShadedMidFrame, "bottomShadedMidFrame", "midBottomShadedFrame"); + optRight = loadBorderPixmap( bottomShadedRightFrame, "bottomShadedRightFrame", "rightBottomShadedFrame"); + HASBOTTOMSHADEDFRAME = optLeft && optMid && optRight; + + // right frame from top to bottom + loadBorderPixmap( rightUpperFrame, "rightUpperFrame", "topRightFrame"); + loadBorderPixmap( rightMidFrame, "rightMidFrame", "midRightFrame"); + loadBorderPixmap( rightLowerCornerFrame, "rightLowerCornerFrame", "bottomRightFrame"); // buttons diff --git a/client/deKoratorclient.h b/client/deKoratorclient.h index 467360d..6fc3bab 100644 --- a/client/deKoratorclient.h +++ b/client/deKoratorclient.h @@ -154,6 +154,7 @@ public: private: bool readConfig(); + bool loadBorderPixmap(decoType borderPart, const TQString& oldName, const TQString& newName); void loadPixmaps(); void colorizeDecoPixmaps( bool isActive ); void colorizeButtonsPixmaps( bool isActive ); |
