summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/systray.cpp70
-rw-r--r--core/launcher/systray.h12
2 files changed, 35 insertions, 47 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
@@ -9,145 +9,133 @@
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 <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 )
73 delete layout; 82 delete layout;
74 layout = new QHBoxLayout( this, 0, 1 ); 83 layout = new QHBoxLayout( this, 0, 1 );
75 layout->setAutoAdd(TRUE); 84 layout->setAutoAdd(TRUE);
76} 85}
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" );
95 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 96 QString path = QPEApplication::qpeDir() + "/plugins/applets";
96 QDir dir( path, "lib*.so" ); 97 QDir dir( path, "lib*.so" );
97 QStringList list = dir.entryList(); 98 QStringList list = dir.entryList();
98 QStringList::Iterator it; 99 QStringList::Iterator it;
99 int napplets=0; 100 int napplets=0;
100 TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; 101 TaskbarApplet* *applets = new TaskbarApplet*[list.count()];
101 for ( it = list.begin(); it != list.end(); ++it ) { 102 for ( it = list.begin(); it != list.end(); ++it ) {
102 if ( exclude.find( *it ) != exclude.end() ) 103 if ( exclude.find( *it ) != exclude.end() )
103 continue; 104 continue;
104 TaskbarAppletInterface *iface = 0; 105 TaskbarAppletInterface *iface = 0;
105 QLibrary *lib = new QLibrary( path + "/" + *it ); 106 QLibrary *lib = new QLibrary( path + "/" + *it );
106 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 107 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
107 TaskbarApplet *applet = new TaskbarApplet; 108 TaskbarApplet *applet = new TaskbarApplet;
108 applets[napplets++] = applet; 109 applets[napplets++] = applet;
109 applet->library = lib; 110 applet->library = lib;
110 applet->iface = iface; 111 applet->iface = iface;
111 112
112 QTranslator *trans = new QTranslator(qApp); 113 QTranslator *trans = new QTranslator(qApp);
113 QString type = (*it).left( (*it).find(".") ); 114 QString type = (*it).left( (*it).find(".") );
114 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 115 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
115 if ( trans->load( tfn )) 116 if ( trans->load( tfn ))
116 qApp->installTranslator( trans ); 117 qApp->installTranslator( trans );
117 else 118 else
118 delete trans; 119 delete trans;
119 } else { 120 } else {
120 exclude += *it; 121 exclude += *it;
121 delete lib; 122 delete lib;
122 } 123 }
123 } 124 }
124 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 125 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
125 qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); 126 qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions);
126 while (napplets--) { 127 while (napplets--) {
127 TaskbarApplet *applet = applets[napplets]; 128 TaskbarApplet *applet = applets[napplets];
128 applet->applet = applet->iface->applet( this ); 129 applet->applet = applet->iface->applet( this );
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
@@ -12,50 +12,50 @@
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#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>
28 30
29class QHBoxLayout; 31class QHBoxLayout;
30class QLibrary; 32class QLibrary;
31 33
32struct TaskbarApplet 34struct 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};
58 58
59 59
60#endif // __SYSTRAY_H__ 60#endif // __SYSTRAY_H__
61 61