You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.9 KiB

/***************************************************************************
* Copyright (C) 2003 by Sandro Giessl *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include <kconfig.h>
#include <klocale.h>
#include <kglobal.h>
#include <qcheckbox.h>
#include <qslider.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qwhatsthis.h>
#include "malloryconfig.h"
#include "configdialog.h"
MalloryConfig::MalloryConfig(KConfig* config, QWidget* parent)
: QObject(parent), m_config(0), m_dialog(0)
{
// Create the configuration object.
m_config = new KConfig("kwinmalloryrc");
KGlobal::locale()->insertCatalogue("kwin_mallory_config");
// Create and show the configuration dialog.
m_dialog = new ConfigDialog(parent);
m_dialog->show();
// Load the configuration.
load(config);
// Setup the connections.
connect(m_dialog->m_borderSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(m_dialog->m_titleSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(m_dialog->m_buttonSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
connect(m_dialog->m_lessRounded, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
connect(m_dialog->m_buttonStyle, SIGNAL(activated(int)), this, SIGNAL(changed()));
connect(m_dialog->m_resizeHandle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
connect(m_dialog->m_superSize, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
connect(m_dialog->m_titleShadow, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
connect(m_dialog->m_titleShadowSize, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
}
MalloryConfig::~MalloryConfig()
{
if (m_dialog) delete m_dialog;
if (m_config) delete m_config;
}
void MalloryConfig::load(KConfig*)
{
m_config->setGroup("General");
int borderSize = m_config->readNumEntry("BorderSize", 5);
m_dialog->m_borderSize->setValue(borderSize);
int buttonSize = m_config->readNumEntry("ButtonSize", 18);
m_dialog->m_buttonSize->setValue(buttonSize);
int titleSize = m_config->readNumEntry("TitleSize", 22);
m_dialog->m_titleSize->setValue(titleSize);
bool lessRounded = m_config->readBoolEntry("LessRounded", false);
m_dialog->m_lessRounded->setChecked(lessRounded);
int buttonStyle = m_config->readNumEntry("ButtonStyle", 0);
m_dialog->m_buttonStyle->setCurrentItem(buttonStyle);
bool resizeHandle = m_config->readBoolEntry("ResizeHandle", true);
m_dialog->m_resizeHandle->setChecked(resizeHandle);
bool superSize = m_config->readBoolEntry("SuperSize", true);
m_dialog->m_superSize->setChecked(superSize);
bool titleShadow = m_config->readBoolEntry("TitleShadow", true);
m_dialog->m_titleShadow->setChecked(titleShadow);
int titleShadowSize = m_config->readNumEntry("TitleShadowSize", 2);
m_dialog->m_titleShadowSize->setValue(titleShadowSize);
}
void MalloryConfig::save(KConfig*)
{
m_config->setGroup("General");
m_config->writeEntry("ButtonSize", m_dialog->m_buttonSize->value());
m_config->writeEntry("TitleSize", m_dialog->m_titleSize->value());
m_config->writeEntry("BorderSize", m_dialog->m_borderSize->value());
m_config->writeEntry("LessRounded", m_dialog->m_lessRounded->isChecked());
m_config->writeEntry("ButtonStyle", m_dialog->m_buttonStyle->currentItem());
m_config->writeEntry("ResizeHandle", m_dialog->m_resizeHandle->isChecked());
m_config->writeEntry("SuperSize", m_dialog->m_superSize->isChecked());
m_config->writeEntry("TitleShadow", m_dialog->m_titleShadow->isChecked());
m_config->writeEntry("TitleShadowSize", m_dialog->m_titleShadowSize->value());
m_config->sync();
}
void MalloryConfig::defaults()
{
m_dialog->m_titleSize->setValue(22);
m_dialog->m_buttonSize->setValue(18);
m_dialog->m_borderSize->setValue(5);
m_dialog->m_lessRounded->setChecked(false);
m_dialog->m_buttonStyle->setCurrentItem(0);
m_dialog->m_resizeHandle->setChecked(true);
m_dialog->m_superSize->setChecked(true);
m_dialog->m_titleShadow->setChecked(true);
m_dialog->m_titleShadowSize->setValue(2);
}
//////////////////////////////////////////////////////////////////////////////
// Plugin Stuff //
//////////////////////////////////////////////////////////////////////////////
extern "C"
{
QObject* allocate_config(KConfig* config, QWidget* parent) {
return (new MalloryConfig(config, parent));
}
}
#include "malloryconfig.moc"