-rw-r--r-- | core/launcher/appicons.cpp | 14 |
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,129 +1,131 @@ | |||
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 | ||
30 | AppIcons::AppIcons( QWidget *parent ) : | 32 | AppIcons::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 | ||
42 | void AppIcons::setIcon(int id, const QPixmap& pm) | 44 | void AppIcons::setIcon(int id, const QPixmap& pm) |
43 | { | 45 | { |
44 | button(id)->setPixmap(pm); | 46 | button(id)->setPixmap(pm); |
45 | } | 47 | } |
46 | 48 | ||
47 | class FlatButton : public QLabel { | 49 | class FlatButton : public QLabel { |
48 | Q_OBJECT | 50 | Q_OBJECT |
49 | public: | 51 | public: |
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 | ||
62 | signals: | 64 | signals: |
63 | void clicked(const QPoint&, int, bool); | 65 | void clicked(const QPoint&, int, bool); |
64 | }; | 66 | }; |
65 | 67 | ||
66 | QLabel* AppIcons::button(int id) | 68 | QLabel* 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 | ||
77 | int AppIcons::findId(QLabel* b) | 79 | int 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 | ||
84 | void AppIcons::clicked(const QPoint& relpos, int button, bool dbl) | 86 | void 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 | } |
96 | #endif | 98 | #endif |
97 | } | 99 | } |
98 | 100 | ||
99 | void AppIcons::setToolTip(int id, const QString& tip) | 101 | void AppIcons::setToolTip(int id, const QString& tip) |
100 | { | 102 | { |
101 | QToolTip::add(button(id),tip); | 103 | QToolTip::add(button(id),tip); |
102 | } | 104 | } |
103 | 105 | ||
104 | void AppIcons::remove(int id) | 106 | void AppIcons::remove(int id) |
105 | { | 107 | { |
106 | buttons.remove(id); | 108 | buttons.remove(id); |
107 | } | 109 | } |
108 | 110 | ||
109 | void AppIcons::receive( const QCString &msg, const QByteArray &data ) | 111 | void AppIcons::receive( const QCString &msg, const QByteArray &data ) |
110 | { | 112 | { |
111 | QDataStream stream( data, IO_ReadOnly ); | 113 | QDataStream stream( data, IO_ReadOnly ); |
112 | if ( msg == "remove(int)" ) { | 114 | if ( msg == "remove(int)" ) { |
113 | int id; | 115 | int id; |
114 | stream >> id; | 116 | stream >> id; |
115 | remove(id); | 117 | remove(id); |
116 | } else if ( msg == "setIcon(int,QPixmap)" ) { | 118 | } else if ( msg == "setIcon(int,QPixmap)" ) { |
117 | int id; | 119 | int id; |
118 | QPixmap pm; | 120 | QPixmap pm; |
119 | stream >> id >> pm; | 121 | stream >> id >> pm; |
120 | setIcon(id,pm); | 122 | setIcon(id,pm); |
121 | } else if ( msg == "setToolTip(int,QString)" ) { | 123 | } else if ( msg == "setToolTip(int,QString)" ) { |
122 | int id; | 124 | int id; |
123 | QString s; | 125 | QString s; |
124 | stream >> id >> s; | 126 | stream >> id >> s; |
125 | setToolTip(id,s); | 127 | setToolTip(id,s); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | 130 | ||
129 | #include "appicons.moc" | 131 | #include "appicons.moc" |