-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 2 | ||||
-rw-r--r-- | core/launcher/systray.cpp | 103 | ||||
-rw-r--r-- | core/launcher/systray.h | 13 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 4 |
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 | |||
@@ -9,7 +9,6 @@ HEADERS = background.h \ | |||
9 | appicons.h \ | 9 | appicons.h \ |
10 | taskbar.h \ | 10 | taskbar.h \ |
11 | sidething.h \ | 11 | sidething.h \ |
12 | mrulist.h \ | ||
13 | runningappbar.h \ | 12 | runningappbar.h \ |
14 | stabmon.h \ | 13 | stabmon.h \ |
15 | inputmethods.h \ | 14 | inputmethods.h \ |
@@ -51,7 +50,6 @@ SOURCES = background.cpp \ | |||
51 | appicons.cpp \ | 50 | appicons.cpp \ |
52 | taskbar.cpp \ | 51 | taskbar.cpp \ |
53 | sidething.cpp \ | 52 | sidething.cpp \ |
54 | mrulist.cpp \ | ||
55 | runningappbar.cpp \ | 53 | runningappbar.cpp \ |
56 | stabmon.cpp \ | 54 | stabmon.cpp \ |
57 | inputmethods.cpp \ | 55 | inputmethods.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 | |||
@@ -242,7 +242,7 @@ void handle_sigterm ( int /* sig */ ) | |||
242 | 242 | ||
243 | int main( int argc, char ** argv ) | 243 | int main( int argc, char ** argv ) |
244 | { | 244 | { |
245 | ::signal( SIGCHLD, SIG_IGN ); | 245 | ::signal ( SIGCHLD, SIG_IGN ); |
246 | 246 | ||
247 | ::signal ( SIGTERM, handle_sigterm ); | 247 | ::signal ( SIGTERM, handle_sigterm ); |
248 | ::signal ( SIGINT, handle_sigterm ); | 248 | ::signal ( SIGINT, handle_sigterm ); |
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,7 +1,7 @@ | |||
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 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -37,12 +37,29 @@ | |||
37 | 37 | ||
38 | SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) | 38 | 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 ); |
41 | loadApplets(); | 42 | loadApplets(); |
42 | } | 43 | } |
43 | 44 | ||
45 | static 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 | |||
44 | void SysTray::loadApplets() | 54 | void SysTray::loadApplets() |
45 | { | 55 | { |
56 | clearApplets(); | ||
57 | addApplets(); | ||
58 | } | ||
59 | |||
60 | void SysTray::clearApplets() | ||
61 | { | ||
62 | hide(); | ||
46 | #ifndef SINGLE_APP | 63 | #ifndef SINGLE_APP |
47 | QValueList<TaskbarApplet>::Iterator mit; | 64 | QValueList<TaskbarApplet>::Iterator mit; |
48 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { | 65 | for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { |
@@ -50,58 +67,82 @@ void SysTray::loadApplets() | |||
50 | (*mit).library->unload(); | 67 | (*mit).library->unload(); |
51 | delete (*mit).library; | 68 | delete (*mit).library; |
52 | } | 69 | } |
70 | #endif | ||
53 | appletList.clear(); | 71 | appletList.clear(); |
54 | if ( layout ) | 72 | if ( layout ) |
55 | delete layout; | 73 | delete layout; |
56 | layout = new QHBoxLayout( this ); | 74 | layout = new QHBoxLayout( this, 0, 1 ); |
75 | layout->setAutoAdd(TRUE); | ||
76 | } | ||
77 | |||
78 | void 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 | ||
58 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 90 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
59 | QDir dir( path, "lib*.so" ); | 91 | QDir dir( path, "lib*.so" ); |
60 | QStringList list = dir.entryList(); | 92 | QStringList list = dir.entryList(); |
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; |
64 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 100 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
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; |
82 | } | 109 | } |
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; |
87 | applet.iface = new ClockAppletImpl(); | 129 | applet.iface = new ClockAppletImpl(); |
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 | ||
93 | void SysTray::positionApplet( const TaskbarApplet &a ) | 139 | void 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,7 +1,7 @@ | |||
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 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -43,12 +43,15 @@ class SysTray : public QFrame { | |||
43 | public: | 43 | public: |
44 | SysTray( QWidget *parent ); | 44 | SysTray( QWidget *parent ); |
45 | 45 | ||
46 | void loadApplets(); | 46 | void clearApplets(); |
47 | void addApplets(); | ||
47 | 48 | ||
48 | private: | 49 | protected: |
49 | void positionApplet( const TaskbarApplet &a ); | 50 | void timerEvent(QTimerEvent* e); |
50 | 51 | ||
51 | private: | 52 | private: |
53 | void loadApplets(); | ||
54 | int safety_tid; | ||
52 | QHBoxLayout *layout; | 55 | QHBoxLayout *layout; |
53 | QValueList<TaskbarApplet> appletList; | 56 | QValueList<TaskbarApplet> appletList; |
54 | }; | 57 | }; |
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 | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include "startmenu.h" | 21 | #include "startmenu.h" |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | #include "mrulist.h" | ||
24 | #include "runningappbar.h" | 23 | #include "runningappbar.h" |
25 | #include "systray.h" | 24 | #include "systray.h" |
26 | #include "calibrate.h" | 25 | #include "calibrate.h" |
@@ -273,7 +272,8 @@ void TaskBar::receive( const QCString &msg, const QByteArray &data ) | |||
273 | } else if ( msg == "reloadInputMethods()" ) { | 272 | } else if ( msg == "reloadInputMethods()" ) { |
274 | inputMethods->loadInputMethods(); | 273 | inputMethods->loadInputMethods(); |
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()" ) { |
278 | Desktop::soundAlarm(); | 278 | Desktop::soundAlarm(); |
279 | } | 279 | } |