removed 'button type' option, as recommanded by many people, and because it will allow to use oxygen helper directly rather than rewriting it

svn path=/trunk/KDE/kdebase/workspace/; revision=1019609
This commit is contained in:
Hugo Pereira Da Costa 2009-09-04 01:50:20 +00:00
parent 32aeeb070c
commit e86a284b5c
9 changed files with 51 additions and 181 deletions

View file

@ -61,7 +61,6 @@ namespace Nitrogen
user_interface_ = new NitrogenConfigurationUI( parent ); user_interface_ = new NitrogenConfigurationUI( parent );
connect( user_interface_->titleAlignment, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) ); connect( user_interface_->titleAlignment, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( user_interface_->buttonSize, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) ); connect( user_interface_->buttonSize, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( user_interface_->buttonType, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( user_interface_->frameBorder, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) ); connect( user_interface_->frameBorder, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( user_interface_->blendColor, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) ); connect( user_interface_->blendColor, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( user_interface_->sizeGripMode, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) ); connect( user_interface_->sizeGripMode, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
@ -124,10 +123,6 @@ namespace Nitrogen
NitrogenConfig::BUTTON_SIZE, NitrogenConfig::BUTTON_SIZE,
NitrogenConfiguration::buttonSizeName( NitrogenConfiguration::buttonSize( user_interface_->buttonSize->currentText(), true ), false ) ); NitrogenConfiguration::buttonSizeName( NitrogenConfiguration::buttonSize( user_interface_->buttonSize->currentText(), true ), false ) );
configurationGroup.writeEntry(
NitrogenConfig::BUTTON_TYPE,
NitrogenConfiguration::buttonTypeName( NitrogenConfiguration::buttonType( user_interface_->buttonType->currentText(), true ), false ) );
configurationGroup.writeEntry( configurationGroup.writeEntry(
NitrogenConfig::BLEND_COLOR, NitrogenConfig::BLEND_COLOR,
NitrogenConfiguration::blendColorName( NitrogenConfiguration::blendColor( user_interface_->blendColor->currentText(), true ), false ) ); NitrogenConfiguration::blendColorName( NitrogenConfiguration::blendColor( user_interface_->blendColor->currentText(), true ), false ) );
@ -175,7 +170,6 @@ namespace Nitrogen
user_interface_->titleAlignment->setCurrentIndex( user_interface_->titleAlignment->findText( configuration.titleAlignmentName( true ) ) ); user_interface_->titleAlignment->setCurrentIndex( user_interface_->titleAlignment->findText( configuration.titleAlignmentName( true ) ) );
user_interface_->buttonSize->setCurrentIndex( user_interface_->buttonSize->findText( configuration.buttonSizeName( true ) ) ); user_interface_->buttonSize->setCurrentIndex( user_interface_->buttonSize->findText( configuration.buttonSizeName( true ) ) );
user_interface_->buttonType->setCurrentIndex( user_interface_->buttonType->findText( configuration.buttonTypeName( true ) ) );
user_interface_->blendColor->setCurrentIndex( user_interface_->blendColor->findText( configuration.blendColorName( true ) ) ); user_interface_->blendColor->setCurrentIndex( user_interface_->blendColor->findText( configuration.blendColorName( true ) ) );
user_interface_->frameBorder->setCurrentIndex( user_interface_->frameBorder->findText( configuration.frameBorderName( true ) ) ); user_interface_->frameBorder->setCurrentIndex( user_interface_->frameBorder->findText( configuration.frameBorderName( true ) ) );
user_interface_->sizeGripMode->setCurrentIndex( user_interface_->sizeGripMode->findText( configuration.sizeGripModeName( true ) ) ); user_interface_->sizeGripMode->setCurrentIndex( user_interface_->sizeGripMode->findText( configuration.sizeGripModeName( true ) ) );

View file

