summaryrefslogtreecommitdiffstats
path: root/kcontrol/accessibility/accessibility.cpp
blob: c34f7be64286159cf6104ee948d1224f4e159ce6 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/****************************************************************************
  accessibility.cpp
  KDE Control Accessibility module to control Bell, Keyboard and ?Mouse?
  -------------------
  Copyright : (c) 2000 Matthias Hölzer-Klüpfel
  -------------------
  Original Author: Matthias Hölzer-Klüpfel
  Contributors: José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org>
  Current Maintainer: José Pablo Ezequiel "Pupeno" Fernández <pupeno@kde.org>
 ****************************************************************************/

/****************************************************************************
 *                                                                          *
 *   This program is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 2 of the License, or      *
 *   (at your option) any later version.                                    *
 *                                                                          *
 ****************************************************************************/

#include <tqcheckbox.h>
#include <tqradiobutton.h>
#include <tqtabwidget.h>

#include <tdeaboutdata.h>
#include <kcolorbutton.h>
#include <tdeconfig.h>
#include <kgenericfactory.h>
#include <knuminput.h>
#include <kurlrequester.h>

#include "accessibility.moc"

typedef KGenericFactory<AccessibilityConfig, TQWidget> AccessibilityFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_accessibility, AccessibilityFactory("kcmaccessibility") )

/**
 * This function checks if the kaccess daemon needs to be run
 * This function will be deprecated since the kaccess daemon will be part of kded
 */
// static bool needToRunKAccessDaemon( TDEConfig *config ){
//    TDEConfigGroup group( config, "Bell" );
//
//    if(!group.readBoolEntry("SystemBell", true)){
//       return true;
//    }
//    if(group.readBoolEntry("ArtsBell", false)){
//       return true;
//    }
//    if(group.readBoolEntry("VisibleBell", false)){
//       return true;
//    }
//    return false; // don't need it
// }

AccessibilityConfig::AccessibilityConfig(TQWidget *parent, const char *name, const TQStringList &)
  : AccessibilityConfigWidget( parent, name){

   TDEAboutData *about =
   new TDEAboutData(I18N_NOOP("kcmaccessiblity"), I18N_NOOP("TDE Accessibility Tool"),
                  0, 0, TDEAboutData::License_GPL,
                  I18N_NOOP("(c) 2000, Matthias Hoelzer-Kluepfel"));

   about->addAuthor("Matthias Hoelzer-Kluepfel", I18N_NOOP("Author") , "hoelzer@kde.org");
   about->addAuthor("José Pablo Ezequiel Fernández", I18N_NOOP("Author") , "pupeno@kde.org");
   setAboutData( about );

   kdDebug() << "Running: AccessibilityConfig::AccessibilityConfig(TQWidget *parent, const char *name, const TQStringList &)" << endl;
   // TODO: set the KURL Dialog to open just audio files
   connect( mainTab, TQT_SIGNAL(currentChanged(TQWidget*)), this, TQT_SIGNAL(quickHelpChanged()) );
   load();
}


AccessibilityConfig::~AccessibilityConfig(){
   kdDebug() << "Running: AccessibilityConfig::~AccessibilityConfig()" << endl;
}

void AccessibilityConfig::load()
{
   load( false );
}

void AccessibilityConfig::load( bool useDefaults )
{
   kdDebug() << "Running: AccessibilityConfig::load()" << endl;
   
   TDEConfig *bell = new TDEConfig("bellrc", true);
  
   bell->setReadDefaults( useDefaults );

   bell->setGroup("General");
   systemBell->setChecked(bell->readBoolEntry("SystemBell", false));
   customBell->setChecked(bell->readBoolEntry("CustomBell", false));
   visibleBell->setChecked(bell->readBoolEntry("VisibleBell", false));
   
   bell->setGroup("CustomBell");
   soundToPlay->setURL(bell->readPathEntry("Sound", ""));

   bell->setGroup("Visible");
   invertScreen->setChecked(bell->readBoolEntry("Invert", true));
   flashScreen->setChecked(bell->readBoolEntry("Flash", false));
   // TODO: There has to be a cleaner way.
   TQColor *redColor = new TQColor(Qt::red);
   flashScreenColor->setColor(bell->readColorEntry("FlashColor", redColor));
   delete redColor;
   visibleBellDuration->setValue(bell->readNumEntry("Duration", 500));
  
   delete bell;
   emit changed( useDefaults );
}


void AccessibilityConfig::save(){
   kdDebug() << "Running: AccessibilityConfig::save()" << endl;
   
   TDEConfig *bell = new TDEConfig("bellrc");
   
   bell->setGroup("General");
   bell->writeEntry("SystemBell", systemBell->isChecked());
   bell->writeEntry("CustomBell", customBell->isChecked());
   bell->writeEntry("VisibleBell", visibleBell->isChecked());
   
   bell->setGroup("CustomBell");
   bell->writePathEntry("Sound", soundToPlay->url());

   bell->setGroup("Visible");
   bell->writeEntry("Invert", invertScreen->isChecked());
   bell->writeEntry("Flash", flashScreen->isChecked());
   bell->writeEntry("FlashColor", flashScreenColor->color());
   bell->writeEntry("Duration", visibleBellDuration->value());
   
   bell->sync();
   delete bell;
}


void AccessibilityConfig::defaults()
{
   load( true );
}