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