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

« back to all changes in this revision

Viewing changes to kwin/effects/thumbnailaside/thumbnailaside_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 Christian Nitschkowski <christian.nitschkowski@kdemail.net>
 
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 "thumbnailaside_config.h"
 
22
 
 
23
#include <kwineffects.h>
 
24
 
 
25
#include <klocale.h>
 
26
#include <kdebug.h>
 
27
#include <kconfiggroup.h>
 
28
#include <KActionCollection>
 
29
#include <kaction.h>
 
30
#include <KShortcutsEditor>
 
31
 
 
32
#include <QWidget>
 
33
#include <QVBoxLayout>
 
34
 
 
35
namespace KWin
 
36
{
 
37
 
 
38
KWIN_EFFECT_CONFIG_FACTORY
 
39
 
 
40
ThumbnailAsideEffectConfigForm::ThumbnailAsideEffectConfigForm(QWidget* parent) : QWidget(parent)
 
41
{
 
42
    setupUi(this);
 
43
}
 
44
 
 
45
ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QVariantList& args) :
 
46
    KCModule(EffectFactory::componentData(), parent, args)
 
47
{
 
48
    m_ui = new ThumbnailAsideEffectConfigForm(this);
 
49
 
 
50
    QVBoxLayout* layout = new QVBoxLayout(this);
 
51
 
 
52
    layout->addWidget(m_ui);
 
53
 
 
54
    connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
 
55
    connect(m_ui->spinWidth, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
56
    connect(m_ui->spinSpacing, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
57
    connect(m_ui->spinOpacity, SIGNAL(valueChanged(int)), this, SLOT(changed()));
 
58
 
 
59
    // Shortcut config. The shortcut belongs to the component "kwin"!
 
60
    m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
 
61
 
 
62
    m_actionCollection->setConfigGroup("ThumbnailAside");
 
63
    m_actionCollection->setConfigGlobal(true);
 
64
 
 
65
    KAction* a = (KAction*)m_actionCollection->addAction("ToggleCurrentThumbnail");
 
66
    a->setText(i18n("Toggle Thumbnail for Current Window"));
 
67
    a->setProperty("isConfigurationAction", true);
 
68
    a->setGlobalShortcut(KShortcut(Qt::META + Qt::CTRL + Qt::Key_T));
 
69
 
 
70
    m_ui->editor->addCollection(m_actionCollection);
 
71
 
 
72
}
 
73
 
 
74
ThumbnailAsideEffectConfig::~ThumbnailAsideEffectConfig()
 
75
{
 
76
    // Undo (only) unsaved changes to global key shortcuts
 
77
    m_ui->editor->undoChanges();
 
78
}
 
79
 
 
80
void ThumbnailAsideEffectConfig::load()
 
81
{
 
82
    KCModule::load();
 
83
 
 
84
    KConfigGroup conf = EffectsHandler::effectConfig("ThumbnailAside");
 
85
 
 
86
    int width = conf.readEntry("MaxWidth", 200);
 
87
    int spacing = conf.readEntry("Spacing", 10);
 
88
    int opacity = conf.readEntry("Opacity", 50);
 
89
    m_ui->spinWidth->setValue(width);
 
90
    m_ui->spinWidth->setSuffix(ki18np(" pixel", " pixels"));
 
91
    m_ui->spinSpacing->setValue(spacing);
 
92
    m_ui->spinSpacing->setSuffix(ki18np(" pixel", " pixels"));
 
93
    m_ui->spinOpacity->setValue(opacity);
 
94
 
 
95
    emit changed(false);
 
96
}
 
97
 
 
98
void ThumbnailAsideEffectConfig::save()
 
99
{
 
100
    kDebug(1212) << "Saving config of ThumbnailAside" ;
 
101
    //KCModule::save();
 
102
 
 
103
    KConfigGroup conf = EffectsHandler::effectConfig("ThumbnailAside");
 
104
 
 
105
    conf.writeEntry("MaxWidth", m_ui->spinWidth->value());
 
106
    conf.writeEntry("Spacing", m_ui->spinSpacing->value());
 
107
    conf.writeEntry("Opacity", m_ui->spinOpacity->value());
 
108
 
 
109
    m_actionCollection->writeSettings();
 
110
    m_ui->editor->save();   // undo() will restore to this state from now on
 
111
 
 
112
    conf.sync();
 
113
 
 
114
    emit changed(false);
 
115
    EffectsHandler::sendReloadMessage("thumbnailaside");
 
116
}
 
117
 
 
118
void ThumbnailAsideEffectConfig::defaults()
 
119
{
 
120
    m_ui->spinWidth->setValue(200);
 
121
    m_ui->spinSpacing->setValue(10);
 
122
    m_ui->spinOpacity->setValue(50);
 
123
    m_ui->editor->allDefault();
 
124
    emit changed(true);
 
125
 
 
126
 
 
127
}
 
128
 
 
129
 
 
130
} // namespace
 
131
 
 
132
#include "thumbnailaside_config.moc"