summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-09-11 10:48:38 (UTC)
committer harlekin <harlekin>2002-09-11 10:48:38 (UTC)
commit8699473dd4e21242b1c98192c2dd38655177762b (patch) (unidiff)
tree2fe54c8c306eacbf91e8d06b602d332d092bff20
parent6013fac8a6ea871453565faf0f8b51c62465cf71 (diff)
downloadopie-8699473dd4e21242b1c98192c2dd38655177762b.zip
opie-8699473dd4e21242b1c98192c2dd38655177762b.tar.gz
opie-8699473dd4e21242b1c98192c2dd38655177762b.tar.bz2
looks now nice on liquid - again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/runningappbar.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp
index 298f671..b830d1b 100644
--- a/core/launcher/runningappbar.cpp
+++ b/core/launcher/runningappbar.cpp
@@ -1,287 +1,289 @@
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 21
22#define QTOPIA_INTERNAL_PRELOADACCESS 22#define QTOPIA_INTERNAL_PRELOADACCESS
23 23
24// For "kill" 24// For "kill"
25#include <sys/types.h> 25#include <sys/types.h>
26#include <signal.h> 26#include <signal.h>
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include "qprocess.h" 32#include "qprocess.h"
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/applnk.h> 34#include <qpe/applnk.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#include <qpe/global.h> 36#include <qpe/global.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#include "runningappbar.h" 38#include "runningappbar.h"
39 39
40RunningAppBar::RunningAppBar(QWidget* parent) 40RunningAppBar::RunningAppBar(QWidget* parent)
41 : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1) 41 : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1)
42{ 42{
43 setBackgroundMode( PaletteBackground );
44
43 m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); 45 m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" );
44 46
45 connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); 47 connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&)));
46 connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); 48 connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&)));
47 QCopChannel* channel = new QCopChannel( "QPE/System", this ); 49 QCopChannel* channel = new QCopChannel( "QPE/System", this );
48 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 50 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
49 this, SLOT(received(const QCString&, const QByteArray&)) ); 51 this, SLOT(received(const QCString&, const QByteArray&)) );
50 52
51 spacing = AppLnk::smallIconSize()+3; 53 spacing = AppLnk::smallIconSize()+3;
52} 54}
53 55
54RunningAppBar::~RunningAppBar() { 56RunningAppBar::~RunningAppBar() {
55} 57}
56 58
57void RunningAppBar::newQcopChannel(const QString& channelName) { 59void RunningAppBar::newQcopChannel(const QString& channelName) {
58 QString prefix("QPE/Application/"); 60 QString prefix("QPE/Application/");
59 if (channelName.startsWith(prefix)) { 61 if (channelName.startsWith(prefix)) {
60 QString appName = channelName.mid(prefix.length()); 62 QString appName = channelName.mid(prefix.length());
61// qDebug("App %s just connected!", appName.latin1()); 63// qDebug("App %s just connected!", appName.latin1());
62 const AppLnk* newGuy = m_AppLnkSet->findExec(appName); 64 const AppLnk* newGuy = m_AppLnkSet->findExec(appName);
63 if (newGuy && !newGuy->isPreloaded()) { 65 if (newGuy && !newGuy->isPreloaded()) {
64 addTask(*newGuy); 66 addTask(*newGuy);
65 } 67 }
66 } 68 }
67} 69}
68 70
69void RunningAppBar::removedQcopChannel(const QString& channelName) { 71void RunningAppBar::removedQcopChannel(const QString& channelName) {
70 QString prefix("QPE/Application/"); 72 QString prefix("QPE/Application/");
71 if (channelName.startsWith(prefix)) { 73 if (channelName.startsWith(prefix)) {
72 QString appName = channelName.mid(prefix.length()); 74 QString appName = channelName.mid(prefix.length());
73 qDebug("App %s just disconnected!", appName.latin1()); 75 qDebug("App %s just disconnected!", appName.latin1());
74 const AppLnk* newGuy = m_AppLnkSet->findExec(appName); 76 const AppLnk* newGuy = m_AppLnkSet->findExec(appName);
75 if (newGuy) { 77 if (newGuy) {
76 removeTask(*newGuy); 78 removeTask(*newGuy);
77 } 79 }
78 } 80 }
79} 81}
80 82
81void RunningAppBar::received(const QCString& msg, const QByteArray& data) { 83void RunningAppBar::received(const QCString& msg, const QByteArray& data) {
82 // Since fast apps appear and disappear without disconnecting from their 84 // Since fast apps appear and disappear without disconnecting from their
83 // channel we need to watch for the showing/hiding events and update according. 85 // channel we need to watch for the showing/hiding events and update according.
84 QDataStream stream( data, IO_ReadOnly ); 86 QDataStream stream( data, IO_ReadOnly );
85 if ( msg == "fastAppShowing(QString)") { 87 if ( msg == "fastAppShowing(QString)") {
86 QString appName; 88 QString appName;
87 stream >> appName; 89 stream >> appName;
88 addTask(*m_AppLnkSet->findExec(appName)); 90 addTask(*m_AppLnkSet->findExec(appName));
89 } else if ( msg == "fastAppHiding(QString)") { 91 } else if ( msg == "fastAppHiding(QString)") {
90 QString appName; 92 QString appName;
91 stream >> appName; 93 stream >> appName;
92 removeTask(*m_AppLnkSet->findExec(appName)); 94 removeTask(*m_AppLnkSet->findExec(appName));
93 } 95 }
94} 96}
95 97
96void RunningAppBar::addTask(const AppLnk& appLnk) { 98void RunningAppBar::addTask(const AppLnk& appLnk) {
97// qDebug("Added %s to app list.", appLnk.name().latin1()); 99// qDebug("Added %s to app list.", appLnk.name().latin1());
98 AppLnk* newApp = new AppLnk(appLnk); 100 AppLnk* newApp = new AppLnk(appLnk);
99 newApp->setExec(appLnk.exec()); 101 newApp->setExec(appLnk.exec());
100 m_AppList.prepend(newApp); 102 m_AppList.prepend(newApp);
101 update(); 103 update();
102} 104}
103 105
104void RunningAppBar::removeTask(const AppLnk& appLnk) { 106void RunningAppBar::removeTask(const AppLnk& appLnk) {
105 unsigned int i = 0; 107 unsigned int i = 0;
106 for (; i < m_AppList.count() ; i++) { 108 for (; i < m_AppList.count() ; i++) {
107 AppLnk* target = m_AppList.at(i); 109 AppLnk* target = m_AppList.at(i);
108 if (target->exec() == appLnk.exec()) { 110 if (target->exec() == appLnk.exec()) {
109 qDebug("Removing %s from app list.", appLnk.name().latin1()); 111 qDebug("Removing %s from app list.", appLnk.name().latin1());
110 m_AppList.remove(); 112 m_AppList.remove();
111 delete target; 113 delete target;
112 } 114 }
113 } 115 }
114 update(); 116 update();
115} 117}
116 118
117void RunningAppBar::mousePressEvent(QMouseEvent *e) 119void RunningAppBar::mousePressEvent(QMouseEvent *e)
118{ 120{
119 // Find out if the user is clicking on an app icon... 121 // Find out if the user is clicking on an app icon...
120 // If so, snag the index so when we repaint we show it 122 // If so, snag the index so when we repaint we show it
121 // as highlighed. 123 // as highlighed.
122 m_SelectedAppIndex = 0; 124 m_SelectedAppIndex = 0;
123 int x=0; 125 int x=0;
124 QListIterator<AppLnk> it( m_AppList ); 126 QListIterator<AppLnk> it( m_AppList );
125 for ( ; it.current(); ++it,++m_SelectedAppIndex,x+=spacing ) { 127 for ( ; it.current(); ++it,++m_SelectedAppIndex,x+=spacing ) {
126 if ( x + spacing <= width() ) { 128 if ( x + spacing <= width() ) {
127 if ( e->x() >= x && e->x() < x+spacing ) { 129 if ( e->x() >= x && e->x() < x+spacing ) {
128 if ( m_SelectedAppIndex < (int)m_AppList.count() ) { 130 if ( m_SelectedAppIndex < (int)m_AppList.count() ) {
129 repaint(FALSE); 131 repaint(FALSE);
130 return; 132 return;
131 } 133 }
132 } 134 }
133 } else { 135 } else {
134 break; 136 break;
135 } 137 }
136 } 138 }
137 m_SelectedAppIndex = -1; 139 m_SelectedAppIndex = -1;
138 repaint( FALSE ); 140 repaint( FALSE );
139} 141}
140 142
141void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) 143void RunningAppBar::mouseReleaseEvent(QMouseEvent *e)
142{ 144{
143 if (e->button() == QMouseEvent::RightButton) { 145 if (e->button() == QMouseEvent::RightButton) {
144 return; 146 return;
145 } 147 }
146 if ( m_SelectedAppIndex >= 0 ) { 148 if ( m_SelectedAppIndex >= 0 ) {
147 QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); 149 QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec();
148 if (QCopChannel::isRegistered(channel.latin1())) { 150 if (QCopChannel::isRegistered(channel.latin1())) {
149// qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); 151// qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1());
150 QCopEnvelope e(channel.latin1(), "raise()"); 152 QCopEnvelope e(channel.latin1(), "raise()");
151 // This class will delete itself after hearing from the app or the timer expiring 153 // This class will delete itself after hearing from the app or the timer expiring
152 (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); 154 (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this);
153 } 155 }
154 else { 156 else {
155 removeTask(*m_AppList.at(m_SelectedAppIndex)); 157 removeTask(*m_AppList.at(m_SelectedAppIndex));
156 } 158 }
157 159
158 m_SelectedAppIndex = -1; 160 m_SelectedAppIndex = -1;
159 update(); 161 update();
160 } 162 }
161} 163}
162 164
163void RunningAppBar::paintEvent( QPaintEvent * ) 165void RunningAppBar::paintEvent( QPaintEvent * )
164{ 166{
165 QPainter p( this ); 167 QPainter p( this );
166 AppLnk *curApp; 168 AppLnk *curApp;
167 int x = 0; 169 int x = 0;
168 int y = (height() - AppLnk::smallIconSize()) / 2; 170 int y = (height() - AppLnk::smallIconSize()) / 2;
169 int i = 0; 171 int i = 0;
170 172
171 p.fillRect( 0, 0, width(), height(), colorGroup().background() ); 173 //p.fillRect( 0, 0, width(), height(), colorGroup().background() );
172 174
173 QListIterator<AppLnk> it(m_AppList); 175 QListIterator<AppLnk> it(m_AppList);
174 176
175 for (; it.current(); i++, ++it ) { 177 for (; it.current(); i++, ++it ) {
176 if ( x + spacing <= width() ) { 178 if ( x + spacing <= width() ) {
177 curApp = it.current(); 179 curApp = it.current();
178 if ( (int)i == m_SelectedAppIndex ) 180 if ( (int)i == m_SelectedAppIndex )
179 p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); 181 p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() );
180 else 182 else
181 p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); 183 // p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 );
182 p.drawPixmap( x, y, curApp->pixmap() ); 184 p.drawPixmap( x, y, curApp->pixmap() );
183 x += spacing; 185 x += spacing;
184 } 186 }
185 } 187 }
186} 188}
187 189
188QSize RunningAppBar::sizeHint() const 190QSize RunningAppBar::sizeHint() const
189{ 191{
190 return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); 192 return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 );
191} 193}
192 194
193const int AppMonitor::RAISE_TIMEOUT_MS = 500; 195const int AppMonitor::RAISE_TIMEOUT_MS = 500;
194 196
195AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) 197AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner)
196 : QObject(0L), m_Owner(owner), m_App(app), m_PsProc(0L), m_AppKillerBox(0L) { 198 : QObject(0L), m_Owner(owner), m_App(app), m_PsProc(0L), m_AppKillerBox(0L) {
197 QCopChannel* channel = new QCopChannel( "QPE/System", this ); 199 QCopChannel* channel = new QCopChannel( "QPE/System", this );
198 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 200 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
199 this, SLOT(received(const QCString&, const QByteArray&)) ); 201 this, SLOT(received(const QCString&, const QByteArray&)) );
200 connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); 202 connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired()));
201 m_Timer.start(RAISE_TIMEOUT_MS, TRUE); 203 m_Timer.start(RAISE_TIMEOUT_MS, TRUE);
202} 204}
203 205
204AppMonitor::~AppMonitor() { 206AppMonitor::~AppMonitor() {
205 if (m_AppKillerBox) { 207 if (m_AppKillerBox) {
206 delete m_AppKillerBox; 208 delete m_AppKillerBox;
207 m_AppKillerBox = 0L; 209 m_AppKillerBox = 0L;
208 } 210 }
209} 211}
210 212
211void AppMonitor::received(const QCString& msg, const QByteArray& data) { 213void AppMonitor::received(const QCString& msg, const QByteArray& data) {
212 QDataStream stream( data, IO_ReadOnly ); 214 QDataStream stream( data, IO_ReadOnly );
213 215
214 if (msg == "appRaised(QString)") { 216 if (msg == "appRaised(QString)") {
215 QString appName; 217 QString appName;
216 stream >> appName; 218 stream >> appName;
217 if (appName == m_App.exec()) { 219 if (appName == m_App.exec()) {
218 // qDebug("Got a heartbeat from %s", appName.latin1()); 220 // qDebug("Got a heartbeat from %s", appName.latin1());
219 m_Timer.stop(); 221 m_Timer.stop();
220 // Check to make sure we're not waiting on user input... 222 // Check to make sure we're not waiting on user input...
221 if (m_AppKillerBox) { 223 if (m_AppKillerBox) {
222 // If we are, we kill the dialog box, and the code waiting on the result 224 // If we are, we kill the dialog box, and the code waiting on the result
223 // will clean us up (basically the user said "no"). 225 // will clean us up (basically the user said "no").
224 delete m_AppKillerBox; 226 delete m_AppKillerBox;
225 m_AppKillerBox = 0L; 227 m_AppKillerBox = 0L;
226 } 228 }
227 else { 229 else {
228 // Ok, we're not waiting on user input, so clean us up now. 230 // Ok, we're not waiting on user input, so clean us up now.
229 // WE DELETE OURSELVES HERE! Don't do anything else!! 231 // WE DELETE OURSELVES HERE! Don't do anything else!!
230 delete this; 232 delete this;
231 } 233 }
232 } 234 }
233 } 235 }
234} 236}
235 237
236void AppMonitor::timerExpired() { 238void AppMonitor::timerExpired() {
237 // qDebug("Checking in on %s", m_App.name().latin1()); 239 // qDebug("Checking in on %s", m_App.name().latin1());
238 // We store this incase the application responds while we're 240 // We store this incase the application responds while we're
239 // waiting for user input so we know not to delete ourselves. This 241 // waiting for user input so we know not to delete ourselves. This
240 // will be cleaned up in the destructor. 242 // will be cleaned up in the destructor.
241 m_AppKillerBox = new QMessageBox(tr("Application Problem"), 243 m_AppKillerBox = new QMessageBox(tr("Application Problem"),
242 tr("<p>%1 is not responding.</p>").arg(m_App.name()) + 244 tr("<p>%1 is not responding.</p>").arg(m_App.name()) +
243 tr("<p>Would you like to force the application to exit?</p>"), 245 tr("<p>Would you like to force the application to exit?</p>"),
244 QMessageBox::Warning, QMessageBox::Yes, 246 QMessageBox::Warning, QMessageBox::Yes,
245 QMessageBox::No | QMessageBox::Default, 247 QMessageBox::No | QMessageBox::Default,
246 QMessageBox::NoButton); 248 QMessageBox::NoButton);
247 if (m_AppKillerBox->exec() == QMessageBox::Yes) { 249 if (m_AppKillerBox->exec() == QMessageBox::Yes) {
248 // qDebug("Killing the app!!! Bwuhahahaha!"); 250 // qDebug("Killing the app!!! Bwuhahahaha!");
249 m_PsProc = new QProcess(QString("ps")); 251 m_PsProc = new QProcess(QString("ps"));
250 m_PsProc->addArgument("h"); 252 m_PsProc->addArgument("h");
251 m_PsProc->addArgument("-C"); 253 m_PsProc->addArgument("-C");
252 m_PsProc->addArgument(m_App.exec()); 254 m_PsProc->addArgument(m_App.exec());
253 m_PsProc->addArgument("-o"); 255 m_PsProc->addArgument("-o");
254 m_PsProc->addArgument("pid"); 256 m_PsProc->addArgument("pid");
255 connect(m_PsProc, SIGNAL(processExited()), this, SLOT(psProcFinished())); 257 connect(m_PsProc, SIGNAL(processExited()), this, SLOT(psProcFinished()));
256 m_PsProc->start(); 258 m_PsProc->start();
257 } 259 }
258 else { 260 else {
259 // qDebug("Wuss.."); 261 // qDebug("Wuss..");
260 // WE DELETE OURSELVES HERE! Don't do anything else!! 262 // WE DELETE OURSELVES HERE! Don't do anything else!!
261 delete this; 263 delete this;
262 } 264 }
263} 265}
264 266
265void AppMonitor::psProcFinished() { 267void AppMonitor::psProcFinished() {
266 QString pid = m_PsProc->readLineStdout(); 268 QString pid = m_PsProc->readLineStdout();
267 delete m_PsProc; 269 delete m_PsProc;
268 m_PsProc = 0L; 270 m_PsProc = 0L;
269 271
270 // qDebug("Killing app %s", pid.latin1()); 272 // qDebug("Killing app %s", pid.latin1());
271 if (pid.isEmpty()) { 273 if (pid.isEmpty()) {
272 // Hmm.. did the application bail before we got there? 274 // Hmm.. did the application bail before we got there?
273 qDebug("AppMonitor: Tried to kill application %s but ps couldn't find it.", m_App.exec().latin1()); 275 qDebug("AppMonitor: Tried to kill application %s but ps couldn't find it.", m_App.exec().latin1());
274 } 276 }
275 else { 277 else {
276 int success = kill(pid.toUInt(), SIGKILL); 278 int success = kill(pid.toUInt(), SIGKILL);
277 if (success == 0) { 279 if (success == 0) {
278 m_Owner.removeTask(m_App); 280 m_Owner.removeTask(m_App);
279 } 281 }
280 else { 282 else {
281 qWarning("Could not kill task %s", m_App.exec().latin1()); 283 qWarning("Could not kill task %s", m_App.exec().latin1());
282 } 284 }
283 } 285 }
284 286
285 // WE DELETE OURSELVES HERE! Don't do anything else!! 287 // WE DELETE OURSELVES HERE! Don't do anything else!!
286 delete this; 288 delete this;
287} 289}