author | harlekin <harlekin> | 2003-04-26 18:09:02 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-04-26 18:09:02 (UTC) |
commit | e2d44ce9293a3db6710753c2e7e2c38a54f60faf (patch) (unidiff) | |
tree | 0934dcd9e1af931a3e61f6f0d09e9aaa838b53e1 | |
parent | fb10c3a3ba4e509db788cee5009b2480a8381190 (diff) | |
download | opie-e2d44ce9293a3db6710753c2e7e2c38a54f60faf.zip opie-e2d44ce9293a3db6710753c2e7e2c38a54f60faf.tar.gz opie-e2d44ce9293a3db6710753c2e7e2c38a54f60faf.tar.bz2 |
make applets more flexible regarding size
-rw-r--r-- | core/applets/batteryapplet/battery.cpp | 15 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.cpp | 13 | ||||
-rw-r--r-- | core/applets/cardmon/cardmon.h | 2 | ||||
-rw-r--r-- | core/applets/clipboardapplet/clipboard.cpp | 196 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 5 |
5 files changed, 26 insertions, 205 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index 3b329c6..f3a95ed 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -1,152 +1,153 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | #include "battery.h" | 20 | #include "battery.h" |
21 | #include "batterystatus.h" | 21 | #include "batterystatus.h" |
22 | 22 | ||
23 | #include <qpe/power.h> | 23 | #include <qpe/power.h> |
24 | #include <qpe/applnk.h> | ||
24 | 25 | ||
25 | #include <qpainter.h> | 26 | #include <qpainter.h> |
26 | #include <qtimer.h> | 27 | #include <qtimer.h> |
27 | 28 | ||
28 | 29 | ||
29 | BatteryMeter::BatteryMeter( QWidget *parent ) | 30 | BatteryMeter::BatteryMeter( QWidget *parent ) |
30 | : QWidget( parent ), charging(false) | 31 | : QWidget( parent ), charging(false) |
31 | { | 32 | { |
32 | ps = new PowerStatus; | 33 | ps = new PowerStatus; |
33 | startTimer( 10000 ); | 34 | startTimer( 10000 ); |
34 | setFixedHeight(12); | 35 | setFixedHeight( AppLnk::smallIconSize() ); |
35 | chargeTimer = new QTimer( this ); | 36 | chargeTimer = new QTimer( this ); |
36 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); | 37 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); |
37 | timerEvent(0); | 38 | timerEvent(0); |
38 | } | 39 | } |
39 | 40 | ||
40 | BatteryMeter::~BatteryMeter() | 41 | BatteryMeter::~BatteryMeter() |
41 | { | 42 | { |
42 | delete ps; | 43 | delete ps; |
43 | } | 44 | } |
44 | 45 | ||
45 | QSize BatteryMeter::sizeHint() const | 46 | QSize BatteryMeter::sizeHint() const |
46 | { | 47 | { |
47 | return QSize(10,12); | 48 | return QSize(10, height() ); |
48 | } | 49 | } |
49 | 50 | ||
50 | void BatteryMeter::mouseReleaseEvent( QMouseEvent *) | 51 | void BatteryMeter::mouseReleaseEvent( QMouseEvent *) |
51 | { | 52 | { |
52 | if ( batteryView && batteryView->isVisible() ) { | 53 | if ( batteryView && batteryView->isVisible() ) { |
53 | delete (QWidget *) batteryView; | 54 | delete (QWidget *) batteryView; |
54 | } else { | 55 | } else { |
55 | if ( !batteryView ) | 56 | if ( !batteryView ) |
56 | batteryView = new BatteryStatus( ps ); | 57 | batteryView = new BatteryStatus( ps ); |
57 | batteryView->showMaximized(); | 58 | batteryView->showMaximized(); |
58 | batteryView->raise(); | 59 | batteryView->raise(); |
59 | batteryView->show(); | 60 | batteryView->show(); |
60 | } | 61 | } |
61 | } | 62 | } |
62 | 63 | ||
63 | void BatteryMeter::timerEvent( QTimerEvent * ) | 64 | void BatteryMeter::timerEvent( QTimerEvent * ) |
64 | { | 65 | { |
65 | PowerStatus prev = *ps; | 66 | PowerStatus prev = *ps; |
66 | 67 | ||
67 | *ps = PowerStatusManager::readStatus(); | 68 | *ps = PowerStatusManager::readStatus(); |
68 | 69 | ||
69 | if ( prev != *ps ) { | 70 | if ( prev != *ps ) { |
70 | percent = ps->batteryPercentRemaining(); | 71 | percent = ps->batteryPercentRemaining(); |
71 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { | 72 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { |
72 | percent = 0; | 73 | percent = 0; |
73 | charging = true; | 74 | charging = true; |
74 | chargeTimer->start( 500 ); | 75 | chargeTimer->start( 500 ); |
75 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { | 76 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { |
76 | charging = false; | 77 | charging = false; |
77 | chargeTimer->stop(); | 78 | chargeTimer->stop(); |
78 | if ( batteryView ) | 79 | if ( batteryView ) |
79 | batteryView->updatePercent( percent ); | 80 | batteryView->updatePercent( percent ); |
80 | } | 81 | } |
81 | repaint(FALSE); | 82 | repaint(FALSE); |
82 | if ( batteryView ) | 83 | if ( batteryView ) |
83 | batteryView->repaint(); | 84 | batteryView->repaint(); |
84 | } | 85 | } |
85 | } | 86 | } |
86 | 87 | ||
87 | void BatteryMeter::chargeTimeout() | 88 | void BatteryMeter::chargeTimeout() |
88 | { | 89 | { |
89 | percent += 20; | 90 | percent += 20; |
90 | if ( percent > 100 ) | 91 | if ( percent > 100 ) |
91 | percent = 0; | 92 | percent = 0; |
92 | 93 | ||
93 | repaint(FALSE); | 94 | repaint(FALSE); |
94 | if ( batteryView ) | 95 | if ( batteryView ) |
95 | batteryView->updatePercent( percent ); | 96 | batteryView->updatePercent( percent ); |
96 | } | 97 | } |
97 | 98 | ||
98 | void BatteryMeter::paintEvent( QPaintEvent* ) | 99 | void BatteryMeter::paintEvent( QPaintEvent* ) |
99 | { | 100 | { |
100 | QPainter p(this); | 101 | QPainter p(this); |
101 | 102 | ||
102 | QColor c; | 103 | QColor c; |
103 | QColor darkc; | 104 | QColor darkc; |
104 | QColor lightc; | 105 | QColor lightc; |
105 | if ( ps->acStatus() == PowerStatus::Offline ) { | 106 | if ( ps->acStatus() == PowerStatus::Offline ) { |
106 | c = blue.light(120); | 107 | c = blue.light(120); |
107 | darkc = c.dark(120); | 108 | darkc = c.dark(120); |
108 | lightc = c.light(140); | 109 | lightc = c.light(140); |
109 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 110 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
110 | c = green.dark(130); | 111 | c = green.dark(130); |
111 | darkc = c.dark(120); | 112 | darkc = c.dark(120); |
112 | lightc = c.light(180); | 113 | lightc = c.light(180); |
113 | } else { | 114 | } else { |
114 | c = red; | 115 | c = red; |
115 | darkc = c.dark(120); | 116 | darkc = c.dark(120); |
116 | lightc = c.light(160); | 117 | lightc = c.light(160); |
117 | } | 118 | } |
118 | 119 | ||
119 | int w = 6; | 120 | int w = height() / 2 ; |
120 | int h = height()-3; | 121 | int h = height() - 4; |
121 | int pix = (percent * h) / 100; | 122 | int pix = (percent * h) / 100; |
122 | int y2 = height() - 2; | 123 | int y2 = height() -2; |
123 | int y = y2 - pix; | 124 | int y = y2 - pix; |
124 | int x1 = (width() - w) / 2; | 125 | int x1 = (width() - w ) / 2; |
125 | 126 | ||
126 | p.setPen(QColor(80,80,80)); | 127 | p.setPen(QColor(80,80,80)); |
127 | p.drawLine(x1+w/4,0,x1+w/4+w/2,0); | 128 | p.drawLine(x1+w/4,0,x1+w/4+w/2,0); |
128 | p.drawRect(x1,1,w,height()-1); | 129 | p.drawRect(x1,1,w,height()-1); |
129 | p.setBrush(c); | 130 | p.setBrush(c); |
130 | 131 | ||
131 | int extra = ((percent * h) % 100)/(100/4); | 132 | int extra = ((percent * h) % 100)/(100/4); |
132 | 133 | ||
133 | #define Y(i) ((i<=extra)?y-1:y) | 134 | #define Y(i) ((i<=extra)?y-1:y) |
134 | #define DRAWUPPER(i) if ( Y(i) >= 2 ) p.drawLine(i+x1,2,i+x1,Y(i)); | 135 | #define DRAWUPPER(i) if ( Y(i) >= 2 ) p.drawLine(i+x1,2,i+x1,Y(i)); |
135 | p.setPen( gray ); | 136 | p.setPen( gray ); |
136 | DRAWUPPER(1); | 137 | DRAWUPPER(1); |
137 | DRAWUPPER(3); | 138 | DRAWUPPER(3); |
138 | p.setPen( gray.light(130) ); | 139 | p.setPen( gray.light(130) ); |
139 | DRAWUPPER(2); | 140 | DRAWUPPER(2); |
140 | p.setPen( gray.dark(120) ); | 141 | p.setPen( gray.dark(120) ); |
141 | DRAWUPPER(4); | 142 | DRAWUPPER(4); |
142 | 143 | ||
143 | #define DRAW(i) { if ( Y(i) < y2 ) p.drawLine(i+x1,Y(i)+1,i+x1,y2); } | 144 | #define DRAW(i) { if ( Y(i) < y2 ) p.drawLine(i+x1,Y(i)+1, i+x1,y2); } |
144 | p.setPen( c ); | 145 | p.setPen( c ); |
145 | DRAW(1); | 146 | DRAW(1); |
146 | DRAW(3); | 147 | DRAW(3); |
147 | p.setPen( lightc ); | 148 | p.setPen( lightc ); |
148 | DRAW(2); | 149 | DRAW(2); |
149 | p.setPen(darkc); | 150 | p.setPen(darkc); |
150 | DRAW(4); | 151 | DRAW(4); |
151 | } | 152 | } |
152 | 153 | ||
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index f3f9044..b8c4553 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,131 +1,136 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.cpp | 2 | * cardmon.cpp |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2002 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | 19 | ||
20 | #include "cardmon.h" | 20 | #include "cardmon.h" |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <opie/odevice.h> | 24 | #include <opie/odevice.h> |
25 | 25 | ||
26 | #include <qpe/applnk.h> | ||
27 | |||
26 | #include <qcopchannel_qws.h> | 28 | #include <qcopchannel_qws.h> |
27 | #include <qpainter.h> | 29 | #include <qpainter.h> |
28 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
29 | #include <qfile.h> | 31 | #include <qfile.h> |
30 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
31 | #include <qtimer.h> | 33 | #include <qtimer.h> |
32 | #include <qapplication.h> | 34 | #include <qapplication.h> |
33 | 35 | ||
34 | #include <stdio.h> | 36 | #include <stdio.h> |
35 | #include <unistd.h> | 37 | #include <unistd.h> |
36 | #include <stdlib.h> | 38 | #include <stdlib.h> |
37 | #include <string.h> | 39 | #include <string.h> |
38 | #include <fcntl.h> | 40 | #include <fcntl.h> |
39 | #include <qsound.h> | 41 | #include <qsound.h> |
40 | 42 | ||
41 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 43 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
42 | #include <sys/vfs.h> | 44 | #include <sys/vfs.h> |
43 | #include <mntent.h> | 45 | #include <mntent.h> |
44 | #endif | 46 | #endif |
45 | 47 | ||
46 | using namespace Opie; | 48 | using namespace Opie; |
47 | 49 | ||
48 | CardMonitor::CardMonitor(QWidget * parent):QWidget(parent), | 50 | CardMonitor::CardMonitor(QWidget * parent):QWidget(parent), |
49 | pm(Resource:: | 51 | pm( Resource::loadPixmap("cardmon/pcmcia") ) |
50 | loadPixmap("cardmon/pcmcia")) | ||
51 | { | 52 | { |
52 | 53 | ||
53 | QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); | 54 | QCopChannel *pcmciaChannel = new QCopChannel("QPE/Card", this); |
54 | connect(pcmciaChannel, | 55 | connect(pcmciaChannel, |
55 | SIGNAL(received(const QCString &, const QByteArray &)), this, | 56 | SIGNAL(received(const QCString &, const QByteArray &)), this, |
56 | SLOT(cardMessage(const QCString &, const QByteArray &))); | 57 | SLOT(cardMessage(const QCString &, const QByteArray &))); |
57 | 58 | ||
58 | QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); | 59 | QCopChannel *sdChannel = new QCopChannel("QPE/Card", this); |
59 | connect(sdChannel, | 60 | connect(sdChannel, |
60 | SIGNAL(received(const QCString &, const QByteArray &)), this, | 61 | SIGNAL(received(const QCString &, const QByteArray &)), this, |
61 | SLOT(cardMessage(const QCString &, const QByteArray &))); | 62 | SLOT(cardMessage(const QCString &, const QByteArray &))); |
62 | 63 | ||
63 | cardInPcmcia0 = FALSE; | 64 | cardInPcmcia0 = FALSE; |
64 | cardInPcmcia1 = FALSE; | 65 | cardInPcmcia1 = FALSE; |
65 | cardInSd = FALSE; | 66 | cardInSd = FALSE; |
66 | 67 | ||
67 | setFixedSize(pm.size()); | 68 | setFocusPolicy( NoFocus ); |
69 | |||
70 | setFixedWidth ( AppLnk::smallIconSize() ); | ||
71 | setFixedHeight ( AppLnk::smallIconSize() ); | ||
72 | |||
68 | getStatusPcmcia(TRUE); | 73 | getStatusPcmcia(TRUE); |
69 | getStatusSd(TRUE); | 74 | getStatusSd(TRUE); |
70 | repaint(FALSE); | 75 | repaint(FALSE); |
71 | popupMenu = 0; | 76 | popupMenu = 0; |
72 | } | 77 | } |
73 | 78 | ||
74 | CardMonitor::~CardMonitor() | 79 | CardMonitor::~CardMonitor() |
75 | { | 80 | { |
76 | if (popupMenu) { | 81 | if (popupMenu) { |
77 | delete popupMenu; | 82 | delete popupMenu; |
78 | } | 83 | } |
79 | } | 84 | } |
80 | 85 | ||
81 | void CardMonitor::popUp(QString message, QString icon) | 86 | void CardMonitor::popUp(QString message, QString icon) |
82 | { | 87 | { |
83 | if (!popupMenu) { | 88 | if (!popupMenu) { |
84 | popupMenu = new QPopupMenu(this); | 89 | popupMenu = new QPopupMenu(this); |
85 | } | 90 | } |
86 | 91 | ||
87 | popupMenu->clear(); | 92 | popupMenu->clear(); |
88 | if (icon.isEmpty()) { | 93 | if (icon.isEmpty()) { |
89 | popupMenu->insertItem(message, 0); | 94 | popupMenu->insertItem(message, 0); |
90 | } else { | 95 | } else { |
91 | popupMenu->insertItem(QIconSet(Resource::loadPixmap(icon)), | 96 | popupMenu->insertItem(QIconSet(Resource::loadPixmap(icon)), |
92 | message, 0); | 97 | message, 0); |
93 | } | 98 | } |
94 | 99 | ||
95 | QPoint p = mapToGlobal(QPoint(0, 0)); | 100 | QPoint p = mapToGlobal(QPoint(0, 0)); |
96 | QSize s = popupMenu->sizeHint(); | 101 | QSize s = popupMenu->sizeHint(); |
97 | popupMenu->popup(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 102 | popupMenu->popup(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
98 | p.y() - s.height()), 0); | 103 | p.y() - s.height()), 0); |
99 | 104 | ||
100 | QTimer::singleShot(2000, this, SLOT(popupTimeout())); | 105 | QTimer::singleShot(2000, this, SLOT(popupTimeout())); |
101 | } | 106 | } |
102 | 107 | ||
103 | void CardMonitor::popupTimeout() | 108 | void CardMonitor::popupTimeout() |
104 | { | 109 | { |
105 | popupMenu->hide(); | 110 | popupMenu->hide(); |
106 | } | 111 | } |
107 | 112 | ||
108 | void CardMonitor::mousePressEvent(QMouseEvent *) | 113 | void CardMonitor::mousePressEvent(QMouseEvent *) |
109 | { | 114 | { |
110 | QPopupMenu *menu = new QPopupMenu(this); | 115 | QPopupMenu *menu = new QPopupMenu(this); |
111 | QString cmd; | 116 | QString cmd; |
112 | int err = 0; | 117 | int err = 0; |
113 | 118 | ||
114 | if (cardInSd) { | 119 | if (cardInSd) { |
115 | menu->insertItem(QIconSet(Resource::loadPixmap("cardmon/ide")), | 120 | menu->insertItem(QIconSet(Resource::loadPixmap("cardmon/ide")), |
116 | tr("Eject SD/MMC card"), 0); | 121 | tr("Eject SD/MMC card"), 0); |
117 | } | 122 | } |
118 | 123 | ||
119 | if (cardInPcmcia0) { | 124 | if (cardInPcmcia0) { |
120 | menu-> | 125 | menu-> |
121 | insertItem(QIconSet | 126 | insertItem(QIconSet |
122 | (Resource::loadPixmap("cardmon/" + cardInPcmcia0Type)), | 127 | (Resource::loadPixmap("cardmon/" + cardInPcmcia0Type)), |
123 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1); | 128 | tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1); |
124 | } | 129 | } |
125 | 130 | ||
126 | if (cardInPcmcia1) { | 131 | if (cardInPcmcia1) { |
127 | menu-> | 132 | menu-> |
128 | insertItem(QIconSet | 133 | insertItem(QIconSet |
129 | (Resource::loadPixmap("cardmon/" + cardInPcmcia1Type)), | 134 | (Resource::loadPixmap("cardmon/" + cardInPcmcia1Type)), |
130 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2); | 135 | tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2); |
131 | } | 136 | } |
@@ -274,71 +279,71 @@ bool CardMonitor::getStatusPcmcia(int showPopUp) | |||
274 | qDebug("no file found"); | 279 | qDebug("no file found"); |
275 | cardInPcmcia0 = FALSE; | 280 | cardInPcmcia0 = FALSE; |
276 | cardInPcmcia1 = FALSE; | 281 | cardInPcmcia1 = FALSE; |
277 | } | 282 | } |
278 | repaint( FALSE ); | 283 | repaint( FALSE ); |
279 | return ((cardWas0 == cardInPcmcia0 | 284 | return ((cardWas0 == cardInPcmcia0 |
280 | && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); | 285 | && cardWas1 == cardInPcmcia1) ? FALSE : TRUE); |
281 | 286 | ||
282 | } | 287 | } |
283 | 288 | ||
284 | 289 | ||
285 | bool CardMonitor::getStatusSd(int showPopUp) | 290 | bool CardMonitor::getStatusSd(int showPopUp) |
286 | { | 291 | { |
287 | 292 | ||
288 | bool cardWas = cardInSd;// remember last state | 293 | bool cardWas = cardInSd;// remember last state |
289 | cardInSd = FALSE; | 294 | cardInSd = FALSE; |
290 | 295 | ||
291 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 296 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
292 | struct mntent *me; | 297 | struct mntent *me; |
293 | FILE *mntfp = setmntent("/etc/mtab", "r"); | 298 | FILE *mntfp = setmntent("/etc/mtab", "r"); |
294 | 299 | ||
295 | if (mntfp) { | 300 | if (mntfp) { |
296 | while ((me = getmntent(mntfp)) != 0) { | 301 | while ((me = getmntent(mntfp)) != 0) { |
297 | QString fs = me->mnt_fsname; | 302 | QString fs = me->mnt_fsname; |
298 | //qDebug( fs ); | 303 | //qDebug( fs ); |
299 | if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" | 304 | if (fs.left(14) == "/dev/mmc/part1" || fs.left(7) == "/dev/sd" |
300 | || fs.left(9) == "/dev/mmcd") { | 305 | || fs.left(9) == "/dev/mmcd") { |
301 | cardInSd = TRUE; | 306 | cardInSd = TRUE; |
302 | show(); | 307 | show(); |
303 | } | 308 | } |
304 | // else { | 309 | // else { |
305 | // cardInSd = FALSE; | 310 | // cardInSd = FALSE; |
306 | // } | 311 | // } |
307 | } | 312 | } |
308 | endmntent(mntfp); | 313 | endmntent(mntfp); |
309 | } | 314 | } |
310 | 315 | ||
311 | if (!showPopUp && cardWas != cardInSd) { | 316 | if (!showPopUp && cardWas != cardInSd) { |
312 | QString text = QString::null; | 317 | QString text = QString::null; |
313 | QString what = QString::null; | 318 | QString what = QString::null; |
314 | if (cardInSd) { | 319 | if (cardInSd) { |
315 | text += "New card: SD/MMC"; | 320 | text += "New card: SD/MMC"; |
316 | what = "on"; | 321 | what = "on"; |
317 | } else { | 322 | } else { |
318 | text += "Ejected: SD/MMC"; | 323 | text += "Ejected: SD/MMC"; |
319 | what = "off"; | 324 | what = "off"; |
320 | } | 325 | } |
321 | //qDebug("TEXT: " + text ); | 326 | //qDebug("TEXT: " + text ); |
322 | QSound::play(Resource::findSound("cardmon/card" + what)); | 327 | QSound::play(Resource::findSound("cardmon/card" + what)); |
323 | popUp(text, "cardmon/ide");// XX add SD pic | 328 | popUp(text, "cardmon/ide");// XX add SD pic |
324 | } | 329 | } |
325 | #else | 330 | #else |
326 | #error "Not on Linux" | 331 | #error "Not on Linux" |
327 | #endif | 332 | #endif |
328 | repaint( FALSE ); | 333 | repaint( FALSE ); |
329 | return ((cardWas == cardInSd) ? FALSE : TRUE); | 334 | return ((cardWas == cardInSd) ? FALSE : TRUE); |
330 | } | 335 | } |
331 | 336 | ||
332 | void CardMonitor::paintEvent(QPaintEvent *) | 337 | void CardMonitor::paintEvent(QPaintEvent *) |
333 | { | 338 | { |
334 | 339 | ||
335 | QPainter p(this); | 340 | QPainter p(this); |
336 | 341 | ||
337 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { | 342 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { |
338 | p.drawPixmap(0, 0, pm); | 343 | p.drawPixmap(0, 0, pm ); |
339 | show(); | 344 | show(); |
340 | } else { | 345 | } else { |
341 | //p.eraseRect(rect()); | 346 | //p.eraseRect(rect()); |
342 | hide(); | 347 | hide(); |
343 | } | 348 | } |
344 | } | 349 | } |
diff --git a/core/applets/cardmon/cardmon.h b/core/applets/cardmon/cardmon.h index 49bcae8..4f00920 100644 --- a/core/applets/cardmon/cardmon.h +++ b/core/applets/cardmon/cardmon.h | |||
@@ -1,58 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * cardmon.h | 2 | * cardmon.h |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * copyright : (c) 2002 by Maximilian Reiss | 6 | * copyright : (c) 2003 by Maximilian Reiss |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * based on two apps by Devin Butterfield | 8 | * based on two apps by Devin Butterfield |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #ifndef CARDMON_H | 19 | #ifndef CARDMON_H |
20 | #define CARDMON_H | 20 | #define CARDMON_H |
21 | 21 | ||
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpixmap.h> | 23 | #include <qpixmap.h> |
24 | #include <qpopupmenu.h> | 24 | #include <qpopupmenu.h> |
25 | 25 | ||
26 | class CardMonitor : public QWidget { | 26 | class CardMonitor : public QWidget { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | public: | 28 | public: |
29 | CardMonitor( QWidget *parent = 0 ); | 29 | CardMonitor( QWidget *parent = 0 ); |
30 | ~CardMonitor(); | 30 | ~CardMonitor(); |
31 | bool getStatusPcmcia( int showPopUp = FALSE ); | 31 | bool getStatusPcmcia( int showPopUp = FALSE ); |
32 | bool getStatusSd( int showPopUp = FALSE ); | 32 | bool getStatusSd( int showPopUp = FALSE ); |
33 | 33 | ||
34 | private slots: | 34 | private slots: |
35 | void cardMessage( const QCString &msg, const QByteArray & ); | 35 | void cardMessage( const QCString &msg, const QByteArray & ); |
36 | void popupTimeout(); | 36 | void popupTimeout(); |
37 | 37 | ||
38 | protected: | 38 | protected: |
39 | void paintEvent( QPaintEvent* ); | 39 | void paintEvent( QPaintEvent* ); |
40 | void mousePressEvent( QMouseEvent * ); | 40 | void mousePressEvent( QMouseEvent * ); |
41 | private: | 41 | private: |
42 | QPixmap pm; | 42 | QPixmap pm; |
43 | // pcmcia socket 0 | 43 | // pcmcia socket 0 |
44 | bool cardInPcmcia0; | 44 | bool cardInPcmcia0; |
45 | QString cardInPcmcia0Name; | 45 | QString cardInPcmcia0Name; |
46 | QString cardInPcmcia0Type; | 46 | QString cardInPcmcia0Type; |
47 | // pcmcia socket 1 | 47 | // pcmcia socket 1 |
48 | bool cardInPcmcia1; | 48 | bool cardInPcmcia1; |
49 | QString cardInPcmcia1Name; | 49 | QString cardInPcmcia1Name; |
50 | QString cardInPcmcia1Type; | 50 | QString cardInPcmcia1Type; |
51 | bool cardInSd; | 51 | bool cardInSd; |
52 | void iconShow(); | 52 | void iconShow(); |
53 | QPopupMenu *popupMenu; | 53 | QPopupMenu *popupMenu; |
54 | void popUp(QString message, QString icon = QString::null ); | 54 | void popUp(QString message, QString icon = QString::null ); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | #endif | 57 | #endif |
58 | 58 | ||
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp index b83e16e..21b68e3 100644 --- a/core/applets/clipboardapplet/clipboard.cpp +++ b/core/applets/clipboardapplet/clipboard.cpp | |||
@@ -1,358 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | #include "clipboard.h" | 21 | #include "clipboard.h" |
22 | 22 | ||
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/applnk.h> | ||
24 | 25 | ||
25 | #include <qpainter.h> | 26 | #include <qpainter.h> |
26 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
27 | #include <qwindowsystem_qws.h> | 28 | #include <qwindowsystem_qws.h> |
28 | #include <qapplication.h> | 29 | #include <qapplication.h> |
29 | #include <qclipboard.h> | 30 | #include <qclipboard.h> |
30 | #include <qtimer.h> | 31 | #include <qtimer.h> |
31 | 32 | ||
32 | //=========================================================================== | 33 | //=========================================================================== |
33 | 34 | ||
34 | /* XPM */ | ||
35 | static const char * paste_xpm[] = { | ||
36 | "14 16 167 2", | ||
37 | " c None", | ||
38 | ". c #96A0AC", | ||
39 | "+ c #9BB0D4", | ||
40 | "@ c #5E7095", | ||
41 | "# c #F1CA79", | ||
42 | "$ c #EFC56D", | ||
43 | "% c #C9AF76", | ||
44 | "& c #9FABBA", | ||
45 | "* c #AEBFDD", | ||
46 | "= c #8899BA", | ||
47 | "- c #726E68", | ||
48 | "; c #D19A33", | ||
49 | "> c #DA9524", | ||
50 | ", c #EFC065", | ||
51 | "' c #F3DDA6", | ||
52 | ") c #E9D192", | ||
53 | "! c #ADA895", | ||
54 | "~ c #9AA8BF", | ||
55 | "{ c #B4C2D8", | ||
56 | "] c #AEBED7", | ||
57 | "^ c #797E8A", | ||
58 | "/ c #B78534", | ||
59 | "( c #DE8516", | ||
60 | "_ c #8A4308", | ||
61 | ": c #F0C470", | ||
62 | "< c #F5EFD3", | ||
63 | "[ c #DFD7B4", | ||
64 | "} c #8F9BA6", | ||
65 | "| c #7C8BA3", | ||
66 | "1 c #808A9A", | ||
67 | "2 c #828892", | ||
68 | "3 c #727582", | ||
69 | "4 c #9A6435", | ||
70 | "5 c #F37004", | ||
71 | "6 c #A24104", | ||
72 | "7 c #F0C36E", | ||
73 | "8 c #F4EBCC", | ||
74 | "9 c #ECDCAF", | ||
75 | "0 c #CDC29B", | ||
76 | "a c #C1B486", | ||
77 | "b c #C3A86B", | ||
78 | "c c #B8924A", | ||
79 | "d c #B17B31", | ||
80 | "e c #C66C1C", | ||
81 | "f c #DE6610", | ||
82 | "g c #944311", | ||
83 | "h c #F3E8C6", | ||
84 | "i c #F3E0AB", | ||
85 | "j c #F2DB9B", | ||
86 | "k c #F1D382", | ||
87 | "l c #F0C056", | ||
88 | "m c #CCA354", | ||
89 | "n c #B7B09D", | ||
90 | "o c #C2A898", | ||
91 | "p c #BCA298", | ||
92 | "q c #9A959F", | ||
93 | "r c #526C8F", | ||
94 | "s c #F3E4B9", | ||
95 | "t c #F3DA99", | ||
96 | "u c #F4D78A", | ||
97 | "v c #F5CA6A", | ||
98 | "w c #F4B032", | ||
99 | "x c #C19A56", | ||
100 | "y c #C2D7EA", | ||
101 | "z c #C0D0E7", | ||
102 | "A c #B0C6E8", | ||
103 | "B c #A6C1EB", | ||
104 | "C c #6AA1E3", | ||
105 | "D c #F0C36D", | ||
106 | "E c #F3E2B0", | ||
107 | "F c #F3D891", | ||
108 | "G c #F3CF7A", | ||
109 | "H c #F4BC4C", | ||
110 | "I c #F3A51C", | ||
111 | "J c #BC9758", | ||
112 | "K c #CAE4FE", | ||
113 | "L c #C5DDFB", | ||
114 | "M c #B5D3FB", | ||
115 | "N c #A8CCFC", | ||
116 | "O c #63A6F6", | ||
117 | "P c #2180E3", | ||
118 | "Q c #F3E1AE", | ||
119 | "R c #F3D488", | ||
120 | "S c #F3C664", | ||
121 | "T c #F4B63C", | ||
122 | "U c #F2A61C", | ||
123 | "V c #BC9A5C", | ||
124 | "W c #CCE6FE", | ||
125 | "X c #C8DEFB", | ||
126 | "Y c #B9D6FB", | ||
127 | "Z c #B2D0FC", | ||
128 | "` c #84B6FB", | ||
129 | " .c #479DFB", | ||
130 | "..c #F3DFAC", | ||
131 | "+.c #F3CC76", | ||
132 | "@.c #F3BE52", | ||
133 | "#.c #F4B53A", | ||
134 | "$.c #F2AB24", | ||
135 | "%.c #BC9D61", | ||
136 | "&.c #CBE5FE", | ||
137 | "*.c #C3DBFB", | ||
138 | "=.c #B0D0FB", | ||
139 | "-.c #ACCBFC", | ||
140 | ";.c #A0C3FD", | ||
141 | ">.c #6EB1FF", | ||
142 | ",.c #F3DCA4", | ||
143 | "'.c #F3C35F", | ||
144 | ").c #F3BC4A", | ||
145 | "!.c #F3AC26", | ||
146 | "~.c #BC9E63", | ||
147 | "{.c #CAE4FF", | ||
148 | "].c #BCD7FB", | ||
149 | "^.c #A3C7FB", | ||
150 | "/.c #94BCFB", | ||
151 | "(.c #92BAFB", | ||
152 | "_.c #74B4FE", | ||
153 | ":.c #F1C46D", | ||
154 | "<.c #F4D99A", | ||
155 | "[.c #F4BE52", | ||
156 | "}.c #F4BB47", | ||
157 | "|.c #F4B63D", | ||
158 | "1.c #F4AD27", | ||
159 | "2.c #BC9E64", | ||
160 | "3.c #CAE5FF", | ||
161 | "4.c #BAD6FB", | ||
162 | "5.c #A1C5FB", | ||
163 | "6.c #9AC1FB", | ||
164 | "7.c #9DC1FC", | ||
165 | "8.c #7CBAFE", | ||
166 | "9.c #F5C870", | ||
167 | "0.c #F8DC9B", | ||
168 | "a.c #F8C65C", | ||
169 | "b.c #F8C252", | ||
170 | "c.c #F8BE49", | ||
171 | "d.c #F7B534", | ||
172 | "e.c #BFA46C", | ||
173 | "f.c #CBE4FF", | ||
174 | "g.c #B7D3FB", | ||
175 | "h.c #A4C6FB", | ||
176 | "i.c #A0C4FB", | ||
177 | "j.c #A2C4FC", | ||
178 | "k.c #80BDFF", | ||
179 | "l.c #BC9250", | ||
180 | "m.c #BF9461", | ||
181 | "n.c #BD8944", | ||
182 | "o.c #BD863D", | ||
183 | "p.c #BD8438", | ||
184 | "q.c #BC7C2C", | ||
185 | "r.c #988269", | ||
186 | "s.c #C5E7FF", | ||
187 | "t.c #C0DDFE", | ||
188 | "u.c #B2D4FE", | ||
189 | "v.c #ACD1FE", | ||
190 | "w.c #ACD0FE", | ||
191 | "x.c #7DC0FF", | ||
192 | "y.c #805835", | ||
193 | "z.c #754D26", | ||
194 | "A.c #754C22", | ||
195 | "B.c #754B20", | ||
196 | "C.c #75471A", | ||
197 | "D.c #534D4F", | ||
198 | "E.c #619BCE", | ||
199 | "F.c #6295C8", | ||
200 | "G.c #5C91C8", | ||
201 | "H.c #598FC8", | ||
202 | "I.c #588FC8", | ||
203 | "J.c #3E87CD", | ||
204 | " . + @ ", | ||
205 | " # $ % & * = - ; > ", | ||
206 | ", ' ) ! ~ { ] ^ / ( _ ", | ||
207 | ": < [ } | 1 2 3 4 5 6 ", | ||
208 | "7 8 9 0 a b c d e f g ", | ||
209 | "7 h i j k l m n o p q r ", | ||
210 | "7 s t u v w x y z A B C ", | ||
211 | "D E F G H I J K L M N O P ", | ||
212 | "D Q R S T U V W X Y Z ` . ", | ||
213 | "D ..+.@.#.$.%.&.*.=.-.;.>. ", | ||
214 | "7 ,.'.).T !.~.{.].^./.(._. ", | ||
215 | ":.<.[.}.|.1.2.3.4.5.6.7.8. ", | ||
216 | "9.0.a.b.c.d.e.f.g.h.i.j.k. ", | ||
217 | "l.m.n.o.p.q.r.s.t.u.v.w.x. ", | ||
218 | " y.z.A.B.C.D.E.F.G.H.I.J. ", | ||
219 | " "}; | ||
220 | |||
221 | 35 | ||
222 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) | 36 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) |
223 | { | 37 | { |
224 | setFixedWidth ( 14 ); | 38 | setFixedWidth ( AppLnk::smallIconSize() ); |
225 | setFixedHeight ( 18 ); | 39 | setFixedHeight ( AppLnk::smallIconSize() ); |
226 | m_clipboardPixmap = QPixmap ( paste_xpm ); | 40 | m_clipboardPixmap = QPixmap ( Resource::loadPixmap( "paste" ) ); |
227 | 41 | ||
228 | m_timer = new QTimer ( this ); | 42 | m_timer = new QTimer ( this ); |
229 | 43 | ||
230 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); | 44 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); |
231 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); | 45 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); |
232 | connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); | 46 | connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); |
233 | 47 | ||
234 | m_menu = 0; | 48 | m_menu = 0; |
235 | m_dirty = true; | 49 | m_dirty = true; |
236 | m_lasttext = QString::null; | 50 | m_lasttext = QString::null; |
237 | 51 | ||
238 | m_timer-> start ( 0, true ); | 52 | m_timer-> start ( 0, true ); |
239 | } | 53 | } |
240 | 54 | ||
241 | ClipboardApplet::~ClipboardApplet ( ) | 55 | ClipboardApplet::~ClipboardApplet ( ) |
242 | { | 56 | { |
243 | } | 57 | } |
244 | 58 | ||
245 | void ClipboardApplet::shutdown ( ) | 59 | void ClipboardApplet::shutdown ( ) |
246 | { | 60 | { |
247 | // the timer has to be stopped, or Qt/E will hang on quit() | 61 | // the timer has to be stopped, or Qt/E will hang on quit() |
248 | // see launcher/desktop.cpp | 62 | // see launcher/desktop.cpp |
249 | 63 | ||
250 | m_timer-> stop ( ); | 64 | m_timer-> stop ( ); |
251 | } | 65 | } |
252 | 66 | ||
253 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) | 67 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) |
254 | { | 68 | { |
255 | if ( m_dirty ) { | 69 | if ( m_dirty ) { |
256 | delete m_menu; | 70 | delete m_menu; |
257 | 71 | ||
258 | m_menu = new QPopupMenu ( this ); | 72 | m_menu = new QPopupMenu ( this ); |
259 | m_menu-> setCheckable ( true ); | 73 | m_menu-> setCheckable ( true ); |
260 | 74 | ||
261 | if ( m_history. count ( )) { | 75 | if ( m_history. count ( )) { |
262 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { | 76 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { |
263 | QString str = m_history [i]; | 77 | QString str = m_history [i]; |
264 | 78 | ||
265 | if ( str. length ( ) > 20 ) | 79 | if ( str. length ( ) > 20 ) |
266 | str = str. left ( 20 ) + "..."; | 80 | str = str. left ( 20 ) + "..."; |
267 | 81 | ||
268 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); | 82 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); |
269 | m_menu-> setItemChecked ( i, false ); | 83 | m_menu-> setItemChecked ( i, false ); |
270 | } | 84 | } |
271 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); | 85 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); |
272 | m_menu-> insertSeparator ( ); | 86 | m_menu-> insertSeparator ( ); |
273 | } | 87 | } |
274 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); | 88 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); |
275 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); | 89 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); |
276 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); | 90 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); |
277 | 91 | ||
278 | connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); | 92 | connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); |
279 | 93 | ||
280 | m_dirty = false; | 94 | m_dirty = false; |
281 | } | 95 | } |
282 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 96 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
283 | QSize s = m_menu-> sizeHint ( ); | 97 | QSize s = m_menu-> sizeHint ( ); |
284 | 98 | ||
285 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); | 99 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); |
286 | } | 100 | } |
287 | 101 | ||
288 | void ClipboardApplet::action(int id) | 102 | void ClipboardApplet::action(int id) |
289 | { | 103 | { |
290 | ushort unicode = 0; | 104 | ushort unicode = 0; |
291 | int scan = 0; | 105 | int scan = 0; |
292 | 106 | ||
293 | switch ( id ) { | 107 | switch ( id ) { |
294 | case 100: | 108 | case 100: |
295 | unicode = 'X' - '@'; | 109 | unicode = 'X' - '@'; |
296 | scan = Key_X; // Cut | 110 | scan = Key_X; // Cut |
297 | break; | 111 | break; |
298 | case 101: | 112 | case 101: |
299 | unicode = 'C' - '@'; | 113 | unicode = 'C' - '@'; |
300 | scan = Key_C; // Copy | 114 | scan = Key_C; // Copy |
301 | break; | 115 | break; |
302 | case 102: | 116 | case 102: |
303 | unicode = 'V' - '@'; | 117 | unicode = 'V' - '@'; |
304 | scan = Key_V; // Paste | 118 | scan = Key_V; // Paste |
305 | break; | 119 | break; |
306 | 120 | ||
307 | default: | 121 | default: |
308 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { | 122 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { |
309 | QApplication::clipboard ( )-> setText ( m_history [id] ); | 123 | QApplication::clipboard ( )-> setText ( m_history [id] ); |
310 | 124 | ||
311 | for ( uint i = 0; i < m_history. count ( ); i++ ) | 125 | for ( uint i = 0; i < m_history. count ( ); i++ ) |
312 | m_menu-> setItemChecked ( i, i == uint( id )); | 126 | m_menu-> setItemChecked ( i, i == uint( id )); |
313 | 127 | ||
314 | unicode = 'V' - '@'; | 128 | unicode = 'V' - '@'; |
315 | scan = Key_V; | 129 | scan = Key_V; |
316 | } | 130 | } |
317 | break; | 131 | break; |
318 | } | 132 | } |
319 | 133 | ||
320 | if ( scan ) { | 134 | if ( scan ) { |
321 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); | 135 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); |
322 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); | 136 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); |
323 | } | 137 | } |
324 | } | 138 | } |
325 | 139 | ||
326 | void ClipboardApplet::paintEvent ( QPaintEvent* ) | 140 | void ClipboardApplet::paintEvent ( QPaintEvent* ) |
327 | { | 141 | { |
328 | QPainter p ( this ); | 142 | QPainter p ( this ); |
329 | p. drawPixmap ( 0, 1, m_clipboardPixmap ); | 143 | p. drawPixmap( 0, 1, m_clipboardPixmap ); |
330 | } | 144 | } |
331 | 145 | ||
332 | void ClipboardApplet::newData ( ) | 146 | void ClipboardApplet::newData ( ) |
333 | { | 147 | { |
334 | static bool excllock = false; | 148 | static bool excllock = false; |
335 | 149 | ||
336 | if ( excllock ) | 150 | if ( excllock ) |
337 | return; | 151 | return; |
338 | else | 152 | else |
339 | excllock = true; | 153 | excllock = true; |
340 | 154 | ||
341 | m_timer-> stop ( ); | 155 | m_timer-> stop ( ); |
342 | 156 | ||
343 | QCString type = "plain"; | 157 | QCString type = "plain"; |
344 | QString txt = QApplication::clipboard ( )-> text ( type ); | 158 | QString txt = QApplication::clipboard ( )-> text ( type ); |
345 | 159 | ||
346 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { | 160 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { |
347 | m_history. append ( txt ); | 161 | m_history. append ( txt ); |
348 | 162 | ||
349 | if ( m_history. count ( ) > 5 ) | 163 | if ( m_history. count ( ) > 5 ) |
350 | m_history. remove ( m_history. begin ( )); | 164 | m_history. remove ( m_history. begin ( )); |
351 | 165 | ||
352 | m_dirty = true; | 166 | m_dirty = true; |
353 | } | 167 | } |
354 | 168 | ||
355 | m_timer-> start ( 1500, true ); | 169 | m_timer-> start ( 1500, true ); |
356 | 170 | ||
357 | excllock = false; | 171 | excllock = false; |
358 | } | 172 | } |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index ed07ec4..906bb77 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,90 +1,91 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | 22 | ||
23 | #include "volume.h" | 23 | #include "volume.h" |
24 | 24 | ||
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/applnk.h> | ||
27 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
28 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 29 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
29 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
30 | #endif | 31 | #endif |
31 | 32 | ||
32 | #include <qpainter.h> | 33 | #include <qpainter.h> |
33 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
34 | #include <qslider.h> | 35 | #include <qslider.h> |
35 | #include <qlayout.h> | 36 | #include <qlayout.h> |
36 | #include <qframe.h> | 37 | #include <qframe.h> |
37 | #include <qpixmap.h> | 38 | #include <qpixmap.h> |
38 | #include <qvbox.h> | 39 | #include <qvbox.h> |
39 | #include <qlabel.h> | 40 | #include <qlabel.h> |
40 | 41 | ||
41 | #include <qtoolbutton.h> | 42 | #include <qtoolbutton.h> |
42 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
43 | #include <qtimer.h> | 44 | #include <qtimer.h> |
44 | 45 | ||
45 | #include <opie/odevice.h> | 46 | #include <opie/odevice.h> |
46 | 47 | ||
47 | #include "oledbox.h" | 48 | #include "oledbox.h" |
48 | 49 | ||
49 | using namespace Opie; | 50 | using namespace Opie; |
50 | 51 | ||
51 | #define RATE_TIMER_INTERVAL 100 | 52 | #define RATE_TIMER_INTERVAL 100 |
52 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 53 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
53 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 54 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
54 | 55 | ||
55 | 56 | ||
56 | /* XPM */ | 57 | /* XPM */ |
57 | static const char * vol_xpm[] = { | 58 | static const char * vol_xpm[] = { |
58 | "20 20 3 1", | 59 | "20 20 3 1", |
59 | " c None", | 60 | " c None", |
60 | ". c #0000FF", | 61 | ". c #0000FF", |
61 | "+ c #000000", | 62 | "+ c #000000", |
62 | " ", | 63 | " ", |
63 | " . ", | 64 | " . ", |
64 | " . . . . ", | 65 | " . . . . ", |
65 | " . . . . . . ", | 66 | " . . . . . . ", |
66 | " . . . . . . . ", | 67 | " . . . . . . . ", |
67 | " . . ..... . . ", | 68 | " . . ..... . . ", |
68 | " . ... ..... ... ", | 69 | " . ... ..... ... ", |
69 | " ........... .... ", | 70 | " ........... .... ", |
70 | " ................. ", | 71 | " ................. ", |
71 | "++++++++++++++++++++", | 72 | "++++++++++++++++++++", |
72 | " .................. ", | 73 | " .................. ", |
73 | " . ............. . ", | 74 | " . ............. . ", |
74 | " . ..... ....... ", | 75 | " . ..... ....... ", |
75 | " . ... ..... . ", | 76 | " . ... ..... . ", |
76 | " . ... ..... . ", | 77 | " . ... ..... . ", |
77 | " . ... ..... ", | 78 | " . ... ..... ", |
78 | " . . . . . ", | 79 | " . . . . . ", |
79 | " . . . ", | 80 | " . . . ", |
80 | " . . . ", | 81 | " . . . ", |
81 | " "}; | 82 | " "}; |
82 | /* XPM */ | 83 | /* XPM */ |
83 | static const char * mic_xpm[] = { | 84 | static const char * mic_xpm[] = { |
84 | "20 20 21 1", | 85 | "20 20 21 1", |
85 | " c None", | 86 | " c None", |
86 | ". c #000000", | 87 | ". c #000000", |
87 | "+ c #EEEEEE", | 88 | "+ c #EEEEEE", |
88 | "@ c #B4B6B4", | 89 | "@ c #B4B6B4", |
89 | "# c #8B8D8B", | 90 | "# c #8B8D8B", |
90 | "$ c #D5D6D5", | 91 | "$ c #D5D6D5", |
@@ -664,119 +665,119 @@ void VolumeControl::alarmMoved ( int percent ) | |||
664 | } | 665 | } |
665 | 666 | ||
666 | 667 | ||
667 | void VolumeControl::bassMoved ( int percent ) | 668 | void VolumeControl::bassMoved ( int percent ) |
668 | { | 669 | { |
669 | m_bass_percent = 100 - percent; | 670 | m_bass_percent = 100 - percent; |
670 | 671 | ||
671 | // clamp bass percent to be between 0 and 100 | 672 | // clamp bass percent to be between 0 and 100 |
672 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 673 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
673 | 674 | ||
674 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 675 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
675 | } | 676 | } |
676 | 677 | ||
677 | 678 | ||
678 | 679 | ||
679 | void VolumeControl::trebleMoved ( int percent ) | 680 | void VolumeControl::trebleMoved ( int percent ) |
680 | { | 681 | { |
681 | m_treble_percent = 100 - percent; | 682 | m_treble_percent = 100 - percent; |
682 | 683 | ||
683 | // clamp treble percent to be between 0 and 100 | 684 | // clamp treble percent to be between 0 and 100 |
684 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 685 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
685 | 686 | ||
686 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 687 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
687 | } | 688 | } |
688 | 689 | ||
689 | 690 | ||
690 | 691 | ||
691 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 692 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
692 | { | 693 | { |
693 | Config cfg ( "qpe" ); | 694 | Config cfg ( "qpe" ); |
694 | cfg. setGroup ( "Volume" ); | 695 | cfg. setGroup ( "Volume" ); |
695 | cfg. writeEntry ( entry, val ); | 696 | cfg. writeEntry ( entry, val ); |
696 | // cfg. write ( ); | 697 | // cfg. write ( ); |
697 | 698 | ||
698 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 699 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
699 | switch ( upd ) { | 700 | switch ( upd ) { |
700 | case UPD_Vol: { | 701 | case UPD_Vol: { |
701 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 702 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
702 | break; | 703 | break; |
703 | } | 704 | } |
704 | case UPD_Mic: { | 705 | case UPD_Mic: { |
705 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 706 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
706 | break; | 707 | break; |
707 | } | 708 | } |
708 | case UPD_Bass: { | 709 | case UPD_Bass: { |
709 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 710 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
710 | break; | 711 | break; |
711 | } | 712 | } |
712 | case UPD_Treble: { | 713 | case UPD_Treble: { |
713 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 714 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
714 | break; | 715 | break; |
715 | } | 716 | } |
716 | 717 | ||
717 | case UPD_None: | 718 | case UPD_None: |
718 | break; | 719 | break; |
719 | } | 720 | } |
720 | #endif | 721 | #endif |
721 | } | 722 | } |
722 | 723 | ||
723 | //=========================================================================== | 724 | //=========================================================================== |
724 | 725 | ||
725 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 726 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
726 | : QWidget( parent, name ) | 727 | : QWidget( parent, name ) |
727 | { | 728 | { |
728 | setFixedHeight ( 18 ); | 729 | setFixedWidth ( AppLnk::smallIconSize() ); |
729 | setFixedWidth ( 14 ); | 730 | setFixedHeight ( AppLnk::smallIconSize() ); |
730 | 731 | ||
731 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 732 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
732 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 733 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
733 | 734 | ||
734 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); | 735 | connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); |
735 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); | 736 | connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); |
736 | } | 737 | } |
737 | 738 | ||
738 | VolumeApplet::~VolumeApplet() | 739 | VolumeApplet::~VolumeApplet() |
739 | { | 740 | { |
740 | delete m_pixmap; | 741 | delete m_pixmap; |
741 | } | 742 | } |
742 | 743 | ||
743 | 744 | ||
744 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 745 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
745 | { | 746 | { |
746 | if ( m_dialog-> isVisible ( )) | 747 | if ( m_dialog-> isVisible ( )) |
747 | m_dialog-> hide ( ); | 748 | m_dialog-> hide ( ); |
748 | else | 749 | else |
749 | m_dialog-> show ( true ); | 750 | m_dialog-> show ( true ); |
750 | } | 751 | } |
751 | 752 | ||
752 | void VolumeApplet::redraw ( bool all ) | 753 | void VolumeApplet::redraw ( bool all ) |
753 | { | 754 | { |
754 | if ( all ) | 755 | if ( all ) |
755 | repaint ( true ); | 756 | repaint ( true ); |
756 | else | 757 | else |
757 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 758 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
758 | } | 759 | } |
759 | 760 | ||
760 | 761 | ||
761 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 762 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
762 | { | 763 | { |
763 | QPainter p ( this ); | 764 | QPainter p ( this ); |
764 | 765 | ||
765 | p. drawPixmap ( 0, 1, *m_pixmap ); | 766 | p. drawPixmap ( 0, 1, *m_pixmap ); |
766 | p. setPen ( darkGray ); | 767 | p. setPen ( darkGray ); |
767 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 768 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
768 | 769 | ||
769 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 770 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
770 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 771 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
771 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 772 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
772 | 773 | ||
773 | if ( m_dialog-> volMuted ( )) { | 774 | if ( m_dialog-> volMuted ( )) { |
774 | p. setPen ( red ); | 775 | p. setPen ( red ); |
775 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 776 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
776 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 777 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
777 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 778 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
778 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 779 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
779 | } | 780 | } |
780 | } | 781 | } |
781 | 782 | ||
782 | 783 | ||