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.
twin-style-crystal/client/config/crystalconfig.cpp

387 lines
19 KiB

/***************************************************************************
* Copyright (C) 2006 by Sascha Hlusiak *
* Spam84@gmx.de *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <tdeconfig.h>
#include <tdelocale.h>
#include <tdeglobal.h>
#include <tqbuttongroup.h>
#include <tqlabel.h>
#include <tqgroupbox.h>
#include <tqbuttongroup.h>
#include <tqcheckbox.h>
#include <tqradiobutton.h>
#include <tqwhatsthis.h>
#include <tqspinbox.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqwidgetstack.h>
#include <tqlineedit.h>
#include <tqfiledialog.h>
#include <kcolorbutton.h>
#include <tdefiledialog.h>
#include <tqpicture.h>
#include <tdeapplication.h>
#include <kurlrequester.h>
#include "configdialog.h"
#include "infodialog.h"
#include "crystalconfig.h"
CrystalConfig::CrystalConfig(TDEConfig*, TQWidget* parent)
: TQObject(parent), config_(0), dialog_(0)
{
TDEGlobal::locale()->insertCatalogue("twin_clients");
TDEGlobal::locale()->insertCatalogue("twin-style-crystal");
config_ = new TDEConfig("twincrystalrc");
dialog_ = new ConfigDialog(parent);
dialog_->show();
connect(dialog_->titlealign, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->drawCaption, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->textshadow, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->tooltip,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->wheelTask,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->trackdesktop, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->shade1, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->shade2, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->frame1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->frame2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->frameColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->frameColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->inline1, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->inline2, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->inlineColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->inlineColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->type1,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->type2,TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->enableTransparency,TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->borderwidth, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->titlebarheight, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->tlc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->trc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->blc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->brc, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->buttonColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->buttonColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->buttonColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->minColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->minColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->minColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->maxColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->maxColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->maxColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->closeColor1, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->closeColor2, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->closeColor3, TQT_SIGNAL(changed(const TQColor&)),this,TQT_SLOT(colorChanged(const TQColor&)));
connect(dialog_->hover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->animateHover, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->buttonTheme, TQT_SIGNAL(activated(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->tintButtons, TQT_SIGNAL(toggled(bool)),this,TQT_SLOT(boolChanged(bool)));
connect(dialog_->menuimage, TQT_SIGNAL(stateChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->repaintMode, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->updateTime, TQT_SIGNAL(valueChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->infoButton, TQT_SIGNAL(clicked(void)),this,TQT_SLOT(infoDialog(void)));
connect(dialog_->active_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->inactive_blur, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int)));
connect(dialog_->userPicture1, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->userPicture2, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->activeFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& )));
connect(dialog_->inactiveFile,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged( const TQString& )));
connect(dialog_->overlay_active, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_active_changed(int)));
connect(dialog_->overlay_inactive, TQT_SIGNAL(activated(int)),this, TQT_SLOT(overlay_inactive_changed(int)));
connect(dialog_->overlay_active_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &)));
connect(dialog_->overlay_inactive_file,TQT_SIGNAL(textChanged(const TQString&)),this,TQT_SLOT(textChanged(const TQString &)));
connect(dialog_->logoEnabled, TQT_SIGNAL(clicked(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->logoFile, TQT_SIGNAL(textChanged(const TQString &)),this, TQT_SLOT(logoTextChanged(const TQString&)));
connect(dialog_->logoStretch, TQT_SIGNAL(activated(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->logoActive, TQT_SIGNAL(stateChanged(int)),this, TQT_SLOT(selectionChanged(int)));
connect(dialog_->logoDistance,TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(selectionChanged(int)));
load(config_);
}
CrystalConfig::~CrystalConfig()
{
if (dialog_) delete dialog_;
if (config_) delete config_;
}
void CrystalConfig::selectionChanged(int)
{
emit changed();
}
void CrystalConfig::load(TDEConfig*)
{
TQColor color(255,255,255);
config_->setGroup("General");
TQString value = config_->readEntry("TitleAlignment", "AlignHCenter");
TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->child(value.utf8());
if (button) button->setChecked(true);
dialog_->drawCaption->setChecked(config_->readBoolEntry("DrawCaption",true));
dialog_->textshadow->setChecked(config_->readBoolEntry("TextShadow",true));
dialog_->tooltip->setChecked(config_->readBoolEntry("CaptionTooltip",true));
dialog_->wheelTask->setChecked(config_->readBoolEntry("WheelTask",false));
dialog_->enableTransparency->setChecked(config_->readBoolEntry("EnableTransparency",true));
dialog_->trackdesktop->setChecked(config_->readBoolEntry("TrackDesktop",false));
dialog_->frame1->setCurrentItem(config_->readNumEntry("ActiveFrame",1));
color=TQColor(192,192,192);
dialog_->frameColor1->setColor(config_->readColorEntry("FrameColor1",&color));
dialog_->frame2->setCurrentItem(config_->readNumEntry("InactiveFrame",1));
color=TQColor(192,192,192);
dialog_->frameColor2->setColor(config_->readColorEntry("FrameColor2",&color));
dialog_->inline1->setCurrentItem(config_->readNumEntry("ActiveInline",0));
color=TQColor(192,192,192);
dialog_->inlineColor1->setColor(config_->readColorEntry("InlineColor1",&color));
dialog_->inline2->setCurrentItem(config_->readNumEntry("InactiveInline",0));
color=TQColor(192,192,192);
dialog_->inlineColor2->setColor(config_->readColorEntry("InlineColor2",&color));
dialog_->borderwidth->setValue(config_->readNumEntry("Borderwidth",5));
dialog_->titlebarheight->setValue(config_->readNumEntry("Titlebarheight",19));
int active=config_->readNumEntry("ActiveShade",30);
dialog_->shade1->setValue(active);
active=config_->readNumEntry("InactiveShade",-30);
dialog_->shade2->setValue(active);
dialog_->type1->setCurrentItem(config_->readNumEntry("ActiveMode",0));
dialog_->type2->setCurrentItem(config_->readNumEntry("InactiveMode",2));
int cornersFlag = config_->readNumEntry("RoundCorners",TOP_LEFT & TOP_RIGHT );
dialog_->tlc->setChecked( cornersFlag & TOP_LEFT );
dialog_->trc->setChecked( cornersFlag & TOP_RIGHT );
dialog_->blc->setChecked( cornersFlag & BOT_LEFT );
dialog_->brc->setChecked( cornersFlag & BOT_RIGHT );
dialog_->hover->setChecked(config_->readBoolEntry("HoverEffect",true));
dialog_->animateHover->setChecked(config_->readBoolEntry("AnimateHover",true));
dialog_->menuimage->setChecked(config_->readBoolEntry("MenuImage",true));
color=TQColor(255,255,255);
dialog_->buttonColor1->setColor(config_->readColorEntry("ButtonColor",&color));
dialog_->buttonColor2->setColor(config_->readColorEntry("ButtonColor2",&color));
dialog_->buttonColor3->setColor(config_->readColorEntry("ButtonColor3",&color));
dialog_->minColor1->setColor(config_->readColorEntry("MinColor",&color));
dialog_->minColor2->setColor(config_->readColorEntry("MinColor2",&color));
dialog_->minColor3->setColor(config_->readColorEntry("MinColor3",&color));
dialog_->maxColor1->setColor(config_->readColorEntry("MaxColor",&color));
dialog_->maxColor2->setColor(config_->readColorEntry("MaxColor2",&color));
dialog_->maxColor3->setColor(config_->readColorEntry("MaxColor3",&color));
dialog_->closeColor1->setColor(config_->readColorEntry("CloseColor",&color));
dialog_->closeColor2->setColor(config_->readColorEntry("CloseColor2",&color));
dialog_->closeColor3->setColor(config_->readColorEntry("CloseColor3",&color));
dialog_->tintButtons->setChecked(config_->readBoolEntry("TintButtons",dialog_->buttonColor1->color()!=TQColor(255,255,255)));
dialog_->buttonTheme->setCurrentItem(config_->readNumEntry("ButtonTheme",8));
dialog_->updateTime->setValue(config_->readNumEntry("RepaintTime",200));
button=(TQRadioButton*)dialog_->repaintMode->find(config_->readNumEntry("RepaintMode",1));
if (button)button->setChecked(true);
dialog_->active_blur->setValue(config_->readNumEntry("ActiveBlur",0));
dialog_->inactive_blur->setValue(config_->readNumEntry("InactiveBlur",0));
dialog_->activeFile->setURL(config_->readEntry("ActiveUserdefinedPicture",""));
dialog_->userPicture1->setChecked(config_->readBoolEntry("ActiveUserdefined",false));
dialog_->inactiveFile->setURL(config_->readEntry("InactiveUserdefinedPicture",""));
dialog_->userPicture2->setChecked(config_->readBoolEntry("InactiveUserdefined",false));
dialog_->overlay_active->setCurrentItem(config_->readNumEntry("OverlayModeActive",0));
dialog_->overlay_active_file->setURL(config_->readEntry("OverlayFileActive",""));
overlay_active_changed(dialog_->overlay_active->currentItem());
dialog_->overlay_inactive->setCurrentItem(config_->readNumEntry("OverlayModeInactive",0));
dialog_->overlay_inactive_file->setURL(config_->readEntry("OverlayFileInactive",""));
overlay_inactive_changed(dialog_->overlay_inactive->currentItem());
dialog_->logoEnabled->setButton(config_->readNumEntry("LogoAlignment",1));
dialog_->logoFile->setURL(config_->readEntry("LogoFile",""));
dialog_->logoActive->setChecked(config_->readBoolEntry("LogoActive",1));
dialog_->logoStretch->setCurrentItem(config_->readNumEntry("LogoStretch",0));
dialog_->logoDistance->setValue(config_->readNumEntry("LogoDistance",0));
updateLogo();
}
void CrystalConfig::save(TDEConfig*)
{
config_->setGroup("General");
TQRadioButton *button = (TQRadioButton*)dialog_->titlealign->selected();
if (button) config_->writeEntry("TitleAlignment", TQString(button->name()));
config_->writeEntry("DrawCaption",dialog_->drawCaption->isChecked());
config_->writeEntry("TextShadow",dialog_->textshadow->isChecked());
config_->writeEntry("CaptionTooltip",dialog_->tooltip->isChecked());
config_->writeEntry("WheelTask",dialog_->wheelTask->isChecked());
config_->writeEntry("EnableTransparency",dialog_->enableTransparency->isChecked());
config_->writeEntry("TrackDesktop",dialog_->trackdesktop->isChecked());
config_->writeEntry("Borderwidth",dialog_->borderwidth->value());
config_->writeEntry("Titlebarheight",dialog_->titlebarheight->value());
config_->writeEntry("ActiveShade",dialog_->shade1->value());
config_->writeEntry("InactiveShade",dialog_->shade2->value());
config_->writeEntry("ActiveFrame",dialog_->frame1->currentItem());
config_->writeEntry("FrameColor1",dialog_->frameColor1->color());
config_->writeEntry("InactiveFrame",dialog_->frame2->currentItem());
config_->writeEntry("ActiveMode",dialog_->type1->currentItem());
config_->writeEntry("InactiveMode",dialog_->type2->currentItem());
config_->writeEntry("FrameColor2",dialog_->frameColor2->color());
config_->writeEntry("ActiveInline",dialog_->inline1->currentItem());
config_->writeEntry("InlineColor1",dialog_->inlineColor1->color());
config_->writeEntry("InactiveInline",dialog_->inline2->currentItem());
config_->writeEntry("InlineColor2",dialog_->inlineColor2->color());
config_->writeEntry("ButtonColor",dialog_->buttonColor1->color());
config_->writeEntry("ButtonColor2",dialog_->buttonColor2->color());
config_->writeEntry("ButtonColor3",dialog_->buttonColor3->color());
config_->writeEntry("MinColor",dialog_->minColor1->color());
config_->writeEntry("MinColor2",dialog_->minColor2->color());
config_->writeEntry("MinColor3",dialog_->minColor3->color());
config_->writeEntry("MaxColor",dialog_->maxColor1->color());
config_->writeEntry("MaxColor2",dialog_->maxColor2->color());
config_->writeEntry("MaxColor3",dialog_->maxColor3->color());
config_->writeEntry("CloseColor",dialog_->closeColor1->color());
config_->writeEntry("CloseColor2",dialog_->closeColor2->color());
config_->writeEntry("CloseColor3",dialog_->closeColor3->color());
int cornersFlag = 0;
if(dialog_->tlc->isChecked()) cornersFlag += TOP_LEFT;
if(dialog_->trc->isChecked()) cornersFlag += TOP_RIGHT;
if(dialog_->blc->isChecked()) cornersFlag += BOT_LEFT;
if(dialog_->brc->isChecked()) cornersFlag += BOT_RIGHT;
config_->writeEntry("RoundCorners", cornersFlag );
config_->writeEntry("HoverEffect",dialog_->hover->isChecked());
config_->writeEntry("AnimateHover",dialog_->animateHover->isChecked());
config_->writeEntry("TintButtons",dialog_->tintButtons->isChecked());
config_->writeEntry("MenuImage",dialog_->menuimage->isChecked());
config_->writeEntry("ButtonTheme",dialog_->buttonTheme->currentItem());
config_->writeEntry("RepaintMode",dialog_->repaintMode->selectedId());
config_->writeEntry("RepaintTime",dialog_->updateTime->value());
config_->writeEntry("ActiveBlur",dialog_->active_blur->value());
config_->writeEntry("InactiveBlur",dialog_->inactive_blur->value());
config_->writeEntry("ActiveUserdefined",dialog_->userPicture1->isChecked());
config_->writeEntry("ActiveUserdefinedPicture",dialog_->activeFile->url());
config_->writeEntry("InactiveUserdefined",dialog_->userPicture2->isChecked());
config_->writeEntry("InactiveUserdefinedPicture",dialog_->inactiveFile->url());
config_->writeEntry("OverlayModeActive",dialog_->overlay_active->currentItem());
config_->writeEntry("OverlayFileActive",dialog_->overlay_active_file->url());
config_->writeEntry("OverlayModeInactive",dialog_->overlay_inactive->currentItem());
config_->writeEntry("OverlayFileInactive",dialog_->overlay_inactive_file->url());
config_->writeEntry("LogoAlignment",dialog_->logoEnabled->selectedId());
config_->writeEntry("LogoFile",dialog_->logoFile->url());
config_->writeEntry("LogoActive",dialog_->logoActive->isChecked());
config_->writeEntry("LogoStretch",dialog_->logoStretch->currentItem());
config_->writeEntry("LogoDistance",dialog_->logoDistance->value());
config_->sync();
}
void CrystalConfig::infoDialog()
{
InfoDialog d(dialog_);
connect((TQLabel*)(d.kURLLabel1),TQT_SIGNAL(leftClickedURL(const TQString&)),TDEApplication::kApplication(),TQT_SLOT(invokeBrowser(const TQString &)));
d.exec();
}
void CrystalConfig::logoTextChanged(const TQString&)
{
updateLogo();
emit changed();
}
void CrystalConfig::overlay_active_changed(int a)
{
dialog_->overlay_active_file->setEnabled(a==4);
emit changed();
}
void CrystalConfig::overlay_inactive_changed(int a)
{
dialog_->overlay_inactive_file->setEnabled(a==4);
emit changed();
}
void CrystalConfig::updateLogo()
{
TQPixmap pic;
pic.load(dialog_->logoFile->url());
dialog_->logoPreview->setPixmap(pic);
}
void CrystalConfig::defaults()
{
TQRadioButton *button =
(TQRadioButton*)dialog_->titlealign->child("AlignHCenter");
if (button) button->setChecked(true);
dialog_->shade1->setValue(50);
dialog_->shade2->setValue(50);
}
extern "C"
{
KDE_EXPORT TQObject* allocate_config(TDEConfig* config, TQWidget* parent) {
return (new CrystalConfig(config, parent));
}
}
#include "crystalconfig.moc"