2007-07-20 16:19:09 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "advanced.h"
|
2007-07-21 10:20:51 +00:00
|
|
|
#include "advanced.moc"
|
2007-07-20 16:19:09 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
KWinAdvancedCompositingOptions::KWinAdvancedCompositingOptions(QWidget* parent, KSharedConfigPtr config) :
|
|
|
|
KDialog(parent)
|
|
|
|
{
|
|
|
|
mKWinConfig = config;
|
|
|
|
|
|
|
|
setCaption(i18n("Advanced compositing options"));
|
|
|
|
setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
|
|
|
|
setModal(true);
|
|
|
|
|
|
|
|
QWidget* mainWidget = new QWidget(this);
|
|
|
|
ui.setupUi(mainWidget);
|
|
|
|
setMainWidget(mainWidget);
|
|
|
|
|
2007-08-27 12:53:56 +00:00
|
|
|
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(compositingModeChanged()));
|
|
|
|
|
2007-07-20 16:19:09 +00:00
|
|
|
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2007-07-20 18:50:51 +00:00
|
|
|
connect(ui.glMode, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2007-08-24 17:34:09 +00:00
|
|
|
connect(ui.glTextureFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2007-07-20 18:50:51 +00:00
|
|
|
connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
|
|
|
connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
2007-07-20 16:19:09 +00:00
|
|
|
|
|
|
|
connect(this, SIGNAL(okClicked()), this, SLOT(save()));
|
|
|
|
connect(this, SIGNAL(applyClicked()), this, SLOT(save()));
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
|
|
|
enableButtonApply(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
KWinAdvancedCompositingOptions::~KWinAdvancedCompositingOptions()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinAdvancedCompositingOptions::changed()
|
|
|
|
{
|
|
|
|
enableButtonApply(true);
|
|
|
|
}
|
|
|
|
|
2007-08-27 12:53:56 +00:00
|
|
|
void KWinAdvancedCompositingOptions::compositingModeChanged()
|
|
|
|
{
|
|
|
|
ui.glGroup->setEnabled(ui.compositingType->currentIndex() == 0);
|
|
|
|
}
|
|
|
|
|
2007-07-20 16:19:09 +00:00
|
|
|
void KWinAdvancedCompositingOptions::load()
|
|
|
|
{
|
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
|
|
|
QString backend = config.readEntry("Backend", "OpenGL");
|
|
|
|
ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0);
|
2007-07-20 18:50:51 +00:00
|
|
|
QString glMode = config.readEntry("GLMode", "TFP");
|
|
|
|
ui.glMode->setCurrentIndex((glMode == "TFP") ? 0 : ((glMode == "SHM") ? 1 : 2));
|
2007-08-24 17:34:09 +00:00
|
|
|
ui.glTextureFilter->setCurrentIndex(config.readEntry("GLTextureFilter", 1));
|
2007-07-20 18:50:51 +00:00
|
|
|
ui.glDirect->setChecked(config.readEntry("GLDirect", true));
|
|
|
|
ui.glVSync->setChecked(config.readEntry("GLVSync", true));
|
2007-07-20 16:19:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KWinAdvancedCompositingOptions::save()
|
|
|
|
{
|
|
|
|
// Is this ok?
|
|
|
|
if (!isButtonEnabled(KDialog::Apply)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
|
|
|
config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender");
|
2007-07-20 18:50:51 +00:00
|
|
|
QString glModes[] = { "TFP", "SHM", "Fallback" };
|
|
|
|
config.writeEntry("GLMode", glModes[ui.glMode->currentIndex()]);
|
2007-08-24 17:34:09 +00:00
|
|
|
config.writeEntry("GLTextureFilter", ui.glTextureFilter->currentIndex());
|
2007-07-20 18:50:51 +00:00
|
|
|
config.writeEntry("GLDirect", ui.glDirect->isChecked());
|
|
|
|
config.writeEntry("GLVSync", ui.glVSync->isChecked());
|
2007-07-20 16:19:09 +00:00
|
|
|
|
|
|
|
enableButtonApply(false);
|
|
|
|
emit configSaved();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|