summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/launcher/menusettings.cpp159
-rw-r--r--core/settings/launcher/menusettings.h60
2 files changed, 219 insertions, 0 deletions
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
new file mode 100644
index 0000000..8d363fa
--- a/dev/null
+++ b/core/settings/launcher/menusettings.cpp
@@ -0,0 +1,159 @@
1/*
2                This file is part of the OPIE Project
3 =. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "menusettings.h"
30
31#include <qpe/config.h>
32#include <qpe/qlibrary.h>
33#include <qpe/qpeapplication.h>
34#include <qpe/menuappletinterface.h>
35#include <qpe/qcopenvelope_qws.h>
36
37#include <qdir.h>
38#include <qlistview.h>
39#include <qcheckbox.h>
40#include <qheader.h>
41#include <qlayout.h>
42#include <qlabel.h>
43#include <qwhatsthis.h>
44
45#include <stdlib.h>
46
47
48MenuSettings::MenuSettings ( QWidget *parent, const char *name )
49 : QWidget ( parent, name )
50{
51 m_applets_changed = false;
52
53 QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
54
55 QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this );
56 lay-> addWidget ( l );
57
58 m_list = new QListView ( this );
59 m_list-> addColumn ( "foobar" );
60 m_list-> header ( )-> hide ( );
61
62 lay-> addWidget ( m_list );
63
64 m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
65 lay-> addWidget ( m_menutabs );
66
67 QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the O-Menu." ));
68 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher as menus in the O-Menu." ));
69
70 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( )));
71
72 init ( );
73}
74
75void MenuSettings::init ( )
76{
77 Config cfg ( "StartMenu" );
78 cfg. setGroup ( "Applets" );
79 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
80
81 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
82 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
83
84 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
85 QString name;
86 QPixmap icon;
87 MenuAppletInterface *iface = 0;
88
89 QLibrary *lib = new QLibrary ( path + "/" + *it );
90 lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface );
91 if ( iface ) {
92 QString lang = getenv( "LANG" );
93 QTranslator *trans = new QTranslator ( qApp );
94 QString type = (*it). left ((*it). find ("."));
95 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
96 if ( trans-> load ( tfn ))
97 qApp-> installTranslator ( trans );
98 else
99 delete trans;
100 name = iface-> name ( );
101 icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal );
102 iface-> release ( );
103 lib-> unload ( );
104
105 QCheckListItem *item;
106 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
107 if ( !icon. isNull ( ))
108 item-> setPixmap ( 0, icon );
109 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
110 m_applets [*it] = item;
111 } else {
112 delete lib;
113 }
114 }
115
116 cfg. setGroup ( "Menu" );
117 m_menutabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true ));
118}
119
120void MenuSettings::appletChanged()
121{
122 m_applets_changed = true;
123}
124
125void MenuSettings::accept ( )
126{
127 bool apps_changed = false;
128
129 Config cfg ( "StartMenu" );
130 cfg. setGroup ( "Applets" );
131 if ( m_applets_changed ) {
132 QStringList exclude;
133 QMap <QString, QCheckListItem *>::Iterator it;
134 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
135 if ( !(*it)-> isOn ( ))
136 exclude << it. key ( );
137 }
138 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
139 }
140 cfg. writeEntry ( "SafeMode", false );
141
142 cfg. setGroup ( "Menu" );
143
144 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
145 apps_changed = true;
146 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
147 }
148
149 cfg. write ( );
150
151 if ( m_applets_changed ) {
152 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
153 m_applets_changed = false;
154 }
155 if ( apps_changed ) {
156 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
157 }
158}
159
diff --git a/core/settings/launcher/menusettings.h b/core/settings/launcher/menusettings.h
new file mode 100644
index 0000000..5986958
--- a/dev/null
+++ b/core/settings/launcher/menusettings.h
@@ -0,0 +1,60 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#ifndef __MENU_SETTINGS_H__
29#define __MENU_SETTINGS_H__
30
31#include <qwidget.h>
32#include <qmap.h>
33
34class QListView;
35class QCheckListItem;
36class QCheckBox;
37
38
39class MenuSettings : public QWidget {
40 Q_OBJECT
41
42public:
43 MenuSettings ( QWidget *parent = 0, const char *name = 0 );
44
45 void accept ( );
46
47protected slots:
48 void appletChanged ( );
49
50protected:
51 void init ( );
52
53private:
54 QListView *m_list;
55 QMap <QString, QCheckListItem *> m_applets;
56 bool m_applets_changed;
57 QCheckBox *m_menutabs;
58};
59
60#endif