summaryrefslogtreecommitdiff
path: root/core/launcher/appicons.cpp
Unidiff
Diffstat (limited to 'core/launcher/appicons.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/appicons.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/launcher/appicons.cpp b/core/launcher/appicons.cpp
index c51ee5a..4d48b24 100644
--- a/core/launcher/appicons.cpp
+++ b/core/launcher/appicons.cpp
@@ -1,95 +1,97 @@
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
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
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 21
22#include "appicons.h" 22#include "appicons.h"
23 23
24#include <qpe/qcopenvelope_qws.h> 24#ifdef QWS
25#include <qtopia/qcopenvelope_qws.h>
26#endif
25 27
26#include <qtooltip.h> 28#include <qtooltip.h>
27#include <qpixmap.h> 29#include <qpixmap.h>
28 30
29 31
30AppIcons::AppIcons( QWidget *parent ) : 32AppIcons::AppIcons( QWidget *parent ) :
31 QHBox(parent) 33 QHBox(parent)
32{ 34{
33 buttons.setAutoDelete(TRUE); 35 buttons.setAutoDelete(TRUE);
34 36
35#ifndef QT_NO_COP 37#ifndef QT_NO_COP
36 QCopChannel* channel = new QCopChannel("Qt/Tray", this); 38 QCopChannel* channel = new QCopChannel("Qt/Tray", this);
37 connect(channel, SIGNAL(received(const QCString&, const QByteArray&)), 39 connect(channel, SIGNAL(received(const QCString&,const QByteArray&)),
38 this, SLOT(receive(const QCString&, const QByteArray&))); 40 this, SLOT(receive(const QCString&,const QByteArray&)));
39#endif 41#endif
40} 42}
41 43
42void AppIcons::setIcon(int id, const QPixmap& pm) 44void AppIcons::setIcon(int id, const QPixmap& pm)
43{ 45{
44 button(id)->setPixmap(pm); 46 button(id)->setPixmap(pm);
45} 47}
46 48
47class FlatButton : public QLabel { 49class FlatButton : public QLabel {
48 Q_OBJECT 50 Q_OBJECT
49public: 51public:
50 FlatButton(QWidget* parent) : QLabel(parent) { } 52 FlatButton(QWidget* parent) : QLabel(parent) { }
51 53
52 void mouseDoubleClickEvent(QMouseEvent* e) 54 void mouseDoubleClickEvent(QMouseEvent* e)
53 { 55 {
54 emit clicked(e->pos(),e->button(),TRUE); 56 emit clicked(e->pos(),e->button(),TRUE);
55 } 57 }
56 void mouseReleaseEvent(QMouseEvent* e) 58 void mouseReleaseEvent(QMouseEvent* e)
57 { 59 {
58 if ( rect().contains(e->pos()) ) 60 if ( rect().contains(e->pos()) )
59 emit clicked(e->pos(),e->button(),FALSE); 61 emit clicked(e->pos(),e->button(),FALSE);
60 } 62 }
61 63
62signals: 64signals:
63 void clicked(const QPoint&, int, bool); 65 void clicked(const QPoint&, int, bool);
64}; 66};
65 67
66QLabel* AppIcons::button(int id) 68QLabel* AppIcons::button(int id)
67{ 69{
68 QLabel* f = buttons.find(id); 70 QLabel* f = buttons.find(id);
69 if ( !f ) { 71 if ( !f ) {
70 buttons.insert(id,f=new FlatButton(this)); 72 buttons.insert(id,f=new FlatButton(this));
71 connect(f,SIGNAL(clicked(const QPoint&, int, bool)),this,SLOT(clicked(const QPoint&, int, bool))); 73 connect(f,SIGNAL(clicked(const QPoint&,int,bool)),this,SLOT(clicked(const QPoint&,int,bool)));
72 f->show(); 74 f->show();
73 } 75 }
74 return f; 76 return f;
75} 77}
76 78
77int AppIcons::findId(QLabel* b) 79int AppIcons::findId(QLabel* b)
78{ 80{
79 QIntDictIterator<QLabel> it(buttons); 81 QIntDictIterator<QLabel> it(buttons);
80 for ( ; ; ++it ) 82 for ( ; ; ++it )
81 if ( it.current() == b ) return it.currentKey(); 83 if ( it.current() == b ) return it.currentKey();
82} 84}
83 85
84void AppIcons::clicked(const QPoint& relpos, int button, bool dbl) 86void AppIcons::clicked(const QPoint& relpos, int button, bool dbl)
85{ 87{
86#ifndef QT_NO_COP 88#ifndef QT_NO_COP
87 QLabel* s = (QLabel*)sender(); 89 QLabel* s = (QLabel*)sender();
88 if ( button == RightButton ) { 90 if ( button == RightButton ) {
89 QCopEnvelope("Qt/Tray","popup(int,QPoint)") 91 QCopEnvelope("Qt/Tray","popup(int,QPoint)")
90 << findId(s) << s->mapToGlobal(QPoint(0,0)); 92 << findId(s) << s->mapToGlobal(QPoint(0,0));
91 } else { 93 } else {
92 QCopEnvelope("Qt/Tray", 94 QCopEnvelope("Qt/Tray",
93 dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)") 95 dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)")
94 << findId(s) << relpos; 96 << findId(s) << relpos;
95 } 97 }