author | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-16 00:01:01 (UTC) |
commit | df14f647ff1a60ca82e0fa9bd91458be146153b8 (patch) (unidiff) | |
tree | 4859961352851a4392e1442f2080c15bff8ad7bc /core/launcher/systray.cpp | |
parent | 419f9710c488f56a7a117eb1529970d3371e0094 (diff) | |
download | opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.zip opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.gz opie-df14f647ff1a60ca82e0fa9bd91458be146153b8.tar.bz2 |
Replace QPEApplication::qpeDir() + "/ with
QPEApplication::qpeDir() + "
as it is guranteed that qpeDir() will have '/' as the last
charachter
-rw-r--r-- | core/launcher/systray.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 3c72d25..d0f1808 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -1,150 +1,150 @@ | |||
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" | 21 | #include "systray.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | #include <qtopia/qlibrary.h> | 26 | #include <qtopia/qlibrary.h> |
27 | #include <qtopia/config.h> | 27 | #include <qtopia/config.h> |
28 | using namespace Opie::Core; | 28 | using namespace Opie::Core; |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | 33 | ||
34 | /* STD */ | 34 | /* STD */ |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 37 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
38 | { | 38 | { |
39 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 39 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
40 | loadApplets(); | 40 | loadApplets(); |
41 | } | 41 | } |
42 | 42 | ||
43 | SysTray::~SysTray() | 43 | SysTray::~SysTray() |
44 | { | 44 | { |
45 | clearApplets(); | 45 | clearApplets(); |
46 | } | 46 | } |
47 | 47 | ||
48 | static int compareAppletPositions(const void *a, const void *b) | 48 | static int compareAppletPositions(const void *a, const void *b) |
49 | { | 49 | { |
50 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; | 50 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; |
51 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; | 51 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; |
52 | int d = ab->iface->position() - aa->iface->position(); | 52 | int d = ab->iface->position() - aa->iface->position(); |
53 | if ( d ) return d; | 53 | if ( d ) return d; |
54 | return QString::compare(ab->name,aa->name); | 54 | return QString::compare(ab->name,aa->name); |
55 | } | 55 | } |
56 | 56 | ||
57 | void SysTray::loadApplets() | 57 | void SysTray::loadApplets() |
58 | { | 58 | { |
59 | hide(); | 59 | hide(); |
60 | clearApplets(); | 60 | clearApplets(); |
61 | addApplets(); | 61 | addApplets(); |
62 | } | 62 | } |
63 | 63 | ||
64 | void SysTray::clearApplets() | 64 | void SysTray::clearApplets() |
65 | { | 65 | { |
66 | #ifndef QT_NO_COMPONENTS | 66 | #ifndef QT_NO_COMPONENTS |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * Note on clearing. SOme applets delete their | 69 | * Note on clearing. SOme applets delete their |
70 | * applets themselves some don't do it | 70 | * applets themselves some don't do it |
71 | * and on restart this can crash. If we delete it | 71 | * and on restart this can crash. If we delete it |
72 | * here we might end up in a double deletion. We could | 72 | * here we might end up in a double deletion. We could |
73 | * use QGuardedPtr but that would be one QOBject | 73 | * use QGuardedPtr but that would be one QOBject |
74 | * for every applet more but only useful for restart | 74 | * for every applet more but only useful for restart |
75 | */ | 75 | */ |
76 | QValueList<TaskbarApplet>::Iterator mit; | 76 | QValueList<TaskbarApplet>::Iterator mit; |
77 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 77 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
78 | (*mit).iface->release(); | 78 | (*mit).iface->release(); |
79 | (*mit).library->unload(); | 79 | (*mit).library->unload(); |
80 | delete (*mit).library; | 80 | delete (*mit).library; |
81 | } | 81 | } |
82 | 82 | ||
83 | #endif | 83 | #endif |
84 | appletList.clear(); | 84 | appletList.clear(); |
85 | if ( layout ) | 85 | if ( layout ) |
86 | delete layout; | 86 | delete layout; |
87 | layout = new QHBoxLayout( this, 0, 1 ); | 87 | layout = new QHBoxLayout( this, 0, 1 ); |
88 | layout->setAutoAdd(TRUE); | 88 | layout->setAutoAdd(TRUE); |
89 | } | 89 | } |
90 | 90 | ||
91 | void SysTray::addApplets() | 91 | void SysTray::addApplets() |
92 | { | 92 | { |
93 | hide(); | 93 | hide(); |
94 | #ifndef QT_NO_COMPONENTS | 94 | #ifndef QT_NO_COMPONENTS |
95 | Config cfg( "Taskbar" ); | 95 | Config cfg( "Taskbar" ); |
96 | cfg.setGroup( "Applets" ); | 96 | cfg.setGroup( "Applets" ); |
97 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 97 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
98 | 98 | ||
99 | QString lang = getenv( "LANG" ); | 99 | QString lang = getenv( "LANG" ); |
100 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 100 | QString path = QPEApplication::qpeDir() + "plugins/applets"; |
101 | #ifdef Q_OS_MACX | 101 | #ifdef Q_OS_MACX |
102 | QDir dir( path, "lib*.dylib" ); | 102 | QDir dir( path, "lib*.dylib" ); |
103 | #else | 103 | #else |
104 | QDir dir( path, "lib*.so" ); | 104 | QDir dir( path, "lib*.so" ); |
105 | #endif /* Q_OS_MACX */ | 105 | #endif /* Q_OS_MACX */ |
106 | QStringList list = dir.entryList(); | 106 | QStringList list = dir.entryList(); |
107 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
108 | int napplets=0; | 108 | int napplets=0; |
109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; | 109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; |
110 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
111 | if ( exclude.find( *it ) != exclude.end() ) | 111 | if ( exclude.find( *it ) != exclude.end() ) |
112 | continue; | 112 | continue; |
113 | owarn << "Found Applet: " << (*it) << "" << oendl; | 113 | owarn << "Found Applet: " << (*it) << "" << oendl; |
114 | TaskbarAppletInterface *iface = 0; | 114 | TaskbarAppletInterface *iface = 0; |
115 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 115 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
116 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 116 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
117 | TaskbarApplet *applet = new TaskbarApplet; | 117 | TaskbarApplet *applet = new TaskbarApplet; |
118 | applets[napplets++] = applet; | 118 | applets[napplets++] = applet; |
119 | applet->library = lib; | 119 | applet->library = lib; |
120 | applet->iface = iface; | 120 | applet->iface = iface; |
121 | 121 | ||
122 | QTranslator *trans = new QTranslator(qApp); | 122 | QTranslator *trans = new QTranslator(qApp); |
123 | QString type = (*it).left( (*it).find(".") ); | 123 | QString type = (*it).left( (*it).find(".") ); |
124 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 124 | QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; |
125 | if ( trans->load( tfn )) | 125 | if ( trans->load( tfn )) |
126 | qApp->installTranslator( trans ); | 126 | qApp->installTranslator( trans ); |
127 | else | 127 | else |
128 | delete trans; | 128 | delete trans; |
129 | } else { | 129 | } else { |
130 | exclude += *it; | 130 | exclude += *it; |
131 | delete lib; | 131 | delete lib; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 134 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
135 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); | 135 | qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); |
136 | while (napplets--) { | 136 | while (napplets--) { |
137 | TaskbarApplet *applet = applets[napplets]; | 137 | TaskbarApplet *applet = applets[napplets]; |
138 | applet->applet = applet->iface->applet( this ); | 138 | applet->applet = applet->iface->applet( this ); |
139 | appletList.append(*applet); | 139 | appletList.append(*applet); |
140 | } | 140 | } |
141 | delete [] applets; | 141 | delete [] applets; |
142 | #else /* ## FIXME single app */ | 142 | #else /* ## FIXME single app */ |
143 | TaskbarApplet * const applet = new TaskbarApplet(); | 143 | TaskbarApplet * const applet = new TaskbarApplet(); |
144 | applet->iface = new ClockAppletImpl(); | 144 | applet->iface = new ClockAppletImpl(); |
145 | applet->applet = applet->iface->applet( this ); | 145 | applet->applet = applet->iface->applet( this ); |
146 | appletList.append( applet ); | 146 | appletList.append( applet ); |
147 | #endif | 147 | #endif |
148 | show(); | 148 | show(); |
149 | } | 149 | } |
150 | 150 | ||