From 62f7201f4125becde2664620ce228fc12c7fa2fa Mon Sep 17 00:00:00 2001 From: Huynh Huu Long Date: Mon, 9 Mar 2009 22:36:39 +0000 Subject: [PATCH] Use the stardard method to adjust the border width svn path=/trunk/KDE/kdebase/workspace/; revision=937562 --- clients/oxygen/config/config.cpp | 4 -- clients/oxygen/config/oxygenconfig.ui | 9 +--- clients/oxygen/oxygen.cpp | 64 +++++++++++++++++++++++++-- clients/oxygen/oxygen.h | 12 +++-- clients/oxygen/oxygenclient.cpp | 14 +++--- 5 files changed, 72 insertions(+), 31 deletions(-) diff --git a/clients/oxygen/config/config.cpp b/clients/oxygen/config/config.cpp index 5986287d73..eae2c2b6c6 100644 --- a/clients/oxygen/config/config.cpp +++ b/clients/oxygen/config/config.cpp @@ -49,7 +49,6 @@ OxygenConfig::OxygenConfig( KConfig*, QWidget* parent ) KConfigGroup cg(c, "Windeco"); ui = new OxygenConfigUI( parent ); connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) ); - connect( ui->thinBorders, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentRight, SIGNAL(clicked()), SIGNAL(changed()) ); @@ -72,7 +71,6 @@ void OxygenConfig::load( const KConfigGroup& ) { KConfigGroup cg(c, "Windeco"); ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) ); - ui->thinBorders->setChecked( cg.readEntry("ThinBorders", true) ); QString titleAlignment = cg.readEntry("TitleAlignment", "Left"); ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" ); @@ -86,7 +84,6 @@ void OxygenConfig::save( KConfigGroup& ) { KConfigGroup cg(c, "Windeco"); cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() ); - cg.writeEntry( "ThinBorders", ui->thinBorders->isChecked() ); QString titleAlignment = "Left"; if (ui->titleAlignmentCenter->isChecked()) @@ -106,7 +103,6 @@ void OxygenConfig::save( KConfigGroup& ) void OxygenConfig::defaults() { ui->showStripes->setChecked( true ); - ui->thinBorders->setChecked( true ); ui->titleAlignmentLeft->setChecked( true ); emit changed(); diff --git a/clients/oxygen/config/oxygenconfig.ui b/clients/oxygen/config/oxygenconfig.ui index f77f335d7a..1f21b12b9a 100644 --- a/clients/oxygen/config/oxygenconfig.ui +++ b/clients/oxygen/config/oxygenconfig.ui @@ -7,7 +7,7 @@ 0 0 364 - 234 + 92 @@ -60,13 +60,6 @@ - - - - Use thin borders - - - diff --git a/clients/oxygen/oxygen.cpp b/clients/oxygen/oxygen.cpp index 9bb9923307..54819b793c 100644 --- a/clients/oxygen/oxygen.cpp +++ b/clients/oxygen/oxygen.cpp @@ -51,7 +51,7 @@ OxygenHelper *oxygenHelper(); // referenced from definition in oxygendclient.cpp bool OxygenFactory::initialized_ = false; Qt::Alignment OxygenFactory::titleAlignment_ = Qt::AlignLeft; bool OxygenFactory::showStripes_ = true; -bool OxygenFactory::thinBorders_ = true; +int OxygenFactory::borderSize_ = 4; // BorderSize::BorderNormal ////////////////////////////////////////////////////////////////////////////// // OxygenFactory() @@ -101,6 +101,31 @@ bool OxygenFactory::reset(unsigned long changed) resetDecorations(changed); return false; } + + // taken from plastik + switch(KDecoration::options()->preferredBorderSize( this )) { + case BorderTiny: + borderSize_ = 2; + break; + case BorderLarge: + borderSize_ = 8; + break; + case BorderVeryLarge: + borderSize_ = 12; + break; + case BorderHuge: + borderSize_ = 18; + break; + case BorderVeryHuge: + borderSize_ = 27; + break; + case BorderOversized: + borderSize_ = 40; + break; + case BorderNormal: + default: + borderSize_ = 4; + } } ////////////////////////////////////////////////////////////////////////////// @@ -124,14 +149,36 @@ bool OxygenFactory::readConfig() else if (value == "Right") titleAlignment_ = Qt::AlignRight; - bool oldborders = thinBorders_; - thinBorders_ = group.readEntry( "ThinBorders", true ); + int oldBorderSize = borderSize_; + switch(KDecoration::options()->preferredBorderSize( this )) { + case BorderTiny: + borderSize_ = 2; + break; + case BorderLarge: + borderSize_ = 8; + break; + case BorderVeryLarge: + borderSize_ = 12; + break; + case BorderHuge: + borderSize_ = 18; + break; + case BorderVeryHuge: + borderSize_ = 27; + break; + case BorderOversized: + borderSize_ = 40; + break; + case BorderNormal: + default: + borderSize_ = 4; + } bool oldstripes = showStripes_; showStripes_ = group.readEntry( "ShowStripes", true ); if (oldalign == titleAlignment_ && oldstripes == showStripes_ - && oldborders == thinBorders_) + && oldBorderSize == borderSize_) return false; else return true; @@ -163,6 +210,15 @@ bool OxygenFactory::supports( Ability ability ) const }; } +QList< OxygenFactory::BorderSize > +OxygenFactory::borderSizes() const +{ + // the list must be sorted + return QList< BorderSize >() << BorderTiny << BorderNormal << + BorderLarge << BorderVeryLarge << BorderHuge << + BorderVeryHuge << BorderOversized; +} + ////////////////////////////////////////////////////////////////////////////// // Shadows diff --git a/clients/oxygen/oxygen.h b/clients/oxygen/oxygen.h index 0c95dcb397..59e3c9ff12 100644 --- a/clients/oxygen/oxygen.h +++ b/clients/oxygen/oxygen.h @@ -35,9 +35,6 @@ namespace Oxygen static const int OXYGEN_BUTTONSIZE = 22; #define TFRAMESIZE 3 -#define BFRAMESIZE 5 -#define LFRAMESIZE 5 -#define RFRAMESIZE 5 enum ButtonType { ButtonHelp=0, @@ -61,6 +58,7 @@ public: virtual KDecoration *createDecoration(KDecorationBridge *b); virtual bool reset(unsigned long changed); virtual bool supports( Ability ability ) const; + QList< BorderSize > borderSizes() const; virtual QList< QList > shadowTextures(); virtual int shadowTextureList( ShadowType type ) const; @@ -70,7 +68,7 @@ public: static bool initialized(); static Qt::Alignment titleAlignment(); static bool showStripes(); - static bool thinBorders(); + static int borderSize(); private: bool readConfig(); @@ -79,7 +77,7 @@ private: static bool initialized_; static Qt::Alignment titleAlignment_; static bool showStripes_; - static bool thinBorders_; + static int borderSize_; }; inline bool OxygenFactory::initialized() @@ -91,8 +89,8 @@ inline Qt::Alignment OxygenFactory::titleAlignment() inline bool OxygenFactory::showStripes() { return showStripes_; } -inline bool OxygenFactory::thinBorders() - { return thinBorders_; } +inline int OxygenFactory::borderSize() + { return borderSize_; } } //namespace Oxygen diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 466fdfea1d..63b0dc0edc 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -122,6 +122,7 @@ bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const { bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); + int frameWidth = OxygenFactory::borderSize(); switch (lm) { case LM_BorderLeft: @@ -131,15 +132,12 @@ int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const K if (respectWindowState && maximized) { return 0; } else { - if (OxygenFactory::thinBorders()) - { - if (lm == LM_BorderBottom) { - return BFRAMESIZE + 2; - } else { - return 2; - } + // Even for thin borders (2px wide) we want to preserve + // the rounded corners having a minimum height of 7px + if (lm == LM_BorderBottom) { + return qMax(frameWidth, 7); } else { - return BFRAMESIZE; + return frameWidth; } } }