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

« back to all changes in this revision

Viewing changes to kstyles/highcontrast/config/highcontrastconfig.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
Copyright (c) 2005 Luciano Montanaro <mikelima@cirulla.net>
 
3
 
 
4
based on the Keramick configuration dialog 
 
5
Copyright (c) 2003 Maksim Orlovich <maksim.orlovich@kdemail.net>
 
6
 
 
7
Permission is hereby granted, free of charge, to any person obtaining a
 
8
copy of this software and associated documentation files (the "Software"),
 
9
to deal in the Software without restriction, including without limitation
 
10
the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
11
and/or sell copies of the Software, and to permit persons to whom the
 
12
Software is furnished to do so, subject to the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice shall be included in
 
15
all copies or substantial portions of the Software.
 
16
 
 
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
20
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
21
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
23
DEALINGS IN THE SOFTWARE.
 
24
 
 
25
*/
 
26
 
 
27
#include "highcontrastconfig.h"
 
28
 
 
29
#include <QtGui/QCheckBox>
 
30
#include <QtGui/QLayout>
 
31
#include <QtCore/QSettings>
 
32
#include <kdialog.h>
 
33
#include <kglobal.h>
 
34
#include <klocale.h>
 
35
 
 
36
extern "C" KDE_EXPORT QWidget* 
 
37
allocate_kstyle_config(QWidget* parent)
 
38
{
 
39
    return new HighContrastStyleConfig(parent);
 
40
}
 
41
 
 
42
HighContrastStyleConfig::HighContrastStyleConfig(
 
43
        QWidget* parent): QWidget(parent)
 
44
{
 
45
    // Should have no margins here, the dialog provides them
 
46
    QVBoxLayout* layout = new QVBoxLayout(this, 0, 0);
 
47
    KGlobal::locale()->insertCatalog("kstyle_config");
 
48
 
 
49
    wideLinesBox = new QCheckBox(i18n("Use wider lines"), this);
 
50
 
 
51
    layout->add(wideLinesBox);
 
52
    layout->addStretch(1);
 
53
 
 
54
    QSettings s;
 
55
 
 
56
    originalWideLinesState = s.readBoolEntry(
 
57
            "/highcontraststyle/Settings/wideLines", false);
 
58
    wideLinesBox->setChecked(originalWideLinesState);
 
59
 
 
60
    connect(wideLinesBox, SIGNAL(toggled(bool)), SLOT(updateChanged()));
 
61
}
 
62
 
 
63
HighContrastStyleConfig::~HighContrastStyleConfig()
 
64
{
 
65
    KGlobal::locale()->removeCatalog("kstyle_config");
 
66
}
 
67
 
 
68
 
 
69
void 
 
70
HighContrastStyleConfig::save()
 
71
{
 
72
    QSettings s;
 
73
    s.writeEntry("/highcontraststyle/Settings/wideLines", 
 
74
            wideLinesBox->isChecked());
 
75
}
 
76
 
 
77
void 
 
78
HighContrastStyleConfig::defaults()
 
79
{
 
80
    wideLinesBox->setChecked(false);
 
81
    // updateChanged would be done by setChecked already
 
82
}
 
83
 
 
84
void 
 
85
HighContrastStyleConfig::updateChanged()
 
86
{
 
87
    if ((wideLinesBox->isChecked() == originalWideLinesState)) {
 
88
        emit changed(false);
 
89
    } else {
 
90
        emit changed(true);
 
91
    }
 
92
}
 
93
 
 
94
#include "highcontrastconfig.moc"