summaryrefslogtreecommitdiff
path: root/core/launcher/systray.cpp
Unidiff
Diffstat (limited to 'core/launcher/systray.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/systray.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
new file mode 100644
index 0000000..ad1553f
--- a/dev/null
+++ b/core/launcher/systray.cpp
@@ -0,0 +1,107 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qpe/qpeapplication.h>
22#include <qpe/qlibrary.h>
23#include <qpe/config.h>
24
25#include <qlayout.h>
26#include <qdir.h>
27#include <qtranslator.h>
28
29#include "quicklauncher.h"
30#include "systray.h"
31
32#include <stdlib.h>
33
34#ifdef SINGLE_APP
35#include "clockappletimpl.h"
36#endif
37
38SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0)
39{
40 //setFrameStyle( QFrame::Panel | QFrame::Sunken );
41 loadApplets();
42}
43
44void SysTray::loadApplets()
45{
46#ifndef SINGLE_APP
47 QValueList<TaskbarApplet>::Iterator mit;
48 for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) {
49 (*mit).iface->release();
50 (*mit).library->unload();
51 delete (*mit).library;
52 }
53 appletList.clear();
54 if ( layout )
55 delete layout;
56 layout = new QHBoxLayout( this );
57
58 QString path = QPEApplication::qpeDir() + "/plugins/applets";
59 QDir dir( path, "lib*.so" );
60 QStringList list = dir.entryList();
61 QStringList::Iterator it;
62 for ( it = list.begin(); it != list.end(); ++it ) {
63 TaskbarAppletInterface *iface = 0;
64 QLibrary *lib = new QLibrary( path + "/" + *it );
65 if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) {
66 TaskbarApplet applet;
67 applet.library = lib;
68 applet.iface = iface;
69 applet.applet = applet.iface->applet( this );
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 {
81 delete lib;
82 }
83 }
84#else
85 layout = new QHBoxLayout( this );
86 TaskbarApplet applet;
87 applet.iface = new ClockAppletImpl();
88 applet.applet = applet.iface->applet( this );
89 positionApplet( applet );
90#endif
91}
92
93void SysTray::positionApplet( const TaskbarApplet &a )
94{
95 int p = 0;
96 QValueList<TaskbarApplet>::Iterator it;
97 for ( it = appletList.begin(); it != appletList.end(); ++it ) {
98 if ( (*it).iface->position() > a.iface->position() )
99 break;
100 p += 2;
101 }
102
103 appletList.insert( it, a );
104 layout->insertWidget( p, a.applet );
105 layout->insertSpacing( p, 1 );
106}
107