-rw-r--r-- | core/launcher/systray.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 64356ca..6122770 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -24,96 +24,104 @@ | |||
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtranslator.h> | 28 | #include <qtranslator.h> |
29 | 29 | ||
30 | #include "systray.h" | 30 | #include "systray.h" |
31 | 31 | ||
32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
33 | 33 | ||
34 | /* ### Single build floppies ### */ | 34 | /* ### Single build floppies ### */ |
35 | #if 0 | 35 | #if 0 |
36 | #ifdef QT_NO_COMPONENTS | 36 | #ifdef QT_NO_COMPONENTS |
37 | #include "../plugins/applets/clockapplet/clockappletimpl.h" | 37 | #include "../plugins/applets/clockapplet/clockappletimpl.h" |
38 | #endif | 38 | #endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 41 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
42 | { | 42 | { |
43 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 43 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
44 | loadApplets(); | 44 | loadApplets(); |
45 | } | 45 | } |
46 | 46 | ||
47 | SysTray::~SysTray() | 47 | SysTray::~SysTray() |
48 | { | 48 | { |
49 | clearApplets(); | 49 | clearApplets(); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int compareAppletPositions(const void *a, const void *b) | 52 | static int compareAppletPositions(const void *a, const void *b) |
53 | { | 53 | { |
54 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; | 54 | const TaskbarApplet* aa = *(const TaskbarApplet**)a; |
55 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; | 55 | const TaskbarApplet* ab = *(const TaskbarApplet**)b; |
56 | int d = ab->iface->position() - aa->iface->position(); | 56 | int d = ab->iface->position() - aa->iface->position(); |
57 | if ( d ) return d; | 57 | if ( d ) return d; |
58 | return QString::compare(ab->name,aa->name); | 58 | return QString::compare(ab->name,aa->name); |
59 | } | 59 | } |
60 | 60 | ||
61 | void SysTray::loadApplets() | 61 | void SysTray::loadApplets() |
62 | { | 62 | { |
63 | hide(); | 63 | hide(); |
64 | clearApplets(); | 64 | clearApplets(); |
65 | addApplets(); | 65 | addApplets(); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SysTray::clearApplets() | 68 | void SysTray::clearApplets() |
69 | { | 69 | { |
70 | #ifndef QT_NO_COMPONENTS | 70 | #ifndef QT_NO_COMPONENTS |
71 | 71 | ||
72 | /* | ||
73 | * Note on clearing. SOme applets delete their | ||
74 | * applets themselves some don't do it | ||
75 | * and on restart this can crash. If we delete it | ||
76 | * here we might end up in a double deletion. We could | ||
77 | * use QGuardedPtr but that would be one QOBject | ||
78 | * for every applet more but only useful for restart | ||
79 | */ | ||
72 | QValueList<TaskbarApplet>::Iterator mit; | 80 | QValueList<TaskbarApplet>::Iterator mit; |
73 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 81 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
74 | (*mit).iface->release(); | 82 | (*mit).iface->release(); |
75 | (*mit).library->unload(); | 83 | (*mit).library->unload(); |
76 | delete (*mit).library; | 84 | delete (*mit).library; |
77 | } | 85 | } |
78 | 86 | ||
79 | #endif | 87 | #endif |
80 | appletList.clear(); | 88 | appletList.clear(); |
81 | if ( layout ) | 89 | if ( layout ) |
82 | delete layout; | 90 | delete layout; |
83 | layout = new QHBoxLayout( this, 0, 1 ); | 91 | layout = new QHBoxLayout( this, 0, 1 ); |
84 | layout->setAutoAdd(TRUE); | 92 | layout->setAutoAdd(TRUE); |
85 | } | 93 | } |
86 | 94 | ||
87 | void SysTray::addApplets() | 95 | void SysTray::addApplets() |
88 | { | 96 | { |
89 | hide(); | 97 | hide(); |
90 | #ifndef QT_NO_COMPONENTS | 98 | #ifndef QT_NO_COMPONENTS |
91 | Config cfg( "Taskbar" ); | 99 | Config cfg( "Taskbar" ); |
92 | cfg.setGroup( "Applets" ); | 100 | cfg.setGroup( "Applets" ); |
93 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 101 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
94 | 102 | ||
95 | QString lang = getenv( "LANG" ); | 103 | QString lang = getenv( "LANG" ); |
96 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 104 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
97 | QDir dir( path, "lib*.so" ); | 105 | QDir dir( path, "lib*.so" ); |
98 | QStringList list = dir.entryList(); | 106 | QStringList list = dir.entryList(); |
99 | QStringList::Iterator it; | 107 | QStringList::Iterator it; |
100 | int napplets=0; | 108 | int napplets=0; |
101 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; | 109 | TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; |
102 | for ( it = list.begin(); it != list.end(); ++it ) { | 110 | for ( it = list.begin(); it != list.end(); ++it ) { |
103 | if ( exclude.find( *it ) != exclude.end() ) | 111 | if ( exclude.find( *it ) != exclude.end() ) |
104 | continue; | 112 | continue; |
105 | TaskbarAppletInterface *iface = 0; | 113 | TaskbarAppletInterface *iface = 0; |
106 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 114 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
107 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 115 | if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
108 | TaskbarApplet *applet = new TaskbarApplet; | 116 | TaskbarApplet *applet = new TaskbarApplet; |
109 | applets[napplets++] = applet; | 117 | applets[napplets++] = applet; |
110 | applet->library = lib; | 118 | applet->library = lib; |
111 | applet->iface = iface; | 119 | applet->iface = iface; |
112 | 120 | ||
113 | QTranslator *trans = new QTranslator(qApp); | 121 | QTranslator *trans = new QTranslator(qApp); |
114 | QString type = (*it).left( (*it).find(".") ); | 122 | QString type = (*it).left( (*it).find(".") ); |
115 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 123 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
116 | if ( trans->load( tfn )) | 124 | if ( trans->load( tfn )) |
117 | qApp->installTranslator( trans ); | 125 | qApp->installTranslator( trans ); |
118 | else | 126 | else |
119 | delete trans; | 127 | delete trans; |