4
* Copyright (c) 2000 Matthias Elter <elter@kde.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
21
#include <qgroupbox.h>
22
#include <qvbuttongroup.h>
23
#include <qwhatsthis.h>
24
#include <qradiobutton.h>
25
#include <qpushbutton.h>
26
#include <qtoolbutton.h>
28
#include <qfileinfo.h>
34
#include <kstandarddirs.h>
35
#include <klistview.h>
38
#include "applettab_impl.h"
39
#include "applettab_impl.moc"
41
AppletTab::AppletTab( QWidget *parent, const char* name )
42
: AppletTabBase (parent, name)
45
connect(level_group, SIGNAL(clicked(int)), SLOT(level_changed(int)));
47
connect(lb_trusted, SIGNAL(selectionChanged(QListViewItem*)),
48
SLOT(trusted_selection_changed(QListViewItem*)));
50
connect(pb_add, SIGNAL(clicked()), SLOT(add_clicked()));
51
connect(pb_remove, SIGNAL(clicked()), SLOT(remove_clicked()));
53
connect(lb_available, SIGNAL(selectionChanged(QListViewItem*)),
54
SLOT(available_selection_changed(QListViewItem*)));
56
pb_add->setEnabled(false);
57
pb_remove->setEnabled(false);
59
QWhatsThis::add( level_group, i18n("Panel applets can be started in two different ways:"
60
" internally or externally. While 'internally' is the preferred way to load applets, this can"
61
" raise stability or security problems when you are using poorly programmed third-party applets."
62
" To address these problems, applets can be marked 'trusted'. You might want to configure"
63
" Kicker to treat trusted applets different from untrusted ones. Your options are:"
64
" <ul><li><em>Load only trusted applets internally:</em> All applets but the ones marked 'trusted'"
65
" will be loaded using an external wrapper application.</li>"
66
" <li><em>Load startup config applets internally:</em> The applets shown on KDE startup"
67
" will be loaded internally, others will be loaded using an external wrapper application.</li>"
68
" <li><em>Load all applets internally</em></li></ul>") );
70
QWhatsThis::add( lb_trusted, i18n("Here you can see a list of applets that are marked"
71
" 'trusted', i.e. will be loaded internally by Kicker in any case. To move an applet"
72
" from the list of available applets to the trusted ones or vice versa, select it and"
73
" press the left or right buttons.") );
75
QWhatsThis::add( pb_add, i18n("Click here to add the selected applet from the list of available,"
76
" untrusted applets to the list of trusted applets.") );
78
QWhatsThis::add( pb_remove, i18n("Click here to remove the selected applet from the list of trusted"
79
" applets to the list of available, untrusted applets.") );
81
QWhatsThis::add( lb_available, i18n("Here you can see a list of available applets that you"
82
" currently don't trust. This doesn't mean you can't use those applets, but rather that"
83
" the panel's policy using them depends on your applet security level. To move an applet"
84
" from the list of available applets to the trusted ones or vice versa, select it and"
85
" press the left or right buttons.") );
90
void AppletTab::load()
92
KConfig c(KickerConfig::configName(), false, false);
93
c.setGroup("General");
99
int level = c.readNumEntry("SecurityLevel", 1);
105
trusted_rb->setChecked(true);
108
new_rb->setChecked(true);
111
all_rb->setChecked(true);
115
list_group->setEnabled(trusted_rb->isChecked());
117
QStringList list = KGlobal::dirs()->findAllResources("applets", "*.desktop");
118
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
121
available << fi.baseName();
124
if(c.hasKey("TrustedApplets"))
126
QStringList list = c.readListEntry("TrustedApplets");
127
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
129
if(available.contains(*it))
134
l_trusted << "clockapplet" << "ksystemtrayapplet" << "krunapplet" << "quicklauncher"
135
<< "kminipagerapplet" << "ktaskbarapplet" << "eyesapplet" << "kmixapplet";
137
for ( QStringList::Iterator it = available.begin(); it != available.end(); ++it )
139
if(!l_trusted.contains(*it))
140
l_available << (*it);
147
void AppletTab::save()
149
KConfig c(KickerConfig::configName(), false, false);
150
c.setGroup("General");
153
if(new_rb->isChecked()) level = 1;
154
else if (all_rb->isChecked()) level = 2;
156
c.writeEntry("SecurityLevel", level);
157
c.writeEntry("TrustedApplets", l_trusted);
161
void AppletTab::defaults()
163
new_rb->setChecked(true);
164
list_group->setEnabled(false);
167
QString AppletTab::quickHelp() const
172
void AppletTab::level_changed(int)
174
list_group->setEnabled(trusted_rb->isChecked());
178
void AppletTab::updateTrusted()
181
for ( QStringList::Iterator it = l_trusted.begin(); it != l_trusted.end(); ++it )
182
(void) new QListViewItem(lb_trusted, (*it));
185
void AppletTab::updateAvailable()
187
lb_available->clear();
188
for ( QStringList::Iterator it = l_available.begin(); it != l_available.end(); ++it )
189
(void) new QListViewItem(lb_available, (*it));
192
void AppletTab::trusted_selection_changed(QListViewItem * item)
194
pb_remove->setEnabled(item != 0);
198
void AppletTab::available_selection_changed(QListViewItem * item)
200
pb_add->setEnabled(item != 0);
204
void AppletTab::add_clicked()
206
QListViewItem *item = lb_available->selectedItem();
208
l_available.remove(item->text(0));
209
l_trusted.append(item->text(0));
213
updateAddRemoveButton();
216
void AppletTab::remove_clicked()
218
QListViewItem *item = lb_trusted->selectedItem();
220
l_trusted.remove(item->text(0));
221
l_available.append(item->text(0));
225
updateAddRemoveButton();
229
void AppletTab::updateAddRemoveButton()
231
pb_remove->setEnabled(l_trusted.count ()>0);
232
pb_add->setEnabled(l_available.count()>0);