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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
/*
* Copyright (c) 2000 Matthias Elter <elter@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.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*/
#include <tqcombobox.h>
#include <dcopclient.h>
#include <tdeaboutdata.h>
#include <tdeapplication.h>
#include <tdecmodulecontainer.h>
#include <kdirwatch.h>
#include <kimageio.h>
#include <tdelistview.h>
#include <kstaticdeleter.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include "hidingconfig.h"
#include "kickerSettings.h"
#include "lookandfeelconfig.h"
#include "menuconfig.h"
#include "positionconfig.h"
#include "main.h"
#include "main.moc"
#include <X11/Xlib.h>
KickerConfig *KickerConfig::m_self = 0;
static KStaticDeleter<KickerConfig> staticKickerConfigDeleter;
KickerConfig *KickerConfig::the()
{
if (!m_self)
{
staticKickerConfigDeleter.setObject(m_self, new KickerConfig());
}
return m_self;
}
KickerConfig::KickerConfig(TQWidget *parent, const char *name)
: TQObject(parent, name),
DCOPObject("KickerConfig"),
configFileWatch(new KDirWatch(this)),
m_currentPanelIndex(0)
{
m_screenNumber = tqt_xdisplay() ? DefaultScreen(tqt_xdisplay()) : 0;
KickerSettings::instance(configName().latin1());
init();
kapp->dcopClient()->setNotifications(true);
connectDCOPSignal("kicker", "kicker", "configSwitchToPanel(TQString)",
"jumpToPanel(TQString)", false);
kapp->dcopClient()->send("kicker", "kicker", "configLaunched()", TQByteArray());
connect(this, TQT_SIGNAL(hidingPanelChanged(int)),
this, TQT_SLOT(setCurrentPanelIndex(int)));
connect(this, TQT_SIGNAL(positionPanelChanged(int)),
this, TQT_SLOT(setCurrentPanelIndex(int)));
}
KickerConfig::~KickerConfig()
{
// TQValueList::setAutoDelete where for art thou?
ExtensionInfoList::iterator it = m_extensionInfo.begin();
while (it != m_extensionInfo.end())
{
ExtensionInfo* info = *it;
it = m_extensionInfo.erase(it);
delete info;
}
}
// TODO: This is not true anymore:
// this method may get called multiple times during the life of the control panel!
void KickerConfig::init()
{
disconnect(configFileWatch, TQT_SIGNAL(dirty(const TQString&)), this, TQT_SLOT(configChanged(const TQString&)));
configFileWatch->stopScan();
for (ExtensionInfoList::iterator it = m_extensionInfo.begin();
it != m_extensionInfo.end();
++it)
{
configFileWatch->removeFile((*it)->_configPath);
}
TQString configname = configName();
TQString configpath = TDEGlobal::dirs()->findResource("config", configname);
if (configpath.isEmpty())
configpath = locateLocal("config", configname);
TDESharedConfig::Ptr config = TDESharedConfig::openConfig(configname);
if (m_extensionInfo.isEmpty())
{
// our list is empty, so add the main kicker config
m_extensionInfo.append(new ExtensionInfo(TQString::null, configname, configpath));
configFileWatch->addFile(configpath);
}
else
{
// this isn't our first trip through here, which means we are reloading
// so reload the kicker config (first we have to find it ;)
ExtensionInfoList::iterator it = m_extensionInfo.begin();
for (; it != m_extensionInfo.end(); ++it)
{
if (configpath == (*it)->_configPath)
{
(*it)->load();
break;
}
}
}
setupExtensionInfo(*config, true, true);
connect(configFileWatch, TQT_SIGNAL(dirty(const TQString&)), this, TQT_SLOT(configChanged(const TQString&)));
configFileWatch->startScan();
}
void KickerConfig::restartKicker()
{
// Tell kicker to restart
if (!kapp->dcopClient()->isAttached())
{
kapp->dcopClient()->attach();
}
TQCString appname;
appname = "kicker";
kapp->dcopClient()->send(appname, appname, "restart", TQString(""));
}
void KickerConfig::notifyKicker()
{
kdDebug() << "KickerConfig::notifyKicker()" << endl;
emit aboutToNotifyKicker();
// Tell kicker about the new config file.
if (!kapp->dcopClient()->isAttached())
{
kapp->dcopClient()->attach();
}
TQByteArray data;
TQCString appname;
if (m_screenNumber == 0)
{
appname = "kicker";
}
else
{
appname.sprintf("kicker-screen-%d", m_screenNumber);
}
kapp->dcopClient()->send(appname, appname, "configure()", data);
}
void KickerConfig::setupExtensionInfo(TDEConfig& config, bool checkExists, bool reloadIfExists)
{
config.setGroup("General");
TQStringList elist = config.readListEntry("Extensions2");
// all of our existing extensions
// we'll remove ones we find which are still there the oldExtensions, and delete
// all the extensions that remain (e.g. are no longer active)
ExtensionInfoList oldExtensions(m_extensionInfo);
for (TQStringList::Iterator it = elist.begin(); it != elist.end(); ++it)
{
// extension id
TQString group(*it);
// is there a config group for this extension?
if (!config.hasGroup(group) || group.contains("Extension") < 1)
{
continue;
}
// set config group
config.setGroup(group);
TQString df = TDEGlobal::dirs()->findResource("extensions", config.readEntry("DesktopFile"));
TQString configname = config.readEntry("ConfigFile");
TQString configpath = TDEGlobal::dirs()->findResource("config", configname);
if (checkExists)
{
ExtensionInfoList::iterator extIt = m_extensionInfo.begin();
for (; extIt != m_extensionInfo.end(); ++extIt)
{
if (configpath == (*extIt)->_configPath)
{
// we have found it in the config file and it exists
// so remove it from our list of existing extensions
oldExtensions.remove(*extIt);
if (reloadIfExists)
{
(*extIt)->load();
}
break;
}
}
if (extIt != m_extensionInfo.end())
{
continue;
}
}
configFileWatch->addFile(configpath);
ExtensionInfo* info = new ExtensionInfo(df, configname, configpath);
m_extensionInfo.append(info);
emit extensionAdded(info);
}
if (checkExists)
{
// now remove all the left overs that weren't in the file
ExtensionInfoList::iterator extIt = oldExtensions.begin();
for (; extIt != oldExtensions.end(); ++extIt)
{
// don't remove the kickerrc!
if (!(*extIt)->_configPath.endsWith(configName()))
{
emit extensionRemoved(*extIt);
m_extensionInfo.remove(*extIt);
}
}
}
}
void KickerConfig::configChanged(const TQString& configPath)
{
if (configPath.endsWith(configName()))
{
TDESharedConfig::Ptr config = TDESharedConfig::openConfig(configName());
config->reparseConfiguration();
setupExtensionInfo(*config, true);
}
// find the extension and change it
for (ExtensionInfoList::iterator it = m_extensionInfo.begin(); it != m_extensionInfo.end(); ++it)
{
if (configPath == (*it)->_configPath)
{
emit extensionAboutToChange(configPath);
(*it)->configChanged();
break;
}
}
emit extensionChanged(configPath);
}
void KickerConfig::populateExtensionInfoList(TQComboBox* list)
{
list->clear();
for (ExtensionInfoList::iterator it = m_extensionInfo.begin(); it != m_extensionInfo.end(); ++it)
{
list->insertItem((*it)->_name);
}
}
const ExtensionInfoList& KickerConfig::extensionsInfo()
{
return m_extensionInfo;
}
void KickerConfig::reloadExtensionInfo()
{
for (ExtensionInfoList::iterator it = m_extensionInfo.begin(); it != m_extensionInfo.end(); ++it)
{
(*it)->load();
}
emit extensionInfoChanged();
}
void KickerConfig::saveExtentionInfo()
{
for (ExtensionInfoList::iterator it = m_extensionInfo.begin(); it != m_extensionInfo.end(); ++it)
{
(*it)->save();
}
}
void KickerConfig::jumpToPanel(const TQString& panelConfig)
{
ExtensionInfoList::iterator it = m_extensionInfo.begin();
int index = 0;
for (; it != m_extensionInfo.end(); ++it, ++index)
{
if ((*it)->_configFile == panelConfig)
{
break;
}
}
if (it == m_extensionInfo.end())
{
return;
}
kdDebug() << "KickerConfig::jumpToPanel: index=" << index << endl;
emit hidingPanelChanged(index);
emit positionPanelChanged(index);
}
TQString KickerConfig::configName()
{
if (m_screenNumber == 0)
{
return "kickerrc";
}
else
{
return TQString("kicker-screen-%1rc").arg(m_screenNumber);
}
}
void KickerConfig::setCurrentPanelIndex(int index)
{
m_currentPanelIndex = index;
}
TQString KickerConfig::quickHelp() const
{
return i18n("<h1>Panel</h1> Here you can configure the TDE panel (also"
" referred to as 'kicker'). This includes options like the position and"
" size of the panel, as well as its hiding behavior and its looks.<p>"
" Note that you can also access some of these options directly by clicking"
" on the panel, e.g. dragging it with the left mouse button or using the"
" context menu on right mouse button click. This context menu also offers you"
" manipulation of the panel's buttons and applets.");
}
TDEAboutData *KickerConfig::aboutData()
{
// the TDEAboutDatas are deleted by the TDECModules
TDEAboutData *about
= new TDEAboutData(I18N_NOOP("kcmkicker"),
I18N_NOOP("TDE Panel Control Module"),
0, 0, TDEAboutData::License_GPL,
I18N_NOOP("(c) 2009 - 2014 Timothy Pearson\n"
"(c) 1999 - 2001 Matthias Elter\n"
"(c) 2002 - 2003 Aaron J. Seigo"));
about->addAuthor("Timothy Pearson", 0, "kb9vqf@pearsoncomputing.net");
about->addAuthor("Aaron J. Seigo", 0, "aseigo@kde.org");
about->addAuthor("Matthias Elter", 0, "elter@kde.org");
return about;
}
extern "C"
{
KDE_EXPORT TDECModule *create_kicker(TQWidget *parent, const char *name)
{
TDECModuleContainer *container = new TDECModuleContainer(parent, "kcmkicker");
container->addModule("kicker_config_arrangement");
container->addModule("kicker_config_hiding");
container->addModule("kicker_config_menus");
container->addModule("kicker_config_appearance");
return container;
}
KDE_EXPORT TDECModule *create_kicker_arrangement(TQWidget *parent, const char * /*name*/)
{
TDEGlobal::dirs()->addResourceType("extensions", TDEStandardDirs::kde_default("data") +
"kicker/extensions");
return new PositionConfig(parent, "kcmkicker");
}
KDE_EXPORT TDECModule *create_kicker_hiding(TQWidget *parent, const char * /*name*/)
{
TDEGlobal::dirs()->addResourceType("extensions", TDEStandardDirs::kde_default("data") +
"kicker/extensions");
return new HidingConfig(parent, "kcmkicker");
}
KDE_EXPORT TDECModule *create_kicker_menus(TQWidget *parent, const char * /*name*/)
{
return new MenuConfig(parent, "kcmkicker");
}
KDE_EXPORT TDECModule *create_kicker_appearance(TQWidget *parent, const char * /*name*/)
{
KImageIO::registerFormats();
TDEGlobal::dirs()->addResourceType("tiles", TDEStandardDirs::kde_default("data") +
"kicker/tiles");
TDEGlobal::dirs()->addResourceType("hb_pics", TDEStandardDirs::kde_default("data") +
"kcmkicker/pics");
return new LookAndFeelConfig(parent, "kcmkicker");
}
}
|