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,90 +1,92 @@
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;
@@ -123,107 +125,107 @@ void RunningAppBar::mousePressEvent(QMouseEvent *e)
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!!