~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kcontrol/screensaver/advanceddialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ana Beatriz Guerrero Lopez
  • Date: 2009-04-05 05:22:13 UTC
  • mfrom: (0.4.2 experimental) (0.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 235.
  • Revision ID: james.westby@ubuntu.com-20090405052213-39thr4l6p2ss07uj
Tags: 4:4.2.2-1
* New upstream release:
  - khtml fixes. (Closes: #290285, #359680)
  - Default konsole sessions can be deleted. (Closes: #286342)
  - Tag widget uses standard application palette. (Closes: #444800)
  - ... and surely many more but we have lost track...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <klocale.h>
2
 
#include <kstandarddirs.h>
3
 
#include <qcombobox.h>
4
 
#include <kdebug.h>
5
 
 
6
 
#include <qwhatsthis.h>
7
 
#include <qstring.h>
8
 
 
9
 
#include <config.h>
10
 
 
11
 
#include "advanceddialog.h"
12
 
#include "advanceddialogimpl.h"
13
 
#include "stdlib.h"
14
 
 
15
 
#include "advanceddialog.moc"
16
 
 
17
 
KScreenSaverAdvancedDialog::KScreenSaverAdvancedDialog(QWidget *parent, const char* name)
18
 
 : KDialogBase( parent, name, true, i18n( "Advanced Options" ),
19
 
                Ok | Cancel, Ok, true )
20
 
{
21
 
        
22
 
        dialog = new AdvancedDialog(this);
23
 
        setMainWidget(dialog);
24
 
 
25
 
        readSettings();
26
 
 
27
 
        connect(dialog->qcbPriority, SIGNAL(activated(int)),
28
 
                this, SLOT(slotPriorityChanged(int)));
29
 
 
30
 
        connect(dialog->qcbTopLeft, SIGNAL(activated(int)),
31
 
                this, SLOT(slotChangeTopLeftCorner(int)));
32
 
        connect(dialog->qcbTopRight, SIGNAL(activated(int)),
33
 
                this, SLOT(slotChangeTopLeftCorner(int)));
34
 
        connect(dialog->qcbBottomLeft, SIGNAL(activated(int)),
35
 
                this, SLOT(slotChangeTopLeftCorner(int)));
36
 
        connect(dialog->qcbBottomRight, SIGNAL(activated(int)),
37
 
                this, SLOT(slotChangeTopLeftCorner(int)));
38
 
 
39
 
#ifndef HAVE_SETPRIORITY
40
 
    dialog->qgbPriority->setEnabled(false);
41
 
#endif
42
 
}
43
 
 
44
 
void KScreenSaverAdvancedDialog::readSettings()
45
 
{
46
 
        KConfig *config = new KConfig("kdesktoprc");
47
 
        config->setGroup("ScreenSaver");
48
 
        
49
 
        mPriority = config->readNumEntry("Priority", 19);
50
 
        if (mPriority < 0) mPriority = 0;
51
 
        if (mPriority > 19) mPriority = 19;
52
 
        
53
 
        dialog->qcbTopLeft->setCurrentItem(config->readNumEntry("ActionTopLeft", 0));    
54
 
        dialog->qcbTopRight->setCurrentItem(config->readNumEntry("ActionTopRight", 0));
55
 
        dialog->qcbBottomLeft->setCurrentItem(config->readNumEntry("ActionBottomLeft", 0));
56
 
        dialog->qcbBottomRight->setCurrentItem(config->readNumEntry("ActionBottomRight", 0));
57
 
 
58
 
 
59
 
        switch(mPriority)
60
 
        {
61
 
                case 19: // Low
62
 
                        dialog->qcbPriority->setCurrentItem(0);
63
 
                        kdDebug() << "setting low" << endl;
64
 
                        break;
65
 
                case 10: // Medium
66
 
                        dialog->qcbPriority->setCurrentItem(1);
67
 
                        kdDebug() << "setting medium" << endl;
68
 
                        break;
69
 
                case 0: // High
70
 
                        dialog->qcbPriority->setCurrentItem(2);
71
 
                        kdDebug() << "setting high" << endl;
72
 
                        break;
73
 
        }
74
 
        
75
 
        mChanged = false;
76
 
        delete config;
77
 
}
78
 
 
79
 
void KScreenSaverAdvancedDialog::slotPriorityChanged(int val)
80
 
{
81
 
        switch (val)
82
 
        {
83
 
                case 0: // Low
84
 
                        mPriority = 19;
85
 
                        kdDebug() << "low priority" << endl;
86
 
                        break;
87
 
                case 1: // Medium
88
 
                        mPriority = 10;
89
 
                        kdDebug() << "medium priority" << endl;
90
 
                        break;
91
 
                case 2: // High
92
 
                        mPriority = 0;
93
 
                        kdDebug() << "high priority" << endl;
94
 
                        break;
95
 
        }
96
 
        mChanged = true;
97
 
}
98
 
 
99
 
void KScreenSaverAdvancedDialog::slotOk()
100
 
{
101
 
        if (mChanged)
102
 
        {
103
 
                KConfig *config = new KConfig("kdesktoprc");
104
 
                config->setGroup( "ScreenSaver" );
105
 
        
106
 
                config->writeEntry("Priority", mPriority);
107
 
                config->writeEntry(
108
 
                "ActionTopLeft", dialog->qcbTopLeft->currentItem());
109
 
                config->writeEntry(
110
 
                "ActionTopRight", dialog->qcbTopRight->currentItem());
111
 
                config->writeEntry(
112
 
                "ActionBottomLeft", dialog->qcbBottomLeft->currentItem());
113
 
                config->writeEntry(
114
 
                "ActionBottomRight", dialog->qcbBottomRight->currentItem());
115
 
                config->sync();
116
 
                delete config;
117
 
        }
118
 
        accept();
119
 
}
120
 
 
121
 
void KScreenSaverAdvancedDialog::slotChangeBottomRightCorner(int)
122
 
{
123
 
        mChanged = true;
124
 
}
125
 
 
126
 
void KScreenSaverAdvancedDialog::slotChangeBottomLeftCorner(int)
127
 
{
128
 
        mChanged = true;
129
 
}
130
 
 
131
 
void KScreenSaverAdvancedDialog::slotChangeTopRightCorner(int)
132
 
{
133
 
        mChanged = true;
134
 
}
135
 
 
136
 
void KScreenSaverAdvancedDialog::slotChangeTopLeftCorner(int)
137
 
{
138
 
        mChanged = true;
139
 
}
140
 
 
141
 
/* =================================================================================================== */
142
 
 
143
 
AdvancedDialog::AdvancedDialog(QWidget *parent, const char *name) : AdvancedDialogImpl(parent, name)
144
 
{
145
 
        monitorLabel->setPixmap(QPixmap(locate("data", "kcontrol/pics/monitor.png")));
146
 
        QWhatsThis::add(qcbPriority, "<qt>" + i18n("Specify the priority that the screensaver will run at. A higher priority may mean that the screensaver runs faster, though may reduce the speed that other programs run at while the screensaver is active.") + "</qt>");
147
 
        QString qsTopLeft("<qt>" +  i18n("The action to take when the mouse cursor is located in the top left corner of the screen for 15 seconds.") + "</qt>");
148
 
        QString qsTopRight("<qt>" +  i18n("The action to take when the mouse cursor is located in the top right corner of the screen for 15 seconds.") + "</qt>");
149
 
        QString qsBottomLeft("<qt>" +  i18n("The action to take when the mouse cursor is located in the bottom left corner of the screen for 15 seconds.") + "</qt>");
150
 
        QString qsBottomRight("<qt>" +  i18n("The action to take when the mouse cursor is located in the bottom right corner of the screen for 15 seconds.") + "</qt>");
151
 
        QWhatsThis::add(qlTopLeft, qsTopLeft);
152
 
        QWhatsThis::add(qcbTopLeft, qsTopLeft);
153
 
        QWhatsThis::add(qlTopRight, qsTopRight);
154
 
        QWhatsThis::add(qcbTopRight, qsTopRight);
155
 
        QWhatsThis::add(qlBottomLeft, qsBottomLeft);
156
 
        QWhatsThis::add(qcbBottomLeft, qsBottomLeft);
157
 
        QWhatsThis::add(qlBottomRight, qsBottomRight);
158
 
        QWhatsThis::add(qcbBottomRight, qsBottomRight);
159
 
}
160
 
 
161
 
AdvancedDialog::~AdvancedDialog()
162
 
{
163
 
 
164
 
}
165
 
 
166
 
void AdvancedDialog::setMode(QComboBox *box, int i)
167
 
{
168
 
        box->setCurrentItem(i);
169
 
}
170
 
 
171
 
int AdvancedDialog::mode(QComboBox *box)
172
 
{
173
 
        return box->currentItem();
174
 
}