summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.pro2
-rw-r--r--core/launcher/main.cpp2
-rw-r--r--core/launcher/systray.cpp103
-rw-r--r--core/launcher/systray.h13
-rw-r--r--core/launcher/taskbar.cpp4
5 files changed, 83 insertions, 41 deletions
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro
index 0e557aa..dbe3820 100644
--- a/core/launcher/launcher.pro
+++ b/core/launcher/launcher.pro
@@ -11,3 +11,2 @@ HEADERS = background.h \
11 sidething.h \ 11 sidething.h \
12 mrulist.h \
13 runningappbar.h \ 12 runningappbar.h \
@@ -53,3 +52,2 @@ SOURCES = background.cpp \
53 sidething.cpp \ 52 sidething.cpp \
54 mrulist.cpp \
55 runningappbar.cpp \ 53 runningappbar.cpp \
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index ca0bbe4..490af39 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -244,3 +244,3 @@ int main( int argc, char ** argv )
244{ 244{
245 ::signal( SIGCHLD, SIG_IGN ); 245 ::signal ( SIGCHLD, SIG_IGN );
246 246
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
index ad1553f..4767150 100644
--- a/core/launcher/systray.cpp
+++ b/core/launcher/systray.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -39,2 +39,3 @@ SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0)
39{ 39{
40 safety_tid = 0;
40 //setFrameStyle( QFrame::Panel | QFrame::Sunken ); 41 //setFrameStyle( QFrame::Panel | QFrame::Sunken );
@@ -43,4 +44,20 @@ SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0)
43 44
45static int compareAppletPositions(const void *a, const void *b)
46{
47 const TaskbarApplet* aa = *(const TaskbarApplet**)a;
48 const TaskbarApplet* ab = *(const TaskbarApplet**)b;
49 int d = ab->iface->position() - aa->iface->position();
50 if ( d ) return d;
51 return QString::compare(ab->library->library(),aa->library->library());
52}
53
44void SysTray::loadApplets() 54void SysTray::loadApplets()
45{ 55{
56 clearApplets();
57 addApplets();
58}
59
60void SysTray::clearApplets()
61{
62 hide();
46#ifndef SINGLE_APP 63#ifndef SINGLE_APP
@@ -52,2 +69,3 @@ void SysTray::loadApplets()
52 } 69 }
70#endif
53 appletList.clear(); 71 appletList.clear();
@@ -55,3 +73,17 @@ void SysTray::loadApplets()
55 delete layout; 73 delete layout;
56 layout = new QHBoxLayout( this ); 74 layout = new QHBoxLayout( this, 0, 1 );
75 layout->setAutoAdd(TRUE);
76}
77
78void SysTray::addApplets()
79{
80#ifndef SINGLE_APP
81 Config cfg( "Taskbar" );
82 cfg.setGroup( "Applets" );
83 bool safe = cfg.readBoolEntry("SafeMode",FALSE);
84 if ( safe && !safety_tid )
85 return;
86 cfg.writeEntry("SafeMode",TRUE);
87 cfg.write();
88 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
57 89
@@ -61,3 +93,7 @@ void SysTray::loadApplets()
61 QStringList::Iterator it; 93 QStringList::Iterator it;
94 int napplets=0;
95 TaskbarApplet* *applets = new TaskbarApplet*[list.count()];
62 for ( it = list.begin(); it != list.end(); ++it ) { 96 for ( it = list.begin(); it != list.end(); ++it ) {
97 if ( exclude.find( *it ) != exclude.end() )
98 continue;
63 TaskbarAppletInterface *iface = 0; 99 TaskbarAppletInterface *iface = 0;
@@ -65,17 +101,8 @@ void SysTray::loadApplets()
65 if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) { 101 if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) {
66 TaskbarApplet applet; 102 TaskbarApplet *applet = new TaskbarApplet;
67 applet.library = lib; 103 applets[napplets++] = applet;
68 applet.iface = iface; 104 applet->library = lib;
69 applet.applet = applet.iface->applet( this ); 105 applet->iface = iface;
70 positionApplet( applet );
71 QString lang = getenv( "LANG" );
72 QTranslator * trans = new QTranslator(qApp);
73 QString type = (*it).left( (*it).find(".") );
74 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
75 qDebug("tr fpr sysapplet: %s", tfn.latin1() );
76 if ( trans->load( tfn ))
77 qApp->installTranslator( trans );
78 else
79 delete trans;
80 } else { 106 } else {
107 exclude += *it;
81 delete lib; 108 delete lib;
@@ -83,4 +110,19 @@ void SysTray::loadApplets()
83 } 110 }
111 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
112 qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions);
113 while (napplets--) {
114 TaskbarApplet *applet = applets[napplets];
115 applet->applet = applet->iface->applet( this );
116 appletList.append(*applet);
117 QString lang = getenv( "LANG" );
118 QTranslator * trans = new QTranslator(qApp);
119 QString type = (*it).left( (*it).find(".") );
120 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
121 if ( trans->load( tfn ))
122 qApp->installTranslator( trans );
123 else
124 delete trans;
125 }
126 delete applets;
84#else 127#else
85 layout = new QHBoxLayout( this );
86 TaskbarApplet applet; 128 TaskbarApplet applet;
@@ -88,20 +130,19 @@ void SysTray::loadApplets()
88 applet.applet = applet.iface->applet( this ); 130 applet.applet = applet.iface->applet( this );
89 positionApplet( applet ); 131 appletList.append( a );
90#endif 132#endif
133 show();
134
135 if ( !safety_tid )
136 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman)
91} 137}
92 138
93void SysTray::positionApplet( const TaskbarApplet &a ) 139void SysTray::timerEvent(QTimerEvent* e)
94{ 140{
95 int p = 0; 141 if ( e->timerId() == safety_tid ) {
96 QValueList<TaskbarApplet>::Iterator it; 142 Config cfg( "Taskbar" );
97 for ( it = appletList.begin(); it != appletList.end(); ++it ) { 143 cfg.setGroup( "Applets" );
98 if ( (*it).iface->position() > a.iface->position() ) 144 cfg.writeEntry( "SafeMode", FALSE );
99 break; 145 killTimer(safety_tid);
100 p += 2; 146 safety_tid = 0;
101 } 147 }
102
103 appletList.insert( it, a );
104 layout->insertWidget( p, a.applet );
105 layout->insertSpacing( p, 1 );
106} 148}
107
diff --git a/core/launcher/systray.h b/core/launcher/systray.h
index 0aed348..5a6849a 100644
--- a/core/launcher/systray.h
+++ b/core/launcher/systray.h
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -45,8 +45,11 @@ public:
45 45
46 void loadApplets(); 46 void clearApplets();
47 void addApplets();
47 48
48private: 49protected:
49 void positionApplet( const TaskbarApplet &a ); 50 void timerEvent(QTimerEvent* e);
50 51
51private: 52private:
53 void loadApplets();
54 int safety_tid;
52 QHBoxLayout *layout; 55 QHBoxLayout *layout;
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 988d072..1feae4a 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -22,3 +22,2 @@
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "mrulist.h"
24#include "runningappbar.h" 23#include "runningappbar.h"
@@ -275,3 +274,4 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data )
275 } else if ( msg == "reloadApplets()" ) { 274 } else if ( msg == "reloadApplets()" ) {
276 sysTray->loadApplets(); 275 sysTray->clearApplets();
276 sysTray->addApplets();
277 } else if ( msg == "soundAlarm()" ) { 277 } else if ( msg == "soundAlarm()" ) {