-rw-r--r-- | core/launcher/systray.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 6cc1446..3c72d25 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -1,62 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "systray.h" | ||
22 | |||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
21 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
22 | #include <qtopia/qlibrary.h> | 26 | #include <qtopia/qlibrary.h> |
23 | #include <qtopia/config.h> | 27 | #include <qtopia/config.h> |
28 | using namespace Opie::Core; | ||
24 | 29 | ||
30 | /* QT */ | ||
25 | #include <qlayout.h> | 31 | #include <qlayout.h> |
26 | #include <qdir.h> | 32 | #include <qdir.h> |
27 | 33 | ||
28 | #include "systray.h" | 34 | /* STD */ |
29 | |||
30 | #include <stdlib.h> | 35 | #include <stdlib.h> |
31 | 36 | ||
32 | /* ### Single build floppies ### */ | ||
33 | #if 0 | ||
34 | #ifdef QT_NO_COMPONENTS | ||
35 | #include "../plugins/applets/clockapplet/clockappletimpl.h" | ||
36 | #endif | ||
37 | #endif | ||
38 | |||
39 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 37 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
40 | { | 38 | { |
41 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 39 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
42 | loadApplets(); | 40 | loadApplets(); |
43 | } | 41 | } |
44 | 42 | ||
45 | SysTray::~SysTray() | 43 | SysTray::~SysTray() |
46 | { | 44 | { |
47 | clearApplets(); | 45 | clearApplets(); |
48 | } | 46 | } |
49 | 47 | ||
50 | static int compareAppletPositions(const void *a, const void *b) | 48 | static int compareAppletPositions(const void *a, const void *b) |
51 | { | 49 | { |
52 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; | 50 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; |
53 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; | 51 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; |
54 | int d = ab->iface->position() - aa->iface->position(); | 52 | int d = ab->iface->position() - aa->iface->position(); |
55 | if ( d ) return d; | 53 | if ( d ) return d; |
56 | return QString::compare(ab->name,aa->name); | 54 | return QString::compare(ab->name,aa->name); |
57 | } | 55 | } |
58 | 56 | ||
59 | void SysTray::loadApplets() | 57 | void SysTray::loadApplets() |
60 | { | 58 | { |
61 | hide(); | 59 | hide(); |
62 | clearApplets(); | 60 | clearApplets(); |
@@ -91,49 +89,49 @@ void SysTray::clearApplets() | |||
91 | } | 89 | } |
92 | 90 | ||
93 | void SysTray::addApplets() | 91 | void SysTray::addApplets() |
94 | { | 92 | { |
95 | hide(); | 93 | hide(); |
96 | #ifndef QT_NO_COMPONENTS | 94 | #ifndef QT_NO_COMPONENTS |
97 | Config cfg( "Taskbar" ); | 95 | Config cfg( "Taskbar" ); |
98 | cfg.setGroup( "Applets" ); | 96 | cfg.setGroup( "Applets" ); |
99 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 97 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
100 | 98 | ||
101 | QString lang = getenv( "LANG" ); | 99 | QString lang = getenv( "LANG" ); |
102 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 100 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
103 | #ifdef Q_OS_MACX | 101 | #ifdef Q_OS_MACX |
104 | QDir dir( path, "lib*.dylib" ); | 102 | QDir dir( path, "lib*.dylib" ); |
105 | #else | 103 | #else |
106 | QDir dir( path, "lib*.so" ); | 104 | QDir dir( path, "lib*.so" ); |
107 | #endif /* Q_OS_MACX */ | 105 | #endif /* Q_OS_MACX */ |
108 | QStringList list = dir.entryList(); | 106 | QStringList list = dir.entryList(); |
109 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
110 | int napplets=0; | 108 | int napplets=0; |
111 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; | 109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; |
112 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
113 | if ( exclude.find( *it ) != exclude.end() ) | 111 | if ( exclude.find( *it ) != exclude.end() ) |
114 | continue; | 112 | continue; |
115 | qWarning( "Found Applet: %s", (*it).latin1() ); | 113 | owarn << "Found Applet: " << (*it) << "" << oendl; |
116 | TaskbarAppletInterface *iface = 0; | 114 | TaskbarAppletInterface *iface = 0; |
117 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 115 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
118 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 116 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
119 | TaskbarApplet *applet = new TaskbarApplet; | 117 | TaskbarApplet *applet = new TaskbarApplet; |
120 | applets[napplets++] = applet; | 118 | applets[napplets++] = applet; |
121 | applet->library = lib; | 119 | applet->library = lib; |
122 | applet->iface = iface; | 120 | applet->iface = iface; |
123 | 121 | ||
124 | QTranslator *trans = new QTranslator(qApp); | 122 | QTranslator *trans = new QTranslator(qApp); |
125 | QString type = (*it).left( (*it).find(".") ); | 123 | QString type = (*it).left( (*it).find(".") ); |
126 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 124 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
127 | if ( trans->load( tfn )) | 125 | if ( trans->load( tfn )) |
128 | qApp->installTranslator( trans ); | 126 | qApp->installTranslator( trans ); |
129 | else | 127 | else |
130 | delete trans; | 128 | delete trans; |
131 | } else { | 129 | } else { |
132 | exclude += *it; | 130 | exclude += *it; |
133 | delete lib; | 131 | delete lib; |
134 | } | 132 | } |
135 | } | 133 | } |
136 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 134 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
137 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); | 135 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); |
138 | while (napplets--) { | 136 | while (napplets--) { |
139 | TaskbarApplet *applet = applets[napplets]; | 137 | TaskbarApplet *applet = applets[napplets]; |