summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/systray.cpp64
-rw-r--r--core/launcher/systray.h12
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
@@ -18,55 +18,64 @@
18** 18**
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
38SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) 41SysTray::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
47SysTray::~SysTray()
48{
49 clearApplets();
50}
51
45static int compareAppletPositions(const void *a, const void *b) 52static int compareAppletPositions(const void *a, const void *b)
46{ 53{
47 const TaskbarApplet* aa = *(const TaskbarApplet**)a; 54 const TaskbarApplet* aa = *(const TaskbarApplet**)a;
48 const TaskbarApplet* ab = *(const TaskbarApplet**)b; 55 const TaskbarApplet* ab = *(const TaskbarApplet**)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
54void SysTray::loadApplets() 61void SysTray::loadApplets()
55{ 62{
63 hide();
56 clearApplets(); 64 clearApplets();
57 addApplets(); 65 addApplets();
58} 66}
59 67
60void SysTray::clearApplets() 68void 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 ) {
66 (*mit).iface->release(); 74 (*mit).iface->release();
67 (*mit).library->unload(); 75 (*mit).library->unload();
68 delete (*mit).library; 76 delete (*mit).library;
69 } 77 }
78
70#endif 79#endif
71 appletList.clear(); 80 appletList.clear();
72 if ( layout ) 81 if ( layout )
@@ -77,18 +86,10 @@ void SysTray::clearApplets()
77 86
78void SysTray::addApplets() 87void 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
94 QString lang = getenv( "LANG" ); 95 QString lang = getenv( "LANG" );
@@ -129,25 +130,12 @@ void SysTray::addApplets()
129 appletList.append(*applet); 130 appletList.append(*applet);
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
144void 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
@@ -21,7 +21,9 @@
21#ifndef __SYSTRAY_H__ 21#ifndef __SYSTRAY_H__
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>
27#include <qvaluelist.h> 29#include <qvaluelist.h>
@@ -33,25 +35,23 @@ struct TaskbarApplet
33{ 35{
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
41class SysTray : public QFrame { 44class SysTray : public QFrame {
42 Q_OBJECT 45 Q_OBJECT
43public: 46public:
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
49protected:
50 void timerEvent(QTimerEvent* e);
51
52private: 53private:
53 void loadApplets(); 54 void loadApplets();
54 int safety_tid;
55 QHBoxLayout *layout; 55 QHBoxLayout *layout;
56 QValueList<TaskbarApplet> appletList; 56 QValueList<TaskbarApplet> appletList;
57}; 57};