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.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 6fca621..faa7cf4 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,90 +1,93 @@
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 m_menusubpopup = new QCheckBox ( tr( "Show Applications in subpopups" ), this );
68 lay-> addWidget ( m_menusubpopup );
69
67 QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); 70 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." )); 71 QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." ));
69 72
70 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); 73 connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( )));
71 74
72 init ( ); 75 init ( );
73} 76}
74 77
75void MenuSettings::init ( ) 78void MenuSettings::init ( )
76{ 79{
77 Config cfg ( "StartMenu" ); 80 Config cfg ( "StartMenu" );
78 cfg. setGroup ( "Applets" ); 81 cfg. setGroup ( "Applets" );
79 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); 82 QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
80 83
81 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; 84 QString path = QPEApplication::qpeDir ( ) + "/plugins/applets";
82#ifdef Q_OS_MACX 85#ifdef Q_OS_MACX
83 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); 86 QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
84#else 87#else
85 QStringList list = QDir ( path, "lib*.so" ). entryList ( ); 88 QStringList list = QDir ( path, "lib*.so" ). entryList ( );
86#endif /* Q_OS_MACX */ 89#endif /* Q_OS_MACX */
87 90
88 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { 91 for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
89 QString name; 92 QString name;
90 QPixmap icon; 93 QPixmap icon;
@@ -98,66 +101,75 @@ void MenuSettings::init ( )
98 QString type = (*it). left ((*it). find (".")); 101 QString type = (*it). left ((*it). find ("."));
99 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; 102 QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm";
100 if ( trans-> load ( tfn )) 103 if ( trans-> load ( tfn ))
101 qApp-> installTranslator ( trans ); 104 qApp-> installTranslator ( trans );
102 else 105 else
103 delete trans; 106 delete trans;
104 name = iface-> name ( ); 107 name = iface-> name ( );
105 icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); 108 icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal );
106 iface-> release ( ); 109 iface-> release ( );
107 lib-> unload ( ); 110 lib-> unload ( );
108 111
109 QCheckListItem *item; 112 QCheckListItem *item;
110 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); 113 item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
111 if ( !icon. isNull ( )) 114 if ( !icon. isNull ( ))
112 item-> setPixmap ( 0, icon ); 115 item-> setPixmap ( 0, icon );
113 item-> setOn ( exclude. find ( *it ) == exclude. end ( )); 116 item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
114 m_applets [*it] = item; 117 m_applets [*it] = item;
115 } else { 118 } else {
116 delete lib; 119 delete lib;
117 } 120 }
118 } 121 }
119 122
120 cfg. setGroup ( "Menu" ); 123 cfg. setGroup ( "Menu" );
121 m_menutabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true )); 124 m_menutabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true ));
125 m_menusubpopup-> setChecked ( cfg. readBoolEntry ( "LauncherSubPopup", true ));
122} 126}
123 127
124void MenuSettings::appletChanged() 128void MenuSettings::appletChanged()
125{ 129{
126 m_applets_changed = true; 130 m_applets_changed = true;
127} 131}
128 132
129void MenuSettings::accept ( ) 133void MenuSettings::accept ( )
130{ 134{
131 bool apps_changed = false; 135 bool apps_changed = false;
132 136
133 Config cfg ( "StartMenu" ); 137 Config cfg ( "StartMenu" );
134 cfg. setGroup ( "Applets" ); 138 cfg. setGroup ( "Applets" );
135 if ( m_applets_changed ) { 139 if ( m_applets_changed ) {
136 QStringList exclude; 140 QStringList exclude;
137 QMap <QString, QCheckListItem *>::Iterator it; 141 QMap <QString, QCheckListItem *>::Iterator it;
138 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { 142 for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
139 if ( !(*it)-> isOn ( )) 143 if ( !(*it)-> isOn ( ))
140 exclude << it. key ( ); 144 exclude << it. key ( );
141 } 145 }
142 cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); 146 cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
143 } 147 }
144 cfg. writeEntry ( "SafeMode", false ); 148 cfg. writeEntry ( "SafeMode", false );
145 149
146 cfg. setGroup ( "Menu" ); 150 cfg. setGroup ( "Menu" );
147 151
148 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { 152 if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
149 apps_changed = true; 153 apps_changed = true;
150 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); 154 cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
151 } 155 }
152 156
157 if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) {
158 apps_changed = true;
159 cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( ));
160 }
161
153 cfg. write ( ); 162 cfg. write ( );
154 163
155 if ( m_applets_changed ) { 164 if ( m_applets_changed ) {
156 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); 165 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
157 m_applets_changed = false; 166 m_applets_changed = false;
158 } 167 }
159 if ( apps_changed ) { 168 if ( apps_changed ) {
169 // currently use reloadApplets() since reloadApps is now used exclusive for server
170 // to refresh the tabs. But what we want here is also a refresh of the startmenu entries
160 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); 171 QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
172 QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
161 } 173 }
162} 174}
163 175