summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp15
-rw-r--r--core/applets/cardmon/cardmon.cpp13
-rw-r--r--core/applets/cardmon/cardmon.h2
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp196
-rw-r--r--core/applets/volumeapplet/volume.cpp5
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
29BatteryMeter::BatteryMeter( QWidget *parent ) 30BatteryMeter::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
40BatteryMeter::~BatteryMeter() 41BatteryMeter::~BatteryMeter()
41{ 42{
42 delete ps; 43 delete ps;
43} 44}
44 45
45QSize BatteryMeter::sizeHint() const 46QSize BatteryMeter::sizeHint() const
46{ 47{
47 return QSize(10,12); 48 return QSize(10, height() );
48} 49}
49 50
50void BatteryMeter::mouseReleaseEvent( QMouseEvent *) 51void 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
63void BatteryMeter::timerEvent( QTimerEvent * ) 64void 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
87void BatteryMeter::chargeTimeout() 88void 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
98void BatteryMeter::paintEvent( QPaintEvent* ) 99void 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,344 +1,349 @@
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
46using namespace Opie; 48using namespace Opie;
47 49
48CardMonitor::CardMonitor(QWidget * parent):QWidget(parent), 50CardMonitor::CardMonitor(QWidget * parent):QWidget(parent),
49pm(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
74CardMonitor::~CardMonitor() 79CardMonitor::~CardMonitor()
75{ 80{
76 if (popupMenu) { 81 if (popupMenu) {
77 delete popupMenu; 82 delete popupMenu;
78 } 83 }
79} 84}
80 85
81void CardMonitor::popUp(QString message, QString icon) 86void 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
103void CardMonitor::popupTimeout() 108void CardMonitor::popupTimeout()
104{ 109{
105 popupMenu->hide(); 110 popupMenu->hide();
106} 111}
107 112
108void CardMonitor::mousePressEvent(QMouseEvent *) 113void 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
169void CardMonitor::cardMessage(const QCString & msg, const QByteArray &) 174void 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
180bool CardMonitor::getStatusPcmcia(int showPopUp) 185bool 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 }
196 201
197 QFile f(fileName); 202 QFile f(fileName);
198 203
199 if (f.open(IO_ReadOnly)) { 204 if (f.open(IO_ReadOnly)) {
200 QStringList list; 205 QStringList list;
201 QTextStream stream(&f); 206 QTextStream stream(&f);
202 QString streamIn; 207 QString streamIn;
203 streamIn = stream.read(); 208 streamIn = stream.read();
204 list = QStringList::split("\n", streamIn); 209 list = QStringList::split("\n", streamIn);
205 for (QStringList::Iterator line = list.begin(); line != list.end(); 210 for (QStringList::Iterator line = list.begin(); line != list.end();
206 line++) { 211 line++) {
207 if ((*line).startsWith("Socket 0:")) { 212 if ((*line).startsWith("Socket 0:")) {
208 if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) { 213 if ((*line).startsWith("Socket 0: empty") && cardInPcmcia0) {
209 cardInPcmcia0 = FALSE; 214 cardInPcmcia0 = FALSE;
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
285bool CardMonitor::getStatusSd(int showPopUp) 290bool 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
332void CardMonitor::paintEvent(QPaintEvent *) 337void 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
26class CardMonitor : public QWidget { 26class CardMonitor : public QWidget {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
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
34private slots: 34private 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
38protected: 38protected:
39 void paintEvent( QPaintEvent* ); 39 void paintEvent( QPaintEvent* );
40 void mousePressEvent( QMouseEvent * ); 40 void mousePressEvent( QMouseEvent * );
41private: 41private:
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 */
35static 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
222ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 36ClipboardApplet::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
241ClipboardApplet::~ClipboardApplet ( ) 55ClipboardApplet::~ClipboardApplet ( )
242{ 56{
243} 57}
244 58
245void ClipboardApplet::shutdown ( ) 59void 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
253void ClipboardApplet::mousePressEvent ( QMouseEvent *) 67void 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
288void ClipboardApplet::action(int id) 102void 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
326void ClipboardApplet::paintEvent ( QPaintEvent* ) 140void 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
332void ClipboardApplet::newData ( ) 146void 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,782 +1,783 @@
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
49using namespace Opie; 50using 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 */
57static const char * vol_xpm[] = { 58static 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 */
83static const char * mic_xpm[] = { 84static 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
128static const char * bass_xpm[] = { 129static 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
155static const char * treble_xpm[] = { 156static const char * treble_xpm[] = {
156"20 20 3 1", 157"20 20 3 1",
157" c None", 158" c None",
158". c #0000FF", 159". c #0000FF",
159"+ c #000000", 160"+ c #000000",
160" .. ", 161" .. ",
161" . .. ", 162" . .. ",
162" . .. ", 163" . .. ",
163"++++++++ . .. ++++++", 164"++++++++ . .. ++++++",
164" . . ", 165" . . ",
165" ... ", 166" ... ",
166"++++++++ . +++++++", 167"++++++++ . +++++++",
167" .. ", 168" .. ",
168" .. . ", 169" .. . ",
169"+++ .. ... +++++++", 170"+++ .. ... +++++++",
170" .. .. .. ", 171" .. .. .. ",
171" .. . . .. ", 172" .. . . .. ",
172"+++ .. . . + . +++++", 173"+++ .. . . + . +++++",
173" .. . .. ", 174" .. . .. ",
174" .. . .. ", 175" .. . .. ",
175"++++ ...... +++++++", 176"++++ ...... +++++++",
176" . ", 177" . ",
177" .. . ", 178" .. . ",
178" .. . ", 179" .. . ",
179" .. "}; 180" .. "};
180 181
181 182
182 183
183 184
184/* XPM */ 185/* XPM */
185static const char * alarm_xpm[] = { 186static const char * alarm_xpm[] = {
186"20 20 33 1", 187"20 20 33 1",
187" c None", 188" c None",
188". c #080602", 189". c #080602",
189"+ c #AAA602", 190"+ c #AAA602",
190"@ c #252002", 191"@ c #252002",
191"# c #434202", 192"# c #434202",
192"$ c #795602", 193"$ c #795602",
193"% c #C3C20D", 194"% c #C3C20D",
194"& c #DADAC2", 195"& c #DADAC2",
195"* c #826002", 196"* c #826002",
196"= c #740502", 197"= c #740502",
197"- c #D6D602", 198"- c #D6D602",
198"; c #322E02", 199"; c #322E02",
199"> c #826A02", 200"> c #826A02",
200", c #F1F195", 201", c #F1F195",
201"' c #959215", 202"' c #959215",
202") c #423602", 203") c #423602",
203"! c #4B0302", 204"! c #4B0302",
204"~ c #844315", 205"~ c #844315",
205"{ c #AAAA2A", 206"{ c #AAAA2A",
206"] c #E2DE42", 207"] c #E2DE42",
207"^ c #BA7E04", 208"^ c #BA7E04",
208"/ c #7F7502", 209"/ c #7F7502",
209"( c #828276", 210"( c #828276",
210"_ c #FEFE4E", 211"_ c #FEFE4E",
211": c #7D1902", 212": c #7D1902",
212"< c #989656", 213"< c #989656",
213"[ c #260B02", 214"[ c #260B02",
214"} c #F7F7D8", 215"} c #F7F7D8",
215"| c #DCDA5A", 216"| c #DCDA5A",
216"1 c #823102", 217"1 c #823102",
217"2 c #B1AC6B", 218"2 c #B1AC6B",
218"3 c #F7F710", 219"3 c #F7F710",
219"4 c #838204", 220"4 c #838204",
220" ", 221" ",
221" ", 222" ",
222" 4'4/ ", 223" 4'4/ ",
223" /-^= ", 224" /-^= ",
224" 42{4>4 ", 225" 42{4>4 ",
225" '2|+*$44 ", 226" '2|+*$44 ",
226" +2&3+$1*44 ", 227" +2&3+$1*44 ",
227" (%_}_+/$:>/4 ", 228" (%_}_+/$:>/4 ",
228" 4%_}3+#;>:*4 ", 229" 4%_}3+#;>:*4 ",
229" 4%_}&+#[1$/4 ", 230" 4%_}&+#[1$/4 ",
230" 4%_,2')[~~>4 ", 231" 4%_,2')[~~>4 ",
231" 4%33'4#@~1>4 ", 232" 4%33'4#@~1>4 ",
232" 4%3344#[:>/4 ", 233" 4%3344#[:>/4 ",
233" 42&_3'4#@>:*44 ", 234" 42&_3'4#@>:*44 ",
234" 42|}}3'4#[;$)$44 ", 235" 42|}}3'4#[;$)$44 ",
235"444{]]2^~~:!!#.@##/ ", 236"444{]]2^~~:!!#.@##/ ",
236"4444-%*:==!!=...../ ", 237"4444-%*:==!!=...../ ",
237" /:[.. ", 238" /:[.. ",
238" /@. ", 239" /@. ",
239" "}; 240" "};
240 241
241VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 242VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
242 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 243 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
243{ 244{
244 m_icon = icon; 245 m_icon = icon;
245 246
246 bool has_wav_alarm = true; 247 bool has_wav_alarm = true;
247 bool has_bass = true; 248 bool has_bass = true;
248 bool has_treble = true; 249 bool has_treble = true;
249 250
250 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 251 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
251 case Model_Zaurus_SL5000: 252 case Model_Zaurus_SL5000:
252 has_wav_alarm = false; //poor guys probably feeling left out... 253 has_wav_alarm = false; //poor guys probably feeling left out...
253 break; 254 break;
254 default: 255 default:
255 break; 256 break;
256 } 257 }
257 258
258 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 259 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
259 has_bass = false; 260 has_bass = false;
260 has_treble = false; 261 has_treble = false;
261 } 262 }
262 263
263 264
264 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 265 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
265 266
266 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 267 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
267 grid-> setSpacing ( 4 ); 268 grid-> setSpacing ( 4 );
268 grid-> setMargin ( 6 ); 269 grid-> setMargin ( 6 );
269 270
270 QVBoxLayout *vbox; 271 QVBoxLayout *vbox;
271 QLabel *l; 272 QLabel *l;
272 273
273 vbox = new QVBoxLayout ( ); 274 vbox = new QVBoxLayout ( );
274 vbox-> setSpacing ( 4 ); 275 vbox-> setSpacing ( 4 );
275 grid-> addLayout ( vbox, 1, 0 ); 276 grid-> addLayout ( vbox, 1, 0 );
276 277
277 upButton = new QPushButton ( this ); 278 upButton = new QPushButton ( this );
278 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 279 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
279 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 280 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
280 upButton-> setFocusPolicy ( QWidget::NoFocus ); 281 upButton-> setFocusPolicy ( QWidget::NoFocus );
281 282
282 vbox-> addWidget ( upButton ); 283 vbox-> addWidget ( upButton );
283 284
284 downButton = new QPushButton ( this ); 285 downButton = new QPushButton ( this );
285 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 286 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
286 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 287 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
287 downButton-> setFocusPolicy ( QWidget::NoFocus ); 288 downButton-> setFocusPolicy ( QWidget::NoFocus );
288 289
289 vbox-> addWidget ( downButton ); 290 vbox-> addWidget ( downButton );
290 291
291 volSlider = new QSlider ( this ); 292 volSlider = new QSlider ( this );
292 volSlider-> setRange ( 0, 100 ); 293 volSlider-> setRange ( 0, 100 );
293 volSlider-> setTickmarks ( QSlider::Both ); 294 volSlider-> setTickmarks ( QSlider::Both );
294 volSlider-> setTickInterval ( 20 ); 295 volSlider-> setTickInterval ( 20 );
295 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 296 volSlider-> setFocusPolicy ( QWidget::NoFocus );
296 297
297 l = new QLabel ( this ); 298 l = new QLabel ( this );
298 l-> setPixmap ( QPixmap ( vol_xpm )); 299 l-> setPixmap ( QPixmap ( vol_xpm ));
299 300
300 grid-> addWidget ( l, 0, 1, AlignCenter ); 301 grid-> addWidget ( l, 0, 1, AlignCenter );
301 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 302 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
302 303
303 volLed = new OLedBox ( green, this ); 304 volLed = new OLedBox ( green, this );
304 volLed-> setFocusPolicy ( QWidget::NoFocus ); 305 volLed-> setFocusPolicy ( QWidget::NoFocus );
305 volLed-> setFixedSize ( 16, 16 ); 306 volLed-> setFixedSize ( 16, 16 );
306 307
307 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 308 grid-> addWidget ( volLed, 2, 1, AlignCenter );
308 309
309 QVBox *basstrebleBox = new QVBox( this ); 310 QVBox *basstrebleBox = new QVBox( this );
310 311
311 trebleSlider = new QSlider ( basstrebleBox ); 312 trebleSlider = new QSlider ( basstrebleBox );
312 trebleSlider-> setRange ( 0, 100 ); 313 trebleSlider-> setRange ( 0, 100 );
313 trebleSlider-> setTickmarks ( QSlider::Both ); 314 trebleSlider-> setTickmarks ( QSlider::Both );
314 trebleSlider-> setTickInterval ( 20 ); 315 trebleSlider-> setTickInterval ( 20 );
315 trebleSlider->setMaximumHeight( 40 ); 316 trebleSlider->setMaximumHeight( 40 );
316 trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); 317 trebleSlider-> setFocusPolicy ( QWidget::NoFocus );
317 318
318 bassSlider = new QSlider ( basstrebleBox ); 319 bassSlider = new QSlider ( basstrebleBox );
319 bassSlider-> setRange ( 0, 100 ); 320 bassSlider-> setRange ( 0, 100 );
320 bassSlider-> setTickmarks ( QSlider::Both ); 321 bassSlider-> setTickmarks ( QSlider::Both );
321 bassSlider-> setTickInterval ( 20 ); 322 bassSlider-> setTickInterval ( 20 );
322 bassSlider->setMaximumHeight( 40 ); 323 bassSlider->setMaximumHeight( 40 );
323 bassSlider-> setFocusPolicy ( QWidget::NoFocus ); 324 bassSlider-> setFocusPolicy ( QWidget::NoFocus );
324 325
325 QLabel *bassLabel = new QLabel ( this ); 326 QLabel *bassLabel = new QLabel ( this );
326 bassLabel-> setPixmap ( QPixmap ( bass_xpm )); 327 bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
327 328
328 QLabel *trebleLabel = new QLabel( this ); 329 QLabel *trebleLabel = new QLabel( this );
329 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 330 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
330 331
331 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 332 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
332 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 333 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
333 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 334 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
334 335
335 if ( !has_bass ) { 336 if ( !has_bass ) {
336 bassSlider->hide(); 337 bassSlider->hide();
337 bassLabel->hide(); 338 bassLabel->hide();
338 } 339 }
339 340
340 if ( !has_treble ) { 341 if ( !has_treble ) {
341 trebleSlider->hide(); 342 trebleSlider->hide();
342 trebleLabel->hide(); 343 trebleLabel->hide();
343 } 344 }
344 345
345 micSlider = new QSlider ( this ); 346 micSlider = new QSlider ( this );
346 micSlider-> setRange ( 0, 100 ); 347 micSlider-> setRange ( 0, 100 );
347 micSlider-> setTickmarks ( QSlider::Both ); 348 micSlider-> setTickmarks ( QSlider::Both );
348 micSlider-> setTickInterval ( 20 ); 349 micSlider-> setTickInterval ( 20 );
349 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 350 micSlider-> setFocusPolicy ( QWidget::NoFocus );
350 351
351 l = new QLabel ( this ); 352 l = new QLabel ( this );
352 l-> setPixmap ( QPixmap ( mic_xpm )); 353 l-> setPixmap ( QPixmap ( mic_xpm ));
353 354
354 grid-> addWidget ( l, 0, 2, AlignCenter ); 355 grid-> addWidget ( l, 0, 2, AlignCenter );
355 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 356 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
356 357
357 micLed = new OLedBox ( red, this ); 358 micLed = new OLedBox ( red, this );
358 micLed-> setFocusPolicy ( QWidget::NoFocus ); 359 micLed-> setFocusPolicy ( QWidget::NoFocus );
359 micLed-> setFixedSize ( 16, 16 ); 360 micLed-> setFixedSize ( 16, 16 );
360 361
361 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 362 grid-> addWidget ( micLed, 2, 2, AlignCenter );
362 363
363 alarmSlider = new QSlider ( this ); 364 alarmSlider = new QSlider ( this );
364 alarmSlider-> setRange ( 0, 100 ); 365 alarmSlider-> setRange ( 0, 100 );
365 alarmSlider-> setTickmarks ( QSlider::Both ); 366 alarmSlider-> setTickmarks ( QSlider::Both );
366 alarmSlider-> setTickInterval ( 20 ); 367 alarmSlider-> setTickInterval ( 20 );
367 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 368 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
368 369
369 QLabel *alarmLabel = new QLabel ( this ); 370 QLabel *alarmLabel = new QLabel ( this );
370 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 371 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
371 372
372 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 373 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
373 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 374 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
374 375
375 alarmLed = new OLedBox ( yellow, this ); 376 alarmLed = new OLedBox ( yellow, this );
376 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 377 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
377 alarmLed-> setFixedSize ( 16, 16 ); 378 alarmLed-> setFixedSize ( 16, 16 );
378 379
379 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 380 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
380 381
381 if ( !has_wav_alarm ) { 382 if ( !has_wav_alarm ) {
382 alarmSlider-> hide ( ); 383 alarmSlider-> hide ( );
383 alarmLabel-> hide ( ); 384 alarmLabel-> hide ( );
384 alarmLed-> hide ( ); 385 alarmLed-> hide ( );
385 } 386 }
386 387
387 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 388 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
388 389
389 vbox = new QVBoxLayout ( ); 390 vbox = new QVBoxLayout ( );
390 vbox-> setSpacing ( 4 ); 391 vbox-> setSpacing ( 4 );
391 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 392 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
392 393
393 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 394 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
394 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 395 tapBox-> setFocusPolicy ( QWidget::NoFocus );
395 396
396 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 397 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
397 398
398 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 399 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
399 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 400 keyBox-> setFocusPolicy ( QWidget::NoFocus );
400 401
401 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 402 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
402 403
403 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 404 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
404 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 405 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
405 406
406 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 407 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
407 408
408 if ( has_wav_alarm ) { 409 if ( has_wav_alarm ) {
409 alarmBox-> hide ( ); 410 alarmBox-> hide ( );
410 } 411 }
411 412
412 vbox-> addStretch ( 100 ); 413 vbox-> addStretch ( 100 );
413 414
414 setFixedSize ( sizeHint ( )); 415 setFixedSize ( sizeHint ( ));
415 setFocusPolicy ( QWidget::NoFocus ); 416 setFocusPolicy ( QWidget::NoFocus );
416 417
417 rateTimer = new QTimer( this ); 418 rateTimer = new QTimer( this );
418 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 419 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
419 420
420 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 421 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
421 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 422 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
422 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 423 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
423 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 424 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
424 425
425 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 426 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
426 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 427 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
427 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 428 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
428 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); 429 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int )));
429 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); 430 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int )));
430 431
431 432
432 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 433 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
433 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 434 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
434 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 435 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
435 436
436 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 437 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
437 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 438 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
438 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 439 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
439 440
440 // initialize variables 441 // initialize variables
441 442
442 readConfig ( true ); 443 readConfig ( true );
443 444
444 // initialize the config file, in case some entries are missing 445 // initialize the config file, in case some entries are missing
445 446
446 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 447 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
447 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 448 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
448 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 449 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
449 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 450 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
450 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 451 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
451 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 452 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
452 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 453 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
453 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 454 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
454 455
455 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 456 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
456 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 457 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
457} 458}
458 459
459bool VolumeControl::volMuted ( ) const 460bool VolumeControl::volMuted ( ) const
460{ 461{
461 return m_vol_muted; 462 return m_vol_muted;
462} 463}
463 464
464int VolumeControl::volPercent ( ) const 465int VolumeControl::volPercent ( ) const
465{ 466{
466 return m_vol_percent; 467 return m_vol_percent;
467} 468}
468 469
469void VolumeControl::keyPressEvent ( QKeyEvent *e ) 470void VolumeControl::keyPressEvent ( QKeyEvent *e )
470{ 471{
471 switch ( e-> key ( )) { 472 switch ( e-> key ( )) {
472 case Key_Up: 473 case Key_Up:
473 volSlider-> subtractStep ( ); 474 volSlider-> subtractStep ( );
474 break; 475 break;
475 case Key_Down: 476 case Key_Down:
476 volSlider-> addStep ( ); 477 volSlider-> addStep ( );
477 break; 478 break;
478 case Key_Space: 479 case Key_Space:
479 volLed-> toggle ( ); 480 volLed-> toggle ( );
480 break; 481 break;
481 case Key_Escape: 482 case Key_Escape:
482 hide ( ); 483 hide ( );
483 break; 484 break;
484 } 485 }
485} 486}
486 487
487void VolumeControl::buttonChanged ( ) 488void VolumeControl::buttonChanged ( )
488{ 489{
489 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 490 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
490 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 491 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
491 // called at all when a button is pressed for a time 492 // called at all when a button is pressed for a time
492 // shorter than RATE_TIMER_INTERVAL. 493 // shorter than RATE_TIMER_INTERVAL.
493 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 494 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
494 } 495 }
495 else 496 else
496 rateTimer-> stop ( ); 497 rateTimer-> stop ( );
497} 498}
498 499
499void VolumeControl::rateTimerDone ( ) 500void VolumeControl::rateTimerDone ( )
500{ 501{
501 if ( upButton-> isDown ( )) 502 if ( upButton-> isDown ( ))
502 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 503 volSlider-> setValue ( volSlider-> value ( ) - 2 );
503 else // if ( downButton-> isDown ( )) 504 else // if ( downButton-> isDown ( ))
504 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 505 volSlider-> setValue ( volSlider-> value ( ) + 2 );
505} 506}
506 507
507void VolumeControl::show ( bool /*showMic*/ ) 508void VolumeControl::show ( bool /*showMic*/ )
508{ 509{
509 readConfig ( ); 510 readConfig ( );
510 511
511 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 512 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
512 513
513 int w = sizeHint ( ). width ( ); 514 int w = sizeHint ( ). width ( );
514 int x = curPos.x ( ) - ( w / 2 ); 515 int x = curPos.x ( ) - ( w / 2 );
515 516
516 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 517 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
517 x = QPEApplication::desktop ( )-> width ( ) - w; 518 x = QPEApplication::desktop ( )-> width ( ) - w;
518 519
519 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 520 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
520 QFrame::show ( ); 521 QFrame::show ( );
521 522
522} 523}
523 524
524void VolumeControl::readConfig ( bool force ) 525void VolumeControl::readConfig ( bool force )
525{ 526{
526 Config cfg ( "qpe" ); 527 Config cfg ( "qpe" );
527 cfg. setGroup ( "Volume" ); 528 cfg. setGroup ( "Volume" );
528 529
529 int old_vp = m_vol_percent; 530 int old_vp = m_vol_percent;
530 int old_mp = m_mic_percent; 531 int old_mp = m_mic_percent;
531 int old_bass = m_bass_percent; 532 int old_bass = m_bass_percent;
532 int old_treble = m_treble_percent; 533 int old_treble = m_treble_percent;
533 bool old_vm = m_vol_muted; 534 bool old_vm = m_vol_muted;
534 bool old_mm = m_mic_muted; 535 bool old_mm = m_mic_muted;
535 bool old_sk = m_snd_key; 536 bool old_sk = m_snd_key;
536 bool old_st = m_snd_touch; 537 bool old_st = m_snd_touch;
537 bool old_sa = m_snd_alarm; 538 bool old_sa = m_snd_alarm;
538 int old_ap = m_alarm_percent; 539 int old_ap = m_alarm_percent;
539 540
540 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 541 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
541 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 542 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
542 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 543 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
543 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 544 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
544 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 545 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
545 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 546 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
546 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 547 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
547 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 548 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
548 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 549 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
549 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 550 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
550 551
551 if ( force || ( m_vol_percent != old_vp )) 552 if ( force || ( m_vol_percent != old_vp ))
552 volSlider-> setValue ( 100 - m_vol_percent ); 553 volSlider-> setValue ( 100 - m_vol_percent );
553 if ( force || ( m_mic_percent != old_mp )) 554 if ( force || ( m_mic_percent != old_mp ))
554 micSlider-> setValue ( 100 - m_mic_percent ); 555 micSlider-> setValue ( 100 - m_mic_percent );
555 if ( force || ( m_alarm_percent != old_ap )) 556 if ( force || ( m_alarm_percent != old_ap ))
556 alarmSlider-> setValue ( 100 - m_alarm_percent ); 557 alarmSlider-> setValue ( 100 - m_alarm_percent );
557 if ( force || ( m_bass_percent != old_bass )) 558 if ( force || ( m_bass_percent != old_bass ))
558 bassSlider-> setValue ( 100 - m_bass_percent ); 559 bassSlider-> setValue ( 100 - m_bass_percent );
559 if ( force || ( m_treble_percent != old_treble )) 560 if ( force || ( m_treble_percent != old_treble ))
560 trebleSlider-> setValue ( 100 - m_treble_percent ); 561 trebleSlider-> setValue ( 100 - m_treble_percent );
561 562
562 563
563 if ( force || ( m_vol_muted != old_vm )) 564 if ( force || ( m_vol_muted != old_vm ))
564 volLed-> setOn ( !m_vol_muted ); 565 volLed-> setOn ( !m_vol_muted );
565 if ( force || ( m_mic_muted != old_mm )) 566 if ( force || ( m_mic_muted != old_mm ))
566 micLed-> setOn ( !m_mic_muted ); 567 micLed-> setOn ( !m_mic_muted );
567 if ( force || ( m_snd_alarm != old_sa )) 568 if ( force || ( m_snd_alarm != old_sa ))
568 alarmLed-> setOn ( m_snd_alarm ); 569 alarmLed-> setOn ( m_snd_alarm );
569 570
570 if ( force || ( m_snd_key != old_sk )) 571 if ( force || ( m_snd_key != old_sk ))
571 keyBox-> setChecked ( m_snd_key ); 572 keyBox-> setChecked ( m_snd_key );
572 if ( force || ( m_snd_touch != old_st )) 573 if ( force || ( m_snd_touch != old_st ))
573 tapBox-> setChecked ( m_snd_touch ); 574 tapBox-> setChecked ( m_snd_touch );
574 if ( force || ( m_snd_alarm != old_sa )) 575 if ( force || ( m_snd_alarm != old_sa ))
575 alarmBox-> setChecked ( m_snd_alarm ); 576 alarmBox-> setChecked ( m_snd_alarm );
576} 577}
577 578
578 579
579void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 580void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
580{ 581{
581 int prevVol = m_vol_percent; 582 int prevVol = m_vol_percent;
582 bool prevMute = m_vol_muted; 583 bool prevMute = m_vol_muted;
583 584
584 readConfig ( ); 585 readConfig ( );
585 586
586 // Handle case where muting it toggled 587 // Handle case where muting it toggled
587 if ( m_vol_muted != prevMute ) 588 if ( m_vol_muted != prevMute )
588 m_icon-> redraw ( true ); 589 m_icon-> redraw ( true );
589 else if ( prevVol != m_vol_percent ) // Avoid over repainting 590 else if ( prevVol != m_vol_percent ) // Avoid over repainting
590 m_icon-> redraw ( false ); 591 m_icon-> redraw ( false );
591} 592}
592 593
593void VolumeControl::micChanged ( bool nowMuted ) 594void VolumeControl::micChanged ( bool nowMuted )
594{ 595{
595 if ( !nowMuted ) 596 if ( !nowMuted )
596 readConfig ( ); 597 readConfig ( );
597 m_mic_muted = nowMuted; 598 m_mic_muted = nowMuted;
598} 599}
599 600
600void VolumeControl::screenTapToggled ( bool b ) 601void 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
606void VolumeControl::keyClickToggled ( bool b ) 607void 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
612void VolumeControl::alarmSoundToggled ( bool b ) 613void 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
618void VolumeControl::volMuteToggled ( bool b ) 619void 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
627void VolumeControl::micMuteToggled ( bool b ) 628void 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
634void VolumeControl::volMoved ( int percent ) 635void 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
646void VolumeControl::micMoved ( int percent ) 647void 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
656void VolumeControl::alarmMoved ( int percent ) 657void 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
667void VolumeControl::bassMoved ( int percent ) 668void 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
679void VolumeControl::trebleMoved ( int percent ) 680void 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
691void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 692void 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
725VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 726VolumeApplet::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
738VolumeApplet::~VolumeApplet() 739VolumeApplet::~VolumeApplet()
739{ 740{
740 delete m_pixmap; 741 delete m_pixmap;
741} 742}
742 743
743 744
744void VolumeApplet::mousePressEvent ( QMouseEvent * ) 745void 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
752void VolumeApplet::redraw ( bool all ) 753void 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
761void VolumeApplet::paintEvent ( QPaintEvent * ) 762void 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