- use kcfg for shadow configuration

- move Shadow configuration UI to libs
- removed useDropShadow and useOxygenShadow options, and replaced by activeShadow::enable and inactiveShadow::enable
- use kcfg for decoration configuration. The handling of exceptions requires dedicated readConfig and writeConfig methods, implemented in oxygenutils
- changed sizegrip combobox into a check box and rephrased for clarification
icc-effect-5.14.5
Hugo Pereira Da Costa 2012-11-23 10:09:39 +01:00
parent dec63fb987
commit fcb275abe7
36 changed files with 1029 additions and 2128 deletions

View File

@ -11,15 +11,15 @@ set(kwin_oxygen_SRCS
oxygenbutton.cpp
oxygenclient.cpp
oxygenclientgroupitemdata.cpp
oxygenconfiguration.cpp
oxygendecohelper.cpp
oxygenexception.cpp
oxygenexceptionlist.cpp
oxygenfactory.cpp
oxygensizegrip.cpp
oxygentitleanimationdata.cpp
)
kde4_add_kcfg_files(kwin_oxygen_SRCS oxygenconfiguration.kcfgc )
kde4_add_plugin(kwin3_oxygen ${kwin_oxygen_SRCS})
target_link_libraries(
kwin3_oxygen

View File

@ -1,9 +1,6 @@
include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/oxygen)
set(kwin_oxygen_config_PART_SRCS
../oxygenconfiguration.cpp
../oxygenexception.cpp
../oxygenexceptionlist.cpp
oxygenanimationconfigwidget.cpp
oxygenconfig.cpp
oxygenconfigurationui.cpp
@ -11,7 +8,7 @@ set(kwin_oxygen_config_PART_SRCS
oxygenexceptiondialog.cpp
oxygenexceptionlistwidget.cpp
oxygenexceptionmodel.cpp
oxygenshadowconfigurationui.cpp
../oxygenexceptionlist.cpp
)
kde4_add_ui_files(kwin_oxygen_config_PART_SRCS
@ -19,9 +16,10 @@ kde4_add_ui_files(kwin_oxygen_config_PART_SRCS
ui/oxygendetectwidget.ui
ui/oxygenexceptiondialog.ui
ui/oxygenexceptionlistwidget.ui
ui/oxygenshadowconfigurationui.ui
)
kde4_add_kcfg_files(kwin_oxygen_config_PART_SRCS ../oxygenconfiguration.kcfgc )
kde4_add_plugin(kwin_oxygen_config ${kwin_oxygen_config_PART_SRCS})
target_link_libraries(

View File

@ -84,38 +84,38 @@ namespace Oxygen
void AnimationConfigWidget::load( void )
{
animationsEnabled()->setChecked( _configuration.animationsEnabled() );
animationsEnabled()->setChecked( _configuration->animationsEnabled() );
_buttonAnimations->setEnabled( _configuration.buttonAnimationsEnabled() );
_buttonAnimations->setDuration( _configuration.buttonAnimationsDuration() );
_buttonAnimations->setEnabled( _configuration->buttonAnimationsEnabled() );
_buttonAnimations->setDuration( _configuration->buttonAnimationsDuration() );
_titleAnimations->setEnabled( _configuration.titleAnimationsEnabled() );
_titleAnimations->setDuration( _configuration.titleAnimationsDuration() );
_titleAnimations->setEnabled( _configuration->titleAnimationsEnabled() );
_titleAnimations->setDuration( _configuration->titleAnimationsDuration() );
_shadowAnimations->setEnabled( _configuration.shadowAnimationsEnabled() );
_shadowAnimations->setDuration( _configuration.shadowAnimationsDuration() );
_shadowAnimations->setEnabled( _configuration->shadowAnimationsEnabled() );
_shadowAnimations->setDuration( _configuration->shadowAnimationsDuration() );
_tabAnimations->setEnabled( _configuration.tabAnimationsEnabled() );
_tabAnimations->setDuration( _configuration.tabAnimationsDuration() );
_tabAnimations->setEnabled( _configuration->tabAnimationsEnabled() );
_tabAnimations->setDuration( _configuration->tabAnimationsDuration() );
}
//_______________________________________________
void AnimationConfigWidget::save( void )
{
_configuration.setAnimationsEnabled( animationsEnabled()->isChecked() );
_configuration->setAnimationsEnabled( animationsEnabled()->isChecked() );
_configuration.setButtonAnimationsEnabled( _buttonAnimations->enabled() );
_configuration.setButtonAnimationsDuration( _buttonAnimations->duration() );
_configuration->setButtonAnimationsEnabled( _buttonAnimations->enabled() );
_configuration->setButtonAnimationsDuration( _buttonAnimations->duration() );
_configuration.setTitleAnimationsEnabled( _titleAnimations->enabled() );
_configuration.setTitleAnimationsDuration( _titleAnimations->duration() );
_configuration->setTitleAnimationsEnabled( _titleAnimations->enabled() );
_configuration->setTitleAnimationsDuration( _titleAnimations->duration() );
_configuration.setShadowAnimationsEnabled( _shadowAnimations->enabled() );
_configuration.setShadowAnimationsDuration( _shadowAnimations->duration() );
_configuration->setShadowAnimationsEnabled( _shadowAnimations->enabled() );
_configuration->setShadowAnimationsDuration( _shadowAnimations->duration() );
_configuration.setTabAnimationsEnabled( _tabAnimations->enabled() );
_configuration.setTabAnimationsDuration( _tabAnimations->duration() );
_configuration->setTabAnimationsEnabled( _tabAnimations->enabled() );
_configuration->setTabAnimationsDuration( _tabAnimations->duration() );
setChanged( false );
@ -127,18 +127,18 @@ namespace Oxygen
bool modified( false );
if( animationsEnabled()->isChecked() != _configuration.animationsEnabled() ) modified = true;
else if( _buttonAnimations->enabled() != _configuration.buttonAnimationsEnabled() ) modified = true;
else if( _buttonAnimations->duration() != _configuration.buttonAnimationsDuration() ) modified = true;
if( animationsEnabled()->isChecked() != _configuration->animationsEnabled() ) modified = true;
else if( _buttonAnimations->enabled() != _configuration->buttonAnimationsEnabled() ) modified = true;
else if( _buttonAnimations->duration() != _configuration->buttonAnimationsDuration() ) modified = true;
else if( _titleAnimations->enabled() != _configuration.titleAnimationsEnabled() ) modified = true;
else if( _titleAnimations->duration() != _configuration.titleAnimationsDuration() ) modified = true;
else if( _titleAnimations->enabled() != _configuration->titleAnimationsEnabled() ) modified = true;
else if( _titleAnimations->duration() != _configuration->titleAnimationsDuration() ) modified = true;
else if( _shadowAnimations->enabled() != _configuration.shadowAnimationsEnabled() ) modified = true;
else if( _shadowAnimations->duration() != _configuration.shadowAnimationsDuration() ) modified = true;
else if( _shadowAnimations->enabled() != _configuration->shadowAnimationsEnabled() ) modified = true;
else if( _shadowAnimations->duration() != _configuration->shadowAnimationsDuration() ) modified = true;
else if( _tabAnimations->enabled() != _configuration.tabAnimationsEnabled() ) modified = true;
else if( _tabAnimations->duration() != _configuration.tabAnimationsDuration() ) modified = true;
else if( _tabAnimations->enabled() != _configuration->tabAnimationsEnabled() ) modified = true;
else if( _tabAnimations->duration() != _configuration->tabAnimationsDuration() ) modified = true;
setChanged( modified );

View File

@ -27,8 +27,8 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "../oxygendecorationdefines.h"
#include "oxygenbaseanimationconfigwidget.h"
#include "../oxygenconfiguration.h"
namespace Oxygen
{
@ -51,13 +51,9 @@ namespace Oxygen
virtual ~AnimationConfigWidget( void );
//! configuration
void setConfiguration( const Configuration& configuration )
void setConfiguration( ConfigurationPtr configuration )
{ _configuration = configuration; }
//! configuration
const Configuration& configuration( void ) const
{ return _configuration; }
public slots:
//! read current configuration
@ -74,7 +70,7 @@ namespace Oxygen
private:
//! local configuration, needed to handle I/O
Configuration _configuration;
ConfigurationPtr _configuration;
//!@name animations
//@{

View File

@ -31,8 +31,9 @@
#include "oxygenconfig.moc"
#include "oxygenanimationconfigwidget.h"
#include "oxygenshadowconfiguration.h"
#include "../oxygenconfiguration.h"
#include "oxygenconfiguration.h"
#include "oxygenutil.h"
#include "../oxygenexceptionlist.h"
#include <QtCore/QTextStream>
#include <QtDBus/QDBusConnection>
@ -88,18 +89,18 @@ namespace Oxygen
{
// load standard configuration
loadConfiguration( Configuration( KConfigGroup( _configuration, "Windeco") ) );
loadShadowConfiguration( QPalette::Active, ShadowConfiguration( QPalette::Active, KConfigGroup( _configuration, "ActiveShadow") ) );
loadShadowConfiguration( QPalette::Inactive, ShadowConfiguration( QPalette::Inactive, KConfigGroup( _configuration, "InactiveShadow") ) );
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
loadConfiguration( configuration );
// load shadows
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
{ ui->readConfig( _configuration ); }
// load exceptions
ExceptionList exceptions;
exceptions.read( *_configuration );
if( exceptions.empty() )
{ exceptions = ExceptionList::defaultList(); }
// install in ui
ui->ui.exceptions->setExceptions( exceptions );
exceptions.readConfig( *_configuration );
ui->ui.exceptions->setExceptions( exceptions.get() );
updateChanged();
}
@ -108,30 +109,28 @@ namespace Oxygen
void Config::updateChanged( void )
{
Configuration configuration( KConfigGroup( _configuration, "Windeco") );
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
bool modified( false );
if( ui->ui.titleAlignment->currentIndex() != ui->ui.titleAlignment->findText( configuration.titleAlignmentName( true ) ) ) modified = true;
else if( ui->ui.buttonSize->currentIndex() != ui->ui.buttonSize->findText( configuration.buttonSizeName( true ) ) ) modified = true;
else if( ui->ui.blendColor->currentIndex() != ui->ui.blendColor->findText( configuration.blendColorName( true ) ) ) modified = true;
else if( ui->ui.frameBorder->currentIndex() != ui->ui.frameBorder->findText( configuration.frameBorderName( true ) ) ) modified = true;
else if( ui->ui.sizeGripMode->currentIndex() != ui->ui.sizeGripMode->findText( configuration.sizeGripModeName( true ) ) ) modified = true;
else if( ui->ui.separatorMode->currentIndex() != configuration.separatorMode() ) modified = true;
else if( ui->ui.titleOutline->isChecked() != configuration.drawTitleOutline() ) modified = true;
else if( ui->ui.narrowButtonSpacing->isChecked() != configuration.useNarrowButtonSpacing() ) modified = true;
if( ui->ui.titleAlignment->currentIndex() != configuration->titleAlignment() ) modified = true;
else if( ui->ui.buttonSize->currentIndex() != configuration->buttonSize() ) modified = true;
else if( ui->ui.blendColor->currentIndex() != configuration->blendStyle() ) modified = true;
else if( ui->ui.frameBorder->currentIndex() != configuration->frameBorder() ) modified = true;
else if( ui->ui.separatorMode->currentIndex() != configuration->separatorMode() ) modified = true;
else if( ui->ui.drawSizeGrip->isChecked() != configuration->drawSizeGrip() ) modified = true;
else if( ui->ui.titleOutline->isChecked() != configuration->drawTitleOutline() ) modified = true;
else if( ui->ui.narrowButtonSpacing->isChecked() != configuration->useNarrowButtonSpacing() ) modified = true;
// shadow configurations
else if( ui->shadowConfigurations[0]->isChecked() != configuration.useOxygenShadows() ) modified = true;
else if( ui->shadowConfigurations[1]->isChecked() != configuration.useDropShadows() ) modified = true;
else if( shadowConfigurationChanged( ShadowConfiguration( QPalette::Active, KConfigGroup( _configuration, "ActiveShadow") ), *ui->shadowConfigurations[0] ) ) modified = true;
else if( shadowConfigurationChanged( ShadowConfiguration( QPalette::Inactive, KConfigGroup( _configuration, "InactiveShadow") ), *ui->shadowConfigurations[1] ) ) modified = true;
else if( ui->shadowConfigurations[0]->isModified() ) modified = true;
else if( ui->shadowConfigurations[1]->isModified() ) modified = true;
// exceptions
else if( exceptionListChanged() ) modified = true;
// animations
else if( !ui->expertMode() && ui->ui.animationsEnabled->isChecked() != configuration.animationsEnabled() ) modified = true;
else if( !ui->expertMode() && ui->ui.animationsEnabled->isChecked() != configuration->animationsEnabled() ) modified = true;
else if( ui->expertMode() && ui->animationConfigWidget()->isChanged() ) modified = true;
// emit relevant signals
@ -145,46 +144,42 @@ namespace Oxygen
{
// create configuration from group
KConfigGroup configurationGroup( _configuration, "Windeco" );
Configuration configuration( configurationGroup );
ConfigurationPtr configuration( new Configuration() );
configuration->readConfig();
// apply modifications from ui
configuration.setTitleAlignment( Configuration::titleAlignment( ui->ui.titleAlignment->currentText(), true ) );
configuration.setCenterTitleOnFullWidth( ui->ui.titleAlignment->currentText() == Configuration::titleAlignmentName( Qt::AlignHCenter, true, true ) );
configuration.setButtonSize( Configuration::buttonSize( ui->ui.buttonSize->currentText(), true ) );
configuration.setBlendColor( Configuration::blendColor( ui->ui.blendColor->currentText(), true ) );
configuration.setFrameBorder( Configuration::frameBorder( ui->ui.frameBorder->currentText(), true ) );
configuration.setSizeGripMode( Configuration::sizeGripMode( ui->ui.sizeGripMode->currentText(), true ) );
configuration.setSeparatorMode( (Oxygen::Configuration::SeparatorMode) ui->ui.separatorMode->currentIndex() );
configuration.setDrawTitleOutline( ui->ui.titleOutline->isChecked() );
configuration.setUseDropShadows( ui->shadowConfigurations[1]->isChecked() );
configuration.setUseOxygenShadows( ui->shadowConfigurations[0]->isChecked() );
configuration.setUseNarrowButtonSpacing( ui->ui.narrowButtonSpacing->isChecked() );
configuration.setCloseFromMenuButton( ui->ui.closeFromMenuButton->isChecked() );
configuration->setTitleAlignment( ui->ui.titleAlignment->currentIndex() );
configuration->setButtonSize( ui->ui.buttonSize->currentIndex() );
configuration->setBlendStyle( ui->ui.blendColor->currentIndex() );
configuration->setFrameBorder( ui->ui.frameBorder->currentIndex() );
configuration->setSeparatorMode( ui->ui.separatorMode->currentIndex() );
configuration->setDrawSizeGrip( ui->ui.drawSizeGrip->isChecked() );
configuration->setDrawTitleOutline( ui->ui.titleOutline->isChecked() );
configuration->setUseNarrowButtonSpacing( ui->ui.narrowButtonSpacing->isChecked() );
configuration->setCloseWindowFromMenuButton( ui->ui.closeFromMenuButton->isChecked() );
if( ui->expertMode() )
{
ui->animationConfigWidget()->setConfiguration( configuration );
ui->animationConfigWidget()->save();
configuration = ui->animationConfigWidget()->configuration();
} else {
configuration.setAnimationsEnabled( ui->ui.animationsEnabled->isChecked() );
configuration->setAnimationsEnabled( ui->ui.animationsEnabled->isChecked() );
}
// save standard configuration
configurationGroup.deleteGroup();
configuration.write( configurationGroup );
Util::writeConfig( configuration.data(), _configuration );
// write exceptions
ui->ui.exceptions->exceptions().write( *_configuration );
// get list of exceptions and write
ConfigurationList exceptions( ui->ui.exceptions->exceptions() );
ExceptionList( exceptions ).writeConfig( *_configuration );
// write shadow configuration
saveShadowConfiguration( QPalette::Active, *ui->shadowConfigurations[0] );
saveShadowConfiguration( QPalette::Inactive, *ui->shadowConfigurations[1] );
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
{ ui->writeConfig( _configuration ); }
// sync configuration
_configuration->sync();
@ -194,105 +189,58 @@ namespace Oxygen
}
//_______________________________________________________________________
void Config::saveShadowConfiguration( QPalette::ColorGroup colorGroup, const ShadowConfigurationUi& ui ) const
{
assert( colorGroup == QPalette::Active || colorGroup == QPalette::Inactive );
// create shadow configuration
ShadowConfiguration configuration( colorGroup );
configuration.setShadowSize( ui.ui.shadowSize->value() );
configuration.setVerticalOffset( 0.1*ui.ui.verticalOffset->value() );
configuration.setInnerColor( ui.ui.innerColor->color() );
configuration.setOuterColor( ui.ui.outerColor->color() );
configuration.setUseOuterColor( ui.ui.useOuterColor->isChecked() );
// save shadow configuration
KConfigGroup configurationGroup( _configuration, ( (colorGroup == QPalette::Active) ? "ActiveShadow":"InactiveShadow" ) );
configurationGroup.deleteGroup();
configuration.write( configurationGroup );
}
//_______________________________________________________________________
void Config::defaults()
{
// install default configuration
loadConfiguration( Configuration() );
ConfigurationPtr configuration( new Configuration() );
configuration->setDefaults();
loadConfiguration( configuration );
// load shadows
loadShadowConfiguration( QPalette::Active, ShadowConfiguration( QPalette::Active ) );
loadShadowConfiguration( QPalette::Inactive, ShadowConfiguration( QPalette::Inactive ) );
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
{ ui->readDefaults( _configuration ); }
// install default exceptions
ui->ui.exceptions->setExceptions( ExceptionList::defaultList() );
// ui->ui.exceptions->setExceptions( ExceptionList::defaultList() );
updateChanged();
}
//_______________________________________________________________________
void Config::loadConfiguration( const Configuration& configuration )
void Config::loadConfiguration( ConfigurationPtr configuration )
{
ui->ui.titleAlignment->setCurrentIndex( ui->ui.titleAlignment->findText( configuration.titleAlignmentName( true ) ) );
ui->ui.buttonSize->setCurrentIndex( ui->ui.buttonSize->findText( configuration.buttonSizeName( true ) ) );
ui->ui.blendColor->setCurrentIndex( ui->ui.blendColor->findText( configuration.blendColorName( true ) ) );
ui->ui.frameBorder->setCurrentIndex( ui->ui.frameBorder->findText( configuration.frameBorderName( true ) ) );
ui->ui.sizeGripMode->setCurrentIndex( ui->ui.sizeGripMode->findText( configuration.sizeGripModeName( true ) ) );
ui->ui.separatorMode->setCurrentIndex( configuration.separatorMode() );
ui->ui.titleOutline->setChecked( configuration.drawTitleOutline() );
ui->shadowConfigurations[0]->setChecked( configuration.useOxygenShadows() );
ui->shadowConfigurations[1]->setChecked( configuration.useDropShadows() );
ui->ui.animationsEnabled->setChecked( configuration.animationsEnabled() );
ui->ui.narrowButtonSpacing->setChecked( configuration.useNarrowButtonSpacing() );
ui->ui.closeFromMenuButton->setChecked( configuration.closeFromMenuButton() );
ui->ui.titleAlignment->setCurrentIndex( configuration->titleAlignment() );
ui->ui.buttonSize->setCurrentIndex( configuration->buttonSize() );
ui->ui.blendColor->setCurrentIndex( configuration->blendStyle() );
ui->ui.frameBorder->setCurrentIndex( configuration->frameBorder() );
ui->ui.separatorMode->setCurrentIndex( configuration->separatorMode() );
ui->ui.drawSizeGrip->setChecked( configuration->drawSizeGrip() );
ui->ui.titleOutline->setChecked( configuration->drawTitleOutline() );
ui->ui.animationsEnabled->setChecked( configuration->animationsEnabled() );
ui->ui.narrowButtonSpacing->setChecked( configuration->useNarrowButtonSpacing() );
ui->ui.closeFromMenuButton->setChecked( configuration->closeWindowFromMenuButton() );
ui->animationConfigWidget()->setConfiguration( configuration );
ui->animationConfigWidget()->load();
}
//_______________________________________________________________________
void Config::loadShadowConfiguration( QPalette::ColorGroup colorGroup, const ShadowConfiguration& configuration )
{
assert( colorGroup == QPalette::Active || colorGroup == QPalette::Inactive );
ShadowConfigurationUi* ui = this->ui->shadowConfigurations[ (colorGroup == QPalette::Active) ? 0:1 ];
ui->ui.shadowSize->setValue( configuration.shadowSize() );
ui->ui.verticalOffset->setValue( 10*configuration.verticalOffset() );
ui->ui.innerColor->setColor( configuration.innerColor() );
ui->ui.outerColor->setColor( configuration.outerColor() );
ui->ui.useOuterColor->setChecked( configuration.useOuterColor() );
}
//_______________________________________________________________________
bool Config::shadowConfigurationChanged( const ShadowConfiguration& configuration, const ShadowConfigurationUi& ui ) const
{
bool modified( false );
if( ui.ui.shadowSize->value() != configuration.shadowSize() ) modified = true;
else if( 0.1*ui.ui.verticalOffset->value() != configuration.verticalOffset() ) modified = true;
else if( ui.ui.innerColor->color() != configuration.innerColor() ) modified = true;
else if( ui.ui.useOuterColor->isChecked() != configuration.useOuterColor() ) modified = true;
else if( ui.ui.useOuterColor->isChecked() && ui.ui.outerColor->color() != configuration.outerColor() ) modified = true;
return modified;
}
//_______________________________________________________________________
bool Config::exceptionListChanged( void ) const
{
// get saved list
ExceptionList exceptions;
exceptions.read( *_configuration );
if( exceptions.empty() )
{ exceptions = ExceptionList::defaultList(); }
// compare to current
return exceptions != ui->ui.exceptions->exceptions();
return true;
// // get saved list
// ExceptionList exceptions;
// exceptions.read( *_configuration );
// if( exceptions.empty() )
// { exceptions = ExceptionList::defaultList(); }
//
// // compare to current
// return exceptions != ui->ui.exceptions->exceptions();
}

View File

@ -30,15 +30,16 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenconfigurationui.h"
#include "oxygenconfiguration.h"
#include "../oxygendecorationdefines.h"
#include <KConfig>
#include <QtGui/QPalette>
#include "oxygenconfigurationui.h"
namespace Oxygen {
class Configuration;
class ShadowConfiguration;
// oxygen configuration object
class Config: public QObject
@ -84,16 +85,7 @@ namespace Oxygen {
private:
//! load configuration
void loadConfiguration( const Configuration& );
//! load configuration
void loadShadowConfiguration( QPalette::ColorGroup, const ShadowConfiguration& );
//! load configuration
void saveShadowConfiguration( QPalette::ColorGroup, const ShadowConfigurationUi& ) const;
//! returns true if shadow configuration changed
bool shadowConfigurationChanged( const ShadowConfiguration&, const ShadowConfigurationUi& ) const;
void loadConfiguration( ConfigurationPtr );
//! returns true if exception list is changed
bool exceptionListChanged( void ) const;

View File

@ -25,7 +25,6 @@
#include "oxygenconfigurationui.h"
#include "oxygenanimationconfigwidget.h"
#include "../oxygenconfiguration.h"
#include <kdeversion.h>
@ -47,49 +46,12 @@ namespace Oxygen
ui.setupUi( this );
// basic configuration
ui.frameBorder->insertItems(0, QStringList()
<< Configuration::frameBorderName( Configuration::BorderNone, true )
<< Configuration::frameBorderName( Configuration::BorderNoSide, true )
<< Configuration::frameBorderName( Configuration::BorderTiny, true )
<< Configuration::frameBorderName( Configuration::BorderDefault, true )
<< Configuration::frameBorderName( Configuration::BorderLarge, true )
<< Configuration::frameBorderName( Configuration::BorderVeryLarge, true )
<< Configuration::frameBorderName( Configuration::BorderHuge, true )
<< Configuration::frameBorderName( Configuration::BorderVeryHuge, true )
<< Configuration::frameBorderName( Configuration::BorderOversized, true )
);
// shadow configuration
ui.activeShadowConfiguration->setGroup( QPalette::Active );
ui.inactiveShadowConfiguration->setGroup( QPalette::Inactive );
ui.titleAlignment->insertItems(0, QStringList()
<< Configuration::titleAlignmentName( Qt::AlignLeft, true )
<< Configuration::titleAlignmentName( Qt::AlignHCenter, true, false )
<< Configuration::titleAlignmentName( Qt::AlignHCenter, true, true )
<< Configuration::titleAlignmentName( Qt::AlignRight, true )
);
ui.buttonSize->insertItems(0, QStringList()
<< Configuration::buttonSizeName( Configuration::ButtonSmall, true )
<< Configuration::buttonSizeName( Configuration::ButtonDefault, true )
<< Configuration::buttonSizeName( Configuration::ButtonLarge, true )
<< Configuration::buttonSizeName( Configuration::ButtonVeryLarge, true )
<< Configuration::buttonSizeName( Configuration::ButtonHuge, true )
);
// advanced configuration
ui.blendColor->insertItems(0, QStringList()
<< Configuration::blendColorName( Configuration::NoBlending, true )
<< Configuration::blendColorName( Configuration::RadialBlending, true )
<< Configuration::blendColorName( Configuration::BlendFromStyle, true )
);
// draw size grip
ui.sizeGripMode->insertItems(0, QStringList()
<< Configuration::sizeGripModeName( Configuration::SizeGripNever, true )
<< Configuration::sizeGripModeName( Configuration::SizeGripWhenNeeded, true )
);
shadowConfigurations.push_back( ui.activeShadowConfiguration );
shadowConfigurations.push_back( ui.inactiveShadowConfiguration );
shadowConfigurations.append( ui.activeShadowConfiguration );
shadowConfigurations.append( ui.inactiveShadowConfiguration );
// connections
connect( ui.titleOutline, SIGNAL(toggled(bool)), ui.separatorMode, SLOT(setDisabled(bool)) );
@ -104,11 +66,11 @@ namespace Oxygen
connect( ui.buttonSize, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( ui.frameBorder, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( ui.blendColor, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( ui.sizeGripMode, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( ui.titleOutline, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui.drawSizeGrip, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui.narrowButtonSpacing, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui.separatorMode, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
connect( ui.titleOutline, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui.exceptions, SIGNAL(changed()), SIGNAL(changed()) );
connect( ui._expertModeButton, SIGNAL(pressed()), SLOT(toggleExpertModeInternal()) );
@ -146,9 +108,8 @@ namespace Oxygen
// narrow button spacing
ui.narrowButtonSpacing->setVisible( _expertMode );
// size grip mode
ui.sizeGripModeLabel->setVisible( _expertMode );
ui.sizeGripMode->setVisible( _expertMode );
// size grip
ui.drawSizeGrip->setVisible( _expertMode );
// 'basic' animations enabled flag
ui.animationsEnabled->setVisible( !_expertMode );

View File

@ -25,16 +25,15 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <kdeversion.h>
#include "ui_oxygenconfigurationui.h"
#include "oxygenshadowconfigurationui.h"
#include "oxygenexceptionlistwidget.h"
#include <KComboBox>
#include <QtGui/QWidget>
#include <QtGui/QCheckBox>
#include <QtCore/QVector>
#include "ui_oxygenconfigurationui.h"
#include "oxygenshadowconfigurationui.h"
#include "oxygenexceptionlistwidget.h"
namespace Oxygen
{

View File

@ -30,7 +30,9 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <map>
#include "oxygenconfiguration.h"
#include "ui_oxygendetectwidget.h"
#include <KDialog>
#include <QtCore/QEvent>
#include <QtCore/QByteArray>
@ -39,9 +41,6 @@
#include <kwindowsystem.h>
#include "../oxygenexception.h"
#include "ui_oxygendetectwidget.h"
namespace Oxygen
{
@ -66,11 +65,11 @@ namespace Oxygen
{ return _info; }
//! exception type
Exception::Type exceptionType() const
Configuration::EnumExceptionType exceptionType() const
{
if( ui.windowClassCheckBox->isChecked() ) return Exception::WindowClassName;
else if( ui.windowTitleCheckBox->isChecked() ) return Exception::WindowTitle;
else return Exception::WindowClassName;
if( ui.windowClassCheckBox->isChecked() ) return Configuration::ExceptionWindowClassName;
else if( ui.windowTitleCheckBox->isChecked() ) return Configuration::ExceptionWindowTitle;
else return Configuration::ExceptionWindowClassName;
}
signals:

View File

@ -27,9 +27,6 @@
#include "oxygenexceptiondialog.moc"
#include "oxygendetectwidget.h"
#include <cassert>
namespace Oxygen
{
@ -45,114 +42,79 @@ namespace Oxygen
ui.setupUi( local );
setMainWidget( local );
// exception type
ui.exceptionType->insertItems( 0, QStringList()
<< Exception::typeName( Exception::WindowClassName, true )
<< Exception::typeName( Exception::WindowTitle, true )
);
connect( ui.detectDialogButton, SIGNAL(clicked()), SLOT(selectWindowProperties()) );
// border size
ui.frameBorderComboBox->insertItems(0, QStringList()
<< Configuration::frameBorderName( Configuration::BorderNone, true )
<< Configuration::frameBorderName( Configuration::BorderNoSide, true )
<< Configuration::frameBorderName( Configuration::BorderTiny, true )
<< Configuration::frameBorderName( Configuration::BorderDefault, true )
<< Configuration::frameBorderName( Configuration::BorderLarge, true )
<< Configuration::frameBorderName( Configuration::BorderVeryLarge, true )
<< Configuration::frameBorderName( Configuration::BorderHuge, true )
<< Configuration::frameBorderName( Configuration::BorderVeryHuge, true )
<< Configuration::frameBorderName( Configuration::BorderOversized, true )
);
ui.frameBorderComboBox->setEnabled( false );
_checkBoxes.insert( std::make_pair( Exception::FrameBorder, ui.frameBorderCheckBox ) );
_checkBoxes.insert( FrameBorder, ui.frameBorderCheckBox );
connect( ui.frameBorderCheckBox, SIGNAL(toggled(bool)), ui.frameBorderComboBox, SLOT(setEnabled(bool)) );
// blend color
ui.blendColorComboBox->insertItems(0, QStringList()
<< Exception::blendColorName( Exception::NoBlending, true )
<< Exception::blendColorName( Exception::RadialBlending, true )
<< Exception::blendColorName( Exception::BlendFromStyle, true )
);
ui.blendColorComboBox->setEnabled( false );
_checkBoxes.insert( std::make_pair( Exception::BlendColor, ui.blendColorCheckBox ) );
_checkBoxes.insert( BlendColor, ui.blendColorCheckBox );
connect( ui.blendColorCheckBox, SIGNAL(toggled(bool)), ui.blendColorComboBox, SLOT(setEnabled(bool)) );
// size grip
ui.sizeGripComboBox->insertItems(0, QStringList()
<< Configuration::sizeGripModeName( Configuration::SizeGripNever, true )
<< Configuration::sizeGripModeName( Configuration::SizeGripWhenNeeded, true )
);
ui.sizeGripComboBox->setEnabled( false );
_checkBoxes.insert( std::make_pair( Exception::SizeGripMode, ui.sizeGripCheckBox ) );
_checkBoxes.insert( SizeGripMode, ui.sizeGripCheckBox );
connect( ui.sizeGripCheckBox, SIGNAL(toggled(bool)), ui.sizeGripComboBox, SLOT(setEnabled(bool)) );
// outline active window title
ui.titleOutlineComboBox->insertItems(0, QStringList() << i18nc( "outline window title", "Enabled" ) << i18nc( "outline window title", "Disabled" ) );
ui.titleOutlineComboBox->setEnabled( false );
_checkBoxes.insert( std::make_pair( Exception::TitleOutline, ui.titleOutlineCheckBox ) );
_checkBoxes.insert( TitleOutline, ui.titleOutlineCheckBox );
connect( ui.titleOutlineCheckBox, SIGNAL(toggled(bool)), ui.titleOutlineComboBox, SLOT(setEnabled(bool)) );
// separator
ui.separatorComboBox->setEnabled( false );
_checkBoxes.insert( std::make_pair( Exception::DrawSeparator, ui.separatorCheckBox ) );
_checkBoxes.insert( DrawSeparator, ui.separatorCheckBox );
connect( ui.separatorCheckBox, SIGNAL(toggled(bool)), ui.separatorComboBox, SLOT(setEnabled(bool)) );
}
//___________________________________________
void ExceptionDialog::setException( Exception exception )
void ExceptionDialog::setException( ConfigurationPtr exception )
{
// store exception internally
_exception = exception;
// type
ui.exceptionType->setCurrentIndex( ui.exceptionType->findText( exception.typeName( true ) ) );
ui.exceptionEditor->setText( exception.regExp().pattern() );
ui.frameBorderComboBox->setCurrentIndex( ui.frameBorderComboBox->findText( exception.frameBorderName( true ) ) );
ui.blendColorComboBox->setCurrentIndex( ui.blendColorComboBox->findText( exception.blendColorName( true ) ) );
ui.sizeGripComboBox->setCurrentIndex( ui.sizeGripComboBox->findText( exception.sizeGripModeName( true ) ) );
ui.separatorComboBox->setCurrentIndex( exception.separatorMode() );
ui.titleOutlineComboBox->setCurrentIndex( ui.titleOutlineComboBox->findText( exception.drawTitleOutline() ? i18nc( "outline window title", "Enabled" ) : i18nc( "outline window title", "Disabled" ) ) );
ui.hideTitleBar->setChecked( exception.hideTitleBar() );
ui.exceptionType->setCurrentIndex(_exception->exceptionType() );
ui.exceptionEditor->setText( _exception->exceptionPattern() );
ui.frameBorderComboBox->setCurrentIndex( _exception->frameBorder() );
ui.blendColorComboBox->setCurrentIndex( _exception->blendStyle() );
ui.sizeGripComboBox->setCurrentIndex( _exception->drawSizeGrip() );
ui.separatorComboBox->setCurrentIndex( _exception->separatorMode() );
ui.titleOutlineComboBox->setCurrentIndex( _exception->drawTitleOutline() );
ui.hideTitleBar->setChecked( _exception->hideTitleBar() );
// mask
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{ iter->second->setChecked( exception.mask() & iter->first ); }
{ iter.value()->setChecked( _exception->mask() & iter.key() ); }
}
//___________________________________________
Exception ExceptionDialog::exception( void ) const
void ExceptionDialog::save( void )
{
Exception exception( _exception );
exception.setType( Exception::type( ui.exceptionType->currentText(), true ) );
exception.regExp().setPattern( ui.exceptionEditor->text() );
exception.setFrameBorder( Exception::frameBorder( ui.frameBorderComboBox->currentText(), true ) );
exception.setBlendColor( Exception::blendColor( ui.blendColorComboBox->currentText(), true ) );
exception.setSizeGripMode( Exception::sizeGripMode( ui.sizeGripComboBox->currentText(), true ) );
_exception->setExceptionType( ui.exceptionType->currentIndex() );
_exception->setExceptionPattern( ui.exceptionEditor->text() );
_exception->setFrameBorder( ui.frameBorderComboBox->currentIndex() );
_exception->setBlendStyle( ui.blendColorComboBox->currentIndex() );
_exception->setDrawSizeGrip( ui.sizeGripComboBox->currentIndex() );
// flags
switch( ui.separatorComboBox->currentIndex() )
{
default:
case 0: exception.setSeparatorMode( Configuration::SeparatorNever ); break;
case 1: exception.setSeparatorMode( Configuration::SeparatorActive ); break;
case 2: exception.setSeparatorMode( Configuration::SeparatorAlways ); break;
}
exception.setDrawTitleOutline( ui.titleOutlineComboBox->currentText() == i18nc( "outline window title", "Enabled" ) );
exception.setHideTitleBar( ui.hideTitleBar->isChecked() );
_exception->setSeparatorMode( ui.separatorComboBox->currentIndex() );
_exception->setDrawTitleOutline( ui.titleOutlineComboBox->currentIndex() );
_exception->setHideTitleBar( ui.hideTitleBar->isChecked() );
// mask
unsigned int mask = Exception::None;
unsigned int mask = None;
for( CheckBoxMap::const_iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
{ if( iter->second->isChecked() ) mask |= iter->first; }
{ if( iter.value()->isChecked() ) mask |= iter.key(); }
exception.setMask( mask );
return exception;
_exception->setMask( mask );
}
@ -174,28 +136,28 @@ namespace Oxygen
//___________________________________________
void ExceptionDialog::readWindowProperties( bool valid )
{
assert( _detectDialog );
Q_CHECK_PTR( _detectDialog );
if( valid )
{
// type
ui.exceptionType->setCurrentIndex( ui.exceptionType->findText( Exception::typeName( _detectDialog->exceptionType(), true ) ) );
ui.exceptionType->setCurrentIndex( _detectDialog->exceptionType() );
// window info
const KWindowInfo& info( _detectDialog->windowInfo() );
switch( _detectDialog->exceptionType() )
{
case Exception::WindowClassName:
default:
case Configuration::ExceptionWindowClassName:
ui.exceptionEditor->setText( info.windowClassClass() );
break;
case Exception::WindowTitle:
case Configuration::ExceptionWindowTitle:
ui.exceptionEditor->setText( info.name() );
break;
default: assert( false );
}
}

View File

@ -25,15 +25,14 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "ui_oxygenexceptiondialog.h"
#include "../oxygendecorationdefines.h"
#include <KDialog>
#include <KLineEdit>
#include <KComboBox>
#include <QtGui/QCheckBox>
#include <map>
#include "../oxygenexception.h"
#include "ui_oxygenexceptiondialog.h"
#include <QtCore/QMap>
namespace Oxygen
{
@ -52,10 +51,10 @@ namespace Oxygen
explicit ExceptionDialog( QWidget* parent );
//! set exception
void setException( Exception );
void setException( ConfigurationPtr );
//! get exception
Exception exception( void ) const;
//! save exception
void save( void );
private slots:
@ -68,13 +67,13 @@ namespace Oxygen
Ui_OxygenExceptionWidget ui;
//! map mask and checkbox
typedef std::map< Exception::AttributesMask, QCheckBox*> CheckBoxMap;
typedef QMap< ExceptionMask, QCheckBox*> CheckBoxMap;
//! map mask and checkbox
CheckBoxMap _checkBoxes;
//! internal exception
Exception _exception;
ConfigurationPtr _exception;
//! detection dialog
DetectDialog* _detectDialog;

View File

@ -36,9 +36,8 @@ namespace Oxygen
{
//__________________________________________________________
ExceptionListWidget::ExceptionListWidget( QWidget* parent, Configuration defaultConfiguration ):
QWidget( parent ),
_defaultConfiguration( defaultConfiguration )
ExceptionListWidget::ExceptionListWidget( QWidget* parent ):
QWidget( parent )
{
//! ui
@ -76,23 +75,15 @@ namespace Oxygen
}
//__________________________________________________________
void ExceptionListWidget::setExceptions( const ExceptionList& exceptions )
void ExceptionListWidget::setExceptions( const ConfigurationList& exceptions )
{
model().set( exceptions );
resizeColumns();
}
//__________________________________________________________
ExceptionList ExceptionListWidget::exceptions( void ) const
{
ExceptionModel::List exceptions( model().get() );
ExceptionList out;
for( ExceptionModel::List::const_iterator iter = exceptions.constBegin(); iter != exceptions.constEnd(); ++iter )
{ out.push_back( *iter ); }
return out;
}
ConfigurationList ExceptionListWidget::exceptions( void ) const
{ return model().get(); }
//__________________________________________________________
void ExceptionListWidget::updateButtons( void )
@ -112,22 +103,20 @@ namespace Oxygen
void ExceptionListWidget::add( void )
{
// map dialog
QPointer<ExceptionDialog> dialog = new ExceptionDialog( this );
dialog->setException( _defaultConfiguration );
ConfigurationPtr exception( new Configuration() );
exception->readConfig();
dialog->setException( exception );
// run dialog and check existence
if( dialog->exec() == QDialog::Rejected )
if( !dialog->exec() )
{
delete dialog;
return;
}
// check dialog
if( !dialog ) return;
// retrieve exception and check
Exception exception( dialog->exception() );
dialog->save();
delete dialog;
// check exceptions
@ -158,34 +147,25 @@ namespace Oxygen
QModelIndex current( ui.exceptionListView->selectionModel()->currentIndex() );
if( ! model().contains( current ) ) return;
Exception& exception( model().get( current ) );
ConfigurationPtr exception( model().get( current ) );
// create dialog
QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
dialog->setException( exception );
// map dialog
if( dialog->exec() == QDialog::Rejected )
if( !dialog->exec() )
{
delete dialog;
return;
}
// check dialog
if( !dialog ) return;
// retrieve exception
Exception newException = dialog->exception();
dialog->save();
delete dialog;
// check if exception was changed
if( exception == newException ) return;
// check new exception validity
if( !checkException( newException ) ) return;
// asign new exception
*&exception = newException;
checkException( exception );
resizeColumns();
emit changed();
@ -217,9 +197,8 @@ namespace Oxygen
if( index.column() != ExceptionModel::ENABLED ) return;
// get matching exception
Exception& exception( model().get( index ) );
exception.setEnabled( !exception.enabled() );
model().add( exception );
ConfigurationPtr exception( model().get( index ) );
exception->setEnabled( !exception->enabled() );
emit changed();
return;
@ -230,17 +209,17 @@ namespace Oxygen
void ExceptionListWidget::up( void )
{
ExceptionModel::List selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
if( selection.empty() ) { return; }
// retrieve selected indexes in list and store in model
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedRows() );
ExceptionModel::List selectedExceptions( model().get( selectedIndices ) );
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
ExceptionModel::List currentException( model().get() );
ExceptionModel::List newExceptions;
ConfigurationList currentException( model().get() );
ConfigurationList newExceptions;
for( ExceptionModel::List::const_iterator iter = currentException.constBegin(); iter != currentException.constEnd(); ++iter )
for( ConfigurationList::const_iterator iter = currentException.constBegin(); iter != currentException.constEnd(); ++iter )
{
// check if new list is not empty, current index is selected and last index is not.
@ -251,7 +230,7 @@ namespace Oxygen
selectedIndices.indexOf( model().index( newExceptions.back() ) ) != -1
) )
{
Exception last( newExceptions.back() );
ConfigurationPtr last( newExceptions.back() );
newExceptions.removeLast();
newExceptions.append( *iter );
newExceptions.append( last );
@ -263,7 +242,7 @@ namespace Oxygen
// restore selection
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
for( ExceptionModel::List::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
emit changed();
@ -275,23 +254,23 @@ namespace Oxygen
void ExceptionListWidget::down( void )
{
ExceptionModel::List selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
ConfigurationList selection( model().get( ui.exceptionListView->selectionModel()->selectedRows() ) );
if( selection.empty() )
{ return; }
// retrieve selected indexes in list and store in model
QModelIndexList selectedIndices( ui.exceptionListView->selectionModel()->selectedIndexes() );
ExceptionModel::List selectedExceptions( model().get( selectedIndices ) );
ConfigurationList selectedExceptions( model().get( selectedIndices ) );
ExceptionModel::List currentExceptions( model().get() );
ExceptionModel::List newExceptions;
ConfigurationList currentExceptions( model().get() );
ConfigurationList newExceptions;
ExceptionModel::ListIterator iter( currentExceptions );
ConfigurationListIterator iter( currentExceptions );
iter.toBack();
while( iter.hasPrevious() )
{
const Exception& current( iter.previous() );
ConfigurationPtr current( iter.previous() );
// check if new list is not empty, current index is selected and last index is not.
// if yes, move.
@ -302,7 +281,7 @@ namespace Oxygen
) )
{
Exception first( newExceptions.front() );
ConfigurationPtr first( newExceptions.front() );
newExceptions.removeFirst();
newExceptions.prepend( current );
newExceptions.prepend( first );
@ -314,7 +293,7 @@ namespace Oxygen
// restore selection
ui.exceptionListView->selectionModel()->select( model().index( selectedExceptions.front() ), QItemSelectionModel::Clear|QItemSelectionModel::Select|QItemSelectionModel::Rows );
for( ExceptionModel::List::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
for( ConfigurationList::const_iterator iter = selectedExceptions.constBegin(); iter != selectedExceptions.constEnd(); ++iter )
{ ui.exceptionListView->selectionModel()->select( model().index( *iter ), QItemSelectionModel::Select|QItemSelectionModel::Rows ); }
emit changed();
@ -331,10 +310,10 @@ namespace Oxygen
}
//_______________________________________________________
bool ExceptionListWidget::checkException( Exception& exception )
bool ExceptionListWidget::checkException( ConfigurationPtr exception )
{
while( !exception.regExp().isValid() )
while( exception->exceptionPattern().isEmpty() || !QRegExp( exception->exceptionPattern() ).isValid() )
{
KMessageBox::error( this, i18n("Regular Expression syntax is incorrect") );
@ -346,7 +325,7 @@ namespace Oxygen
return false;
}
exception = dialog->exception();
dialog->save();
delete dialog;
}

View File

@ -27,7 +27,6 @@
#include "ui_oxygenexceptionlistwidget.h"
#include "oxygenexceptionmodel.h"
#include "../oxygenexceptionlist.h"
//! QDialog used to commit selected files
namespace Oxygen
@ -42,13 +41,13 @@ namespace Oxygen
public:
//! constructor
explicit ExceptionListWidget( QWidget* = 0, Configuration defaultConfiguration = Configuration() );
explicit ExceptionListWidget( QWidget* = 0 );
//! set exceptions
void setExceptions( const ExceptionList& );
void setExceptions( const ConfigurationList& );
//! get exceptions
ExceptionList exceptions( void ) const;
ConfigurationList exceptions( void ) const;
signals:
@ -94,13 +93,10 @@ namespace Oxygen
void resizeColumns( void ) const;
//! check exception
bool checkException( Exception& );
bool checkException( ConfigurationPtr );
private:
//! default configuration
Configuration _defaultConfiguration;
//! model
ExceptionModel _model;

View File

@ -27,7 +27,7 @@
#include <KLocale>
namespace Oxygen
{
//_______________________________________________
const QString ExceptionModel::_columnTitles[ ExceptionModel::nColumns ] =
{
@ -35,57 +35,71 @@ namespace Oxygen
i18n("Exception Type"),
i18n("Regular Expression")
};
//__________________________________________________________________
QVariant ExceptionModel::data( const QModelIndex& index, int role ) const
{
// check index, role and column
if( !index.isValid() ) return QVariant();
// retrieve associated file info
const Exception& exception( get(index) );
const ConfigurationPtr& configuration( get(index) );
// return text associated to file and column
if( role == Qt::DisplayRole )
{
switch( index.column() )
{
case TYPE: return exception.typeName( true );
case REGEXP: return exception.regExp().pattern();
case TYPE:
{
switch( configuration->exceptionType() )
{
case Configuration::ExceptionWindowTitle:
return i18n( "Window Title" );
default:
case Configuration::ExceptionWindowClassName:
return i18n( "Window Class Name" );
}
}
case REGEXP: return configuration->exceptionPattern();
default: return QVariant();
break;
}
} else if( role == Qt::CheckStateRole && index.column() == ENABLED ) {
return exception.enabled() ? Qt::Checked : Qt::Unchecked;
return configuration->enabled() ? Qt::Checked : Qt::Unchecked;
} else if( role == Qt::ToolTipRole && index.column() == ENABLED ) {
return i18n("Enable/disable this exception");
}
return QVariant();
}
//__________________________________________________________________
QVariant ExceptionModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(
orientation == Qt::Horizontal &&
role == Qt::DisplayRole &&
section >= 0 &&
section < nColumns )
{ return _columnTitles[section]; }
// return empty
return QVariant();
}
}

View File

@ -26,55 +26,56 @@
//////////////////////////////////////////////////////////////////////////////
#include "oxygenlistmodel.h"
#include "../oxygenexception.h"
#include "oxygenconfiguration.h"
#include "../oxygendecorationdefines.h"
namespace Oxygen
{
//! qlistview for object counters
class ExceptionModel: public ListModel<Exception>
class ExceptionModel: public ListModel<ConfigurationPtr>
{
public:
//! number of columns
enum { nColumns = 3 };
//! column type enumeration
enum ColumnType {
ENABLED,
TYPE,
REGEXP
};
//!@name methods reimplemented from base class
//@{
// return data for a given index
virtual QVariant data(const QModelIndex &index, int role) const;
//! header data
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
//! number of columns for a given index
virtual int columnCount(const QModelIndex& ) const
{ return nColumns; }
//@}
protected:
//! sort
virtual void privateSort( int, Qt::SortOrder )
{}
private:
//! column titles
static const QString _columnTitles[ nColumns ];
};
}
#endif

View File

@ -1,53 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// ShadowConfigurationUi.cpp
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenshadowconfigurationui.h"
#include <KLocale>
#include <QtGui/QLabel>
#include <QtGui/QLayout>
namespace Oxygen
{
//_________________________________________________________
ShadowConfigurationUi::ShadowConfigurationUi( QWidget* parent ):
QGroupBox( parent )
{
ui.setupUi( this );
// connections
ui.outerColor->setEnabled( false );
connect( ui.useOuterColor, SIGNAL(toggled(bool)), SLOT(enableOuterColor()) );
connect( this, SIGNAL(toggled(bool)), SLOT(enableOuterColor()) );
connect( ui.shadowSize, SIGNAL(valueChanged(int)), SIGNAL(changed()) );
connect( ui.verticalOffset, SIGNAL(valueChanged(int)), SIGNAL(changed()) );
connect( ui.innerColor, SIGNAL(changed(QColor)), SIGNAL(changed()) );
connect( ui.outerColor, SIGNAL(changed(QColor)), SIGNAL(changed()) );
connect( ui.useOuterColor, SIGNAL(toggled(bool)), SIGNAL(changed()) );
}
}

View File

@ -47,7 +47,53 @@
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="frameBorder"/>
<widget class="KComboBox" name="frameBorder">
<item>
<property name="text">
<string>No Border</string>
</property>
</item>
<item>
<property name="text">
<string>No Side Borders</string>
</property>
</item>
<item>
<property name="text">
<string>Tiny</string>
</property>
</item>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
<item>
<property name="text">
<string>Very Large</string>
</property>
</item>
<item>
<property name="text">
<string>Huge</string>
</property>
</item>
<item>
<property name="text">
<string>Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string>Oversized</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
@ -63,7 +109,28 @@
</widget>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="titleAlignment"/>
<widget class="KComboBox" name="titleAlignment">
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Center</string>
</property>
</item>
<item>
<property name="text">
<string>Center (Full Width)</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer">
@ -92,16 +159,35 @@
</widget>
</item>
<item row="2" column="2">
<widget class="KComboBox" name="buttonSize"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
<widget class="KComboBox" name="buttonSize">
<item>
<property name="text">
<string>Small</string>
</property>
</item>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
<item>
<property name="text">
<string>Very Large</string>
</property>
</item>
<item>
<property name="text">
<string>Huge</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -114,6 +200,13 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="animationsEnabled">
<property name="text">
<string>Enable animations</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
@ -124,7 +217,26 @@
<property name="margin">
<number>4</number>
</property>
<item row="2" column="0">
<item row="1" column="1">
<widget class="KComboBox" name="separatorMode">
<item>
<property name="text">
<string>Never Draw Separator</string>
</property>
</item>
<item>
<property name="text">
<string>Draw Separator When Window is Active</string>
</property>
</item>
<item>
<property name="text">
<string>Always Draw Separator</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Separator display:</string>
@ -151,7 +263,23 @@
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="blendColor"/>
<widget class="KComboBox" name="blendColor">
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>Radial Gradient</string>
</property>
</item>
<item>
<property name="text">
<string>Follow Style Hint</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
@ -166,14 +294,35 @@
</property>
</spacer>
</item>
<item row="4" column="0" colspan="3">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="titleOutline">
<property name="text">
<string>Outline active window title</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0" colspan="3">
<widget class="QCheckBox" name="narrowButtonSpacing">
<property name="text">
<string>Use narrow space between decoration buttons</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QCheckBox" name="drawSizeGrip">
<property name="text">
<string>Add handle to resize windows with no border</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="closeFromMenuButton">
<property name="text">
<string>Close windows by double clicking the menu button</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -186,55 +335,6 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="narrowButtonSpacing">
<property name="text">
<string>Use narrow space between decoration buttons</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KComboBox" name="sizeGripMode"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="sizeGripModeLabel">
<property name="text">
<string>Extra size grip display: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>sizeGripMode</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KComboBox" name="separatorMode">
<item>
<property name="text">
<string>Never Draw Separator</string>
</property>
</item>
<item>
<property name="text">
<string>Draw Separator When Window is Active</string>
</property>
</item>
<item>
<property name="text">
<string>Always Draw Separator</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="closeFromMenuButton">
<property name="text">
<string>Close windows by double clicking the menu button</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
@ -351,10 +451,8 @@
<tabstop>animationsEnabled</tabstop>
<tabstop>_expertModeButton</tabstop>
<tabstop>blendColor</tabstop>
<tabstop>sizeGripMode</tabstop>
<tabstop>separatorMode</tabstop>
<tabstop>titleOutline</tabstop>
<tabstop>closeFromMenuButton</tabstop>
<tabstop>narrowButtonSpacing</tabstop>
<tabstop>inactiveShadowConfiguration</tabstop>
<tabstop>activeShadowConfiguration</tabstop>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<width>512</width>
<height>352</height>
</rect>
</property>
@ -58,7 +58,18 @@
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="KComboBox" name="exceptionType"/>
<widget class="KComboBox" name="exceptionType">
<item>
<property name="text">
<string>Window Class Name</string>
</property>
</item>
<item>
<property name="text">
<string>Window Title</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
@ -79,7 +90,7 @@
<item row="3" column="0">
<widget class="QCheckBox" name="sizeGripCheckBox">
<property name="text">
<string>Extra size grip display:</string>
<string>Add handle to resize windows with no border</string>
</property>
</widget>
</item>
@ -122,16 +133,100 @@
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="frameBorderComboBox"/>
<widget class="KComboBox" name="frameBorderComboBox">
<item>
<property name="text">
<string>No Border</string>
</property>
</item>
<item>
<property name="text">
<string>No Side Borders</string>
</property>
</item>
<item>
<property name="text">
<string>Tiny</string>
</property>
</item>
<item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Large</string>
</property>
</item>
<item>
<property name="text">
<string>Very Large</string>
</property>
</item>
<item>
<property name="text">
<string>Huge</string>
</property>
</item>
<item>
<property name="text">
<string>Very Huge</string>
</property>
</item>
<item>
<property name="text">
<string>Oversized</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2">
<widget class="KComboBox" name="blendColorComboBox"/>
<widget class="KComboBox" name="blendColorComboBox">
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>Radial Gradient</string>
</property>
</item>
<item>
<property name="text">
<string>Follow Style Hint</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2">
<widget class="KComboBox" name="sizeGripComboBox"/>
<widget class="KComboBox" name="sizeGripComboBox">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Enabled</string>
</property>
</item>
</widget>
</item>
<item row="4" column="2">
<widget class="KComboBox" name="titleOutlineComboBox"/>
<widget class="KComboBox" name="titleOutlineComboBox">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Enabled</string>
</property>
</item>
</widget>
</item>
<item row="5" column="2">
<widget class="KComboBox" name="separatorComboBox">

View File

@ -1,129 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ShadowConfiguraionUI</class>
<widget class="QWidget" name="ShadowConfiguraionUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>112</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Inner Color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>innerColor</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="KColorButton" name="innerColor"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Outer Color:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>outerColor</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="outerColor">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="useOuterColor">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Vertical Offset:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>verticalOffset</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Size: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>shadowSize</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KIntSpinBox" name="shadowSize">
<property name="suffix">
<string>px</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KIntSpinBox" name="verticalOffset">
<property name="suffix">
<string>px</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>shadowSize</tabstop>
<tabstop>verticalOffset</tabstop>
<tabstop>innerColor</tabstop>
<tabstop>outerColor</tabstop>
<tabstop>useOuterColor</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -26,7 +26,6 @@
#include "oxygenshadowdemodialog.h"
#include "oxygenshadowdemodialog.moc"
#include "oxygenshadowconfiguration.h"
#include <QtGui/QDialogButtonBox>
#include <QtDBus/QDBusConnection>
@ -94,11 +93,8 @@ namespace Oxygen
{
// read shadow configurations
KConfig config( "oxygenrc" );
_cache.invalidateCaches();
_cache.setEnabled( true );
_cache.setShadowConfiguration( ShadowConfiguration( QPalette::Inactive, KConfigGroup( &config, "InactiveShadow") ) );
_cache.setShadowConfiguration( ShadowConfiguration( QPalette::Active, KConfigGroup( &config, "ActiveShadow") ) );
// pass tileSets to UI
ShadowCache::Key key;

View File

@ -57,7 +57,7 @@ namespace Oxygen
setAutoFillBackground(false);
setAttribute(Qt::WA_NoSystemBackground);
unsigned int size( _client.configuration().buttonSize() );
int size( _client.buttonSize() );
setFixedSize( size, size );
setCursor(Qt::ArrowCursor);
@ -96,18 +96,18 @@ namespace Oxygen
//___________________________________________________
bool Button::buttonAnimationsEnabled( void ) const
{ return _client.animationsEnabled() && _client.configuration().buttonAnimationsEnabled(); }
{ return _client.animationsEnabled() && _client.configuration()->buttonAnimationsEnabled(); }
//___________________________________________________
QSize Button::sizeHint() const
{
unsigned int size( _client.configuration().buttonSize() );
unsigned int size( _client.buttonSize() );
return QSize( size, size );
}
//___________________________________________________
void Button::reset( unsigned long )
{ _glowAnimation->setDuration( _client.configuration().buttonAnimationsDuration() ); }
{ _glowAnimation->setDuration( _client.configuration()->buttonAnimationsDuration() ); }
//___________________________________________________
void Button::paint( QPainter& painter )
@ -156,7 +156,7 @@ namespace Oxygen
if( hasDecoration() )
{
// scale
qreal scale( (21.0*_client.configuration().buttonSize())/22.0 );
qreal scale( (21.0*_client.buttonSize())/22.0 );
// pressed state
const bool pressed(
@ -175,7 +175,19 @@ namespace Oxygen
if( isMenuButton() )
{
const QPixmap& pixmap( _client.icon().pixmap( _client.configuration().iconScale() ) );
int iconScale( 0 );
switch( _client.buttonSize() )
{
case Configuration::ButtonSmall: iconScale = 13; break;
default:
case Configuration::ButtonDefault: iconScale = 16; break;
case Configuration::ButtonLarge: iconScale = 20; break;
case Configuration::ButtonVeryLarge: iconScale = 24; break;
case Configuration::ButtonHuge: iconScale = 35; break;
}
const QPixmap& pixmap( _client.icon().pixmap( iconScale ) );
const double offset = 0.5*(width()-pixmap.width() );
painter.drawPixmap(offset, offset-1, pixmap );

View File

@ -28,21 +28,16 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <kcommondecoration.h>
#include "oxygenfactory.h"
#include "oxygenanimation.h"
#include "oxygendecorationdefines.h"
#include "oxygendecohelper.h"
#include <kcommondecoration.h>
namespace Oxygen
{
class Client;
enum ButtonStatus {
Normal = 0,
Hovered = 1<<0,
Pressed = 1<<1
};
Q_DECLARE_FLAGS(ButtonState, ButtonStatus)
class Button : public KCommonDecorationButton

View File

@ -85,6 +85,9 @@ namespace Oxygen
void Client::init()
{
// make sure valid configuration is set
if( !_configuration ) _configuration = _factory->configuration( *this );
KCommonDecoration::init();
widget()->setAttribute(Qt::WA_NoSystemBackground );
@ -99,7 +102,6 @@ namespace Oxygen
_glowAnimation->setEasingCurve( QEasingCurve::InOutQuad );
connect( _glowAnimation, SIGNAL(finished()), this, SLOT(clearForceActive()) );
// title animation data
_titleAnimationData->initialize();
connect( _titleAnimationData, SIGNAL(pixmapsChanged()), SLOT(updateTitleRect()) );
@ -150,14 +152,14 @@ namespace Oxygen
_configuration = _factory->configuration( *this );
// glow animations
_glowAnimation->setDuration( configuration().shadowAnimationsDuration() );
_glowAnimation->setDuration( _configuration->shadowAnimationsDuration() );
// title transitions
_titleAnimationData->setDuration( configuration().titleAnimationsDuration() );
_titleAnimationData->setDuration( _configuration->titleAnimationsDuration() );
// tabs
_itemData.setAnimationsEnabled( animationsEnabled() && configuration().tabAnimationsEnabled() );
_itemData.animation().data()->setDuration( configuration().tabAnimationsDuration() );
_itemData.setAnimationsEnabled( animationsEnabled() && _configuration->tabAnimationsEnabled() );
_itemData.animation().data()->setDuration( _configuration->tabAnimationsDuration() );
// reset title transitions
_titleAnimationData->reset();
@ -176,7 +178,7 @@ namespace Oxygen
_itemData.setDirty( true );
// handle size grip
if( configuration().drawSizeGrip() )
if( _configuration->drawSizeGrip() && _configuration->frameBorder() == Configuration::BorderNone )
{
if( !hasSizeGrip() ) createSizeGrip();
@ -195,7 +197,7 @@ namespace Oxygen
{
case DB_MenuClose:
return configuration().closeFromMenuButton();
return _configuration->closeWindowFromMenuButton();
case DB_WindowMask:
return false;
@ -259,7 +261,7 @@ namespace Oxygen
-layoutMetric( LM_OuterPaddingRight ), -layoutMetric( LM_OuterPaddingBottom ) ) );
QRegion mask;
if( configuration().frameBorder() == Configuration::BorderNone && !isShade() )
if( _configuration->frameBorder() == Configuration::BorderNone && !isShade() )
{
if( hideTitleBar() ) mask = QRegion();
@ -283,9 +285,9 @@ namespace Oxygen
const bool maximized( isMaximized() );
const bool shaded( isShade() );
const bool narrowSpacing( configuration().useNarrowButtonSpacing() );
const int frameBorder( configuration().frameBorder() );
const int buttonSize( hideTitleBar() ? 0 : configuration().buttonSize() );
const bool narrowSpacing( _configuration->useNarrowButtonSpacing() );
const int frameBorder( this->frameBorder() );
const int buttonSize( hideTitleBar() ? 0 : this->buttonSize() );
switch (lm)
{
@ -298,11 +300,11 @@ namespace Oxygen
border = 0;
} else if( frameBorder < Configuration::BorderTiny ) {
} else if( _configuration->frameBorder() < Configuration::BorderTiny ) {
border = 0;
} else if( !compositingActive() && frameBorder == Configuration::BorderTiny ) {
} else if( !compositingActive() && _configuration->frameBorder() == Configuration::BorderTiny ) {
border = qMax( frameBorder, 3 );
@ -319,17 +321,17 @@ namespace Oxygen
border = 0;
} else if( frameBorder >= Configuration::BorderNoSide ) {
} else if( _configuration->frameBorder() >= Configuration::BorderNoSide ) {
// for tiny border, the convention is to have a larger bottom area in order to
// make resizing easier
border = qMax(frameBorder, 4);
} else if( frameBorder < Configuration::BorderTiny ) {
} else if( _configuration->frameBorder() < Configuration::BorderTiny ) {
border = 0;
} else if( !compositingActive() && frameBorder == Configuration::BorderTiny ) {
} else if( !compositingActive() && _configuration->frameBorder() == Configuration::BorderTiny ) {
border = qMax( frameBorder, 3 );
@ -341,7 +343,7 @@ namespace Oxygen
case LM_TitleEdgeTop:
{
int border = 0;
if( frameBorder == Configuration::BorderNone && hideTitleBar() )
if( _configuration->frameBorder() == Configuration::BorderNone && hideTitleBar() )
{
border = 0;
@ -379,7 +381,7 @@ namespace Oxygen
// if title outline is to be drawn, one adds the space needed to
// separate title and tab border. namely the same value
if( configuration().drawTitleOutline() ) border += border;
if( _configuration->drawTitleOutline() ) border += border;
return border;
}
@ -418,11 +420,11 @@ namespace Oxygen
QRect titleRect( this->titleRect().adjusted( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 ) );
// when drawing title outline, shrink the rect so that it matches the actual caption size
if( active && configuration().drawTitleOutline() && isActive() )
if( active && _configuration->drawTitleOutline() && isActive() )
{
if( configuration().centerTitleOnFullWidth() )
if( _configuration->titleAlignment() == Configuration::AlignCenterFullWidth )
{
titleRect.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) );
titleRect.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) );
@ -449,7 +451,7 @@ namespace Oxygen
{
// get title bounding rect
QRect boundingRect( QFontMetrics( font ).boundingRect( rect, configuration().titleAlignment() | Qt::AlignVCenter, caption ) );
QRect boundingRect( QFontMetrics( font ).boundingRect( rect, titleAlignment() | Qt::AlignVCenter, caption ) );
// adjust to make sure bounding rect
// 1/ has same vertical alignment as original titleRect
@ -460,7 +462,7 @@ namespace Oxygen
// check bounding rect against input rect
boundRectTo( boundingRect, rect );
if( configuration().centerTitleOnFullWidth() )
if( _configuration->titleAlignment() == Configuration::AlignCenterFullWidth )
{
/*
@ -606,8 +608,8 @@ namespace Oxygen
// window background
if(
configuration().blendColor() == Configuration::NoBlending ||
( configuration().blendColor() == Configuration::BlendFromStyle &&
_configuration->blendStyle() == Configuration::BlendNone ||
( _configuration->blendStyle() == Configuration::BlendFromStyle &&
!helper().hasBackgroundGradient( windowId() )
) )
{
@ -619,7 +621,7 @@ namespace Oxygen
int offset = layoutMetric( LM_OuterPaddingTop );
// radial gradient positionning
const int height = hideTitleBar() ? 0:configuration().buttonSize();
const int height = hideTitleBar() ? 0:buttonSize();
if( isMaximized() ) offset -= 3;
const QWidget* window( isPreview() ? this->widget() : widget->window() );
@ -633,7 +635,7 @@ namespace Oxygen
int offset = layoutMetric( LM_OuterPaddingTop );
// radial gradient positionning
const int height = hideTitleBar() ? 0:configuration().buttonSize();
const int height = hideTitleBar() ? 0:buttonSize();
if( isMaximized() ) offset -= 3;
// background pixmap
@ -685,7 +687,7 @@ namespace Oxygen
const int titleHeight( layoutMetric( LM_TitleEdgeTop ) + layoutMetric( LM_TitleEdgeBottom ) + layoutMetric( LM_TitleHeight ) );
// make titlebar background darker for tabbed, non-outline window
if( ( tabCount() >= 2 || _itemData.isAnimated() ) && !(configuration().drawTitleOutline() && isActive() ) )
if( ( tabCount() >= 2 || _itemData.isAnimated() ) && !(_configuration->drawTitleOutline() && isActive() ) )
{
const QPoint topLeft( r.topLeft()-position );
@ -710,10 +712,10 @@ namespace Oxygen
// adjustements to cope with shadow size and outline border.
rect.adjust( -shadowSize, 0, shadowSize-1, 0 );
if( configuration().drawTitleOutline() && ( isActive() || glowIsAnimated() ) && !isMaximized() )
if( _configuration->drawTitleOutline() && ( isActive() || glowIsAnimated() ) && !isMaximized() )
{
if( configuration().frameBorder() == Configuration::BorderTiny ) rect.adjust( 1, 0, -1, 0 );
else if( configuration().frameBorder() > Configuration::BorderTiny ) rect.adjust( HFRAMESIZE-1, 0, -HFRAMESIZE+1, 0 );
if( _configuration->frameBorder() == Configuration::BorderTiny ) rect.adjust( 1, 0, -1, 0 );
else if( _configuration->frameBorder() > Configuration::BorderTiny ) rect.adjust( HFRAMESIZE-1, 0, -HFRAMESIZE+1, 0 );
}
if( rect.isValid() )
@ -721,7 +723,7 @@ namespace Oxygen
}
if( configuration().drawTitleOutline() && ( isActive() || glowIsAnimated() ) )
if( _configuration->drawTitleOutline() && ( isActive() || glowIsAnimated() ) )
{
// save old hints and turn off anti-aliasing
@ -736,7 +738,7 @@ namespace Oxygen
// bottom line
const int leftOffset = qMin( layoutMetric( LM_BorderLeft ), int(HFRAMESIZE) );
const int rightOffset = qMin( layoutMetric( LM_BorderRight ), int(HFRAMESIZE) );
if( configuration().frameBorder() > Configuration::BorderNone )
if( _configuration->frameBorder() > Configuration::BorderNone )
{
const int height = qMax( 0, layoutMetric( LM_BorderBottom ) - HFRAMESIZE );
@ -756,7 +758,7 @@ namespace Oxygen
const int bottomOffset = qMin( layoutMetric( LM_BorderBottom ), int(HFRAMESIZE) );
const int height = r.height() - topOffset - bottomOffset - 1;
if( configuration().frameBorder() >= Configuration::BorderTiny )
if( _configuration->frameBorder() >= Configuration::BorderTiny )
{
const QColor shadow( helper().calcLightColor( color ) );
@ -836,7 +838,7 @@ namespace Oxygen
// set color
QColor local( color );
if( glowIsAnimated() && configuration().separatorMode() != Configuration::SeparatorAlways )
if( glowIsAnimated() && _configuration->separatorMode() != Configuration::SeparatorAlways )
{ local = helper().alphaColor( color, glowIntensity() ); }
// render
@ -952,7 +954,7 @@ namespace Oxygen
void Client::renderTitleText( QPainter* painter, const QRect& rect, const QString& caption, const QColor& color, const QColor& contrast, bool elide ) const
{
const Qt::Alignment alignment( configuration().titleAlignment() | Qt::AlignVCenter );
const Qt::Alignment alignment( titleAlignment() | Qt::AlignVCenter );
const QString local( elide ? QFontMetrics( painter->font() ).elidedText( caption, Qt::ElideRight, rect.width() ):caption );
// translate title down in case of maximized window
@ -986,7 +988,7 @@ namespace Oxygen
QPainter painter( &out );
painter.setFont( options()->font(isActive(), false) );
const Qt::Alignment alignment( configuration().titleAlignment() | Qt::AlignVCenter );
const Qt::Alignment alignment( titleAlignment() | Qt::AlignVCenter );
const QString local( elide ? QFontMetrics( painter.font() ).elidedText( caption, Qt::ElideRight, rect.width() ):caption );
painter.setPen( color );
@ -1017,7 +1019,7 @@ namespace Oxygen
// add extra space for the button
if( itemCount > 1 && item._closeButton && item._closeButton.data()->isVisible() )
{ textRect.adjust( 0, 0, - configuration().buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 ); }
{ textRect.adjust( 0, 0, - buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 ); }
// check if current item is active
const bool active( tabId(index) == currentTabId() );
@ -1025,7 +1027,7 @@ namespace Oxygen
// get current item caption and update text rect
const QString caption( itemCount == 1 ? this->caption() : this->caption(index) );
if( !configuration().centerTitleOnFullWidth() )
if( _configuration->titleAlignment() != Configuration::AlignCenterFullWidth )
{ boundRectTo( textRect, titleRect() ); }
// adjust textRect
@ -1042,7 +1044,7 @@ namespace Oxygen
renderTitleOutline( painter, item._boundingRect, palette );
} else if( (isActive()||glowIsAnimated()) && configuration().drawTitleOutline() ) {
} else if( (isActive()||glowIsAnimated()) && _configuration->drawTitleOutline() ) {
// adjusts boundingRect accordingly
QRect boundingRect( item._boundingRect );
@ -1079,7 +1081,7 @@ namespace Oxygen
QColor background( backgroundPalette( widget(), palette ).color( widget()->window()->backgroundRole() ) );
// add extra shade (as used in renderWindowBorder
if( !( isActive() && configuration().drawTitleOutline() ) )
if( !( isActive() && _configuration->drawTitleOutline() ) )
{ background = KColorUtils::mix( background, Qt::black, 0.10 ); }
// otherwise current caption is rendered directly
@ -1159,12 +1161,12 @@ namespace Oxygen
if( !isMaximized() )
{
if( configuration().frameBorder() >= Configuration::BorderTiny )
if( _configuration->frameBorder() >= Configuration::BorderTiny )
{
helper().drawFloatFrame(
painter, frame, backgroundColor( widget(), palette ),
!compositingActive(), isActive() && configuration().useOxygenShadows(),
!compositingActive(), isActive() && shadowCache().isEnabled( QPalette::Active ),
KDecoration::options()->color(ColorTitleBar)
);
@ -1174,7 +1176,7 @@ namespace Oxygen
const QRect local( frame.topLeft(), QSize( frame.width(), layoutMetric(LM_TitleHeight) + layoutMetric(LM_TitleEdgeTop) ) );
helper().drawFloatFrame(
painter, local, backgroundColor( widget(), palette ),
false, isActive() && configuration().useOxygenShadows(),
false, isActive() && shadowCache().isEnabled( QPalette::Active ),
KDecoration::options()->color(ColorTitleBar)
);
}
@ -1184,7 +1186,7 @@ namespace Oxygen
// for shaded maximized windows adjust frame and draw the bottom part of it
helper().drawFloatFrame(
painter, frame, backgroundColor( widget(), palette ),
!( compositingActive() || configuration().frameBorder() == Configuration::BorderNone ), isActive(),
!( compositingActive() || _configuration->frameBorder() == Configuration::BorderNone ), isActive(),
KDecoration::options()->color(ColorTitleBar),
TileSet::Bottom
);
@ -1197,7 +1199,7 @@ namespace Oxygen
void Client::renderDots( QPainter* painter, const QRect& frame, const QColor& color ) const
{
if( configuration().frameBorder() >= Configuration::BorderTiny )
if( _configuration->frameBorder() >= Configuration::BorderTiny )
{
// dimensions
@ -1218,7 +1220,7 @@ namespace Oxygen
}
// Draw bottom-right cornet 3-dots resize handles
if( isResizable() && !isShade() && !configuration().drawSizeGrip() )
if( isResizable() && !isShade() && !_configuration->drawSizeGrip() )
{
painter->save();
@ -1288,7 +1290,7 @@ namespace Oxygen
QPalette Client::backgroundPalette( const QWidget* widget, QPalette palette ) const
{
if( configuration().drawTitleOutline() )
if( _configuration->drawTitleOutline() )
{
if( glowIsAnimated() && !isForcedActive() )
{
@ -1317,7 +1319,7 @@ namespace Oxygen
QColor Client::backgroundColor( const QWidget*, QPalette palette, bool active ) const
{
return ( configuration().drawTitleOutline() && active ) ?
return ( _configuration->drawTitleOutline() && active ) ?
options()->color( KDecorationDefines::ColorTitleBar, true ):
palette.color( QPalette::Window );
@ -1433,7 +1435,7 @@ namespace Oxygen
{
// return empty region for anything but extended borders, when enabled
if( !( r == KDecorationDefines::ExtendedBorderRegion && configuration().useExtendedWindowBorder() ) )
if( !( r == KDecorationDefines::ExtendedBorderRegion && configuration()->useExtendedWindowBorders() ) )
{ return QRegion(); }
// return empty region for maximized windows
@ -1441,7 +1443,7 @@ namespace Oxygen
// return 3 pixels extended borders for sides that have no visible borders
// also add the invisible pixels at the masked rounded corners, in non compositing mode
if( configuration().frameBorder() <= Configuration::BorderNoSide || !compositingActive() )
if( configuration()->frameBorder() <= Configuration::BorderNoSide || !compositingActive() )
{
QRect rect = widget()->rect().adjusted(
@ -1458,8 +1460,8 @@ namespace Oxygen
else mask.translate( -layoutMetric( LM_OuterPaddingLeft ), -layoutMetric( LM_OuterPaddingTop ) );
// only return non-empty region on the sides for which there is no border
if( configuration().frameBorder() == Configuration::BorderNone ) return QRegion( rect.adjusted( -3, 0, 3, 3 ) ) - mask;
else if( configuration().frameBorder() == Configuration::BorderNoSide ) return QRegion( rect.adjusted( -3, 0, 3, 0 ) ) - mask;
if( configuration()->frameBorder() == Configuration::BorderNone ) return QRegion( rect.adjusted( -3, 0, 3, 3 ) ) - mask;
else if( configuration()->frameBorder() == Configuration::BorderNoSide ) return QRegion( rect.adjusted( -3, 0, 3, 0 ) ) - mask;
else if( !compositingActive() ) return QRegion( rect ) - mask;
}
@ -1550,7 +1552,7 @@ namespace Oxygen
TileSet *tileSet( 0 );
const ShadowCache::Key key( this->key() );
if( configuration().useOxygenShadows() && glowIsAnimated() && !isForcedActive() )
if( shadowCache().isEnabled( QPalette::Active ) && glowIsAnimated() && !isForcedActive() )
{
tileSet = shadowCache().tileSet( key, glowIntensity() );
@ -1589,7 +1591,7 @@ namespace Oxygen
int bottom = 1;
// disable bottom corners when border frame is too small and window is not shaded
if( configuration().frameBorder() == Configuration::BorderNone && !isShade() ) bottom = 0;
if( _configuration->frameBorder() == Configuration::BorderNone && !isShade() ) bottom = 0;
QRegion mask( helper().roundedMask( frame, left, right, top, bottom ) );
renderCorners( &painter, frame, palette );
@ -1733,9 +1735,9 @@ namespace Oxygen
if( _itemData.count() > 1 )
{
geometry.adjust( 0, 0, - configuration().buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 );
geometry.adjust( 0, 0, - buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 );
} else if( !( isActive() && configuration().drawTitleOutline() ) ) {
} else if( !( isActive() && _configuration->drawTitleOutline() ) ) {
geometry.adjust(
buttonsLeftWidth() + layoutMetric( LM_TitleEdgeLeft ) , 0,

View File

@ -81,7 +81,7 @@ namespace Oxygen
//! true if animations are used
bool animationsEnabled( void ) const
{ return configuration().animationsEnabled(); }
{ return _configuration->animationsEnabled(); }
//! true if glow is animated
bool glowIsAnimated( void ) const
@ -94,8 +94,8 @@ namespace Oxygen
//! true when separator is to be drawn
bool drawSeparator( void ) const
{
if( configuration().drawTitleOutline() ) return false;
switch( configuration().separatorMode() )
if( _configuration->drawTitleOutline() ) return false;
switch( _configuration->separatorMode() )
{
case Configuration::SeparatorAlways:
return true;
@ -114,7 +114,7 @@ namespace Oxygen
bool hideTitleBar( void ) const
{
return
configuration().hideTitleBar() &&
_configuration->hideTitleBar() &&
!isShade() &&
tabCount() == 1;
}
@ -131,7 +131,7 @@ namespace Oxygen
virtual void reset( unsigned long changed );
//! return associated configuration
const Configuration& configuration( void ) const
Factory::ConfigurationPtr configuration( void ) const
{ return _configuration; }
//!@name glow animation
@ -201,6 +201,15 @@ namespace Oxygen
//! default buttons located on the right
virtual QString defaultButtonsRight() const;
//! title alignment
inline Qt::Alignment titleAlignment( void ) const;
//! button size
inline int buttonSize( void ) const;
//! frame border
inline int frameBorder( void ) const;
//!@name status change methods (overloaded from KCommonDecorationUnstable)
//@{
@ -243,9 +252,9 @@ namespace Oxygen
ShadowCache::Key key( void ) const
{
ShadowCache::Key key;
key.active = ( isActive() || isForcedActive() ) && configuration().useOxygenShadows();
key.active = ( isActive() || isForcedActive() ) && shadowCache().isEnabled( QPalette::Active );
key.isShade = isShade();
key.hasBorder = ( configuration().frameBorder() > Configuration::BorderNone );
key.hasBorder = ( _configuration->frameBorder() > Configuration::BorderNone );
return key;
}
@ -344,15 +353,15 @@ namespace Oxygen
//! return true when activity change are animated
bool shadowAnimationsEnabled( void ) const
{ return ( animationsEnabled() && configuration().shadowAnimationsEnabled() && !isPreview() ); }
{ return ( animationsEnabled() && _configuration->shadowAnimationsEnabled() && !isPreview() ); }
//! return true when activity change are animated
bool titleAnimationsEnabled( void ) const
{
return
animationsEnabled() &&
configuration().titleAnimationsEnabled() &&
!configuration().drawTitleOutline() &&
_configuration->titleAnimationsEnabled() &&
!_configuration->drawTitleOutline() &&
!hideTitleBar() &&
!isPreview();
}
@ -363,7 +372,7 @@ namespace Oxygen
return
tabCount() >= 2 ||
_itemData.isAnimated() ||
( (isActive()||glowIsAnimated()) && configuration().drawTitleOutline() );
( (isActive()||glowIsAnimated()) && _configuration->drawTitleOutline() );
}
//! calculate mask
@ -438,7 +447,7 @@ namespace Oxygen
SizeGrip* _sizeGrip;
//! configuration
Configuration _configuration;
Factory::ConfigurationPtr _configuration;
//! glow animation
Animation* _glowAnimation;
@ -481,4 +490,56 @@ namespace Oxygen
} // namespace Oxygen
#endif // EXAMPLECLIENT_H
//____________________________________________________
Qt::Alignment Oxygen::Client::titleAlignment( void ) const
{
switch( _configuration->titleAlignment() )
{
case Configuration::AlignLeft: return Qt::AlignLeft;
case Configuration::AlignRight: return Qt::AlignRight;
default:
case Configuration::AlignCenter:
case Configuration::AlignCenterFullWidth:
return Qt::AlignCenter;
}
}
//____________________________________________________
int Oxygen::Client::buttonSize( void ) const
{
switch( _configuration->buttonSize() )
{
case Configuration::ButtonSmall: return 18;
default:
case Configuration::ButtonDefault: return 20;
case Configuration::ButtonLarge: return 24;
case Configuration::ButtonVeryLarge: return 32;
case Configuration::ButtonHuge: return 48;
}
}
//____________________________________________________
int Oxygen::Client::frameBorder( void ) const
{
switch( _configuration->frameBorder() )
{
case Configuration::BorderNone: return 0;
case Configuration::BorderNoSide: return 1;
default:
case Configuration::BorderTiny: return 2;
case Configuration::BorderDefault: return 4;
case Configuration::BorderLarge: return 8;
case Configuration::BorderVeryLarge: return 12;
case Configuration::BorderHuge: return 18;
case Configuration::BorderVeryHuge: return 27;
case Configuration::BorderOversized: return 40;
}
}
#endif

View File

@ -294,7 +294,7 @@ namespace Oxygen
} else {
QPoint position(
item._boundingRect.right() - _client.configuration().buttonSize() - _client.layoutMetric(KCommonDecoration::LM_TitleEdgeRight),
item._boundingRect.right() - _client.buttonSize() - _client.layoutMetric(KCommonDecoration::LM_TitleEdgeRight),
item._boundingRect.top() + _client.layoutMetric( KCommonDecoration::LM_TitleEdgeTop ) );
if( item._closeButton.data()->isHidden() ) item._closeButton.data()->show();

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg>
<kcfgfile name="oxygenrc"/>
<group name="Windeco">
<entry name="TitleAlignment" type="Enum">
<choices>
<choice name="AlignLeft" />
<choice name="AlignCenter" />
<choice name="AlignCenterFullWidth" />
<choice name="AlignRight" />
</choices>
<default>AlignCenterFullWidth</default>
</entry>
<entry name="ButtonSize" type="Enum">
<choices>
<choice name="ButtonSmall" />
<choice name="ButtonDefault" />
<choice name="ButtonLarge" />
<choice name="ButtonVeryLarge" />
<choice name="ButtonHuge" />
</choices>
<default>ButtonDefault</default>
</entry>
<entry name="SeparatorMode" type = "Enum">
<choices>
<choice name="SeparatorNever" />
<choice name="SeparatorActive" />
<choice name="SeparatorAlways" />
</choices>
<default>SeparatorNever</default>
</entry>
<entry name="FrameBorder" type = "Enum">
<choices>
<choice name="BorderNone" />
<choice name="BorderNoSide" />
<choice name="BorderTiny" />
<choice name="BorderDefault" />
<choice name="BorderLarge" />
<choice name="BorderVeryLarge" />
<choice name="BorderHuge" />
<choice name="BorderVeryHuge" />
<choice name="BorderOversized" />
</choices>
<default>BorderTiny</default>
</entry>
<entry name="BlendStyle" type = "Enum">
<choices>
<choice name="BlendNone" />
<choice name="BlendRadial" />
<choice name="BlendFromStyle" />
</choices>
<default>BlendFromStyle</default>
</entry>
<entry name="drawSizeGrip" type = "Bool">
<default>true</default>
</entry>
<entry name="DrawTitleOutline" type = "Bool">
<default>false</default>
</entry>
<entry name="HideTitleBar" type = "Bool">
<default>false</default>
</entry>
<entry name="UseNarrowButtonSpacing" type = "Bool">
<default>false</default>
</entry>
<entry name="CloseWindowFromMenuButton" type = "Bool">
<default>false</default>
</entry>
<entry name="UseExtendedWindowBorders" type = "Bool">
<default>true</default>
</entry>
<!-- animations -->
<entry name="AnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ButtonAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="TitleAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ShadowAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="TabAnimationsEnabled" type = "Bool">
<default>true</default>
</entry>
<entry name="ButtonAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="TitleAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="ShadowAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<entry name="TabAnimationsDuration" type = "Int">
<default>150</default>
</entry>
<!-- exceptions -->
<entry name="ExceptionType" type="Enum">
<choices>
<choice name="ExceptionWindowClassName" />
<choice name="ExceptionWindowTitle" />
</choices>
<default>ExceptionWindowClassName</default>
</entry>
<entry name="ExceptionPattern" type = "String"/>
<entry name="Enabled" type = "Bool">
<default>true</default>
</entry>
<entry name="Mask" type = "Int">
<default>0</default>
</entry>
</group>
</kcfg>

View File

@ -1,432 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenconfiguration.cpp
// decoration configuration
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenconfiguration.h"
#include "oxygenshadowconfiguration.h"
#include "oxygenexception.h"
#include <QTextStream>
#include <KLocale>
namespace Oxygen
{
//__________________________________________________
Configuration::Configuration( void ):
_titleAlignment( Qt::AlignHCenter ),
_centerTitleOnFullWidth( true ),
_buttonSize( ButtonDefault ),
_frameBorder( BorderTiny ),
_blendColor( BlendFromStyle ),
_sizeGripMode( SizeGripWhenNeeded ),
_separatorMode( SeparatorNever ),
_drawTitleOutline( false ),
_hideTitleBar( false ),
_useDropShadows( true ),
_useOxygenShadows( true ),
_closeFromMenuButton( false ),
_useNarrowButtonSpacing( false ),
_useExtendedWindowBorder( true ),
_animationsEnabled( true ),
_buttonAnimationsEnabled( true ),
_titleAnimationsEnabled( true ),
_shadowAnimationsEnabled( true ),
_tabAnimationsEnabled( true ),
_buttonAnimationsDuration( 150 ),
_titleAnimationsDuration( 150 ),
_shadowAnimationsDuration( 150 ),
_tabAnimationsDuration( 150 )
{}
//__________________________________________________
Configuration::Configuration( KConfigGroup group )
{
// used to set default values when entries are not found in kconfig
Configuration defaultConfiguration;
// title alignment
setTitleAlignment( titleAlignment(
group.readEntry( OxygenConfig::TITLE_ALIGNMENT,
defaultConfiguration.titleAlignmentName( false ) ), false ) );
// center title on full width
setCenterTitleOnFullWidth( group.readEntry( OxygenConfig::CENTER_TITLE_ON_FULL_WIDTH,
defaultConfiguration.centerTitleOnFullWidth() ) );
// button size
setButtonSize( buttonSize(
group.readEntry( OxygenConfig::BUTTON_SIZE,
defaultConfiguration.buttonSizeName( false ) ), false ) );
// frame border
setFrameBorder( frameBorder(
group.readEntry( OxygenConfig::FRAME_BORDER,
defaultConfiguration.frameBorderName( false ) ), false ) );
// blend color
setBlendColor( blendColor(
group.readEntry( OxygenConfig::BLEND_COLOR,
defaultConfiguration.blendColorName( false ) ), false ) );
// size grip
setSizeGripMode( sizeGripMode(
group.readEntry( OxygenConfig::SIZE_GRIP_MODE,
defaultConfiguration.sizeGripModeName( false ) ), false ) );
// separator mode
if( !group.readEntry( OxygenConfig::DRAW_SEPARATOR, defaultConfiguration.separatorMode() != SeparatorNever ) )
{
setSeparatorMode( SeparatorNever );
} else if( group.readEntry( OxygenConfig::SEPARATOR_ACTIVE_ONLY, defaultConfiguration.separatorMode() == SeparatorActive ) ) {
setSeparatorMode( SeparatorActive );
} else setSeparatorMode( SeparatorAlways );
// title outline
setDrawTitleOutline( group.readEntry(
OxygenConfig::DRAW_TITLE_OUTLINE,
defaultConfiguration.drawTitleOutline() ) );
// hide title bar
setHideTitleBar( group.readEntry(
OxygenConfig::HIDE_TITLEBAR,
defaultConfiguration.hideTitleBar() ) );
// drop shadows
setUseDropShadows( group.readEntry(
OxygenConfig::USE_DROP_SHADOWS,
defaultConfiguration.useDropShadows() ) );
// oxygen shadows
setUseOxygenShadows( group.readEntry(
OxygenConfig::USE_OXYGEN_SHADOWS,
defaultConfiguration.useOxygenShadows() ) );
// close from menu button
setCloseFromMenuButton( group.readEntry(
OxygenConfig::CLOSE_FROM_MENU_BUTTON,
defaultConfiguration.closeFromMenuButton() ) );
// buttonSpacing
setUseNarrowButtonSpacing( group.readEntry(
OxygenConfig::NARROW_BUTTON_SPACING,
defaultConfiguration.useNarrowButtonSpacing() ) );
// extended window border
setUseExtendedWindowBorder( group.readEntry(
OxygenConfig::EXTENDED_WINDOW_BORDERS,
defaultConfiguration.useExtendedWindowBorder() ) );
// animations
setAnimationsEnabled( group.readEntry(
OxygenConfig::ANIMATIONS_ENABLED,
defaultConfiguration.animationsEnabled() ) );
setButtonAnimationsEnabled( group.readEntry(
OxygenConfig::BUTTON_ANIMATIONS_ENABLED,
defaultConfiguration.buttonAnimationsEnabled() ) );
setTitleAnimationsEnabled( group.readEntry(
OxygenConfig::TITLE_ANIMATIONS_ENABLED,
defaultConfiguration.titleAnimationsEnabled() ) );
setShadowAnimationsEnabled( group.readEntry(
OxygenConfig::SHADOW_ANIMATIONS_ENABLED,
defaultConfiguration.shadowAnimationsEnabled() ) );
setTabAnimationsEnabled( group.readEntry(
OxygenConfig::TAB_ANIMATIONS_ENABLED,
defaultConfiguration.tabAnimationsEnabled() ) );
// animations duration
setButtonAnimationsDuration( group.readEntry(
OxygenConfig::BUTTON_ANIMATIONS_DURATION,
defaultConfiguration.buttonAnimationsDuration() ) );
setTitleAnimationsDuration( group.readEntry(
OxygenConfig::TITLE_ANIMATIONS_DURATION,
defaultConfiguration.titleAnimationsDuration() ) );
setShadowAnimationsDuration( group.readEntry(
OxygenConfig::SHADOW_ANIMATIONS_DURATION,
defaultConfiguration.shadowAnimationsDuration() ) );
setTabAnimationsDuration( group.readEntry(
OxygenConfig::TAB_ANIMATIONS_DURATION,
defaultConfiguration.tabAnimationsDuration() ) );
}
//__________________________________________________
void Configuration::readException( const Exception& exception )
{
// propagate all features found in mask to the output configuration
if( exception.mask() & Exception::FrameBorder ) setFrameBorder( exception.frameBorder() );
if( exception.mask() & Exception::BlendColor ) setBlendColor( exception.blendColor() );
if( exception.mask() & Exception::DrawSeparator ) setSeparatorMode( exception.separatorMode() );
if( exception.mask() & Exception::TitleOutline ) setDrawTitleOutline( exception.drawTitleOutline() );
if( exception.mask() & Exception::SizeGripMode ) setSizeGripMode( exception.sizeGripMode() );
setHideTitleBar( exception.hideTitleBar() );
}
//__________________________________________________
void Configuration::write( KConfigGroup& group ) const
{
Configuration defaultConfiguration;
if( titleAlignment() != defaultConfiguration.titleAlignment() ) group.writeEntry( OxygenConfig::TITLE_ALIGNMENT, titleAlignmentName( false ) );
if( centerTitleOnFullWidth() != defaultConfiguration.centerTitleOnFullWidth() ) group.writeEntry( OxygenConfig::CENTER_TITLE_ON_FULL_WIDTH, centerTitleOnFullWidth() );
if( buttonSize() != defaultConfiguration.buttonSize() ) group.writeEntry( OxygenConfig::BUTTON_SIZE, buttonSizeName( false ) );
if( blendColor() != defaultConfiguration.blendColor() ) group.writeEntry( OxygenConfig::BLEND_COLOR, blendColorName( false ) );
if( frameBorder() != defaultConfiguration.frameBorder() ) group.writeEntry( OxygenConfig::FRAME_BORDER, frameBorderName( false ) );
if( sizeGripMode() != defaultConfiguration.sizeGripMode() ) group.writeEntry( OxygenConfig::SIZE_GRIP_MODE, sizeGripModeName( false ) );
if( separatorMode() != defaultConfiguration.separatorMode() )
{
group.writeEntry( OxygenConfig::DRAW_SEPARATOR, separatorMode() != SeparatorNever );
group.writeEntry( OxygenConfig::SEPARATOR_ACTIVE_ONLY, separatorMode() == SeparatorActive );
}
if( drawTitleOutline() != defaultConfiguration.drawTitleOutline() ) group.writeEntry( OxygenConfig::DRAW_TITLE_OUTLINE, drawTitleOutline() );
if( hideTitleBar() != defaultConfiguration.hideTitleBar() ) group.writeEntry( OxygenConfig::HIDE_TITLEBAR, hideTitleBar() );
if( useDropShadows() != defaultConfiguration.useDropShadows() ) group.writeEntry( OxygenConfig::USE_DROP_SHADOWS, useDropShadows() );
if( useOxygenShadows() != defaultConfiguration.useOxygenShadows() ) group.writeEntry( OxygenConfig::USE_OXYGEN_SHADOWS, useOxygenShadows() );
if( closeFromMenuButton() != defaultConfiguration.closeFromMenuButton() ) group.writeEntry( OxygenConfig::CLOSE_FROM_MENU_BUTTON, closeFromMenuButton() );
if( useNarrowButtonSpacing() != defaultConfiguration.useNarrowButtonSpacing() ) group.writeEntry( OxygenConfig::NARROW_BUTTON_SPACING, useNarrowButtonSpacing() );
if( useExtendedWindowBorder() != defaultConfiguration.useExtendedWindowBorder() ) group.writeEntry( OxygenConfig::EXTENDED_WINDOW_BORDERS, useExtendedWindowBorder() );
// animations
if( animationsEnabled() != defaultConfiguration.animationsEnabled() ) group.writeEntry( OxygenConfig::ANIMATIONS_ENABLED, animationsEnabled() );
if( buttonAnimationsEnabled() != defaultConfiguration.buttonAnimationsEnabled() ) group.writeEntry( OxygenConfig::BUTTON_ANIMATIONS_ENABLED, buttonAnimationsEnabled() );
if( titleAnimationsEnabled() != defaultConfiguration.titleAnimationsEnabled() ) group.writeEntry( OxygenConfig::TITLE_ANIMATIONS_ENABLED, titleAnimationsEnabled() );
if( shadowAnimationsEnabled() != defaultConfiguration.shadowAnimationsEnabled() ) group.writeEntry( OxygenConfig::SHADOW_ANIMATIONS_ENABLED, shadowAnimationsEnabled() );
if( tabAnimationsEnabled() != defaultConfiguration.tabAnimationsEnabled() ) group.writeEntry( OxygenConfig::TAB_ANIMATIONS_ENABLED, tabAnimationsEnabled() );
// animations duration
if( buttonAnimationsDuration() != defaultConfiguration.buttonAnimationsDuration() ) group.writeEntry( OxygenConfig::BUTTON_ANIMATIONS_DURATION, buttonAnimationsDuration() );
if( titleAnimationsDuration() != defaultConfiguration.titleAnimationsDuration() ) group.writeEntry( OxygenConfig::TITLE_ANIMATIONS_DURATION, titleAnimationsDuration() );
if( shadowAnimationsDuration() != defaultConfiguration.shadowAnimationsDuration() ) group.writeEntry( OxygenConfig::SHADOW_ANIMATIONS_DURATION, shadowAnimationsDuration() );
if( tabAnimationsDuration() != defaultConfiguration.tabAnimationsDuration() ) group.writeEntry( OxygenConfig::TAB_ANIMATIONS_DURATION, tabAnimationsDuration() );
}
//__________________________________________________
QString Configuration::titleAlignmentName( Qt::Alignment value, bool translated, bool fullWidth )
{
QString out;
switch( value )
{
case Qt::AlignLeft: out = translated ? i18n( "Left" ):"Left"; break;
case Qt::AlignHCenter:
{
if( fullWidth ) out = translated ? i18n( "Center (Full Width)" ):"Center (Full Width)";
else out = translated ? i18n( "Center" ):"Center";
} break;
case Qt::AlignRight: out = translated ? i18n( "Right" ):"Right"; break;
default: return Configuration().titleAlignmentName( translated );
}
return out;
}
//__________________________________________________
Qt::Alignment Configuration::titleAlignment( QString value, bool translated )
{
if (value == titleAlignmentName( Qt::AlignLeft, translated ) ) return Qt::AlignLeft;
else if (value == titleAlignmentName( Qt::AlignHCenter, translated, false ) || value == titleAlignmentName( Qt::AlignHCenter, translated, true ) ) return Qt::AlignHCenter;
else if (value == titleAlignmentName( Qt::AlignRight, translated ) ) return Qt::AlignRight;
else return Configuration().titleAlignment();
}
//__________________________________________________
QString Configuration::buttonSizeName( ButtonSize value, bool translated )
{
QString out;
switch( value )
{
case ButtonSmall: out = translated ? i18nc( "@item:inlistbox Button size:", "Small" ):"Small"; break;
case ButtonDefault: out = translated ? i18nc( "@item:inlistbox Button size:", "Normal" ):"Normal"; break;
case ButtonLarge: out = translated ? i18nc( "@item:inlistbox Button size:", "Large" ):"Large"; break;
case ButtonVeryLarge: out = translated ? i18nc( "@item:inlistbox Button size:", "Very Large" ):"Very Large"; break;
case ButtonHuge: out = translated ? i18nc( "@item:inlistbox Button size:", "Huge" ):"Huge"; break;
default: return Configuration().buttonSizeName( translated );
}
return out;
}
//__________________________________________________
Configuration::ButtonSize Configuration::buttonSize( QString value, bool translated )
{
if( value == buttonSizeName( ButtonSmall, translated ) ) return ButtonSmall;
else if( value == buttonSizeName( ButtonDefault, translated ) ) return ButtonDefault;
else if( value == buttonSizeName( ButtonLarge, translated ) ) return ButtonLarge;
else if( value == buttonSizeName( ButtonVeryLarge, translated ) ) return ButtonVeryLarge;
else if( value == buttonSizeName( ButtonHuge, translated ) ) return ButtonHuge;
else return Configuration().buttonSize();
}
//__________________________________________________
int Configuration::iconScale( ButtonSize value )
{
switch( value )
{
case ButtonSmall: return 13;
case ButtonDefault: return 16;
case ButtonLarge: return 20;
case ButtonVeryLarge: return 24;
case ButtonHuge: return 35;
default: return Configuration().iconScale();
}
}
//__________________________________________________
QString Configuration::frameBorderName( FrameBorder value, bool translated )
{
QString out;
switch( value )
{
case BorderNone: out = translated ? i18nc( "@item:inlistbox Border size:", "No Border" ):"No Border"; break;
case BorderNoSide: out = translated ? i18nc( "@item:inlistbox Border size:", "No Side Border" ):"No Side Border"; break;
case BorderTiny: out = translated ? i18nc( "@item:inlistbox Border size:", "Tiny" ):"Tiny"; break;
case BorderDefault: out = translated ? i18nc( "@item:inlistbox Border size:", "Normal" ):"Normal"; break;
case BorderLarge: out = translated ? i18nc( "@item:inlistbox Border size:", "Large" ):"Large"; break;
case BorderVeryLarge: out = translated ? i18nc( "@item:inlistbox Border size:", "Very Large" ):"Very Large"; break;
case BorderHuge: out = translated ? i18nc( "@item:inlistbox Border size:", "Huge" ):"Huge"; break;
case BorderVeryHuge: out = translated ? i18nc( "@item:inlistbox Border size:", "Very Huge" ):"Very Huge"; break;
case BorderOversized: out = translated ? i18nc( "@item:inlistbox Border size:", "Oversized" ):"Oversized"; break;
default: return Configuration().frameBorderName( translated );
}
return out;
}
//__________________________________________________
Configuration::FrameBorder Configuration::frameBorder( QString value, bool translated )
{
if( value == frameBorderName( BorderNone, translated ) ) return BorderNone;
else if( value == frameBorderName( BorderNoSide, translated ) ) return BorderNoSide;
else if( value == frameBorderName( BorderTiny, translated ) ) return BorderTiny;
else if( value == frameBorderName( BorderDefault, translated ) ) return BorderDefault;
else if( value == frameBorderName( BorderLarge, translated ) ) return BorderLarge;
else if( value == frameBorderName( BorderVeryLarge, translated ) ) return BorderVeryLarge;
else if( value == frameBorderName( BorderHuge, translated ) ) return BorderHuge;
else if( value == frameBorderName( BorderVeryHuge, translated ) ) return BorderVeryHuge;
else if( value == frameBorderName( BorderOversized, translated ) ) return BorderOversized;
else return Configuration().frameBorder();
}
//__________________________________________________
QString Configuration::blendColorName( BlendColorType value, bool translated )
{
QString out;
switch( value )
{
case NoBlending: out = translated ? i18n( "Solid Color" ):"Solid Color"; break;
case RadialBlending: out = translated ? i18n( "Radial Gradient" ):"Radial Gradient"; break;
case BlendFromStyle: out = translated ? i18n( "Follow Style Hint" ):"Follow Style Hint"; break;
default: return Configuration().blendColorName( translated );
}
return out;
}
//__________________________________________________
Configuration::BlendColorType Configuration::blendColor( QString value, bool translated )
{
if( value == blendColorName( NoBlending, translated ) ) return NoBlending;
else if( value == blendColorName( RadialBlending, translated ) ) return RadialBlending;
else if( value == blendColorName( BlendFromStyle, translated ) ) return BlendFromStyle;
else return Configuration().blendColor();
}
//__________________________________________________
QString Configuration::sizeGripModeName( SizeGripMode value, bool translated )
{
QString out;
switch( value )
{
case SizeGripNever: out = translated ? i18n( "Always Hide Extra Size Grip" ):"Always Hide Extra Size Grip"; break;
case SizeGripWhenNeeded: out = translated ? i18n( "Show Extra Size Grip When Needed" ):"Show Extra Size Grip When Needed"; break;
default: return Configuration().sizeGripModeName( translated );
}
return out;
}
//__________________________________________________
Configuration::SizeGripMode Configuration::sizeGripMode( QString value, bool translated )
{
if( value == sizeGripModeName( SizeGripNever, translated ) ) return SizeGripNever;
else if( value == sizeGripModeName( SizeGripWhenNeeded, translated ) ) return SizeGripWhenNeeded;
else return Configuration().sizeGripMode();
}
//________________________________________________________
bool Configuration::operator == (const Configuration& other ) const
{
return
titleAlignment() == other.titleAlignment() &&
centerTitleOnFullWidth() == other.centerTitleOnFullWidth() &&
buttonSize() == other.buttonSize() &&
frameBorder() == other.frameBorder() &&
blendColor() == other.blendColor() &&
sizeGripMode() == other.sizeGripMode() &&
separatorMode() == other.separatorMode() &&
drawTitleOutline() == other.drawTitleOutline() &&
hideTitleBar() == other.hideTitleBar() &&
useDropShadows() == other.useDropShadows() &&
useOxygenShadows() == other.useOxygenShadows() &&
closeFromMenuButton() == other.closeFromMenuButton() &&
useNarrowButtonSpacing() == other.useNarrowButtonSpacing() &&
useExtendedWindowBorder() == other.useExtendedWindowBorder() &&
animationsEnabled() == other.animationsEnabled() &&
buttonAnimationsEnabled() == other.buttonAnimationsEnabled() &&
titleAnimationsEnabled() == other.titleAnimationsEnabled() &&
shadowAnimationsEnabled() == other.shadowAnimationsEnabled() &&
tabAnimationsEnabled() == other.tabAnimationsEnabled() &&
buttonAnimationsDuration() == other.buttonAnimationsDuration() &&
titleAnimationsDuration() == other.titleAnimationsDuration() &&
shadowAnimationsDuration() == other.shadowAnimationsDuration() &&
tabAnimationsDuration() == other.tabAnimationsDuration();
}
}

View File

@ -1,461 +0,0 @@
#ifndef oxygenconfiguration_h
#define oxygenconfiguration_h
//////////////////////////////////////////////////////////////////////////////
// oxygenconfiguration.h
// decoration configuration
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <KConfigGroup>
namespace OxygenConfig
{
static const QString TITLE_ALIGNMENT = "TitleAlignment";
static const QString CENTER_TITLE_ON_FULL_WIDTH = "CenterTitleOnFullWidth";
static const QString BUTTON_SIZE = "ButtonSize";
static const QString DRAW_SEPARATOR = "DrawSeparator";
static const QString SEPARATOR_ACTIVE_ONLY = "SeparatorActiveOnly";
static const QString DRAW_TITLE_OUTLINE = "DrawTitleOutline";
static const QString FRAME_BORDER = "FrameBorder";
static const QString BLEND_COLOR = "BlendColor";
static const QString SIZE_GRIP_MODE = "SizeGripMode";
static const QString HIDE_TITLEBAR = "HideTitleBar";
static const QString ANIMATIONS_ENABLED = "AnimationsEnabled";
static const QString NARROW_BUTTON_SPACING = "UseNarrowButtonSpacing";
static const QString CLOSE_FROM_MENU_BUTTON = "CloseFromMenuButton";
static const QString EXTENDED_WINDOW_BORDERS = "UseExtendedWindowBorders";
//!@name animation flags
//@{
static const QString BUTTON_ANIMATIONS_ENABLED = "ButtonAnimationsEnabled";
static const QString TITLE_ANIMATIONS_ENABLED = "TitleAnimationsEnabled";
static const QString SHADOW_ANIMATIONS_ENABLED = "ShadowAnimationsEnabled";
static const QString TAB_ANIMATIONS_ENABLED = "TabAnimationsEnabled";
//@}
//!@name animations duration
//@{
static const QString BUTTON_ANIMATIONS_DURATION = "ButtonAnimationsDuration";
static const QString TITLE_ANIMATIONS_DURATION = "TitleAnimationsDuration";
static const QString SHADOW_ANIMATIONS_DURATION = "ShadowAnimationsDuration";
static const QString TAB_ANIMATIONS_DURATION = "TabAnimationsDuration";
//@}
}
namespace Oxygen
{
// forward declaration
class Exception;
//! stores all configuration options needed for decoration appearance
class Configuration
{
public:
//! button size enumeration
enum ButtonSize {
ButtonSmall = 18,
ButtonDefault = 20,
ButtonLarge = 24,
ButtonVeryLarge = 32,
ButtonHuge = 48
};
//! frame border enumeration
enum FrameBorder {
BorderNone = 0,
BorderNoSide = 1,
BorderTiny = 2,
BorderDefault = 4,
BorderLarge = 8,
BorderVeryLarge = 12,
BorderHuge = 18,
BorderVeryHuge = 27,
BorderOversized = 40
};
//! blend color enumeration
enum BlendColorType {
NoBlending,
RadialBlending,
BlendFromStyle
};
//! size grip mode
enum SizeGripMode {
SizeGripNever,
SizeGripWhenNeeded
};
//! decide when separator is to be drawn
enum SeparatorMode {
//! never
SeparatorNever,
//! active window only
SeparatorActive,
//! always
SeparatorAlways
};
//! default constructor
Configuration( void );
//! constructor from KConfig
explicit Configuration( KConfigGroup );
//! destructor
virtual ~Configuration( void )
{}
//! equal to operator
bool operator == ( const Configuration& ) const;
//! propagate all features found in exception mask to this configuration
void readException( const Exception& );
//! write to kconfig group
virtual void write( KConfigGroup& ) const;
//!@name title alignment
//@{
static QString titleAlignmentName( Qt::Alignment, bool translated, bool fullWidth = false );
static Qt::Alignment titleAlignment( QString, bool translated );
virtual Qt::Alignment titleAlignment() const
{ return _titleAlignment; }
virtual QString titleAlignmentName( bool translated ) const
{ return titleAlignmentName( titleAlignment(), translated, centerTitleOnFullWidth() ); }
virtual void setTitleAlignment( Qt::Alignment value )
{ _titleAlignment = value; }
virtual void setTitleAlignment( QString value, bool translated )
{ _titleAlignment = titleAlignment( value, translated ); }
virtual bool centerTitleOnFullWidth( void ) const
{ return _centerTitleOnFullWidth; }
virtual void setCenterTitleOnFullWidth( bool value )
{ _centerTitleOnFullWidth = value; }
//@}
//!@name button size
//@{
static QString buttonSizeName( ButtonSize, bool translated );
static ButtonSize buttonSize( QString, bool translated );
static int iconScale( ButtonSize );
virtual ButtonSize buttonSize( void ) const
{ return _buttonSize; }
virtual int iconScale( void ) const
{ return iconScale( buttonSize() ); }
virtual QString buttonSizeName( bool translated ) const
{ return buttonSizeName( buttonSize(), translated ); }
virtual void setButtonSize( ButtonSize value )
{ _buttonSize = value; }
virtual bool useNarrowButtonSpacing( void ) const
{ return _useNarrowButtonSpacing; }
virtual void setUseNarrowButtonSpacing( bool value )
{ _useNarrowButtonSpacing = value; }
//@}
//!@name frame border
//@{
static QString frameBorderName( FrameBorder, bool translated );
static FrameBorder frameBorder( QString, bool translated );
virtual FrameBorder frameBorder() const
{ return _frameBorder; }
virtual QString frameBorderName( bool translated ) const
{ return frameBorderName( frameBorder(), translated ); }
virtual void setFrameBorder( FrameBorder value )
{ _frameBorder = value; }
virtual void setFrameBorder( QString value, bool translated )
{ _frameBorder = frameBorder( value, translated ); }
virtual bool useExtendedWindowBorder( void ) const
{ return _useExtendedWindowBorder; }
virtual void setUseExtendedWindowBorder( bool value )
{ _useExtendedWindowBorder = value; }
//@}
//!@name blend color
//@{
static QString blendColorName( BlendColorType, bool translated );
static BlendColorType blendColor( QString, bool translated );
virtual BlendColorType blendColor( void ) const
{ return _blendColor; }
virtual QString blendColorName( bool translated ) const
{ return blendColorName( blendColor(), translated ); }
virtual void setBlendColor( BlendColorType value )
{ _blendColor = value; }
virtual void setBlendColor( QString value, bool translated )
{ _blendColor = blendColor( value, translated ); }
//@}
//!@name size grip
//@{
static QString sizeGripModeName( SizeGripMode, bool translated );
static SizeGripMode sizeGripMode( QString, bool translated );
virtual SizeGripMode sizeGripMode( void ) const
{ return _sizeGripMode; }
virtual QString sizeGripModeName( bool translated ) const
{ return sizeGripModeName( sizeGripMode(), translated ); }
virtual void setSizeGripMode( SizeGripMode value )
{ _sizeGripMode = value; }
virtual void setSizeGripMode( QString value, bool translated )
{ _sizeGripMode = sizeGripMode( value, translated ); }
//! draw size grip
virtual bool drawSizeGrip( void ) const
{ return (sizeGripMode() == SizeGripWhenNeeded && frameBorder() == BorderNone ); }
//@}
//! separator
virtual SeparatorMode separatorMode( void ) const
{ return _separatorMode; }
//! separator
virtual void setSeparatorMode( SeparatorMode value )
{ _separatorMode = value; }
//! title outline
virtual bool drawTitleOutline( void ) const
{ return _drawTitleOutline; }
//! title outline
virtual void setDrawTitleOutline( bool value )
{ _drawTitleOutline = value; }
//! hide title bar
virtual bool hideTitleBar( void ) const
{ return _hideTitleBar; }
//! hide title bar
virtual void setHideTitleBar( bool value )
{ _hideTitleBar = value; }
//! drop shadows
virtual bool useDropShadows( void ) const
{ return _useDropShadows; }
//! drop shadows
virtual void setUseDropShadows( bool value )
{ _useDropShadows = value; }
//! oxygen shadows
virtual bool useOxygenShadows( void ) const
{ return _useOxygenShadows; }
//! oxygen shadows
virtual void setUseOxygenShadows( bool value )
{ _useOxygenShadows = value; }
//! close from menu button
virtual bool closeFromMenuButton( void ) const
{ return _closeFromMenuButton; }
//! close from menu button
virtual void setCloseFromMenuButton( bool value )
{ _closeFromMenuButton = value; }
//!@name animations
//@{
//! global flag
virtual bool animationsEnabled( void ) const
{ return _animationsEnabled; }
//! global flag
virtual void setAnimationsEnabled( bool value )
{ _animationsEnabled = value; }
//! buttons
virtual bool buttonAnimationsEnabled( void ) const
{ return _buttonAnimationsEnabled; }
//! buttons
virtual void setButtonAnimationsEnabled( bool value )
{ _buttonAnimationsEnabled = value; }
//! buttons
virtual int buttonAnimationsDuration( void ) const
{ return _buttonAnimationsDuration; }
//! buttons
virtual void setButtonAnimationsDuration( int value )
{ _buttonAnimationsDuration = value; }
//! titles
virtual bool titleAnimationsEnabled( void ) const
{ return _titleAnimationsEnabled; }
//! title
virtual void setTitleAnimationsEnabled( bool value )
{ _titleAnimationsEnabled = value; }
//! title
virtual int titleAnimationsDuration( void ) const
{ return _titleAnimationsDuration; }
//! title
virtual void setTitleAnimationsDuration( int value )
{ _titleAnimationsDuration = value; }
//! shadows
virtual bool shadowAnimationsEnabled( void ) const
{ return _shadowAnimationsEnabled; }
//! shadows
virtual void setShadowAnimationsEnabled( bool value )
{ _shadowAnimationsEnabled = value; }
//! shadows
virtual int shadowAnimationsDuration( void ) const
{ return _shadowAnimationsDuration; }
//! shadows
virtual void setShadowAnimationsDuration( int value )
{ _shadowAnimationsDuration = value; }
//! tabs
virtual bool tabAnimationsEnabled( void ) const
{ return _tabAnimationsEnabled; }
//! tabs
virtual void setTabAnimationsEnabled( bool value )
{ _tabAnimationsEnabled = value; }
//! tabs
virtual int tabAnimationsDuration( void ) const
{ return _tabAnimationsDuration; }
//! tabs
virtual void setTabAnimationsDuration( int value )
{ _tabAnimationsDuration = value; }
//@}
private:
//! title alignment
Qt::Alignment _titleAlignment;
//! full width alignment (makes sense only for Center alignment
bool _centerTitleOnFullWidth;
//! button size
ButtonSize _buttonSize;
//! blend color
FrameBorder _frameBorder;
//! frame border
BlendColorType _blendColor;
//! size grip mode
SizeGripMode _sizeGripMode;
//! separator
SeparatorMode _separatorMode;
//! active window title outline
bool _drawTitleOutline;
//! hide titlebar completely (but not window border)
bool _hideTitleBar;
//! drop shadows
bool _useDropShadows;
//! oxygen shadows
bool _useOxygenShadows;
//! close window from menu button
bool _closeFromMenuButton;
//! narrow button spacing
bool _useNarrowButtonSpacing;
//! extended window borders
bool _useExtendedWindowBorder;
//!@name animation flags
//@{
bool _animationsEnabled;
bool _buttonAnimationsEnabled;
bool _titleAnimationsEnabled;
bool _shadowAnimationsEnabled;
bool _tabAnimationsEnabled;
//@}
//!@name animation durations
//@{
int _buttonAnimationsDuration;
int _titleAnimationsDuration;
int _shadowAnimationsDuration;
int _tabAnimationsDuration;
//@}
};
}
#endif

View File

@ -0,0 +1,6 @@
File=oxygenconfigdata.kcfgc
ClassName=Configuration
NameSpace=Oxygen
Singleton=false
Mutators=true
GlobalEnums=true

View File

@ -1,7 +1,7 @@
#ifndef ShadowConfigurationUi_h
#define ShadowConfigurationUi_h
#ifndef oxygendecorationdefines_h
#define oxygendecorationdefines_h
//////////////////////////////////////////////////////////////////////////////
// ShadowConfigurationUi.h
// oxygendecorationdefines.h
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
@ -25,35 +25,58 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <QtGui/QCheckBox>
#include <QtGui/QGroupBox>
#include <ui_oxygenshadowconfigurationui.h>
#include "oxygenconfiguration.h"
#include <QtCore/QSharedPointer>
#include <QtCore/QList>
namespace Oxygen
{
//_____________________________________________
class ShadowConfigurationUi: public QGroupBox
//! this should move to some global declaration
typedef QSharedPointer<Configuration> ConfigurationPtr;
typedef QList<ConfigurationPtr> ConfigurationList;
typedef QListIterator<ConfigurationPtr> ConfigurationListIterator;
//! buttons
enum ButtonType {
ButtonHelp=0,
ButtonMax,
ButtonMin,
ButtonClose,
ButtonMenu,
ButtonSticky,
ButtonAbove,
ButtonBelow,
ButtonShade,
ButtonApplicationMenu,
ButtonTypeCount,
// Close only one tab
ButtonItemClose=100,
// shows the window menu for one tab
ButtonItemMenu
};
//! buttons status
enum ButtonStatus {
Normal = 0,
Hovered = 1<<0,
Pressed = 1<<1
};
//! exception
enum ExceptionMask
{
Q_OBJECT
public:
//! constructor
explicit ShadowConfigurationUi( QWidget* );
Ui_ShadowConfiguraionUI ui;
signals:
//! emmitted when configuration is changed
void changed( void );
protected slots:
//! update enable state of outer color chooser
void enableOuterColor( void )
{ ui.outerColor->setEnabled( isChecked() && ui.useOuterColor->isChecked() ); }
None = 0,
TitleAlignment = 1<<0,
DrawSeparator = 1<<2,
TitleOutline = 1<<3,
FrameBorder = 1<<4,
BlendColor = 1<<5,
SizeGripMode = 1<<6,
};
}

View File

@ -1,95 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// oxygenexception.cpp
// window decoration exception
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenexception.h"
#include <cassert>
#include <KLocale>
namespace Oxygen
{
//_______________________________________________________
Exception::Exception( KConfigGroup group ):
Configuration( group )
{
// used to set default values when entries are not found in kconfig
Exception default_configuration;
// exception type
setType( type(
group.readEntry( OxygenConfig::TYPE,
default_configuration.typeName( false ) ), false ) );
// exception pattern
regExp().setPattern( group.readEntry( OxygenConfig::PATTERN, QString() ) );
// enability
setEnabled(
group.readEntry( OxygenConfig::ENABLED,
default_configuration.enabled() ) );
// exception mask
setMask(
group.readEntry( OxygenConfig::MASK,
default_configuration.mask() ) );
}
//_______________________________________________________
void Exception::write( KConfigGroup& group ) const
{
Configuration::write( group );
group.writeEntry( OxygenConfig::TYPE, typeName( false ) );
group.writeEntry( OxygenConfig::PATTERN, regExp().pattern() );
group.writeEntry( OxygenConfig::ENABLED, enabled() );
group.writeEntry( OxygenConfig::MASK, mask() );
}
//_______________________________________________________
QString Exception::typeName( Type type, bool translated )
{
switch( type )
{
case WindowTitle: return translated ? i18n( "Window Title" ):"Window Title";
case WindowClassName: return translated ? i18n( "Window Class Name" ):"Window Class Name";
default: assert( false );
}
return QString();
}
//_______________________________________________________
Exception::Type Exception::type( const QString& value, bool translated )
{
if( value == typeName( WindowTitle, translated ) ) return WindowTitle;
else if( value == typeName( WindowClassName, translated ) ) return WindowClassName;
else return WindowClassName;
}
}

View File

@ -1,181 +0,0 @@
#ifndef oxygenexception_h
#define oxygenexception_h
//////////////////////////////////////////////////////////////////////////////
// oxygenexception.h
// window decoration exception
// -------------------
//
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <QtCore/QRegExp>
#include "oxygenconfiguration.h"
namespace OxygenConfig
{
//! needed for exceptions
static const QString TYPE = "Type";
static const QString PATTERN = "Pattern";
static const QString ENABLED = "Enabled";
static const QString MASK = "Mask";
}
namespace Oxygen
{
//! oxygen exception
class Exception: public Configuration
{
public:
//! exception type
enum Type {
WindowTitle,
WindowClassName
};
//! mask
enum AttributesMask {
None = 0,
TitleAlignment = 1<<0,
DrawSeparator = 1<<2,
TitleOutline = 1<<3,
FrameBorder = 1<<4,
BlendColor = 1<<5,
SizeGripMode = 1<<6,
All = TitleAlignment|DrawSeparator|TitleOutline|FrameBorder|BlendColor|SizeGripMode
};
//! constructor
Exception( Configuration configuration = Configuration() ):
Configuration( configuration ),
_enabled( true ),
_type( WindowClassName ),
_mask( None )
{}
//! constructor
explicit Exception( KConfigGroup );
//! destructor
virtual ~Exception( void )
{}
//! equal to operator
bool operator == (const Exception& exception ) const
{
return
enabled() == exception.enabled() &&
type() == exception.type() &&
regExp().pattern() == exception.regExp().pattern() &&
mask() == exception.mask() &&
Configuration::operator == ( exception );
}
//! less than operator
bool operator < (const Exception& exception ) const
{
if( enabled() != exception.enabled() ) return enabled() < exception.enabled();
else if( mask() != exception.mask() ) return mask() < exception.mask();
else if( type() != exception.type() ) return type() < exception.type();
else return regExp().pattern() < exception.regExp().pattern();
}
//! write to kconfig group
virtual void write( KConfigGroup& ) const;
//!@name enability
//@{
bool enabled( void ) const
{ return _enabled; }
void setEnabled( bool enabled )
{ _enabled = enabled; }
//@}
//!@name exception type
//@{
static QString typeName( Type, bool );
static Type type( const QString& name, bool );
virtual QString typeName( bool translated ) const
{ return typeName( type(), translated ); }
virtual Type type( void ) const
{ return _type; }
virtual void setType( Type value )
{ _type = value; }
//@}
//!@name regular expression
//@{
virtual QRegExp regExp( void ) const
{ return _regExp; }
virtual QRegExp& regExp( void )
{ return _regExp; }
//@}
//! mask
//!@{
unsigned int mask( void ) const
{ return _mask; }
void setMask( unsigned int mask )
{ _mask = mask; }
//@}
private:
//! enability
bool _enabled;
//! exception type
Type _type;
//! regular expression to match window caption
QRegExp _regExp;
//! attributes mask
unsigned int _mask;
};
}
#endif

View File

@ -25,6 +25,7 @@
//////////////////////////////////////////////////////////////////////////////
#include "oxygenexceptionlist.h"
#include "oxygenutil.h"
#include <QtCore/QTextStream>
@ -32,61 +33,82 @@ namespace Oxygen
{
//______________________________________________________________
void ExceptionList::read( const KConfig& config )
void ExceptionList::readConfig( KConfig& config )
{
clear();
_exceptions.clear();
for( int index = 0; true; index++ )
QString groupName;
for( int index = 0; KConfigGroup( &config, groupName = exceptionGroupName( index ) ).exists(); ++index )
{
// create exception
Configuration exception;
// reset group
Util::readConfig( &exception, &config, groupName );
// create new configuration
ConfigurationPtr configuration( new Configuration() );
Util::readConfig( configuration.data(), &config );
// apply changes from exception
configuration->setEnabled( exception.enabled() );
configuration->setExceptionType( exception.exceptionType() );
configuration->setExceptionPattern( exception.exceptionPattern() );
configuration->setMask( exception.mask() );
// propagate all features found in mask to the output configuration
if( exception.mask() & FrameBorder ) configuration->setFrameBorder( exception.frameBorder() );
if( exception.mask() & BlendColor ) configuration->setBlendStyle( exception.blendStyle() );
if( exception.mask() & DrawSeparator ) configuration->setSeparatorMode( exception.separatorMode() );
if( exception.mask() & TitleOutline ) configuration->setDrawTitleOutline( exception.drawTitleOutline() );
if( exception.mask() & SizeGripMode ) configuration->setDrawSizeGrip( exception.drawSizeGrip() );
configuration->setHideTitleBar( exception.hideTitleBar() );
// append to exceptions
_exceptions.append( configuration );
}
}
//______________________________________________________________
void ExceptionList::writeConfig( KConfig& config )
{
// remove all existing exceptions
int index(0);
while( true )
{
KConfigGroup group( &config, exceptionGroupName( index ) );
if( group.exists() )
{
Exception exception( group );
if( exception.regExp().isValid() ) push_back( exception );
group.deleteGroup();
++index;
} else break;
}
// rewrite current exceptions
index = 0;
foreach( const ConfigurationPtr& exception, _exceptions )
{
Util::writeConfig( exception.data(), &config, exceptionGroupName( index ) );
++index;
}
}
//______________________________________________________________
void ExceptionList::write( KConfig& config )
{
// remove previous group
for( int index = 0; true ;index++ )
{
KConfigGroup group( &config, exceptionGroupName( index ) );
if( group.exists() ) group.deleteGroup();
else break;
}
// also add exceptions
int index(0);
for( ExceptionList::const_iterator iter = constBegin(); iter != constEnd(); ++iter, index++ )
{
KConfigGroup group( &config, exceptionGroupName( index ) );
iter->write( group );
}
}
//______________________________________________________________
ExceptionList ExceptionList::defaultList( void )
{ return ExceptionList(); }
//_______________________________________________________________________
QString ExceptionList::exceptionGroupName( int index )
{
QString out;
QTextStream( &out ) << "Windeco Exception " << index;
return out;
QString out;
QTextStream( &out ) << "Windeco Exception " << index;
return out;
}
}

View File

@ -27,40 +27,45 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include <KConfig>
#include <QtCore/QList>
#include "oxygenconfiguration.h"
#include "oxygendecorationdefines.h"
#include "oxygenexception.h"
#include <KConfig>
namespace Oxygen
{
//! oxygen exceptions list
class ExceptionList: public QList<Exception>
class ExceptionList
{
public:
//! default constructor
ExceptionList( void )
//! constructor from list
explicit ExceptionList( const ConfigurationList& exceptions = ConfigurationList() ):
_exceptions( exceptions )
{}
//! default constructor
explicit ExceptionList( const KConfig& config )
{ read( config ); }
//! exceptions
const ConfigurationList& get( void ) const
{ return _exceptions; }
//! read from KConfig
void read( const KConfig& );
void readConfig( KConfig& );
//! write to kconfig
void write( KConfig& );
void writeConfig( KConfig& );
//! default exception list
static ExceptionList defaultList( void );
protected:
//! generate exception group name for given exception index
static QString exceptionGroupName( int index );
private:
//! exceptions
ConfigurationList _exceptions;
};
}

View File

@ -27,8 +27,8 @@
#include "oxygenfactory.h"
#include "oxygenfactory.moc"
#include "oxygenclient.h"
#include "oxygenexceptionlist.h"
#include <cassert>
#include <KConfigGroup>
#include <KDebug>
#include <KGlobal>
@ -63,36 +63,20 @@ namespace Oxygen
{
if( changed & SettingColors )
{ shadowCache().invalidateCaches(); }
{ _shadowCache.invalidateCaches(); }
// read in the configuration
setInitialized( false );
bool _configurationchanged = readConfig();
readConfig();
setInitialized( true );
if( _configurationchanged || (changed & (SettingDecoration | SettingButtons | SettingBorder)) )
{
// returning true triggers all decorations to be re-created
return true;
} else {
// no need to re-create the decorations
// trigger repaint only
resetDecorations(changed);
return false;
}
return true;
}
//___________________________________________________
bool Factory::readConfig()
void Factory::readConfig()
{
bool changed( false );
/*
always reload helper
this is needed to properly handle
@ -101,26 +85,22 @@ namespace Oxygen
helper().invalidateCaches();
helper().reloadConfig();
// initialize default configuration and read
if( !_defaultConfiguration ) _defaultConfiguration = ConfigurationPtr(new Configuration());
_defaultConfiguration->setCurrentGroup( "Windeco" );
_defaultConfiguration->readConfig();
// create a config object
KConfig config("oxygenrc");
KConfigGroup group( config.group("Windeco") );
Configuration configuration( group );
if( !( configuration == defaultConfiguration() ) )
{
setDefaultConfiguration( configuration );
changed = true;
}
// read exceptionsreadConfig
ExceptionList exceptions( config );
if( !( exceptions == _exceptions ) )
{
_exceptions = exceptions;
changed = true;
}
// clear exceptions and read
ExceptionList exceptions;
exceptions.readConfig( config );
_exceptions = exceptions.get();
// read shadowCache configuration
changed |= shadowCache().readConfig( config );
_shadowCache.readConfig();
_shadowCache.setAnimationsDuration( _defaultConfiguration->shadowAnimationsDuration() );
// background pixmap
{
@ -128,8 +108,6 @@ namespace Oxygen
helper().setBackgroundPixmap( group.readEntry( "BackgroundPixmap", "" ) );
}
return changed;
}
//_________________________________________________________________
@ -155,13 +133,8 @@ namespace Oxygen
case AbilityButtonSpacer:
case AbilityButtonShade:
// // colors
// case AbilityColorTitleBack:
// case AbilityColorTitleFore:
// case AbilityColorFrame:
// compositing
case AbilityProvidesShadow: // TODO: UI option to use default shadows instead
case AbilityProvidesShadow:
return true;
case AbilityUsesAlphaChannel:
@ -181,59 +154,59 @@ namespace Oxygen
//____________________________________________________________________
Configuration Factory::configuration( const Client& client )
Factory::ConfigurationPtr Factory::configuration( const Client& client )
{
QString window_title;
QString class_name;
for( ExceptionList::const_iterator iter = _exceptions.constBegin(); iter != _exceptions.constEnd(); ++iter )
QString windowTitle;
QString className;
foreach( const ConfigurationPtr& configuration, _exceptions )
{
// discard disabled exceptions
if( !iter->enabled() ) continue;
if( !configuration->enabled() ) continue;
// discard exceptions with empty exception pattern
if( configuration->exceptionPattern().isEmpty() ) continue;
/*
decide which value is to be compared
to the regular expression, based on exception type
*/
QString value;
switch( iter->type() )
switch( configuration->exceptionType() )
{
case Exception::WindowTitle:
case Configuration::ExceptionWindowTitle:
{
value = window_title.isEmpty() ? (window_title = client.caption()):window_title;
value = windowTitle.isEmpty() ? (windowTitle = client.caption()):windowTitle;
break;
}
case Exception::WindowClassName:
default:
case Configuration::ExceptionWindowClassName:
{
if( class_name.isEmpty() )
if( className.isEmpty() )
{
// retrieve class name
KWindowInfo info( client.windowId(), 0, NET::WM2WindowClass );
QString window_class_name( info.windowClassName() );
QString window_className( info.windowClassName() );
QString window_class( info.windowClassClass() );
class_name = window_class_name + ' ' + window_class;
className = window_className + ' ' + window_class;
}
value = class_name;
value = className;
break;
}
default: assert( false );
}
if( iter->regExp().indexIn( value ) < 0 ) continue;
Configuration configuration( defaultConfiguration() );
configuration.readException( *iter );
return configuration;
// check matching
if( QRegExp( configuration->exceptionPattern() ).indexIn( value ) >= 0 )
{ return configuration; }
}
return defaultConfiguration();
return _defaultConfiguration;
}
} //namespace Oxygen
}

View File

@ -27,44 +27,20 @@
// IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
#include "oxygenconfiguration.h"
#include "oxygendecorationdefines.h"
#include "oxygendecohelper.h"
#include "oxygenshadowcache.h"
#include <QtCore/QObject>
#include <kdecorationfactory.h>
#include <kdeversion.h>
#include "oxygenconfiguration.h"
#include "oxygendecohelper.h"
#include "oxygenexceptionlist.h"
#include "oxygenshadowcache.h"
namespace Oxygen
{
class Client;
//! buttons
enum ButtonType {
ButtonHelp=0,
ButtonMax,
ButtonMin,
ButtonClose,
ButtonMenu,
ButtonSticky,
ButtonAbove,
ButtonBelow,
ButtonShade,
ButtonApplicationMenu,
ButtonTypeCount,
// Close only one tab
ButtonItemClose=100,
// shows the window menu for one tab
ButtonItemMenu
};
Q_DECLARE_FLAGS(ButtonTypes, ButtonType)
enum {
//! this is the top title bar edge
@ -83,10 +59,10 @@ namespace Oxygen
Q_OBJECT
public:
public:
//! constructor
Factory();
//! constructor
Factory();
//! destructor
virtual ~Factory();
@ -116,29 +92,30 @@ namespace Oxygen
virtual const ShadowCache& shadowCache( void ) const
{ return _shadowCache; }
//! get configuration for a give client
virtual Configuration configuration( const Client& );
//! pointer to configuration
typedef QSharedPointer<Configuration> ConfigurationPtr;
private:
//! get configuration for a give client
virtual ConfigurationPtr configuration( const Client& );
protected:
//! read configuration from KConfig
bool readConfig();
//! default configuration
const Configuration& defaultConfiguration( void ) const
{ return _defaultConfiguration; }
//! default configuration
Configuration& defaultConfiguration( void )
{ return _defaultConfiguration; }
void readConfig();
//! initialization
void setInitialized( bool value )
{ _initialized = value; }
//! set default configuration
void setDefaultConfiguration( Configuration value )
{ _defaultConfiguration = value; }
//! exception group name
QString exceptionGroupName( int index ) const
{
QString out;
QTextStream( &out ) << "Windeco Exception " << index;
return out;
}
private:
//! initialization flag
bool _initialized;
@ -150,10 +127,10 @@ namespace Oxygen
ShadowCache _shadowCache;
//! default configuration
Configuration _defaultConfiguration;
ConfigurationPtr _defaultConfiguration;
//! exceptions
ExceptionList _exceptions;
//! list of exceptiosn
QList<ConfigurationPtr> _exceptions;
};