-rw-r--r-- | core/launcher/systray.cpp | 64 | ||||
-rw-r--r-- | core/launcher/systray.h | 12 |
2 files changed, 32 insertions, 44 deletions
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index be55791..64356ca 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp | |||
@@ -19,28 +19,35 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qtopia/qpeapplication.h> |
22 | #include <qpe/qlibrary.h> | 22 | #include <qtopia/qlibrary.h> |
23 | #include <qpe/config.h> | 23 | #include <qtopia/config.h> |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qmessagebox.h> | ||
27 | #include <qtranslator.h> | 28 | #include <qtranslator.h> |
28 | 29 | ||
29 | #include "quicklauncher.h" | ||
30 | #include "systray.h" | 30 | #include "systray.h" |
31 | 31 | ||
32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
33 | 33 | ||
34 | #ifdef SINGLE_APP | 34 | /* ### Single build floppies ### */ |
35 | #include "clockappletimpl.h" | 35 | #if 0 |
36 | #ifdef QT_NO_COMPONENTS | ||
37 | #include "../plugins/applets/clockapplet/clockappletimpl.h" | ||
38 | #endif | ||
36 | #endif | 39 | #endif |
37 | 40 | ||
38 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 41 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) |
39 | { | 42 | { |
40 | safety_tid = 0; | ||
41 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 43 | //setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
42 | loadApplets(); | 44 | loadApplets(); |
43 | } | 45 | } |
44 | 46 | ||
47 | SysTray::~SysTray() | ||
48 | { | ||
49 | clearApplets(); | ||
50 | } | ||
51 | |||
45 | static int compareAppletPositions(const void *a, const void *b) | 52 | static int compareAppletPositions(const void *a, const void *b) |
46 | { | 53 | { |
@@ -49,9 +56,10 @@ static int compareAppletPositions(const void *a, const void *b) | |||
49 | int d = ab->iface->position() - aa->iface->position(); | 56 | int d = ab->iface->position() - aa->iface->position(); |
50 | if ( d ) return d; | 57 | if ( d ) return d; |
51 | return QString::compare(ab->library->library(),aa->library->library()); | 58 | return QString::compare(ab->name,aa->name); |
52 | } | 59 | } |
53 | 60 | ||
54 | void SysTray::loadApplets() | 61 | void SysTray::loadApplets() |
55 | { | 62 | { |
63 | hide(); | ||
56 | clearApplets(); | 64 | clearApplets(); |
57 | addApplets(); | 65 | addApplets(); |
@@ -60,6 +68,6 @@ void SysTray::loadApplets() | |||
60 | void SysTray::clearApplets() | 68 | void SysTray::clearApplets() |
61 | { | 69 | { |
62 | hide(); | 70 | #ifndef QT_NO_COMPONENTS |
63 | #ifndef SINGLE_APP | 71 | |
64 | QValueList<TaskbarApplet>::Iterator mit; | 72 | QValueList<TaskbarApplet>::Iterator mit; |
65 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 73 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
@@ -68,4 +76,5 @@ void SysTray::clearApplets() | |||
68 | delete (*mit).library; | 76 | delete (*mit).library; |
69 | } | 77 | } |
78 | |||
70 | #endif | 79 | #endif |
71 | appletList.clear(); | 80 | appletList.clear(); |
@@ -78,16 +87,8 @@ void SysTray::clearApplets() | |||
78 | void SysTray::addApplets() | 87 | void SysTray::addApplets() |
79 | { | 88 | { |
80 | #ifndef SINGLE_APP | 89 | hide(); |
90 | #ifndef QT_NO_COMPONENTS | ||
81 | Config cfg( "Taskbar" ); | 91 | Config cfg( "Taskbar" ); |
82 | cfg.setGroup( "Applets" ); | 92 | cfg.setGroup( "Applets" ); |
83 | |||
84 | // SafeMode causes too much problems, so we disable it for now -- | ||
85 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 | ||
86 | |||
87 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); | ||
88 | if ( safe && !safety_tid ) | ||
89 | return; | ||
90 | cfg.writeEntry("SafeMode",TRUE); | ||
91 | cfg.write(); | ||
92 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 93 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
93 | 94 | ||
@@ -130,24 +131,11 @@ void SysTray::addApplets() | |||
130 | } | 131 | } |
131 | delete [] applets; | 132 | delete [] applets; |
132 | #else | 133 | #else /* ## FIXME single app */ |
133 | TaskbarApplet applet; | 134 | TaskbarApplet * const applet = new TaskbarApplet(); |
134 | applet.iface = new ClockAppletImpl(); | 135 | applet->iface = new ClockAppletImpl(); |
135 | applet.applet = applet.iface->applet( this ); | 136 | applet->applet = applet->iface->applet( this ); |
136 | appletList.append( a ); | 137 | appletList.append( applet ); |
137 | #endif | 138 | #endif |
138 | show(); | 139 | show(); |
139 | |||
140 | if ( !safety_tid ) | ||
141 | safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) | ||
142 | } | 140 | } |
143 | 141 | ||
144 | void SysTray::timerEvent(QTimerEvent* e) | ||
145 | { | ||
146 | if ( e->timerId() == safety_tid ) { | ||
147 | Config cfg( "Taskbar" ); | ||
148 | cfg.setGroup( "Applets" ); | ||
149 | cfg.writeEntry( "SafeMode", FALSE ); | ||
150 | killTimer(safety_tid); | ||
151 | safety_tid = 0; | ||
152 | } | ||
153 | } | ||
diff --git a/core/launcher/systray.h b/core/launcher/systray.h index 5a6849a..77c581f 100644 --- a/core/launcher/systray.h +++ b/core/launcher/systray.h | |||
@@ -22,5 +22,7 @@ | |||
22 | #define __SYSTRAY_H__ | 22 | #define __SYSTRAY_H__ |
23 | 23 | ||
24 | #include <qpe/taskbarappletinterface.h> | 24 | #ifndef QT_NO_COMPONENT |
25 | #include <qtopia/taskbarappletinterface.h> | ||
26 | #endif | ||
25 | 27 | ||
26 | #include <qframe.h> | 28 | #include <qframe.h> |
@@ -34,7 +36,8 @@ struct TaskbarApplet | |||
34 | #ifndef QT_NO_COMPONENT | 36 | #ifndef QT_NO_COMPONENT |
35 | QLibrary *library; | 37 | QLibrary *library; |
36 | #endif | ||
37 | TaskbarAppletInterface *iface; | 38 | TaskbarAppletInterface *iface; |
39 | #endif | ||
38 | QWidget *applet; | 40 | QWidget *applet; |
41 | QString name; | ||
39 | }; | 42 | }; |
40 | 43 | ||
@@ -43,14 +46,11 @@ class SysTray : public QFrame { | |||
43 | public: | 46 | public: |
44 | SysTray( QWidget *parent ); | 47 | SysTray( QWidget *parent ); |
48 | ~SysTray(); | ||
45 | 49 | ||
46 | void clearApplets(); | 50 | void clearApplets(); |
47 | void addApplets(); | 51 | void addApplets(); |
48 | 52 | ||
49 | protected: | ||
50 | void timerEvent(QTimerEvent* e); | ||
51 | |||
52 | private: | 53 | private: |
53 | void loadApplets(); | 54 | void loadApplets(); |
54 | int safety_tid; | ||
55 | QHBoxLayout *layout; | 55 | QHBoxLayout *layout; |
56 | QValueList<TaskbarApplet> appletList; | 56 | QValueList<TaskbarApplet> appletList; |