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 <KAboutData>
|
|
|
|
#include <KAboutApplicationDialog>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KGlobal>
|
|
|
|
#include <KLocale>
|
|
|
|
#include <kstandarddirs.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "config.moc"
|
|
|
|
|
|
|
|
#include "../nitrogenconfiguration.h"
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
|
|
|
{ return ( new Nitrogen::Config( conf, parent ) ); }
|
|
|
|
}
|
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
namespace Nitrogen
|
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-08-22 08:24:06 +00:00
|
|
|
configuration_ = new KConfig( "nitrogenrc" );
|
|
|
|
KConfigGroup configurationGroup( configuration_, "Windeco");
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
user_interface_ = new NitrogenConfigurationUI( parent );
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( user_interface_->titleAlignment, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
|
|
|
connect( user_interface_->buttonSize, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
|
|
|
connect( user_interface_->frameBorder, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
|
|
|
connect( user_interface_->blendColor, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
2009-09-02 02:18:25 +00:00
|
|
|
connect( user_interface_->sizeGripMode, SIGNAL(currentIndexChanged(int)), SIGNAL(changed()) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( user_interface_->drawSeparator, SIGNAL(clicked()), SIGNAL(changed()) );
|
2009-09-04 19:05:56 +00:00
|
|
|
connect( user_interface_->titleOutline, SIGNAL(clicked()), SIGNAL(changed()) );
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( user_interface_->useOxygenShadows, SIGNAL(clicked()), SIGNAL(changed()) );
|
2009-08-30 17:42:04 +00:00
|
|
|
connect( user_interface_->exceptions, SIGNAL(changed()), SIGNAL(changed()) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
load( configurationGroup );
|
|
|
|
user_interface_->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()
|
|
|
|
{
|
|
|
|
delete user_interface_;
|
|
|
|
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
|
|
|
|
KConfigGroup configurationGroup( configuration_, "Windeco");
|
|
|
|
loadConfiguration( NitrogenConfiguration( configurationGroup ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// load exceptions
|
|
|
|
NitrogenExceptionList exceptions;
|
|
|
|
exceptions.read( *configuration_ );
|
|
|
|
if( exceptions.empty() )
|
|
|
|
{ exceptions = NitrogenExceptionList::defaultList(); }
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// install in ui
|
|
|
|
user_interface_->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
|
|
|
|
|
|
|
// when writting 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(
|
|
|
|
NitrogenConfig::TITLE_ALIGNMENT,
|
2009-08-24 16:15:14 +00:00
|
|
|
NitrogenConfiguration::titleAlignmentName( NitrogenConfiguration::titleAlignment( user_interface_->titleAlignment->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
|
|
|
NitrogenConfig::BUTTON_SIZE,
|
2009-08-24 16:15:14 +00:00
|
|
|
NitrogenConfiguration::buttonSizeName( NitrogenConfiguration::buttonSize( user_interface_->buttonSize->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
|
|
|
NitrogenConfig::BLEND_COLOR,
|
2009-08-24 16:15:14 +00:00
|
|
|
NitrogenConfiguration::blendColorName( NitrogenConfiguration::blendColor( user_interface_->blendColor->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
configurationGroup.writeEntry(
|
|
|
|
NitrogenConfig::FRAME_BORDER,
|
2009-08-24 16:15:14 +00:00
|
|
|
NitrogenConfiguration::frameBorderName( NitrogenConfiguration::frameBorder( user_interface_->frameBorder->currentText(), true ), false ) );
|
2009-09-02 02:18:25 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
configurationGroup.writeEntry(
|
2009-09-02 02:18:25 +00:00
|
|
|
NitrogenConfig::SIZE_GRIP_MODE,
|
|
|
|
NitrogenConfiguration::sizeGripModeName( NitrogenConfiguration::sizeGripMode( user_interface_->sizeGripMode->currentText(), true ), false ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
configurationGroup.writeEntry( NitrogenConfig::DRAW_SEPARATOR, user_interface_->drawSeparator->isChecked() );
|
2009-09-04 19:05:56 +00:00
|
|
|
configurationGroup.writeEntry( NitrogenConfig::DRAW_TITLE_OUTLINE, user_interface_->titleOutline->isChecked() );
|
2009-08-22 08:24:06 +00:00
|
|
|
configurationGroup.writeEntry( NitrogenConfig::USE_OXYGEN_SHADOWS, user_interface_->useOxygenShadows->isChecked() );
|
|
|
|
|
2009-08-30 17:42:04 +00:00
|
|
|
// write exceptions
|
2009-09-09 00:55:55 +00:00
|
|
|
user_interface_->exceptions->exceptions().write( *configuration_ );
|
|
|
|
|
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-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
|
|
|
|
loadConfiguration( NitrogenConfiguration() );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// install default exceptions
|
2009-08-30 17:42:04 +00:00
|
|
|
user_interface_->exceptions->setExceptions( NitrogenExceptionList::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
|
|
|
}
|
|
|
|
|
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::loadConfiguration( const NitrogenConfiguration& configuration )
|
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
user_interface_->titleAlignment->setCurrentIndex( user_interface_->titleAlignment->findText( configuration.titleAlignmentName( true ) ) );
|
|
|
|
user_interface_->buttonSize->setCurrentIndex( user_interface_->buttonSize->findText( configuration.buttonSizeName( true ) ) );
|
2009-08-24 16:15:14 +00:00
|
|
|
user_interface_->blendColor->setCurrentIndex( user_interface_->blendColor->findText( configuration.blendColorName( true ) ) );
|
|
|
|
user_interface_->frameBorder->setCurrentIndex( user_interface_->frameBorder->findText( configuration.frameBorderName( true ) ) );
|
2009-09-02 02:18:25 +00:00
|
|
|
user_interface_->sizeGripMode->setCurrentIndex( user_interface_->sizeGripMode->findText( configuration.sizeGripModeName( true ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
user_interface_->drawSeparator->setChecked( configuration.drawSeparator() );
|
2009-09-04 19:05:56 +00:00
|
|
|
user_interface_->titleOutline->setChecked( configuration.drawTitleOutline() );
|
2009-08-22 08:24:06 +00:00
|
|
|
user_interface_->useOxygenShadows->setChecked( configuration.useOxygenShadows() );
|
|
|
|
}
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
//_______________________________________________________________________
|
|
|
|
void Config::aboutNitrogen( void )
|
|
|
|
{
|
|
|
|
KAboutData aboutData( "nitrogen", 0,
|
|
|
|
ki18n( "Nitrogen" ), APP_VERSION,
|
|
|
|
ki18n( "Oxygen based Window decoration for KDE" ), KAboutData::License_GPL,
|
|
|
|
KLocalizedString(),
|
|
|
|
KLocalizedString(),
|
|
|
|
( "http://www.kde-look.org/content/show.php/Nitrogen?content=99551" ) );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
aboutData.addAuthor(
|
2009-08-25 18:33:51 +00:00
|
|
|
ki18n( "Hugo Pereira Da Costa" ), ki18n( "Developer" ),
|
2009-08-22 08:24:06 +00:00
|
|
|
"hugo.pereira@free.fr",
|
|
|
|
"http://hugo.pereira.free.fr/index.php" );
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
aboutData.addCredit( ki18n( "Oxygen team" ) );
|
|
|
|
|
|
|
|
// create dialog
|
|
|
|
KAboutApplicationDialog( &aboutData, 0 ).exec();
|
2009-09-09 00:55:55 +00:00
|
|
|
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
2009-08-30 17:42:04 +00:00
|
|
|
|
2009-09-09 00:55:55 +00:00
|
|
|
}
|