1
/*****************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
7
You can Freely distribute this program under the GNU General Public
8
License. See the file "COPYING" for the exact licensing terms.
9
******************************************************************/
12
#include "advanced.moc"
18
KWinAdvancedCompositingOptions::KWinAdvancedCompositingOptions(QWidget* parent, KSharedConfigPtr config) :
23
setCaption(i18n("Advanced compositing options"));
24
setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
27
QWidget* mainWidget = new QWidget(this);
28
ui.setupUi(mainWidget);
29
setMainWidget(mainWidget);
31
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(compositingModeChanged()));
33
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
34
connect(ui.glMode, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
35
connect(ui.glTextureFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
36
connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed()));
37
connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed()));
39
connect(this, SIGNAL(okClicked()), this, SLOT(save()));
40
connect(this, SIGNAL(applyClicked()), this, SLOT(save()));
44
enableButtonApply(false);
47
KWinAdvancedCompositingOptions::~KWinAdvancedCompositingOptions()
51
void KWinAdvancedCompositingOptions::changed()
53
enableButtonApply(true);
56
void KWinAdvancedCompositingOptions::compositingModeChanged()
58
ui.glGroup->setEnabled(ui.compositingType->currentIndex() == 0);
61
void KWinAdvancedCompositingOptions::load()
63
KConfigGroup config(mKWinConfig, "Compositing");
64
QString backend = config.readEntry("Backend", "OpenGL");
65
ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0);
66
QString glMode = config.readEntry("GLMode", "TFP");
67
ui.glMode->setCurrentIndex((glMode == "TFP") ? 0 : ((glMode == "SHM") ? 1 : 2));
68
ui.glTextureFilter->setCurrentIndex(config.readEntry("GLTextureFilter", 1));
69
ui.glDirect->setChecked(config.readEntry("GLDirect", true));
70
ui.glVSync->setChecked(config.readEntry("GLVSync", true));
73
void KWinAdvancedCompositingOptions::save()
76
if (!isButtonEnabled(KDialog::Apply)) {
80
KConfigGroup config(mKWinConfig, "Compositing");
81
config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender");
82
QString glModes[] = { "TFP", "SHM", "Fallback" };
83
config.writeEntry("GLMode", glModes[ui.glMode->currentIndex()]);
84
config.writeEntry("GLTextureFilter", ui.glTextureFilter->currentIndex());
85
config.writeEntry("GLDirect", ui.glDirect->isChecked());
86
config.writeEntry("GLVSync", ui.glVSync->isChecked());
88
enableButtonApply(false);