~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kwin/kcmkwin/kwincompositing/advanced.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
 
6
 
 
7
You can Freely distribute this program under the GNU General Public
 
8
License. See the file "COPYING" for the exact licensing terms.
 
9
******************************************************************/
 
10
 
 
11
#include "advanced.h"
 
12
#include "advanced.moc"
 
13
#include <klocale.h>
 
14
 
 
15
namespace KWin
 
16
{
 
17
 
 
18
KWinAdvancedCompositingOptions::KWinAdvancedCompositingOptions(QWidget* parent, KSharedConfigPtr config) :
 
19
        KDialog(parent)
 
20
{
 
21
    mKWinConfig = config;
 
22
 
 
23
    setCaption(i18n("Advanced compositing options"));
 
24
    setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply);
 
25
    setModal(true);
 
26
 
 
27
    QWidget* mainWidget = new QWidget(this);
 
28
    ui.setupUi(mainWidget);
 
29
    setMainWidget(mainWidget);
 
30
 
 
31
    connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(compositingModeChanged()));
 
32
 
 
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()));
 
38
 
 
39
    connect(this, SIGNAL(okClicked()), this, SLOT(save()));
 
40
    connect(this, SIGNAL(applyClicked()), this, SLOT(save()));
 
41
 
 
42
    load();
 
43
 
 
44
    enableButtonApply(false);
 
45
}
 
46
 
 
47
KWinAdvancedCompositingOptions::~KWinAdvancedCompositingOptions()
 
48
{
 
49
}
 
50
 
 
51
void KWinAdvancedCompositingOptions::changed()
 
52
{
 
53
    enableButtonApply(true);
 
54
}
 
55
 
 
56
void KWinAdvancedCompositingOptions::compositingModeChanged()
 
57
{
 
58
    ui.glGroup->setEnabled(ui.compositingType->currentIndex() == 0);
 
59
}
 
60
 
 
61
void KWinAdvancedCompositingOptions::load()
 
62
{
 
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));
 
71
}
 
72
 
 
73
void KWinAdvancedCompositingOptions::save()
 
74
{
 
75
    // Is this ok?
 
76
    if (!isButtonEnabled(KDialog::Apply)) {
 
77
        return;
 
78
    }
 
79
 
 
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());
 
87
 
 
88
    enableButtonApply(false);
 
89
    emit configSaved();
 
90
}
 
91
 
 
92
} // namespace
 
93