summaryrefslogtreecommitdiffstats
path: root/styles/phase/config/phasestyleconfig.cpp
blob: 8543214c49b94305ea0aa9c3c82f913c62919208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//////////////////////////////////////////////////////////////////////////////
// phasestyleconfig.cpp
// -------------------
// Config dialog for Phase widget style
// -------------------
// Copyright (c) 2004 David Johnson <david@usermode.org>
// Please see the header file for copyright and license information.
//////////////////////////////////////////////////////////////////////////////

#include <qsettings.h>
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qwhatsthis.h>
#include <klocale.h>
#include <kglobal.h>

#include "phasestyleconfig.h"
#include "styledialog.h"

//////////////////////////////////////////////////////////////////////////////
// PhaseStyleConfig Class                                                    //
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// PhaseStyleConfig()
// ----------------
// Constructor

PhaseStyleConfig::PhaseStyleConfig(QWidget* parent) : StyleDialog(parent)
{
    KGlobal::locale()->insertCatalogue("kstyle_phase_config");

    QSettings settings;
    oldgradients =
        settings.readBoolEntry("/phasestyle/Settings/gradients", true);
    gradients->setChecked(oldgradients);
    oldhighlights =
        settings.readBoolEntry("/phasestyle/Settings/highlights", true);
    highlights->setChecked(oldhighlights);

    // connections
    connect(gradients, SIGNAL(toggled(bool)),
            this, SLOT(updateChanged()));
    connect(highlights, SIGNAL(toggled(bool)),
            this, SLOT(updateChanged()));
}

//////////////////////////////////////////////////////////////////////////////
// ~PhaseStyleConfig()
// -----------------
// Destructor

PhaseStyleConfig::~PhaseStyleConfig()
{
    KGlobal::locale()->removeCatalogue("kstyle_phase_config");
}

//////////////////////////////////////////////////////////////////////////////
// selectionChanged()
// ------------------
// Selection has changed

void PhaseStyleConfig::updateChanged()
{
    bool update = false;

    if ((gradients->isChecked() != oldgradients) ||
        (highlights->isChecked() != oldhighlights)) {
        update = true;
    }

    emit changed(update);
}

//////////////////////////////////////////////////////////////////////////////
// save()
// ------
// Save the settings

void PhaseStyleConfig::save()
{
    QSettings settings;
    settings.writeEntry("/phasestyle/Settings/gradients",
                        gradients->isChecked());
    settings.writeEntry("/phasestyle/Settings/highlights",
                        highlights->isChecked());
}

//////////////////////////////////////////////////////////////////////////////
// defaults()
// ----------
// Set to the defaults

void PhaseStyleConfig::defaults()
{
    gradients->setChecked(true);
    highlights->setChecked(true);
}

//////////////////////////////////////////////////////////////////////////////
// Plugin Stuff                                                             //
//////////////////////////////////////////////////////////////////////////////

extern "C"
{
    KDE_EXPORT QObject* allocate_kstyle_config(QWidget* parent) {
        return(new PhaseStyleConfig(parent));
    }
}

#include "phasestyleconfig.moc"