-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,195 +1,200 @@ | |||
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 | } |
132 | 137 | ||
133 | QPoint p = mapToGlobal(QPoint(0, 0)); | 138 | QPoint p = mapToGlobal(QPoint(0, 0)); |
134 | QSize s = menu->sizeHint(); | 139 | QSize s = menu->sizeHint(); |
135 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 140 | int opt = menu->exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
136 | p.y() - s.height()), 0); | 141 | p.y() - s.height()), 0); |
137 | 142 | ||
138 | if (opt == 1) { | 143 | if (opt == 1) { |
139 | cmd = "/sbin/cardctl eject 0"; | 144 | cmd = "/sbin/cardctl eject 0"; |
140 | err = system((const char *) cmd); | 145 | err = system((const char *) cmd); |
141 | if (err != 0) { | 146 | if (err != 0) { |
142 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", | 147 | qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", |
143 | err); | 148 | err); |
144 | popUp(tr("CF/PCMCIA card eject failed!")); | 149 | popUp(tr("CF/PCMCIA card eject failed!")); |
145 | } | 150 | } |
146 | } else if (opt == 0) { | 151 | } else if (opt == 0) { |
147 | if (ODevice::inst()->system() == System_Familiar) { | 152 | if (ODevice::inst()->system() == System_Familiar) { |
148 | cmd = "umount /dev/mmc/part1"; | 153 | cmd = "umount /dev/mmc/part1"; |
149 | } else { | 154 | } else { |
150 | cmd = "umount /dev/mmcda1"; | 155 | cmd = "umount /dev/mmcda1"; |
151 | } | 156 | } |
152 | err = system((const char *) cmd); | 157 | err = system((const char *) cmd); |
153 | if (err != 0) { | 158 | if (err != 0) { |
154 | popUp(tr("SD/MMC card eject failed!")); | 159 | popUp(tr("SD/MMC card eject failed!")); |
155 | } | 160 | } |
156 | } else if (opt == 2) { | 161 | } else if (opt == 2) { |
157 | cmd = "/sbin/cardctl eject 1"; | 162 | cmd = "/sbin/cardctl eject 1"; |
158 | err = system((const char *) cmd); | 163 | err = system((const char *) cmd); |
159 | if (err != 0) { | 164 | if (err != 0) { |
160 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", | 165 | qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", |
161 | err); | 166 | err); |
162 | popUp(tr("CF/PCMCIA card eject failed!")); | 167 | popUp(tr("CF/PCMCIA card eject failed!")); |
163 | } | 168 | } |
164 | } | 169 | } |
165 | delete menu; | 170 | delete menu; |
166 | } | 171 | } |
167 | 172 | ||
168 | 173 | ||
169 | void CardMonitor::cardMessage(const QCString & msg, const QByteArray &) | 174 | void CardMonitor::cardMessage(const QCString & msg, const QByteArray &) |
170 | { | 175 | { |
171 | if (msg == "stabChanged()") { | 176 | if (msg == "stabChanged()") { |
172 | // qDebug("Pcmcia: stabchanged"); | 177 | // qDebug("Pcmcia: stabchanged"); |
173 | getStatusPcmcia(); | 178 | getStatusPcmcia(); |
174 | } else if (msg == "mtabChanged()") { | 179 | } else if (msg == "mtabChanged()") { |
175 | // qDebug("CARDMONAPPLET: mtabchanged"); | 180 | // qDebug("CARDMONAPPLET: mtabchanged"); |
176 | getStatusSd(); | 181 | getStatusSd(); |
177 | } | 182 | } |
178 | } | 183 | } |
179 | 184 | ||
180 | bool CardMonitor::getStatusPcmcia(int showPopUp) | 185 | bool CardMonitor::getStatusPcmcia(int showPopUp) |
181 | { | 186 | { |
182 | 187 | ||
183 | bool cardWas0 = cardInPcmcia0;// remember last state | 188 | bool cardWas0 = cardInPcmcia0;// remember last state |
184 | bool cardWas1 = cardInPcmcia1; | 189 | bool cardWas1 = cardInPcmcia1; |
185 | 190 | ||
186 | QString fileName; | 191 | QString fileName; |
187 | 192 | ||
188 | // one of these 3 files should exist | 193 | // one of these 3 files should exist |
189 | if (QFile::exists("/var/run/stab")) { | 194 | if (QFile::exists("/var/run/stab")) { |
190 | fileName = "/var/run/stab"; | 195 | fileName = "/var/run/stab"; |
191 | } else if (QFile::exists("/var/state/pcmcia/stab")) { | 196 | } else if (QFile::exists("/var/state/pcmcia/stab")) { |
192 | fileName = "/var/state/pcmcia/stab"; | 197 | fileName = "/var/state/pcmcia/stab"; |
193 | } else { | 198 | } else { |
194 | fileName = "/var/lib/pcmcia/stab"; | 199 | fileName = "/var/lib/pcmcia/stab"; |
195 | } | 200 | } |
@@ -210,135 +215,135 @@ bool CardMonitor::getStatusPcmcia(int showPopUp) | |||
210 | } else if (!(*line).startsWith("Socket 0: empty") | 215 | } else if (!(*line).startsWith("Socket 0: empty") |
211 | && !cardInPcmcia0) { | 216 | && !cardInPcmcia0) { |
212 | cardInPcmcia0Name = | 217 | cardInPcmcia0Name = |
213 | (*line).mid(((*line).find(':') + 1), | 218 | (*line).mid(((*line).find(':') + 1), |
214 | (*line).length() - 9); | 219 | (*line).length() - 9); |
215 | cardInPcmcia0Name.stripWhiteSpace(); | 220 | cardInPcmcia0Name.stripWhiteSpace(); |
216 | cardInPcmcia0 = TRUE; | 221 | cardInPcmcia0 = TRUE; |
217 | show(); | 222 | show(); |
218 | line++; | 223 | line++; |
219 | int pos = (*line).find('\t') + 1; | 224 | int pos = (*line).find('\t') + 1; |
220 | cardInPcmcia0Type = | 225 | cardInPcmcia0Type = |
221 | (*line).mid(pos, (*line).find("\t", pos) - pos); | 226 | (*line).mid(pos, (*line).find("\t", pos) - pos); |
222 | } | 227 | } |
223 | } else if ((*line).startsWith("Socket 1:")) { | 228 | } else if ((*line).startsWith("Socket 1:")) { |
224 | if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) { | 229 | if ((*line).startsWith("Socket 1: empty") && cardInPcmcia1) { |
225 | cardInPcmcia1 = FALSE; | 230 | cardInPcmcia1 = FALSE; |
226 | } else if (!(*line).startsWith("Socket 1: empty") | 231 | } else if (!(*line).startsWith("Socket 1: empty") |
227 | && !cardInPcmcia1) { | 232 | && !cardInPcmcia1) { |
228 | cardInPcmcia1Name = | 233 | cardInPcmcia1Name = |
229 | (*line).mid(((*line).find(':') + 1), | 234 | (*line).mid(((*line).find(':') + 1), |
230 | (*line).length() - 9); | 235 | (*line).length() - 9); |
231 | cardInPcmcia1Name.stripWhiteSpace(); | 236 | cardInPcmcia1Name.stripWhiteSpace(); |
232 | cardInPcmcia1 = TRUE; | 237 | cardInPcmcia1 = TRUE; |
233 | show(); | 238 | show(); |
234 | line++; | 239 | line++; |
235 | int pos = (*line).find('\t') + 1; | 240 | int pos = (*line).find('\t') + 1; |
236 | cardInPcmcia1Type = | 241 | cardInPcmcia1Type = |
237 | (*line).mid(pos, (*line).find("\t", pos) - pos); | 242 | (*line).mid(pos, (*line).find("\t", pos) - pos); |
238 | } | 243 | } |
239 | } | 244 | } |
240 | } | 245 | } |
241 | f.close(); | 246 | f.close(); |
242 | 247 | ||
243 | if (!showPopUp | 248 | if (!showPopUp |
244 | && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { | 249 | && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { |
245 | QString text = QString::null; | 250 | QString text = QString::null; |
246 | QString what = QString::null; | 251 | QString what = QString::null; |
247 | if (cardWas0 != cardInPcmcia0) { | 252 | if (cardWas0 != cardInPcmcia0) { |
248 | if (cardInPcmcia0) { | 253 | if (cardInPcmcia0) { |
249 | text += tr("New card: "); | 254 | text += tr("New card: "); |
250 | what = "on"; | 255 | what = "on"; |
251 | } else { | 256 | } else { |
252 | text += tr("Ejected: "); | 257 | text += tr("Ejected: "); |
253 | what = "off"; | 258 | what = "off"; |
254 | } | 259 | } |
255 | text += cardInPcmcia0Name; | 260 | text += cardInPcmcia0Name; |
256 | popUp(text, "cardmon/" + cardInPcmcia0Type); | 261 | popUp(text, "cardmon/" + cardInPcmcia0Type); |
257 | } | 262 | } |
258 | 263 | ||
259 | if (cardWas1 != cardInPcmcia1) { | 264 | if (cardWas1 != cardInPcmcia1) { |
260 | if (cardInPcmcia1) { | 265 | if (cardInPcmcia1) { |
261 | text += tr("New card: "); | 266 | text += tr("New card: "); |
262 | what = "on"; | 267 | what = "on"; |
263 | } else { | 268 | } else { |
264 | text += tr("Ejected: "); | 269 | text += tr("Ejected: "); |
265 | what = "off"; | 270 | what = "off"; |
266 | } | 271 | } |
267 | text += cardInPcmcia1Name; | 272 | text += cardInPcmcia1Name; |
268 | popUp(text, "cardmon/" + cardInPcmcia1Type); | 273 | popUp(text, "cardmon/" + cardInPcmcia1Type); |
269 | } | 274 | } |
270 | QSound::play(Resource::findSound("cardmon/card" + what)); | 275 | QSound::play(Resource::findSound("cardmon/card" + what)); |
271 | } | 276 | } |
272 | } else { | 277 | } else { |
273 | // no file found | 278 | // no file found |
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,154 +1,155 @@ | |||
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", |
91 | "% c #E6E6E6", | 92 | "% c #E6E6E6", |
92 | "& c #9C9D9C", | 93 | "& c #9C9D9C", |
93 | "* c #6A696A", | 94 | "* c #6A696A", |
94 | "= c #E6E2E6", | 95 | "= c #E6E2E6", |
95 | "- c #F6F2F6", | 96 | "- c #F6F2F6", |
96 | "; c #CDC6CD", | 97 | "; c #CDC6CD", |
97 | "> c #737573", | 98 | "> c #737573", |
98 | ", c #4A484A", | 99 | ", c #4A484A", |
99 | "' c #DEDEDE", | 100 | "' c #DEDEDE", |
100 | ") c #F6EEF6", | 101 | ") c #F6EEF6", |
101 | "! c #414041", | 102 | "! c #414041", |
102 | "~ c #202020", | 103 | "~ c #202020", |
103 | "{ c #ACAEAC", | 104 | "{ c #ACAEAC", |
104 | "] c #838583", | 105 | "] c #838583", |
105 | "^ c #6A656A", | 106 | "^ c #6A656A", |
106 | " ", | 107 | " ", |
107 | " .... ", | 108 | " .... ", |
108 | " .+@+#. ", | 109 | " .+@+#. ", |
109 | " ..$%&%*. ", | 110 | " ..$%&%*. ", |
110 | " .=-.;=>=,. ", | 111 | " .=-.;=>=,. ", |
111 | " .'+).&+!+. ", | 112 | " .'+).&+!+. ", |
112 | " .+;+;.~+~. ", | 113 | " .+;+;.~+~. ", |
113 | " ..%{%,.... ", | 114 | " ..%{%,.... ", |
114 | " ..&=>=~.. ", | 115 | " ..&=>=~.. ", |
115 | " .+..]^,.. ", | 116 | " .+..]^,.. ", |
116 | " .+....... ", | 117 | " .+....... ", |
117 | " .%... ", | 118 | " .%... ", |
118 | " .=... ", | 119 | " .=... ", |
119 | " .+... ", | 120 | " .+... ", |
120 | " .+... ", | 121 | " .+... ", |
121 | " .... ", | 122 | " .... ", |
122 | " .... ", | 123 | " .... ", |
123 | " .. ", | 124 | " .. ", |
124 | " . ", | 125 | " . ", |
125 | ". "}; | 126 | ". "}; |
126 | 127 | ||
127 | 128 | ||
128 | static const char * bass_xpm[] = { | 129 | static const char * bass_xpm[] = { |
129 | "20 20 3 1", | 130 | "20 20 3 1", |
130 | " c None", | 131 | " c None", |
131 | ". c #000000", | 132 | ". c #000000", |
132 | "+ c #0000FF", | 133 | "+ c #0000FF", |
133 | " ", | 134 | " ", |
134 | " ", | 135 | " ", |
135 | " ", | 136 | " ", |
136 | "..... +++ ......", | 137 | "..... +++ ......", |
137 | " +++++++ ", | 138 | " +++++++ ", |
138 | " ++ ++ ", | 139 | " ++ ++ ", |
139 | "... ++ ... ++ ++ .", | 140 | "... ++ ... ++ ++ .", |
140 | " +++ ++ ++ ", | 141 | " +++ ++ ++ ", |
141 | " ++++ ++ ", | 142 | " ++++ ++ ", |
142 | "... ++++ .. ++ .....", | 143 | "... ++++ .. ++ .....", |
143 | " ++ ++ ", | 144 | " ++ ++ ", |
144 | " ++ ++ ", | 145 | " ++ ++ ", |
145 | "..........++ ++ .", | 146 | "..........++ ++ .", |
146 | " ++ ", | 147 | " ++ ", |
147 | " ++ ", | 148 | " ++ ", |
148 | "...... ++ .........", | 149 | "...... ++ .........", |
149 | " + ", | 150 | " + ", |
150 | " ", | 151 | " ", |
151 | " ", | 152 | " ", |
152 | " "}; | 153 | " "}; |
153 | 154 | ||
154 | 155 | ||
@@ -600,183 +601,183 @@ void VolumeControl::micChanged ( bool nowMuted ) | |||
600 | void VolumeControl::screenTapToggled ( bool b ) | 601 | void VolumeControl::screenTapToggled ( bool b ) |
601 | { | 602 | { |
602 | m_snd_touch = b; | 603 | m_snd_touch = b; |
603 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 604 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
604 | } | 605 | } |
605 | 606 | ||
606 | void VolumeControl::keyClickToggled ( bool b ) | 607 | void VolumeControl::keyClickToggled ( bool b ) |
607 | { | 608 | { |
608 | m_snd_key = b; | 609 | m_snd_key = b; |
609 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 610 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
610 | } | 611 | } |
611 | 612 | ||
612 | void VolumeControl::alarmSoundToggled ( bool b ) | 613 | void VolumeControl::alarmSoundToggled ( bool b ) |
613 | { | 614 | { |
614 | m_snd_alarm = b; | 615 | m_snd_alarm = b; |
615 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 616 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
616 | } | 617 | } |
617 | 618 | ||
618 | void VolumeControl::volMuteToggled ( bool b ) | 619 | void VolumeControl::volMuteToggled ( bool b ) |
619 | { | 620 | { |
620 | m_vol_muted = !b; | 621 | m_vol_muted = !b; |
621 | 622 | ||
622 | m_icon-> redraw ( true ); | 623 | m_icon-> redraw ( true ); |
623 | 624 | ||
624 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 625 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
625 | } | 626 | } |
626 | 627 | ||
627 | void VolumeControl::micMuteToggled ( bool b ) | 628 | void VolumeControl::micMuteToggled ( bool b ) |
628 | { | 629 | { |
629 | m_mic_muted = !b; | 630 | m_mic_muted = !b; |
630 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 631 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
631 | } | 632 | } |
632 | 633 | ||
633 | 634 | ||
634 | void VolumeControl::volMoved ( int percent ) | 635 | void VolumeControl::volMoved ( int percent ) |
635 | { | 636 | { |
636 | m_vol_percent = 100 - percent; | 637 | m_vol_percent = 100 - percent; |
637 | 638 | ||
638 | // clamp volume percent to be between 0 and 100 | 639 | // clamp volume percent to be between 0 and 100 |
639 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 640 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
640 | // repaint just the little volume rectangle | 641 | // repaint just the little volume rectangle |
641 | m_icon-> redraw ( false ); | 642 | m_icon-> redraw ( false ); |
642 | 643 | ||
643 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 644 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
644 | } | 645 | } |
645 | 646 | ||
646 | void VolumeControl::micMoved ( int percent ) | 647 | void VolumeControl::micMoved ( int percent ) |
647 | { | 648 | { |
648 | m_mic_percent = 100 - percent; | 649 | m_mic_percent = 100 - percent; |
649 | 650 | ||
650 | // clamp volume percent to be between 0 and 100 | 651 | // clamp volume percent to be between 0 and 100 |
651 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 652 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
652 | 653 | ||
653 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 654 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
654 | } | 655 | } |
655 | 656 | ||
656 | void VolumeControl::alarmMoved ( int percent ) | 657 | void VolumeControl::alarmMoved ( int percent ) |
657 | { | 658 | { |
658 | m_alarm_percent = 100 - percent; | 659 | m_alarm_percent = 100 - percent; |
659 | 660 | ||
660 | // clamp volume percent to be between 0 and 100 | 661 | // clamp volume percent to be between 0 and 100 |
661 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 662 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
662 | 663 | ||
663 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 664 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
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 | ||