summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/battery.cpp10
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp14
-rw-r--r--core/applets/irdaapplet/irda.cpp2
-rw-r--r--core/applets/irdaapplet/irdaappletimpl.h2
-rw-r--r--core/applets/rotateapplet/rotate.h2
-rw-r--r--core/applets/volumeapplet/volume.cpp2
6 files changed, 23 insertions, 9 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp
index 078ce8d..15eb762 100644
--- a/core/applets/batteryapplet/battery.cpp
+++ b/core/applets/batteryapplet/battery.cpp
@@ -1,166 +1,170 @@
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/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/power.h> 25#include <qpe/power.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27 27
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qtimer.h> 29#include <qtimer.h>
30 30
31 31
32BatteryMeter::BatteryMeter( QWidget *parent ) 32BatteryMeter::BatteryMeter( QWidget *parent )
33 : QWidget( parent ), charging(false) 33 : QWidget( parent ), charging(false)
34{ 34{
35 ps = new PowerStatus; 35 ps = new PowerStatus;
36 startTimer( 10000 ); 36 startTimer( 10000 );
37
38 setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) );
37 setFixedHeight( AppLnk::smallIconSize() ); 39 setFixedHeight( AppLnk::smallIconSize() );
40
38 chargeTimer = new QTimer( this ); 41 chargeTimer = new QTimer( this );
39 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); 42 connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) );
40 timerEvent(0); 43 timerEvent(0);
41 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 44 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
42 Config c( "qpe" ); 45 Config c( "qpe" );
43 c.setGroup( "Battery" ); 46 c.setGroup( "Battery" );
44 style = c.readNumEntry( "Style", 0 ); 47 style = c.readNumEntry( "Style", 0 );
45} 48}
46 49
47BatteryMeter::~BatteryMeter() 50BatteryMeter::~BatteryMeter()
48{ 51{
49 delete ps; 52 delete ps;
50} 53}
51 54
52QSize BatteryMeter::sizeHint() const 55QSize BatteryMeter::sizeHint() const
53{ 56{
54 return QSize(10, height() ); 57 return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() );
55} 58}
56 59
57void BatteryMeter::mousePressEvent( QMouseEvent* e ) 60void BatteryMeter::mousePressEvent( QMouseEvent* e )
58{ 61{
59 if ( e->button() == RightButton ) 62 if ( e->button() == RightButton )
60 { 63 {
61 style = 1-style; 64 style = 1-style;
62 Config c( "qpe" ); 65 Config c( "qpe" );
63 c.setGroup( "Battery" ); 66 c.setGroup( "Battery" );
64 c.writeEntry( "Style", style ); 67 c.writeEntry( "Style", style );
65 repaint( true ); 68 repaint( true );
66 } 69 }
67 QWidget::mousePressEvent( e ); 70 QWidget::mousePressEvent( e );
68} 71}
69 72
70void BatteryMeter::mouseReleaseEvent( QMouseEvent* e) 73void BatteryMeter::mouseReleaseEvent( QMouseEvent* e)
71{ 74{
72 if ( batteryView && batteryView->isVisible() ) { 75 if ( batteryView && batteryView->isVisible() ) {
73 delete (QWidget *) batteryView; 76 delete (QWidget *) batteryView;
74 } else { 77 } else {
75 if ( !batteryView ) batteryView = new BatteryStatus( ps ); 78 if ( !batteryView ) batteryView = new BatteryStatus( ps );
76 batteryView->showMaximized(); 79 batteryView->showMaximized();
77 batteryView->raise(); 80 batteryView->raise();
78 batteryView->show(); 81 batteryView->show();
79 } 82 }
80} 83}
81 84
82void BatteryMeter::timerEvent( QTimerEvent * ) 85void BatteryMeter::timerEvent( QTimerEvent * )
83{ 86{
84 PowerStatus prev = *ps; 87 PowerStatus prev = *ps;
85 88
86 *ps = PowerStatusManager::readStatus(); 89 *ps = PowerStatusManager::readStatus();
87 90
88 if ( prev != *ps ) { 91 if ( prev != *ps ) {
89 percent = ps->batteryPercentRemaining(); 92 percent = ps->batteryPercentRemaining();
90 if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) { 93 if ( !charging && ps->batteryStatus() == PowerStatus::Charging && percent < 0 ) {
91 percent = 0; 94 percent = 0;
92 charging = true; 95 charging = true;
93 chargeTimer->start( 500 ); 96 chargeTimer->start( 500 );
94 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { 97 } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) {
95 charging = false; 98 charging = false;
96 chargeTimer->stop(); 99 chargeTimer->stop();
97 if ( batteryView ) 100 if ( batteryView )
98 batteryView->updatePercent( percent ); 101 batteryView->updatePercent( percent );
99 } 102 }
100 repaint( style != 0 ); 103 repaint( style != 0 );
101 if ( batteryView ) 104 if ( batteryView )
102 batteryView->repaint(); 105 batteryView->repaint();
103 } 106 }
104} 107}
105 108
106void BatteryMeter::chargeTimeout() 109void BatteryMeter::chargeTimeout()
107{ 110{
108 percent += 20; 111 percent += 20;
109 if ( percent > 100 ) 112 if ( percent > 100 )
110 percent = 0; 113 percent = 0;
111 114
112 repaint(FALSE); 115 repaint(FALSE);
113 if ( batteryView ) 116 if ( batteryView )
114 batteryView->updatePercent( percent ); 117 batteryView->updatePercent( percent );
115} 118}
116 119
117void BatteryMeter::paintEvent( QPaintEvent* ) 120void BatteryMeter::paintEvent( QPaintEvent* )
118{ 121{
122 qWarning("paint");
119 if ( style == 1 ) 123 if ( style == 1 )
120 { 124 {
121 QPainter p(this); 125 QPainter p(this);
122 QFont f( "Fixed", AppLnk::smallIconSize()/2 ); 126 QFont f( "Fixed", AppLnk::smallIconSize()/2 );
123 QFontMetrics fm( f ); 127 QFontMetrics fm( f );
124 p.setFont( f ); 128 p.setFont( f );
125 p.drawText( 0, AppLnk::smallIconSize()/2, QString::number( percent ) ); 129 p.drawText( 0, height()/2, QString::number( percent ) );
126 p.drawText( AppLnk::smallIconSize()/4, AppLnk::smallIconSize(), "%" ); 130 p.drawText( width()/4, height(), "%" );
127 return; 131 return;
128 } 132 }
129 133
130 QPainter p(this); 134 QPainter p(this);
131 QColor color; 135 QColor color;
132 QColor g = gray.light( 160 ); 136 QColor g = gray.light( 160 );
133 switch ( ps->acStatus() ) 137 switch ( ps->acStatus() )
134 { 138 {
135 case PowerStatus::Offline: color = blue.light( 150 ); break; 139 case PowerStatus::Offline: color = blue.light( 150 ); break;
136 case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; 140 case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break;
137 default: color = red.light( 160 ); 141 default: color = red.light( 160 );
138 } 142 }
139 143
140 int w = height() / 2; 144 int w = height() / 2;
141 if ( !(w%2) ) w--; // should have an odd value to get a real middle line 145 if ( !(w%2) ) w--; // should have an odd value to get a real middle line
142 int h = height() - 4; 146 int h = height() - 4;
143 int pix = (percent * h) / 100; 147 int pix = (percent * h) / 100;
144 int y2 = height() -2; 148 int y2 = height() -2;
145 int y = y2 - pix; 149 int y = y2 - pix;
146 int x1 = (width() - w ) / 2; 150 int x1 = (width() - w ) / 2;
147 151
148 p.setPen(QColor(80,80,80)); 152 p.setPen(QColor(80,80,80));
149 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header 153 p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header
150 p.drawRect(x1,1,w,height()-1); // corpus 154 p.drawRect(x1,1,w,height()-1); // corpus
151 p.setBrush(color); 155 p.setBrush(color);
152 156
153 int extra = ((percent * h) % 100)/(100/4); 157 int extra = ((percent * h) % 100)/(100/4);
154 158
155 int middle = w/2; 159 int middle = w/2;
156 for ( int i = 0; i < middle; i++ ) 160 for ( int i = 0; i < middle; i++ )
157 { 161 {
158 p.setPen( gray.dark( 100+i*20 ) ); 162 p.setPen( gray.dark( 100+i*20 ) );
159 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); 163 p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 );
160 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); 164 p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 );
161 p.setPen( color.dark( 100+i*20 ) ); 165 p.setPen( color.dark( 100+i*20 ) );
162 p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); 166 p.drawLine( x1+middle-i, y, x1+middle-i, y2 );
163 p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); 167 p.drawLine( x1+middle+i, y, x1+middle+i, y2 );
164 } 168 }
165} 169}
166 170
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 21b68e3..bb0db9b 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,172 +1,178 @@
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#include <qpe/applnk.h>
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qpopupmenu.h> 27#include <qpopupmenu.h>
28#include <qwindowsystem_qws.h> 28#include <qwindowsystem_qws.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#include <qclipboard.h> 30#include <qclipboard.h>
31#include <qtimer.h> 31#include <qtimer.h>
32 32
33//=========================================================================== 33//===========================================================================
34 34
35 35
36ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 36ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
37{ 37{
38 setFixedWidth ( AppLnk::smallIconSize() ); 38 setFixedWidth ( AppLnk::smallIconSize() );
39 setFixedHeight ( AppLnk::smallIconSize() ); 39 setFixedHeight ( AppLnk::smallIconSize() );
40 m_clipboardPixmap = QPixmap ( Resource::loadPixmap( "paste" ) ); 40
41 QImage img = Resource::loadImage( "paste");
42 img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
43
44 m_clipboardPixmap.convertFromImage( img );
41 45
42 m_timer = new QTimer ( this ); 46 m_timer = new QTimer ( this );
43 47
44 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); 48 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
45 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); 49 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
46 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( ))); 50 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
47 51
48 m_menu = 0; 52 m_menu = 0;
49 m_dirty = true; 53 m_dirty = true;
50 m_lasttext = QString::null; 54 m_lasttext = QString::null;
51 55
52 m_timer-> start ( 0, true ); 56 m_timer-> start ( 0, true );
53} 57}
54 58
55ClipboardApplet::~ClipboardApplet ( ) 59ClipboardApplet::~ClipboardApplet ( )
56{ 60{
57} 61}
58 62
59void ClipboardApplet::shutdown ( ) 63void ClipboardApplet::shutdown ( )
60{ 64{
61 // the timer has to be stopped, or Qt/E will hang on quit() 65 // the timer has to be stopped, or Qt/E will hang on quit()
62 // see launcher/desktop.cpp 66 // see launcher/desktop.cpp
63 67
64 m_timer-> stop ( ); 68 m_timer-> stop ( );
65} 69}
66 70
67void ClipboardApplet::mousePressEvent ( QMouseEvent *) 71void ClipboardApplet::mousePressEvent ( QMouseEvent *)
68{ 72{
69 if ( m_dirty ) { 73 if ( m_dirty ) {
70 delete m_menu; 74 delete m_menu;
71 75
72 m_menu = new QPopupMenu ( this ); 76 m_menu = new QPopupMenu ( this );
73 m_menu-> setCheckable ( true ); 77 m_menu-> setCheckable ( true );
74 78
75 if ( m_history. count ( )) { 79 if ( m_history. count ( )) {
76 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 80 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
77 QString str = m_history [i]; 81 QString str = m_history [i];
78 82
79 if ( str. length ( ) > 20 ) 83 if ( str. length ( ) > 20 )
80 str = str. left ( 20 ) + "..."; 84 str = str. left ( 20 ) + "...";
81 85
82 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 86 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
83 m_menu-> setItemChecked ( i, false ); 87 m_menu-> setItemChecked ( i, false );
84 } 88 }
85 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 89 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
86 m_menu-> insertSeparator ( ); 90 m_menu-> insertSeparator ( );
87 } 91 }
88 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 92 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
89 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 93 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
90 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 94 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
91 95
92 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); 96 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
93 97
94 m_dirty = false; 98 m_dirty = false;
95 } 99 }
96 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 100 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
97 QSize s = m_menu-> sizeHint ( ); 101 QSize s = m_menu-> sizeHint ( );
98 102
99 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 103 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
100} 104}
101 105
102void ClipboardApplet::action(int id) 106void ClipboardApplet::action(int id)
103{ 107{
104 ushort unicode = 0; 108 ushort unicode = 0;
105 int scan = 0; 109 int scan = 0;
106 110
107 switch ( id ) { 111 switch ( id ) {
108 case 100: 112 case 100:
109 unicode = 'X' - '@'; 113 unicode = 'X' - '@';
110 scan = Key_X; // Cut 114 scan = Key_X; // Cut
111 break; 115 break;
112 case 101: 116 case 101:
113 unicode = 'C' - '@'; 117 unicode = 'C' - '@';
114 scan = Key_C; // Copy 118 scan = Key_C; // Copy
115 break; 119 break;
116 case 102: 120 case 102:
117 unicode = 'V' - '@'; 121 unicode = 'V' - '@';
118 scan = Key_V; // Paste 122 scan = Key_V; // Paste
119 break; 123 break;
120 124
121 default: 125 default:
122 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { 126 if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) {
123 QApplication::clipboard ( )-> setText ( m_history [id] ); 127 QApplication::clipboard ( )-> setText ( m_history [id] );
124 128
125 for ( uint i = 0; i < m_history. count ( ); i++ ) 129 for ( uint i = 0; i < m_history. count ( ); i++ )
126 m_menu-> setItemChecked ( i, i == uint( id )); 130 m_menu-> setItemChecked ( i, i == uint( id ));
127 131
128 unicode = 'V' - '@'; 132 unicode = 'V' - '@';
129 scan = Key_V; 133 scan = Key_V;
130 } 134 }
131 break; 135 break;
132 } 136 }
133 137
134 if ( scan ) { 138 if ( scan ) {
135 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); 139 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false );
136 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); 140 qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false );
137 } 141 }
138} 142}
139 143
140void ClipboardApplet::paintEvent ( QPaintEvent* ) 144void ClipboardApplet::paintEvent ( QPaintEvent* )
141{ 145{
142 QPainter p ( this ); 146 QPainter p ( this );
143 p. drawPixmap( 0, 1, m_clipboardPixmap ); 147 /* center the height but our pixmap is as big as the height ;)*/
148 p. drawPixmap( 0, 0,
149 m_clipboardPixmap );
144} 150}
145 151
146void ClipboardApplet::newData ( ) 152void ClipboardApplet::newData ( )
147{ 153{
148 static bool excllock = false; 154 static bool excllock = false;
149 155
150 if ( excllock ) 156 if ( excllock )
151 return; 157 return;
152 else 158 else
153 excllock = true; 159 excllock = true;
154 160
155 m_timer-> stop ( ); 161 m_timer-> stop ( );
156 162
157 QCString type = "plain"; 163 QCString type = "plain";
158 QString txt = QApplication::clipboard ( )-> text ( type ); 164 QString txt = QApplication::clipboard ( )-> text ( type );
159 165
160 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { 166 if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) {
161 m_history. append ( txt ); 167 m_history. append ( txt );
162 168
163 if ( m_history. count ( ) > 5 ) 169 if ( m_history. count ( ) > 5 )
164 m_history. remove ( m_history. begin ( )); 170 m_history. remove ( m_history. begin ( ));
165 171
166 m_dirty = true; 172 m_dirty = true;
167 } 173 }
168 174
169 m_timer-> start ( 1500, true ); 175 m_timer-> start ( 1500, true );
170 176
171 excllock = false; 177 excllock = false;
172} 178}
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index 51c2ebf..f850424 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -1,357 +1,357 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org> 2** Copyright (C) 2002 David Woodhouse <dwmw2@infradead.org>
3** Max Reiss <harlekin@handhelds.org> [trivial stuff] 3** Max Reiss <harlekin@handhelds.org> [trivial stuff]
4** Robert Griebl <sandman@handhelds.org> 4** Robert Griebl <sandman@handhelds.org>
5** Holger Freyther <zecke@handhelds.org> QCOP Interface 5** Holger Freyther <zecke@handhelds.org> QCOP Interface
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15**********************************************************************/ 15**********************************************************************/
16 16
17#include <qcopchannel_qws.h> 17#include <qcopchannel_qws.h>
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/ir.h> 21#include <qpe/ir.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/sound.h> 23#include <qpe/sound.h>
24 24
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30 30
31#include <unistd.h> 31#include <unistd.h>
32#include <net/if.h> 32#include <net/if.h>
33#include <netinet/in.h> 33#include <netinet/in.h>
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/socket.h> 35#include <sys/socket.h>
36#include <sys/ioctl.h> 36#include <sys/ioctl.h>
37 37
38#include "irda.h" 38#include "irda.h"
39 39
40//=========================================================================== 40//===========================================================================
41 41
42IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) 42IrdaApplet::IrdaApplet ( QWidget *parent, const char *name )
43 : QWidget ( parent, name ) 43 : QWidget ( parent, name )
44{ 44{
45 setFixedHeight ( 18 ); 45 setFixedHeight ( 18 );
46 setFixedWidth ( 14 ); 46 setFixedWidth ( 14 );
47 47
48 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); 48 m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP );
49 49
50 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); 50 m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" );
51 m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); 51 m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" );
52 m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); 52 m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" );
53 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); 53 m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" );
54 54
55 m_irda_active = false; 55 m_irda_active = false;
56 m_irda_discovery_active = false; 56 m_irda_discovery_active = false;
57 m_receive_active = false; 57 m_receive_active = false;
58 m_receive_state_changed = false; 58 m_receive_state_changed = false;
59 m_popup = 0; 59 m_popup = 0;
60 m_wasOn = false; 60 m_wasOn = false;
61 m_wasDiscover = false; 61 m_wasDiscover = false;
62 62
63 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); 63 QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this );
64 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), 64 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
65 this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) ); 65 this, SLOT(slotMessage(const QCString&, const QByteArray& ) ) );
66} 66}
67 67
68void IrdaApplet::show() 68void IrdaApplet::show()
69{ 69{
70 QWidget::show ( ); 70 QWidget::show ( );
71 startTimer ( 2000 ); 71 startTimer ( 2000 );
72} 72}
73 73
74IrdaApplet::~IrdaApplet() 74IrdaApplet::~IrdaApplet()
75{ 75{
76 if ( m_sockfd >= 0 ) 76 if ( m_sockfd >= 0 )
77 ::close ( m_sockfd ); 77 ::close ( m_sockfd );
78} 78}
79 79
80void IrdaApplet::popup ( QString message, QString icon ) 80void IrdaApplet::popup ( QString message, QString icon )
81{ 81{
82 if ( !m_popup ) 82 if ( !m_popup )
83 m_popup = new QPopupMenu ( this ); 83 m_popup = new QPopupMenu ( this );
84 84
85 m_popup-> clear ( ); 85 m_popup-> clear ( );
86 86
87 if ( icon. isEmpty ( )) 87 if ( icon. isEmpty ( ))
88 m_popup-> insertItem ( message, 0 ); 88 m_popup-> insertItem ( message, 0 );
89 else 89 else
90 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); 90 m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 );
91 91
92 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 92 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
93 QSize s = m_popup-> sizeHint ( ); 93 QSize s = m_popup-> sizeHint ( );
94 m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), 94 m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ),
95 p. y ( ) - s. height ( ))); 95 p. y ( ) - s. height ( )));
96 96
97 QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( ))); 97 QTimer::singleShot ( 2000, this, SLOT( popupTimeout ( )));
98} 98}
99 99
100void IrdaApplet::popupTimeout ( ) 100void IrdaApplet::popupTimeout ( )
101{ 101{
102 m_popup-> hide ( ); 102 m_popup-> hide ( );
103} 103}
104 104
105bool IrdaApplet::checkIrdaStatus ( ) 105bool IrdaApplet::checkIrdaStatus ( )
106{ 106{
107 struct ifreq ifr; 107 struct ifreq ifr;
108 strcpy ( ifr. ifr_name, "irda0" ); 108 strcpy ( ifr. ifr_name, "irda0" );
109 109
110 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 110 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
111 return false; 111 return false;
112 112
113 return ( ifr. ifr_flags & IFF_UP ); 113 return ( ifr. ifr_flags & IFF_UP );
114} 114}
115 115
116bool IrdaApplet::setIrdaStatus ( bool b ) 116bool IrdaApplet::setIrdaStatus ( bool b )
117{ 117{
118 struct ifreq ifr; 118 struct ifreq ifr;
119 strcpy ( ifr. ifr_name, "irda0" ); 119 strcpy ( ifr. ifr_name, "irda0" );
120 120
121 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) 121 if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 )
122 return false; 122 return false;
123 123
124 if ( b ) { 124 if ( b ) {
125 ifr. ifr_flags |= IFF_UP; 125 ifr. ifr_flags |= IFF_UP;
126 } 126 }
127 else { 127 else {
128 setIrdaDiscoveryStatus ( 0 ); 128 setIrdaDiscoveryStatus ( 0 );
129 setIrdaReceiveStatus ( 0 ); 129 setIrdaReceiveStatus ( 0 );
130 ifr. ifr_flags &= ~IFF_UP; 130 ifr. ifr_flags &= ~IFF_UP;
131 } 131 }
132 132
133 if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) 133 if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 )
134 return false; 134 return false;
135 135
136 return true; 136 return true;
137} 137}
138 138
139bool IrdaApplet::checkIrdaDiscoveryStatus ( ) 139bool IrdaApplet::checkIrdaDiscoveryStatus ( )
140{ 140{
141 QFile discovery ( "/proc/sys/net/irda/discovery" ); 141 QFile discovery ( "/proc/sys/net/irda/discovery" );
142 142
143 QString streamIn = "0"; 143 QString streamIn = "0";
144 144
145 if ( discovery. open ( IO_ReadOnly )) { 145 if ( discovery. open ( IO_ReadOnly )) {
146 QTextStream stream ( &discovery ); 146 QTextStream stream ( &discovery );
147 streamIn = stream. read ( ); 147 streamIn = stream. read ( );
148 } 148 }
149 149
150 return streamIn. toInt ( ) > 0; 150 return streamIn. toInt ( ) > 0;
151} 151}
152 152
153 153
154bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) 154bool IrdaApplet::setIrdaDiscoveryStatus ( bool d )
155{ 155{
156 QFile discovery ( "/proc/sys/net/irda/discovery" ); 156 QFile discovery ( "/proc/sys/net/irda/discovery" );
157 157
158 if ( discovery. open ( IO_WriteOnly | IO_Raw )) { 158 if ( discovery. open ( IO_WriteOnly | IO_Raw )) {
159 discovery.putch ( d ? '1' : '0' ); 159 discovery.putch ( d ? '1' : '0' );
160 return true; 160 return true;
161 } 161 }
162 return false; 162 return false;
163} 163}
164 164
165 165
166bool IrdaApplet::setIrdaReceiveStatus ( bool d ) 166bool IrdaApplet::setIrdaReceiveStatus ( bool d )
167{ 167{
168 QCopEnvelope e ( "QPE/Obex", "receive(int)" ); 168 QCopEnvelope e ( "QPE/Obex", "receive(int)" );
169 e << ( d ? 1 : 0 ); 169 e << ( d ? 1 : 0 );
170 170
171 m_receive_active = d; 171 m_receive_active = d;
172 m_receive_state_changed = true; 172 m_receive_state_changed = true;
173 173
174 return true; 174 return true;
175} 175}
176 176
177 177
178void IrdaApplet::showDiscovered ( ) 178void IrdaApplet::showDiscovered ( )
179{ 179{
180 //static Sound snd_found ( "irdaapplet/irdaon" ); 180 //static Sound snd_found ( "irdaapplet/irdaon" );
181 //static Sound snd_lost ( "irdaapplet/irdaoff" ); 181 //static Sound snd_lost ( "irdaapplet/irdaoff" );
182 182
183 QFile discovery ( "/proc/net/irda/discovery" ); 183 QFile discovery ( "/proc/net/irda/discovery" );
184 184
185 if ( discovery. open ( IO_ReadOnly )) { 185 if ( discovery. open ( IO_ReadOnly )) {
186 bool qcopsend = false; 186 bool qcopsend = false;
187 187
188 QString discoveredDevice; 188 QString discoveredDevice;
189 QString deviceAddr; 189 QString deviceAddr;
190 190
191 // since it is /proc we _must_ use QTextStream 191 // since it is /proc we _must_ use QTextStream
192 QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); 192 QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( ));
193 193
194 QMap <QString, QString>::Iterator it; 194 QMap <QString, QString>::Iterator it;
195 195
196 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) 196 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it )
197 it. data ( ). prepend ( "+++" ); 197 it. data ( ). prepend ( "+++" );
198 198
199 for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { 199 for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) {
200 const QString &line = *lit; 200 const QString &line = *lit;
201 201
202 if ( line. startsWith ( "nickname:" )) { 202 if ( line. startsWith ( "nickname:" )) {
203 discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); 203 discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 );
204 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); 204 deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 );
205 205
206 // qDebug(discoveredDevice + "(" + deviceAddr + ")"); 206 // qDebug(discoveredDevice + "(" + deviceAddr + ")");
207 207
208 if ( !m_devices. contains ( deviceAddr )) { 208 if ( !m_devices. contains ( deviceAddr )) {
209 popup ( tr( "Found:" ) + " " + discoveredDevice ); 209 popup ( tr( "Found:" ) + " " + discoveredDevice );
210 //snd_found. play ( ); 210 //snd_found. play ( );
211 qcopsend = true; 211 qcopsend = true;
212 } 212 }
213 m_devices. replace ( deviceAddr, discoveredDevice ); 213 m_devices. replace ( deviceAddr, discoveredDevice );
214 } 214 }
215 } 215 }
216 216
217 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { 217 for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) {
218 // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); 218 // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?");
219 219
220 if ( it. data ( ). left ( 3 ) == "+++" ) { 220 if ( it. data ( ). left ( 3 ) == "+++" ) {
221 popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); 221 popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 ));
222 //snd_lost. play ( ); 222 //snd_lost. play ( );
223 223
224 QMap <QString, QString>::Iterator tmp = it; 224 QMap <QString, QString>::Iterator tmp = it;
225 tmp++; 225 tmp++;
226 m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator 226 m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator
227 it = tmp; 227 it = tmp;
228 228
229 qcopsend = true; 229 qcopsend = true;
230 } 230 }
231 else 231 else
232 it++; 232 it++;
233 } 233 }
234 // XXX if( qcopsend ) { 234 // XXX if( qcopsend ) {
235 QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); 235 QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" );
236 e << ( m_devices. count ( ) > 0 ); 236 e << ( m_devices. count ( ) > 0 );
237 // } 237 // }
238 } 238 }
239} 239}
240 240
241void IrdaApplet::mousePressEvent ( QMouseEvent * ) 241void IrdaApplet::mousePressEvent ( QMouseEvent * )
242{ 242{
243 QPopupMenu *menu = new QPopupMenu ( this ); 243 QPopupMenu *menu = new QPopupMenu ( this );
244 QString cmd; 244 QString cmd;
245 245
246 /* Refresh active state */ 246 /* Refresh active state */
247 timerEvent ( 0 ); 247 timerEvent ( 0 );
248 248
249 //menu->insertItem( tr("More..."), 4 ); 249 //menu->insertItem( tr("More..."), 4 );
250 250
251 if ( m_irda_active && !m_devices. isEmpty ( )) { 251 if ( m_irda_active && !m_devices. isEmpty ( )) {
252 menu-> insertItem ( tr( "Discovered Device:" ), 9 ); 252 menu-> insertItem ( tr( "Discovered Device:" ), 9 );
253 253
254 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) 254 for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it )
255 menu-> insertItem ( *it ); 255 menu-> insertItem ( *it );
256 256
257 menu-> insertSeparator ( ); 257 menu-> insertSeparator ( );
258 } 258 }
259 259
260 menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); 260 menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 );
261 261
262 if ( m_irda_active ) { 262 if ( m_irda_active ) {
263 menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); 263 menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 );
264 menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); 264 menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 );
265 } 265 }
266 266
267 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); 267 QPoint p = mapToGlobal ( QPoint ( 0, 0 ) );
268 QSize s = menu-> sizeHint ( ); 268 QSize s = menu-> sizeHint ( );
269 269
270 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); 270 p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ));
271 271
272 switch ( menu-> exec ( p )) { 272 switch ( menu-> exec ( p )) {
273 case 0: 273 case 0:
274 setIrdaStatus ( !m_irda_active ); 274 setIrdaStatus ( !m_irda_active );
275 timerEvent ( 0 ); 275 timerEvent ( 0 );
276 break; 276 break;
277 case 1: 277 case 1:
278 setIrdaDiscoveryStatus ( !m_irda_discovery_active ); 278 setIrdaDiscoveryStatus ( !m_irda_discovery_active );
279 timerEvent ( 0 ); 279 timerEvent ( 0 );
280 break; 280 break;
281 case 2: 281 case 2:
282 setIrdaReceiveStatus ( !m_receive_active ); 282 setIrdaReceiveStatus ( !m_receive_active );
283 timerEvent( 0 ); 283 timerEvent( 0 );
284 break; 284 break;
285 } 285 }
286 286
287 delete menu; 287 delete menu;
288} 288}
289 289
290void IrdaApplet::timerEvent ( QTimerEvent * ) 290void IrdaApplet::timerEvent ( QTimerEvent * )
291{ 291{
292 bool oldactive = m_irda_active; 292 bool oldactive = m_irda_active;
293 bool olddiscovery = m_irda_discovery_active; 293 bool olddiscovery = m_irda_discovery_active;
294 bool receiveUpdate = false; 294 bool receiveUpdate = false;
295 295
296 if ( m_receive_state_changed ) { 296 if ( m_receive_state_changed ) {
297 receiveUpdate = true; 297 receiveUpdate = true;
298 m_receive_state_changed = false; 298 m_receive_state_changed = false;
299 } 299 }
300 300
301 m_irda_active = checkIrdaStatus ( ); 301 m_irda_active = checkIrdaStatus ( );
302 m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); 302 m_irda_discovery_active = checkIrdaDiscoveryStatus ( );
303 303
304 if ( m_irda_discovery_active ) 304 if ( m_irda_discovery_active )
305 showDiscovered ( ); 305 showDiscovered ( );
306 306
307 if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) 307 if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate )
308 update ( ); 308 update ( );
309} 309}
310 310
311void IrdaApplet::paintEvent ( QPaintEvent * ) 311void IrdaApplet::paintEvent ( QPaintEvent * )
312{ 312{
313 QPainter p ( this ); 313 QPainter p ( this );
314 314
315 p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); 315 p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap );
316 316
317 if ( m_irda_discovery_active ) 317 if ( m_irda_discovery_active )
318 p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); 318 p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap );
319 319
320 if ( m_receive_active ) 320 if ( m_receive_active )
321 p. drawPixmap( 0, 1, m_receiveActivePixmap ); 321 p. drawPixmap( 0, 1, m_receiveActivePixmap );
322} 322}
323/* 323/*
324 * We know 3 calls 324 * We know 3 calls
325 * a) enable 325 * a) enable
326 * b) disable 326 * b) disable
327 * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on 327 * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on
328 * c) listDevices: We will return a list of known devices 328 * c) listDevices: We will return a list of known devices
329 */ 329 */
330void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { 330void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) {
331 if ( str == "enableIrda()") { 331 if ( str == "enableIrda()") {
332 m_wasOn = checkIrdaStatus(); 332 m_wasOn = checkIrdaStatus();
333 m_wasDiscover = checkIrdaDiscoveryStatus(); 333 m_wasDiscover = checkIrdaDiscoveryStatus();
334 if (!m_wasOn) { 334 if (!m_wasOn) {
335 setIrdaStatus( true ); 335 setIrdaStatus( true );
336 } 336 }
337 if ( !m_wasDiscover ) { 337 if ( !m_wasDiscover ) {
338 setIrdaDiscoveryStatus ( true ); 338 setIrdaDiscoveryStatus ( true );
339 } 339 }
340 } else if ( str == "disableIrda()") { 340 } else if ( str == "disableIrda()") {
341 if (!m_wasOn) { 341 if (!m_wasOn) {
342 setIrdaStatus( false ); 342 setIrdaStatus( false );
343 } 343 }
344 if ( !m_wasDiscover ) { 344 if ( !m_wasDiscover ) {
345 setIrdaDiscoveryStatus ( false ); 345 setIrdaDiscoveryStatus ( false );
346 } 346 }
347 } else if ( str == "listDevices()") { 347 } else if ( str == "listDevices()") {
348 QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); 348 QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)");
349 349
350 QStringList list; 350 QStringList list;
351 QMap<QString, QString>::Iterator it; 351 QMap<QString, QString>::Iterator it;
352 for (it = m_devices.begin(); it != m_devices.end(); ++it ) 352 for (it = m_devices.begin(); it != m_devices.end(); ++it )
353 list << (*it); 353 list << (*it);
354 354
355 e << list; 355 e << list;
356 } 356 }
357} 357}
diff --git a/core/applets/irdaapplet/irdaappletimpl.h b/core/applets/irdaapplet/irdaappletimpl.h
index ef0c5a6..f9e855a 100644
--- a/core/applets/irdaapplet/irdaappletimpl.h
+++ b/core/applets/irdaapplet/irdaappletimpl.h
@@ -1,44 +1,46 @@
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#ifndef IRDAAPPLETIMPL_H 20#ifndef IRDAAPPLETIMPL_H
21#define IRDAAPPLETIMPL_H 21#define IRDAAPPLETIMPL_H
22 22
23#include <qwidget.h>
24
23#include <qpe/taskbarappletinterface.h> 25#include <qpe/taskbarappletinterface.h>
24 26
25class IrdaApplet; 27class IrdaApplet;
26 28
27class IrdaAppletImpl : public TaskbarAppletInterface 29class IrdaAppletImpl : public TaskbarAppletInterface
28{ 30{
29public: 31public:
30 IrdaAppletImpl(); 32 IrdaAppletImpl();
31 virtual ~IrdaAppletImpl(); 33 virtual ~IrdaAppletImpl();
32 34
33 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 35 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
34 Q_REFCOUNT 36 Q_REFCOUNT
35 37
36 virtual QWidget *applet( QWidget *parent ); 38 virtual QWidget *applet( QWidget *parent );
37 virtual int position() const; 39 virtual int position() const;
38 40
39private: 41private:
40 IrdaApplet *irda; 42 IrdaApplet *irda;
41 ulong ref; 43 ulong ref;
42}; 44};
43 45
44#endif 46#endif
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h
index 5ac7768..de2a707 100644
--- a/core/applets/rotateapplet/rotate.h
+++ b/core/applets/rotateapplet/rotate.h
@@ -1,69 +1,71 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> 3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <_,   >  .   <= redistribute it and/or modify it under 6.> <_,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30 30
31#ifndef __OPIE_ROTATE_APPLET_H__ 31#ifndef __OPIE_ROTATE_APPLET_H__
32#define __OPIE_ROTATE_APPLET_H__ 32#define __OPIE_ROTATE_APPLET_H__
33 33
34#include <qpe/menuappletinterface.h> 34#include <qpe/menuappletinterface.h>
35#include <qobject.h> 35#include <qobject.h>
36 36
37#include <qobject.h>
38
37class RotateApplet : public QObject, public MenuAppletInterface 39class RotateApplet : public QObject, public MenuAppletInterface
38{ 40{
39 41
40 Q_OBJECT 42 Q_OBJECT
41 43
42public: 44public:
43 RotateApplet ( ); 45 RotateApplet ( );
44 virtual ~RotateApplet ( ); 46 virtual ~RotateApplet ( );
45 47
46 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 48 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
47 Q_REFCOUNT 49 Q_REFCOUNT
48 50
49 virtual int position() const; 51 virtual int position() const;
50 52
51 virtual QString name ( ) const; 53 virtual QString name ( ) const;
52 virtual QIconSet icon ( ) const; 54 virtual QIconSet icon ( ) const;
53 virtual QString text ( ) const; 55 virtual QString text ( ) const;
54 /* virtual QString tr( const char* ) const; 56 /* virtual QString tr( const char* ) const;
55 virtual QString tr( const char*, const char* ) const; 57 virtual QString tr( const char*, const char* ) const;
56 */ 58 */
57 virtual QPopupMenu *popup ( QWidget *parent ) const; 59 virtual QPopupMenu *popup ( QWidget *parent ) const;
58 virtual void activated ( ); 60 virtual void activated ( );
59 61
60private slots: 62private slots:
61 void channelReceived( const QCString &msg, const QByteArray & data ); 63 void channelReceived( const QCString &msg, const QByteArray & data );
62 64
63private: 65private:
64 ulong ref; 66 ulong ref;
65 bool m_flipped; 67 bool m_flipped;
66 68
67}; 69};
68 70
69#endif 71#endif
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index b129be3..38f827e 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,783 +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/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#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)
30#include <qpe/qcopenvelope_qws.h> 30#include <qpe/qcopenvelope_qws.h>
31#endif 31#endif
32 32
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qframe.h> 37#include <qframe.h>
38#include <qpixmap.h> 38#include <qpixmap.h>
39#include <qvbox.h> 39#include <qvbox.h>
40#include <qlabel.h> 40#include <qlabel.h>
41 41
42#include <qtoolbutton.h> 42#include <qtoolbutton.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qtimer.h> 44#include <qtimer.h>
45 45
46#include <opie/odevice.h> 46#include <opie/odevice.h>
47 47
48#include "oledbox.h" 48#include "oledbox.h"
49 49
50using namespace Opie; 50using namespace Opie;
51 51
52#define RATE_TIMER_INTERVAL 100 52#define RATE_TIMER_INTERVAL 100
53// 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
54// 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.
55 55
56 56
57/* XPM */ 57/* XPM */
58static const char * vol_xpm[] = { 58static const char * vol_xpm[] = {
59"20 20 3 1", 59"20 20 3 1",
60" c None", 60" c None",
61". c #0000FF", 61". c #0000FF",
62"+ c #000000", 62"+ c #000000",
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" "};
83/* XPM */ 83/* XPM */
84static const char * mic_xpm[] = { 84static const char * mic_xpm[] = {
85"20 20 21 1", 85"20 20 21 1",
86" c None", 86" c None",
87". c #000000", 87". c #000000",
88"+ c #EEEEEE", 88"+ c #EEEEEE",
89"@ c #B4B6B4", 89"@ c #B4B6B4",
90"# c #8B8D8B", 90"# c #8B8D8B",
91"$ c #D5D6D5", 91"$ c #D5D6D5",
92"% c #E6E6E6", 92"% c #E6E6E6",
93"& c #9C9D9C", 93"& c #9C9D9C",
94"* c #6A696A", 94"* c #6A696A",
95"= c #E6E2E6", 95"= c #E6E2E6",
96"- c #F6F2F6", 96"- c #F6F2F6",
97"; c #CDC6CD", 97"; c #CDC6CD",
98"> c #737573", 98"> c #737573",
99", c #4A484A", 99", c #4A484A",
100"' c #DEDEDE", 100"' c #DEDEDE",
101") c #F6EEF6", 101") c #F6EEF6",
102"! c #414041", 102"! c #414041",
103"~ c #202020", 103"~ c #202020",
104"{ c #ACAEAC", 104"{ c #ACAEAC",
105"] c #838583", 105"] c #838583",
106"^ c #6A656A", 106"^ c #6A656A",
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
129static const char * bass_xpm[] = { 129static const char * bass_xpm[] = {
130"20 20 3 1", 130"20 20 3 1",
131" c None", 131" c None",
132". c #000000", 132". c #000000",
133"+ c #0000FF", 133"+ c #0000FF",
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 155
156static const char * treble_xpm[] = { 156static const char * treble_xpm[] = {
157"20 20 3 1", 157"20 20 3 1",
158" c None", 158" c None",
159". c #0000FF", 159". c #0000FF",
160"+ c #000000", 160"+ c #000000",
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
185/* XPM */ 185/* XPM */
186static const char * alarm_xpm[] = { 186static const char * alarm_xpm[] = {
187"20 20 33 1", 187"20 20 33 1",
188" c None", 188" c None",
189". c #080602", 189". c #080602",
190"+ c #AAA602", 190"+ c #AAA602",
191"@ c #252002", 191"@ c #252002",
192"# c #434202", 192"# c #434202",
193"$ c #795602", 193"$ c #795602",
194"% c #C3C20D", 194"% c #C3C20D",
195"& c #DADAC2", 195"& c #DADAC2",
196"* c #826002", 196"* c #826002",
197"= c #740502", 197"= c #740502",
198"- c #D6D602", 198"- c #D6D602",
199"; c #322E02", 199"; c #322E02",
200"> c #826A02", 200"> c #826A02",
201", c #F1F195", 201", c #F1F195",
202"' c #959215", 202"' c #959215",
203") c #423602", 203") c #423602",
204"! c #4B0302", 204"! c #4B0302",
205"~ c #844315", 205"~ c #844315",
206"{ c #AAAA2A", 206"{ c #AAAA2A",
207"] c #E2DE42", 207"] c #E2DE42",
208"^ c #BA7E04", 208"^ c #BA7E04",
209"/ c #7F7502", 209"/ c #7F7502",
210"( c #828276", 210"( c #828276",
211"_ c #FEFE4E", 211"_ c #FEFE4E",
212": c #7D1902", 212": c #7D1902",
213"< c #989656", 213"< c #989656",
214"[ c #260B02", 214"[ c #260B02",
215"} c #F7F7D8", 215"} c #F7F7D8",
216"| c #DCDA5A", 216"| c #DCDA5A",
217"1 c #823102", 217"1 c #823102",
218"2 c #B1AC6B", 218"2 c #B1AC6B",
219"3 c #F7F710", 219"3 c #F7F710",
220"4 c #838204", 220"4 c #838204",
221" ", 221" ",
222" ", 222" ",
223" 4'4/ ", 223" 4'4/ ",
224" /-^= ", 224" /-^= ",
225" 42{4>4 ", 225" 42{4>4 ",
226" '2|+*$44 ", 226" '2|+*$44 ",
227" +2&3+$1*44 ", 227" +2&3+$1*44 ",
228" (%_}_+/$:>/4 ", 228" (%_}_+/$:>/4 ",
229" 4%_}3+#;>:*4 ", 229" 4%_}3+#;>:*4 ",
230" 4%_}&+#[1$/4 ", 230" 4%_}&+#[1$/4 ",
231" 4%_,2')[~~>4 ", 231" 4%_,2')[~~>4 ",
232" 4%33'4#@~1>4 ", 232" 4%33'4#@~1>4 ",
233" 4%3344#[:>/4 ", 233" 4%3344#[:>/4 ",
234" 42&_3'4#@>:*44 ", 234" 42&_3'4#@>:*44 ",
235" 42|}}3'4#[;$)$44 ", 235" 42|}}3'4#[;$)$44 ",
236"444{]]2^~~:!!#.@##/ ", 236"444{]]2^~~:!!#.@##/ ",
237"4444-%*:==!!=...../ ", 237"4444-%*:==!!=...../ ",
238" /:[.. ", 238" /:[.. ",
239" /@. ", 239" /@. ",
240" "}; 240" "};
241 241
242VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 242VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
243 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 243 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
244{ 244{
245 m_icon = icon; 245 m_icon = icon;
246 246
247 bool has_wav_alarm = true; 247 bool has_wav_alarm = true;
248 bool has_bass = true; 248 bool has_bass = true;
249 bool has_treble = true; 249 bool has_treble = true;
250 250
251 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 251 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
252 case Model_Zaurus_SL5000: 252 case Model_Zaurus_SL5000:
253 has_wav_alarm = false; //poor guys probably feeling left out... 253 has_wav_alarm = false; //poor guys probably feeling left out...
254 break; 254 break;
255 default: 255 default:
256 break; 256 break;
257 } 257 }
258 258
259 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 259 if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
260 has_bass = false; 260 has_bass = false;
261 has_treble = false; 261 has_treble = false;
262 } 262 }
263 263
264 264
265 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 265 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
266 266
267 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 267 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
268 grid-> setSpacing ( 4 ); 268 grid-> setSpacing ( 4 );
269 grid-> setMargin ( 6 ); 269 grid-> setMargin ( 6 );
270 270
271 QVBoxLayout *vbox; 271 QVBoxLayout *vbox;
272 QLabel *l; 272 QLabel *l;
273 273
274 vbox = new QVBoxLayout ( ); 274 vbox = new QVBoxLayout ( );
275 vbox-> setSpacing ( 4 ); 275 vbox-> setSpacing ( 4 );
276 grid-> addLayout ( vbox, 1, 0 ); 276 grid-> addLayout ( vbox, 1, 0 );
277 277
278 upButton = new QPushButton ( this ); 278 upButton = new QPushButton ( this );
279 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 279 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
280 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 280 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
281 upButton-> setFocusPolicy ( QWidget::NoFocus ); 281 upButton-> setFocusPolicy ( QWidget::NoFocus );
282 282
283 vbox-> addWidget ( upButton ); 283 vbox-> addWidget ( upButton );
284 284
285 downButton = new QPushButton ( this ); 285 downButton = new QPushButton ( this );
286 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 286 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
287 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 287 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
288 downButton-> setFocusPolicy ( QWidget::NoFocus ); 288 downButton-> setFocusPolicy ( QWidget::NoFocus );
289 289
290 vbox-> addWidget ( downButton ); 290 vbox-> addWidget ( downButton );
291 291
292 volSlider = new QSlider ( this ); 292 volSlider = new QSlider ( this );
293 volSlider-> setRange ( 0, 100 ); 293 volSlider-> setRange ( 0, 100 );
294 volSlider-> setTickmarks ( QSlider::Both ); 294 volSlider-> setTickmarks ( QSlider::Both );
295 volSlider-> setTickInterval ( 20 ); 295 volSlider-> setTickInterval ( 20 );
296 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 296 volSlider-> setFocusPolicy ( QWidget::NoFocus );
297 297
298 l = new QLabel ( this ); 298 l = new QLabel ( this );
299 l-> setPixmap ( QPixmap ( vol_xpm )); 299 l-> setPixmap ( QPixmap ( vol_xpm ));
300 300
301 grid-> addWidget ( l, 0, 1, AlignCenter ); 301 grid-> addWidget ( l, 0, 1, AlignCenter );
302 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 302 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
303 303
304 volLed = new OLedBox ( green, this ); 304 volLed = new OLedBox ( green, this );
305 volLed-> setFocusPolicy ( QWidget::NoFocus ); 305 volLed-> setFocusPolicy ( QWidget::NoFocus );
306 volLed-> setFixedSize ( 16, 16 ); 306 volLed-> setFixedSize ( 16, 16 );
307 307
308 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 308 grid-> addWidget ( volLed, 2, 1, AlignCenter );
309 309
310 QVBox *basstrebleBox = new QVBox( this ); 310 QVBox *basstrebleBox = new QVBox( this );
311 311
312 trebleSlider = new QSlider ( basstrebleBox ); 312 trebleSlider = new QSlider ( basstrebleBox );
313 trebleSlider-> setRange ( 0, 100 ); 313 trebleSlider-> setRange ( 0, 100 );
314 trebleSlider-> setTickmarks ( QSlider::Both ); 314 trebleSlider-> setTickmarks ( QSlider::Both );
315 trebleSlider-> setTickInterval ( 20 ); 315 trebleSlider-> setTickInterval ( 20 );
316 trebleSlider->setMaximumHeight( 40 ); 316 trebleSlider->setMaximumHeight( 40 );
317 trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); 317 trebleSlider-> setFocusPolicy ( QWidget::NoFocus );
318 318
319 bassSlider = new QSlider ( basstrebleBox ); 319 bassSlider = new QSlider ( basstrebleBox );
320 bassSlider-> setRange ( 0, 100 ); 320 bassSlider-> setRange ( 0, 100 );
321 bassSlider-> setTickmarks ( QSlider::Both ); 321 bassSlider-> setTickmarks ( QSlider::Both );
322 bassSlider-> setTickInterval ( 20 ); 322 bassSlider-> setTickInterval ( 20 );
323 bassSlider->setMaximumHeight( 40 ); 323 bassSlider->setMaximumHeight( 40 );
324 bassSlider-> setFocusPolicy ( QWidget::NoFocus ); 324 bassSlider-> setFocusPolicy ( QWidget::NoFocus );
325 325
326 QLabel *bassLabel = new QLabel ( this ); 326 QLabel *bassLabel = new QLabel ( this );
327 bassLabel-> setPixmap ( QPixmap ( bass_xpm )); 327 bassLabel-> setPixmap ( QPixmap ( bass_xpm ));
328 328
329 QLabel *trebleLabel = new QLabel( this ); 329 QLabel *trebleLabel = new QLabel( this );
330 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 330 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
331 331
332 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 332 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
333 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 333 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
334 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 334 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
335 335
336 if ( !has_bass ) { 336 if ( !has_bass ) {
337 bassSlider->hide(); 337 bassSlider->hide();
338 bassLabel->hide(); 338 bassLabel->hide();
339 } 339 }
340 340
341 if ( !has_treble ) { 341 if ( !has_treble ) {
342 trebleSlider->hide(); 342 trebleSlider->hide();
343 trebleLabel->hide(); 343 trebleLabel->hide();
344 } 344 }
345 345
346 micSlider = new QSlider ( this ); 346 micSlider = new QSlider ( this );
347 micSlider-> setRange ( 0, 100 ); 347 micSlider-> setRange ( 0, 100 );
348 micSlider-> setTickmarks ( QSlider::Both ); 348 micSlider-> setTickmarks ( QSlider::Both );
349 micSlider-> setTickInterval ( 20 ); 349 micSlider-> setTickInterval ( 20 );
350 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 350 micSlider-> setFocusPolicy ( QWidget::NoFocus );
351 351
352 l = new QLabel ( this ); 352 l = new QLabel ( this );
353 l-> setPixmap ( QPixmap ( mic_xpm )); 353 l-> setPixmap ( QPixmap ( mic_xpm ));
354 354
355 grid-> addWidget ( l, 0, 2, AlignCenter ); 355 grid-> addWidget ( l, 0, 2, AlignCenter );
356 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 356 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
357 357
358 micLed = new OLedBox ( red, this ); 358 micLed = new OLedBox ( red, this );
359 micLed-> setFocusPolicy ( QWidget::NoFocus ); 359 micLed-> setFocusPolicy ( QWidget::NoFocus );
360 micLed-> setFixedSize ( 16, 16 ); 360 micLed-> setFixedSize ( 16, 16 );
361 361
362 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 362 grid-> addWidget ( micLed, 2, 2, AlignCenter );
363 363
364 alarmSlider = new QSlider ( this ); 364 alarmSlider = new QSlider ( this );
365 alarmSlider-> setRange ( 0, 100 ); 365 alarmSlider-> setRange ( 0, 100 );
366 alarmSlider-> setTickmarks ( QSlider::Both ); 366 alarmSlider-> setTickmarks ( QSlider::Both );
367 alarmSlider-> setTickInterval ( 20 ); 367 alarmSlider-> setTickInterval ( 20 );
368 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 368 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
369 369
370 QLabel *alarmLabel = new QLabel ( this ); 370 QLabel *alarmLabel = new QLabel ( this );
371 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 371 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
372 372
373 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 373 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
374 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 374 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
375 375
376 alarmLed = new OLedBox ( yellow, this ); 376 alarmLed = new OLedBox ( yellow, this );
377 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 377 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
378 alarmLed-> setFixedSize ( 16, 16 ); 378 alarmLed-> setFixedSize ( 16, 16 );
379 379
380 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 380 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
381 381
382 if ( !has_wav_alarm ) { 382 if ( !has_wav_alarm ) {
383 alarmSlider-> hide ( ); 383 alarmSlider-> hide ( );
384 alarmLabel-> hide ( ); 384 alarmLabel-> hide ( );
385 alarmLed-> hide ( ); 385 alarmLed-> hide ( );
386 } 386 }
387 387
388 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 );
389 389
390 vbox = new QVBoxLayout ( ); 390 vbox = new QVBoxLayout ( );
391 vbox-> setSpacing ( 4 ); 391 vbox-> setSpacing ( 4 );
392 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 392 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
393 393
394 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 394 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
395 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 395 tapBox-> setFocusPolicy ( QWidget::NoFocus );
396 396
397 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 397 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
398 398
399 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 399 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
400 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 400 keyBox-> setFocusPolicy ( QWidget::NoFocus );
401 401
402 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 402 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
403 403
404 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 404 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
405 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 405 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
406 406
407 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 407 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
408 408
409 if ( has_wav_alarm ) { 409 if ( has_wav_alarm ) {
410 alarmBox-> hide ( ); 410 alarmBox-> hide ( );
411 } 411 }
412 412
413 vbox-> addStretch ( 100 ); 413 vbox-> addStretch ( 100 );
414 414
415 setFixedSize ( sizeHint ( )); 415 setFixedSize ( sizeHint ( ));
416 setFocusPolicy ( QWidget::NoFocus ); 416 setFocusPolicy ( QWidget::NoFocus );
417 417
418 rateTimer = new QTimer( this ); 418 rateTimer = new QTimer( this );
419 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 419 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
420 420
421 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 421 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
422 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 422 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
423 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 423 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
424 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 424 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
425 425
426 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 426 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
427 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 427 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
428 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 428 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
429 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); 429 connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int )));
430 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); 430 connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int )));
431 431
432 432
433 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 433 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
434 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 434 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
435 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 435 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
436 436
437 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 437 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
438 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 438 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
439 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 439 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
440 440
441 // initialize variables 441 // initialize variables
442 442
443 readConfig ( true ); 443 readConfig ( true );
444 444
445 // initialize the config file, in case some entries are missing 445 // initialize the config file, in case some entries are missing
446 446
447 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 447 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
448 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 448 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
449 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 449 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
450 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 450 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
451 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 451 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
452 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 452 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
453 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 453 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
454 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 454 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
455 455
456 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 456 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
457 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 457 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
458} 458}
459 459
460bool VolumeControl::volMuted ( ) const 460bool VolumeControl::volMuted ( ) const
461{ 461{
462 return m_vol_muted; 462 return m_vol_muted;
463} 463}
464 464
465int VolumeControl::volPercent ( ) const 465int VolumeControl::volPercent ( ) const
466{ 466{
467 return m_vol_percent; 467 return m_vol_percent;
468} 468}
469 469
470void VolumeControl::keyPressEvent ( QKeyEvent *e ) 470void VolumeControl::keyPressEvent ( QKeyEvent *e )
471{ 471{
472 switch ( e-> key ( )) { 472 switch ( e-> key ( )) {
473 case Key_Up: 473 case Key_Up:
474 volSlider-> subtractStep ( ); 474 volSlider-> subtractStep ( );
475 break; 475 break;
476 case Key_Down: 476 case Key_Down:
477 volSlider-> addStep ( ); 477 volSlider-> addStep ( );
478 break; 478 break;
479 case Key_Space: 479 case Key_Space:
480 volLed-> toggle ( ); 480 volLed-> toggle ( );
481 break; 481 break;
482 case Key_Escape: 482 case Key_Escape:
483 hide ( ); 483 hide ( );
484 break; 484 break;
485 } 485 }
486} 486}
487 487
488void VolumeControl::buttonChanged ( ) 488void VolumeControl::buttonChanged ( )
489{ 489{
490 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 490 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
491 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 491 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
492 // called at all when a button is pressed for a time 492 // called at all when a button is pressed for a time
493 // shorter than RATE_TIMER_INTERVAL. 493 // shorter than RATE_TIMER_INTERVAL.
494 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 494 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
495 } 495 }
496 else 496 else
497 rateTimer-> stop ( ); 497 rateTimer-> stop ( );
498} 498}
499 499
500void VolumeControl::rateTimerDone ( ) 500void VolumeControl::rateTimerDone ( )
501{ 501{
502 if ( upButton-> isDown ( )) 502 if ( upButton-> isDown ( ))
503 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 503 volSlider-> setValue ( volSlider-> value ( ) - 2 );
504 else // if ( downButton-> isDown ( )) 504 else // if ( downButton-> isDown ( ))
505 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 505 volSlider-> setValue ( volSlider-> value ( ) + 2 );
506} 506}
507 507
508void VolumeControl::show ( bool /*showMic*/ ) 508void VolumeControl::show ( bool /*showMic*/ )
509{ 509{
510 readConfig ( ); 510 readConfig ( );
511 511
512 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 512 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
513 513
514 int w = sizeHint ( ). width ( ); 514 int w = sizeHint ( ). width ( );
515 int x = curPos.x ( ) - ( w / 2 ); 515 int x = curPos.x ( ) - ( w / 2 );
516 516
517 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 517 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
518 x = QPEApplication::desktop ( )-> width ( ) - w; 518 x = QPEApplication::desktop ( )-> width ( ) - w;
519 519
520 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 520 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
521 QFrame::show ( ); 521 QFrame::show ( );
522 522
523} 523}
524 524
525void VolumeControl::readConfig ( bool force ) 525void VolumeControl::readConfig ( bool force )
526{ 526{
527 Config cfg ( "qpe" ); 527 Config cfg ( "qpe" );
528 cfg. setGroup ( "Volume" ); 528 cfg. setGroup ( "Volume" );
529 529
530 int old_vp = m_vol_percent; 530 int old_vp = m_vol_percent;
531 int old_mp = m_mic_percent; 531 int old_mp = m_mic_percent;
532 int old_bass = m_bass_percent; 532 int old_bass = m_bass_percent;
533 int old_treble = m_treble_percent; 533 int old_treble = m_treble_percent;
534 bool old_vm = m_vol_muted; 534 bool old_vm = m_vol_muted;
535 bool old_mm = m_mic_muted; 535 bool old_mm = m_mic_muted;
536 bool old_sk = m_snd_key; 536 bool old_sk = m_snd_key;
537 bool old_st = m_snd_touch; 537 bool old_st = m_snd_touch;
538 bool old_sa = m_snd_alarm; 538 bool old_sa = m_snd_alarm;
539 int old_ap = m_alarm_percent; 539 int old_ap = m_alarm_percent;
540 540
541 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 541 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
542 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 542 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
543 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 543 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
544 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 544 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
545 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 545 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
546 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 546 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
547 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 547 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
548 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 548 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
549 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 549 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
550 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 550 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
551 551
552 if ( force || ( m_vol_percent != old_vp )) 552 if ( force || ( m_vol_percent != old_vp ))
553 volSlider-> setValue ( 100 - m_vol_percent ); 553 volSlider-> setValue ( 100 - m_vol_percent );
554 if ( force || ( m_mic_percent != old_mp )) 554 if ( force || ( m_mic_percent != old_mp ))
555 micSlider-> setValue ( 100 - m_mic_percent ); 555 micSlider-> setValue ( 100 - m_mic_percent );
556 if ( force || ( m_alarm_percent != old_ap )) 556 if ( force || ( m_alarm_percent != old_ap ))
557 alarmSlider-> setValue ( 100 - m_alarm_percent ); 557 alarmSlider-> setValue ( 100 - m_alarm_percent );
558 if ( force || ( m_bass_percent != old_bass )) 558 if ( force || ( m_bass_percent != old_bass ))
559 bassSlider-> setValue ( 100 - m_bass_percent ); 559 bassSlider-> setValue ( 100 - m_bass_percent );
560 if ( force || ( m_treble_percent != old_treble )) 560 if ( force || ( m_treble_percent != old_treble ))
561 trebleSlider-> setValue ( 100 - m_treble_percent ); 561 trebleSlider-> setValue ( 100 - m_treble_percent );
562 562
563 563
564 if ( force || ( m_vol_muted != old_vm )) 564 if ( force || ( m_vol_muted != old_vm ))
565 volLed-> setOn ( !m_vol_muted ); 565 volLed-> setOn ( !m_vol_muted );
566 if ( force || ( m_mic_muted != old_mm )) 566 if ( force || ( m_mic_muted != old_mm ))
567 micLed-> setOn ( !m_mic_muted ); 567 micLed-> setOn ( !m_mic_muted );
568 if ( force || ( m_snd_alarm != old_sa )) 568 if ( force || ( m_snd_alarm != old_sa ))
569 alarmLed-> setOn ( m_snd_alarm ); 569 alarmLed-> setOn ( m_snd_alarm );
570 570
571 if ( force || ( m_snd_key != old_sk )) 571 if ( force || ( m_snd_key != old_sk ))
572 keyBox-> setChecked ( m_snd_key ); 572 keyBox-> setChecked ( m_snd_key );
573 if ( force || ( m_snd_touch != old_st )) 573 if ( force || ( m_snd_touch != old_st ))
574 tapBox-> setChecked ( m_snd_touch ); 574 tapBox-> setChecked ( m_snd_touch );
575 if ( force || ( m_snd_alarm != old_sa )) 575 if ( force || ( m_snd_alarm != old_sa ))
576 alarmBox-> setChecked ( m_snd_alarm ); 576 alarmBox-> setChecked ( m_snd_alarm );
577} 577}
578 578
579 579
580void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 580void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
581{ 581{
582 int prevVol = m_vol_percent; 582 int prevVol = m_vol_percent;
583 bool prevMute = m_vol_muted; 583 bool prevMute = m_vol_muted;
584 584
585 readConfig ( ); 585 readConfig ( );
586 586
587 // Handle case where muting it toggled 587 // Handle case where muting it toggled
588 if ( m_vol_muted != prevMute ) 588 if ( m_vol_muted != prevMute )
589 m_icon-> redraw ( true ); 589 m_icon-> redraw ( true );
590 else if ( prevVol != m_vol_percent ) // Avoid over repainting 590 else if ( prevVol != m_vol_percent ) // Avoid over repainting
591 m_icon-> redraw ( false ); 591 m_icon-> redraw ( false );
592} 592}
593 593
594void VolumeControl::micChanged ( bool nowMuted ) 594void VolumeControl::micChanged ( bool nowMuted )
595{ 595{
596 if ( !nowMuted ) 596 if ( !nowMuted )
597 readConfig ( ); 597 readConfig ( );
598 m_mic_muted = nowMuted; 598 m_mic_muted = nowMuted;
599} 599}
600 600
601void VolumeControl::screenTapToggled ( bool b ) 601void VolumeControl::screenTapToggled ( bool b )
602{ 602{
603 m_snd_touch = b; 603 m_snd_touch = b;
604 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 604 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
605} 605}
606 606
607void VolumeControl::keyClickToggled ( bool b ) 607void VolumeControl::keyClickToggled ( bool b )
608{ 608{
609 m_snd_key = b; 609 m_snd_key = b;
610 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 610 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
611} 611}
612 612
613void VolumeControl::alarmSoundToggled ( bool b ) 613void VolumeControl::alarmSoundToggled ( bool b )
614{ 614{
615 m_snd_alarm = b; 615 m_snd_alarm = b;
616 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 616 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
617} 617}
618 618
619void VolumeControl::volMuteToggled ( bool b ) 619void VolumeControl::volMuteToggled ( bool b )
620{ 620{
621 m_vol_muted = !b; 621 m_vol_muted = !b;
622 622
623 m_icon-> redraw ( true ); 623 m_icon-> redraw ( true );
624 624
625 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 625 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
626} 626}
627 627
628void VolumeControl::micMuteToggled ( bool b ) 628void VolumeControl::micMuteToggled ( bool b )
629{ 629{
630 m_mic_muted = !b; 630 m_mic_muted = !b;
631 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 631 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
632} 632}
633 633
634 634
635void VolumeControl::volMoved ( int percent ) 635void VolumeControl::volMoved ( int percent )
636{ 636{
637 m_vol_percent = 100 - percent; 637 m_vol_percent = 100 - percent;
638 638
639 // clamp volume percent to be between 0 and 100 639 // clamp volume percent to be between 0 and 100
640 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 );
641 // repaint just the little volume rectangle 641 // repaint just the little volume rectangle
642 m_icon-> redraw ( false ); 642 m_icon-> redraw ( false );
643 643
644 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 644 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
645} 645}
646 646
647void VolumeControl::micMoved ( int percent ) 647void VolumeControl::micMoved ( int percent )
648{ 648{
649 m_mic_percent = 100 - percent; 649 m_mic_percent = 100 - percent;
650 650
651 // clamp volume percent to be between 0 and 100 651 // clamp volume percent to be between 0 and 100
652 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 );
653 653
654 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 654 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
655} 655}
656 656
657void VolumeControl::alarmMoved ( int percent ) 657void VolumeControl::alarmMoved ( int percent )
658{ 658{
659 m_alarm_percent = 100 - percent; 659 m_alarm_percent = 100 - percent;
660 660
661 // clamp volume percent to be between 0 and 100 661 // clamp volume percent to be between 0 and 100
662 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 );
663 663
664 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 664 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
665} 665}
666 666
667 667
668void VolumeControl::bassMoved ( int percent ) 668void VolumeControl::bassMoved ( int percent )
669{ 669{
670 m_bass_percent = 100 - percent; 670 m_bass_percent = 100 - percent;
671 671
672 // clamp bass percent to be between 0 and 100 672 // clamp bass percent to be between 0 and 100
673 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 );
674 674
675 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); 675 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
676} 676}
677 677
678 678
679 679
680void VolumeControl::trebleMoved ( int percent ) 680void VolumeControl::trebleMoved ( int percent )
681{ 681{
682 m_treble_percent = 100 - percent; 682 m_treble_percent = 100 - percent;
683 683
684 // clamp treble percent to be between 0 and 100 684 // clamp treble percent to be between 0 and 100
685 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 );
686 686
687 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 687 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
688} 688}
689 689
690 690
691 691
692void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 692void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
693{ 693{
694 Config cfg ( "qpe" ); 694 Config cfg ( "qpe" );
695 cfg. setGroup ( "Volume" ); 695 cfg. setGroup ( "Volume" );
696 cfg. writeEntry ( entry, val ); 696 cfg. writeEntry ( entry, val );
697// cfg. write ( ); 697// cfg. write ( );
698 698
699#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)
700 switch ( upd ) { 700 switch ( upd ) {
701 case UPD_Vol: { 701 case UPD_Vol: {
702 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 702 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
703 break; 703 break;
704 } 704 }
705 case UPD_Mic: { 705 case UPD_Mic: {
706 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 706 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
707 break; 707 break;
708 } 708 }
709 case UPD_Bass: { 709 case UPD_Bass: {
710 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 710 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
711 break; 711 break;
712 } 712 }
713 case UPD_Treble: { 713 case UPD_Treble: {
714 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; 714 QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true;
715 break; 715 break;
716 } 716 }
717 717
718 case UPD_None: 718 case UPD_None:
719 break; 719 break;
720 } 720 }
721#endif 721#endif
722} 722}
723 723
724//=========================================================================== 724//===========================================================================
725 725
726VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 726VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
727 : QWidget( parent, name ) 727 : QWidget( parent, name )
728{ 728{
729 setFixedWidth ( AppLnk::smallIconSize() ); 729 setFixedWidth ( AppLnk::smallIconSize() );
730 setFixedHeight ( AppLnk::smallIconSize()+4 ); 730 setFixedHeight ( AppLnk::smallIconSize()+4 );
731 731
732 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 732 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
733 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); 733 m_dialog = new VolumeControl ( this, true, this, "volumecontrol" );
734 734
735 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); 735 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
736 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); 736 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
737} 737}
738 738
739VolumeApplet::~VolumeApplet() 739VolumeApplet::~VolumeApplet()
740{ 740{
741 delete m_pixmap; 741 delete m_pixmap;
742} 742}
743 743
744 744
745void VolumeApplet::mousePressEvent ( QMouseEvent * ) 745void VolumeApplet::mousePressEvent ( QMouseEvent * )
746{ 746{
747 if ( m_dialog-> isVisible ( )) 747 if ( m_dialog-> isVisible ( ))
748 m_dialog-> hide ( ); 748 m_dialog-> hide ( );
749 else 749 else
750 m_dialog-> show ( true ); 750 m_dialog-> show ( true );
751} 751}
752 752
753void VolumeApplet::redraw ( bool all ) 753void VolumeApplet::redraw ( bool all )
754{ 754{
755 if ( all ) 755 if ( all )
756 repaint ( true ); 756 repaint ( true );
757 else 757 else
758 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 758 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
759} 759}
760 760
761 761
762void VolumeApplet::paintEvent ( QPaintEvent * ) 762void VolumeApplet::paintEvent ( QPaintEvent * )
763{ 763{
764 QPainter p ( this ); 764 QPainter p ( this );
765 765
766 p. drawPixmap ( 0, 1, *m_pixmap ); 766 p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap );
767 p. setPen ( darkGray ); 767 p. setPen ( darkGray );
768 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 768 p. drawRect ( 1, height() - 4, width() - 2, 4 );
769 769
770 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 770 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
771 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 771 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
772 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 772 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
773 773
774 if ( m_dialog-> volMuted ( )) { 774 if ( m_dialog-> volMuted ( )) {
775 p. setPen ( red ); 775 p. setPen ( red );
776 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 776 p. drawLine ( 1, 2, width() - 2, height() - 5 );
777 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 777 p. drawLine ( 1, 3, width() - 2, height() - 4 );
778 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 778 p. drawLine ( width() - 2, 2, 1, height() - 5 );
779 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 779 p. drawLine ( width() - 2, 3, 1, height() - 4 );
780 } 780 }
781} 781}
782 782
783 783