Diffstat (limited to 'core/launcher/runningappbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/runningappbar.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index 2e9d2a9..a25963f 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp | |||
@@ -1,102 +1,106 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the 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 | #define QTOPIA_INTERNAL_PRELOADACCESS | 21 | #define QTOPIA_INTERNAL_PRELOADACCESS |
22 | 22 | ||
23 | #include "runningappbar.h" | ||
24 | #include "serverinterface.h" | ||
23 | 25 | ||
24 | #include <stdlib.h> | 26 | /* OPIE */ |
27 | #include <opie2/odebug.h> | ||
28 | #include <qtopia/qcopenvelope_qws.h> | ||
29 | using namespace Opie::Core; | ||
25 | 30 | ||
31 | /* QT */ | ||
26 | #include <qpainter.h> | 32 | #include <qpainter.h> |
27 | 33 | ||
28 | #include <qtopia/qcopenvelope_qws.h> | 34 | /* STD */ |
29 | 35 | #include <stdlib.h> | |
30 | #include "runningappbar.h" | ||
31 | #include "serverinterface.h" | ||
32 | 36 | ||
33 | RunningAppBar::RunningAppBar(QWidget* parent) | 37 | RunningAppBar::RunningAppBar(QWidget* parent) |
34 | : QFrame(parent), selectedAppIndex(-1) | 38 | : QFrame(parent), selectedAppIndex(-1) |
35 | { | 39 | { |
36 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 40 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
37 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 41 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
38 | this, SLOT(received(const QCString&,const QByteArray&)) ); | 42 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
39 | 43 | ||
40 | spacing = AppLnk::smallIconSize()+3; | 44 | spacing = AppLnk::smallIconSize()+3; |
41 | } | 45 | } |
42 | 46 | ||
43 | RunningAppBar::~RunningAppBar() | 47 | RunningAppBar::~RunningAppBar() |
44 | { | 48 | { |
45 | } | 49 | } |
46 | 50 | ||
47 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { | 51 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { |
48 | // Since fast apps appear and disappear without disconnecting from their | 52 | // Since fast apps appear and disappear without disconnecting from their |
49 | // channel we need to watch for the showing/hiding events and update according. | 53 | // channel we need to watch for the showing/hiding events and update according. |
50 | QDataStream stream( data, IO_ReadOnly ); | 54 | QDataStream stream( data, IO_ReadOnly ); |
51 | if ( msg == "fastAppShowing(QString)") { | 55 | if ( msg == "fastAppShowing(QString)") { |
52 | QString appName; | 56 | QString appName; |
53 | stream >> appName; | 57 | stream >> appName; |
54 | // qDebug("fastAppShowing %s", appName.data() ); | 58 | // odebug << "fastAppShowing " << appName.data() << "" << oendl; |
55 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); | 59 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); |
56 | if ( f ) addTask(*f); | 60 | if ( f ) addTask(*f); |
57 | } else if ( msg == "fastAppHiding(QString)") { | 61 | } else if ( msg == "fastAppHiding(QString)") { |
58 | QString appName; | 62 | QString appName; |
59 | stream >> appName; | 63 | stream >> appName; |
60 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); | 64 | const AppLnk* f = ServerInterface::appLnks().findExec(appName); |
61 | if ( f ) removeTask(*f); | 65 | if ( f ) removeTask(*f); |
62 | } | 66 | } |
63 | } | 67 | } |
64 | 68 | ||
65 | void RunningAppBar::addTask(const AppLnk& appLnk) { | 69 | void RunningAppBar::addTask(const AppLnk& appLnk) { |
66 | qDebug("Added %s to app list.", appLnk.name().latin1()); | 70 | odebug << "Added " << appLnk.name() << " to app list." << oendl; |
67 | AppLnk* newApp = new AppLnk(appLnk); | 71 | AppLnk* newApp = new AppLnk(appLnk); |
68 | newApp->setExec(appLnk.exec()); | 72 | newApp->setExec(appLnk.exec()); |
69 | appList.prepend(newApp); | 73 | appList.prepend(newApp); |
70 | update(); | 74 | update(); |
71 | } | 75 | } |
72 | 76 | ||
73 | void RunningAppBar::removeTask(const AppLnk& appLnk) { | 77 | void RunningAppBar::removeTask(const AppLnk& appLnk) { |
74 | unsigned int i = 0; | 78 | unsigned int i = 0; |
75 | for (; i < appList.count() ; i++) { | 79 | for (; i < appList.count() ; i++) { |
76 | AppLnk* target = appList.at(i); | 80 | AppLnk* target = appList.at(i); |
77 | if (target->exec() == appLnk.exec()) { | 81 | if (target->exec() == appLnk.exec()) { |
78 | qDebug("Removing %s from app list.", appLnk.name().latin1()); | 82 | odebug << "Removing " << appLnk.name() << " from app list." << oendl; |
79 | appList.remove(); | 83 | appList.remove(); |
80 | delete target; | 84 | delete target; |
81 | } | 85 | } |
82 | } | 86 | } |
83 | update(); | 87 | update(); |
84 | } | 88 | } |
85 | 89 | ||
86 | void RunningAppBar::mousePressEvent(QMouseEvent *e) | 90 | void RunningAppBar::mousePressEvent(QMouseEvent *e) |
87 | { | 91 | { |
88 | // Find out if the user is clicking on an app icon... | 92 | // Find out if the user is clicking on an app icon... |
89 | // If so, snag the index so when we repaint we show it | 93 | // If so, snag the index so when we repaint we show it |
90 | // as highlighed. | 94 | // as highlighed. |
91 | selectedAppIndex = 0; | 95 | selectedAppIndex = 0; |
92 | int x=0; | 96 | int x=0; |
93 | QListIterator<AppLnk> it( appList ); | 97 | QListIterator<AppLnk> it( appList ); |
94 | for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) { | 98 | for ( ; it.current(); ++it,++selectedAppIndex,x+=spacing ) { |
95 | if ( x + spacing <= width() ) { | 99 | if ( x + spacing <= width() ) { |
96 | if ( e->x() >= x && e->x() < x+spacing ) { | 100 | if ( e->x() >= x && e->x() < x+spacing ) { |
97 | if ( selectedAppIndex < (int)appList.count() ) { | 101 | if ( selectedAppIndex < (int)appList.count() ) { |
98 | repaint(FALSE); | 102 | repaint(FALSE); |
99 | return; | 103 | return; |
100 | } | 104 | } |
101 | } | 105 | } |
102 | } else { | 106 | } else { |
@@ -114,59 +118,59 @@ void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) | |||
114 | if ( selectedAppIndex >= 0 ) { | 118 | if ( selectedAppIndex >= 0 ) { |
115 | QString app = appList.at(selectedAppIndex)->exec(); | 119 | QString app = appList.at(selectedAppIndex)->exec(); |
116 | QCopEnvelope e("QPE/System", "raise(QString)"); | 120 | QCopEnvelope e("QPE/System", "raise(QString)"); |
117 | e << app; | 121 | e << app; |
118 | selectedAppIndex = -1; | 122 | selectedAppIndex = -1; |
119 | update(); | 123 | update(); |
120 | } | 124 | } |
121 | } | 125 | } |
122 | 126 | ||
123 | void RunningAppBar::paintEvent( QPaintEvent * ) | 127 | void RunningAppBar::paintEvent( QPaintEvent * ) |
124 | { | 128 | { |
125 | QPainter p( this ); | 129 | QPainter p( this ); |
126 | AppLnk *curApp; | 130 | AppLnk *curApp; |
127 | int x = 0; | 131 | int x = 0; |
128 | int y = (height() - AppLnk::smallIconSize()) / 2; | 132 | int y = (height() - AppLnk::smallIconSize()) / 2; |
129 | int i = 0; | 133 | int i = 0; |
130 | 134 | ||
131 | p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | 135 | p.fillRect( 0, 0, width(), height(), colorGroup().background() ); |
132 | 136 | ||
133 | QListIterator<AppLnk> it(appList); | 137 | QListIterator<AppLnk> it(appList); |
134 | 138 | ||
135 | for (; it.current(); i++, ++it ) { | 139 | for (; it.current(); i++, ++it ) { |
136 | if ( x + spacing <= width() ) { | 140 | if ( x + spacing <= width() ) { |
137 | curApp = it.current(); | 141 | curApp = it.current(); |
138 | qWarning("Drawing %s", curApp->name().latin1() ); | 142 | owarn << "Drawing " << curApp->name() << "" << oendl; |
139 | if ( (int)i == selectedAppIndex ) | 143 | if ( (int)i == selectedAppIndex ) |
140 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); | 144 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); |
141 | else | 145 | else |
142 | p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); | 146 | p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); |
143 | p.drawPixmap( x, y, curApp->pixmap() ); | 147 | p.drawPixmap( x, y, curApp->pixmap() ); |
144 | x += spacing; | 148 | x += spacing; |
145 | } | 149 | } |
146 | } | 150 | } |
147 | } | 151 | } |
148 | 152 | ||
149 | QSize RunningAppBar::sizeHint() const | 153 | QSize RunningAppBar::sizeHint() const |
150 | { | 154 | { |
151 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); | 155 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); |
152 | } | 156 | } |
153 | 157 | ||
154 | void RunningAppBar::applicationLaunched(const QString &appName) | 158 | void RunningAppBar::applicationLaunched(const QString &appName) |
155 | { | 159 | { |
156 | qDebug("desktop:: app: %s launched with pid ", appName.data() ); | 160 | odebug << "desktop:: app: " << appName.data() << " launched with pid " << oendl; |
157 | const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName); | 161 | const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName); |
158 | if ( newGuy && !newGuy->isPreloaded() ) { | 162 | if ( newGuy && !newGuy->isPreloaded() ) { |
159 | addTask( *newGuy ); | 163 | addTask( *newGuy ); |
160 | } | 164 | } |
161 | } | 165 | } |
162 | 166 | ||
163 | void RunningAppBar::applicationTerminated(const QString &app) | 167 | void RunningAppBar::applicationTerminated(const QString &app) |
164 | { | 168 | { |
165 | const AppLnk* gone = ServerInterface::appLnks().findExec(app); | 169 | const AppLnk* gone = ServerInterface::appLnks().findExec(app); |
166 | if ( gone ) { | 170 | if ( gone ) { |
167 | removeTask(*gone); | 171 | removeTask(*gone); |
168 | } | 172 | } |
169 | } | 173 | } |
170 | 174 | ||
171 | 175 | ||
172 | 176 | ||