@ -44,7 +44,6 @@ namespace Nitrogen
QWidget( parent ), QWidget( parent ),
titleAlignment(0), titleAlignment(0),
buttonSize(0), buttonSize(0),
buttonType(0),
frameBorder(0), frameBorder(0),
blendColor(0), blendColor(0),
sizeGripMode(0), sizeGripMode(0),
@ -162,21 +161,9 @@ namespace Nitrogen
vboxLayout->addLayout( gridLayout ); vboxLayout->addLayout( gridLayout );
gridLayout->setColumnStretch(2, 1); gridLayout->setColumnStretch(2, 1);
// button type
QLabel* label;
gridLayout->addWidget( label = new QLabel( i18n("Button style:"), advancedWidget ), 0, 0, 1, 1 );
gridLayout->addWidget( buttonType = new QComboBox(advancedWidget), 0, 1, 1, 1 );
buttonType->setObjectName(QString::fromUtf8("buttonType"));
buttonType->insertItems(0, QStringList()
<< NitrogenConfiguration::buttonTypeName( NitrogenConfiguration::ButtonKde42, true )
<< NitrogenConfiguration::buttonTypeName( NitrogenConfiguration::ButtonKde43, true )
);
label->setAlignment( Qt::AlignRight|Qt::AlignVCenter );
label->setBuddy( buttonType );
// title bar blending // title bar blending
QLabel* label;
gridLayout->addWidget( label = new QLabel( i18n("Background style:" ), advancedWidget ), 1, 0, 1, 1 ); gridLayout->addWidget( label = new QLabel( i18n("Background style:" ), advancedWidget ), 1, 0, 1, 1 );
gridLayout->addWidget( blendColor = new QComboBox(advancedWidget), 1, 1, 1, 1 ); gridLayout->addWidget( blendColor = new QComboBox(advancedWidget), 1, 1, 1, 1 );
blendColor->setObjectName(QString::fromUtf8("blendColor")); blendColor->setObjectName(QString::fromUtf8("blendColor"));

View file

@ -56,9 +56,6 @@ namespace Nitrogen
//! button size //! button size
QComboBox* buttonSize; QComboBox* buttonSize;
//! button size
QComboBox* buttonType;
//! frame border //! frame border
QComboBox *frameBorder; QComboBox *frameBorder;

View file

@ -318,7 +318,7 @@ QLinearGradient NitrogenHelper::decoGradient(const QRect &r, const QColor &color
} }
//_______________________________________________________________________________________________________________ //_______________________________________________________________________________________________________________
QPixmap NitrogenHelper::windecoButton(const QColor &color, bool pressed, Nitrogen::NitrogenConfiguration::ButtonType type, int size) QPixmap NitrogenHelper::windecoButton(const QColor &color, bool pressed, int size)
{ {
quint64 key = (quint64(color.rgba()) << 32) | (size << 1) | pressed; quint64 key = (quint64(color.rgba()) << 32) | (size << 1) | pressed;
@ -334,73 +334,41 @@ QPixmap NitrogenHelper::windecoButton(const QColor &color, bool pressed, Nitroge
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);
double u = double(size)/22.0; double u = double(size)/22.0;
if( type == Nitrogen::NitrogenConfiguration::ButtonKde42 ) QColor light = calcLightColor(color);
QColor dark = calcDarkColor(color);
QColor shadow = calcShadowColor(color);
QRectF rect(0.0, 0.0, size, size);
QRectF buttonRect = rect.adjusted(2*u,2*u,-2*u,-2*u);
QLinearGradient fill(QPointF(0.0, 0.0*u), QPointF(0.0, 21.0*u));
fill.setColorAt(0.0, alphaColor(light, 0.7));
fill.setColorAt(1.0, alphaColor(dark, 0.7));
p.setBrush(fill);
p.drawEllipse(buttonRect);
p.setBrush(Qt::NoBrush);
// shadow
if (pressed)
{ {
QColor light = calcLightColor(color); p.setPen(alphaColor(dark, 0.4));
QColor dark = alphaColor(calcShadowColor(color), 0.6); p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(1.7,1.7,-1.7,-1.7));
p.setPen(alphaColor(dark, 0.8));
QRectF rect(0.0, 0.0, size, size); p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(1.2,1.2,-1.2,-1.2));
QRectF buttonRect = rect.adjusted(3*u,3*u,-3*u,-3*u);
p.setBrush(color);
p.drawEllipse(buttonRect);
p.setBrush(Qt::NoBrush);
QLinearGradient darkgr(QPointF(1.0*u, 0.0), QPointF(20.0*u, 0.0));
darkgr.setColorAt(0.0, Qt::transparent);
darkgr.setColorAt(0.5, dark);
darkgr.setColorAt(1.0, Qt::transparent);
QLinearGradient lightgr(QPointF(1.0*u, 0.0), QPointF(20.0*u, 0.0));
lightgr.setColorAt(0.0, Qt::transparent);
lightgr.setColorAt(0.5, light);
lightgr.setColorAt(1.0, Qt::transparent);
p.setPen(QPen(darkgr, 1.5*u));
p.drawEllipse(buttonRect);
p.setPen(QPen(lightgr, 1.5*u));
if (!pressed) p.drawEllipse(buttonRect.adjusted(0.0, 1.0, 0.0, 1.0));
else p.drawEllipse(buttonRect.adjusted(1.0, 1.5, -1.0, 1.0));
} else {
QColor light = calcLightColor(color);
QColor dark = calcDarkColor(color);
QColor shadow = calcShadowColor(color);
QRectF rect(0.0, 0.0, size, size);
QRectF buttonRect = rect.adjusted(2*u,2*u,-2*u,-2*u);
QLinearGradient fill(QPointF(0.0, 0.0*u), QPointF(0.0, 21.0*u));
fill.setColorAt(0.0, alphaColor(light, 0.7));
fill.setColorAt(1.0, alphaColor(dark, 0.7));
p.setBrush(fill);
p.drawEllipse(buttonRect);
p.setBrush(Qt::NoBrush);
// shadow
if (pressed)
{
p.setPen(alphaColor(dark, 0.4));
p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(1.7,1.7,-1.7,-1.7));
p.setPen(alphaColor(dark, 0.8));
p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(1.2,1.2,-1.2,-1.2));
}
p.setPen(QPen(KColorUtils::mix(dark, shadow, 0.12), 2.0));
p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(0,0.1,0,-0.1));
p.setPen(QPen(KColorUtils::mix(dark, shadow, 0.6), 1.2));
p.drawEllipse(buttonRect.adjusted(1.0, 1.4, -0.8, -0.8));
// reflection
QLinearGradient lightgr(QPointF(0.0, 0.0*u), QPointF(0.0, 21.0*u));
lightgr.setColorAt(0.0, Qt::transparent);
lightgr.setColorAt(1.0, light);
p.setPen(QPen(lightgr, 1.7));
p.drawEllipse(buttonRect.adjusted(0.0, -0.5, -0.1, 0.0));
} }
p.setPen(QPen(KColorUtils::mix(dark, shadow, 0.12), 2.0));
p.drawEllipse(buttonRect.adjusted(0.9, 0.6, -0.7, -0.7).adjusted(0,0.1,0,-0.1));
p.setPen(QPen(KColorUtils::mix(dark, shadow, 0.6), 1.2));
p.drawEllipse(buttonRect.adjusted(1.0, 1.4, -0.8, -0.8));
// reflection
QLinearGradient lightgr(QPointF(0.0, 0.0*u), QPointF(0.0, 21.0*u));
lightgr.setColorAt(0.0, Qt::transparent);
lightgr.setColorAt(1.0, light);
p.setPen(QPen(lightgr, 1.7));
p.drawEllipse(buttonRect.adjusted(0.0, -0.5, -0.1, 0.0));
m_windecoButtonCache.insert(key, pixmap); m_windecoButtonCache.insert(key, pixmap);
} }

