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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
/* This file is part of the KDE Project
Copyright (c) 2005 Kévin Ottens <ervin ipsquad net>
Copyright (c) 2006 Valentine Sinitsyn <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include "managermodule.h"
#include <tdeconfig.h>
#include <tdelocale.h>
#include <dcopref.h>
#include <tqbutton.h>
#include <tqcheckbox.h>
#include <kcombobox.h>
#include <tqlayout.h>
#include <tqobjectlist.h>
#include <kdirnotify_stub.h>
#include "managermoduleview.h"
#include "mediamanagersettings.h"
ManagerModule::ManagerModule( TQWidget* parent, const char* name )
: TDECModule( parent, name )
{
TQBoxLayout *layout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );
view = new ManagerModuleView( this );
layout->addWidget( view );
addConfig( MediaManagerSettings::self(), view );
#ifndef COMPILE_LINUXCDPOLLING
TQString poll_text = view->kcfg_CdPollingEnabled->text();
poll_text += " ("+i18n("No support for CD polling on this system")+")";
view->kcfg_CdPollingEnabled->setText( poll_text );
#endif
view->kcfg_CdPollingEnabled->setEnabled( false );
connect( view->option_automount, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_ro, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_quiet, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_flush, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_uid, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_utf8, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_sync, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_atime, SIGNAL( stateChanged(int) ), this, SLOT( emitChanged() ) );
connect( view->option_shortname, SIGNAL( activated(int) ), this, SLOT( emitChanged() ) );
connect( view->option_journaling, SIGNAL( activated(int) ), this, SLOT( emitChanged() ) );
load();
}
void ManagerModule::load()
{
TDECModule::load();
TDEConfig config("mediamanagerrc");
config.setGroup("DefaultOptions");
view->option_automount->setChecked( config.readBoolEntry("automount", false) );
view->option_ro->setChecked( config.readBoolEntry("ro", false) );
view->option_quiet->setChecked( config.readBoolEntry("quiet", false) );
if (config.hasKey("flush"))
view->option_flush->setChecked( config.readBoolEntry("flush") );
else
view->option_flush->setNoChange();
view->option_uid->setChecked( config.readBoolEntry("uid", true) );
view->option_utf8->setChecked( config.readBoolEntry("utf8", true) );
if (config.hasKey("sync"))
view->option_sync->setChecked( config.readBoolEntry("sync") );
else
view->option_sync->setNoChange();
if (config.hasKey("atime"))
view->option_atime->setChecked( config.readBoolEntry("atime") );
else
view->option_atime->setNoChange();
QString value;
value = config.readEntry("shortname", "lower").lower();
for (int i = 0; i < view->option_shortname->count(); i++)
if (view->option_shortname->text(i).lower() == value) view->option_shortname->setCurrentItem(i);
value = config.readEntry("journaling", "ordered").lower();
for (int i = 0; i < view->option_journaling->count(); i++)
if (view->option_journaling->text(i).lower() == value) view->option_journaling->setCurrentItem(i);
rememberSettings();
}
void ManagerModule::save()
{
TDECModule::save();
TDEConfig config("mediamanagerrc");
config.setGroup("DefaultOptions");
config.writeEntry("automount", view->option_automount->isChecked());
config.writeEntry("ro", view->option_ro->isChecked());
config.writeEntry("quiet", view->option_quiet->isChecked());
if (view->option_flush->state() == TQButton::NoChange)
config.deleteEntry("flush");
else
config.writeEntry("flush", view->option_flush->isChecked());
config.writeEntry("uid", view->option_uid->isChecked());
config.writeEntry("utf8", view->option_utf8->isChecked());
if (view->option_sync->state() == TQButton::NoChange)
config.deleteEntry("sync");
else
config.writeEntry("sync", view->option_sync->isChecked());
if (view->option_atime->state() == TQButton::NoChange)
config.deleteEntry("atime");
else
config.writeEntry("atime", view->option_atime->isChecked());
config.writeEntry("journaling", view->option_journaling->currentText().lower());
config.writeEntry("shortname", view->option_shortname->currentText().lower());
rememberSettings();
DCOPRef kded( "kded", "kded" );
// DCOPReply reply = mediamanager.call( "reloadBackends" );
// Well... reloadBackends had issues with HAL, it seems it was linked
// to a bug in the unmaintained Qt3 DBUS binding, but it is not quite clear.
// It may be ok now that HAL is no longer supported but needs to be tested.
// So we use this hack instead...
kded.call( "unloadModule", "mediamanager" );
kded.call( "loadModule", "mediamanager" );
KDirNotify_stub notifier( "*", "*" );
notifier.FilesAdded( "media:/" );
}
void ManagerModule::defaults()
{
TDECModule::defaults();
view->option_automount->setChecked(false);
view->option_ro->setChecked(false);
view->option_quiet->setChecked(false);
view->option_flush->setNoChange();
view->option_uid->setChecked(true);
view->option_utf8->setChecked(true);
view->option_sync->setNoChange();
view->option_atime->setNoChange();
view->option_journaling->setCurrentItem(1);
view->option_shortname->setCurrentItem(0);
}
void ManagerModule::rememberSettings()
{
TQObjectList *options = view->queryList(0, "^option_");
TQObject *current = 0;
TQObjectListIterator it(*options);
settings.clear();
while ( (current = it.current()) != 0 ) {
if (current->isA("TQCheckBox"))
settings[current] = ((TQCheckBox *)current)->state();
else if (current->isA("TQComboBox"))
settings[current] = ((TQComboBox *)current)->currentItem();
++it;
}
delete options;
}
void ManagerModule::emitChanged()
{
TQObjectList *options = view->queryList(0, "^option_");
TQObject *current = 0;
TQObjectListIterator it(*options);
int value = -1;
bool somethingChanged = false;
while ( (current = it.current()) != 0 ) {
if (current->isA("TQCheckBox"))
value = ((TQCheckBox *)current)->state();
else if (current->isA("TQComboBox"))
value = ((TQComboBox *)current)->currentItem();
if (settings[current] != value) {
somethingChanged = true;
break;
}
++it;
}
delete options;
emit changed(somethingChanged);
}
#include "managermodule.moc"
|