2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// config.cpp
|
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-24 16:15:14 +00:00
|
|
|
// Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
//
|
|
|
|
// Based on the Quartz configuration module,
|
|
|
|
// Copyright (c) 2001 Karol Szwed <gallium@kde.org>
|
|
|
|
//
|
|
|
|
// 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
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "config.moc"
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
#include "../oxygenconfiguration.h"
|
|
|
|
#include "../oxygenshadowconfiguration.h"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-16 06:09:31 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KAboutApplicationDialog>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KGlobal>
|
|
|
|
#include <KLocale>
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
2009-09-15 07:12:54 +00:00
|
|
|
{ return ( new Oxygen::Config( conf, parent ) ); }
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
Config::Config( KConfig*, QWidget* parent ): QObject( parent )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
KGlobal::locale()->insertCatalog("kwin_clients");
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 06:25:06 +00:00
|
|
|
configuration_ = new KConfig( "oxygenrc" );
|
2009-08-22 08:24:06 +00:00
|
|
|
KConfigGroup configurationGroup( configuration_, "Windeco");
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
userInterface_ = new OxygenConfigurationUI( parent );
|
2009-09-14 19:21:39 +00:00
|
|
|
connect( userInterface_, SIGNAL(changed()), SIGNAL( changed() ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
load( configurationGroup );
|
2009-09-14 19:21:39 +00:00
|
|
|
userInterface_->show();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
Config::~Config()
|
|
|
|
{
|
2009-09-14 19:21:39 +00:00
|
|
|
delete userInterface_;
|
2009-08-22 08:24:06 +00:00
|
|
|
delete configuration_;
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::load( const KConfigGroup& )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// load standard configuration
|
2009-09-15 07:12:54 +00:00
|
|
|
loadConfiguration( OxygenConfiguration( KConfigGroup( configuration_, "Windeco") ) );
|
|
|
|
loadShadowConfiguration( QPalette::Active, OxygenShadowConfiguration( QPalette::Active, KConfigGroup( configuration_, "ActiveShadow") ) );
|
|
|
|
loadShadowConfiguration( QPalette::Inactive, OxygenShadowConfiguration( QPalette::Inactive, KConfigGroup( configuration_, "InactiveShadow") ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// load exceptions
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenExceptionList exceptions;
|
2009-08-30 17:42:04 +00:00
|
|
|
exceptions.read( *configuration_ );
|
|
|
|
if( exceptions.empty() )
|
2009-09-15 07:12:54 +00:00
|
|
|
{ exceptions = OxygenExceptionList::defaultList(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// install in ui
|
2009-10-31 04:25:38 +00:00
|
|
|
userInterface_->ui.exceptions->setExceptions( exceptions );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::save( KConfigGroup& )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// save standard configuration
|
|
|
|
KConfigGroup configurationGroup( configuration_, "Windeco");
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-16 06:09:31 +00:00
|
|
|
// when writing text entries, on needs to make sure that strings written
|
2009-08-24 16:15:14 +00:00
|
|
|
// to the configuration file are *not* translated using current locale
|
2009-09-09 00:55:55 +00:00
|
|
|
configurationGroup.writeEntry(
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenConfig::TITLE_ALIGNMENT,
|
2009-10-31 04:25:38 +00:00
|
|
|
OxygenConfiguration::titleAlignmentName( OxygenConfiguration::titleAlignment( userInterface_->ui.titleAlignment->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenConfig::BUTTON_SIZE,
|
2009-10-31 04:25:38 +00:00
|
|
|
OxygenConfiguration::buttonSizeName( OxygenConfiguration::buttonSize( userInterface_->ui.buttonSize->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenConfig::BLEND_COLOR,
|
2009-10-31 04:25:38 +00:00
|
|
|
OxygenConfiguration::blendColorName( OxygenConfiguration::blendColor( userInterface_->ui.blendColor->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenConfig::FRAME_BORDER,
|
2009-10-31 04:25:38 +00:00
|
|
|
OxygenConfiguration::frameBorderName( OxygenConfiguration::frameBorder( userInterface_->ui.frameBorder->currentText(), true ), false ) );
|
2009-09-02 02:18:25 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
configurationGroup.writeEntry(
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenConfig::SIZE_GRIP_MODE,
|
2009-10-31 04:25:38 +00:00
|
|
|
OxygenConfiguration::sizeGripModeName( OxygenConfiguration::sizeGripMode( userInterface_->ui.sizeGripMode->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-31 04:25:38 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::DRAW_SEPARATOR, userInterface_->ui.drawSeparator->isChecked() );
|
|
|
|
configurationGroup.writeEntry( OxygenConfig::DRAW_TITLE_OUTLINE, userInterface_->ui.titleOutline->isChecked() );
|
2010-03-25 00:51:27 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::USE_DROP_SHADOWS, userInterface_->shadowConfigurations[1]->isChecked() );
|
2009-12-07 23:32:24 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::USE_OXYGEN_SHADOWS, userInterface_->shadowConfigurations[0]->isChecked() );
|
2009-11-15 03:24:04 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::TABS_ENABLED, userInterface_->ui.tabsEnabled->isChecked() );
|
2010-02-12 01:18:46 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::USE_ANIMATIONS, userInterface_->ui.useAnimations->isChecked() );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// write exceptions
|
2009-10-31 04:25:38 +00:00
|
|
|
userInterface_->ui.exceptions->exceptions().write( *configuration_ );
|
2009-09-14 19:21:39 +00:00
|
|
|
|
|
|
|
// write shadow configuration
|
2010-04-25 20:28:02 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_MODE,
|
|
|
|
OxygenConfiguration::shadowModeName( OxygenConfiguration::shadowMode( userInterface_->ui.shadowMode->currentText(), true ), false ) );
|
2009-09-14 19:21:39 +00:00
|
|
|
saveShadowConfiguration( QPalette::Active, *userInterface_->shadowConfigurations[0] );
|
|
|
|
saveShadowConfiguration( QPalette::Inactive, *userInterface_->shadowConfigurations[1] );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// sync configuration
|
2009-08-22 08:24:06 +00:00
|
|
|
configuration_->sync();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-09-14 19:21:39 +00:00
|
|
|
//_______________________________________________________________________
|
2009-09-15 07:12:54 +00:00
|
|
|
void Config::saveShadowConfiguration( QPalette::ColorGroup colorGroup, const OxygenShadowConfigurationUI& ui ) const
|
2009-09-14 19:21:39 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
assert( colorGroup == QPalette::Active || colorGroup == QPalette::Inactive );
|
|
|
|
|
|
|
|
// save shadow configuration
|
|
|
|
KConfigGroup configurationGroup( configuration_, ( (colorGroup == QPalette::Active) ? "ActiveShadow":"InactiveShadow" ) );
|
2009-10-31 03:16:51 +00:00
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_SIZE, ui.ui.shadowSize->value() );
|
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_VOFFSET, 0.1*ui.ui.verticalOffset->value() );
|
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_INNER_COLOR, ui.ui.innerColor->color() );
|
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_OUTER_COLOR, ui.ui.outerColor->color() );
|
|
|
|
configurationGroup.writeEntry( OxygenConfig::SHADOW_USE_OUTER_COLOR, ui.ui.useOuterColor->isChecked() );
|
2009-09-14 19:21:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::defaults()
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// install default configuration
|
2009-09-15 07:12:54 +00:00
|
|
|
loadConfiguration( OxygenConfiguration() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-09-14 19:21:39 +00:00
|
|
|
// load shadows
|
2009-09-15 07:12:54 +00:00
|
|
|
loadShadowConfiguration( QPalette::Active, OxygenShadowConfiguration( QPalette::Active ) );
|
|
|
|
loadShadowConfiguration( QPalette::Inactive, OxygenShadowConfiguration( QPalette::Inactive ) );
|
2009-09-14 19:21:39 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// install default exceptions
|
2009-10-31 04:25:38 +00:00
|
|
|
userInterface_->ui.exceptions->setExceptions( OxygenExceptionList::defaultList() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// emit changed signal
|
|
|
|
emit changed();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
2009-09-15 07:12:54 +00:00
|
|
|
void Config::loadConfiguration( const OxygenConfiguration& configuration )
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-10-31 04:25:38 +00:00
|
|
|
userInterface_->ui.titleAlignment->setCurrentIndex( userInterface_->ui.titleAlignment->findText( configuration.titleAlignmentName( true ) ) );
|
|
|
|
userInterface_->ui.buttonSize->setCurrentIndex( userInterface_->ui.buttonSize->findText( configuration.buttonSizeName( true ) ) );
|
|
|
|
userInterface_->ui.blendColor->setCurrentIndex( userInterface_->ui.blendColor->findText( configuration.blendColorName( true ) ) );
|
|
|
|
userInterface_->ui.frameBorder->setCurrentIndex( userInterface_->ui.frameBorder->findText( configuration.frameBorderName( true ) ) );
|
|
|
|
userInterface_->ui.sizeGripMode->setCurrentIndex( userInterface_->ui.sizeGripMode->findText( configuration.sizeGripModeName( true ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-10-31 04:25:38 +00:00
|
|
|
userInterface_->ui.drawSeparator->setChecked( configuration.drawSeparator() );
|
|
|
|
userInterface_->ui.titleOutline->setChecked( configuration.drawTitleOutline() );
|
2009-12-07 23:32:24 +00:00
|
|
|
userInterface_->shadowConfigurations[0]->setChecked( configuration.useOxygenShadows() );
|
2010-03-25 00:51:27 +00:00
|
|
|
userInterface_->shadowConfigurations[1]->setChecked( configuration.useDropShadows() );
|
2009-11-15 03:24:04 +00:00
|
|
|
userInterface_->ui.tabsEnabled->setChecked( configuration.tabsEnabled() );
|
2010-02-12 01:18:46 +00:00
|
|
|
userInterface_->ui.useAnimations->setChecked( configuration.useAnimations() );
|
2010-04-25 20:28:02 +00:00
|
|
|
userInterface_->ui.shadowMode->setCurrentIndex( userInterface_->ui.shadowMode->findText( configuration.shadowModeName( true ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-09-14 19:21:39 +00:00
|
|
|
//_______________________________________________________________________
|
2009-09-15 07:12:54 +00:00
|
|
|
void Config::loadShadowConfiguration( QPalette::ColorGroup colorGroup, const OxygenShadowConfiguration& configuration )
|
2009-09-14 19:21:39 +00:00
|
|
|
{
|
|
|
|
assert( colorGroup == QPalette::Active || colorGroup == QPalette::Inactive );
|
2009-09-15 07:12:54 +00:00
|
|
|
OxygenShadowConfigurationUI* ui = userInterface_->shadowConfigurations[ (colorGroup == QPalette::Active) ? 0:1 ];
|
2009-10-31 03:16:51 +00:00
|
|
|
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() );
|
2009-09-14 19:21:39 +00:00
|
|
|
}
|
2010-04-25 20:28:02 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
2009-09-15 07:12:54 +00:00
|
|
|
void Config::aboutOxygen( void )
|
2009-09-15 06:25:06 +00:00
|
|
|
{}
|
2009-08-30 17:42:04 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
}
|