View file

@ -32,7 +32,6 @@
#include <QtGui/QLinearGradient> #include <QtGui/QLinearGradient>
#include <QtCore/QCache> #include <QtCore/QCache>
#include "../nitrogenconfiguration.h"
#define _glowBias 0.9 // not likely to be configurable #define _glowBias 0.9 // not likely to be configurable
@ -87,7 +86,7 @@ class NitrogenHelper
//@} //@}
//! buttons //! buttons
QPixmap windecoButton(const QColor &color, bool pressed, Nitrogen::NitrogenConfiguration::ButtonType type, int size = 21); QPixmap windecoButton(const QColor &color, bool pressed, int size = 21);
QPixmap windecoButtonGlow(const QColor &color, int size = 21); QPixmap windecoButtonGlow(const QColor &color, int size = 21);
//! frame //! frame

View file

@ -191,7 +191,7 @@ namespace Nitrogen
client_.options()->color(KDecorationDefines::ColorTitleBar, client_.isActive()); client_.options()->color(KDecorationDefines::ColorTitleBar, client_.isActive());
// draw button shape // draw button shape
painter.drawPixmap(0, 0, helper_.windecoButton(bt, status_ == Nitrogen::Pressed, client_.configuration().buttonType(), (21.0*client_.configuration().buttonSize())/22 ) ); painter.drawPixmap(0, 0, helper_.windecoButton(bt, status_ == Nitrogen::Pressed, (21.0*client_.configuration().buttonSize())/22 ) );
// draw glow on hover // draw glow on hover
if( status_ == Nitrogen::Hovered ) if( status_ == Nitrogen::Hovered )
@ -203,19 +203,10 @@ namespace Nitrogen
QLinearGradient lg = helper_.decoGradient( QRect( 4, 4, 13, 13 ), color); QLinearGradient lg = helper_.decoGradient( QRect( 4, 4, 13, 13 ), color);
painter.setRenderHints(QPainter::Antialiasing); painter.setRenderHints(QPainter::Antialiasing);
qreal width( client_.configuration().buttonType() == NitrogenConfiguration::ButtonKde43 ? 1.4:2.2 ); qreal width( 1.4 );
painter.setBrush(Qt::NoBrush); painter.setBrush(Qt::NoBrush);
if( client_.configuration().buttonType() == NitrogenConfiguration::ButtonKde42 ) painter.setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
{
painter.setPen(QPen(lg, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
} else {
painter.setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
}
drawIcon(&painter, palette, type_); drawIcon(&painter, palette, type_);
} else { } else {

View file

@ -149,25 +149,20 @@ namespace Nitrogen
int border( 0 ); int border( 0 );
if (respectWindowState && maximized) { if (respectWindowState && maximized) {
border = 0; border = 0;
} else if( configuration().frameBorder() == 0 && isPreview() && !compositingActive() ) { } else if( configuration().frameBorder() == NitrogenConfiguration::BorderNone && isPreview() && !compositingActive() ) {
border = 1; border = 1;
} else { } else if( lm == LM_BorderBottom && frameBorder >= NitrogenConfiguration::BorderTiny ) {
if( lm == LM_BorderBottom && frameBorder >= NitrogenConfiguration::BorderTiny )
{
// for tiny border, the convention is to have a larger bottom area in order to // for tiny border, the convention is to have a larger bottom area in order to
// make resizing easier // make resizing easier
border = qMax(frameBorder, 4); border = qMax(frameBorder, 4);
} else { } else {
border = frameBorder; border = frameBorder;
}
} }
return border + extraBorder; return border + extraBorder;
} }
@ -574,7 +569,7 @@ namespace Nitrogen
// useOxygenShadow is set to true, // useOxygenShadow is set to true,
// and copositing is active // and copositing is active
// (that makes a lot of ifs) // (that makes a lot of ifs)
if( isPreview() && configuration().frameBorder() == 0 && !compositingActive() ) if( isPreview() && configuration().frameBorder() == NitrogenConfiguration::BorderNone && !compositingActive() )
{ {
painter.save(); painter.save();
painter.setBrush( Qt::NoBrush ); painter.setBrush( Qt::NoBrush );
@ -689,9 +684,7 @@ namespace Nitrogen
} }
// Draw the 3-dots resize handles // Draw the 3-dots resize handles
if( if( isResizable() && !configuration().drawSizeGrip() )
isResizable() &&
!configuration().drawSizeGrip() )
{ {
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);

View file

@ -38,7 +38,6 @@ namespace Nitrogen
NitrogenConfiguration::NitrogenConfiguration( void ): NitrogenConfiguration::NitrogenConfiguration( void ):
titleAlignment_( Qt::AlignLeft ), titleAlignment_( Qt::AlignLeft ),
buttonSize_( ButtonDefault ), buttonSize_( ButtonDefault ),
buttonType_( ButtonKde43 ),
frameBorder_( BorderDefault ), frameBorder_( BorderDefault ),
blendColor_( RadialBlending ), blendColor_( RadialBlending ),
sizeGripMode_( SizeGripWhenNeeded ), sizeGripMode_( SizeGripWhenNeeded ),
@ -65,11 +64,6 @@ namespace Nitrogen
group.readEntry( NitrogenConfig::BUTTON_SIZE, group.readEntry( NitrogenConfig::BUTTON_SIZE,
defaultConfiguration.buttonSizeName( false ) ), false ) ); defaultConfiguration.buttonSizeName( false ) ), false ) );
// button type
setButtonType( buttonType(
group.readEntry( NitrogenConfig::BUTTON_TYPE,
defaultConfiguration.buttonTypeName( false ) ), false ) );
// frame border // frame border
setFrameBorder( frameBorder( setFrameBorder( frameBorder(
group.readEntry( NitrogenConfig::FRAME_BORDER, group.readEntry( NitrogenConfig::FRAME_BORDER,
@ -112,7 +106,6 @@ namespace Nitrogen
group.writeEntry( NitrogenConfig::TITLE_ALIGNMENT, titleAlignmentName( false ) ); group.writeEntry( NitrogenConfig::TITLE_ALIGNMENT, titleAlignmentName( false ) );
group.writeEntry( NitrogenConfig::BUTTON_SIZE, buttonSizeName( false ) ); group.writeEntry( NitrogenConfig::BUTTON_SIZE, buttonSizeName( false ) );
group.writeEntry( NitrogenConfig::BUTTON_TYPE, buttonTypeName( false ) );
group.writeEntry( NitrogenConfig::BLEND_COLOR, blendColorName( false ) ); group.writeEntry( NitrogenConfig::BLEND_COLOR, blendColorName( false ) );
group.writeEntry( NitrogenConfig::FRAME_BORDER, frameBorderName( false ) ); group.writeEntry( NitrogenConfig::FRAME_BORDER, frameBorderName( false ) );
group.writeEntry( NitrogenConfig::SIZE_GRIP_MODE, sizeGripModeName( false ) ); group.writeEntry( NitrogenConfig::SIZE_GRIP_MODE, sizeGripModeName( false ) );
@ -190,29 +183,6 @@ namespace Nitrogen
} }
//__________________________________________________
QString NitrogenConfiguration::buttonTypeName( ButtonType value, bool translated )
{
const char* out;
switch( value )
{
case ButtonKde42: out = "Flush"; break;
case ButtonKde43: out = "Sunken"; break;
default: return NitrogenConfiguration().buttonTypeName( translated );
}
return translated ? i18n(out):out;
}
//__________________________________________________
NitrogenConfiguration::ButtonType NitrogenConfiguration::buttonType( QString value, bool translated )
{
if( value == buttonTypeName( ButtonKde42, translated ) ) return ButtonKde42;
else if( value == buttonTypeName( ButtonKde43, translated ) ) return ButtonKde43;
else return NitrogenConfiguration().buttonType();
}
//__________________________________________________ //__________________________________________________
QString NitrogenConfiguration::frameBorderName( FrameBorder value, bool translated ) QString NitrogenConfiguration::frameBorderName( FrameBorder value, bool translated )
{ {
@ -303,7 +273,6 @@ namespace Nitrogen
return return
titleAlignment() == other.titleAlignment() && titleAlignment() == other.titleAlignment() &&
buttonSize() == other.buttonSize() && buttonSize() == other.buttonSize() &&
buttonType() == other.buttonType() &&
frameBorder() == other.frameBorder() && frameBorder() == other.frameBorder() &&
blendColor() == other.blendColor() && blendColor() == other.blendColor() &&
sizeGripMode() == other.sizeGripMode() && sizeGripMode() == other.sizeGripMode() &&

View file

@ -33,7 +33,6 @@ namespace NitrogenConfig
static const QString TITLE_ALIGNMENT = "TitleAlignment"; static const QString TITLE_ALIGNMENT = "TitleAlignment";
static const QString BUTTON_SIZE = "ButtonSize"; static const QString BUTTON_SIZE = "ButtonSize";
static const QString BUTTON_TYPE = "ButtonType";
static const QString SHOW_STRIPES = "ShowStripes"; static const QString SHOW_STRIPES = "ShowStripes";
static const QString DRAW_SEPARATOR = "DrawSeparator"; static const QString DRAW_SEPARATOR = "DrawSeparator";
static const QString OVERWRITE_COLORS = "OverwriteColors"; static const QString OVERWRITE_COLORS = "OverwriteColors";
@ -52,13 +51,6 @@ namespace Nitrogen
public: public:
//! button type
enum ButtonType
{
ButtonKde42,
ButtonKde43
};
//! button size enumeration //! button size enumeration
enum ButtonSize enum ButtonSize
{ {
@ -151,24 +143,7 @@ namespace Nitrogen
{ buttonSize_ = value; } { buttonSize_ = value; }
//@} //@}
//!@name button size
//@{
static QString buttonTypeName( ButtonType, bool translated );
static ButtonType buttonType( QString, bool translated );
virtual ButtonType buttonType( void ) const
{ return buttonType_; }
virtual QString buttonTypeName( bool translated ) const
{ return buttonTypeName( buttonType(), translated ); }
virtual void setButtonType( ButtonType value )
{ buttonType_ = value; }
//@}
//!@name frame border //!@name frame border
//@{ //@{
@ -277,9 +252,6 @@ namespace Nitrogen
//! button size //! button size
ButtonSize buttonSize_; ButtonSize buttonSize_;
//! button type
ButtonType buttonType_;
//! blend color //! blend color
FrameBorder frameBorder_; FrameBorder frameBorder_;