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
|
|
|
|
2010-05-01 23:44:27 +00:00
|
|
|
#include "oxygenconfig.h"
|
|
|
|
#include "oxygenconfig.moc"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2011-07-18 07:49:15 +00:00
|
|
|
#include "oxygenanimationconfigwidget.h"
|
2012-11-23 09:09:39 +00:00
|
|
|
#include "oxygenconfiguration.h"
|
|
|
|
#include "oxygenutil.h"
|
|
|
|
#include "../oxygenexceptionlist.h"
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2011-07-18 07:49:15 +00:00
|
|
|
#include <QtCore/QTextStream>
|
2011-01-29 18:33:01 +00:00
|
|
|
#include <QtDBus/QDBusConnection>
|
|
|
|
#include <QtDBus/QDBusMessage>
|
|
|
|
|
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"
|
|
|
|
{
|
2010-10-03 02:22:56 +00:00
|
|
|
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
|
|
|
{ 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
|
|
|
{
|
2010-11-11 16:37:52 +00:00
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
Config::Config( KConfig*, QWidget* parent ):
|
|
|
|
QObject( parent )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
KGlobal::locale()->insertCatalog("kwin_clients");
|
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
_configuration = new KConfig( "oxygenrc" );
|
|
|
|
KConfigGroup configurationGroup( _configuration, "Windeco");
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2012-11-26 21:36:15 +00:00
|
|
|
_configWidget = new ConfigWidget( parent );
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
load( configurationGroup );
|
2012-11-26 21:36:15 +00:00
|
|
|
connect( _configWidget, SIGNAL( changed( bool ) ), SLOT(updateChanged()) );
|
|
|
|
_configWidget->show();
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
Config::~Config()
|
|
|
|
{
|
2012-11-26 21:36:15 +00:00
|
|
|
delete _configWidget;
|
2011-02-24 16:47:38 +00:00
|
|
|
delete _configuration;
|
2010-10-03 02:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::toggleExpertMode( bool value )
|
2012-11-26 21:36:15 +00:00
|
|
|
{ _configWidget->toggleExpertMode( value ); }
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::load( const KConfigGroup& )
|
|
|
|
{
|
|
|
|
|
|
|
|
// load standard configuration
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr configuration( new Configuration() );
|
|
|
|
configuration->readConfig();
|
|
|
|
loadConfiguration( configuration );
|
|
|
|
|
|
|
|
// load shadows
|
2012-11-26 21:51:17 +00:00
|
|
|
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
|
2012-11-23 09:09:39 +00:00
|
|
|
{ ui->readConfig( _configuration ); }
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
// load exceptions
|
|
|
|
ExceptionList exceptions;
|
2012-11-23 09:09:39 +00:00
|
|
|
exceptions.readConfig( *_configuration );
|
2012-11-26 21:36:15 +00:00
|
|
|
_configWidget->exceptionListWidget()->setExceptions( exceptions.get() );
|
2010-10-03 02:22:56 +00:00
|
|
|
updateChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::updateChanged( void )
|
|
|
|
{
|
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr configuration( new Configuration() );
|
|
|
|
configuration->readConfig();
|
2010-10-03 02:22:56 +00:00
|
|
|
bool modified( false );
|
|
|
|
|
|
|
|
// exceptions
|
2012-11-26 21:36:15 +00:00
|
|
|
if( _configWidget->isChanged() ) modified = true;
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
// emit relevant signals
|
|
|
|
if( modified ) emit changed();
|
|
|
|
emit changed( modified );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::save( KConfigGroup& )
|
|
|
|
{
|
|
|
|
|
2012-11-16 10:59:58 +00:00
|
|
|
// create configuration from group
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr configuration( new Configuration() );
|
|
|
|
configuration->readConfig();
|
2012-11-16 10:59:58 +00:00
|
|
|
|
2012-11-26 21:36:15 +00:00
|
|
|
// save config widget
|
|
|
|
_configWidget->setConfiguration( configuration );
|
|
|
|
_configWidget->save();
|
2011-07-18 08:21:17 +00:00
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
// save standard configuration
|
2012-11-23 09:09:39 +00:00
|
|
|
Util::writeConfig( configuration.data(), _configuration );
|
2010-10-03 02:22:56 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
// get list of exceptions and write
|
2012-11-26 21:36:15 +00:00
|
|
|
ConfigurationList exceptions( _configWidget->exceptionListWidget()->exceptions() );
|
2012-11-23 09:09:39 +00:00
|
|
|
ExceptionList( exceptions ).writeConfig( *_configuration );
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
// write shadow configuration
|
2012-11-26 21:51:17 +00:00
|
|
|
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
|
2012-11-23 09:09:39 +00:00
|
|
|
{ ui->writeConfig( _configuration ); }
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
// sync configuration
|
2011-02-24 16:47:38 +00:00
|
|
|
_configuration->sync();
|
2010-10-03 02:22:56 +00:00
|
|
|
|
2011-01-29 18:33:01 +00:00
|
|
|
QDBusMessage message( QDBusMessage::createSignal("/OxygenWindeco", "org.kde.Oxygen.Style", "reparseConfiguration") );
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::defaults()
|
|
|
|
{
|
|
|
|
|
|
|
|
// install default configuration
|
2012-11-23 09:09:39 +00:00
|
|
|
ConfigurationPtr configuration( new Configuration() );
|
|
|
|
configuration->setDefaults();
|
|
|
|
loadConfiguration( configuration );
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
// load shadows
|
2012-11-26 21:51:17 +00:00
|
|
|
foreach( ShadowConfigWidget* ui, _configWidget->shadowConfigurations )
|
2012-11-23 09:09:39 +00:00
|
|
|
{ ui->readDefaults( _configuration ); }
|
2010-10-03 02:22:56 +00:00
|
|
|
|
|
|
|
updateChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
void Config::loadConfiguration( ConfigurationPtr configuration )
|
2010-10-03 02:22:56 +00:00
|
|
|
{
|
|
|
|
|
2012-11-26 21:36:15 +00:00
|
|
|
_configWidget->setConfiguration( configuration );
|
|
|
|
_configWidget->load();
|
2011-07-18 07:49:15 +00:00
|
|
|
|
2010-10-03 02:22:56 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
}
|