renamed ConfigurationUI into ConfigWidget.
moved all ui related stuff from oxygenConfig to oxygenConfigWidget. Implement clean 'updateChanged' method.
This commit is contained in:
parent
fcb275abe7
commit
ea639a0ec2
10 changed files with 335 additions and 275 deletions
|
@ -3,7 +3,7 @@ include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/oxygen)
|
|||
set(kwin_oxygen_config_PART_SRCS
|
||||
oxygenanimationconfigwidget.cpp
|
||||
oxygenconfig.cpp
|
||||
oxygenconfigurationui.cpp
|
||||
oxygenconfigwidget.cpp
|
||||
oxygendetectwidget.cpp
|
||||
oxygenexceptiondialog.cpp
|
||||
oxygenexceptionlistwidget.cpp
|
||||
|
|
|
@ -67,23 +67,22 @@ namespace Oxygen
|
|||
layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding ), _row, 1, 1, 1 );
|
||||
++_row;
|
||||
|
||||
connect( animationsEnabled(), SIGNAL(toggled(bool)), SLOT(updateChanged()) );
|
||||
connect( animationsEnabled(), SIGNAL( toggled( bool ) ), SLOT(updateChanged()) );
|
||||
foreach( AnimationConfigItem* item, findChildren<AnimationConfigItem*>() )
|
||||
{
|
||||
item->QWidget::setEnabled( false );
|
||||
connect( animationsEnabled(), SIGNAL(toggled(bool)), item, SLOT(setEnabled(bool)) );
|
||||
connect( animationsEnabled(), SIGNAL( toggled( bool ) ), item, SLOT(setEnabled(bool)) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_______________________________________________
|
||||
AnimationConfigWidget::~AnimationConfigWidget( void )
|
||||
{}
|
||||
|
||||
//_______________________________________________
|
||||
void AnimationConfigWidget::load( void )
|
||||
{
|
||||
|
||||
// check configuration
|
||||
if( !_configuration ) return;
|
||||
|
||||
animationsEnabled()->setChecked( _configuration->animationsEnabled() );
|
||||
|
||||
_buttonAnimations->setEnabled( _configuration->buttonAnimationsEnabled() );
|
||||
|
@ -103,6 +102,10 @@ namespace Oxygen
|
|||
void AnimationConfigWidget::save( void )
|
||||
{
|
||||
|
||||
// check configuration
|
||||
if( !_configuration ) return;
|
||||
|
||||
// save modifications
|
||||
_configuration->setAnimationsEnabled( animationsEnabled()->isChecked() );
|
||||
|
||||
_configuration->setButtonAnimationsEnabled( _buttonAnimations->enabled() );
|
||||
|
@ -125,8 +128,11 @@ namespace Oxygen
|
|||
void AnimationConfigWidget::updateChanged( void )
|
||||
{
|
||||
|
||||
bool modified( false );
|
||||
// check configuration
|
||||
if( !_configuration ) return;
|
||||
|
||||
// track modifications
|
||||
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;
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace Oxygen
|
|||
explicit AnimationConfigWidget( QWidget* = 0 );
|
||||
|
||||
//! destructor
|
||||
virtual ~AnimationConfigWidget( void );
|
||||
virtual ~AnimationConfigWidget( void )
|
||||
{}
|
||||
|
||||
//! configuration
|
||||
void setConfiguration( ConfigurationPtr configuration )
|
||||
|
|
|
@ -65,24 +65,24 @@ namespace Oxygen
|
|||
_configuration = new KConfig( "oxygenrc" );
|
||||
KConfigGroup configurationGroup( _configuration, "Windeco");
|
||||
|
||||
ui = new ConfigurationUi( parent );
|
||||
_configWidget = new ConfigWidget( parent );
|
||||
|
||||
load( configurationGroup );
|
||||
connect( ui, SIGNAL(changed()), SLOT(updateChanged()) );
|
||||
ui->show();
|
||||
connect( _configWidget, SIGNAL( changed( bool ) ), SLOT(updateChanged()) );
|
||||
_configWidget->show();
|
||||
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
Config::~Config()
|
||||
{
|
||||
delete ui;
|
||||
delete _configWidget;
|
||||
delete _configuration;
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
void Config::toggleExpertMode( bool value )
|
||||
{ ui->toggleExpertMode( value ); }
|
||||
{ _configWidget->toggleExpertMode( value ); }
|
||||
|
||||
//_______________________________________________________________________
|
||||
void Config::load( const KConfigGroup& )
|
||||
|
@ -94,13 +94,13 @@ namespace Oxygen
|
|||
loadConfiguration( configuration );
|
||||
|
||||
// load shadows
|
||||
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
|
||||
foreach( ShadowConfigurationUi* ui, _configWidget->shadowConfigurations )
|
||||
{ ui->readConfig( _configuration ); }
|
||||
|
||||
// load exceptions
|
||||
ExceptionList exceptions;
|
||||
exceptions.readConfig( *_configuration );
|
||||
ui->ui.exceptions->setExceptions( exceptions.get() );
|
||||
_configWidget->exceptionListWidget()->setExceptions( exceptions.get() );
|
||||
updateChanged();
|
||||
|
||||
}
|
||||
|
@ -113,26 +113,10 @@ namespace Oxygen
|
|||
configuration->readConfig();
|
||||
bool modified( false );
|
||||
|
||||
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]->isModified() ) modified = true;
|
||||
else if( ui->shadowConfigurations[1]->isModified() ) modified = true;
|
||||
|
||||
// exceptions
|
||||
if( _configWidget->isChanged() ) modified = true;
|
||||
else if( exceptionListChanged() ) modified = true;
|
||||
|
||||
// animations
|
||||
else if( !ui->expertMode() && ui->ui.animationsEnabled->isChecked() != configuration->animationsEnabled() ) modified = true;
|
||||
else if( ui->expertMode() && ui->animationConfigWidget()->isChanged() ) modified = true;
|
||||
|
||||
// emit relevant signals
|
||||
if( modified ) emit changed();
|
||||
emit changed( modified );
|
||||
|
@ -147,38 +131,19 @@ namespace Oxygen
|
|||
ConfigurationPtr configuration( new Configuration() );
|
||||
configuration->readConfig();
|
||||
|
||||
// apply modifications from ui
|
||||
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();
|
||||
|
||||
} else {
|
||||
|
||||
configuration->setAnimationsEnabled( ui->ui.animationsEnabled->isChecked() );
|
||||
|
||||
}
|
||||
// save config widget
|
||||
_configWidget->setConfiguration( configuration );
|
||||
_configWidget->save();
|
||||
|
||||
// save standard configuration
|
||||
Util::writeConfig( configuration.data(), _configuration );
|
||||
|
||||
// get list of exceptions and write
|
||||
ConfigurationList exceptions( ui->ui.exceptions->exceptions() );
|
||||
ConfigurationList exceptions( _configWidget->exceptionListWidget()->exceptions() );
|
||||
ExceptionList( exceptions ).writeConfig( *_configuration );
|
||||
|
||||
// write shadow configuration
|
||||
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
|
||||
foreach( ShadowConfigurationUi* ui, _configWidget->shadowConfigurations )
|
||||
{ ui->writeConfig( _configuration ); }
|
||||
|
||||
// sync configuration
|
||||
|
@ -199,12 +164,9 @@ namespace Oxygen
|
|||
loadConfiguration( configuration );
|
||||
|
||||
// load shadows
|
||||
foreach( ShadowConfigurationUi* ui, ui->shadowConfigurations )
|
||||
foreach( ShadowConfigurationUi* ui, _configWidget->shadowConfigurations )
|
||||
{ ui->readDefaults( _configuration ); }
|
||||
|
||||
// install default exceptions
|
||||
// ui->ui.exceptions->setExceptions( ExceptionList::defaultList() );
|
||||
|
||||
updateChanged();
|
||||
|
||||
}
|
||||
|
@ -213,35 +175,13 @@ namespace Oxygen
|
|||
void Config::loadConfiguration( ConfigurationPtr configuration )
|
||||
{
|
||||
|
||||
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();
|
||||
_configWidget->setConfiguration( configuration );
|
||||
_configWidget->load();
|
||||
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
bool Config::exceptionListChanged( void ) const
|
||||
{
|
||||
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();
|
||||
|
||||
}
|
||||
{ return true; }
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "oxygenconfigurationui.h"
|
||||
#include "oxygenconfigwidget.h"
|
||||
#include "oxygenconfiguration.h"
|
||||
#include "../oxygendecorationdefines.h"
|
||||
|
||||
|
@ -91,10 +91,10 @@ namespace Oxygen {
|
|||
bool exceptionListChanged( void ) const;
|
||||
|
||||
//! user interface
|
||||
ConfigurationUi *ui;
|
||||
ConfigWidget* _configWidget;
|
||||
|
||||
//! kconfiguration object
|
||||
KConfig *_configuration;
|
||||
KConfig* _configuration;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenconfigurationui.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 "oxygenconfigurationui.h"
|
||||
#include "oxygenanimationconfigwidget.h"
|
||||
|
||||
#include <kdeversion.h>
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <KLocale>
|
||||
#include <KTabWidget>
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
//_________________________________________________________
|
||||
ConfigurationUi::ConfigurationUi( QWidget* parent ):
|
||||
QWidget( parent ),
|
||||
_expertMode( false ),
|
||||
_animationConfigWidget(0)
|
||||
{
|
||||
|
||||
ui.setupUi( this );
|
||||
|
||||
// shadow configuration
|
||||
ui.activeShadowConfiguration->setGroup( QPalette::Active );
|
||||
ui.inactiveShadowConfiguration->setGroup( QPalette::Inactive );
|
||||
|
||||
shadowConfigurations.append( ui.activeShadowConfiguration );
|
||||
shadowConfigurations.append( ui.inactiveShadowConfiguration );
|
||||
|
||||
// connections
|
||||
connect( ui.titleOutline, SIGNAL(toggled(bool)), ui.separatorMode, SLOT(setDisabled(bool)) );
|
||||
|
||||
connect( shadowConfigurations[0], SIGNAL(changed()), SIGNAL(changed()) );
|
||||
connect( shadowConfigurations[0], SIGNAL(toggled(bool)), SIGNAL(changed()) );
|
||||
|
||||
connect( shadowConfigurations[1], SIGNAL(changed()), SIGNAL(changed()) );
|
||||
connect( shadowConfigurations[1], SIGNAL(toggled(bool)), SIGNAL(changed()) );
|
||||
|
||||
connect( ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
||||
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.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.exceptions, SIGNAL(changed()), SIGNAL(changed()) );
|
||||
|
||||
connect( ui._expertModeButton, SIGNAL(pressed()), SLOT(toggleExpertModeInternal()) );
|
||||
|
||||
ui._expertModeButton->setIcon( KIcon("configure") );
|
||||
|
||||
// animation config widget
|
||||
connect( ui.animationsEnabled, SIGNAL(clicked()), SIGNAL(changed()) );
|
||||
_animationConfigWidget = new AnimationConfigWidget();
|
||||
_animationConfigWidget->installEventFilter( this );
|
||||
connect( _animationConfigWidget, SIGNAL(changed(bool)), SIGNAL(changed()) );
|
||||
connect( _animationConfigWidget, SIGNAL(layoutChanged()), SLOT(updateLayout()) );
|
||||
|
||||
toggleExpertModeInternal( false );
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigurationUi::toggleExpertMode( bool value )
|
||||
{
|
||||
ui._expertModeContainer->hide();
|
||||
toggleExpertModeInternal( value );
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigurationUi::toggleExpertModeInternal( bool value )
|
||||
{
|
||||
|
||||
// store value
|
||||
_expertMode = value;
|
||||
|
||||
// update button text
|
||||
ui._expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
|
||||
|
||||
// narrow button spacing
|
||||
ui.narrowButtonSpacing->setVisible( _expertMode );
|
||||
|
||||
// size grip
|
||||
ui.drawSizeGrip->setVisible( _expertMode );
|
||||
|
||||
// 'basic' animations enabled flag
|
||||
ui.animationsEnabled->setVisible( !_expertMode );
|
||||
|
||||
// layout and animations
|
||||
if( _expertMode )
|
||||
{
|
||||
|
||||
// add animationConfigWidget to tabbar if needed
|
||||
if( ui.tabWidget->indexOf( _animationConfigWidget ) < 0 )
|
||||
{ ui.tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
|
||||
|
||||
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
} else {
|
||||
|
||||
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
|
||||
if( int index = ui.tabWidget->indexOf( _animationConfigWidget ) >= 0 )
|
||||
{ ui.tabWidget->removeTab( index ); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//__________________________________________________________________
|
||||
bool ConfigurationUi::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
|
||||
switch( event->type() )
|
||||
{
|
||||
case QEvent::ShowToParent:
|
||||
object->event( event );
|
||||
updateLayout();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//__________________________________________________________________
|
||||
void ConfigurationUi::updateLayout( void )
|
||||
{
|
||||
|
||||
int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
|
||||
window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
244
clients/oxygen/config/oxygenconfigwidget.cpp
Normal file
244
clients/oxygen/config/oxygenconfigwidget.cpp
Normal file
|
@ -0,0 +1,244 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
// oxygenconfigurationui.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 "oxygenconfigwidget.h"
|
||||
#include "oxygenanimationconfigwidget.h"
|
||||
|
||||
#include <kdeversion.h>
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <KLocale>
|
||||
#include <KTabWidget>
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
//_________________________________________________________
|
||||
ConfigWidget::ConfigWidget( QWidget* parent ):
|
||||
QWidget( parent ),
|
||||
_expertMode( false ),
|
||||
_animationConfigWidget(0)
|
||||
{
|
||||
|
||||
ui.setupUi( this );
|
||||
|
||||
// shadow configuration
|
||||
ui.activeShadowConfiguration->setGroup( QPalette::Active );
|
||||
ui.inactiveShadowConfiguration->setGroup( QPalette::Inactive );
|
||||
|
||||
shadowConfigurations.append( ui.activeShadowConfiguration );
|
||||
shadowConfigurations.append( ui.inactiveShadowConfiguration );
|
||||
|
||||
// animation config widget
|
||||
_animationConfigWidget = new AnimationConfigWidget();
|
||||
_animationConfigWidget->installEventFilter( this );
|
||||
|
||||
// expert mode
|
||||
ui._expertModeButton->setIcon( KIcon("configure") );
|
||||
toggleExpertModeInternal( false );
|
||||
|
||||
// connections
|
||||
connect( ui.titleOutline, SIGNAL( toggled( bool ) ), ui.separatorMode, SLOT(setDisabled(bool)) );
|
||||
connect( shadowConfigurations[0], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( shadowConfigurations[0], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
|
||||
|
||||
connect( shadowConfigurations[1], SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( shadowConfigurations[1], SIGNAL( toggled( bool ) ), SLOT( updateChanged( void ) ) );
|
||||
|
||||
connect( ui.titleAlignment, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.buttonSize, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.frameBorder, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.blendColor, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
||||
|
||||
connect( ui.titleOutline, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.drawSizeGrip, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.narrowButtonSpacing, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.closeFromMenuButton, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.separatorMode, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( ui.exceptions, SIGNAL( changed( void ) ), SLOT( updateChanged( void ) ) );
|
||||
|
||||
connect( ui._expertModeButton, SIGNAL( clicked( void ) ), SLOT( toggleExpertModeInternal( void ) ) );
|
||||
|
||||
// animation config widget
|
||||
connect( ui.animationsEnabled, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( _animationConfigWidget, SIGNAL( changed( bool ) ), SLOT( updateChanged( void ) ) );
|
||||
connect( _animationConfigWidget, SIGNAL( layoutChanged( void ) ), SLOT(updateLayout( void ) ) );
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigWidget::setConfiguration( ConfigurationPtr configuration )
|
||||
{
|
||||
_configuration = configuration;
|
||||
_animationConfigWidget->setConfiguration( configuration );
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigWidget::load( void )
|
||||
{
|
||||
if( !_configuration ) return;
|
||||
ui.titleAlignment->setCurrentIndex( _configuration->titleAlignment() );
|
||||
ui.buttonSize->setCurrentIndex( _configuration->buttonSize() );
|
||||
ui.blendColor->setCurrentIndex( _configuration->blendStyle() );
|
||||
ui.frameBorder->setCurrentIndex( _configuration->frameBorder() );
|
||||
ui.separatorMode->setCurrentIndex( _configuration->separatorMode() );
|
||||
ui.drawSizeGrip->setChecked( _configuration->drawSizeGrip() );
|
||||
ui.titleOutline->setChecked( _configuration->drawTitleOutline() );
|
||||
ui.animationsEnabled->setChecked( _configuration->animationsEnabled() );
|
||||
ui.narrowButtonSpacing->setChecked( _configuration->useNarrowButtonSpacing() );
|
||||
ui.closeFromMenuButton->setChecked( _configuration->closeWindowFromMenuButton() );
|
||||
|
||||
_animationConfigWidget->load();
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigWidget::save( void )
|
||||
{
|
||||
|
||||
if( !_configuration ) return;
|
||||
|
||||
// apply modifications from ui
|
||||
_configuration->setTitleAlignment( ui.titleAlignment->currentIndex() );
|
||||
_configuration->setButtonSize( ui.buttonSize->currentIndex() );
|
||||
_configuration->setBlendStyle( ui.blendColor->currentIndex() );
|
||||
_configuration->setFrameBorder( ui.frameBorder->currentIndex() );
|
||||
_configuration->setSeparatorMode( ui.separatorMode->currentIndex() );
|
||||
_configuration->setDrawSizeGrip( ui.drawSizeGrip->isChecked() );
|
||||
_configuration->setDrawTitleOutline( ui.titleOutline->isChecked() );
|
||||
_configuration->setUseNarrowButtonSpacing( ui.narrowButtonSpacing->isChecked() );
|
||||
_configuration->setCloseWindowFromMenuButton( ui.closeFromMenuButton->isChecked() );
|
||||
|
||||
if( _expertMode )
|
||||
{ _animationConfigWidget->save(); }
|
||||
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigWidget::toggleExpertMode( bool value )
|
||||
{
|
||||
ui._expertModeContainer->hide();
|
||||
toggleExpertModeInternal( value );
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
void ConfigWidget::toggleExpertModeInternal( bool value )
|
||||
{
|
||||
|
||||
// store value
|
||||
_expertMode = value;
|
||||
|
||||
// update button text
|
||||
ui._expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
|
||||
|
||||
// narrow button spacing
|
||||
ui.narrowButtonSpacing->setVisible( _expertMode );
|
||||
|
||||
// size grip
|
||||
ui.drawSizeGrip->setVisible( _expertMode );
|
||||
|
||||
// 'basic' animations enabled flag
|
||||
ui.animationsEnabled->setVisible( !_expertMode );
|
||||
|
||||
// layout and animations
|
||||
if( _expertMode )
|
||||
{
|
||||
|
||||
// add animationConfigWidget to tabbar if needed
|
||||
if( ui.tabWidget->indexOf( _animationConfigWidget ) < 0 )
|
||||
{ ui.tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
|
||||
|
||||
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
} else {
|
||||
|
||||
ui.shadowSpacer->changeSize(0,0, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
|
||||
if( int index = ui.tabWidget->indexOf( _animationConfigWidget ) >= 0 )
|
||||
{ ui.tabWidget->removeTab( index ); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//__________________________________________________________________
|
||||
bool ConfigWidget::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
|
||||
switch( event->type() )
|
||||
{
|
||||
case QEvent::ShowToParent:
|
||||
object->event( event );
|
||||
updateLayout();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//__________________________________________________________________
|
||||
void ConfigWidget::updateLayout( void )
|
||||
{
|
||||
|
||||
int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
|
||||
window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//_______________________________________________
|
||||
void ConfigWidget::updateChanged( void )
|
||||
{
|
||||
|
||||
// check configuration
|
||||
if( !_configuration ) return;
|
||||
|
||||
// track modifications
|
||||
bool modified( false );
|
||||
|
||||
if( ui.titleAlignment->currentIndex() != _configuration->titleAlignment() ) modified = true;
|
||||
else if( ui.buttonSize->currentIndex() != _configuration->buttonSize() ) modified = true;
|
||||
else if( ui.blendColor->currentIndex() != _configuration->blendStyle() ) modified = true;
|
||||
else if( ui.frameBorder->currentIndex() != _configuration->frameBorder() ) modified = true;
|
||||
else if( ui.separatorMode->currentIndex() != _configuration->separatorMode() ) modified = true;
|
||||
else if( ui.drawSizeGrip->isChecked() != _configuration->drawSizeGrip() ) modified = true;
|
||||
else if( ui.titleOutline->isChecked() != _configuration->drawTitleOutline() ) modified = true;
|
||||
else if( ui.narrowButtonSpacing->isChecked() != _configuration->useNarrowButtonSpacing() ) modified = true;
|
||||
|
||||
// shadow configurations
|
||||
else if( shadowConfigurations[0]->isModified() ) modified = true;
|
||||
else if( shadowConfigurations[1]->isModified() ) modified = true;
|
||||
|
||||
// animations
|
||||
else if( !_expertMode && ui.animationsEnabled->isChecked() != _configuration->animationsEnabled() ) modified = true;
|
||||
else if( _expertMode && _animationConfigWidget->isChanged() ) modified = true;
|
||||
|
||||
setChanged( modified );
|
||||
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@
|
|||
#include "ui_oxygenconfigurationui.h"
|
||||
#include "oxygenshadowconfigurationui.h"
|
||||
#include "oxygenexceptionlistwidget.h"
|
||||
#include "../oxygendecorationdefines.h"
|
||||
|
||||
#include <KComboBox>
|
||||
#include <QtGui/QWidget>
|
||||
|
@ -40,7 +41,7 @@ namespace Oxygen
|
|||
class AnimationConfigWidget;
|
||||
|
||||
//_____________________________________________
|
||||
class ConfigurationUi: public QWidget
|
||||
class ConfigWidget: public QWidget
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
@ -48,14 +49,28 @@ namespace Oxygen
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
explicit ConfigurationUi( QWidget* );
|
||||
explicit ConfigWidget( QWidget* );
|
||||
|
||||
//! destructor
|
||||
virtual ~ConfigurationUi( void )
|
||||
virtual ~ConfigWidget( void )
|
||||
{}
|
||||
|
||||
//! ui
|
||||
Ui_OxygenConfigurationUI ui;
|
||||
//! set configuration
|
||||
void setConfiguration( ConfigurationPtr );
|
||||
|
||||
//! load configuration
|
||||
void load( void );
|
||||
|
||||
//! save configuration
|
||||
void save( void );
|
||||
|
||||
//! true if changed
|
||||
virtual bool isChanged( void ) const
|
||||
{ return _changed; }
|
||||
|
||||
//! exceptions
|
||||
ExceptionListWidget* exceptionListWidget( void ) const
|
||||
{ return ui.exceptions; }
|
||||
|
||||
//! shadow configuration
|
||||
QVector<ShadowConfigurationUi*> shadowConfigurations;
|
||||
|
@ -63,18 +78,15 @@ namespace Oxygen
|
|||
//! toggle expert mode
|
||||
void toggleExpertMode( bool );
|
||||
|
||||
//! expert mode
|
||||
bool expertMode( void ) const
|
||||
{ return _expertMode; }
|
||||
|
||||
//! animation config widget
|
||||
AnimationConfigWidget* animationConfigWidget( void ) const
|
||||
{ return _animationConfigWidget; }
|
||||
|
||||
//! event filter
|
||||
virtual bool eventFilter( QObject*, QEvent* );
|
||||
|
||||
protected Q_SLOTS:
|
||||
signals:
|
||||
|
||||
//! emmited when changed
|
||||
void changed( bool );
|
||||
|
||||
protected slots:
|
||||
|
||||
//! toggle expert mode
|
||||
void toggleExpertModeInternal( void )
|
||||
|
@ -83,23 +95,39 @@ namespace Oxygen
|
|||
//! toggle expert mode
|
||||
void toggleExpertModeInternal( bool );
|
||||
|
||||
//! check whether configuration is changed and emit appropriate signal if yes
|
||||
virtual void updateChanged();
|
||||
|
||||
//! update layout
|
||||
/*! needed in expert mode to accommodate with animations config widget size changes */
|
||||
void updateLayout( void );
|
||||
|
||||
signals:
|
||||
protected:
|
||||
|
||||
//! emmited when changed
|
||||
void changed( void );
|
||||
//! set changed state
|
||||
virtual void setChanged( bool value )
|
||||
{
|
||||
_changed = value;
|
||||
emit changed( value );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! ui
|
||||
Ui_OxygenConfigurationUI ui;
|
||||
|
||||
//! internal exception
|
||||
ConfigurationPtr _configuration;
|
||||
|
||||
//! expert mode
|
||||
bool _expertMode;
|
||||
|
||||
//! animation config (expert mode only)
|
||||
AnimationConfigWidget* _animationConfigWidget;
|
||||
|
||||
//! changed state
|
||||
bool _changed;
|
||||
|
||||
};
|
||||
|
||||
}
|
|
@ -42,33 +42,33 @@ namespace Oxygen
|
|||
ui.setupUi( local );
|
||||
setMainWidget( local );
|
||||
|
||||
connect( ui.detectDialogButton, SIGNAL(clicked()), SLOT(selectWindowProperties()) );
|
||||
connect( ui.detectDialogButton, SIGNAL( clicked( void ) ), SLOT(selectWindowProperties()) );
|
||||
|
||||
// border size
|
||||
ui.frameBorderComboBox->setEnabled( false );
|
||||
_checkBoxes.insert( FrameBorder, ui.frameBorderCheckBox );
|
||||
connect( ui.frameBorderCheckBox, SIGNAL(toggled(bool)), ui.frameBorderComboBox, SLOT(setEnabled(bool)) );
|
||||
connect( ui.frameBorderCheckBox, SIGNAL( toggled( bool ) ), ui.frameBorderComboBox, SLOT(setEnabled(bool)) );
|
||||
|
||||
// blend color
|
||||
ui.blendColorComboBox->setEnabled( false );
|
||||
_checkBoxes.insert( BlendColor, ui.blendColorCheckBox );
|
||||
connect( ui.blendColorCheckBox, SIGNAL(toggled(bool)), ui.blendColorComboBox, SLOT(setEnabled(bool)) );
|
||||
connect( ui.blendColorCheckBox, SIGNAL( toggled( bool ) ), ui.blendColorComboBox, SLOT(setEnabled(bool)) );
|
||||
|
||||
// size grip
|
||||
ui.sizeGripComboBox->setEnabled( false );
|
||||
_checkBoxes.insert( SizeGripMode, ui.sizeGripCheckBox );
|
||||
connect( ui.sizeGripCheckBox, SIGNAL(toggled(bool)), ui.sizeGripComboBox, SLOT(setEnabled(bool)) );
|
||||
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( TitleOutline, ui.titleOutlineCheckBox );
|
||||
connect( ui.titleOutlineCheckBox, SIGNAL(toggled(bool)), ui.titleOutlineComboBox, SLOT(setEnabled(bool)) );
|
||||
connect( ui.titleOutlineCheckBox, SIGNAL( toggled( bool ) ), ui.titleOutlineComboBox, SLOT(setEnabled(bool)) );
|
||||
|
||||
// separator
|
||||
ui.separatorComboBox->setEnabled( false );
|
||||
_checkBoxes.insert( DrawSeparator, ui.separatorCheckBox );
|
||||
connect( ui.separatorCheckBox, SIGNAL(toggled(bool)), ui.separatorComboBox, SLOT(setEnabled(bool)) );
|
||||
connect( ui.separatorCheckBox, SIGNAL( toggled( bool ) ), ui.separatorComboBox, SLOT(setEnabled(bool)) );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ namespace Oxygen
|
|||
//! constructor
|
||||
explicit ExceptionDialog( QWidget* parent );
|
||||
|
||||
//! destructor
|
||||
virtual ~ExceptionDialog( void )
|
||||
{}
|
||||
|
||||
//! set exception
|
||||
void setException( ConfigurationPtr );
|
||||
|
||||
|
|
Loading…
Reference in a new issue