~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/effects/translucency/translucency_config.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

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
This program is free software; you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation; either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
*********************************************************************/
 
20
 
 
21
#include "translucency_config.h"
 
22
 
 
23
#include <kwineffects.h>
 
24
 
 
25
#include <klocale.h>
 
26
#include <kdebug.h>
 
27
#include <kconfiggroup.h>
 
28
 
 
29
#include <QVBoxLayout>
 
30
#include <QCheckBox>
 
31
 
 
32
namespace KWin
 
33
{
 
34
 
 
35
KWIN_EFFECT_CONFIG_FACTORY
 
36
 
 
37
TranslucencyEffectConfigForm::TranslucencyEffectConfigForm(QWidget* parent) : QWidget(parent)
 
38
{
 
39
    setupUi(this);
 
40
}
 
41
 
 
42
TranslucencyEffectConfig::TranslucencyEffectConfig(QWidget* parent, const QVariantList& args) :
 
43
    KCModule(EffectFactory::componentData(), parent, args)
 
44
{
 
45
    m_ui = new TranslucencyEffectConfigForm(this);
 
46
    QVBoxLayout* layout = new QVBoxLayout(this);
 
47
    layout->addWidget(m_ui);
 
48
 
 
49
    connect(m_ui->decorations, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
50
    connect(m_ui->inactive, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
51
    connect(m_ui->moveresize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
52
    connect(m_ui->dialogs, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
53
    connect(m_ui->comboboxpopup, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
54
    connect(m_ui->menus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
55
    connect(m_ui->individualmenuconfig, SIGNAL(toggled(bool)), this, SLOT(changed()));
 
56
    connect(m_ui->dropdownmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
57
    connect(m_ui->popupmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
58
    connect(m_ui->tornoffmenus, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
59
    connect(m_ui->duration, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
60
 
 
61
    load();
 
62
}
 
63
 
 
64
void TranslucencyEffectConfig::load()
 
65
{
 
66
    KCModule::load();
 
67
 
 
68
    KConfigGroup conf = EffectsHandler::effectConfig("Translucency");
 
69
    m_ui->decorations->setValue((int)(conf.readEntry("Decoration", 1.0) * 100));
 
70
    m_ui->moveresize->setValue((int)(conf.readEntry("MoveResize", 0.8) * 100));
 
71
    m_ui->dialogs->setValue((int)(conf.readEntry("Dialogs", 1.0) * 100));
 
72
    m_ui->inactive->setValue((int)(conf.readEntry("Inactive", 1.0) * 100));
 
73
    m_ui->comboboxpopup->setValue((int)(conf.readEntry("ComboboxPopups", 1.0) * 100));
 
74
    m_ui->menus->setValue((int)(conf.readEntry("Menus", 1.0) * 100));
 
75
    m_ui->individualmenuconfig->setChecked((conf.readEntry("IndividualMenuConfig", false)));
 
76
    m_ui->dropdownmenus->setValue((int)(conf.readEntry("DropdownMenus", 1.0) * 100));
 
77
    m_ui->popupmenus->setValue((int)(conf.readEntry("PopupMenus", 1.0) * 100));
 
78
    m_ui->tornoffmenus->setValue((int)(conf.readEntry("TornOffMenus", 1.0) * 100));
 
79
    m_ui->duration->setValue(conf.readEntry("Duration", 0));
 
80
    m_ui->duration->setSuffix(ki18np(" millisecond", " milliseconds"));
 
81
 
 
82
    emit changed(false);
 
83
}
 
84
 
 
85
void TranslucencyEffectConfig::save()
 
86
{
 
87
    KCModule::save();
 
88
 
 
89
    KConfigGroup conf = EffectsHandler::effectConfig("Translucency");
 
90
    conf.writeEntry("Decoration", m_ui->decorations->value() / 100.0);
 
91
    conf.writeEntry("MoveResize", m_ui->moveresize->value() / 100.0);
 
92
    conf.writeEntry("Dialogs", m_ui->dialogs->value() / 100.0);
 
93
    conf.writeEntry("Inactive", m_ui->inactive->value() / 100.0);
 
94
    conf.writeEntry("ComboboxPopups", m_ui->comboboxpopup->value() / 100.0);
 
95
    conf.writeEntry("Menus", m_ui->menus->value() / 100.0);
 
96
    conf.writeEntry("IndividualMenuConfig", m_ui->individualmenuconfig->isChecked());
 
97
    conf.writeEntry("DropdownMenus", m_ui->dropdownmenus->value() / 100.0);
 
98
    conf.writeEntry("PopupMenus", m_ui->popupmenus->value() / 100.0);
 
99
    conf.writeEntry("TornOffMenus", m_ui->tornoffmenus->value() / 100.0);
 
100
    conf.writeEntry("Duration", m_ui->duration->value());
 
101
    conf.sync();
 
102
 
 
103
    emit changed(false);
 
104
    EffectsHandler::sendReloadMessage("translucency");
 
105
}
 
106
 
 
107
void TranslucencyEffectConfig::defaults()
 
108
{
 
109
    m_ui->decorations->setValue(100);
 
110
    m_ui->moveresize->setValue(80);
 
111
    m_ui->dialogs->setValue(100);
 
112
    m_ui->inactive->setValue(100);
 
113
    m_ui->comboboxpopup->setValue(100);
 
114
    m_ui->menus->setValue(100);
 
115
    m_ui->individualmenuconfig->setChecked(false);
 
116
    m_ui->dropdownmenus->setValue(100);
 
117
    m_ui->popupmenus->setValue(100);
 
118
    m_ui->tornoffmenus->setValue(100);
 
119
    m_ui->duration->setValue(0);
 
120
    emit changed(true);
 
121
}
 
122
 
 
123
 
 
124
} // namespace
 
125
 
 
126
#include "translucency_config.moc"