Sync r869205 from oxygen.

svn path=/trunk/KDE/kdebase/workspace/; revision=872700
This commit is contained in:
Luboš Luňák 2008-10-17 21:10:04 +00:00
parent ef10f9572a
commit 8f3441c7e2
5 changed files with 93 additions and 37 deletions

View file

@ -43,24 +43,27 @@ namespace Ozone {
namespace Oxygen {
OxygenConfig::OxygenConfig( KConfig*, QWidget* parent )
: QObject( parent )
: QObject( parent )
{
KGlobal::locale()->insertCatalog("kwin_clients");
c = new KConfig( "oxygenrc" );
KConfigGroup cg(c, "Windeco");
ui = new OxygenConfigUI( parent );
connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->blendTitlebarColors, SIGNAL(clicked()), SIGNAL(changed()) );
KGlobal::locale()->insertCatalog("kwin_clients");
c = new KConfig( "oxygenrc" );
KConfigGroup cg(c, "Windeco");
ui = new OxygenConfigUI( parent );
connect( ui->showStripes, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->blendTitlebarColors, 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()) );
load( cg );
ui->show();
load( cg );
ui->show();
}
OxygenConfig::~OxygenConfig()
{
delete ui;
delete c;
delete ui;
delete c;
}
@ -68,29 +71,46 @@ OxygenConfig::~OxygenConfig()
// It is passed the open config from kwindecoration to improve efficiency
void OxygenConfig::load( const KConfigGroup& )
{
KConfigGroup cg(c, "Windeco");
ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) );
ui->blendTitlebarColors->setChecked( cg.readEntry("BlendTitlebarColors", true) );
KConfigGroup cg(c, "Windeco");
ui->showStripes->setChecked( cg.readEntry("ShowStripes", true) );
ui->blendTitlebarColors->setChecked( cg.readEntry("BlendTitlebarColors", true) );
QString titleAlignment = cg.readEntry("TitleAlignment", "Left");
ui->titleAlignmentLeft->setChecked( titleAlignment == "Left" );
ui->titleAlignmentCenter->setChecked( titleAlignment == "Center" );
ui->titleAlignmentRight->setChecked( titleAlignment == "Right" );
}
// Saves the configurable options to the kwinrc config file
void OxygenConfig::save( KConfigGroup& )
{
KConfigGroup cg(c, "Windeco");
cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
cg.writeEntry( "BlendTitlebarColors", ui->blendTitlebarColors->isChecked() );
c->sync();
KConfigGroup cg(c, "Windeco");
cg.writeEntry( "ShowStripes", ui->showStripes->isChecked() );
cg.writeEntry( "BlendTitlebarColors", ui->blendTitlebarColors->isChecked() );
QString titleAlignment = "Left";
if (ui->titleAlignmentCenter->isChecked())
{
titleAlignment = "Center";
}
else if (ui->titleAlignmentRight->isChecked())
{
titleAlignment = "Right";
}
cg.writeEntry( "TitleAlignment", titleAlignment);
c->sync();
}
// Sets UI widget defaults which must correspond to style defaults
void OxygenConfig::defaults()
{
ui->showStripes->setChecked( true );
ui->blendTitlebarColors->setChecked( true );
emit changed();
ui->showStripes->setChecked( true );
ui->titleAlignmentLeft->setChecked( true );
ui->blendTitlebarColors->setChecked( true );
emit changed();
}
} //namespace Oxygen

View file

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>33</height>
<width>364</width>
<height>234</height>
</rect>
</property>
<property name="windowTitle" >
@ -16,6 +16,39 @@
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Title &amp;Alignment</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QRadioButton" name="titleAlignmentLeft" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>&amp;Left</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="titleAlignmentCenter" >
<property name="text" >
<string>Center</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="titleAlignmentRight" >
<property name="text" >
<string>&amp;Right</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="blendTitlebarColors" >
<property name="whatsThis" >

View file

@ -46,7 +46,7 @@ namespace Oxygen
//////////////////////////////////////////////////////////////////////////////
bool OxygenFactory::initialized_ = false;
Qt::Alignment OxygenFactory::titlealign_ = Qt::AlignLeft;
Qt::Alignment OxygenFactory::titleAlignment_ = Qt::AlignLeft;
bool OxygenFactory::showStripes_ = true;
bool OxygenFactory::blendTitlebarColors_ = true;
@ -112,11 +112,14 @@ bool OxygenFactory::readConfig()
KConfigGroup group = config.group("Windeco");
// grab settings
Qt::Alignment oldalign = titlealign_;
QString value = group.readEntry("TitleAlignment", "AlignLeft");
if (value == "AlignLeft") titlealign_ = Qt::AlignLeft;
else if (value == "AlignHCenter") titlealign_ = Qt::AlignHCenter;
else if (value == "AlignRight") titlealign_ = Qt::AlignRight;
Qt::Alignment oldalign = titleAlignment_;
QString value = group.readEntry("TitleAlignment", "Left");
if (value == "Left")
titleAlignment_ = Qt::AlignLeft;
else if (value == "Center")
titleAlignment_ = Qt::AlignHCenter;
else if (value == "Right")
titleAlignment_ = Qt::AlignRight;
bool oldstripes = showStripes;
showStripes_ = group.readEntry( "ShowStripes", true );
@ -124,7 +127,7 @@ bool OxygenFactory::readConfig()
bool oldblend = blendTitlebarColors;
blendTitlebarColors_ = group.readEntry( "BlendTitlebarColors", true );
if (oldalign == titlealign_ && oldstripes == showStripes_ && oldblend == blendTitlebarColors_)
if (oldalign == titleAlignment_ && oldstripes == showStripes_ && oldblend == blendTitlebarColors_)
return false;
else
return true;

View file

@ -64,7 +64,7 @@ public:
virtual bool supports( Ability ability ) const;
static bool initialized();
static Qt::Alignment titleAlign();
static Qt::Alignment titleAlignment();
static bool showStripes();
static bool blendTitlebarColors();
@ -73,7 +73,7 @@ private:
private:
static bool initialized_;
static Qt::Alignment titlealign_;
static Qt::Alignment titleAlignment_;
static bool showStripes_;
static bool blendTitlebarColors_;
};
@ -81,8 +81,8 @@ private:
inline bool OxygenFactory::initialized()
{ return initialized_; }
inline Qt::Alignment OxygenFactory::titleAlign()
{ return titlealign_; }
inline Qt::Alignment OxygenFactory::titleAlignment()
{ return titleAlignment_; }
inline bool OxygenFactory::blendTitlebarColors()
{ return blendTitlebarColors_; }

View file

@ -303,7 +303,7 @@ void OxygenClient::paintEvent(QPaintEvent *e)
painter.setFont(options()->font(isActive(), false));
painter.setPen(titlebarTextColor(pal2));
painter.drawText(titleLeft, titleTop-1, titleWidth, titleHeight, // -1 is to go into top resizearea
OxygenFactory::titleAlign() | Qt::AlignVCenter, caption());
OxygenFactory::titleAlignment() | Qt::AlignVCenter, caption());
painter.setRenderHint(QPainter::Antialiasing);
@ -318,7 +318,7 @@ void OxygenClient::paintEvent(QPaintEvent *e)
// draw stripes as indicator for active windows
if (isActive() && OxygenFactory::showStripes()) {
Qt::Alignment align = OxygenFactory::titleAlign();
Qt::Alignment align = OxygenFactory::titleAlignment();
if (widget()->layoutDirection() == Qt::RightToLeft)
{
if (align == Qt::AlignLeft)