Diffstat (limited to 'core/settings/launcher/taskbarsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/launcher/taskbarsettings.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp index 8dd9e97..861ff3a 100644 --- a/core/settings/launcher/taskbarsettings.cpp +++ b/core/settings/launcher/taskbarsettings.cpp | |||
@@ -1,176 +1,176 @@ | |||
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 "taskbarsettings.h" | 29 | #include "taskbarsettings.h" |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/qlibrary.h> | 33 | #include <qpe/qlibrary.h> |
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/taskbarappletinterface.h> | 35 | #include <qpe/taskbarappletinterface.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <opie2/odebug.h> | 37 | #include <opie2/odebug.h> |
38 | 38 | ||
39 | /* QT */ | 39 | /* QT */ |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | #include <qheader.h> | 42 | #include <qheader.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qwhatsthis.h> | 45 | #include <qwhatsthis.h> |
46 | 46 | ||
47 | /* STD */ | 47 | /* STD */ |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | 50 | ||
51 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) | 51 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) |
52 | : QWidget ( parent, name ) | 52 | : QWidget ( parent, name ) |
53 | { | 53 | { |
54 | m_applets_changed = false; | 54 | m_applets_changed = false; |
55 | 55 | ||
56 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); | 56 | QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); |
57 | 57 | ||
58 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); | 58 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); |
59 | lay-> addWidget ( l ); | 59 | lay-> addWidget ( l ); |
60 | 60 | ||
61 | m_list = new QListView ( this ); | 61 | m_list = new QListView ( this ); |
62 | m_list-> addColumn ( "foobar" ); | 62 | m_list-> addColumn ( "foobar" ); |
63 | m_list-> header ( )-> hide ( ); | 63 | m_list-> header ( )-> hide ( ); |
64 | 64 | ||
65 | lay-> addWidget ( m_list ); | 65 | lay-> addWidget ( m_list ); |
66 | 66 | ||
67 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); | 67 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); |
68 | 68 | ||
69 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); | 69 | connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged())); |
70 | 70 | ||
71 | init ( ); | 71 | init ( ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void TaskbarSettings::init ( ) | 74 | void TaskbarSettings::init ( ) |
75 | { | 75 | { |
76 | Config cfg ( "Taskbar" ); | 76 | Config cfg ( "Taskbar" ); |
77 | cfg. setGroup ( "Applets" ); | 77 | cfg. setGroup ( "Applets" ); |
78 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 78 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
79 | 79 | ||
80 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 80 | QString path = QPEApplication::qpeDir ( ) + "plugins/applets"; |
81 | #ifdef Q_OS_MACX | 81 | #ifdef Q_OS_MACX |
82 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); | 82 | QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); |
83 | #else | 83 | #else |
84 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 84 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
85 | #endif /* Q_OS_MACX */ | 85 | #endif /* Q_OS_MACX */ |
86 | 86 | ||
87 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 87 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
88 | QString name; | 88 | QString name; |
89 | QPixmap icon; | 89 | QPixmap icon; |
90 | TaskbarNamedAppletInterface *iface = 0; | 90 | TaskbarNamedAppletInterface *iface = 0; |
91 | 91 | ||
92 | owarn << "Load applet: " << (*it) << "" << oendl; | 92 | owarn << "Load applet: " << (*it) << "" << oendl; |
93 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 93 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
94 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); | 94 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); |
95 | owarn << "<1>" << oendl; | 95 | owarn << "<1>" << oendl; |
96 | if ( iface ) { | 96 | if ( iface ) { |
97 | owarn << "<2>" << oendl; | 97 | owarn << "<2>" << oendl; |
98 | QString lang = getenv( "LANG" ); | 98 | QString lang = getenv( "LANG" ); |
99 | QTranslator *trans = new QTranslator ( qApp ); | 99 | QTranslator *trans = new QTranslator ( qApp ); |
100 | QString type = (*it). left ((*it). find (".")); | 100 | QString type = (*it). left ((*it). find (".")); |
101 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 101 | QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm"; |
102 | if ( trans-> load ( tfn )) | 102 | if ( trans-> load ( tfn )) |
103 | qApp-> installTranslator ( trans ); | 103 | qApp-> installTranslator ( trans ); |
104 | else | 104 | else |
105 | delete trans; | 105 | delete trans; |
106 | name = iface-> name ( ); | 106 | name = iface-> name ( ); |
107 | icon = iface-> icon ( ); | 107 | icon = iface-> icon ( ); |
108 | iface-> release ( ); | 108 | iface-> release ( ); |
109 | } | 109 | } |
110 | owarn << "<3>" << oendl; | 110 | owarn << "<3>" << oendl; |
111 | if ( !iface ) { | 111 | if ( !iface ) { |
112 | owarn << "<4>" << oendl; | 112 | owarn << "<4>" << oendl; |
113 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); | 113 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); |
114 | 114 | ||
115 | if ( iface ) { | 115 | if ( iface ) { |
116 | owarn << "<5>" << oendl; | 116 | owarn << "<5>" << oendl; |
117 | name = (*it). mid ( 3 ); | 117 | name = (*it). mid ( 3 ); |
118 | owarn << "Found applet: " << name << "" << oendl; | 118 | owarn << "Found applet: " << name << "" << oendl; |
119 | #ifdef Q_OS_MACX | 119 | #ifdef Q_OS_MACX |
120 | int sep = name. find( ".dylib" ); | 120 | int sep = name. find( ".dylib" ); |
121 | #else | 121 | #else |
122 | int sep = name. find( ".so" ); | 122 | int sep = name. find( ".so" ); |
123 | #endif /* Q_OS_MACX */ | 123 | #endif /* Q_OS_MACX */ |
124 | if ( sep > 0 ) | 124 | if ( sep > 0 ) |
125 | name. truncate ( sep ); | 125 | name. truncate ( sep ); |
126 | sep = name. find ( "applet" ); | 126 | sep = name. find ( "applet" ); |
127 | if ( sep == (int) name.length ( ) - 6 ) | 127 | if ( sep == (int) name.length ( ) - 6 ) |
128 | name. truncate ( sep ); | 128 | name. truncate ( sep ); |
129 | name[0] = name[0]. upper ( ); | 129 | name[0] = name[0]. upper ( ); |
130 | iface-> release ( ); | 130 | iface-> release ( ); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | owarn << "<6>" << oendl; | 133 | owarn << "<6>" << oendl; |
134 | 134 | ||
135 | if ( iface ) { | 135 | if ( iface ) { |
136 | owarn << "<7>" << oendl; | 136 | owarn << "<7>" << oendl; |
137 | QCheckListItem *item; | 137 | QCheckListItem *item; |
138 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 138 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); |
139 | if ( !icon. isNull ( )) | 139 | if ( !icon. isNull ( )) |
140 | item-> setPixmap ( 0, icon ); | 140 | item-> setPixmap ( 0, icon ); |
141 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 141 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); |
142 | m_applets [*it] = item; | 142 | m_applets [*it] = item; |
143 | } | 143 | } |
144 | lib-> unload ( ); | 144 | lib-> unload ( ); |
145 | delete lib; | 145 | delete lib; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | void TaskbarSettings::appletChanged() | 149 | void TaskbarSettings::appletChanged() |
150 | { | 150 | { |
151 | m_applets_changed = true; | 151 | m_applets_changed = true; |
152 | } | 152 | } |
153 | 153 | ||
154 | void TaskbarSettings::accept ( ) | 154 | void TaskbarSettings::accept ( ) |
155 | { | 155 | { |
156 | Config cfg ( "Taskbar" ); | 156 | Config cfg ( "Taskbar" ); |
157 | cfg. setGroup ( "Applets" ); | 157 | cfg. setGroup ( "Applets" ); |
158 | 158 | ||
159 | if ( m_applets_changed ) { | 159 | if ( m_applets_changed ) { |
160 | QStringList exclude; | 160 | QStringList exclude; |
161 | QMap <QString, QCheckListItem *>::Iterator it; | 161 | QMap <QString, QCheckListItem *>::Iterator it; |
162 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 162 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
163 | if ( !(*it)-> isOn ( )) | 163 | if ( !(*it)-> isOn ( )) |
164 | exclude << it. key ( ); | 164 | exclude << it. key ( ); |
165 | } | 165 | } |
166 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 166 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
167 | } | 167 | } |
168 | cfg. writeEntry ( "SafeMode", false ); | 168 | cfg. writeEntry ( "SafeMode", false ); |
169 | cfg. write ( ); | 169 | cfg. write ( ); |
170 | 170 | ||
171 | if ( m_applets_changed ) { | 171 | if ( m_applets_changed ) { |
172 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); | 172 | QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); |
173 | m_applets_changed = false; | 173 | m_applets_changed = false; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||