Use the stardard method to adjust the border width

svn path=/trunk/KDE/kdebase/workspace/; revision=937562
This commit is contained in:
Huynh Huu Long 2009-03-09 22:36:39 +00:00
parent cf222c6da0
commit 62f7201f41
5 changed files with 72 additions and 31 deletions

View file

@ -49,7 +49,6 @@ OxygenConfig::OxygenConfig( KConfig*, QWidget* parent )
KConfigGroup cg(c, "Windeco"); KConfigGroup cg(c, "Windeco");
ui = new OxygenConfigUI( parent ); ui = new OxygenConfigUI( parent );
connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->thinBorders, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentLeft, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentCenter, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->titleAlignmentRight, SIGNAL(clicked()), SIGNAL(changed()) ); connect( ui->titleAlignmentRight, SIGNAL(clicked()), SIGNAL(changed()) );
@ -72,7 +71,6 @@ void OxygenConfig::load( const KConfigGroup& )
{ {
KConfigGroup cg(c, "Windeco"); KConfigGroup cg(c, "Windeco");
ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) ); ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) );
ui->thinBorders->setChecked( cg.readEntry("ThinBorders", true) );
QString titleAlignment = cg.readEntry("TitleAlignment", "Left"); QString titleAlignment = cg.readEntry("TitleAlignment", "Left");
ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" ); ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" );
@ -86,7 +84,6 @@ void OxygenConfig::save( KConfigGroup& )
{ {
KConfigGroup cg(c, "Windeco"); KConfigGroup cg(c, "Windeco");
cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() ); cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
cg.writeEntry( "ThinBorders", ui->thinBorders->isChecked() );
QString titleAlignment = "Left"; QString titleAlignment = "Left";
if (ui->titleAlignmentCenter->isChecked()) if (ui->titleAlignmentCenter->isChecked())
@ -106,7 +103,6 @@ void OxygenConfig::save( KConfigGroup& )
void OxygenConfig::defaults() void OxygenConfig::defaults()
{ {
ui->showStripes->setChecked( true ); ui->showStripes->setChecked( true );
ui->thinBorders->setChecked( true );
ui->titleAlignmentLeft->setChecked( true ); ui->titleAlignmentLeft->setChecked( true );
emit changed(); emit changed();

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>364</width> <width>364</width>
<height>234</height> <height>92</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -60,13 +60,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="thinBorders">
<property name="text">
<string>Use thin borders</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>

View file

@ -51,7 +51,7 @@ OxygenHelper *oxygenHelper(); // referenced from definition in oxygendclient.cpp
bool OxygenFactory::initialized_ = false; bool OxygenFactory::initialized_ = false;
Qt::Alignment OxygenFactory::titleAlignment_ = Qt::AlignLeft; Qt::Alignment OxygenFactory::titleAlignment_ = Qt::AlignLeft;
bool OxygenFactory::showStripes_ = true; bool OxygenFactory::showStripes_ = true;
bool OxygenFactory::thinBorders_ = true; int OxygenFactory::borderSize_ = 4; // BorderSize::BorderNormal
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// OxygenFactory() // OxygenFactory()
@ -101,6 +101,31 @@ bool OxygenFactory::reset(unsigned long changed)
resetDecorations(changed); resetDecorations(changed);
return false; 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") else if (value == "Right")
titleAlignment_ = Qt::AlignRight; titleAlignment_ = Qt::AlignRight;
bool oldborders = thinBorders_; int oldBorderSize = borderSize_;
thinBorders_ = group.readEntry( "ThinBorders", true ); 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_; bool oldstripes = showStripes_;
showStripes_ = group.readEntry( "ShowStripes", true ); showStripes_ = group.readEntry( "ShowStripes", true );
if (oldalign == titleAlignment_ && oldstripes == showStripes_ if (oldalign == titleAlignment_ && oldstripes == showStripes_
&& oldborders == thinBorders_) && oldBorderSize == borderSize_)
return false; return false;
else else
return true; 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 // Shadows

View file

@ -35,9 +35,6 @@ namespace Oxygen
static const int OXYGEN_BUTTONSIZE = 22; static const int OXYGEN_BUTTONSIZE = 22;
#define TFRAMESIZE 3 #define TFRAMESIZE 3
#define BFRAMESIZE 5
#define LFRAMESIZE 5
#define RFRAMESIZE 5
enum ButtonType { enum ButtonType {
ButtonHelp=0, ButtonHelp=0,
@ -61,6 +58,7 @@ public:
virtual KDecoration *createDecoration(KDecorationBridge *b); virtual KDecoration *createDecoration(KDecorationBridge *b);
virtual bool reset(unsigned long changed); virtual bool reset(unsigned long changed);
virtual bool supports( Ability ability ) const; virtual bool supports( Ability ability ) const;
QList< BorderSize > borderSizes() const;
virtual QList< QList<QImage> > shadowTextures(); virtual QList< QList<QImage> > shadowTextures();
virtual int shadowTextureList( ShadowType type ) const; virtual int shadowTextureList( ShadowType type ) const;
@ -70,7 +68,7 @@ public:
static bool initialized(); static bool initialized();
static Qt::Alignment titleAlignment(); static Qt::Alignment titleAlignment();
static bool showStripes(); static bool showStripes();
static bool thinBorders(); static int borderSize();
private: private:
bool readConfig(); bool readConfig();
@ -79,7 +77,7 @@ private:
static bool initialized_; static bool initialized_;
static Qt::Alignment titleAlignment_; static Qt::Alignment titleAlignment_;
static bool showStripes_; static bool showStripes_;
static bool thinBorders_; static int borderSize_;
}; };
inline bool OxygenFactory::initialized() inline bool OxygenFactory::initialized()
@ -91,8 +89,8 @@ inline Qt::Alignment OxygenFactory::titleAlignment()
inline bool OxygenFactory::showStripes() inline bool OxygenFactory::showStripes()
{ return showStripes_; } { return showStripes_; }
inline bool OxygenFactory::thinBorders() inline int OxygenFactory::borderSize()
{ return thinBorders_; } { return borderSize_; }
} //namespace Oxygen } //namespace Oxygen

View file

@ -122,6 +122,7 @@ bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const
int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{ {
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows(); bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
int frameWidth = OxygenFactory::borderSize();
switch (lm) { switch (lm) {
case LM_BorderLeft: case LM_BorderLeft:
@ -131,15 +132,12 @@ int OxygenClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const K
if (respectWindowState && maximized) { if (respectWindowState && maximized) {
return 0; return 0;
} else { } else {
if (OxygenFactory::thinBorders()) // Even for thin borders (2px wide) we want to preserve
{ // the rounded corners having a minimum height of 7px
if (lm == LM_BorderBottom) { if (lm == LM_BorderBottom) {
return BFRAMESIZE + 2; return qMax(frameWidth, 7);
} else {
return 2;
}
} else { } else {
return BFRAMESIZE; return frameWidth;
} }
} }
} }