author | sandman <sandman> | 2002-10-02 22:15:33 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-02 22:15:33 (UTC) |
commit | 7e864eb22b5663ad9771b562fbe901042dc68657 (patch) (unidiff) | |
tree | c7cc270012ff2aba51308088b51022b2056f9721 /core/settings/launcher/taskbarsettings.cpp | |
parent | c8d4ed632ac27261219e5824f988a320b96b8ae2 (diff) | |
download | opie-7e864eb22b5663ad9771b562fbe901042dc68657.zip opie-7e864eb22b5663ad9771b562fbe901042dc68657.tar.gz opie-7e864eb22b5663ad9771b562fbe901042dc68657.tar.bz2 |
Launcher settings now also supports the new menu applets interface
Diffstat (limited to 'core/settings/launcher/taskbarsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/launcher/taskbarsettings.cpp | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp index b5c03c8..5bc5ad2 100644 --- a/core/settings/launcher/taskbarsettings.cpp +++ b/core/settings/launcher/taskbarsettings.cpp | |||
@@ -7,141 +7,149 @@ | |||
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 | #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/taskbarappletinterface.h> | 34 | #include <qpe/taskbarappletinterface.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 | ||
48 | TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) | 48 | TaskbarSettings::TaskbarSettings ( 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:" ), this ); | 55 | QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), 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 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); | 64 | QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); |
65 | 65 | ||
66 | connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); | 66 | connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); |
67 | 67 | ||
68 | init ( ); | 68 | init ( ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void TaskbarSettings::init ( ) | 71 | void TaskbarSettings::init ( ) |
72 | { | 72 | { |
73 | Config cfg ( "Taskbar" ); | 73 | Config cfg ( "Taskbar" ); |
74 | cfg. setGroup ( "Applets" ); | 74 | cfg. setGroup ( "Applets" ); |
75 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); | 75 | QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); |
76 | 76 | ||
77 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; | 77 | QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; |
78 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); | 78 | QStringList list = QDir ( path, "lib*.so" ). entryList ( ); |
79 | 79 | ||
80 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { | 80 | for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { |
81 | QString name; | 81 | QString name; |
82 | QPixmap icon; | 82 | QPixmap icon; |
83 | TaskbarNamedAppletInterface *iface = 0; | 83 | TaskbarNamedAppletInterface *iface = 0; |
84 | 84 | ||
85 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 85 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
86 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); | 86 | lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); |
87 | if ( iface ) { | 87 | if ( iface ) { |
88 | 88 | QString lang = getenv( "LANG" ); | |
89 | QString lang = getenv( "LANG" ); | 89 | QTranslator *trans = new QTranslator ( qApp ); |
90 | QTranslator *trans = new QTranslator ( qApp ); | 90 | QString type = (*it). left ((*it). find (".")); |
91 | QString type = (*it). left ((*it). find (".")); | 91 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; |
92 | QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; | 92 | if ( trans-> load ( tfn )) |
93 | if ( trans-> load ( tfn )) | 93 | qApp-> installTranslator ( trans ); |
94 | qApp-> installTranslator ( trans ); | 94 | else |
95 | else | 95 | delete trans; |
96 | delete trans; | 96 | name = iface-> name ( ); |
97 | name = iface-> name ( ); | 97 | icon = iface-> icon ( ); |
98 | icon = iface-> icon ( ); | ||
99 | iface-> release ( ); | 98 | iface-> release ( ); |
100 | lib-> unload ( ); | ||
101 | } else { | ||
102 | delete lib; | ||
103 | name = (*it). mid ( 3 ); | ||
104 | int sep = name. find( ".so" ); | ||
105 | if ( sep > 0 ) | ||
106 | name. truncate ( sep ); | ||
107 | sep = name. find ( "applet" ); | ||
108 | if ( sep == (int) name.length ( ) - 6 ) | ||
109 | name. truncate ( sep ); | ||
110 | name[0] = name[0]. upper ( ); | ||
111 | } | 99 | } |
112 | QCheckListItem *item; | 100 | if ( !iface ) { |
113 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | 101 | lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); |
114 | if ( !icon. isNull ( )) | 102 | |
115 | item-> setPixmap ( 0, icon ); | 103 | if ( iface ) { |
116 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | 104 | name = (*it). mid ( 3 ); |
117 | m_applets [*it] = item; | 105 | int sep = name. find( ".so" ); |
106 | if ( sep > 0 ) | ||
107 | name. truncate ( sep ); | ||
108 | sep = name. find ( "applet" ); | ||
109 | if ( sep == (int) name.length ( ) - 6 ) | ||
110 | name. truncate ( sep ); | ||
111 | name[0] = name[0]. upper ( ); | ||
112 | iface-> release ( ); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | if ( iface ) { | ||
117 | QCheckListItem *item; | ||
118 | item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); | ||
119 | if ( !icon. isNull ( )) | ||
120 | item-> setPixmap ( 0, icon ); | ||
121 | item-> setOn ( exclude. find ( *it ) == exclude. end ( )); | ||
122 | m_applets [*it] = item; | ||
123 | } | ||
124 | lib-> unload ( ); | ||
125 | delete lib; | ||
118 | } | 126 | } |
119 | } | 127 | } |
120 | 128 | ||
121 | void TaskbarSettings::appletChanged() | 129 | void TaskbarSettings::appletChanged() |
122 | { | 130 | { |
123 | m_applets_changed = true; | 131 | m_applets_changed = true; |
124 | } | 132 | } |
125 | 133 | ||
126 | void TaskbarSettings::accept ( ) | 134 | void TaskbarSettings::accept ( ) |
127 | { | 135 | { |
128 | Config cfg ( "Taskbar" ); | 136 | Config cfg ( "Taskbar" ); |
129 | cfg. setGroup ( "Applets" ); | 137 | cfg. setGroup ( "Applets" ); |
130 | if ( m_applets_changed ) { | 138 | if ( m_applets_changed ) { |
131 | QStringList exclude; | 139 | QStringList exclude; |
132 | QMap <QString, QCheckListItem *>::Iterator it; | 140 | QMap <QString, QCheckListItem *>::Iterator it; |
133 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { | 141 | for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { |
134 | if ( !(*it)-> isOn ( )) | 142 | if ( !(*it)-> isOn ( )) |
135 | exclude << it. key ( ); | 143 | exclude << it. key ( ); |
136 | } | 144 | } |
137 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); | 145 | cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); |
138 | } | 146 | } |
139 | cfg. writeEntry ( "SafeMode", false ); | 147 | cfg. writeEntry ( "SafeMode", false ); |
140 | cfg. write ( ); | 148 | cfg. write ( ); |
141 | 149 | ||
142 | if ( m_applets_changed ) { | 150 | if ( m_applets_changed ) { |
143 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); | 151 | QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); |
144 | m_applets_changed = false; | 152 | m_applets_changed = false; |
145 | } | 153 | } |
146 | } | 154 | } |
147 | 155 | ||