33 files changed, 66 insertions, 70 deletions
diff --git a/core/applets/batteryapplet/battery.cpp b/core/applets/batteryapplet/battery.cpp index b2cef55..18e368e 100644 --- a/core/applets/batteryapplet/battery.cpp +++ b/core/applets/batteryapplet/battery.cpp | |||
@@ -1,182 +1,182 @@ | |||
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 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/otaskbarapplet.h> | 24 | #include <opie2/otaskbarapplet.h> |
25 | |||
26 | #include <qpe/qpeapplication.h> | ||
25 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
26 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
27 | #include <qpe/power.h> | 29 | #include <qpe/power.h> |
28 | 30 | ||
29 | /* QT */ | 31 | /* QT */ |
30 | #include <qpainter.h> | 32 | #include <qpainter.h> |
31 | #include <qtimer.h> | 33 | #include <qtimer.h> |
32 | 34 | ||
33 | 35 | ||
36 | using namespace Opie::Ui; | ||
34 | BatteryMeter::BatteryMeter( QWidget *parent ) | 37 | BatteryMeter::BatteryMeter( QWidget *parent ) |
35 | : QWidget( parent ), charging(false) | 38 | : QWidget( parent ), charging(false) |
36 | { | 39 | { |
37 | ps = new PowerStatus; | 40 | ps = new PowerStatus; |
38 | startTimer( 10000 ); | 41 | startTimer( 10000 ); |
39 | 42 | ||
40 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); | 43 | setFixedWidth( QMAX(AppLnk::smallIconSize()*3/4, 6) ); |
41 | setFixedHeight( AppLnk::smallIconSize() ); | 44 | setFixedHeight( AppLnk::smallIconSize() ); |
42 | 45 | ||
43 | chargeTimer = new QTimer( this ); | 46 | chargeTimer = new QTimer( this ); |
44 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); | 47 | connect( chargeTimer, SIGNAL(timeout()), this, SLOT(chargeTimeout()) ); |
45 | timerEvent(0); | 48 | timerEvent(0); |
46 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 49 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
47 | Config c( "qpe" ); | 50 | Config c( "qpe" ); |
48 | c.setGroup( "Battery" ); | 51 | c.setGroup( "Battery" ); |
49 | style = c.readNumEntry( "Style", 0 ); | 52 | style = c.readNumEntry( "Style", 0 ); |
50 | } | 53 | } |
51 | 54 | ||
52 | BatteryMeter::~BatteryMeter() | 55 | BatteryMeter::~BatteryMeter() |
53 | { | 56 | { |
54 | delete ps; | 57 | delete ps; |
55 | } | 58 | } |
56 | 59 | ||
57 | QSize BatteryMeter::sizeHint() const | 60 | QSize BatteryMeter::sizeHint() const |
58 | { | 61 | { |
59 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); | 62 | return QSize(QMAX(AppLnk::smallIconSize()*3/4, 6), height() ); |
60 | } | 63 | } |
61 | 64 | ||
62 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) | 65 | void BatteryMeter::mousePressEvent( QMouseEvent* e ) |
63 | { | 66 | { |
64 | if ( e->button() == RightButton ) | 67 | if ( e->button() == RightButton ) |
65 | { | 68 | { |
66 | style = 1-style; | 69 | style = 1-style; |
67 | Config c( "qpe" ); | 70 | Config c( "qpe" ); |
68 | c.setGroup( "Battery" ); | 71 | c.setGroup( "Battery" ); |
69 | c.writeEntry( "Style", style ); | 72 | c.writeEntry( "Style", style ); |
70 | repaint( true ); | 73 | repaint( true ); |
71 | } | 74 | } |
72 | QWidget::mousePressEvent( e ); | 75 | QWidget::mousePressEvent( e ); |
73 | } | 76 | } |
74 | 77 | ||
75 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) | 78 | void BatteryMeter::mouseReleaseEvent( QMouseEvent* /*e*/ ) |
76 | { | 79 | { |
77 | if ( batteryView && batteryView->isVisible() ) { | 80 | if ( batteryView && batteryView->isVisible() ) { |
78 | delete (QWidget *) batteryView; | 81 | delete (QWidget *) batteryView; |
79 | } else { | 82 | } else { |
80 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); | 83 | if ( !batteryView ) batteryView = new BatteryStatus( ps ); |
81 | QPEApplication::showWidget( batteryView ); | 84 | QPEApplication::showWidget( batteryView ); |
82 | batteryView->raise(); | 85 | batteryView->raise(); |
83 | batteryView->show(); | 86 | batteryView->show(); |
84 | } | 87 | } |
85 | } | 88 | } |
86 | 89 | ||
87 | void BatteryMeter::timerEvent( QTimerEvent * ) | 90 | void BatteryMeter::timerEvent( QTimerEvent * ) |
88 | { | 91 | { |
89 | PowerStatus prev = *ps; | 92 | PowerStatus prev = *ps; |
90 | 93 | ||
91 | *ps = PowerStatusManager::readStatus(); | 94 | *ps = PowerStatusManager::readStatus(); |
92 | 95 | ||
93 | if ( prev != *ps ) { | 96 | if ( prev != *ps ) { |
94 | percent = ps->batteryPercentRemaining(); | 97 | percent = ps->batteryPercentRemaining(); |
95 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { | 98 | if ( !charging && ps->batteryStatus() == PowerStatus::Charging ) { |
96 | percent = 0; | 99 | percent = 0; |
97 | charging = true; | 100 | charging = true; |
98 | chargeTimer->start( 500 ); | 101 | chargeTimer->start( 500 ); |
99 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { | 102 | } else if ( charging && ps->batteryStatus() != PowerStatus::Charging ) { |
100 | charging = false; | 103 | charging = false; |
101 | chargeTimer->stop(); | 104 | chargeTimer->stop(); |
102 | if ( batteryView ) | 105 | if ( batteryView ) |
103 | batteryView->updatePercent( percent ); | 106 | batteryView->updatePercent( percent ); |
104 | } | 107 | } |
105 | repaint( style != 0 ); | 108 | repaint( style != 0 ); |
106 | if ( batteryView ) | 109 | if ( batteryView ) |
107 | batteryView->repaint(); | 110 | batteryView->repaint(); |
108 | } | 111 | } |
109 | } | 112 | } |
110 | 113 | ||
111 | void BatteryMeter::chargeTimeout() | 114 | void BatteryMeter::chargeTimeout() |
112 | { | 115 | { |
113 | percent += 20; | 116 | percent += 20; |
114 | if ( percent > 100 ) | 117 | if ( percent > 100 ) |
115 | percent = 0; | 118 | percent = 0; |
116 | 119 | ||
117 | repaint(FALSE); | 120 | repaint(FALSE); |
118 | if ( batteryView ) | 121 | if ( batteryView ) |
119 | batteryView->updatePercent( percent ); | 122 | batteryView->updatePercent( percent ); |
120 | } | 123 | } |
121 | 124 | ||
122 | void BatteryMeter::paintEvent( QPaintEvent* ) | 125 | void BatteryMeter::paintEvent( QPaintEvent* ) |
123 | { | 126 | { |
124 | 127 | ||
125 | if ( style == 1 ) | 128 | if ( style == 1 ) |
126 | { | 129 | { |
127 | QPainter p(this); | 130 | QPainter p(this); |
128 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); | 131 | QFont f( "Fixed", AppLnk::smallIconSize()/2 ); |
129 | QFontMetrics fm( f ); | 132 | QFontMetrics fm( f ); |
130 | p.setFont( f ); | 133 | p.setFont( f ); |
131 | p.drawText( 0, height()/2, QString::number( percent ) ); | 134 | p.drawText( 0, height()/2, QString::number( percent ) ); |
132 | p.drawText( width()/4, height(), "%" ); | 135 | p.drawText( width()/4, height(), "%" ); |
133 | return; | 136 | return; |
134 | } | 137 | } |
135 | 138 | ||
136 | QPainter p(this); | 139 | QPainter p(this); |
137 | QColor color; | 140 | QColor color; |
138 | QColor g = gray.light( 160 ); | 141 | QColor g = gray.light( 160 ); |
139 | switch ( ps->acStatus() ) | 142 | switch ( ps->acStatus() ) |
140 | { | 143 | { |
141 | case PowerStatus::Offline: color = blue.light( 150 ); break; | 144 | case PowerStatus::Offline: color = blue.light( 150 ); break; |
142 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; | 145 | case PowerStatus::Online: color = green.dark( 130 ).light( 180 ); break; |
143 | default: color = red.light( 160 ); | 146 | default: color = red.light( 160 ); |
144 | } | 147 | } |
145 | 148 | ||
146 | int w = height() / 2; | 149 | int w = height() / 2; |
147 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line | 150 | if ( !(w%2) ) w--; // should have an odd value to get a real middle line |
148 | int h = height() - 4; | 151 | int h = height() - 4; |
149 | int pix = (percent * h) / 100; | 152 | int pix = (percent * h) / 100; |
150 | int y2 = height() -2; | 153 | int y2 = height() -2; |
151 | int y = y2 - pix; | 154 | int y = y2 - pix; |
152 | int x1 = (width() - w ) / 2; | 155 | int x1 = (width() - w ) / 2; |
153 | 156 | ||
154 | p.setPen(QColor(80,80,80)); | 157 | p.setPen(QColor(80,80,80)); |
155 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header | 158 | p.drawLine(x1+w/4,0,x1+w/4+w/2+1,0); // header |
156 | p.drawRect(x1,1,w,height()-1); // corpus | 159 | p.drawRect(x1,1,w,height()-1); // corpus |
157 | p.setBrush(color); | 160 | p.setBrush(color); |
158 | 161 | ||
159 | //int extra = ((percent * h) % 100)/(100/4); | 162 | //int extra = ((percent * h) % 100)/(100/4); |
160 | 163 | ||
161 | int middle = w/2; | 164 | int middle = w/2; |
162 | for ( int i = 0; i < middle; i++ ) | 165 | for ( int i = 0; i < middle; i++ ) |
163 | { | 166 | { |
164 | p.setPen( gray.dark( 100+i*20 ) ); | 167 | p.setPen( gray.dark( 100+i*20 ) ); |
165 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); | 168 | p.drawLine( x1+middle-i, 2, x1+middle-i, y-1 ); |
166 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); | 169 | p.drawLine( x1+middle+i, 2, x1+middle+i, y-1 ); |
167 | p.setPen( color.dark( 100+i*20 ) ); | 170 | p.setPen( color.dark( 100+i*20 ) ); |
168 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); | 171 | p.drawLine( x1+middle-i, y, x1+middle-i, y2 ); |
169 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); | 172 | p.drawLine( x1+middle+i, y, x1+middle+i, y2 ); |
170 | } | 173 | } |
171 | } | 174 | } |
172 | 175 | ||
173 | int BatteryMeter::position() | 176 | int BatteryMeter::position() |
174 | { | 177 | { |
175 | return 8; | 178 | return 8; |
176 | } | 179 | } |
177 | 180 | ||
178 | Q_EXPORT_INTERFACE() | 181 | EXPORT_OPIE_APPLET_v1( BatteryMeter ) |
179 | { | ||
180 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<BatteryMeter> ); | ||
181 | } | ||
182 | 182 | ||
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp index ea11495..bd86f77 100644 --- a/core/applets/batteryapplet/batterystatus.cpp +++ b/core/applets/batteryapplet/batterystatus.cpp | |||
@@ -1,251 +1,251 @@ | |||
1 | 1 | ||
2 | #include "batterystatus.h" | 2 | #include "batterystatus.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <opie2/odevice.h> | 5 | #include <opie2/odevice.h> |
6 | #include <qpe/power.h> | 6 | #include <qpe/power.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qdrawutil.h> | 10 | #include <qdrawutil.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | #include <qtextstream.h> | 13 | #include <qtextstream.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | 15 | ||
16 | using namespace Opie; | 16 | using namespace Opie::Core; |
17 | 17 | ||
18 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) | 18 | BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent ) |
19 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { | 19 | : QWidget( parent, 0, WDestructiveClose), ps(p), bat2(false) { |
20 | setCaption( tr("Battery status") ); | 20 | setCaption( tr("Battery status") ); |
21 | setMinimumSize( 150, 200 ); | 21 | setMinimumSize( 150, 200 ); |
22 | 22 | ||
23 | QPushButton *pb = new QPushButton( tr("Close"), this ); | 23 | QPushButton *pb = new QPushButton( tr("Close"), this ); |
24 | QVBoxLayout *layout = new QVBoxLayout ( this ); | 24 | QVBoxLayout *layout = new QVBoxLayout ( this ); |
25 | 25 | ||
26 | jackPercent = 0; | 26 | jackPercent = 0; |
27 | 27 | ||
28 | pb->setMaximumSize( 120, 40 ); | 28 | pb->setMaximumSize( 120, 40 ); |
29 | 29 | ||
30 | pb->show(); | 30 | pb->show(); |
31 | 31 | ||
32 | layout->addStretch(); | 32 | layout->addStretch(); |
33 | layout->addWidget( pb ); | 33 | layout->addWidget( pb ); |
34 | 34 | ||
35 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 35 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
36 | getProcApmStatusIpaq(); | 36 | getProcApmStatusIpaq(); |
37 | } | 37 | } |
38 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); | 38 | connect( pb, SIGNAL( clicked() ), this, SLOT( close() ) ); |
39 | percent = ps->batteryPercentRemaining(); | 39 | percent = ps->batteryPercentRemaining(); |
40 | show(); | 40 | show(); |
41 | } | 41 | } |
42 | 42 | ||
43 | BatteryStatus::~BatteryStatus() | 43 | BatteryStatus::~BatteryStatus() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * Make use of the advanced apm interface of the ipaq | 48 | * Make use of the advanced apm interface of the ipaq |
49 | */ | 49 | */ |
50 | bool BatteryStatus::getProcApmStatusIpaq() { | 50 | bool BatteryStatus::getProcApmStatusIpaq() { |
51 | 51 | ||
52 | bat2 = false; | 52 | bat2 = false; |
53 | 53 | ||
54 | QFile procApmIpaq("/proc/hal/battery"); | 54 | QFile procApmIpaq("/proc/hal/battery"); |
55 | 55 | ||
56 | if (procApmIpaq.open(IO_ReadOnly) ) { | 56 | if (procApmIpaq.open(IO_ReadOnly) ) { |
57 | QStringList list; | 57 | QStringList list; |
58 | // since it is /proc we _must_ use QTextStream | 58 | // since it is /proc we _must_ use QTextStream |
59 | QTextStream stream ( &procApmIpaq); | 59 | QTextStream stream ( &procApmIpaq); |
60 | QString streamIn; | 60 | QString streamIn; |
61 | streamIn = stream.read(); | 61 | streamIn = stream.read(); |
62 | list = QStringList::split("\n", streamIn); | 62 | list = QStringList::split("\n", streamIn); |
63 | 63 | ||
64 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | 64 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { |
65 | // not nice, need a rewrite later | 65 | // not nice, need a rewrite later |
66 | if( (*line).startsWith(" Percentage") ){ | 66 | if( (*line).startsWith(" Percentage") ){ |
67 | if (bat2 == true) { | 67 | if (bat2 == true) { |
68 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 68 | perc2 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
69 | } else { | 69 | } else { |
70 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); | 70 | perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); |
71 | } | 71 | } |
72 | }else if( (*line).startsWith(" Life") ){ | 72 | }else if( (*line).startsWith(" Life") ){ |
73 | if (bat2 == true) { | 73 | if (bat2 == true) { |
74 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); | 74 | sec2 = (*line).mid(((*line).find(':')+2), 5 ); |
75 | } else { | 75 | } else { |
76 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); | 76 | sec1 = (*line).mid(((*line).find(':')+2), 5 ); |
77 | } | 77 | } |
78 | }else if( (*line).startsWith("Battery #1") ){ | 78 | }else if( (*line).startsWith("Battery #1") ){ |
79 | bat2 = true; | 79 | bat2 = true; |
80 | }else if( (*line).startsWith(" Status") ){ | 80 | }else if( (*line).startsWith(" Status") ){ |
81 | if (bat2 == true) { | 81 | if (bat2 == true) { |
82 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | 82 | jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
83 | } else { | 83 | } else { |
84 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); | 84 | ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); |
85 | } | 85 | } |
86 | }else if( (*line).startsWith(" Chemistry") ) { | 86 | }else if( (*line).startsWith(" Chemistry") ) { |
87 | if (bat2 == true) { | 87 | if (bat2 == true) { |
88 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 88 | jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
89 | } else { | 89 | } else { |
90 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); | 90 | ipaqChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } else { | 94 | } else { |
95 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); | 95 | QMessageBox::warning(this, tr("Failure"),tr("could not open file")); |
96 | } | 96 | } |
97 | 97 | ||
98 | procApmIpaq.close(); | 98 | procApmIpaq.close(); |
99 | 99 | ||
100 | jackPercent = perc2.toInt(); | 100 | jackPercent = perc2.toInt(); |
101 | ipaqPercent = perc1.toInt(); | 101 | ipaqPercent = perc1.toInt(); |
102 | 102 | ||
103 | if (perc2.isEmpty()) { | 103 | if (perc2.isEmpty()) { |
104 | perc2 = tr("no data"); | 104 | perc2 = tr("no data"); |
105 | } else { | 105 | } else { |
106 | perc2 += " %"; | 106 | perc2 += " %"; |
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { | 110 | if (sec2 == "0" || sec2 == "" || sec2.isEmpty()) { |
111 | sec2 = tr("no data"); | 111 | sec2 = tr("no data"); |
112 | } else { | 112 | } else { |
113 | sec2 += " min"; | 113 | sec2 += " min"; |
114 | } | 114 | } |
115 | 115 | ||
116 | jackStatus == (" ( " + jackStatus + " )"); | 116 | jackStatus == (" ( " + jackStatus + " )"); |
117 | 117 | ||
118 | return true; | 118 | return true; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | void BatteryStatus::updatePercent( int pc ) { | 122 | void BatteryStatus::updatePercent( int pc ) { |
123 | percent = pc; | 123 | percent = pc; |
124 | repaint(FALSE); | 124 | repaint(FALSE); |
125 | } | 125 | } |
126 | 126 | ||
127 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { | 127 | void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) { |
128 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; | 128 | int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height; |
129 | topgrad.hsv( &h1, &s1, &v1 ); | 129 | topgrad.hsv( &h1, &s1, &v1 ); |
130 | botgrad.hsv( &h2, &s2, &v2 ); | 130 | botgrad.hsv( &h2, &s2, &v2 ); |
131 | for ( int j = 0; j < hy-2; j++ ) { | 131 | for ( int j = 0; j < hy-2; j++ ) { |
132 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 132 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
133 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 133 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
134 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); | 134 | p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j ); |
135 | } | 135 | } |
136 | for ( int j = 0; j < hh; j++ ) { | 136 | for ( int j = 0; j < hh; j++ ) { |
137 | p->setPen( highlight ); | 137 | p->setPen( highlight ); |
138 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); | 138 | p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j ); |
139 | } | 139 | } |
140 | for ( int j = 0; j < ng-hy-hh; j++ ) { | 140 | for ( int j = 0; j < ng-hy-hh; j++ ) { |
141 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), | 141 | p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1), |
142 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); | 142 | v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) ); |
143 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); | 143 | p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j ); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | void BatteryStatus::paintEvent( QPaintEvent * ) { | 147 | void BatteryStatus::paintEvent( QPaintEvent * ) { |
148 | 148 | ||
149 | QPainter p(this); | 149 | QPainter p(this); |
150 | QString text; | 150 | QString text; |
151 | if ( ps->batteryStatus() == PowerStatus::Charging ) { | 151 | if ( ps->batteryStatus() == PowerStatus::Charging ) { |
152 | if (bat2) { | 152 | if (bat2) { |
153 | text = tr("Charging both devices"); | 153 | text = tr("Charging both devices"); |
154 | } else { | 154 | } else { |
155 | text = tr("Charging"); | 155 | text = tr("Charging"); |
156 | } | 156 | } |
157 | } else if ( ps->batteryPercentAccurate() ) { | 157 | } else if ( ps->batteryPercentAccurate() ) { |
158 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); | 158 | text.sprintf( tr("Percentage battery remaining") + ": %i%%", percent ); |
159 | } else { | 159 | } else { |
160 | text = tr("Battery status: "); | 160 | text = tr("Battery status: "); |
161 | switch ( ps->batteryStatus() ) { | 161 | switch ( ps->batteryStatus() ) { |
162 | case PowerStatus::High: | 162 | case PowerStatus::High: |
163 | text += tr("Good"); | 163 | text += tr("Good"); |
164 | break; | 164 | break; |
165 | case PowerStatus::Low: | 165 | case PowerStatus::Low: |
166 | text += tr("Low"); | 166 | text += tr("Low"); |
167 | break; | 167 | break; |
168 | case PowerStatus::VeryLow: | 168 | case PowerStatus::VeryLow: |
169 | text += tr("Very Low"); | 169 | text += tr("Very Low"); |
170 | break; | 170 | break; |
171 | case PowerStatus::Critical: | 171 | case PowerStatus::Critical: |
172 | text += tr("Critical"); | 172 | text += tr("Critical"); |
173 | break; | 173 | break; |
174 | default: // NotPresent, etc. | 174 | default: // NotPresent, etc. |
175 | text += tr("Unknown"); | 175 | text += tr("Unknown"); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | p.drawText( 10, 90, text ); | 178 | p.drawText( 10, 90, text ); |
179 | 179 | ||
180 | if ( ps->acStatus() == PowerStatus::Backup ) | 180 | if ( ps->acStatus() == PowerStatus::Backup ) |
181 | p.drawText( 10, 110, tr("On backup power") ); | 181 | p.drawText( 10, 110, tr("On backup power") ); |
182 | else if ( ps->acStatus() == PowerStatus::Online ) | 182 | else if ( ps->acStatus() == PowerStatus::Online ) |
183 | p.drawText( 10, 110, tr("Power on-line") ); | 183 | p.drawText( 10, 110, tr("Power on-line") ); |
184 | else if ( ps->acStatus() == PowerStatus::Offline ) | 184 | else if ( ps->acStatus() == PowerStatus::Offline ) |
185 | p.drawText( 10, 110, tr("External power disconnected") ); | 185 | p.drawText( 10, 110, tr("External power disconnected") ); |
186 | 186 | ||
187 | if ( ps->batteryTimeRemaining() >= 0 ) { | 187 | if ( ps->batteryTimeRemaining() >= 0 ) { |
188 | text.sprintf( tr("Battery time remaining") + ": %im %02is", | 188 | text.sprintf( tr("Battery time remaining") + ": %im %02is", |
189 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); | 189 | ps->batteryTimeRemaining() / 60, ps->batteryTimeRemaining() % 60 ); |
190 | p.drawText( 10, 130, text ); | 190 | p.drawText( 10, 130, text ); |
191 | } | 191 | } |
192 | 192 | ||
193 | QColor c; | 193 | QColor c; |
194 | QColor darkc; | 194 | QColor darkc; |
195 | QColor lightc; | 195 | QColor lightc; |
196 | if ( ps->acStatus() == PowerStatus::Offline ) { | 196 | if ( ps->acStatus() == PowerStatus::Offline ) { |
197 | c = blue.light(120); | 197 | c = blue.light(120); |
198 | darkc = c.dark(280); | 198 | darkc = c.dark(280); |
199 | lightc = c.light(145); | 199 | lightc = c.light(145); |
200 | } else if ( ps->acStatus() == PowerStatus::Online ) { | 200 | } else if ( ps->acStatus() == PowerStatus::Online ) { |
201 | c = green.dark(130); | 201 | c = green.dark(130); |
202 | darkc = c.dark(200); | 202 | darkc = c.dark(200); |
203 | lightc = c.light(220); | 203 | lightc = c.light(220); |
204 | } else { | 204 | } else { |
205 | c = red; | 205 | c = red; |
206 | darkc = c.dark(280); | 206 | darkc = c.dark(280); |
207 | lightc = c.light(140); | 207 | lightc = c.light(140); |
208 | } | 208 | } |
209 | if ( percent < 0 ) | 209 | if ( percent < 0 ) |
210 | return; | 210 | return; |
211 | 211 | ||
212 | int rightEnd1 = width() - 47; | 212 | int rightEnd1 = width() - 47; |
213 | int rightEnd2 = width() - 35; | 213 | int rightEnd2 = width() - 35; |
214 | int percent2 = ( percent / 100 ) * rightEnd1 ; | 214 | int percent2 = ( percent / 100 ) * rightEnd1 ; |
215 | p.setPen( black ); | 215 | p.setPen( black ); |
216 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); | 216 | qDrawShadePanel( &p, 9, 30, rightEnd1 , 39, colorGroup(), TRUE, 1, NULL); |
217 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); | 217 | qDrawShadePanel( &p, rightEnd2, 37, 12, 24, colorGroup(), TRUE, 1, NULL); |
218 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); | 218 | drawSegment( &p, QRect( 10, 30, percent2, 40 ), lightc, darkc, lightc.light(115), 6 ); |
219 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); | 219 | drawSegment( &p, QRect( 11 + percent2, 30, rightEnd1 - percent2, 40 ), white.light(80), black, white.light(90), 6 ); |
220 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 220 | drawSegment( &p, QRect( rightEnd2, 37, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
221 | p.setPen( black); | 221 | p.setPen( black); |
222 | 222 | ||
223 | 223 | ||
224 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 224 | if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
225 | 225 | ||
226 | p.drawText(15, 50, tr ("Ipaq ") + ipaqChem); | 226 | p.drawText(15, 50, tr ("Ipaq ") + ipaqChem); |
227 | 227 | ||
228 | QString jacketMsg; | 228 | QString jacketMsg; |
229 | if (bat2) { | 229 | if (bat2) { |
230 | p.setPen(black); | 230 | p.setPen(black); |
231 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); | 231 | p.drawText(10,220, tr("Percentage battery remaining: ") + perc2 + " " + jackStatus); |
232 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); | 232 | p.drawText(10,240, tr("Battery time remaining: ") + sec2); |
233 | jacketMsg = tr("Jacket ") + jackChem; | 233 | jacketMsg = tr("Jacket ") + jackChem; |
234 | } else { | 234 | } else { |
235 | jackPercent = 0; | 235 | jackPercent = 0; |
236 | jacketMsg = tr("No jacket with battery inserted"); | 236 | jacketMsg = tr("No jacket with battery inserted"); |
237 | } | 237 | } |
238 | 238 | ||
239 | int jackPerc = ( jackPercent / 100 ) * ( width() - 47 ) ; | 239 | int jackPerc = ( jackPercent / 100 ) * ( width() - 47 ) ; |
240 | 240 | ||
241 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); | 241 | qDrawShadePanel( &p, 9, 160, rightEnd1, 39, colorGroup(), TRUE, 1, NULL); |
242 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); | 242 | qDrawShadePanel( &p, rightEnd2, 167, 12, 24, colorGroup(), TRUE, 1, NULL); |
243 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); | 243 | drawSegment( &p, QRect( 10, 160, jackPerc, 40 ), lightc, darkc, lightc.light(115), 6 ); |
244 | drawSegment( &p, QRect( 11 + jackPerc, 160, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); | 244 | drawSegment( &p, QRect( 11 + jackPerc, 160, rightEnd1 - jackPerc, 40 ), white.light(80), black, white.light(90), 6 ); |
245 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); | 245 | drawSegment( &p, QRect( rightEnd2, 167, 10, 25 ), white.light(80), black, white.light(90), 2 ); |
246 | p.setPen( black ); | 246 | p.setPen( black ); |
247 | p.drawText(15, 180, jacketMsg); | 247 | p.drawText(15, 180, jacketMsg); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | 251 | ||
diff --git a/core/applets/batteryapplet/config.in b/core/applets/batteryapplet/config.in index 3067317..eca07e3 100644 --- a/core/applets/batteryapplet/config.in +++ b/core/applets/batteryapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config BATTERYAPPLET | 1 | config BATTERYAPPLET |
2 | boolean "opie-batteryapplet (Applet to monitor battery status)" | 2 | boolean "opie-batteryapplet (Applet to monitor battery status)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 6090b68..ed4bfc7 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp | |||
@@ -1,426 +1,427 @@ | |||
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 | #include "cardmon.h" | 19 | #include "cardmon.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/odevice.h> | 22 | #include <opie2/odevice.h> |
23 | #include <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qcopchannel_qws.h> | 28 | #include <qcopchannel_qws.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | #include <qsound.h> | 32 | #include <qsound.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | 34 | ||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | #include <unistd.h> | 37 | #include <unistd.h> |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <string.h> | 39 | #include <string.h> |
40 | #include <fcntl.h> | 40 | #include <fcntl.h> |
41 | 41 | ||
42 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 42 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
43 | #include <sys/vfs.h> | 43 | #include <sys/vfs.h> |
44 | #include <mntent.h> | 44 | #include <mntent.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | using namespace Opie; | 47 | using namespace Opie; |
48 | 48 | ||
49 | using namespace Opie::Ui; | 49 | using namespace Opie::Ui; |
50 | using namespace Opie::Ui; | ||
50 | using namespace Opie::Core; | 51 | using namespace Opie::Core; |
51 | 52 | ||
52 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), | 53 | CardMonitor::CardMonitor( QWidget * parent ) : QWidget( parent ), |
53 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) | 54 | pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) |
54 | { | 55 | { |
55 | 56 | ||
56 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); | 57 | QCopChannel * pcmciaChannel = new QCopChannel( "QPE/Card", this ); |
57 | connect( pcmciaChannel, | 58 | connect( pcmciaChannel, |
58 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 59 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
59 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 60 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
60 | 61 | ||
61 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); | 62 | QCopChannel *sdChannel = new QCopChannel( "QPE/Card", this ); |
62 | connect( sdChannel, | 63 | connect( sdChannel, |
63 | SIGNAL( received(const QCString&,const QByteArray&) ), this, | 64 | SIGNAL( received(const QCString&,const QByteArray&) ), this, |
64 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); | 65 | SLOT( cardMessage(const QCString&,const QByteArray&) ) ); |
65 | 66 | ||
66 | cardInPcmcia0 = FALSE; | 67 | cardInPcmcia0 = FALSE; |
67 | cardInPcmcia1 = FALSE; | 68 | cardInPcmcia1 = FALSE; |
68 | cardInSd = FALSE; | 69 | cardInSd = FALSE; |
69 | 70 | ||
70 | setFocusPolicy( NoFocus ); | 71 | setFocusPolicy( NoFocus ); |
71 | 72 | ||
72 | setFixedWidth ( AppLnk::smallIconSize() ); | 73 | setFixedWidth ( AppLnk::smallIconSize() ); |
73 | setFixedHeight ( AppLnk::smallIconSize() ); | 74 | setFixedHeight ( AppLnk::smallIconSize() ); |
74 | 75 | ||
75 | getStatusPcmcia( TRUE ); | 76 | getStatusPcmcia( TRUE ); |
76 | getStatusSd( TRUE ); | 77 | getStatusSd( TRUE ); |
77 | repaint( FALSE ); | 78 | repaint( FALSE ); |
78 | popupMenu = 0; | 79 | popupMenu = 0; |
79 | } | 80 | } |
80 | 81 | ||
81 | CardMonitor::~CardMonitor() | 82 | CardMonitor::~CardMonitor() |
82 | { | 83 | { |
83 | if ( popupMenu ) | 84 | if ( popupMenu ) |
84 | { | 85 | { |
85 | delete popupMenu; | 86 | delete popupMenu; |
86 | } | 87 | } |
87 | } | 88 | } |
88 | 89 | ||
89 | void CardMonitor::popUp( QString message, QString icon ) | 90 | void CardMonitor::popUp( QString message, QString icon ) |
90 | { | 91 | { |
91 | if ( !popupMenu ) | 92 | if ( !popupMenu ) |
92 | { | 93 | { |
93 | popupMenu = new QPopupMenu( this ); | 94 | popupMenu = new QPopupMenu( this ); |
94 | } | 95 | } |
95 | 96 | ||
96 | popupMenu->clear(); | 97 | popupMenu->clear(); |
97 | if ( icon.isEmpty() ) | 98 | if ( icon.isEmpty() ) |
98 | { | 99 | { |
99 | popupMenu->insertItem( message, 0 ); | 100 | popupMenu->insertItem( message, 0 ); |
100 | } | 101 | } |
101 | else | 102 | else |
102 | { | 103 | { |
103 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), | 104 | popupMenu->insertItem( QIconSet( Resource::loadPixmap( icon ) ), |
104 | message, 0 ); | 105 | message, 0 ); |
105 | } | 106 | } |
106 | 107 | ||
107 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 108 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
108 | QSize s = popupMenu->sizeHint(); | 109 | QSize s = popupMenu->sizeHint(); |
109 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 110 | popupMenu->popup( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
110 | p.y() - s.height() ), 0 ); | 111 | p.y() - s.height() ), 0 ); |
111 | 112 | ||
112 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); | 113 | QTimer::singleShot( 2000, this, SLOT( popupTimeout() ) ); |
113 | } | 114 | } |
114 | 115 | ||
115 | void CardMonitor::popupTimeout() | 116 | void CardMonitor::popupTimeout() |
116 | { | 117 | { |
117 | popupMenu->hide(); | 118 | popupMenu->hide(); |
118 | } | 119 | } |
119 | 120 | ||
120 | void CardMonitor::mousePressEvent( QMouseEvent * ) | 121 | void CardMonitor::mousePressEvent( QMouseEvent * ) |
121 | { | 122 | { |
122 | QPopupMenu * menu = new QPopupMenu( this ); | 123 | QPopupMenu * menu = new QPopupMenu( this ); |
123 | QString cmd; | 124 | QString cmd; |
124 | int err = 0; | 125 | int err = 0; |
125 | 126 | ||
126 | if ( cardInSd ) | 127 | if ( cardInSd ) |
127 | { | 128 | { |
128 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), | 129 | menu->insertItem( QIconSet( Resource::loadPixmap( "cardmon/ide" ) ), |
129 | tr( "Eject SD/MMC card" ), 0 ); | 130 | tr( "Eject SD/MMC card" ), 0 ); |
130 | } | 131 | } |
131 | 132 | ||
132 | if ( cardInPcmcia0 ) | 133 | if ( cardInPcmcia0 ) |
133 | { | 134 | { |
134 | menu-> | 135 | menu-> |
135 | insertItem( QIconSet | 136 | insertItem( QIconSet |
136 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), | 137 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia0Type ) ), |
137 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); | 138 | tr( "Eject card 0: %1" ).arg( cardInPcmcia0Name ), 1 ); |
138 | } | 139 | } |
139 | 140 | ||
140 | if ( cardInPcmcia1 ) | 141 | if ( cardInPcmcia1 ) |
141 | { | 142 | { |
142 | menu-> | 143 | menu-> |
143 | insertItem( QIconSet | 144 | insertItem( QIconSet |
144 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), | 145 | ( Resource::loadPixmap( "cardmon/" + cardInPcmcia1Type ) ), |
145 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); | 146 | tr( "Eject card 1: %1" ).arg( cardInPcmcia1Name ), 2 ); |
146 | } | 147 | } |
147 | 148 | ||
148 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); | 149 | QPoint p = mapToGlobal( QPoint( 0, 0 ) ); |
149 | QSize s = menu->sizeHint(); | 150 | QSize s = menu->sizeHint(); |
150 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), | 151 | int opt = menu->exec( QPoint( p.x() + ( width() / 2 ) - ( s.width() / 2 ), |
151 | p.y() - s.height() ), 0 ); | 152 | p.y() - s.height() ), 0 ); |
152 | 153 | ||
153 | if ( opt == 1 ) | 154 | if ( opt == 1 ) |
154 | { | 155 | { |
155 | cmd = "/sbin/cardctl eject 0"; | 156 | cmd = "/sbin/cardctl eject 0"; |
156 | err = system( ( const char * ) cmd ); | 157 | err = system( ( const char * ) cmd ); |
157 | if ( err != 0 ) | 158 | if ( err != 0 ) |
158 | { | 159 | { |
159 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", | 160 | qDebug( "Could not execute `/sbin/cardctl eject 0'! err=%d", |
160 | err ); | 161 | err ); |
161 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 162 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
162 | } | 163 | } |
163 | } | 164 | } |
164 | else if ( opt == 0 ) | 165 | else if ( opt == 0 ) |
165 | { | 166 | { |
166 | if ( ODevice::inst() ->system() == System_Familiar ) | 167 | if ( ODevice::inst() ->system() == System_Familiar ) |
167 | { | 168 | { |
168 | cmd = "umount /dev/mmc/part1"; | 169 | cmd = "umount /dev/mmc/part1"; |
169 | } | 170 | } |
170 | else | 171 | else |
171 | { | 172 | { |
172 | cmd = "umount /dev/mmcda1"; | 173 | cmd = "umount /dev/mmcda1"; |
173 | } | 174 | } |
174 | err = system( ( const char * ) cmd ); | 175 | err = system( ( const char * ) cmd ); |
175 | if ( err != 0 ) | 176 | if ( err != 0 ) |
176 | { | 177 | { |
177 | popUp( tr( "SD/MMC card eject failed!" ) ); | 178 | popUp( tr( "SD/MMC card eject failed!" ) ); |
178 | } | 179 | } |
179 | } | 180 | } |
180 | else if ( opt == 2 ) | 181 | else if ( opt == 2 ) |
181 | { | 182 | { |
182 | cmd = "/sbin/cardctl eject 1"; | 183 | cmd = "/sbin/cardctl eject 1"; |
183 | err = system( ( const char * ) cmd ); | 184 | err = system( ( const char * ) cmd ); |
184 | if ( err != 0 ) | 185 | if ( err != 0 ) |
185 | { | 186 | { |
186 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", | 187 | qDebug( "Could not execute `/sbin/cardctl eject 1'! err=%d", |
187 | err ); | 188 | err ); |
188 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); | 189 | popUp( tr( "CF/PCMCIA card eject failed!" ) ); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | delete menu; | 192 | delete menu; |
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||
195 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) | 196 | void CardMonitor::cardMessage( const QCString & msg, const QByteArray & ) |
196 | { | 197 | { |
197 | if ( msg == "stabChanged()" ) | 198 | if ( msg == "stabChanged()" ) |
198 | { | 199 | { |
199 | // qDebug("Pcmcia: stabchanged"); | 200 | // qDebug("Pcmcia: stabchanged"); |
200 | getStatusPcmcia(); | 201 | getStatusPcmcia(); |
201 | } | 202 | } |
202 | else if ( msg == "mtabChanged()" ) | 203 | else if ( msg == "mtabChanged()" ) |
203 | { | 204 | { |
204 | // qDebug("CARDMONAPPLET: mtabchanged"); | 205 | // qDebug("CARDMONAPPLET: mtabchanged"); |
205 | getStatusSd(); | 206 | getStatusSd(); |
206 | } | 207 | } |
207 | } | 208 | } |
208 | 209 | ||
209 | bool CardMonitor::getStatusPcmcia( int showPopUp ) | 210 | bool CardMonitor::getStatusPcmcia( int showPopUp ) |
210 | { | 211 | { |
211 | 212 | ||
212 | bool cardWas0 = cardInPcmcia0;// remember last state | 213 | bool cardWas0 = cardInPcmcia0;// remember last state |
213 | bool cardWas1 = cardInPcmcia1; | 214 | bool cardWas1 = cardInPcmcia1; |
214 | 215 | ||
215 | QString fileName; | 216 | QString fileName; |
216 | 217 | ||
217 | // one of these 3 files should exist | 218 | // one of these 3 files should exist |
218 | if ( QFile::exists( "/var/run/stab" ) ) | 219 | if ( QFile::exists( "/var/run/stab" ) ) |
219 | { | 220 | { |
220 | fileName = "/var/run/stab"; | 221 | fileName = "/var/run/stab"; |
221 | } | 222 | } |
222 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) | 223 | else if ( QFile::exists( "/var/state/pcmcia/stab" ) ) |
223 | { | 224 | { |
224 | fileName = "/var/state/pcmcia/stab"; | 225 | fileName = "/var/state/pcmcia/stab"; |
225 | } | 226 | } |
226 | else | 227 | else |
227 | { | 228 | { |
228 | fileName = "/var/lib/pcmcia/stab"; | 229 | fileName = "/var/lib/pcmcia/stab"; |
229 | } | 230 | } |
230 | 231 | ||
231 | QFile f( fileName ); | 232 | QFile f( fileName ); |
232 | 233 | ||
233 | if ( f.open( IO_ReadOnly ) ) | 234 | if ( f.open( IO_ReadOnly ) ) |
234 | { | 235 | { |
235 | QStringList list; | 236 | QStringList list; |
236 | QTextStream stream( &f ); | 237 | QTextStream stream( &f ); |
237 | QString streamIn; | 238 | QString streamIn; |
238 | streamIn = stream.read(); | 239 | streamIn = stream.read(); |
239 | list = QStringList::split( "\n", streamIn ); | 240 | list = QStringList::split( "\n", streamIn ); |
240 | for ( QStringList::Iterator line = list.begin(); line != list.end(); | 241 | for ( QStringList::Iterator line = list.begin(); line != list.end(); |
241 | line++ ) | 242 | line++ ) |
242 | { | 243 | { |
243 | if ( ( *line ).startsWith( "Socket 0:" ) ) | 244 | if ( ( *line ).startsWith( "Socket 0:" ) ) |
244 | { | 245 | { |
245 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) | 246 | if ( ( *line ).startsWith( "Socket 0: empty" ) && cardInPcmcia0 ) |
246 | { | 247 | { |
247 | cardInPcmcia0 = FALSE; | 248 | cardInPcmcia0 = FALSE; |
248 | } | 249 | } |
249 | else if ( !( *line ).startsWith( "Socket 0: empty" ) | 250 | else if ( !( *line ).startsWith( "Socket 0: empty" ) |
250 | && !cardInPcmcia0 ) | 251 | && !cardInPcmcia0 ) |
251 | { | 252 | { |
252 | cardInPcmcia0Name = | 253 | cardInPcmcia0Name = |
253 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 254 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
254 | ( *line ).length() - 9 ); | 255 | ( *line ).length() - 9 ); |
255 | cardInPcmcia0Name.stripWhiteSpace(); | 256 | cardInPcmcia0Name.stripWhiteSpace(); |
256 | cardInPcmcia0 = TRUE; | 257 | cardInPcmcia0 = TRUE; |
257 | show(); | 258 | show(); |
258 | line++; | 259 | line++; |
259 | int pos = ( *line ).find( '\t' ) + 1; | 260 | int pos = ( *line ).find( '\t' ) + 1; |
260 | cardInPcmcia0Type = | 261 | cardInPcmcia0Type = |
261 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 262 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
262 | } | 263 | } |
263 | } | 264 | } |
264 | else if ( ( *line ).startsWith( "Socket 1:" ) ) | 265 | else if ( ( *line ).startsWith( "Socket 1:" ) ) |
265 | { | 266 | { |
266 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) | 267 | if ( ( *line ).startsWith( "Socket 1: empty" ) && cardInPcmcia1 ) |
267 | { | 268 | { |
268 | cardInPcmcia1 = FALSE; | 269 | cardInPcmcia1 = FALSE; |
269 | } | 270 | } |
270 | else if ( !( *line ).startsWith( "Socket 1: empty" ) | 271 | else if ( !( *line ).startsWith( "Socket 1: empty" ) |
271 | && !cardInPcmcia1 ) | 272 | && !cardInPcmcia1 ) |
272 | { | 273 | { |
273 | cardInPcmcia1Name = | 274 | cardInPcmcia1Name = |
274 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), | 275 | ( *line ).mid( ( ( *line ).find( ':' ) + 1 ), |
275 | ( *line ).length() - 9 ); | 276 | ( *line ).length() - 9 ); |
276 | cardInPcmcia1Name.stripWhiteSpace(); | 277 | cardInPcmcia1Name.stripWhiteSpace(); |
277 | cardInPcmcia1 = TRUE; | 278 | cardInPcmcia1 = TRUE; |
278 | show(); | 279 | show(); |
279 | line++; | 280 | line++; |
280 | int pos = ( *line ).find( '\t' ) + 1; | 281 | int pos = ( *line ).find( '\t' ) + 1; |
281 | cardInPcmcia1Type = | 282 | cardInPcmcia1Type = |
282 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); | 283 | ( *line ).mid( pos, ( *line ).find( "\t", pos ) - pos ); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | } | 286 | } |
286 | f.close(); | 287 | f.close(); |
287 | 288 | ||
288 | if ( !showPopUp | 289 | if ( !showPopUp |
289 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) | 290 | && ( cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1 ) ) |
290 | { | 291 | { |
291 | QString text = QString::null; | 292 | QString text = QString::null; |
292 | QString what = QString::null; | 293 | QString what = QString::null; |
293 | if ( cardWas0 != cardInPcmcia0 ) | 294 | if ( cardWas0 != cardInPcmcia0 ) |
294 | { | 295 | { |
295 | if ( cardInPcmcia0 ) | 296 | if ( cardInPcmcia0 ) |
296 | { | 297 | { |
297 | text += tr( "New card: " ); | 298 | text += tr( "New card: " ); |
298 | what = "on"; | 299 | what = "on"; |
299 | } | 300 | } |
300 | else | 301 | else |
301 | { | 302 | { |
302 | text += tr( "Ejected: " ); | 303 | text += tr( "Ejected: " ); |
303 | what = "off"; | 304 | what = "off"; |
304 | } | 305 | } |
305 | text += cardInPcmcia0Name; | 306 | text += cardInPcmcia0Name; |
306 | popUp( text, "cardmon/" + cardInPcmcia0Type ); | 307 | popUp( text, "cardmon/" + cardInPcmcia0Type ); |
307 | } | 308 | } |
308 | 309 | ||
309 | if ( cardWas1 != cardInPcmcia1 ) | 310 | if ( cardWas1 != cardInPcmcia1 ) |
310 | { | 311 | { |
311 | if ( cardInPcmcia1 ) | 312 | if ( cardInPcmcia1 ) |
312 | { | 313 | { |
313 | text += tr( "New card: " ); | 314 | text += tr( "New card: " ); |
314 | what = "on"; | 315 | what = "on"; |
315 | } | 316 | } |
316 | else | 317 | else |
317 | { | 318 | { |
318 | text += tr( "Ejected: " ); | 319 | text += tr( "Ejected: " ); |
319 | what = "off"; | 320 | what = "off"; |
320 | } | 321 | } |
321 | text += cardInPcmcia1Name; | 322 | text += cardInPcmcia1Name; |
322 | popUp( text, "cardmon/" + cardInPcmcia1Type ); | 323 | popUp( text, "cardmon/" + cardInPcmcia1Type ); |
323 | } | 324 | } |
324 | #ifndef QT_NO_SOUND | 325 | #ifndef QT_NO_SOUND |
325 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 326 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
326 | #endif | 327 | #endif |
327 | 328 | ||
328 | } | 329 | } |
329 | } | 330 | } |
330 | else | 331 | else |
331 | { | 332 | { |
332 | // no file found | 333 | // no file found |
333 | qDebug( "no file found" ); | 334 | qDebug( "no file found" ); |
334 | cardInPcmcia0 = FALSE; | 335 | cardInPcmcia0 = FALSE; |
335 | cardInPcmcia1 = FALSE; | 336 | cardInPcmcia1 = FALSE; |
336 | } | 337 | } |
337 | repaint( FALSE ); | 338 | repaint( FALSE ); |
338 | return ( ( cardWas0 == cardInPcmcia0 | 339 | return ( ( cardWas0 == cardInPcmcia0 |
339 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); | 340 | && cardWas1 == cardInPcmcia1 ) ? FALSE : TRUE ); |
340 | 341 | ||
341 | } | 342 | } |
342 | 343 | ||
343 | 344 | ||
344 | bool CardMonitor::getStatusSd( int showPopUp ) | 345 | bool CardMonitor::getStatusSd( int showPopUp ) |
345 | { | 346 | { |
346 | 347 | ||
347 | bool cardWas = cardInSd;// remember last state | 348 | bool cardWas = cardInSd;// remember last state |
348 | cardInSd = FALSE; | 349 | cardInSd = FALSE; |
349 | 350 | ||
350 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 351 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
351 | struct mntent *me; | 352 | struct mntent *me; |
352 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 353 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
353 | 354 | ||
354 | if ( mntfp ) | 355 | if ( mntfp ) |
355 | { | 356 | { |
356 | while ( ( me = getmntent( mntfp ) ) != 0 ) | 357 | while ( ( me = getmntent( mntfp ) ) != 0 ) |
357 | { | 358 | { |
358 | QString fs = me->mnt_fsname; | 359 | QString fs = me->mnt_fsname; |
359 | //qDebug( fs ); | 360 | //qDebug( fs ); |
360 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" | 361 | if ( fs.left( 14 ) == "/dev/mmc/part1" || fs.left( 7 ) == "/dev/sd" |
361 | || fs.left( 9 ) == "/dev/mmcd" ) | 362 | || fs.left( 9 ) == "/dev/mmcd" ) |
362 | { | 363 | { |
363 | cardInSd = TRUE; | 364 | cardInSd = TRUE; |
364 | show(); | 365 | show(); |
365 | } | 366 | } |
366 | // else { | 367 | // else { |
367 | // cardInSd = FALSE; | 368 | // cardInSd = FALSE; |
368 | // } | 369 | // } |
369 | } | 370 | } |
370 | endmntent( mntfp ); | 371 | endmntent( mntfp ); |
371 | } | 372 | } |
372 | 373 | ||
373 | if ( !showPopUp && cardWas != cardInSd ) | 374 | if ( !showPopUp && cardWas != cardInSd ) |
374 | { | 375 | { |
375 | QString text = QString::null; | 376 | QString text = QString::null; |
376 | QString what = QString::null; | 377 | QString what = QString::null; |
377 | if ( cardInSd ) | 378 | if ( cardInSd ) |
378 | { | 379 | { |
379 | text += "New card: SD/MMC"; | 380 | text += "New card: SD/MMC"; |
380 | what = "on"; | 381 | what = "on"; |
381 | } | 382 | } |
382 | else | 383 | else |
383 | { | 384 | { |
384 | text += "Ejected: SD/MMC"; | 385 | text += "Ejected: SD/MMC"; |
385 | what = "off"; | 386 | what = "off"; |
386 | } | 387 | } |
387 | //qDebug("TEXT: " + text ); | 388 | //qDebug("TEXT: " + text ); |
388 | #ifndef QT_NO_SOUND | 389 | #ifndef QT_NO_SOUND |
389 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); | 390 | QSound::play( Resource::findSound( "cardmon/card" + what ) ); |
390 | #endif | 391 | #endif |
391 | popUp( text, "cardmon/ide" );// XX add SD pic | 392 | popUp( text, "cardmon/ide" );// XX add SD pic |
392 | } | 393 | } |
393 | #else | 394 | #else |
394 | #error "Not on Linux" | 395 | #error "Not on Linux" |
395 | #endif | 396 | #endif |
396 | repaint( FALSE ); | 397 | repaint( FALSE ); |
397 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); | 398 | return ( ( cardWas == cardInSd ) ? FALSE : TRUE ); |
398 | } | 399 | } |
399 | 400 | ||
400 | void CardMonitor::paintEvent( QPaintEvent * ) | 401 | void CardMonitor::paintEvent( QPaintEvent * ) |
401 | { | 402 | { |
402 | 403 | ||
403 | QPainter p( this ); | 404 | QPainter p( this ); |
404 | 405 | ||
405 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) | 406 | if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) |
406 | { | 407 | { |
407 | p.drawPixmap( 0, 0, pm ); | 408 | p.drawPixmap( 0, 0, pm ); |
408 | show(); | 409 | show(); |
409 | } | 410 | } |
410 | else | 411 | else |
411 | { | 412 | { |
412 | //p.eraseRect(rect()); | 413 | //p.eraseRect(rect()); |
413 | hide(); | 414 | hide(); |
414 | } | 415 | } |
415 | } | 416 | } |
416 | 417 | ||
417 | int CardMonitor::position() | 418 | int CardMonitor::position() |
418 | { | 419 | { |
419 | return 7; | 420 | return 7; |
420 | } | 421 | } |
421 | 422 | ||
422 | Q_EXPORT_INTERFACE() | 423 | Q_EXPORT_INTERFACE() |
423 | { | 424 | { |
424 | Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<CardMonitor> ); | 425 | Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<CardMonitor> ); |
425 | } | 426 | } |
426 | 427 | ||
diff --git a/core/applets/cardmon/config.in b/core/applets/cardmon/config.in index f3d57fd..8626c75 100644 --- a/core/applets/cardmon/config.in +++ b/core/applets/cardmon/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config CARDMON | 1 | config CARDMON |
2 | boolean "opie-cardmon (monitor cf/sd/mmc card status, and eject function)" | 2 | boolean "opie-cardmon (monitor cf/sd/mmc card status, and eject function)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp index 4fc8076..57a4088 100644 --- a/core/applets/clipboardapplet/clipboard.cpp +++ b/core/applets/clipboardapplet/clipboard.cpp | |||
@@ -1,189 +1,188 @@ | |||
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 <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qwindowsystem_qws.h> | 29 | #include <qwindowsystem_qws.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qclipboard.h> | 31 | #include <qclipboard.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | //=========================================================================== | 34 | //=========================================================================== |
35 | 35 | ||
36 | 36 | ||
37 | using namespace Opie::Ui; | ||
37 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) | 38 | ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) |
38 | { | 39 | { |
39 | setFixedWidth ( AppLnk::smallIconSize() ); | 40 | setFixedWidth ( AppLnk::smallIconSize() ); |
40 | setFixedHeight ( AppLnk::smallIconSize() ); | 41 | setFixedHeight ( AppLnk::smallIconSize() ); |
41 | 42 | ||
42 | QImage img = Resource::loadImage( "paste"); | 43 | QImage img = Resource::loadImage( "paste"); |
43 | img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 44 | img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
44 | 45 | ||
45 | m_clipboardPixmap.convertFromImage( img ); | 46 | m_clipboardPixmap.convertFromImage( img ); |
46 | 47 | ||
47 | m_timer = new QTimer ( this ); | 48 | m_timer = new QTimer ( this ); |
48 | 49 | ||
49 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData())); | 50 | connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData())); |
50 | connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData())); | 51 | connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData())); |
51 | connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown())); | 52 | connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown())); |
52 | 53 | ||
53 | m_menu = 0; | 54 | m_menu = 0; |
54 | m_dirty = true; | 55 | m_dirty = true; |
55 | m_lasttext = QString::null; | 56 | m_lasttext = QString::null; |
56 | 57 | ||
57 | m_timer-> start ( 0, true ); | 58 | m_timer-> start ( 0, true ); |
58 | } | 59 | } |
59 | 60 | ||
60 | ClipboardApplet::~ClipboardApplet ( ) | 61 | ClipboardApplet::~ClipboardApplet ( ) |
61 | { | 62 | { |
62 | } | 63 | } |
63 | 64 | ||
64 | int ClipboardApplet::position() | 65 | int ClipboardApplet::position() |
65 | { | 66 | { |
66 | return 6; | 67 | return 6; |
67 | } | 68 | } |
68 | 69 | ||
69 | void ClipboardApplet::shutdown ( ) | 70 | void ClipboardApplet::shutdown ( ) |
70 | { | 71 | { |
71 | // the timer has to be stopped, or Qt/E will hang on quit() | 72 | // the timer has to be stopped, or Qt/E will hang on quit() |
72 | // see launcher/desktop.cpp | 73 | // see launcher/desktop.cpp |
73 | 74 | ||
74 | m_timer-> stop ( ); | 75 | m_timer-> stop ( ); |
75 | } | 76 | } |
76 | 77 | ||
77 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) | 78 | void ClipboardApplet::mousePressEvent ( QMouseEvent *) |
78 | { | 79 | { |
79 | if ( m_dirty ) { | 80 | if ( m_dirty ) { |
80 | delete m_menu; | 81 | delete m_menu; |
81 | 82 | ||
82 | m_menu = new QPopupMenu ( this ); | 83 | m_menu = new QPopupMenu ( this ); |
83 | m_menu-> setCheckable ( true ); | 84 | m_menu-> setCheckable ( true ); |
84 | 85 | ||
85 | if ( m_history. count ( )) { | 86 | if ( m_history. count ( )) { |
86 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { | 87 | for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { |
87 | QString str = m_history [i]; | 88 | QString str = m_history [i]; |
88 | 89 | ||
89 | if ( str. length ( ) > 20 ) | 90 | if ( str. length ( ) > 20 ) |
90 | str = str. left ( 20 ) + "..."; | 91 | str = str. left ( 20 ) + "..."; |
91 | 92 | ||
92 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); | 93 | m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); |
93 | m_menu-> setItemChecked ( i, false ); | 94 | m_menu-> setItemChecked ( i, false ); |
94 | } | 95 | } |
95 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); | 96 | m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); |
96 | m_menu-> insertSeparator ( ); | 97 | m_menu-> insertSeparator ( ); |
97 | } | 98 | } |
98 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); | 99 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); |
99 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); | 100 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); |
100 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); | 101 | m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); |
101 | 102 | ||
102 | connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int))); | 103 | connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int))); |
103 | 104 | ||
104 | m_dirty = false; | 105 | m_dirty = false; |
105 | } | 106 | } |
106 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 107 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
107 | QSize s = m_menu-> sizeHint ( ); | 108 | QSize s = m_menu-> sizeHint ( ); |
108 | 109 | ||
109 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); | 110 | m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); |
110 | } | 111 | } |
111 | 112 | ||
112 | void ClipboardApplet::action(int id) | 113 | void ClipboardApplet::action(int id) |
113 | { | 114 | { |
114 | ushort unicode = 0; | 115 | ushort unicode = 0; |
115 | int scan = 0; | 116 | int scan = 0; |
116 | 117 | ||
117 | switch ( id ) { | 118 | switch ( id ) { |
118 | case 100: | 119 | case 100: |
119 | unicode = 'X' - '@'; | 120 | unicode = 'X' - '@'; |
120 | scan = Key_X; // Cut | 121 | scan = Key_X; // Cut |
121 | break; | 122 | break; |
122 | case 101: | 123 | case 101: |
123 | unicode = 'C' - '@'; | 124 | unicode = 'C' - '@'; |
124 | scan = Key_C; // Copy | 125 | scan = Key_C; // Copy |
125 | break; | 126 | break; |
126 | case 102: | 127 | case 102: |
127 | unicode = 'V' - '@'; | 128 | unicode = 'V' - '@'; |
128 | scan = Key_V; // Paste | 129 | scan = Key_V; // Paste |
129 | break; | 130 | break; |
130 | 131 | ||
131 | default: | 132 | default: |
132 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { | 133 | if (( id >= 0 ) && ( uint( id ) < m_history. count ( ))) { |
133 | QApplication::clipboard ( )-> setText ( m_history [id] ); | 134 | QApplication::clipboard ( )-> setText ( m_history [id] ); |
134 | 135 | ||
135 | for ( uint i = 0; i < m_history. count ( ); i++ ) | 136 | for ( uint i = 0; i < m_history. count ( ); i++ ) |
136 | m_menu-> setItemChecked ( i, i == uint( id )); | 137 | m_menu-> setItemChecked ( i, i == uint( id )); |
137 | 138 | ||
138 | unicode = 'V' - '@'; | 139 | unicode = 'V' - '@'; |
139 | scan = Key_V; | 140 | scan = Key_V; |
140 | } | 141 | } |
141 | break; | 142 | break; |
142 | } | 143 | } |
143 | 144 | ||
144 | if ( scan ) { | 145 | if ( scan ) { |
145 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); | 146 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, true, false ); |
146 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); | 147 | qwsServer-> sendKeyEvent ( unicode, scan, ControlButton, false, false ); |
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | void ClipboardApplet::paintEvent ( QPaintEvent* ) | 151 | void ClipboardApplet::paintEvent ( QPaintEvent* ) |
151 | { | 152 | { |
152 | QPainter p ( this ); | 153 | QPainter p ( this ); |
153 | /* center the height but our pixmap is as big as the height ;)*/ | 154 | /* center the height but our pixmap is as big as the height ;)*/ |
154 | p. drawPixmap( 0, 0, | 155 | p. drawPixmap( 0, 0, |
155 | m_clipboardPixmap ); | 156 | m_clipboardPixmap ); |
156 | } | 157 | } |
157 | 158 | ||
158 | void ClipboardApplet::newData ( ) | 159 | void ClipboardApplet::newData ( ) |
159 | { | 160 | { |
160 | static bool excllock = false; | 161 | static bool excllock = false; |
161 | 162 | ||
162 | if ( excllock ) | 163 | if ( excllock ) |
163 | return; | 164 | return; |
164 | else | 165 | else |
165 | excllock = true; | 166 | excllock = true; |
166 | 167 | ||
167 | m_timer-> stop ( ); | 168 | m_timer-> stop ( ); |
168 | 169 | ||
169 | QCString type = "plain"; | 170 | QCString type = "plain"; |
170 | QString txt = QApplication::clipboard ( )-> text ( type ); | 171 | QString txt = QApplication::clipboard ( )-> text ( type ); |
171 | 172 | ||
172 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { | 173 | if ( !txt. isEmpty ( ) && !m_history. contains ( txt )) { |
173 | m_history. append ( txt ); | 174 | m_history. append ( txt ); |
174 | 175 | ||
175 | if ( m_history. count ( ) > 5 ) | 176 | if ( m_history. count ( ) > 5 ) |
176 | m_history. remove ( m_history. begin ( )); | 177 | m_history. remove ( m_history. begin ( )); |
177 | 178 | ||
178 | m_dirty = true; | 179 | m_dirty = true; |
179 | } | 180 | } |
180 | 181 | ||
181 | m_timer-> start ( 1500, true ); | 182 | m_timer-> start ( 1500, true ); |
182 | 183 | ||
183 | excllock = false; | 184 | excllock = false; |
184 | } | 185 | } |
185 | 186 | ||
186 | Q_EXPORT_INTERFACE() | 187 | EXPORT_OPIE_APPLET_v1( ClipboardApplet ) |
187 | { | 188 | |
188 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ClipboardApplet> ); | ||
189 | } | ||
diff --git a/core/applets/clipboardapplet/config.in b/core/applets/clipboardapplet/config.in index 1205b26..e58d239 100644 --- a/core/applets/clipboardapplet/config.in +++ b/core/applets/clipboardapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config CLIPBOARDAPPLET | 1 | config CLIPBOARDAPPLET |
2 | boolean "opie-clipboardapplet (copy/cut/paste applet)" | 2 | boolean "opie-clipboardapplet (copy/cut/paste applet)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/clockapplet/clock.cpp b/core/applets/clockapplet/clock.cpp index 120a019..3b13d74 100644 --- a/core/applets/clockapplet/clock.cpp +++ b/core/applets/clockapplet/clock.cpp | |||
@@ -1,121 +1,120 @@ | |||
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 "clock.h" | 21 | #include "clock.h" |
22 | 22 | ||
23 | #include <opie2/otaskbarapplet.h> | 23 | #include <opie2/otaskbarapplet.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | using namespace Opie::Ui; | ||
28 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) | 29 | LauncherClock::LauncherClock( QWidget *parent ) : QLabel( parent ) |
29 | { | 30 | { |
30 | // If you want a sunken border around the clock do this: | 31 | // If you want a sunken border around the clock do this: |
31 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 32 | // setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
32 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); | 33 | //setFont( QFont( "Helvetica", , QFont::Normal ) ); |
33 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); | 34 | connect( qApp, SIGNAL( timeChanged() ), this, SLOT( updateTime() ) ); |
34 | connect( qApp, SIGNAL( clockChanged(bool) ), | 35 | connect( qApp, SIGNAL( clockChanged(bool) ), |
35 | this, SLOT( slotClockChanged(bool) ) ); | 36 | this, SLOT( slotClockChanged(bool) ) ); |
36 | readConfig(); | 37 | readConfig(); |
37 | timerId = 0; | 38 | timerId = 0; |
38 | timerEvent( 0 ); | 39 | timerEvent( 0 ); |
39 | show(); | 40 | show(); |
40 | } | 41 | } |
41 | 42 | ||
42 | int LauncherClock::position() | 43 | int LauncherClock::position() |
43 | { | 44 | { |
44 | return 10; | 45 | return 10; |
45 | } | 46 | } |
46 | 47 | ||
47 | void LauncherClock::readConfig() { | 48 | void LauncherClock::readConfig() { |
48 | Config config( "qpe" ); | 49 | Config config( "qpe" ); |
49 | config.setGroup( "Time" ); | 50 | config.setGroup( "Time" ); |
50 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); | 51 | ampmFormat = config.readBoolEntry( "AMPM", TRUE ); |
51 | config.setGroup( "Date" ); | 52 | config.setGroup( "Date" ); |
52 | format = config.readNumEntry("ClockApplet",0); | 53 | format = config.readNumEntry("ClockApplet",0); |
53 | } | 54 | } |
54 | 55 | ||
55 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) | 56 | void LauncherClock::mouseReleaseEvent( QMouseEvent * ) |
56 | { | 57 | { |
57 | QCString setTimeApp; | 58 | QCString setTimeApp; |
58 | setTimeApp="systemtime"; | 59 | setTimeApp="systemtime"; |
59 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); | 60 | QCopEnvelope e("QPE/Application/"+setTimeApp, "raise()"); |
60 | } | 61 | } |
61 | 62 | ||
62 | 63 | ||
63 | void LauncherClock::timerEvent( QTimerEvent *e ) | 64 | void LauncherClock::timerEvent( QTimerEvent *e ) |
64 | { | 65 | { |
65 | if ( !e || e->timerId() == timerId ) { | 66 | if ( !e || e->timerId() == timerId ) { |
66 | killTimer( timerId ); | 67 | killTimer( timerId ); |
67 | changeTime(); | 68 | changeTime(); |
68 | QTime t = QTime::currentTime(); | 69 | QTime t = QTime::currentTime(); |
69 | int ms = (60 - t.second())*1000 - t.msec(); | 70 | int ms = (60 - t.second())*1000 - t.msec(); |
70 | timerId = startTimer( ms ); | 71 | timerId = startTimer( ms ); |
71 | } else { | 72 | } else { |
72 | QLabel::timerEvent( e ); | 73 | QLabel::timerEvent( e ); |
73 | } | 74 | } |
74 | } | 75 | } |
75 | 76 | ||
76 | void LauncherClock::updateTime( void ) | 77 | void LauncherClock::updateTime( void ) |
77 | { | 78 | { |
78 | changeTime(); | 79 | changeTime(); |
79 | } | 80 | } |
80 | 81 | ||
81 | void LauncherClock::changeTime( void ) | 82 | void LauncherClock::changeTime( void ) |
82 | { | 83 | { |
83 | QTime tm = QDateTime::currentDateTime().time(); | 84 | QTime tm = QDateTime::currentDateTime().time(); |
84 | QString s; | 85 | QString s; |
85 | if( ampmFormat ) { | 86 | if( ampmFormat ) { |
86 | int hour = tm.hour(); | 87 | int hour = tm.hour(); |
87 | if (hour == 0) | 88 | if (hour == 0) |
88 | hour = 12; | 89 | hour = 12; |
89 | if (hour > 12) | 90 | if (hour > 12) |
90 | hour -= 12; | 91 | hour -= 12; |
91 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 92 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
92 | (tm.hour() >= 12) ? "PM" : "AM" ); | 93 | (tm.hour() >= 12) ? "PM" : "AM" ); |
93 | } else | 94 | } else |
94 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 95 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
95 | 96 | ||
96 | if (format==1) { | 97 | if (format==1) { |
97 | QDate dm = QDate::currentDate(); | 98 | QDate dm = QDate::currentDate(); |
98 | QString d; | 99 | QString d; |
99 | d.sprintf("%d/%d ", dm.day(), dm.month()); | 100 | d.sprintf("%d/%d ", dm.day(), dm.month()); |
100 | setText( d+s ); | 101 | setText( d+s ); |
101 | } else if (format==2) { | 102 | } else if (format==2) { |
102 | QDate dm = QDate::currentDate(); | 103 | QDate dm = QDate::currentDate(); |
103 | QString d; | 104 | QString d; |
104 | d.sprintf("%d/%d ", dm.month(), dm.day()); | 105 | d.sprintf("%d/%d ", dm.month(), dm.day()); |
105 | setText( d+s ); | 106 | setText( d+s ); |
106 | } else { | 107 | } else { |
107 | setText( s ); | 108 | setText( s ); |
108 | } | 109 | } |
109 | } | 110 | } |
110 | 111 | ||
111 | void LauncherClock::slotClockChanged( bool pm ) | 112 | void LauncherClock::slotClockChanged( bool pm ) |
112 | { | 113 | { |
113 | readConfig(); | 114 | readConfig(); |
114 | updateTime(); | 115 | updateTime(); |
115 | } | 116 | } |
116 | 117 | ||
117 | Q_EXPORT_INTERFACE() | 118 | |
118 | { | 119 | EXPORT_OPIE_APPLET_v1( LauncherClock ) |
119 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<LauncherClock> ); | ||
120 | } | ||
121 | 120 | ||
diff --git a/core/applets/clockapplet/config.in b/core/applets/clockapplet/config.in index 20bd39d..6c32f79 100644 --- a/core/applets/clockapplet/config.in +++ b/core/applets/clockapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config CLOCKAPPLET | 1 | config CLOCKAPPLET |
2 | boolean "opie-clockapplet (Digital clock applet)" | 2 | boolean "opie-clockapplet (Digital clock applet)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/homeapplet/config.in b/core/applets/homeapplet/config.in index 1828da0..53d7882 100644 --- a/core/applets/homeapplet/config.in +++ b/core/applets/homeapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config HOMEAPPLET | 1 | config HOMEAPPLET |
2 | boolean "Home" | 2 | boolean "Home" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/irdaapplet/config.in b/core/applets/irdaapplet/config.in index 56ec664..0976e8f 100644 --- a/core/applets/irdaapplet/config.in +++ b/core/applets/irdaapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config IRDAAPPLET | 1 | config IRDAAPPLET |
2 | boolean "opie-irdaapplet (applet for IR beaming/discovery)" | 2 | boolean "opie-irdaapplet (applet for IR beaming/discovery)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index dde8050..2196d18 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -1,365 +1,363 @@ | |||
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 "irda.h" | 17 | #include "irda.h" |
18 | 18 | ||
19 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/otaskbarapplet.h> | 20 | #include <opie2/otaskbarapplet.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
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 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
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 | //=========================================================================== | 38 | //=========================================================================== |
39 | 39 | ||
40 | using namespace Opie::Ui; | ||
40 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) | 41 | IrdaApplet::IrdaApplet ( QWidget *parent, const char *name ) |
41 | : QWidget ( parent, name ) | 42 | : QWidget ( parent, name ) |
42 | { | 43 | { |
43 | setFixedHeight ( 18 ); | 44 | setFixedHeight ( 18 ); |
44 | setFixedWidth ( 14 ); | 45 | setFixedWidth ( 14 ); |
45 | 46 | ||
46 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); | 47 | m_sockfd = ::socket ( PF_INET, SOCK_DGRAM, IPPROTO_IP ); |
47 | 48 | ||
48 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); | 49 | m_irdaOnPixmap = Resource::loadPixmap( "irdaapplet/irdaon" ); |
49 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); | 50 | m_irdaOffPixmap = Resource::loadPixmap( "irdaapplet/irdaoff" ); |
50 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); | 51 | m_irdaDiscoveryOnPixmap = Resource::loadPixmap( "irdaapplet/magglass" ); |
51 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); | 52 | m_receiveActivePixmap = Resource::loadPixmap( "irdaapplet/receive" ); |
52 | 53 | ||
53 | m_irda_active = false; | 54 | m_irda_active = false; |
54 | m_irda_discovery_active = false; | 55 | m_irda_discovery_active = false; |
55 | m_receive_active = false; | 56 | m_receive_active = false; |
56 | m_receive_state_changed = false; | 57 | m_receive_state_changed = false; |
57 | m_popup = 0; | 58 | m_popup = 0; |
58 | m_wasOn = false; | 59 | m_wasOn = false; |
59 | m_wasDiscover = false; | 60 | m_wasDiscover = false; |
60 | 61 | ||
61 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); | 62 | QCopChannel* chan = new QCopChannel("QPE/IrDaApplet", this ); |
62 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), | 63 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
63 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); | 64 | this, SLOT(slotMessage(const QCString&,const QByteArray&) ) ); |
64 | } | 65 | } |
65 | 66 | ||
66 | int IrdaApplet::position() | 67 | int IrdaApplet::position() |
67 | { | 68 | { |
68 | return 6; | 69 | return 6; |
69 | } | 70 | } |
70 | 71 | ||
71 | void IrdaApplet::show() | 72 | void IrdaApplet::show() |
72 | { | 73 | { |
73 | QWidget::show ( ); | 74 | QWidget::show ( ); |
74 | startTimer ( 2000 ); | 75 | startTimer ( 2000 ); |
75 | } | 76 | } |
76 | 77 | ||
77 | IrdaApplet::~IrdaApplet() | 78 | IrdaApplet::~IrdaApplet() |
78 | { | 79 | { |
79 | if ( m_sockfd >= 0 ) | 80 | if ( m_sockfd >= 0 ) |
80 | ::close ( m_sockfd ); | 81 | ::close ( m_sockfd ); |
81 | } | 82 | } |
82 | 83 | ||
83 | void IrdaApplet::popup ( QString message, QString icon ) | 84 | void IrdaApplet::popup ( QString message, QString icon ) |
84 | { | 85 | { |
85 | if ( !m_popup ) | 86 | if ( !m_popup ) |
86 | m_popup = new QPopupMenu ( this ); | 87 | m_popup = new QPopupMenu ( this ); |
87 | 88 | ||
88 | m_popup-> clear ( ); | 89 | m_popup-> clear ( ); |
89 | 90 | ||
90 | if ( icon. isEmpty ( )) | 91 | if ( icon. isEmpty ( )) |
91 | m_popup-> insertItem ( message, 0 ); | 92 | m_popup-> insertItem ( message, 0 ); |
92 | else | 93 | else |
93 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); | 94 | m_popup-> insertItem ( QIconSet ( Resource::loadPixmap ( icon )), message, 0 ); |
94 | 95 | ||
95 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); | 96 | QPoint p = mapToGlobal ( QPoint ( 0, 0 )); |
96 | QSize s = m_popup-> sizeHint ( ); | 97 | QSize s = m_popup-> sizeHint ( ); |
97 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), | 98 | m_popup-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), |
98 | p. y ( ) - s. height ( ))); | 99 | p. y ( ) - s. height ( ))); |
99 | 100 | ||
100 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); | 101 | QTimer::singleShot ( 2000, this, SLOT( popupTimeout())); |
101 | } | 102 | } |
102 | 103 | ||
103 | void IrdaApplet::popupTimeout ( ) | 104 | void IrdaApplet::popupTimeout ( ) |
104 | { | 105 | { |
105 | m_popup-> hide ( ); | 106 | m_popup-> hide ( ); |
106 | } | 107 | } |
107 | 108 | ||
108 | bool IrdaApplet::checkIrdaStatus ( ) | 109 | bool IrdaApplet::checkIrdaStatus ( ) |
109 | { | 110 | { |
110 | struct ifreq ifr; | 111 | struct ifreq ifr; |
111 | strcpy ( ifr. ifr_name, "irda0" ); | 112 | strcpy ( ifr. ifr_name, "irda0" ); |
112 | 113 | ||
113 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 114 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
114 | return false; | 115 | return false; |
115 | 116 | ||
116 | return ( ifr. ifr_flags & IFF_UP ); | 117 | return ( ifr. ifr_flags & IFF_UP ); |
117 | } | 118 | } |
118 | 119 | ||
119 | bool IrdaApplet::setIrdaStatus ( bool b ) | 120 | bool IrdaApplet::setIrdaStatus ( bool b ) |
120 | { | 121 | { |
121 | struct ifreq ifr; | 122 | struct ifreq ifr; |
122 | strcpy ( ifr. ifr_name, "irda0" ); | 123 | strcpy ( ifr. ifr_name, "irda0" ); |
123 | 124 | ||
124 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) | 125 | if ( ::ioctl ( m_sockfd, SIOCGIFFLAGS, &ifr ) < 0 ) |
125 | return false; | 126 | return false; |
126 | 127 | ||
127 | if ( b ) { | 128 | if ( b ) { |
128 | ifr. ifr_flags |= IFF_UP; | 129 | ifr. ifr_flags |= IFF_UP; |
129 | } | 130 | } |
130 | else { | 131 | else { |
131 | setIrdaDiscoveryStatus ( 0 ); | 132 | setIrdaDiscoveryStatus ( 0 ); |
132 | setIrdaReceiveStatus ( 0 ); | 133 | setIrdaReceiveStatus ( 0 ); |
133 | ifr. ifr_flags &= ~IFF_UP; | 134 | ifr. ifr_flags &= ~IFF_UP; |
134 | } | 135 | } |
135 | 136 | ||
136 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) | 137 | if ( ::ioctl ( m_sockfd, SIOCSIFFLAGS, &ifr ) < 0 ) |
137 | return false; | 138 | return false; |
138 | 139 | ||
139 | return true; | 140 | return true; |
140 | } | 141 | } |
141 | 142 | ||
142 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) | 143 | bool IrdaApplet::checkIrdaDiscoveryStatus ( ) |
143 | { | 144 | { |
144 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 145 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
145 | 146 | ||
146 | QString streamIn = "0"; | 147 | QString streamIn = "0"; |
147 | 148 | ||
148 | if ( discovery. open ( IO_ReadOnly )) { | 149 | if ( discovery. open ( IO_ReadOnly )) { |
149 | QTextStream stream ( &discovery ); | 150 | QTextStream stream ( &discovery ); |
150 | streamIn = stream. read ( ); | 151 | streamIn = stream. read ( ); |
151 | } | 152 | } |
152 | 153 | ||
153 | return streamIn. toInt ( ) > 0; | 154 | return streamIn. toInt ( ) > 0; |
154 | } | 155 | } |
155 | 156 | ||
156 | 157 | ||
157 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) | 158 | bool IrdaApplet::setIrdaDiscoveryStatus ( bool d ) |
158 | { | 159 | { |
159 | QFile discovery ( "/proc/sys/net/irda/discovery" ); | 160 | QFile discovery ( "/proc/sys/net/irda/discovery" ); |
160 | 161 | ||
161 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { | 162 | if ( discovery. open ( IO_WriteOnly | IO_Raw )) { |
162 | discovery.putch ( d ? '1' : '0' ); | 163 | discovery.putch ( d ? '1' : '0' ); |
163 | return true; | 164 | return true; |
164 | } | 165 | } |
165 | return false; | 166 | return false; |
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) | 170 | bool IrdaApplet::setIrdaReceiveStatus ( bool d ) |
170 | { | 171 | { |
171 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); | 172 | QCopEnvelope e ( "QPE/Obex", "receive(int)" ); |
172 | e << ( d ? 1 : 0 ); | 173 | e << ( d ? 1 : 0 ); |
173 | 174 | ||
174 | m_receive_active = d; | 175 | m_receive_active = d; |
175 | m_receive_state_changed = true; | 176 | m_receive_state_changed = true; |
176 | 177 | ||
177 | return true; | 178 | return true; |
178 | } | 179 | } |
179 | 180 | ||
180 | 181 | ||
181 | void IrdaApplet::showDiscovered ( ) | 182 | void IrdaApplet::showDiscovered ( ) |
182 | { | 183 | { |
183 | //static Sound snd_found ( "irdaapplet/irdaon" ); | 184 | //static Sound snd_found ( "irdaapplet/irdaon" ); |
184 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); | 185 | //static Sound snd_lost ( "irdaapplet/irdaoff" ); |
185 | 186 | ||
186 | QFile discovery ( "/proc/net/irda/discovery" ); | 187 | QFile discovery ( "/proc/net/irda/discovery" ); |
187 | 188 | ||
188 | if ( discovery. open ( IO_ReadOnly )) { | 189 | if ( discovery. open ( IO_ReadOnly )) { |
189 | bool qcopsend = false; | 190 | bool qcopsend = false; |
190 | 191 | ||
191 | QString discoveredDevice; | 192 | QString discoveredDevice; |
192 | QString deviceAddr; | 193 | QString deviceAddr; |
193 | 194 | ||
194 | // since it is /proc we _must_ use QTextStream | 195 | // since it is /proc we _must_ use QTextStream |
195 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); | 196 | QStringList list = QStringList::split ( "\n", QTextStream ( &discovery ). read ( )); |
196 | 197 | ||
197 | QMap <QString, QString>::Iterator it; | 198 | QMap <QString, QString>::Iterator it; |
198 | 199 | ||
199 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 200 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
200 | it. data ( ). prepend ( "+++" ); | 201 | it. data ( ). prepend ( "+++" ); |
201 | 202 | ||
202 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { | 203 | for ( QStringList::Iterator lit = list. begin ( ); lit != list. end ( ); ++lit ) { |
203 | const QString &line = *lit; | 204 | const QString &line = *lit; |
204 | 205 | ||
205 | if ( line. startsWith ( "nickname:" )) { | 206 | if ( line. startsWith ( "nickname:" )) { |
206 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); | 207 | discoveredDevice = line. mid ( line. find ( ':' ) + 2, line. find ( ',' ) - line. find ( ':' ) - 2 ); |
207 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); | 208 | deviceAddr = line. mid ( line. find ( "daddr:" ) + 9, 8 ); |
208 | 209 | ||
209 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); | 210 | // qDebug(discoveredDevice + "(" + deviceAddr + ")"); |
210 | 211 | ||
211 | if ( !m_devices. contains ( deviceAddr )) { | 212 | if ( !m_devices. contains ( deviceAddr )) { |
212 | popup ( tr( "Found:" ) + " " + discoveredDevice ); | 213 | popup ( tr( "Found:" ) + " " + discoveredDevice ); |
213 | //snd_found. play ( ); | 214 | //snd_found. play ( ); |
214 | qcopsend = true; | 215 | qcopsend = true; |
215 | } | 216 | } |
216 | m_devices. replace ( deviceAddr, discoveredDevice ); | 217 | m_devices. replace ( deviceAddr, discoveredDevice ); |
217 | } | 218 | } |
218 | } | 219 | } |
219 | 220 | ||
220 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { | 221 | for ( it = m_devices. begin ( ); it != m_devices. end ( ); ) { |
221 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); | 222 | // qDebug("IrdaMon: delete " + it.currentKey() + "=" + *devicesAvailable[it.currentKey()] + "?"); |
222 | 223 | ||
223 | if ( it. data ( ). left ( 3 ) == "+++" ) { | 224 | if ( it. data ( ). left ( 3 ) == "+++" ) { |
224 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); | 225 | popup ( tr( "Lost:" ) + " " + it. data ( ). mid ( 3 )); |
225 | //snd_lost. play ( ); | 226 | //snd_lost. play ( ); |
226 | 227 | ||
227 | QMap <QString, QString>::Iterator tmp = it; | 228 | QMap <QString, QString>::Iterator tmp = it; |
228 | tmp++; | 229 | tmp++; |
229 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator | 230 | m_devices. remove ( it ); // in contrast to QValueListIterator this remove doesn't return the next Iterator |
230 | it = tmp; | 231 | it = tmp; |
231 | 232 | ||
232 | qcopsend = true; | 233 | qcopsend = true; |
233 | } | 234 | } |
234 | else | 235 | else |
235 | it++; | 236 | it++; |
236 | } | 237 | } |
237 | // XXX if( qcopsend ) { | 238 | // XXX if( qcopsend ) { |
238 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); | 239 | QCopEnvelope e ( "QPE/Network", "irdaSend(bool)" ); |
239 | e << ( m_devices. count ( ) > 0 ); | 240 | e << ( m_devices. count ( ) > 0 ); |
240 | // } | 241 | // } |
241 | } | 242 | } |
242 | } | 243 | } |
243 | 244 | ||
244 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) | 245 | void IrdaApplet::mousePressEvent ( QMouseEvent * ) |
245 | { | 246 | { |
246 | QPopupMenu *menu = new QPopupMenu ( this ); | 247 | QPopupMenu *menu = new QPopupMenu ( this ); |
247 | QString cmd; | 248 | QString cmd; |
248 | 249 | ||
249 | /* Refresh active state */ | 250 | /* Refresh active state */ |
250 | timerEvent ( 0 ); | 251 | timerEvent ( 0 ); |
251 | 252 | ||
252 | //menu->insertItem( tr("More..."), 4 ); | 253 | //menu->insertItem( tr("More..."), 4 ); |
253 | 254 | ||
254 | if ( m_irda_active && !m_devices. isEmpty ( )) { | 255 | if ( m_irda_active && !m_devices. isEmpty ( )) { |
255 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); | 256 | menu-> insertItem ( tr( "Discovered Device:" ), 9 ); |
256 | 257 | ||
257 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) | 258 | for ( QMap<QString, QString>::Iterator it = m_devices. begin ( ); it != m_devices. end ( ); ++it ) |
258 | menu-> insertItem ( *it ); | 259 | menu-> insertItem ( *it ); |
259 | 260 | ||
260 | menu-> insertSeparator ( ); | 261 | menu-> insertSeparator ( ); |
261 | } | 262 | } |
262 | 263 | ||
263 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); | 264 | menu-> insertItem ( m_irda_active ? tr( "Disable IrDA" ) : tr( "Enable IrDA" ), 0 ); |
264 | 265 | ||
265 | if ( m_irda_active ) { | 266 | if ( m_irda_active ) { |
266 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); | 267 | menu-> insertItem ( m_irda_discovery_active ? tr( "Disable Discovery" ) : tr( "Enable Discovery" ), 1 ); |
267 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); | 268 | menu-> insertItem ( m_receive_active ? tr( "Disable Receive" ) : tr( "Enable Receive" ), 2 ); |
268 | } | 269 | } |
269 | 270 | ||
270 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); | 271 | QPoint p = mapToGlobal ( QPoint ( 0, 0 ) ); |
271 | QSize s = menu-> sizeHint ( ); | 272 | QSize s = menu-> sizeHint ( ); |
272 | 273 | ||
273 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); | 274 | p = QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )); |
274 | 275 | ||
275 | switch ( menu-> exec ( p )) { | 276 | switch ( menu-> exec ( p )) { |
276 | case 0: | 277 | case 0: |
277 | setIrdaStatus ( !m_irda_active ); | 278 | setIrdaStatus ( !m_irda_active ); |
278 | timerEvent ( 0 ); | 279 | timerEvent ( 0 ); |
279 | break; | 280 | break; |
280 | case 1: | 281 | case 1: |
281 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); | 282 | setIrdaDiscoveryStatus ( !m_irda_discovery_active ); |
282 | timerEvent ( 0 ); | 283 | timerEvent ( 0 ); |
283 | break; | 284 | break; |
284 | case 2: | 285 | case 2: |
285 | setIrdaReceiveStatus ( !m_receive_active ); | 286 | setIrdaReceiveStatus ( !m_receive_active ); |
286 | timerEvent( 0 ); | 287 | timerEvent( 0 ); |
287 | break; | 288 | break; |
288 | } | 289 | } |
289 | 290 | ||
290 | delete menu; | 291 | delete menu; |
291 | } | 292 | } |
292 | 293 | ||
293 | void IrdaApplet::timerEvent ( QTimerEvent * ) | 294 | void IrdaApplet::timerEvent ( QTimerEvent * ) |
294 | { | 295 | { |
295 | bool oldactive = m_irda_active; | 296 | bool oldactive = m_irda_active; |
296 | bool olddiscovery = m_irda_discovery_active; | 297 | bool olddiscovery = m_irda_discovery_active; |
297 | bool receiveUpdate = false; | 298 | bool receiveUpdate = false; |
298 | 299 | ||
299 | if ( m_receive_state_changed ) { | 300 | if ( m_receive_state_changed ) { |
300 | receiveUpdate = true; | 301 | receiveUpdate = true; |
301 | m_receive_state_changed = false; | 302 | m_receive_state_changed = false; |
302 | } | 303 | } |
303 | 304 | ||
304 | m_irda_active = checkIrdaStatus ( ); | 305 | m_irda_active = checkIrdaStatus ( ); |
305 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); | 306 | m_irda_discovery_active = checkIrdaDiscoveryStatus ( ); |
306 | 307 | ||
307 | if ( m_irda_discovery_active ) | 308 | if ( m_irda_discovery_active ) |
308 | showDiscovered ( ); | 309 | showDiscovered ( ); |
309 | 310 | ||
310 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) | 311 | if (( m_irda_active != oldactive ) || ( m_irda_discovery_active != olddiscovery ) || receiveUpdate ) |
311 | update ( ); | 312 | update ( ); |
312 | } | 313 | } |
313 | 314 | ||
314 | void IrdaApplet::paintEvent ( QPaintEvent * ) | 315 | void IrdaApplet::paintEvent ( QPaintEvent * ) |
315 | { | 316 | { |
316 | QPainter p ( this ); | 317 | QPainter p ( this ); |
317 | 318 | ||
318 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); | 319 | p. drawPixmap ( 0, 1, m_irda_active ? m_irdaOnPixmap : m_irdaOffPixmap ); |
319 | 320 | ||
320 | if ( m_irda_discovery_active ) | 321 | if ( m_irda_discovery_active ) |
321 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); | 322 | p. drawPixmap( 0, 1, m_irdaDiscoveryOnPixmap ); |
322 | 323 | ||
323 | if ( m_receive_active ) | 324 | if ( m_receive_active ) |
324 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); | 325 | p. drawPixmap( 0, 1, m_receiveActivePixmap ); |
325 | } | 326 | } |
326 | /* | 327 | /* |
327 | * We know 3 calls | 328 | * We know 3 calls |
328 | * a) enable | 329 | * a) enable |
329 | * b) disable | 330 | * b) disable |
330 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on | 331 | * a and b will temp enable the IrDa device and disable will disable it again if it wasn't on |
331 | * c) listDevices: We will return a list of known devices | 332 | * c) listDevices: We will return a list of known devices |
332 | */ | 333 | */ |
333 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { | 334 | void IrdaApplet::slotMessage( const QCString& str, const QByteArray& ar ) { |
334 | if ( str == "enableIrda()") { | 335 | if ( str == "enableIrda()") { |
335 | m_wasOn = checkIrdaStatus(); | 336 | m_wasOn = checkIrdaStatus(); |
336 | m_wasDiscover = checkIrdaDiscoveryStatus(); | 337 | m_wasDiscover = checkIrdaDiscoveryStatus(); |
337 | if (!m_wasOn) { | 338 | if (!m_wasOn) { |
338 | setIrdaStatus( true ); | 339 | setIrdaStatus( true ); |
339 | } | 340 | } |
340 | if ( !m_wasDiscover ) { | 341 | if ( !m_wasDiscover ) { |
341 | setIrdaDiscoveryStatus ( true ); | 342 | setIrdaDiscoveryStatus ( true ); |
342 | } | 343 | } |
343 | } else if ( str == "disableIrda()") { | 344 | } else if ( str == "disableIrda()") { |
344 | if (!m_wasOn) { | 345 | if (!m_wasOn) { |
345 | setIrdaStatus( false ); | 346 | setIrdaStatus( false ); |
346 | } | 347 | } |
347 | if ( !m_wasDiscover ) { | 348 | if ( !m_wasDiscover ) { |
348 | setIrdaDiscoveryStatus ( false ); | 349 | setIrdaDiscoveryStatus ( false ); |
349 | } | 350 | } |
350 | } else if ( str == "listDevices()") { | 351 | } else if ( str == "listDevices()") { |
351 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); | 352 | QCopEnvelope e("QPE/IrDaAppletBack", "devices(QStringList)"); |
352 | 353 | ||
353 | QStringList list; | 354 | QStringList list; |
354 | QMap<QString, QString>::Iterator it; | 355 | QMap<QString, QString>::Iterator it; |
355 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) | 356 | for (it = m_devices.begin(); it != m_devices.end(); ++it ) |
356 | list << (*it); | 357 | list << (*it); |
357 | 358 | ||
358 | e << list; | 359 | e << list; |
359 | } | 360 | } |
360 | } | 361 | } |
361 | 362 | ||
362 | Q_EXPORT_INTERFACE() | 363 | EXPORT_OPIE_APPLET_v1( IrdaApplet ) |
363 | { | ||
364 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<IrdaApplet> ); | ||
365 | } | ||
diff --git a/core/applets/logoutapplet/config.in b/core/applets/logoutapplet/config.in index 385b02f..0d48c6a 100644 --- a/core/applets/logoutapplet/config.in +++ b/core/applets/logoutapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config LOGOUTAPPLET | 1 | config LOGOUTAPPLET |
2 | boolean "Logout" | 2 | boolean "Logout" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/multikeyapplet/multikey.cpp b/core/applets/multikeyapplet/multikey.cpp index fc5f093..195ada5 100644 --- a/core/applets/multikeyapplet/multikey.cpp +++ b/core/applets/multikeyapplet/multikey.cpp | |||
@@ -1,143 +1,142 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru | 2 | ** Copyright (C) 2004 Anton Kachalov mouse@altlinux.ru |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "multikey.h" | 15 | #include "multikey.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/otaskbarapplet.h> | 18 | #include <opie2/otaskbarapplet.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/qpeapplication.h> | ||
20 | 21 | ||
21 | /* QT */ | 22 | /* QT */ |
22 | #include <qdir.h> | 23 | #include <qdir.h> |
23 | 24 | ||
25 | using namespace Opie::Ui; | ||
24 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") | 26 | Multikey::Multikey(QWidget *parent) : QLabel(parent), popupMenu(this), current("EN") |
25 | { | 27 | { |
26 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); | 28 | QCopChannel* swChannel = new QCopChannel("MultiKey/Switcher", this); |
27 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 29 | connect( swChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
28 | this, SLOT(message(const QCString&,const QByteArray&))); | 30 | this, SLOT(message(const QCString&,const QByteArray&))); |
29 | 31 | ||
30 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); | 32 | setFont( QFont( "Helvetica", 10, QFont::Normal ) ); |
31 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); | 33 | QPEApplication::setStylusOperation(this, QPEApplication::RightOnHold); |
32 | lang = 0; | 34 | lang = 0; |
33 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); | 35 | QCopEnvelope e("MultiKey/Keyboard", "getmultikey()"); |
34 | setText("EN"); | 36 | setText("EN"); |
35 | popupMenu.insertItem("EN", 0); | 37 | popupMenu.insertItem("EN", 0); |
36 | show(); | 38 | show(); |
37 | } | 39 | } |
38 | 40 | ||
39 | void Multikey::mousePressEvent(QMouseEvent *ev) | 41 | void Multikey::mousePressEvent(QMouseEvent *ev) |
40 | { | 42 | { |
41 | if (!sw_maps.count()) | 43 | if (!sw_maps.count()) |
42 | return; | 44 | return; |
43 | 45 | ||
44 | if (ev->button() == RightButton) { | 46 | if (ev->button() == RightButton) { |
45 | 47 | ||
46 | QPoint p = mapToGlobal(QPoint(0, 0)); | 48 | QPoint p = mapToGlobal(QPoint(0, 0)); |
47 | QSize s = popupMenu.sizeHint(); | 49 | QSize s = popupMenu.sizeHint(); |
48 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), | 50 | int opt = popupMenu.exec(QPoint(p.x() + (width() / 2) - (s.width() / 2), |
49 | p.y() - s.height()), 0); | 51 | p.y() - s.height()), 0); |
50 | 52 | ||
51 | if (opt == -1) | 53 | if (opt == -1) |
52 | return; | 54 | return; |
53 | lang = opt; | 55 | lang = opt; |
54 | 56 | ||
55 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 57 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
56 | e << sw_maps[lang]; | 58 | e << sw_maps[lang]; |
57 | setText(labels[lang]); | 59 | setText(labels[lang]); |
58 | } | 60 | } |
59 | QWidget::mousePressEvent(ev); | 61 | QWidget::mousePressEvent(ev); |
60 | } | 62 | } |
61 | 63 | ||
62 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) | 64 | void Multikey::mouseReleaseEvent(QMouseEvent *ev) |
63 | { | 65 | { |
64 | if (!sw_maps.count()) | 66 | if (!sw_maps.count()) |
65 | return; | 67 | return; |
66 | 68 | ||
67 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; | 69 | lang = lang < sw_maps.count()-1 ? lang+1 : 0; |
68 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); | 70 | QCopEnvelope e("MultiKey/Keyboard", "setmultikey(QString)"); |
69 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); | 71 | //qDebug("Lang=%d, count=%d, lab=%s", lang, sw_maps.count(), labels[lang].ascii()); |
70 | e << sw_maps[lang]; | 72 | e << sw_maps[lang]; |
71 | setText(labels[lang]); | 73 | setText(labels[lang]); |
72 | } | 74 | } |
73 | 75 | ||
74 | void Multikey::message(const QCString &message, const QByteArray &data) | 76 | void Multikey::message(const QCString &message, const QByteArray &data) |
75 | { | 77 | { |
76 | if ( message == "setsw(QString,QString)" ) { | 78 | if ( message == "setsw(QString,QString)" ) { |
77 | 79 | ||
78 | QDataStream stream(data, IO_ReadOnly); | 80 | QDataStream stream(data, IO_ReadOnly); |
79 | QString maps, current_map; | 81 | QString maps, current_map; |
80 | stream >> maps >> current_map; | 82 | stream >> maps >> current_map; |
81 | QStringList sw = QStringList::split(QChar('|'), maps); | 83 | QStringList sw = QStringList::split(QChar('|'), maps); |
82 | sw.append(current_map); | 84 | sw.append(current_map); |
83 | 85 | ||
84 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); | 86 | QDir map_dir(QPEApplication::qpeDir() + "/share/multikey/", "*.keymap"); |
85 | lang = 0; | 87 | lang = 0; |
86 | labels.clear(); | 88 | labels.clear(); |
87 | sw_maps.clear(); | 89 | sw_maps.clear(); |
88 | popupMenu.clear(); | 90 | popupMenu.clear(); |
89 | 91 | ||
90 | for (uint i = 0; i < sw.count(); ++i) { | 92 | for (uint i = 0; i < sw.count(); ++i) { |
91 | QString keymap_map; | 93 | QString keymap_map; |
92 | if (sw[i][0] != '/') { | 94 | if (sw[i][0] != '/') { |
93 | 95 | ||
94 | keymap_map = map_dir.absPath() + "/" + sw[i]; | 96 | keymap_map = map_dir.absPath() + "/" + sw[i]; |
95 | } else { | 97 | } else { |
96 | 98 | ||
97 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) | 99 | if ((map_dir.exists(QFileInfo(sw[i]).fileName(), false) |
98 | && i != sw.count()-1) || !QFile::exists(sw[i])) { | 100 | && i != sw.count()-1) || !QFile::exists(sw[i])) { |
99 | continue; | 101 | continue; |
100 | } | 102 | } |
101 | keymap_map = sw[i]; | 103 | keymap_map = sw[i]; |
102 | } | 104 | } |
103 | 105 | ||
104 | QFile map(keymap_map); | 106 | QFile map(keymap_map); |
105 | if (map.open(IO_ReadOnly)) { | 107 | if (map.open(IO_ReadOnly)) { |
106 | QString line; | 108 | QString line; |
107 | 109 | ||
108 | map.readLine(line, 1024); | 110 | map.readLine(line, 1024); |
109 | while (!map.atEnd()) { | 111 | while (!map.atEnd()) { |
110 | 112 | ||
111 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { | 113 | if (line.find(QRegExp("^sw\\s*=\\s*")) != -1) { |
112 | 114 | ||
113 | if (i != sw.count()-1) { | 115 | if (i != sw.count()-1) { |
114 | if (keymap_map == current_map) { | 116 | if (keymap_map == current_map) { |
115 | lang = i; | 117 | lang = i; |
116 | } | 118 | } |
117 | sw_maps.append(keymap_map); | 119 | sw_maps.append(keymap_map); |
118 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); | 120 | labels.append(line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace()); |
119 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); | 121 | popupMenu.insertItem(labels[labels.count()-1], labels.count()-1); |
120 | } else { | 122 | } else { |
121 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); | 123 | current = line.right(line.length() - line.find(QChar('=')) - 1).stripWhiteSpace(); |
122 | } | 124 | } |
123 | break; | 125 | break; |
124 | } | 126 | } |
125 | map.readLine(line, 1024); | 127 | map.readLine(line, 1024); |
126 | } | 128 | } |
127 | map.close(); | 129 | map.close(); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | 132 | ||
131 | setText(current); | 133 | setText(current); |
132 | } | 134 | } |
133 | } | 135 | } |
134 | 136 | ||
135 | int Multikey::position() | 137 | int Multikey::position() |
136 | { | 138 | { |
137 | return 10; | 139 | return 10; |
138 | } | 140 | } |
139 | 141 | ||
140 | Q_EXPORT_INTERFACE() | 142 | EXPORT_OPIE_APPLET_v1( Multikey ) |
141 | { | ||
142 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<Multikey> ); | ||
143 | } | ||
diff --git a/core/applets/restartapplet/config.in b/core/applets/restartapplet/config.in index aa2580f..764ae58 100644 --- a/core/applets/restartapplet/config.in +++ b/core/applets/restartapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config RESTARTAPPLET | 1 | config RESTARTAPPLET |
2 | boolean "opie-restartapplet (Restart Opie via taskbar)" | 2 | boolean "opie-restartapplet (Restart Opie via taskbar)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/rotateapplet/config.in b/core/applets/rotateapplet/config.in index 1a0d923..d3de89a 100644 --- a/core/applets/rotateapplet/config.in +++ b/core/applets/rotateapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config ROTATEAPPLET | 1 | config ROTATEAPPLET |
2 | boolean "Rotate" | 2 | boolean "Rotate" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index 0488c36..f621aa9 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -1,252 +1,252 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> | 3 | Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> |
4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> | 4 | Copyright (C) 2003 Greg Gilbert <ggilbert@treke.net> |
5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> | 5 | =. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This library is free software; you can | 8 | _;:, .> :=|. This library is free software; you can |
9 | .> <, > . <= redistribute it and/or modify it under | 9 | .> <, > . <= redistribute it and/or modify it under |
10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%+i> _;_. | 14 | .%+i> _;_. |
15 | .i_,=:_. -<s. This library is distributed in the hope that | 15 | .i_,=:_. -<s. This library is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. . .: details. | 21 | ++= -. . .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-= this library; see the file COPYING.LIB. | 25 | -- :-= this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "rotate.h" | 31 | #include "rotate.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie/odevice.h> | 34 | #include <opie2/odevice.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 36 | #include <qpe/power.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | using namespace Opie; | 39 | using namespace Opie::Core; |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | 42 | ||
43 | #include <time.h> | 43 | #include <time.h> |
44 | 44 | ||
45 | RotateApplet::RotateApplet() | 45 | RotateApplet::RotateApplet() |
46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) | 46 | :QObject( 0, "RotateApplet" ), m_flipped( false ) |
47 | { | 47 | { |
48 | 48 | ||
49 | #if !defined(QT_NO_COP) | 49 | #if !defined(QT_NO_COP) |
50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); | 50 | QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); |
51 | connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 51 | connect ( rotateChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
52 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); | 52 | this, SLOT ( channelReceived(const QCString&,const QByteArray&) ) ); |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | } | 55 | } |
56 | 56 | ||
57 | RotateApplet::~RotateApplet ( ) | 57 | RotateApplet::~RotateApplet ( ) |
58 | {} | 58 | {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * Qcop receive method. | 61 | * Qcop receive method. |
62 | */ | 62 | */ |
63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) | 63 | void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) |
64 | { | 64 | { |
65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); | 65 | qDebug( "RotateApplet::channelReceived( '%s' )", (const char*) msg ); |
66 | 66 | ||
67 | if ( ODevice::inst()->hasHingeSensor() ) | 67 | if ( ODevice::inst()->hasHingeSensor() ) |
68 | { | 68 | { |
69 | struct timespec interval; | 69 | struct timespec interval; |
70 | struct timespec remain; | 70 | struct timespec remain; |
71 | interval.tv_sec = 0; | 71 | interval.tv_sec = 0; |
72 | interval.tv_nsec = 600000; | 72 | interval.tv_nsec = 600000; |
73 | ::nanosleep( &interval, &remain ); | 73 | ::nanosleep( &interval, &remain ); |
74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); | 74 | OHingeStatus status = ODevice::inst()->readHingeSensor(); |
75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); | 75 | qDebug( "RotateApplet::readHingeSensor = %d", (int) status ); |
76 | 76 | ||
77 | Config cfg( "apm" ); | 77 | Config cfg( "apm" ); |
78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); | 78 | cfg.setGroup( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ? "AC" : "Battery" ); |
79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); | 79 | int action = cfg.readNumEntry( "CloseHingeAction", 0 ); |
80 | 80 | ||
81 | if ( status == CASE_CLOSED ) | 81 | if ( status == CASE_CLOSED ) |
82 | { | 82 | { |
83 | switch ( action ) | 83 | switch ( action ) |
84 | { | 84 | { |
85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; | 85 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 0 ); break; |
86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; | 86 | case 2: /* SUSPEND */ ODevice::inst()->suspend(); break; |
87 | default: /* IGNORE */ break; | 87 | default: /* IGNORE */ break; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | else /* status != CASE_CLOSED */ | 90 | else /* status != CASE_CLOSED */ |
91 | { | 91 | { |
92 | switch ( action ) | 92 | switch ( action ) |
93 | { | 93 | { |
94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; | 94 | case 1: /* DISPLAY OFF */ ODevice::inst()->setDisplayBrightness( 127 ); break; |
95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; | 95 | case 2: /* SUSPEND */ /* How to wake up the device from kernel? */; break; |
96 | default: /* IGNORE */ break; | 96 | default: /* IGNORE */ break; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); | 99 | qDebug( "RotateApplet::switchAction %d performed.", cfg.readNumEntry( "CloseHingeAction", 0 ) ); |
100 | } | 100 | } |
101 | 101 | ||
102 | QDataStream stream( data, IO_ReadOnly ); | 102 | QDataStream stream( data, IO_ReadOnly ); |
103 | if ( msg == "flip()" ) | 103 | if ( msg == "flip()" ) |
104 | { | 104 | { |
105 | activated ( ); | 105 | activated ( ); |
106 | } | 106 | } |
107 | else if ( msg == "rotateDefault()") | 107 | else if ( msg == "rotateDefault()") |
108 | { | 108 | { |
109 | rotateDefault(); | 109 | rotateDefault(); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | int RotateApplet::position() const | 113 | int RotateApplet::position() const |
114 | { | 114 | { |
115 | return 3; | 115 | return 3; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString RotateApplet::name() const | 118 | QString RotateApplet::name() const |
119 | { | 119 | { |
120 | return tr( "Rotate shortcut" ); | 120 | return tr( "Rotate shortcut" ); |
121 | } | 121 | } |
122 | 122 | ||
123 | QString RotateApplet::text() const | 123 | QString RotateApplet::text() const |
124 | { | 124 | { |
125 | return tr( "Rotate" ); | 125 | return tr( "Rotate" ); |
126 | } | 126 | } |
127 | 127 | ||
128 | /*QString RotateApplet::tr( const char* s ) const | 128 | /*QString RotateApplet::tr( const char* s ) const |
129 | { | 129 | { |
130 | return qApp->translate( "RotateApplet", s, 0 ); | 130 | return qApp->translate( "RotateApplet", s, 0 ); |
131 | } | 131 | } |
132 | 132 | ||
133 | QString RotateApplet::tr( const char* s, const char* p ) const | 133 | QString RotateApplet::tr( const char* s, const char* p ) const |
134 | { | 134 | { |
135 | return qApp->translate( "RotateApplet", s, p ); | 135 | return qApp->translate( "RotateApplet", s, p ); |
136 | } | 136 | } |
137 | */ | 137 | */ |
138 | 138 | ||
139 | QIconSet RotateApplet::icon() const | 139 | QIconSet RotateApplet::icon() const |
140 | { | 140 | { |
141 | QPixmap pix; | 141 | QPixmap pix; |
142 | QImage img = Resource::loadImage( "Rotation" ); | 142 | QImage img = Resource::loadImage( "Rotation" ); |
143 | if ( !img.isNull() ) | 143 | if ( !img.isNull() ) |
144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); | 144 | pix.convertFromImage( img.smoothScale( 14, 14 ) ); |
145 | return pix; | 145 | return pix; |
146 | } | 146 | } |
147 | 147 | ||
148 | QPopupMenu* RotateApplet::popup(QWidget*) const | 148 | QPopupMenu* RotateApplet::popup(QWidget*) const |
149 | { | 149 | { |
150 | return 0; | 150 | return 0; |
151 | } | 151 | } |
152 | 152 | ||
153 | void RotateApplet::rotateDefault() | 153 | void RotateApplet::rotateDefault() |
154 | { | 154 | { |
155 | int rot = ODevice::inst()->rotation(); | 155 | int rot = ODevice::inst()->rotation(); |
156 | 156 | ||
157 | switch (rot) | 157 | switch (rot) |
158 | { | 158 | { |
159 | case Rot0: rot=0; break; | 159 | case Rot0: rot=0; break; |
160 | case Rot90: rot=90; break; | 160 | case Rot90: rot=90; break; |
161 | case Rot180: rot=180; break; | 161 | case Rot180: rot=180; break; |
162 | case Rot270: rot=270; break; | 162 | case Rot270: rot=270; break; |
163 | default: rot=0; break; | 163 | default: rot=0; break; |
164 | } | 164 | } |
165 | 165 | ||
166 | Config cfg( "qpe" ); | 166 | Config cfg( "qpe" ); |
167 | cfg.setGroup( "Appearance" ); | 167 | cfg.setGroup( "Appearance" ); |
168 | 168 | ||
169 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); | 169 | bool rotateEnabled = cfg.readBoolEntry( "rotateEnabled",true ); |
170 | 170 | ||
171 | if ( !rotateEnabled) return; | 171 | if ( !rotateEnabled) return; |
172 | 172 | ||
173 | // hide inputs methods before rotation | 173 | // hide inputs methods before rotation |
174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 174 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
175 | 175 | ||
176 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 176 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
177 | env << rot; | 177 | env << rot; |
178 | 178 | ||
179 | m_flipped = false; | 179 | m_flipped = false; |
180 | 180 | ||
181 | } | 181 | } |
182 | void RotateApplet::activated() | 182 | void RotateApplet::activated() |
183 | { | 183 | { |
184 | int defaultRotation = QPEApplication::defaultRotation(); | 184 | int defaultRotation = QPEApplication::defaultRotation(); |
185 | int newRotation = defaultRotation; | 185 | int newRotation = defaultRotation; |
186 | 186 | ||
187 | Config cfg( "qpe" ); | 187 | Config cfg( "qpe" ); |
188 | cfg.setGroup( "Appearance" ); | 188 | cfg.setGroup( "Appearance" ); |
189 | 189 | ||
190 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 190 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
191 | ODirection rot = CW; | 191 | ODirection rot = CW; |
192 | 192 | ||
193 | if (rotDirection == -1) | 193 | if (rotDirection == -1) |
194 | { | 194 | { |
195 | rot = ODevice::inst()->direction(); | 195 | rot = ODevice::inst()->direction(); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | rot = (ODirection) rotDirection; | 199 | rot = (ODirection) rotDirection; |
200 | } | 200 | } |
201 | 201 | ||
202 | // hide inputs methods before rotation | 202 | // hide inputs methods before rotation |
203 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | 203 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); |
204 | 204 | ||
205 | if ( m_flipped ) | 205 | if ( m_flipped ) |
206 | { | 206 | { |
207 | // if flipped, flip back to the original state, | 207 | // if flipped, flip back to the original state, |
208 | // regardless of rotation direction | 208 | // regardless of rotation direction |
209 | newRotation = defaultRotation; | 209 | newRotation = defaultRotation; |
210 | } | 210 | } |
211 | else | 211 | else |
212 | { | 212 | { |
213 | if ( rot == CCW ) | 213 | if ( rot == CCW ) |
214 | { | 214 | { |
215 | newRotation = ( defaultRotation + 90 ) % 360; | 215 | newRotation = ( defaultRotation + 90 ) % 360; |
216 | } | 216 | } |
217 | else if ( rot == CW ) | 217 | else if ( rot == CW ) |
218 | { | 218 | { |
219 | newRotation = ( defaultRotation + 270 ) % 360; | 219 | newRotation = ( defaultRotation + 270 ) % 360; |
220 | } | 220 | } |
221 | else if ( rot == Flip ) | 221 | else if ( rot == Flip ) |
222 | { | 222 | { |
223 | newRotation = ( defaultRotation + 180 ) % 360; | 223 | newRotation = ( defaultRotation + 180 ) % 360; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | 227 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); |
228 | env << newRotation; | 228 | env << newRotation; |
229 | 229 | ||
230 | m_flipped = !m_flipped; | 230 | m_flipped = !m_flipped; |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 234 | QRESULT RotateApplet::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
235 | { | 235 | { |
236 | *iface = 0; | 236 | *iface = 0; |
237 | if ( uuid == IID_QUnknown ) | 237 | if ( uuid == IID_QUnknown ) |
238 | *iface = this; | 238 | *iface = this; |
239 | else if ( uuid == IID_MenuApplet ) | 239 | else if ( uuid == IID_MenuApplet ) |
240 | *iface = this; | 240 | *iface = this; |
241 | else | 241 | else |
242 | return QS_FALSE; | 242 | return QS_FALSE; |
243 | 243 | ||
244 | if ( *iface ) | 244 | if ( *iface ) |
245 | (*iface)->addRef(); | 245 | (*iface)->addRef(); |
246 | return QS_OK; | 246 | return QS_OK; |
247 | } | 247 | } |
248 | 248 | ||
249 | Q_EXPORT_INTERFACE() | 249 | Q_EXPORT_INTERFACE() |
250 | { | 250 | { |
251 | Q_CREATE_INSTANCE( RotateApplet ) | 251 | Q_CREATE_INSTANCE( RotateApplet ) |
252 | } | 252 | } |
diff --git a/core/applets/rotateapplet/rotateapplet.pro b/core/applets/rotateapplet/rotateapplet.pro index f24682c..7a4420f 100644 --- a/core/applets/rotateapplet/rotateapplet.pro +++ b/core/applets/rotateapplet/rotateapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugn warn_on release | 2 | CONFIG += qt plugn warn_on release |
3 | HEADERS = rotate.h | 3 | HEADERS = rotate.h |
4 | SOURCES = rotate.cpp | 4 | SOURCES = rotate.cpp |
5 | TARGET = rotateapplet | 5 | TARGET = rotateapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe -lopiecore2 |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/applets/screenshotapplet/config.in b/core/applets/screenshotapplet/config.in index cafd470..98f2b61 100644 --- a/core/applets/screenshotapplet/config.in +++ b/core/applets/screenshotapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config SCREENSHOTAPPLET | 1 | config SCREENSHOTAPPLET |
2 | boolean "opie-screenshotapplet (create images from your current display)" | 2 | boolean "opie-screenshotapplet (create images from your current display)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/screenshotapplet/inputDialog.cpp b/core/applets/screenshotapplet/inputDialog.cpp index 73ec773..ce03ec0 100644 --- a/core/applets/screenshotapplet/inputDialog.cpp +++ b/core/applets/screenshotapplet/inputDialog.cpp | |||
@@ -1,64 +1,65 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'inputDialog.ui' | 2 | ** Form implementation generated from reading ui file 'inputDialog.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sat Mar 2 07:55:03 2002 | 4 | ** Created: Sat Mar 2 07:55:03 2002 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "inputDialog.h" | 9 | #include "inputDialog.h" |
10 | 10 | ||
11 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
12 | 12 | ||
13 | #include <opie2/ofiledialog.h> | 13 | #include <opie2/ofiledialog.h> |
14 | 14 | ||
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | 17 | ||
18 | using namespace Opie::Ui; | ||
18 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 19 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
19 | : QDialog( parent, name, modal, fl ) | 20 | : QDialog( parent, name, modal, fl ) |
20 | { | 21 | { |
21 | if ( !name ) | 22 | if ( !name ) |
22 | setName( "InputDialog" ); | 23 | setName( "InputDialog" ); |
23 | resize( 234, 115); | 24 | resize( 234, 115); |
24 | setMaximumSize( QSize( 240, 40)); | 25 | setMaximumSize( QSize( 240, 40)); |
25 | setCaption( tr(name ) ); | 26 | setCaption( tr(name ) ); |
26 | 27 | ||
27 | QPushButton *browserButton; | 28 | QPushButton *browserButton; |
28 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); | 29 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); |
29 | browserButton->setGeometry( QRect( 205, 10, 22, 22)); | 30 | browserButton->setGeometry( QRect( 205, 10, 22, 22)); |
30 | connect( browserButton, SIGNAL(released()),this,SLOT(browse())); | 31 | connect( browserButton, SIGNAL(released()),this,SLOT(browse())); |
31 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 32 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
32 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); | 33 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); |
33 | } | 34 | } |
34 | 35 | ||
35 | /* | 36 | /* |
36 | * Destroys the object and frees any allocated resources | 37 | * Destroys the object and frees any allocated resources |
37 | */ | 38 | */ |
38 | InputDialog::~InputDialog() | 39 | InputDialog::~InputDialog() |
39 | { | 40 | { |
40 | inputText= LineEdit1->text(); | 41 | inputText= LineEdit1->text(); |
41 | 42 | ||
42 | } | 43 | } |
43 | 44 | ||
44 | void InputDialog::browse() { | 45 | void InputDialog::browse() { |
45 | 46 | ||
46 | MimeTypes types; | 47 | MimeTypes types; |
47 | QStringList audio, video, all; | 48 | QStringList audio, video, all; |
48 | audio << "audio/*"; | 49 | audio << "audio/*"; |
49 | audio << "playlist/plain"; | 50 | audio << "playlist/plain"; |
50 | audio << "audio/x-mpegurl"; | 51 | audio << "audio/x-mpegurl"; |
51 | 52 | ||
52 | video << "video/*"; | 53 | video << "video/*"; |
53 | video << "playlist/plain"; | 54 | video << "playlist/plain"; |
54 | 55 | ||
55 | all += audio; | 56 | all += audio; |
56 | all += video; | 57 | all += video; |
57 | types.insert("All Media Files", all ); | 58 | types.insert("All Media Files", all ); |
58 | types.insert("Audio", audio ); | 59 | types.insert("Audio", audio ); |
59 | types.insert("Video", video ); | 60 | types.insert("Video", video ); |
60 | 61 | ||
61 | QString str = Opie::OFileDialog::getOpenFileName( 1,"/","", types, 0 ); | 62 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 1,"/","", types, 0 ); |
62 | LineEdit1->setText(str); | 63 | LineEdit1->setText(str); |
63 | } | 64 | } |
64 | 65 | ||
diff --git a/core/applets/screenshotapplet/screenshot.cpp b/core/applets/screenshotapplet/screenshot.cpp index 20e1c9b..9aa012a 100644 --- a/core/applets/screenshotapplet/screenshot.cpp +++ b/core/applets/screenshotapplet/screenshot.cpp | |||
@@ -1,543 +1,542 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com | 2 | ** Copyright (C) 2002 L.J. Potter ljp@llornkcor.com |
3 | ** All rights reserved. | 3 | ** All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | **********************************************************************/ | 13 | **********************************************************************/ |
14 | 14 | ||
15 | #include "screenshot.h" | 15 | #include "screenshot.h" |
16 | #include "inputDialog.h" | 16 | #include "inputDialog.h" |
17 | 17 | ||
18 | /* OPIE */ | 18 | /* OPIE */ |
19 | #include <opie2/otaskbarapplet.h> | 19 | #include <opie2/otaskbarapplet.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | 22 | ||
23 | /* QT */ | 23 | /* QT */ |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qspinbox.h> | 29 | #include <qspinbox.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | 33 | ||
34 | /* STD */ | 34 | /* STD */ |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <sys/socket.h> | 36 | #include <sys/socket.h> |
37 | #include <netinet/in.h> | 37 | #include <netinet/in.h> |
38 | #include <netdb.h> | 38 | #include <netdb.h> |
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | 40 | ||
41 | /* XPM */ | 41 | /* XPM */ |
42 | using namespace Opie::Ui; | ||
42 | static char * snapshot_xpm[] = { | 43 | static char * snapshot_xpm[] = { |
43 | "32 32 177 2", | 44 | "32 32 177 2", |
44 | " c None", | 45 | " c None", |
45 | ". c #042045", | 46 | ". c #042045", |
46 | "+ c #0D2B47", | 47 | "+ c #0D2B47", |
47 | "@ c #0E325E", | 48 | "@ c #0E325E", |
48 | "# c #0D2E50", | 49 | "# c #0D2E50", |
49 | "$ c #0A1C32", | 50 | "$ c #0A1C32", |
50 | "% c #0F3A69", | 51 | "% c #0F3A69", |
51 | "& c #164680", | 52 | "& c #164680", |
52 | "* c #165EAE", | 53 | "* c #165EAE", |
53 | "= c #134D89", | 54 | "= c #134D89", |
54 | "- c #0A3A6E", | 55 | "- c #0A3A6E", |
55 | "; c #031024", | 56 | "; c #031024", |
56 | "> c #031B36", | 57 | "> c #031B36", |
57 | ", c #1A5EA3", | 58 | ", c #1A5EA3", |
58 | "' c #1862B1", | 59 | "' c #1862B1", |
59 | ") c #1866B9", | 60 | ") c #1866B9", |
60 | "! c #0F5AAC", | 61 | "! c #0F5AAC", |
61 | "~ c #0F56A8", | 62 | "~ c #0F56A8", |
62 | "{ c #0C4C96", | 63 | "{ c #0C4C96", |
63 | "] c #030918", | 64 | "] c #030918", |
64 | "^ c #060206", | 65 | "^ c #060206", |
65 | "/ c #20242C", | 66 | "/ c #20242C", |
66 | "( c #3E3B3B", | 67 | "( c #3E3B3B", |
67 | "_ c #186ABD", | 68 | "_ c #186ABD", |
68 | ": c #115EB3", | 69 | ": c #115EB3", |
69 | "< c #082644", | 70 | "< c #082644", |
70 | "[ c #222C38", | 71 | "[ c #222C38", |
71 | "} c #5A5859", | 72 | "} c #5A5859", |
72 | "| c #091921", | 73 | "| c #091921", |
73 | "1 c #1E7EDE", | 74 | "1 c #1E7EDE", |
74 | "2 c #1A7ADA", | 75 | "2 c #1A7ADA", |
75 | "3 c #1970CD", | 76 | "3 c #1970CD", |
76 | "4 c #1758A1", | 77 | "4 c #1758A1", |
77 | "5 c #0E529A", | 78 | "5 c #0E529A", |
78 | "6 c #094388", | 79 | "6 c #094388", |
79 | "7 c #22364E", | 80 | "7 c #22364E", |
80 | "8 c #384454", | 81 | "8 c #384454", |
81 | "9 c #04162C", | 82 | "9 c #04162C", |
82 | "0 c #123451", | 83 | "0 c #123451", |
83 | "a c #3296B4", | 84 | "a c #3296B4", |
84 | "b c #298AB1", | 85 | "b c #298AB1", |
85 | "c c #2484AC", | 86 | "c c #2484AC", |
86 | "d c #033D86", | 87 | "d c #033D86", |
87 | "e c #033677", | 88 | "e c #033677", |
88 | "f c #072C58", | 89 | "f c #072C58", |
89 | "g c #525862", | 90 | "g c #525862", |
90 | "h c #5E5E5E", | 91 | "h c #5E5E5E", |
91 | "i c #23492A", | 92 | "i c #23492A", |
92 | "j c #4FBD3F", | 93 | "j c #4FBD3F", |
93 | "k c #50B24C", | 94 | "k c #50B24C", |
94 | "l c #51C72E", | 95 | "l c #51C72E", |
95 | "m c #42C64A", | 96 | "m c #42C64A", |
96 | "n c #2686CA", | 97 | "n c #2686CA", |
97 | "o c #0B52A4", | 98 | "o c #0B52A4", |
98 | "p c #054A9A", | 99 | "p c #054A9A", |
99 | "q c #053B7C", | 100 | "q c #053B7C", |
100 | "r c #2B2325", | 101 | "r c #2B2325", |
101 | "s c #6E7070", | 102 | "s c #6E7070", |
102 | "t c #0D240E", | 103 | "t c #0D240E", |
103 | "u c #1E423E", | 104 | "u c #1E423E", |
104 | "v c #468ABE", | 105 | "v c #468ABE", |
105 | "w c #6A8AC2", | 106 | "w c #6A8AC2", |
106 | "x c #7EAA8E", | 107 | "x c #7EAA8E", |
107 | "y c #84BE4E", | 108 | "y c #84BE4E", |
108 | "z c #65C639", | 109 | "z c #65C639", |
109 | "A c #064EA0", | 110 | "A c #064EA0", |
110 | "B c #0A4DA0", | 111 | "B c #0A4DA0", |
111 | "C c #4E5242", | 112 | "C c #4E5242", |
112 | "D c #62362E", | 113 | "D c #62362E", |
113 | "E c #721A1A", | 114 | "E c #721A1A", |
114 | "F c #6E0A0A", | 115 | "F c #6E0A0A", |
115 | "G c #3E0E0E", | 116 | "G c #3E0E0E", |
116 | "H c #6AB85E", | 117 | "H c #6AB85E", |
117 | "I c #7E8ECA", | 118 | "I c #7E8ECA", |
118 | "J c #929CD4", | 119 | "J c #929CD4", |
119 | "K c #9EAECA", | 120 | "K c #9EAECA", |
120 | "L c #9EBEAE", | 121 | "L c #9EBEAE", |
121 | "M c #8EC26A", | 122 | "M c #8EC26A", |
122 | "N c #32A276", | 123 | "N c #32A276", |
123 | "O c #20518C", | 124 | "O c #20518C", |
124 | "P c #46566E", | 125 | "P c #46566E", |
125 | "Q c #614A51", | 126 | "Q c #614A51", |
126 | "R c #AE2A26", | 127 | "R c #AE2A26", |
127 | "S c #C41C1A", | 128 | "S c #C41C1A", |
128 | "T c #CE0A0A", | 129 | "T c #CE0A0A", |
129 | "U c #A60606", | 130 | "U c #A60606", |
130 | "V c #921616", | 131 | "V c #921616", |
131 | "W c #863735", | 132 | "W c #863735", |
132 | "X c #866A66", | 133 | "X c #866A66", |
133 | "Y c #9E9EA2", | 134 | "Y c #9E9EA2", |
134 | "Z c #1E5212", | 135 | "Z c #1E5212", |
135 | "` c #7EC652", | 136 | "` c #7EC652", |
136 | " .c #B2B2F2", | 137 | " .c #B2B2F2", |
137 | "..c #CACAF6", | 138 | "..c #CACAF6", |
138 | "+.c #AECEC6", | 139 | "+.c #AECEC6", |
139 | "@.c #92CE72", | 140 | "@.c #92CE72", |
140 | "#.c #42AA86", | 141 | "#.c #42AA86", |
141 | "$.c #365E96", | 142 | "$.c #365E96", |
142 | "%.c #B82420", | 143 | "%.c #B82420", |
143 | "&.c #E20E0E", | 144 | "&.c #E20E0E", |
144 | "*.c #EF0E0B", | 145 | "*.c #EF0E0B", |
145 | "=.c #566A86", | 146 | "=.c #566A86", |
146 | "-.c #92929A", | 147 | "-.c #92929A", |
147 | ";.c #16260E", | 148 | ";.c #16260E", |
148 | ">.c #2E571A", | 149 | ">.c #2E571A", |
149 | ",.c #7ED64E", | 150 | ",.c #7ED64E", |
150 | "'.c #9ECEB2", | 151 | "'.c #9ECEB2", |
151 | ").c #C6D5EF", | 152 | ").c #C6D5EF", |
152 | "!.c #E2E0FE", | 153 | "!.c #E2E0FE", |
153 | "~.c #A2DE8A", | 154 | "~.c #A2DE8A", |
154 | "{.c #4AAA5B", | 155 | "{.c #4AAA5B", |
155 | "].c #2A6AB2", | 156 | "].c #2A6AB2", |
156 | "^.c #9A7A6E", | 157 | "^.c #9A7A6E", |
157 | "/.c #D25A52", | 158 | "/.c #D25A52", |
158 | "(.c #F62626", | 159 | "(.c #F62626", |
159 | "_.c #FA0206", | 160 | "_.c #FA0206", |
160 | ":.c #DE1E16", | 161 | ":.c #DE1E16", |
161 | "<.c #B63A26", | 162 | "<.c #B63A26", |
162 | "[.c #865A2E", | 163 | "[.c #865A2E", |
163 | "}.c #26568E", | 164 | "}.c #26568E", |
164 | "|.c #435F7D", | 165 | "|.c #435F7D", |
165 | "1.c #7AE246", | 166 | "1.c #7AE246", |
166 | "2.c #96EA6E", | 167 | "2.c #96EA6E", |
167 | "3.c #BEEAAE", | 168 | "3.c #BEEAAE", |
168 | "4.c #D0EADC", | 169 | "4.c #D0EADC", |
169 | "5.c #B6CEFE", | 170 | "5.c #B6CEFE", |
170 | "6.c #9ADE8A", | 171 | "6.c #9ADE8A", |
171 | "7.c #2A609A", | 172 | "7.c #2A609A", |
172 | "8.c #7E623E", | 173 | "8.c #7E623E", |
173 | "9.c #CA7A72", | 174 | "9.c #CA7A72", |
174 | "0.c #F26E6E", | 175 | "0.c #F26E6E", |
175 | "a.c #FE5252", | 176 | "a.c #FE5252", |
176 | "b.c #FA3638", | 177 | "b.c #FA3638", |
177 | "c.c #DA2E28", | 178 | "c.c #DA2E28", |
178 | "d.c #9E3E3A", | 179 | "d.c #9E3E3A", |
179 | "e.c #3E7656", | 180 | "e.c #3E7656", |
180 | "f.c #76CB3A", | 181 | "f.c #76CB3A", |
181 | "g.c #90DE44", | 182 | "g.c #90DE44", |
182 | "h.c #A2EE6A", | 183 | "h.c #A2EE6A", |
183 | "i.c #9EEA9A", | 184 | "i.c #9EEA9A", |
184 | "j.c #92BEDE", | 185 | "j.c #92BEDE", |
185 | "k.c #7ADA7E", | 186 | "k.c #7ADA7E", |
186 | "l.c #5ECE52", | 187 | "l.c #5ECE52", |
187 | "m.c #6A5E52", | 188 | "m.c #6A5E52", |
188 | "n.c #A83238", | 189 | "n.c #A83238", |
189 | "o.c #FA5656", | 190 | "o.c #FA5656", |
190 | "p.c #F29A92", | 191 | "p.c #F29A92", |
191 | "q.c #D29E92", | 192 | "q.c #D29E92", |
192 | "r.c #8A7A62", | 193 | "r.c #8A7A62", |
193 | "s.c #05336B", | 194 | "s.c #05336B", |
194 | "t.c #59C631", | 195 | "t.c #59C631", |
195 | "u.c #8AD23A", | 196 | "u.c #8AD23A", |
196 | "v.c #66E242", | 197 | "v.c #66E242", |
197 | "w.c #1D6FC1", | 198 | "w.c #1D6FC1", |
198 | "x.c #E61212", | 199 | "x.c #E61212", |
199 | "y.c #CA261E", | 200 | "y.c #CA261E", |
200 | "z.c #5A763E", | 201 | "z.c #5A763E", |
201 | "A.c #1E6E9A", | 202 | "A.c #1E6E9A", |
202 | "B.c #023272", | 203 | "B.c #023272", |
203 | "C.c #329696", | 204 | "C.c #329696", |
204 | "D.c #2074B6", | 205 | "D.c #2074B6", |
205 | "E.c #3E4E76", | 206 | "E.c #3E4E76", |
206 | "F.c #5A525E", | 207 | "F.c #5A525E", |
207 | "G.c #425868", | 208 | "G.c #425868", |
208 | "H.c #04448E", | 209 | "H.c #04448E", |
209 | "I.c #28828A", | 210 | "I.c #28828A", |
210 | "J.c #2D8593", | 211 | "J.c #2D8593", |
211 | "K.c #12427A", | 212 | "K.c #12427A", |
212 | "L.c #054696", | 213 | "L.c #054696", |
213 | "M.c #042B5E", | 214 | "M.c #042B5E", |
214 | "N.c #134F95", | 215 | "N.c #134F95", |
215 | "O.c #1E6ABB", | 216 | "O.c #1E6ABB", |
216 | "P.c #1A5E96", | 217 | "P.c #1A5E96", |
217 | "Q.c #022E67", | 218 | "Q.c #022E67", |
218 | "R.c #0C3E7C", | 219 | "R.c #0C3E7C", |
219 | "S.c #023E8A", | 220 | "S.c #023E8A", |
220 | "T.c #021A3E", | 221 | "T.c #021A3E", |
221 | " ", | 222 | " ", |
222 | " ", | 223 | " ", |
223 | " ", | 224 | " ", |
224 | " . + @ # + ", | 225 | " . + @ # + ", |
225 | " $ # % & * * = - # $ ", | 226 | " $ # % & * * = - # $ ", |
226 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", | 227 | "; > % @ = , ' ) ' ! ~ { % @ . ] ^ / ( ", |
227 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", | 228 | "; + ' * ) _ ) ) ' : : ! { { % < . [ ( } ", |
228 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", | 229 | "| @ 1 2 3 _ _ ) ' : : : : 4 5 6 6 # 7 8 } ", |
229 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", | 230 | "9 0 a b b b c _ ) : : ! ! ~ ~ 5 ~ d e f [ 8 g h h } ", |
230 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", | 231 | "| i j k j l m n 3 ) : ! ! ! ~ o o o p 6 q f / r r r s ", |
231 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", | 232 | "t u v w x y y z a 1 3 ' : ! ~ A A B A p = C D E F G ( s ", |
232 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", | 233 | "| u H I J K L M H k N 3 3 : ~ o o 5 O P Q R S T T U V W X Y ", |
233 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", | 234 | "| Z ` J .....+.@.z #.3 _ 3 3 ) $.P W %.S &.*.*.&.S W Q P =.-. ", |
234 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", | 235 | ";.>.,.'.).!.!.).~.,.{.) : ) 3 ].h ^./.(._._._.:.<.[.g }.= & |. ", |
235 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", | 236 | ";.>.1.2.3.4.4.5.6.,.{._ : : : 7.8.9.0.a.b.b.c.d.} e.4 = 6 q # ", |
236 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", | 237 | ";.>.z f.g.h.i.j.k.l.N ) : ! ! 4 m.n.c.o.p.q.r.|.5 { d e e s.. ", |
237 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", | 238 | "t Z l t.f.u.g.1.v.#.w.' : ! ~ ~ 7.|.n.x.y.z.A.A q - e e e B.> ", |
238 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", | 239 | "| 0 c k t.t.l l C.D.) * * ! 5 { B o E.F.F.G.= H.e e e e q B.. ", |
239 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", | 240 | "; + D.I.J.I.I.I.w.) : : * o K.7 - L.= O = }.6 6 e q q e q s.> ", |
240 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", | 241 | "9 + ) ) ) ) ' ' , * : ! ! ! K.< . M.q 6 B N.{ d q e e e e s.9 ", |
241 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", | 242 | "9 # O.) ) ' , , P.* ! ! ! ! = % . . M.e d p L.d B.B.e B.B.Q.9 ", |
242 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", | 243 | "; < ' ' ' ' , , 4 4 ~ ! ! ~ ! 5 e q e e q A H.d q q e e B.Q.9 ", |
243 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", | 244 | "; $ R.K.5 4 4 ' ! ! 4 ~ ! ~ ~ ~ o { B o A A L.S.B.B.B.B.B.Q.> ", |
244 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", | 245 | " ] $ 0 R.= ' ' 4 4 5 4 5 5 o B o B p A A L.d e e B.B.B.Q.9 ", |
245 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", | 246 | " # + - { 4 4 ~ ! o { o L.p p p p p H.S.B.B.s.Q.Q.M.T. ", |
246 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", | 247 | " + s.6 B o o 5 B p L.p p L.p H.q B.Q.Q.Q.Q.M.; ", |
247 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", | 248 | " < # s.- B o B p p L.L.H.L.H.d B.Q.Q.Q.Q.Q.9 ", |
248 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", | 249 | " $ . s.d 6 B A p H.S.L.H.q B.Q.Q.M.M.. ; ", |
249 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", | 250 | " ; 9 . 6 L.p L.d L.H.d Q.M.M.. 9 ; ] ", |
250 | " | > e L.d L.H.e M.. ; ] ] ", | 251 | " | > e L.d L.H.e M.. ; ] ] ", |
251 | " > 9 . S.Q.. ; ] ", | 252 | " > 9 . S.Q.. ; ] ", |
252 | " T.; ] "}; | 253 | " T.; ] "}; |
253 | 254 | ||
254 | static const char *SCAP_hostname = "www.handhelds.org"; | 255 | static const char *SCAP_hostname = "www.handhelds.org"; |
255 | static const int SCAP_port = 80; | 256 | static const int SCAP_port = 80; |
256 | 257 | ||
257 | 258 | ||
258 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) | 259 | ScreenshotControl::ScreenshotControl( QWidget *parent, const char *name ) |
259 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) | 260 | : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) |
260 | { | 261 | { |
261 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 262 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
262 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); | 263 | QVBoxLayout *vbox = new QVBoxLayout ( this, 5, 3 ); |
263 | QHBoxLayout *hbox; | 264 | QHBoxLayout *hbox; |
264 | 265 | ||
265 | hbox = new QHBoxLayout ( vbox ); | 266 | hbox = new QHBoxLayout ( vbox ); |
266 | 267 | ||
267 | QLabel *l = new QLabel ( tr( "Delay" ), this ); | 268 | QLabel *l = new QLabel ( tr( "Delay" ), this ); |
268 | hbox-> addWidget ( l ); | 269 | hbox-> addWidget ( l ); |
269 | 270 | ||
270 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); | 271 | delaySpin = new QSpinBox( 0, 60, 1, this, "Spinner" ); |
271 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 272 | delaySpin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
272 | delaySpin-> setSuffix ( tr( "sec" )); | 273 | delaySpin-> setSuffix ( tr( "sec" )); |
273 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); | 274 | delaySpin-> setFocusPolicy( QWidget::NoFocus ); |
274 | delaySpin-> setValue ( 1 ); | 275 | delaySpin-> setValue ( 1 ); |
275 | hbox-> addWidget ( delaySpin ); | 276 | hbox-> addWidget ( delaySpin ); |
276 | 277 | ||
277 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); | 278 | saveNamedCheck = new QCheckBox ( tr( "Save named" ), this); |
278 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); | 279 | saveNamedCheck-> setFocusPolicy ( QWidget::NoFocus ); |
279 | vbox->addWidget( saveNamedCheck); | 280 | vbox->addWidget( saveNamedCheck); |
280 | 281 | ||
281 | vbox-> addSpacing ( 3 ); | 282 | vbox-> addSpacing ( 3 ); |
282 | 283 | ||
283 | l = new QLabel ( tr( "Save screenshot as..." ), this ); | 284 | l = new QLabel ( tr( "Save screenshot as..." ), this ); |
284 | vbox-> addWidget ( l, AlignCenter ); | 285 | vbox-> addWidget ( l, AlignCenter ); |
285 | 286 | ||
286 | hbox = new QHBoxLayout ( vbox ); | 287 | hbox = new QHBoxLayout ( vbox ); |
287 | 288 | ||
288 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); | 289 | grabItButton = new QPushButton( tr( "File" ), this, "GrabButton" ); |
289 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); | 290 | grabItButton ->setFocusPolicy( QWidget::TabFocus ); |
290 | hbox-> addWidget ( grabItButton ); | 291 | hbox-> addWidget ( grabItButton ); |
291 | 292 | ||
292 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); | 293 | scapButton = new QPushButton( tr( "Scap" ), this, "ScapButton" ); |
293 | scapButton ->setFocusPolicy( QWidget::TabFocus ); | 294 | scapButton ->setFocusPolicy( QWidget::TabFocus ); |
294 | hbox-> addWidget ( scapButton ); | 295 | hbox-> addWidget ( scapButton ); |
295 | 296 | ||
296 | setFixedSize ( sizeHint ( )); | 297 | setFixedSize ( sizeHint ( )); |
297 | setFocusPolicy ( QWidget::NoFocus ); | 298 | setFocusPolicy ( QWidget::NoFocus ); |
298 | 299 | ||
299 | 300 | ||
300 | grabTimer = new QTimer ( this, "grab timer"); | 301 | grabTimer = new QTimer ( this, "grab timer"); |
301 | 302 | ||
302 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); | 303 | connect ( grabTimer, SIGNAL( timeout()), this, SLOT( performGrab())); |
303 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); | 304 | connect ( grabItButton, SIGNAL( clicked()), SLOT( slotGrab())); |
304 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); | 305 | connect ( scapButton, SIGNAL( clicked()), SLOT( slotScap())); |
305 | } | 306 | } |
306 | 307 | ||
307 | void ScreenshotControl::slotGrab() | 308 | void ScreenshotControl::slotGrab() |
308 | { | 309 | { |
309 | buttonPushed = 1; | 310 | buttonPushed = 1; |
310 | hide(); | 311 | hide(); |
311 | 312 | ||
312 | setFileName = FALSE; | 313 | setFileName = FALSE; |
313 | if ( saveNamedCheck->isChecked()) { | 314 | if ( saveNamedCheck->isChecked()) { |
314 | setFileName = TRUE; | 315 | setFileName = TRUE; |
315 | InputDialog *fileDlg; | 316 | InputDialog *fileDlg; |
316 | 317 | ||
317 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); | 318 | fileDlg = new InputDialog( 0 , tr("Name of screenshot "), TRUE, 0); |
318 | fileDlg->exec(); | 319 | fileDlg->exec(); |
319 | fileDlg->raise(); | 320 | fileDlg->raise(); |
320 | QString fileName, list; | 321 | QString fileName, list; |
321 | if ( fileDlg->result() == 1 ) { | 322 | if ( fileDlg->result() == 1 ) { |
322 | fileName = fileDlg->LineEdit1->text(); | 323 | fileName = fileDlg->LineEdit1->text(); |
323 | 324 | ||
324 | if (fileName.find("/", 0, TRUE) == -1) | 325 | if (fileName.find("/", 0, TRUE) == -1) |
325 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; | 326 | FileNamePath = QDir::homeDirPath() + "/Documents/image/png/" + fileName; |
326 | else | 327 | else |
327 | FileNamePath = fileName; | 328 | FileNamePath = fileName; |
328 | 329 | ||
329 | } | 330 | } |
330 | delete fileDlg; | 331 | delete fileDlg; |
331 | } | 332 | } |
332 | 333 | ||
333 | if ( delaySpin->value() ) | 334 | if ( delaySpin->value() ) |
334 | grabTimer->start( delaySpin->value() * 1000, true ); | 335 | grabTimer->start( delaySpin->value() * 1000, true ); |
335 | else | 336 | else |
336 | show(); | 337 | show(); |
337 | } | 338 | } |
338 | 339 | ||
339 | void ScreenshotControl::slotScap() | 340 | void ScreenshotControl::slotScap() |
340 | { | 341 | { |
341 | buttonPushed = 2; | 342 | buttonPushed = 2; |
342 | hide(); | 343 | hide(); |
343 | 344 | ||
344 | if ( delaySpin->value() ) | 345 | if ( delaySpin->value() ) |
345 | grabTimer->start( delaySpin->value() * 1000, true ); | 346 | grabTimer->start( delaySpin->value() * 1000, true ); |
346 | else | 347 | else |
347 | show(); | 348 | show(); |
348 | } | 349 | } |
349 | 350 | ||
350 | 351 | ||
351 | void ScreenshotControl::savePixmap() | 352 | void ScreenshotControl::savePixmap() |
352 | { | 353 | { |
353 | DocLnk lnk; | 354 | DocLnk lnk; |
354 | QString fileName; | 355 | QString fileName; |
355 | 356 | ||
356 | if ( setFileName) { | 357 | if ( setFileName) { |
357 | fileName = FileNamePath; | 358 | fileName = FileNamePath; |
358 | //not sure why this is needed here, but it forgets fileName | 359 | //not sure why this is needed here, but it forgets fileName |
359 | // if this is below the braces | 360 | // if this is below the braces |
360 | 361 | ||
361 | if (fileName.right(3) != "png") | 362 | if (fileName.right(3) != "png") |
362 | fileName = fileName + ".png"; | 363 | fileName = fileName + ".png"; |
363 | lnk.setFile(fileName); //sets File property | 364 | lnk.setFile(fileName); //sets File property |
364 | qDebug("saving file " + fileName); | 365 | qDebug("saving file " + fileName); |
365 | snapshot.save( fileName, "PNG"); | 366 | snapshot.save( fileName, "PNG"); |
366 | QFileInfo fi( fileName); | 367 | QFileInfo fi( fileName); |
367 | lnk.setName( fi.fileName()); //sets file name | 368 | lnk.setName( fi.fileName()); //sets file name |
368 | 369 | ||
369 | if (!lnk.writeLink()) | 370 | if (!lnk.writeLink()) |
370 | qDebug("Writing doclink did not work"); | 371 | qDebug("Writing doclink did not work"); |
371 | } | 372 | } |
372 | else { | 373 | else { |
373 | 374 | ||
374 | fileName = "sc_" + QDateTime::currentDateTime().toString(); | 375 | fileName = "sc_" + QDateTime::currentDateTime().toString(); |
375 | fileName.replace(QRegExp("'"), ""); | 376 | fileName.replace(QRegExp("'"), ""); |
376 | fileName.replace(QRegExp(" "), "_"); | 377 | fileName.replace(QRegExp(" "), "_"); |
377 | fileName.replace(QRegExp(":"), "."); | 378 | fileName.replace(QRegExp(":"), "."); |
378 | fileName.replace(QRegExp(","), ""); | 379 | fileName.replace(QRegExp(","), ""); |
379 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; | 380 | QString dirName = QDir::homeDirPath() + "/Documents/image/png/"; |
380 | 381 | ||
381 | if ( !QDir( dirName).exists() ) { | 382 | if ( !QDir( dirName).exists() ) { |
382 | qDebug("making dir " + dirName); | 383 | qDebug("making dir " + dirName); |
383 | QString msg = "mkdir -p " + dirName; | 384 | QString msg = "mkdir -p " + dirName; |
384 | system(msg.latin1()); | 385 | system(msg.latin1()); |
385 | } | 386 | } |
386 | fileName = dirName + fileName; | 387 | fileName = dirName + fileName; |
387 | if (fileName.right(3) != "png") | 388 | if (fileName.right(3) != "png") |
388 | fileName = fileName + ".png"; | 389 | fileName = fileName + ".png"; |
389 | lnk.setFile(fileName); //sets File property | 390 | lnk.setFile(fileName); //sets File property |
390 | qDebug("saving file " + fileName); | 391 | qDebug("saving file " + fileName); |
391 | snapshot.save( fileName, "PNG"); | 392 | snapshot.save( fileName, "PNG"); |
392 | QFileInfo fi( fileName); | 393 | QFileInfo fi( fileName); |
393 | lnk.setName( fi.fileName()); //sets file name | 394 | lnk.setName( fi.fileName()); //sets file name |
394 | 395 | ||
395 | if (!lnk.writeLink()) | 396 | if (!lnk.writeLink()) |
396 | qDebug("Writing doclink did not work"); | 397 | qDebug("Writing doclink did not work"); |
397 | 398 | ||
398 | } | 399 | } |
399 | 400 | ||
400 | QPEApplication::beep(); | 401 | QPEApplication::beep(); |
401 | } | 402 | } |
402 | 403 | ||
403 | void ScreenshotControl::performGrab() | 404 | void ScreenshotControl::performGrab() |
404 | { | 405 | { |
405 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); | 406 | snapshot = QPixmap::grabWindow( QPEApplication::desktop()->winId(), 0, 0, QApplication::desktop()->width(), QApplication::desktop()->height() ); |
406 | 407 | ||
407 | if (buttonPushed == 1) { | 408 | if (buttonPushed == 1) { |
408 | qDebug("grabbing screen"); | 409 | qDebug("grabbing screen"); |
409 | grabTimer->stop(); | 410 | grabTimer->stop(); |
410 | show(); | 411 | show(); |
411 | qApp->processEvents(); | 412 | qApp->processEvents(); |
412 | savePixmap(); | 413 | savePixmap(); |
413 | } else { | 414 | } else { |
414 | grabTimer->stop(); | 415 | grabTimer->stop(); |
415 | 416 | ||
416 | struct sockaddr_in raddr; | 417 | struct sockaddr_in raddr; |
417 | struct hostent *rhost_info; | 418 | struct hostent *rhost_info; |
418 | int sock = -1; | 419 | int sock = -1; |
419 | bool ok = false; | 420 | bool ok = false; |
420 | 421 | ||
421 | QString displayEnv = getenv("QWS_DISPLAY"); | 422 | QString displayEnv = getenv("QWS_DISPLAY"); |
422 | qDebug(displayEnv); | 423 | qDebug(displayEnv); |
423 | 424 | ||
424 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { | 425 | if(( displayEnv.left(2) != ":0" ) && (!displayEnv.isEmpty())) { |
425 | 426 | ||
426 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { | 427 | if (( rhost_info = (struct hostent *) ::gethostbyname ((char *) SCAP_hostname )) != 0 ) { |
427 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); | 428 | ::memset ( &raddr, 0, sizeof (struct sockaddr_in)); |
428 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); | 429 | ::memcpy ( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); |
429 | raddr. sin_family = rhost_info-> h_addrtype; | 430 | raddr. sin_family = rhost_info-> h_addrtype; |
430 | raddr. sin_port = htons ( SCAP_port ); | 431 | raddr. sin_port = htons ( SCAP_port ); |
431 | 432 | ||
432 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { | 433 | if (( sock = ::socket ( AF_INET, SOCK_STREAM, 0 )) >= 0 ) { |
433 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { | 434 | if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { |
434 | 435 | ||
435 | QString header; | 436 | QString header; |
436 | 437 | ||
437 | QPixmap pix; | 438 | QPixmap pix; |
438 | 439 | ||
439 | QString SCAP_model=""; | 440 | QString SCAP_model=""; |
440 | #warning FIXME: model string should be filled with actual device model | 441 | #warning FIXME: model string should be filled with actual device model |
441 | if( snapshot.width() > 320) | 442 | if( snapshot.width() > 320) |
442 | SCAP_model ="Corgi"; | 443 | SCAP_model ="Corgi"; |
443 | 444 | ||
444 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! | 445 | if(displayEnv == "QVFb:0") {//set this if you plan on using this app in qvfb!! |
445 | pix = snapshot.xForm(QWMatrix().rotate(90)); | 446 | pix = snapshot.xForm(QWMatrix().rotate(90)); |
446 | } else | 447 | } else |
447 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); | 448 | pix = ( snapshot.width() > snapshot.height() ) ? snapshot : snapshot.xForm( QWMatrix().rotate(90) ); |
448 | 449 | ||
449 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it | 450 | QImage img = pix.convertToImage().convertDepth( 16 ); // could make that also depth independent, if hh.org/scap can handle it |
450 | 451 | ||
451 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user | 452 | header = "POST /scap/capture.cgi?%1+%2 HTTP/1.1\n" // 1: model / 2: user |
452 | "Content-length: %3\n" // 3: content length | 453 | "Content-length: %3\n" // 3: content length |
453 | "Content-Type: image/png\n" | 454 | "Content-Type: image/png\n" |
454 | "Host: %4\n" // 4: scap host | 455 | "Host: %4\n" // 4: scap host |
455 | "\n"; | 456 | "\n"; |
456 | 457 | ||
457 | 458 | ||
458 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); | 459 | header = header.arg( SCAP_model).arg( ::getenv( "USER" ) ).arg( img.numBytes() ).arg( SCAP_hostname ); |
459 | qDebug(header); | 460 | qDebug(header); |
460 | 461 | ||
461 | if ( !pix.isNull() ) { | 462 | if ( !pix.isNull() ) { |
462 | const char *ascii = header.latin1( ); | 463 | const char *ascii = header.latin1( ); |
463 | uint ascii_len = ::strlen( ascii ); | 464 | uint ascii_len = ::strlen( ascii ); |
464 | ::write ( sock, ascii, ascii_len ); | 465 | ::write ( sock, ascii, ascii_len ); |
465 | ::write ( sock, img.bits(), img.numBytes() ); | 466 | ::write ( sock, img.bits(), img.numBytes() ); |
466 | 467 | ||
467 | ok = true; | 468 | ok = true; |
468 | } | 469 | } |
469 | } | 470 | } |
470 | ::close ( sock ); | 471 | ::close ( sock ); |
471 | } | 472 | } |
472 | } | 473 | } |
473 | if ( ok ) { | 474 | if ( ok ) { |
474 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); | 475 | QMessageBox::information( 0, tr( "Success" ), QString( "<p>%1</p>" ).arg ( tr( "Screenshot was uploaded to %1" )).arg( SCAP_hostname )); |
475 | } else { | 476 | } else { |
476 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); | 477 | QMessageBox::warning( 0, tr( "Error" ), QString( "<p>%1</p>" ).arg( tr( "Connection to %1 failed." )).arg( SCAP_hostname )); |
477 | } | 478 | } |
478 | } else { | 479 | } else { |
479 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); | 480 | QMessageBox::warning( 0, tr( "Error" ),tr("Please set <b>QWS_DISPLAY</b> environmental variable.")); |
480 | } | 481 | } |
481 | } | 482 | } |
482 | 483 | ||
483 | } | 484 | } |
484 | 485 | ||
485 | 486 | ||
486 | 487 | ||
487 | //=========================================================================== | 488 | //=========================================================================== |
488 | 489 | ||
489 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) | 490 | ScreenshotApplet::ScreenshotApplet( QWidget *parent, const char *name ) |
490 | : QWidget( parent, name ) | 491 | : QWidget( parent, name ) |
491 | { | 492 | { |
492 | setFixedWidth( AppLnk::smallIconSize()); | 493 | setFixedWidth( AppLnk::smallIconSize()); |
493 | 494 | ||
494 | QImage img = (const char **)snapshot_xpm; | 495 | QImage img = (const char **)snapshot_xpm; |
495 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); | 496 | img = img.smoothScale(AppLnk::smallIconSize(), AppLnk::smallIconSize()); |
496 | m_icon.convertFromImage(img); | 497 | m_icon.convertFromImage(img); |
497 | } | 498 | } |
498 | 499 | ||
499 | ScreenshotApplet::~ScreenshotApplet() | 500 | ScreenshotApplet::~ScreenshotApplet() |
500 | { | 501 | { |
501 | } | 502 | } |
502 | 503 | ||
503 | int ScreenshotApplet::position() | 504 | int ScreenshotApplet::position() |
504 | { | 505 | { |
505 | return 6; | 506 | return 6; |
506 | } | 507 | } |
507 | 508 | ||
508 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) | 509 | void ScreenshotApplet::mousePressEvent( QMouseEvent *) |
509 | { | 510 | { |
510 | ScreenshotControl *sc = new ScreenshotControl ( ); | 511 | ScreenshotControl *sc = new ScreenshotControl ( ); |
511 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); | 512 | QPoint curPos = mapToGlobal ( QPoint ( 0, 0 )); |
512 | 513 | ||
513 | // windowPosX is the windows position centered above the applets icon. | 514 | // windowPosX is the windows position centered above the applets icon. |
514 | // If the icon is near the edge of the screen, the window would leave the visible area | 515 | // If the icon is near the edge of the screen, the window would leave the visible area |
515 | // so we check the position against the screen width and correct the difference if needed | 516 | // so we check the position against the screen width and correct the difference if needed |
516 | 517 | ||
517 | int screenWidth = qApp->desktop()->width(); | 518 | int screenWidth = qApp->desktop()->width(); |
518 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; | 519 | int windowPosX = curPos. x ( ) - ( sc-> sizeHint ( ). width ( ) - width ( )) / 2 ; |
519 | int ZwindowPosX, XwindowPosX; | 520 | int ZwindowPosX, XwindowPosX; |
520 | 521 | ||
521 | // the window would be placed beyond the screen wich doesn't look tooo good | 522 | // the window would be placed beyond the screen wich doesn't look tooo good |
522 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { | 523 | if ( (windowPosX + sc-> sizeHint ( ). width ( )) > screenWidth ) { |
523 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; | 524 | XwindowPosX = windowPosX + sc-> sizeHint ( ). width ( ) - screenWidth; |
524 | ZwindowPosX = windowPosX - XwindowPosX - 1; | 525 | ZwindowPosX = windowPosX - XwindowPosX - 1; |
525 | } else { | 526 | } else { |
526 | ZwindowPosX = windowPosX; | 527 | ZwindowPosX = windowPosX; |
527 | } | 528 | } |
528 | 529 | ||
529 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); | 530 | sc-> move ( ZwindowPosX, curPos. y ( ) - sc-> sizeHint ( ). height ( ) ); |
530 | sc-> show ( ); | 531 | sc-> show ( ); |
531 | } | 532 | } |
532 | 533 | ||
533 | void ScreenshotApplet::paintEvent( QPaintEvent* ) | 534 | void ScreenshotApplet::paintEvent( QPaintEvent* ) |
534 | { | 535 | { |
535 | QPainter p ( this ); | 536 | QPainter p ( this ); |
536 | p.drawPixmap( 0,0, m_icon ); | 537 | p.drawPixmap( 0,0, m_icon ); |
537 | } | 538 | } |
538 | 539 | ||
539 | Q_EXPORT_INTERFACE() | 540 | |
540 | { | 541 | EXPORT_OPIE_APPLET_v1( ScreenshotApplet ) |
541 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ScreenshotApplet> ); | ||
542 | } | ||
543 | 542 | ||
diff --git a/core/applets/suspendapplet/config.in b/core/applets/suspendapplet/config.in index fdbe8b3..d75f581 100644 --- a/core/applets/suspendapplet/config.in +++ b/core/applets/suspendapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config SUSPENDAPPLET | 1 | config SUSPENDAPPLET |
2 | boolean "Suspend" | 2 | boolean "Suspend" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/vmemo/config.in b/core/applets/vmemo/config.in index d13492d..356ab16 100644 --- a/core/applets/vmemo/config.in +++ b/core/applets/vmemo/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config VMEMO | 1 | config VMEMO |
2 | boolean "opie-vmemo (take voice memos)" | 2 | boolean "opie-vmemo (take voice memos)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index 27f6015..7dd5b4b 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp | |||
@@ -1,645 +1,644 @@ | |||
1 | /************************************************************************************ | 1 | /************************************************************************************ |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | ************************************************************************************/ | 11 | ************************************************************************************/ |
12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> | 12 | // copyright 2002 Jeremy Cowgar <jc@cowgar.com> |
13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> | 13 | // copyright 2002 and 2003 L.J.Potter <ljp@llornkcor.com> |
14 | 14 | ||
15 | extern "C" { | 15 | extern "C" { |
16 | #include "adpcm.h" | 16 | #include "adpcm.h" |
17 | } | 17 | } |
18 | 18 | ||
19 | #include <unistd.h> | 19 | #include <unistd.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <fcntl.h> | 21 | #include <fcntl.h> |
22 | #include <sys/ioctl.h> | 22 | #include <sys/ioctl.h> |
23 | #include <linux/soundcard.h> | 23 | #include <linux/soundcard.h> |
24 | 24 | ||
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | 26 | ||
27 | typedef struct _waveheader { | 27 | typedef struct _waveheader { |
28 | u_long main_chunk; /* 'RIFF' */ | 28 | u_long main_chunk; /* 'RIFF' */ |
29 | u_long length; /* filelen */ | 29 | u_long length; /* filelen */ |
30 | u_long chunk_type; /* 'WAVE' */ | 30 | u_long chunk_type; /* 'WAVE' */ |
31 | u_long sub_chunk; /* 'fmt ' */ | 31 | u_long sub_chunk; /* 'fmt ' */ |
32 | u_long sc_len; /* length of sub_chunk, =16 | 32 | u_long sc_len; /* length of sub_chunk, =16 |
33 | (chunckSize) format len */ | 33 | (chunckSize) format len */ |
34 | u_short format; /* should be 1 for PCM-code (formatTag) */ | 34 | u_short format; /* should be 1 for PCM-code (formatTag) */ |
35 | 35 | ||
36 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ | 36 | u_short modus; /* 1 Mono, 2 Stereo (channels) */ |
37 | u_long sample_fq; /* samples per second (samplesPerSecond) */ | 37 | u_long sample_fq; /* samples per second (samplesPerSecond) */ |
38 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ | 38 | u_long byte_p_sec; /* avg bytes per second (avgBytePerSecond) */ |
39 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ | 39 | u_short byte_p_spl; /* samplesize; 1 or 2 bytes (blockAlign) */ |
40 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ | 40 | u_short bit_p_spl; /* 8, 12 or 16 bit (bitsPerSample) */ |
41 | 41 | ||
42 | u_long data_chunk; /* 'data' */ | 42 | u_long data_chunk; /* 'data' */ |
43 | 43 | ||
44 | u_long data_length;/* samplecount */ | 44 | u_long data_length;/* samplecount */ |
45 | } WaveHeader; | 45 | } WaveHeader; |
46 | 46 | ||
47 | #define RIFF 0x46464952 | 47 | #define RIFF 0x46464952 |
48 | #define WAVE 0x45564157 | 48 | #define WAVE 0x45564157 |
49 | #define FMT 0x20746D66 | 49 | #define FMT 0x20746D66 |
50 | #define DATA 0x61746164 | 50 | #define DATA 0x61746164 |
51 | #define PCM_CODE 1 | 51 | #define PCM_CODE 1 |
52 | #define WAVE_MONO 1 | 52 | #define WAVE_MONO 1 |
53 | #define WAVE_STEREO 2 | 53 | #define WAVE_STEREO 2 |
54 | 54 | ||
55 | struct adpcm_state encoder_state; | 55 | struct adpcm_state encoder_state; |
56 | //struct adpcm_state decoder_state; | 56 | //struct adpcm_state decoder_state; |
57 | 57 | ||
58 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 58 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
59 | #define WAVE_FORMAT_PCM (0x0001) | 59 | #define WAVE_FORMAT_PCM (0x0001) |
60 | 60 | ||
61 | 61 | ||
62 | #include "vmemo.h" | 62 | #include "vmemo.h" |
63 | 63 | ||
64 | #include <opie2/otaskbarapplet.h> | 64 | #include <opie2/otaskbarapplet.h> |
65 | #include <qpe/qpeapplication.h> | 65 | #include <qpe/qpeapplication.h> |
66 | #include <qpe/config.h> | 66 | #include <qpe/config.h> |
67 | 67 | ||
68 | #include <qpainter.h> | 68 | #include <qpainter.h> |
69 | #include <qmessagebox.h> | 69 | #include <qmessagebox.h> |
70 | 70 | ||
71 | int seq = 0; | 71 | int seq = 0; |
72 | 72 | ||
73 | /* XPM */ | 73 | /* XPM */ |
74 | static char * vmemo_xpm[] = { | 74 | static char * vmemo_xpm[] = { |
75 | "16 16 102 2", | 75 | "16 16 102 2", |
76 | " c None", | 76 | " c None", |
77 | ". c #60636A", | 77 | ". c #60636A", |
78 | "+ c #6E6E72", | 78 | "+ c #6E6E72", |
79 | "@ c #68696E", | 79 | "@ c #68696E", |
80 | "# c #4D525C", | 80 | "# c #4D525C", |
81 | "$ c #6B6C70", | 81 | "$ c #6B6C70", |
82 | "% c #E3E3E8", | 82 | "% c #E3E3E8", |
83 | "& c #EEEEF2", | 83 | "& c #EEEEF2", |
84 | "* c #EAEAEF", | 84 | "* c #EAEAEF", |
85 | "= c #CACAD0", | 85 | "= c #CACAD0", |
86 | "- c #474A51", | 86 | "- c #474A51", |
87 | "; c #171819", | 87 | "; c #171819", |
88 | "> c #9B9B9F", | 88 | "> c #9B9B9F", |
89 | ", c #EBEBF0", | 89 | ", c #EBEBF0", |
90 | "' c #F4F4F7", | 90 | "' c #F4F4F7", |
91 | ") c #F1F1F5", | 91 | ") c #F1F1F5", |
92 | "! c #DEDEE4", | 92 | "! c #DEDEE4", |
93 | "~ c #57575C", | 93 | "~ c #57575C", |
94 | "{ c #010101", | 94 | "{ c #010101", |
95 | "] c #A2A2A6", | 95 | "] c #A2A2A6", |
96 | "^ c #747477", | 96 | "^ c #747477", |
97 | "/ c #B5B5B8", | 97 | "/ c #B5B5B8", |
98 | "( c #AEAEB2", | 98 | "( c #AEAEB2", |
99 | "_ c #69696D", | 99 | "_ c #69696D", |
100 | ": c #525256", | 100 | ": c #525256", |
101 | "< c #181C24", | 101 | "< c #181C24", |
102 | "[ c #97979B", | 102 | "[ c #97979B", |
103 | "} c #A7A7AC", | 103 | "} c #A7A7AC", |
104 | "| c #B0B0B4", | 104 | "| c #B0B0B4", |
105 | "1 c #C8C8D1", | 105 | "1 c #C8C8D1", |
106 | "2 c #75757B", | 106 | "2 c #75757B", |
107 | "3 c #46464A", | 107 | "3 c #46464A", |
108 | "4 c #494A4F", | 108 | "4 c #494A4F", |
109 | "5 c #323234", | 109 | "5 c #323234", |
110 | "6 c #909095", | 110 | "6 c #909095", |
111 | "7 c #39393B", | 111 | "7 c #39393B", |
112 | "8 c #757578", | 112 | "8 c #757578", |
113 | "9 c #87878E", | 113 | "9 c #87878E", |
114 | "0 c #222224", | 114 | "0 c #222224", |
115 | "a c #414144", | 115 | "a c #414144", |
116 | "b c #6A6A6E", | 116 | "b c #6A6A6E", |
117 | "c c #020C16", | 117 | "c c #020C16", |
118 | "d c #6B6B6F", | 118 | "d c #6B6B6F", |
119 | "e c #68686D", | 119 | "e c #68686D", |
120 | "f c #5B5B60", | 120 | "f c #5B5B60", |
121 | "g c #8A8A8F", | 121 | "g c #8A8A8F", |
122 | "h c #6B6B6E", | 122 | "h c #6B6B6E", |
123 | "i c #ADADB2", | 123 | "i c #ADADB2", |
124 | "j c #828289", | 124 | "j c #828289", |
125 | "k c #3E3E41", | 125 | "k c #3E3E41", |
126 | "l c #CFCFD7", | 126 | "l c #CFCFD7", |
127 | "m c #4C4C50", | 127 | "m c #4C4C50", |
128 | "n c #000000", | 128 | "n c #000000", |
129 | "o c #66666A", | 129 | "o c #66666A", |
130 | "p c #505054", | 130 | "p c #505054", |
131 | "q c #838388", | 131 | "q c #838388", |
132 | "r c #A1A1A7", | 132 | "r c #A1A1A7", |
133 | "s c #A9A9AE", | 133 | "s c #A9A9AE", |
134 | "t c #A8A8B0", | 134 | "t c #A8A8B0", |
135 | "u c #5E5E63", | 135 | "u c #5E5E63", |
136 | "v c #3A3A3E", | 136 | "v c #3A3A3E", |
137 | "w c #BDBDC6", | 137 | "w c #BDBDC6", |
138 | "x c #59595E", | 138 | "x c #59595E", |
139 | "y c #76767C", | 139 | "y c #76767C", |
140 | "z c #373738", | 140 | "z c #373738", |
141 | "A c #717174", | 141 | "A c #717174", |
142 | "B c #727278", | 142 | "B c #727278", |
143 | "C c #1C1C1E", | 143 | "C c #1C1C1E", |
144 | "D c #3C3C3F", | 144 | "D c #3C3C3F", |
145 | "E c #ADADB6", | 145 | "E c #ADADB6", |
146 | "F c #54555A", | 146 | "F c #54555A", |
147 | "G c #8B8C94", | 147 | "G c #8B8C94", |
148 | "H c #5A5A5F", | 148 | "H c #5A5A5F", |
149 | "I c #BBBBC3", | 149 | "I c #BBBBC3", |
150 | "J c #C4C4CB", | 150 | "J c #C4C4CB", |
151 | "K c #909098", | 151 | "K c #909098", |
152 | "L c #737379", | 152 | "L c #737379", |
153 | "M c #343437", | 153 | "M c #343437", |
154 | "N c #8F8F98", | 154 | "N c #8F8F98", |
155 | "O c #000407", | 155 | "O c #000407", |
156 | "P c #2D3137", | 156 | "P c #2D3137", |
157 | "Q c #B0B1BC", | 157 | "Q c #B0B1BC", |
158 | "R c #3B3C40", | 158 | "R c #3B3C40", |
159 | "S c #6E6E74", | 159 | "S c #6E6E74", |
160 | "T c #95959C", | 160 | "T c #95959C", |
161 | "U c #74747A", | 161 | "U c #74747A", |
162 | "V c #1D1D1E", | 162 | "V c #1D1D1E", |
163 | "W c #91929A", | 163 | "W c #91929A", |
164 | "X c #42444A", | 164 | "X c #42444A", |
165 | "Y c #22282E", | 165 | "Y c #22282E", |
166 | "Z c #B0B2BC", | 166 | "Z c #B0B2BC", |
167 | "` c #898A90", | 167 | "` c #898A90", |
168 | " . c #65656A", | 168 | " . c #65656A", |
169 | ".. c #999AA2", | 169 | ".. c #999AA2", |
170 | "+. c #52535A", | 170 | "+. c #52535A", |
171 | "@. c #151B21", | 171 | "@. c #151B21", |
172 | "#. c #515257", | 172 | "#. c #515257", |
173 | "$. c #B5B5BE", | 173 | "$. c #B5B5BE", |
174 | "%. c #616167", | 174 | "%. c #616167", |
175 | "&. c #1A1D22", | 175 | "&. c #1A1D22", |
176 | "*. c #000713", | 176 | "*. c #000713", |
177 | "=. c #1F1F21", | 177 | "=. c #1F1F21", |
178 | " ", | 178 | " ", |
179 | " . + @ # ", | 179 | " . + @ # ", |
180 | " $ % & * = - ", | 180 | " $ % & * = - ", |
181 | " ; > , ' ) ! ~ ", | 181 | " ; > , ' ) ! ~ ", |
182 | " { ] ^ / ( _ : ", | 182 | " { ] ^ / ( _ : ", |
183 | " < [ } | 1 2 3 ", | 183 | " < [ } | 1 2 3 ", |
184 | " 4 5 6 7 8 9 0 a b c ", | 184 | " 4 5 6 7 8 9 0 a b c ", |
185 | " d e f g h i j 3 k l m n ", | 185 | " d e f g h i j 3 k l m n ", |
186 | " o p q r s t u v w n ", | 186 | " o p q r s t u v w n ", |
187 | " o x y z A B C D E n ", | 187 | " o x y z A B C D E n ", |
188 | " F G H I J K L M N O ", | 188 | " F G H I J K L M N O ", |
189 | " P Q R S T U V W X ", | 189 | " P Q R S T U V W X ", |
190 | " Y Z ` b ...+. ", | 190 | " Y Z ` b ...+. ", |
191 | " @.#.$.%.&. ", | 191 | " @.#.$.%.&. ", |
192 | " *.B =. ", | 192 | " *.B =. ", |
193 | " n n n n n n n n n "}; | 193 | " n n n n n n n n n "}; |
194 | 194 | ||
195 | 195 | ||
196 | using namespace Opie::Ui; | ||
196 | VMemo::VMemo( QWidget *parent, const char *_name ) | 197 | VMemo::VMemo( QWidget *parent, const char *_name ) |
197 | : QWidget( parent, _name ) { | 198 | : QWidget( parent, _name ) { |
198 | setFixedHeight( 18 ); | 199 | setFixedHeight( 18 ); |
199 | setFixedWidth( 14 ); | 200 | setFixedWidth( 14 ); |
200 | 201 | ||
201 | t_timer = new QTimer( this ); | 202 | t_timer = new QTimer( this ); |
202 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 203 | connect( t_timer, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
203 | 204 | ||
204 | Config vmCfg("Vmemo"); | 205 | Config vmCfg("Vmemo"); |
205 | vmCfg.setGroup("Defaults"); | 206 | vmCfg.setGroup("Defaults"); |
206 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); | 207 | int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1)); |
207 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 208 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
208 | 209 | ||
209 | qDebug("toggleKey %d", toggleKey); | 210 | qDebug("toggleKey %d", toggleKey); |
210 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 211 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
211 | systemZaurus=TRUE; | 212 | systemZaurus=TRUE; |
212 | else | 213 | else |
213 | systemZaurus=FALSE; | 214 | systemZaurus=FALSE; |
214 | 215 | ||
215 | myChannel = new QCopChannel( "QPE/VMemo", this ); | 216 | myChannel = new QCopChannel( "QPE/VMemo", this ); |
216 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 217 | connect( myChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
217 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 218 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
218 | 219 | ||
219 | if( toggleKey != -1 ) { | 220 | if( toggleKey != -1 ) { |
220 | // keyRegister(key, channel, message) | 221 | // keyRegister(key, channel, message) |
221 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); | 222 | QCopEnvelope e("QPE/Launcher", "keyRegister(int,QCString,QCString)"); |
222 | // e << 4096; // Key_Escape | 223 | // e << 4096; // Key_Escape |
223 | // e << Key_F5; //4148 | 224 | // e << Key_F5; //4148 |
224 | e << toggleKey; | 225 | e << toggleKey; |
225 | e << QString("QPE/VMemo"); | 226 | e << QString("QPE/VMemo"); |
226 | e << QString("toggleRecord()"); | 227 | e << QString("toggleRecord()"); |
227 | } | 228 | } |
228 | if(toggleKey == 1) | 229 | if(toggleKey == 1) |
229 | usingIcon=TRUE; | 230 | usingIcon=TRUE; |
230 | else | 231 | else |
231 | usingIcon=FALSE; | 232 | usingIcon=FALSE; |
232 | if( vmCfg.readNumEntry("hideIcon",0) == 1) | 233 | if( vmCfg.readNumEntry("hideIcon",0) == 1) |
233 | hide(); | 234 | hide(); |
234 | recording = FALSE; | 235 | recording = FALSE; |
235 | // } | 236 | // } |
236 | } | 237 | } |
237 | 238 | ||
238 | VMemo::~VMemo() { | 239 | VMemo::~VMemo() { |
239 | } | 240 | } |
240 | 241 | ||
241 | int VMemo::position() | 242 | int VMemo::position() |
242 | { | 243 | { |
243 | return 6; | 244 | return 6; |
244 | } | 245 | } |
245 | 246 | ||
246 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { | 247 | void VMemo::receive( const QCString &msg, const QByteArray &data ) { |
247 | qDebug("receive"); | 248 | qDebug("receive"); |
248 | QDataStream stream( data, IO_ReadOnly ); | 249 | QDataStream stream( data, IO_ReadOnly ); |
249 | 250 | ||
250 | if (msg == "toggleRecord()") { | 251 | if (msg == "toggleRecord()") { |
251 | if (recording) { | 252 | if (recording) { |
252 | fromToggle = TRUE; | 253 | fromToggle = TRUE; |
253 | stopRecording(); | 254 | stopRecording(); |
254 | } else { | 255 | } else { |
255 | fromToggle = TRUE; | 256 | fromToggle = TRUE; |
256 | startRecording(); | 257 | startRecording(); |
257 | } | 258 | } |
258 | } | 259 | } |
259 | } | 260 | } |
260 | 261 | ||
261 | void VMemo::paintEvent( QPaintEvent* ) { | 262 | void VMemo::paintEvent( QPaintEvent* ) { |
262 | QPainter p(this); | 263 | QPainter p(this); |
263 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); | 264 | p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); |
264 | } | 265 | } |
265 | 266 | ||
266 | void VMemo::mousePressEvent( QMouseEvent * me) { | 267 | void VMemo::mousePressEvent( QMouseEvent * me) { |
267 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions | 268 | /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions |
268 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ | 269 | mousePressEvent and mouseReleaseEvent with a NULL parameter. */ |
269 | 270 | ||
270 | // if (!systemZaurus && me != NULL) | 271 | // if (!systemZaurus && me != NULL) |
271 | // return; | 272 | // return; |
272 | // } | 273 | // } |
273 | 274 | ||
274 | if(!recording) | 275 | if(!recording) |
275 | startRecording(); | 276 | startRecording(); |
276 | else | 277 | else |
277 | stopRecording(); | 278 | stopRecording(); |
278 | } | 279 | } |
279 | 280 | ||
280 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { | 281 | void VMemo::mouseReleaseEvent( QMouseEvent * ) { |
281 | } | 282 | } |
282 | 283 | ||
283 | bool VMemo::startRecording() { | 284 | bool VMemo::startRecording() { |
284 | Config config( "Vmemo" ); | 285 | Config config( "Vmemo" ); |
285 | config.setGroup( "System" ); | 286 | config.setGroup( "System" ); |
286 | 287 | ||
287 | useAlerts = config.readBoolEntry("Alert",1); | 288 | useAlerts = config.readBoolEntry("Alert",1); |
288 | if(useAlerts) { | 289 | if(useAlerts) { |
289 | 290 | ||
290 | msgLabel = new QLabel( 0, "alertLabel" ); | 291 | msgLabel = new QLabel( 0, "alertLabel" ); |
291 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); | 292 | msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>"); |
292 | msgLabel->show(); | 293 | msgLabel->show(); |
293 | } | 294 | } |
294 | 295 | ||
295 | qDebug("Start recording engines"); | 296 | qDebug("Start recording engines"); |
296 | recording = TRUE; | 297 | recording = TRUE; |
297 | 298 | ||
298 | if (openDSP() == -1) { | 299 | if (openDSP() == -1) { |
299 | recording = FALSE; | 300 | recording = FALSE; |
300 | return FALSE; | 301 | return FALSE; |
301 | } | 302 | } |
302 | 303 | ||
303 | config.setGroup("Defaults"); | 304 | config.setGroup("Defaults"); |
304 | 305 | ||
305 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 306 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
306 | date.replace(QRegExp("'"),""); | 307 | date.replace(QRegExp("'"),""); |
307 | date.replace(QRegExp(" "),"_"); | 308 | date.replace(QRegExp(" "),"_"); |
308 | date.replace(QRegExp(":"),"."); | 309 | date.replace(QRegExp(":"),"."); |
309 | date.replace(QRegExp(","),""); | 310 | date.replace(QRegExp(","),""); |
310 | 311 | ||
311 | QString fName; | 312 | QString fName; |
312 | config.setGroup( "System" ); | 313 | config.setGroup( "System" ); |
313 | fName = QPEApplication::documentDir() ; | 314 | fName = QPEApplication::documentDir() ; |
314 | fileName = config.readEntry("RecLocation", fName); | 315 | fileName = config.readEntry("RecLocation", fName); |
315 | 316 | ||
316 | int s; | 317 | int s; |
317 | s=fileName.find(':'); | 318 | s=fileName.find(':'); |
318 | if(s) | 319 | if(s) |
319 | fileName=fileName.right(fileName.length()-s-2); | 320 | fileName=fileName.right(fileName.length()-s-2); |
320 | qDebug("pathname will be "+fileName); | 321 | qDebug("pathname will be "+fileName); |
321 | 322 | ||
322 | if( fileName.left(1).find('/') == -1) | 323 | if( fileName.left(1).find('/') == -1) |
323 | fileName="/"+fileName; | 324 | fileName="/"+fileName; |
324 | if( fileName.right(1).find('/') == -1) | 325 | if( fileName.right(1).find('/') == -1) |
325 | fileName+="/"; | 326 | fileName+="/"; |
326 | fName = "vm_"+ date+ ".wav"; | 327 | fName = "vm_"+ date+ ".wav"; |
327 | 328 | ||
328 | fileName+=fName; | 329 | fileName+=fName; |
329 | qDebug("filename is "+fileName); | 330 | qDebug("filename is "+fileName); |
330 | // open tmp file here | 331 | // open tmp file here |
331 | char *pointer; | 332 | char *pointer; |
332 | pointer=tmpnam(NULL); | 333 | pointer=tmpnam(NULL); |
333 | qDebug("Opening tmp file %s",pointer); | 334 | qDebug("Opening tmp file %s",pointer); |
334 | 335 | ||
335 | if(openWAV(pointer ) == -1) { | 336 | if(openWAV(pointer ) == -1) { |
336 | 337 | ||
337 | QString err("Could not open the temp file\n"); | 338 | QString err("Could not open the temp file\n"); |
338 | err += fileName; | 339 | err += fileName; |
339 | QMessageBox::critical(0, "vmemo", err, "Abort"); | 340 | QMessageBox::critical(0, "vmemo", err, "Abort"); |
340 | ::close(dsp); | 341 | ::close(dsp); |
341 | return FALSE; | 342 | return FALSE; |
342 | } | 343 | } |
343 | if( record() ) { | 344 | if( record() ) { |
344 | 345 | ||
345 | QString cmd; | 346 | QString cmd; |
346 | if( fileName.find(".wav",0,TRUE) == -1) | 347 | if( fileName.find(".wav",0,TRUE) == -1) |
347 | fileName += ".wav"; | 348 | fileName += ".wav"; |
348 | 349 | ||
349 | cmd.sprintf("mv %s "+fileName, pointer); | 350 | cmd.sprintf("mv %s "+fileName, pointer); |
350 | // move tmp file to regular file here | 351 | // move tmp file to regular file here |
351 | 352 | ||
352 | system(cmd.latin1()); | 353 | system(cmd.latin1()); |
353 | 354 | ||
354 | QArray<int> cats(1); | 355 | QArray<int> cats(1); |
355 | cats[0] = config.readNumEntry("Category", 0); | 356 | cats[0] = config.readNumEntry("Category", 0); |
356 | 357 | ||
357 | QString dlName("vm_"); | 358 | QString dlName("vm_"); |
358 | dlName += date; | 359 | dlName += date; |
359 | DocLnk l; | 360 | DocLnk l; |
360 | l.setFile(fileName); | 361 | l.setFile(fileName); |
361 | l.setName(dlName); | 362 | l.setName(dlName); |
362 | l.setType("audio/x-wav"); | 363 | l.setType("audio/x-wav"); |
363 | l.setCategories(cats); | 364 | l.setCategories(cats); |
364 | l.writeLink(); | 365 | l.writeLink(); |
365 | return TRUE; | 366 | return TRUE; |
366 | } else | 367 | } else |
367 | return FALSE; | 368 | return FALSE; |
368 | 369 | ||
369 | } | 370 | } |
370 | 371 | ||
371 | void VMemo::stopRecording() { | 372 | void VMemo::stopRecording() { |
372 | show(); | 373 | show(); |
373 | qDebug("Stopped recording"); | 374 | qDebug("Stopped recording"); |
374 | recording = FALSE; | 375 | recording = FALSE; |
375 | if(useAlerts) { | 376 | if(useAlerts) { |
376 | msgLabel->close(); | 377 | msgLabel->close(); |
377 | msgLabel=0; | 378 | msgLabel=0; |
378 | delete msgLabel; | 379 | delete msgLabel; |
379 | } | 380 | } |
380 | t_timer->stop(); | 381 | t_timer->stop(); |
381 | Config cfg("Vmemo"); | 382 | Config cfg("Vmemo"); |
382 | cfg.setGroup("Defaults"); | 383 | cfg.setGroup("Defaults"); |
383 | if( cfg.readNumEntry("hideIcon",0) == 1 ) | 384 | if( cfg.readNumEntry("hideIcon",0) == 1 ) |
384 | hide(); | 385 | hide(); |
385 | } | 386 | } |
386 | 387 | ||
387 | int VMemo::openDSP() { | 388 | int VMemo::openDSP() { |
388 | Config cfg("Vmemo"); | 389 | Config cfg("Vmemo"); |
389 | cfg.setGroup("Record"); | 390 | cfg.setGroup("Record"); |
390 | 391 | ||
391 | speed = cfg.readNumEntry("SampleRate", 22050); | 392 | speed = cfg.readNumEntry("SampleRate", 22050); |
392 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) | 393 | channels = cfg.readNumEntry("Stereo", 1) ? 2 : 1; // 1 = stereo(2), 0 = mono(1) |
393 | if (cfg.readNumEntry("SixteenBit", 1)==1) { | 394 | if (cfg.readNumEntry("SixteenBit", 1)==1) { |
394 | format = AFMT_S16_LE; | 395 | format = AFMT_S16_LE; |
395 | resolution = 16; | 396 | resolution = 16; |
396 | } else { | 397 | } else { |
397 | format = AFMT_U8; | 398 | format = AFMT_U8; |
398 | resolution = 8; | 399 | resolution = 8; |
399 | } | 400 | } |
400 | 401 | ||
401 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); | 402 | qDebug("samplerate: %d, channels %d, resolution %d", speed, channels, resolution); |
402 | 403 | ||
403 | if(systemZaurus) { | 404 | if(systemZaurus) { |
404 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 | 405 | dsp = open("/dev/dsp1", O_RDONLY); //Zaurus needs /dev/dsp1 |
405 | channels=1; //zaurus has one input channel | 406 | channels=1; //zaurus has one input channel |
406 | } else { | 407 | } else { |
407 | dsp = open("/dev/dsp", O_RDONLY); | 408 | dsp = open("/dev/dsp", O_RDONLY); |
408 | } | 409 | } |
409 | 410 | ||
410 | if(dsp == -1) { | 411 | if(dsp == -1) { |
411 | msgLabel->close(); | 412 | msgLabel->close(); |
412 | msgLabel=0; | 413 | msgLabel=0; |
413 | delete msgLabel; | 414 | delete msgLabel; |
414 | 415 | ||
415 | perror("open(\"/dev/dsp\")"); | 416 | perror("open(\"/dev/dsp\")"); |
416 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); | 417 | errorMsg="open(\"/dev/dsp\")\n "+(QString)strerror(errno); |
417 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); | 418 | QMessageBox::critical(0, "vmemo", errorMsg, "Abort"); |
418 | return -1; | 419 | return -1; |
419 | } | 420 | } |
420 | 421 | ||
421 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { | 422 | if(ioctl(dsp, SNDCTL_DSP_SETFMT , &format)==-1) { |
422 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 423 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
423 | return -1; | 424 | return -1; |
424 | } | 425 | } |
425 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { | 426 | if(ioctl(dsp, SNDCTL_DSP_CHANNELS , &channels)==-1) { |
426 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 427 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
427 | return -1; | 428 | return -1; |
428 | } | 429 | } |
429 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { | 430 | if(ioctl(dsp, SNDCTL_DSP_SPEED , &speed)==-1) { |
430 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 431 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
431 | return -1; | 432 | return -1; |
432 | } | 433 | } |
433 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { | 434 | if(ioctl(dsp, SOUND_PCM_READ_RATE , &rate)==-1) { |
434 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); | 435 | perror("ioctl(\"SOUND_PCM_READ_RATE\")"); |
435 | return -1; | 436 | return -1; |
436 | } | 437 | } |
437 | 438 | ||
438 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute | 439 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; //mute |
439 | 440 | ||
440 | return 1; | 441 | return 1; |
441 | } | 442 | } |
442 | 443 | ||
443 | int VMemo::openWAV(const char *filename) { | 444 | int VMemo::openWAV(const char *filename) { |
444 | track.setName(filename); | 445 | track.setName(filename); |
445 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { | 446 | if(!track.open(IO_WriteOnly|IO_Truncate|IO_Raw)) { |
446 | errorMsg=filename; | 447 | errorMsg=filename; |
447 | return -1; | 448 | return -1; |
448 | } | 449 | } |
449 | 450 | ||
450 | wav=track.handle(); | 451 | wav=track.handle(); |
451 | Config vmCfg("Vmemo"); | 452 | Config vmCfg("Vmemo"); |
452 | vmCfg.setGroup("Defaults"); | 453 | vmCfg.setGroup("Defaults"); |
453 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 454 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
454 | 455 | ||
455 | WaveHeader wh; | 456 | WaveHeader wh; |
456 | 457 | ||
457 | wh.main_chunk = RIFF; | 458 | wh.main_chunk = RIFF; |
458 | wh.length=0; | 459 | wh.length=0; |
459 | wh.chunk_type = WAVE; | 460 | wh.chunk_type = WAVE; |
460 | wh.sub_chunk = FMT; | 461 | wh.sub_chunk = FMT; |
461 | wh.sc_len = 16; | 462 | wh.sc_len = 16; |
462 | if(useADPCM) | 463 | if(useADPCM) |
463 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; | 464 | wh.format = WAVE_FORMAT_DVI_ADPCM;//PCM_CODE; |
464 | else | 465 | else |
465 | wh.format = PCM_CODE; | 466 | wh.format = PCM_CODE; |
466 | wh.modus = channels; | 467 | wh.modus = channels; |
467 | wh.sample_fq = speed; | 468 | wh.sample_fq = speed; |
468 | wh.byte_p_sec = speed * channels * resolution/8; | 469 | wh.byte_p_sec = speed * channels * resolution/8; |
469 | wh.byte_p_spl = channels * (resolution / 8); | 470 | wh.byte_p_spl = channels * (resolution / 8); |
470 | wh.bit_p_spl = resolution; | 471 | wh.bit_p_spl = resolution; |
471 | wh.data_chunk = DATA; | 472 | wh.data_chunk = DATA; |
472 | wh.data_length= 0; | 473 | wh.data_length= 0; |
473 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" | 474 | // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" |
474 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); | 475 | // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); |
475 | write (wav, &wh, sizeof(WaveHeader)); | 476 | write (wav, &wh, sizeof(WaveHeader)); |
476 | 477 | ||
477 | return 1; | 478 | return 1; |
478 | } | 479 | } |
479 | 480 | ||
480 | bool VMemo::record() { | 481 | bool VMemo::record() { |
481 | length=0; | 482 | length=0; |
482 | int result, value; | 483 | int result, value; |
483 | QString msg; | 484 | QString msg; |
484 | msg.sprintf("Recording format %d", format); | 485 | msg.sprintf("Recording format %d", format); |
485 | qDebug(msg); | 486 | qDebug(msg); |
486 | Config config("Vmemo"); | 487 | Config config("Vmemo"); |
487 | config.setGroup("Record"); | 488 | config.setGroup("Record"); |
488 | int sRate=config.readNumEntry("SizeLimit", 30); | 489 | int sRate=config.readNumEntry("SizeLimit", 30); |
489 | if(sRate > 0) | 490 | if(sRate > 0) |
490 | t_timer->start( sRate * 1000+1000, TRUE); | 491 | t_timer->start( sRate * 1000+1000, TRUE); |
491 | 492 | ||
492 | // if(systemZaurus) { | 493 | // if(systemZaurus) { |
493 | // } else { // 16 bit only capabilities | 494 | // } else { // 16 bit only capabilities |
494 | 495 | ||
495 | msg.sprintf("Recording format other"); | 496 | msg.sprintf("Recording format other"); |
496 | qDebug(msg); | 497 | qDebug(msg); |
497 | 498 | ||
498 | int bufsize=1024; | 499 | int bufsize=1024; |
499 | int bytesWritten=0; | 500 | int bytesWritten=0; |
500 | signed short sound[1024], monoBuffer[1024]; | 501 | signed short sound[1024], monoBuffer[1024]; |
501 | char abuf[bufsize/2]; | 502 | char abuf[bufsize/2]; |
502 | short sbuf[bufsize]; | 503 | short sbuf[bufsize]; |
503 | Config vmCfg("Vmemo"); | 504 | Config vmCfg("Vmemo"); |
504 | vmCfg.setGroup("Defaults"); | 505 | vmCfg.setGroup("Defaults"); |
505 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); | 506 | useADPCM = vmCfg.readBoolEntry("use_ADPCM", 0); |
506 | 507 | ||
507 | while(recording) { | 508 | while(recording) { |
508 | 509 | ||
509 | if(useADPCM) | 510 | if(useADPCM) |
510 | result = read( dsp, sbuf, bufsize); // 8192 | 511 | result = read( dsp, sbuf, bufsize); // 8192 |
511 | else | 512 | else |
512 | result = read(dsp, sound, 1024); // 8192 | 513 | result = read(dsp, sound, 1024); // 8192 |
513 | if( result <= 0) { | 514 | if( result <= 0) { |
514 | perror("recording error "); | 515 | perror("recording error "); |
515 | // qDebug(currentFileName); | 516 | // qDebug(currentFileName); |
516 | QMessageBox::message(tr("Note"),tr("error recording")); | 517 | QMessageBox::message(tr("Note"),tr("error recording")); |
517 | recording=FALSE; | 518 | recording=FALSE; |
518 | break; | 519 | break; |
519 | return FALSE; | 520 | return FALSE; |
520 | } | 521 | } |
521 | 522 | ||
522 | if(useADPCM) { | 523 | if(useADPCM) { |
523 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); | 524 | adpcm_coder( sbuf, abuf, result/2, &encoder_state); |
524 | bytesWritten = ::write(wav, abuf, result/4); | 525 | bytesWritten = ::write(wav, abuf, result/4); |
525 | 526 | ||
526 | } else { | 527 | } else { |
527 | for (int i = 0; i < result; i++) { //since Z is mono do normally | 528 | for (int i = 0; i < result; i++) { //since Z is mono do normally |
528 | monoBuffer[i] = sound[i]; | 529 | monoBuffer[i] = sound[i]; |
529 | } | 530 | } |
530 | 531 | ||
531 | length+=write(wav, monoBuffer, result); | 532 | length+=write(wav, monoBuffer, result); |
532 | } | 533 | } |
533 | length +=bytesWritten; | 534 | length +=bytesWritten; |
534 | 535 | ||
535 | if(length<0) { | 536 | if(length<0) { |
536 | recording=false; | 537 | recording=false; |
537 | perror("dev/dsp's is a lookin' messy"); | 538 | perror("dev/dsp's is a lookin' messy"); |
538 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); | 539 | QMessageBox::message("Vmemo","Error writing to file\n"+ fileName); |
539 | break; | 540 | break; |
540 | return FALSE; | 541 | return FALSE; |
541 | } | 542 | } |
542 | // printf("%d\r",length); | 543 | // printf("%d\r",length); |
543 | // fflush(stdout); | 544 | // fflush(stdout); |
544 | qApp->processEvents(); | 545 | qApp->processEvents(); |
545 | } | 546 | } |
546 | // qDebug("file has length of %d lasting %d seconds", | 547 | // qDebug("file has length of %d lasting %d seconds", |
547 | // length, (( length / speed) / channels) / 2 ); | 548 | // length, (( length / speed) / channels) / 2 ); |
548 | // } | 549 | // } |
549 | 550 | ||
550 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// | 551 | //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// |
551 | 552 | ||
552 | value = length+36; | 553 | value = length+36; |
553 | 554 | ||
554 | lseek(wav, 4, SEEK_SET); | 555 | lseek(wav, 4, SEEK_SET); |
555 | write(wav, &value, 4); | 556 | write(wav, &value, 4); |
556 | lseek(wav, 40, SEEK_SET); | 557 | lseek(wav, 40, SEEK_SET); |
557 | 558 | ||
558 | write(wav, &length, 4); | 559 | write(wav, &length, 4); |
559 | 560 | ||
560 | track.close(); | 561 | track.close(); |
561 | qDebug("Track closed"); | 562 | qDebug("Track closed"); |
562 | 563 | ||
563 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) | 564 | if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) |
564 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); | 565 | perror("ioctl(\"SNDCTL_DSP_RESET\")"); |
565 | 566 | ||
566 | ::close(dsp); | 567 | ::close(dsp); |
567 | 568 | ||
568 | Config cfgO("OpieRec"); | 569 | Config cfgO("OpieRec"); |
569 | cfgO.setGroup("Sounds"); | 570 | cfgO.setGroup("Sounds"); |
570 | 571 | ||
571 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); | 572 | int nFiles = cfgO.readNumEntry( "NumberofFiles",0); |
572 | 573 | ||
573 | QString currentFileName = fileName; | 574 | QString currentFileName = fileName; |
574 | QString currentFile = "vm_"+ date; | 575 | QString currentFile = "vm_"+ date; |
575 | 576 | ||
576 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; | 577 | float numberOfRecordedSeconds=(float) length / (float)speed * (float)2; |
577 | 578 | ||
578 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); | 579 | cfgO.writeEntry( "NumberofFiles", nFiles + 1); |
579 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); | 580 | cfgO.writeEntry( QString::number( nFiles + 1), currentFile); |
580 | cfgO.writeEntry( currentFile, currentFileName); | 581 | cfgO.writeEntry( currentFile, currentFileName); |
581 | 582 | ||
582 | QString time; | 583 | QString time; |
583 | time.sprintf("%.2f", numberOfRecordedSeconds); | 584 | time.sprintf("%.2f", numberOfRecordedSeconds); |
584 | cfgO.writeEntry( currentFileName, time ); | 585 | cfgO.writeEntry( currentFileName, time ); |
585 | // qDebug("writing config numberOfRecordedSeconds "+time); | 586 | // qDebug("writing config numberOfRecordedSeconds "+time); |
586 | 587 | ||
587 | cfgO.write(); | 588 | cfgO.write(); |
588 | 589 | ||
589 | qDebug("done recording "+fileName); | 590 | qDebug("done recording "+fileName); |
590 | 591 | ||
591 | Config cfg("qpe"); | 592 | Config cfg("qpe"); |
592 | cfg.setGroup("Volume"); | 593 | cfg.setGroup("Volume"); |
593 | QString foo = cfg.readEntry("Mute","TRUE"); | 594 | QString foo = cfg.readEntry("Mute","TRUE"); |
594 | if(foo.find("TRUE",0,TRUE) != -1) | 595 | if(foo.find("TRUE",0,TRUE) != -1) |
595 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute | 596 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute |
596 | return TRUE; | 597 | return TRUE; |
597 | } | 598 | } |
598 | 599 | ||
599 | int VMemo::setToggleButton(int tog) { | 600 | int VMemo::setToggleButton(int tog) { |
600 | 601 | ||
601 | for( int i=0; i < 10;i++) { | 602 | for( int i=0; i < 10;i++) { |
602 | switch (tog) { | 603 | switch (tog) { |
603 | case 0: | 604 | case 0: |
604 | return -1; | 605 | return -1; |
605 | break; | 606 | break; |
606 | case 1: | 607 | case 1: |
607 | return 0; | 608 | return 0; |
608 | break; | 609 | break; |
609 | case 2: | 610 | case 2: |
610 | return Key_F24; //was Escape | 611 | return Key_F24; //was Escape |
611 | break; | 612 | break; |
612 | case 3: | 613 | case 3: |
613 | return Key_Space; | 614 | return Key_Space; |
614 | break; | 615 | break; |
615 | case 4: | 616 | case 4: |
616 | return Key_F12; | 617 | return Key_F12; |
617 | break; | 618 | break; |
618 | case 5: | 619 | case 5: |
619 | return Key_F9; | 620 | return Key_F9; |
620 | break; | 621 | break; |
621 | case 6: | 622 | case 6: |
622 | return Key_F10; | 623 | return Key_F10; |
623 | break; | 624 | break; |
624 | case 7: | 625 | case 7: |
625 | return Key_F11; | 626 | return Key_F11; |
626 | break; | 627 | break; |
627 | case 8: | 628 | case 8: |
628 | return Key_F13; | 629 | return Key_F13; |
629 | break; | 630 | break; |
630 | }; | 631 | }; |
631 | } | 632 | } |
632 | return -1; | 633 | return -1; |
633 | } | 634 | } |
634 | 635 | ||
635 | void VMemo::timerBreak() { | 636 | void VMemo::timerBreak() { |
636 | //stop | 637 | //stop |
637 | stopRecording(); | 638 | stopRecording(); |
638 | QMessageBox::message("Vmemo","Vmemo recording has ended"); | 639 | QMessageBox::message("Vmemo","Vmemo recording has ended"); |
639 | } | 640 | } |
640 | 641 | ||
641 | Q_EXPORT_INTERFACE() | 642 | |
642 | { | 643 | EXPORT_OPIE_APPLET_v1( VMemo ) |
643 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VMemo> ); | ||
644 | } | ||
645 | 644 | ||
diff --git a/core/applets/volumeapplet/config.in b/core/applets/volumeapplet/config.in index 1233d9f..f097591 100644 --- a/core/applets/volumeapplet/config.in +++ b/core/applets/volumeapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config VOLUMEAPPLET | 1 | config VOLUMEAPPLET |
2 | boolean "opie-volumeapplet (set volume for microphone and speaker)" | 2 | boolean "opie-volumeapplet (set volume for microphone and speaker)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 942cebb..276f47f 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp | |||
@@ -1,783 +1,781 @@ | |||
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 "volume.h" | 21 | #include "volume.h" |
22 | #include "oledbox.h" | 22 | #include "oledbox.h" |
23 | 23 | ||
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <opie2/otaskbarapplet.h> | 25 | #include <opie2/otaskbarapplet.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/qcopenvelope_qws.h> | 29 | #include <qpe/qcopenvelope_qws.h> |
30 | 30 | ||
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qcheckbox.h> | 32 | #include <qcheckbox.h> |
33 | #include <qslider.h> | 33 | #include <qslider.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qtimer.h> | 38 | #include <qtimer.h> |
39 | 39 | ||
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | 41 | ||
42 | using namespace Opie; | 42 | using namespace Opie::Core; |
43 | 43 | ||
44 | #define RATE_TIMER_INTERVAL 100 | 44 | #define RATE_TIMER_INTERVAL 100 |
45 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 45 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
46 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 46 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
47 | 47 | ||
48 | 48 | ||
49 | /* XPM */ | 49 | /* XPM */ |
50 | using namespace Opie::Ui; | ||
50 | static const char * vol_xpm[] = { | 51 | static const char * vol_xpm[] = { |
51 | "20 20 3 1", | 52 | "20 20 3 1", |
52 | " c None", | 53 | " c None", |
53 | ". c #0000FF", | 54 | ". c #0000FF", |
54 | "+ c #000000", | 55 | "+ c #000000", |
55 | " ", | 56 | " ", |
56 | " . ", | 57 | " . ", |
57 | " . . . . ", | 58 | " . . . . ", |
58 | " . . . . . . ", | 59 | " . . . . . . ", |
59 | " . . . . . . . ", | 60 | " . . . . . . . ", |
60 | " . . ..... . . ", | 61 | " . . ..... . . ", |
61 | " . ... ..... ... ", | 62 | " . ... ..... ... ", |
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 | /* XPM */ | 76 | /* XPM */ |
76 | static const char * mic_xpm[] = { | 77 | static const char * mic_xpm[] = { |
77 | "20 20 21 1", | 78 | "20 20 21 1", |
78 | " c None", | 79 | " c None", |
79 | ". c #000000", | 80 | ". c #000000", |
80 | "+ c #EEEEEE", | 81 | "+ c #EEEEEE", |
81 | "@ c #B4B6B4", | 82 | "@ c #B4B6B4", |
82 | "# c #8B8D8B", | 83 | "# c #8B8D8B", |
83 | "$ c #D5D6D5", | 84 | "$ c #D5D6D5", |
84 | "% c #E6E6E6", | 85 | "% c #E6E6E6", |
85 | "& c #9C9D9C", | 86 | "& c #9C9D9C", |
86 | "* c #6A696A", | 87 | "* c #6A696A", |
87 | "= c #E6E2E6", | 88 | "= c #E6E2E6", |
88 | "- c #F6F2F6", | 89 | "- c #F6F2F6", |
89 | "; c #CDC6CD", | 90 | "; c #CDC6CD", |
90 | "> c #737573", | 91 | "> c #737573", |
91 | ", c #4A484A", | 92 | ", c #4A484A", |
92 | "' c #DEDEDE", | 93 | "' c #DEDEDE", |
93 | ") c #F6EEF6", | 94 | ") c #F6EEF6", |
94 | "! c #414041", | 95 | "! c #414041", |
95 | "~ c #202020", | 96 | "~ c #202020", |
96 | "{ c #ACAEAC", | 97 | "{ c #ACAEAC", |
97 | "] c #838583", | 98 | "] c #838583", |
98 | "^ c #6A656A", | 99 | "^ c #6A656A", |
99 | " ", | 100 | " ", |
100 | " .... ", | 101 | " .... ", |
101 | " .+@+#. ", | 102 | " .+@+#. ", |
102 | " ..$%&%*. ", | 103 | " ..$%&%*. ", |
103 | " .=-.;=>=,. ", | 104 | " .=-.;=>=,. ", |
104 | " .'+).&+!+. ", | 105 | " .'+).&+!+. ", |
105 | " .+;+;.~+~. ", | 106 | " .+;+;.~+~. ", |
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 | static const char * bass_xpm[] = { | 122 | static const char * bass_xpm[] = { |
122 | "20 20 3 1", | 123 | "20 20 3 1", |
123 | " c None", | 124 | " c None", |
124 | ". c #000000", | 125 | ". c #000000", |
125 | "+ c #0000FF", | 126 | "+ c #0000FF", |
126 | " ", | 127 | " ", |
127 | " ", | 128 | " ", |
128 | " ", | 129 | " ", |
129 | "..... +++ ......", | 130 | "..... +++ ......", |
130 | " +++++++ ", | 131 | " +++++++ ", |
131 | " ++ ++ ", | 132 | " ++ ++ ", |
132 | "... ++ ... ++ ++ .", | 133 | "... ++ ... ++ ++ .", |
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 | static const char * treble_xpm[] = { | 149 | static const char * treble_xpm[] = { |
149 | "20 20 3 1", | 150 | "20 20 3 1", |
150 | " c None", | 151 | " c None", |
151 | ". c #0000FF", | 152 | ". c #0000FF", |
152 | "+ c #000000", | 153 | "+ c #000000", |
153 | " .. ", | 154 | " .. ", |
154 | " . .. ", | 155 | " . .. ", |
155 | " . .. ", | 156 | " . .. ", |
156 | "++++++++ . .. ++++++", | 157 | "++++++++ . .. ++++++", |
157 | " . . ", | 158 | " . . ", |
158 | " ... ", | 159 | " ... ", |
159 | "++++++++ . +++++++", | 160 | "++++++++ . +++++++", |
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 | /* XPM */ | 178 | /* XPM */ |
178 | static const char * alarm_xpm[] = { | 179 | static const char * alarm_xpm[] = { |
179 | "20 20 33 1", | 180 | "20 20 33 1", |
180 | " c None", | 181 | " c None", |
181 | ". c #080602", | 182 | ". c #080602", |
182 | "+ c #AAA602", | 183 | "+ c #AAA602", |
183 | "@ c #252002", | 184 | "@ c #252002", |
184 | "# c #434202", | 185 | "# c #434202", |
185 | "$ c #795602", | 186 | "$ c #795602", |
186 | "% c #C3C20D", | 187 | "% c #C3C20D", |
187 | "& c #DADAC2", | 188 | "& c #DADAC2", |
188 | "* c #826002", | 189 | "* c #826002", |
189 | "= c #740502", | 190 | "= c #740502", |
190 | "- c #D6D602", | 191 | "- c #D6D602", |
191 | "; c #322E02", | 192 | "; c #322E02", |
192 | "> c #826A02", | 193 | "> c #826A02", |
193 | ", c #F1F195", | 194 | ", c #F1F195", |
194 | "' c #959215", | 195 | "' c #959215", |
195 | ") c #423602", | 196 | ") c #423602", |
196 | "! c #4B0302", | 197 | "! c #4B0302", |
197 | "~ c #844315", | 198 | "~ c #844315", |
198 | "{ c #AAAA2A", | 199 | "{ c #AAAA2A", |
199 | "] c #E2DE42", | 200 | "] c #E2DE42", |
200 | "^ c #BA7E04", | 201 | "^ c #BA7E04", |
201 | "/ c #7F7502", | 202 | "/ c #7F7502", |
202 | "( c #828276", | 203 | "( c #828276", |
203 | "_ c #FEFE4E", | 204 | "_ c #FEFE4E", |
204 | ": c #7D1902", | 205 | ": c #7D1902", |
205 | "< c #989656", | 206 | "< c #989656", |
206 | "[ c #260B02", | 207 | "[ c #260B02", |
207 | "} c #F7F7D8", | 208 | "} c #F7F7D8", |
208 | "| c #DCDA5A", | 209 | "| c #DCDA5A", |
209 | "1 c #823102", | 210 | "1 c #823102", |
210 | "2 c #B1AC6B", | 211 | "2 c #B1AC6B", |
211 | "3 c #F7F710", | 212 | "3 c #F7F710", |
212 | "4 c #838204", | 213 | "4 c #838204", |
213 | " ", | 214 | " ", |
214 | " ", | 215 | " ", |
215 | " 4'4/ ", | 216 | " 4'4/ ", |
216 | " /-^= ", | 217 | " /-^= ", |
217 | " 42{4>4 ", | 218 | " 42{4>4 ", |
218 | " '2|+*$44 ", | 219 | " '2|+*$44 ", |
219 | " +2&3+$1*44 ", | 220 | " +2&3+$1*44 ", |
220 | " (%_}_+/$:>/4 ", | 221 | " (%_}_+/$:>/4 ", |
221 | " 4%_}3+#;>:*4 ", | 222 | " 4%_}3+#;>:*4 ", |
222 | " 4%_}&+#[1$/4 ", | 223 | " 4%_}&+#[1$/4 ", |
223 | " 4%_,2')[~~>4 ", | 224 | " 4%_,2')[~~>4 ", |
224 | " 4%33'4#@~1>4 ", | 225 | " 4%33'4#@~1>4 ", |
225 | " 4%3344#[:>/4 ", | 226 | " 4%3344#[:>/4 ", |
226 | " 42&_3'4#@>:*44 ", | 227 | " 42&_3'4#@>:*44 ", |
227 | " 42|}}3'4#[;$)$44 ", | 228 | " 42|}}3'4#[;$)$44 ", |
228 | "444{]]2^~~:!!#.@##/ ", | 229 | "444{]]2^~~:!!#.@##/ ", |
229 | "4444-%*:==!!=...../ ", | 230 | "4444-%*:==!!=...../ ", |
230 | " /:[.. ", | 231 | " /:[.. ", |
231 | " /@. ", | 232 | " /@. ", |
232 | " "}; | 233 | " "}; |
233 | 234 | ||
234 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 235 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
235 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 236 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
236 | { | 237 | { |
237 | m_icon = icon; | 238 | m_icon = icon; |
238 | 239 | ||
239 | bool has_wav_alarm = true; | 240 | bool has_wav_alarm = true; |
240 | bool has_bass = true; | 241 | bool has_bass = true; |
241 | bool has_treble = true; | 242 | bool has_treble = true; |
242 | 243 | ||
243 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 244 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
244 | case Model_Zaurus_SL5000: | 245 | case Model_Zaurus_SL5000: |
245 | has_wav_alarm = false; //poor guys probably feeling left out... | 246 | has_wav_alarm = false; //poor guys probably feeling left out... |
246 | break; | 247 | break; |
247 | default: | 248 | default: |
248 | break; | 249 | break; |
249 | } | 250 | } |
250 | 251 | ||
251 | if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { | 252 | if ( !ODevice::inst ( )-> series ( ) == Model_iPAQ ) { |
252 | has_bass = false; | 253 | has_bass = false; |
253 | has_treble = false; | 254 | has_treble = false; |
254 | } | 255 | } |
255 | 256 | ||
256 | 257 | ||
257 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 258 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
258 | 259 | ||
259 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 260 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
260 | grid-> setSpacing ( 4 ); | 261 | grid-> setSpacing ( 4 ); |
261 | grid-> setMargin ( 6 ); | 262 | grid-> setMargin ( 6 ); |
262 | 263 | ||
263 | QVBoxLayout *vbox; | 264 | QVBoxLayout *vbox; |
264 | QLabel *l; | 265 | QLabel *l; |
265 | 266 | ||
266 | vbox = new QVBoxLayout ( ); | 267 | vbox = new QVBoxLayout ( ); |
267 | vbox-> setSpacing ( 4 ); | 268 | vbox-> setSpacing ( 4 ); |
268 | grid-> addLayout ( vbox, 1, 0 ); | 269 | grid-> addLayout ( vbox, 1, 0 ); |
269 | 270 | ||
270 | upButton = new QPushButton ( this ); | 271 | upButton = new QPushButton ( this ); |
271 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 272 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
272 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 273 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
273 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 274 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
274 | 275 | ||
275 | vbox-> addWidget ( upButton ); | 276 | vbox-> addWidget ( upButton ); |
276 | 277 | ||
277 | downButton = new QPushButton ( this ); | 278 | downButton = new QPushButton ( this ); |
278 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 279 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
279 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 280 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
280 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 281 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
281 | 282 | ||
282 | vbox-> addWidget ( downButton ); | 283 | vbox-> addWidget ( downButton ); |
283 | 284 | ||
284 | volSlider = new QSlider ( this ); | 285 | volSlider = new QSlider ( this ); |
285 | volSlider-> setRange ( 0, 100 ); | 286 | volSlider-> setRange ( 0, 100 ); |
286 | volSlider-> setTickmarks ( QSlider::Both ); | 287 | volSlider-> setTickmarks ( QSlider::Both ); |
287 | volSlider-> setTickInterval ( 20 ); | 288 | volSlider-> setTickInterval ( 20 ); |
288 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 289 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
289 | 290 | ||
290 | l = new QLabel ( this ); | 291 | l = new QLabel ( this ); |
291 | l-> setPixmap ( QPixmap ( vol_xpm )); | 292 | l-> setPixmap ( QPixmap ( vol_xpm )); |
292 | 293 | ||
293 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 294 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
294 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 295 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
295 | 296 | ||
296 | volLed = new OLedBox ( green, this ); | 297 | volLed = new OLedBox ( green, this ); |
297 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 298 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
298 | volLed-> setFixedSize ( 16, 16 ); | 299 | volLed-> setFixedSize ( 16, 16 ); |
299 | 300 | ||
300 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 301 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
301 | 302 | ||
302 | QVBox *basstrebleBox = new QVBox( this ); | 303 | QVBox *basstrebleBox = new QVBox( this ); |
303 | 304 | ||
304 | trebleSlider = new QSlider ( basstrebleBox ); | 305 | trebleSlider = new QSlider ( basstrebleBox ); |
305 | trebleSlider-> setRange ( 0, 100 ); | 306 | trebleSlider-> setRange ( 0, 100 ); |
306 | trebleSlider-> setTickmarks ( QSlider::Both ); | 307 | trebleSlider-> setTickmarks ( QSlider::Both ); |
307 | trebleSlider-> setTickInterval ( 20 ); | 308 | trebleSlider-> setTickInterval ( 20 ); |
308 | trebleSlider->setMaximumHeight( 40 ); | 309 | trebleSlider->setMaximumHeight( 40 ); |
309 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | 310 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); |
310 | 311 | ||
311 | bassSlider = new QSlider ( basstrebleBox ); | 312 | bassSlider = new QSlider ( basstrebleBox ); |
312 | bassSlider-> setRange ( 0, 100 ); | 313 | bassSlider-> setRange ( 0, 100 ); |
313 | bassSlider-> setTickmarks ( QSlider::Both ); | 314 | bassSlider-> setTickmarks ( QSlider::Both ); |
314 | bassSlider-> setTickInterval ( 20 ); | 315 | bassSlider-> setTickInterval ( 20 ); |
315 | bassSlider->setMaximumHeight( 40 ); | 316 | bassSlider->setMaximumHeight( 40 ); |
316 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | 317 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); |
317 | 318 | ||
318 | QLabel *bassLabel = new QLabel ( this ); | 319 | QLabel *bassLabel = new QLabel ( this ); |
319 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | 320 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); |
320 | 321 | ||
321 | QLabel *trebleLabel = new QLabel( this ); | 322 | QLabel *trebleLabel = new QLabel( this ); |
322 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | 323 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); |
323 | 324 | ||
324 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | 325 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); |
325 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | 326 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); |
326 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | 327 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); |
327 | 328 | ||
328 | if ( !has_bass ) { | 329 | if ( !has_bass ) { |
329 | bassSlider->hide(); | 330 | bassSlider->hide(); |
330 | bassLabel->hide(); | 331 | bassLabel->hide(); |
331 | } | 332 | } |
332 | 333 | ||
333 | if ( !has_treble ) { | 334 | if ( !has_treble ) { |
334 | trebleSlider->hide(); | 335 | trebleSlider->hide(); |
335 | trebleLabel->hide(); | 336 | trebleLabel->hide(); |
336 | } | 337 | } |
337 | 338 | ||
338 | micSlider = new QSlider ( this ); | 339 | micSlider = new QSlider ( this ); |
339 | micSlider-> setRange ( 0, 100 ); | 340 | micSlider-> setRange ( 0, 100 ); |
340 | micSlider-> setTickmarks ( QSlider::Both ); | 341 | micSlider-> setTickmarks ( QSlider::Both ); |
341 | micSlider-> setTickInterval ( 20 ); | 342 | micSlider-> setTickInterval ( 20 ); |
342 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 343 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
343 | 344 | ||
344 | l = new QLabel ( this ); | 345 | l = new QLabel ( this ); |
345 | l-> setPixmap ( QPixmap ( mic_xpm )); | 346 | l-> setPixmap ( QPixmap ( mic_xpm )); |
346 | 347 | ||
347 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 348 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
348 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 349 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
349 | 350 | ||
350 | micLed = new OLedBox ( red, this ); | 351 | micLed = new OLedBox ( red, this ); |
351 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 352 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
352 | micLed-> setFixedSize ( 16, 16 ); | 353 | micLed-> setFixedSize ( 16, 16 ); |
353 | 354 | ||
354 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 355 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
355 | 356 | ||
356 | alarmSlider = new QSlider ( this ); | 357 | alarmSlider = new QSlider ( this ); |
357 | alarmSlider-> setRange ( 0, 100 ); | 358 | alarmSlider-> setRange ( 0, 100 ); |
358 | alarmSlider-> setTickmarks ( QSlider::Both ); | 359 | alarmSlider-> setTickmarks ( QSlider::Both ); |
359 | alarmSlider-> setTickInterval ( 20 ); | 360 | alarmSlider-> setTickInterval ( 20 ); |
360 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 361 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
361 | 362 | ||
362 | QLabel *alarmLabel = new QLabel ( this ); | 363 | QLabel *alarmLabel = new QLabel ( this ); |
363 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 364 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
364 | 365 | ||
365 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 366 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
366 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 367 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
367 | 368 | ||
368 | alarmLed = new OLedBox ( yellow, this ); | 369 | alarmLed = new OLedBox ( yellow, this ); |
369 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 370 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
370 | alarmLed-> setFixedSize ( 16, 16 ); | 371 | alarmLed-> setFixedSize ( 16, 16 ); |
371 | 372 | ||
372 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 373 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
373 | 374 | ||
374 | if ( !has_wav_alarm ) { | 375 | if ( !has_wav_alarm ) { |
375 | alarmSlider-> hide ( ); | 376 | alarmSlider-> hide ( ); |
376 | alarmLabel-> hide ( ); | 377 | alarmLabel-> hide ( ); |
377 | alarmLed-> hide ( ); | 378 | alarmLed-> hide ( ); |
378 | } | 379 | } |
379 | 380 | ||
380 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); | 381 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
381 | 382 | ||
382 | vbox = new QVBoxLayout ( ); | 383 | vbox = new QVBoxLayout ( ); |
383 | vbox-> setSpacing ( 4 ); | 384 | vbox-> setSpacing ( 4 ); |
384 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); | 385 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
385 | 386 | ||
386 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 387 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
387 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 388 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
388 | 389 | ||
389 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 390 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
390 | 391 | ||
391 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 392 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
392 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 393 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
393 | 394 | ||
394 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 395 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
395 | 396 | ||
396 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 397 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
397 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 398 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
398 | 399 | ||
399 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 400 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
400 | 401 | ||
401 | if ( has_wav_alarm ) { | 402 | if ( has_wav_alarm ) { |
402 | alarmBox-> hide ( ); | 403 | alarmBox-> hide ( ); |
403 | } | 404 | } |
404 | 405 | ||
405 | vbox-> addStretch ( 100 ); | 406 | vbox-> addStretch ( 100 ); |
406 | 407 | ||
407 | setFixedSize ( sizeHint ( )); | 408 | setFixedSize ( sizeHint ( )); |
408 | setFocusPolicy ( QWidget::NoFocus ); | 409 | setFocusPolicy ( QWidget::NoFocus ); |
409 | 410 | ||
410 | rateTimer = new QTimer( this ); | 411 | rateTimer = new QTimer( this ); |
411 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); | 412 | connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); |
412 | 413 | ||
413 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 414 | connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
414 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 415 | connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
415 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); | 416 | connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); |
416 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); | 417 | connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); |
417 | 418 | ||
418 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); | 419 | connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); |
419 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); | 420 | connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); |
420 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); | 421 | connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); |
421 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); | 422 | connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); |
422 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); | 423 | connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); |
423 | 424 | ||
424 | 425 | ||
425 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); | 426 | connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); |
426 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); | 427 | connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); |
427 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 428 | connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
428 | 429 | ||
429 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); | 430 | connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); |
430 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); | 431 | connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); |
431 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); | 432 | connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); |
432 | 433 | ||
433 | // initialize variables | 434 | // initialize variables |
434 | 435 | ||
435 | readConfig ( true ); | 436 | readConfig ( true ); |
436 | 437 | ||
437 | // initialize the config file, in case some entries are missing | 438 | // initialize the config file, in case some entries are missing |
438 | 439 | ||
439 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 440 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
440 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | 441 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); |
441 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | 442 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); |
442 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 443 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
443 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 444 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
444 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 445 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
445 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 446 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
446 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 447 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
447 | 448 | ||
448 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 449 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
449 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 450 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
450 | } | 451 | } |
451 | 452 | ||
452 | bool VolumeControl::volMuted ( ) const | 453 | bool VolumeControl::volMuted ( ) const |
453 | { | 454 | { |
454 | return m_vol_muted; | 455 | return m_vol_muted; |
455 | } | 456 | } |
456 | 457 | ||
457 | int VolumeControl::volPercent ( ) const | 458 | int VolumeControl::volPercent ( ) const |
458 | { | 459 | { |
459 | return m_vol_percent; | 460 | return m_vol_percent; |
460 | } | 461 | } |
461 | 462 | ||
462 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) | 463 | void VolumeControl::keyPressEvent ( QKeyEvent *e ) |
463 | { | 464 | { |
464 | switch ( e-> key ( )) { | 465 | switch ( e-> key ( )) { |
465 | case Key_Up: | 466 | case Key_Up: |
466 | volSlider-> subtractStep ( ); | 467 | volSlider-> subtractStep ( ); |
467 | break; | 468 | break; |
468 | case Key_Down: | 469 | case Key_Down: |
469 | volSlider-> addStep ( ); | 470 | volSlider-> addStep ( ); |
470 | break; | 471 | break; |
471 | case Key_Space: | 472 | case Key_Space: |
472 | volLed-> toggle ( ); | 473 | volLed-> toggle ( ); |
473 | break; | 474 | break; |
474 | case Key_Escape: | 475 | case Key_Escape: |
475 | hide ( ); | 476 | hide ( ); |
476 | break; | 477 | break; |
477 | } | 478 | } |
478 | } | 479 | } |
479 | 480 | ||
480 | void VolumeControl::buttonChanged ( ) | 481 | void VolumeControl::buttonChanged ( ) |
481 | { | 482 | { |
482 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { | 483 | if ( upButton-> isDown ( ) || downButton->isDown ( )) { |
483 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get | 484 | rateTimerDone ( ); // Call it one time manually, otherwise it wont get |
484 | // called at all when a button is pressed for a time | 485 | // called at all when a button is pressed for a time |
485 | // shorter than RATE_TIMER_INTERVAL. | 486 | // shorter than RATE_TIMER_INTERVAL. |
486 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); | 487 | rateTimer-> start ( RATE_TIMER_INTERVAL, false ); |
487 | } | 488 | } |
488 | else | 489 | else |
489 | rateTimer-> stop ( ); | 490 | rateTimer-> stop ( ); |
490 | } | 491 | } |
491 | 492 | ||
492 | void VolumeControl::rateTimerDone ( ) | 493 | void VolumeControl::rateTimerDone ( ) |
493 | { | 494 | { |
494 | if ( upButton-> isDown ( )) | 495 | if ( upButton-> isDown ( )) |
495 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); | 496 | volSlider-> setValue ( volSlider-> value ( ) - 2 ); |
496 | else // if ( downButton-> isDown ( )) | 497 | else // if ( downButton-> isDown ( )) |
497 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); | 498 | volSlider-> setValue ( volSlider-> value ( ) + 2 ); |
498 | } | 499 | } |
499 | 500 | ||
500 | void VolumeControl::show ( bool /*showMic*/ ) | 501 | void VolumeControl::show ( bool /*showMic*/ ) |
501 | { | 502 | { |
502 | readConfig ( ); | 503 | readConfig ( ); |
503 | 504 | ||
504 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 505 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
505 | 506 | ||
506 | int w = sizeHint ( ). width ( ); | 507 | int w = sizeHint ( ). width ( ); |
507 | int x = curPos.x ( ) - ( w / 2 ); | 508 | int x = curPos.x ( ) - ( w / 2 ); |
508 | 509 | ||
509 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 510 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
510 | x = QPEApplication::desktop ( )-> width ( ) - w; | 511 | x = QPEApplication::desktop ( )-> width ( ) - w; |
511 | 512 | ||
512 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 513 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
513 | QFrame::show ( ); | 514 | QFrame::show ( ); |
514 | 515 | ||
515 | } | 516 | } |
516 | 517 | ||
517 | void VolumeControl::readConfig ( bool force ) | 518 | void VolumeControl::readConfig ( bool force ) |
518 | { | 519 | { |
519 | Config cfg ( "qpe" ); | 520 | Config cfg ( "qpe" ); |
520 | cfg. setGroup ( "Volume" ); | 521 | cfg. setGroup ( "Volume" ); |
521 | 522 | ||
522 | int old_vp = m_vol_percent; | 523 | int old_vp = m_vol_percent; |
523 | int old_mp = m_mic_percent; | 524 | int old_mp = m_mic_percent; |
524 | int old_bass = m_bass_percent; | 525 | int old_bass = m_bass_percent; |
525 | int old_treble = m_treble_percent; | 526 | int old_treble = m_treble_percent; |
526 | bool old_vm = m_vol_muted; | 527 | bool old_vm = m_vol_muted; |
527 | bool old_mm = m_mic_muted; | 528 | bool old_mm = m_mic_muted; |
528 | bool old_sk = m_snd_key; | 529 | bool old_sk = m_snd_key; |
529 | bool old_st = m_snd_touch; | 530 | bool old_st = m_snd_touch; |
530 | bool old_sa = m_snd_alarm; | 531 | bool old_sa = m_snd_alarm; |
531 | int old_ap = m_alarm_percent; | 532 | int old_ap = m_alarm_percent; |
532 | 533 | ||
533 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 534 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
534 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 535 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
535 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | 536 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); |
536 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | 537 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); |
537 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 538 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
538 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 539 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
539 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 540 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
540 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 541 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
541 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 542 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
542 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 543 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
543 | 544 | ||
544 | if ( force || ( m_vol_percent != old_vp )) | 545 | if ( force || ( m_vol_percent != old_vp )) |
545 | volSlider-> setValue ( 100 - m_vol_percent ); | 546 | volSlider-> setValue ( 100 - m_vol_percent ); |
546 | if ( force || ( m_mic_percent != old_mp )) | 547 | if ( force || ( m_mic_percent != old_mp )) |
547 | micSlider-> setValue ( 100 - m_mic_percent ); | 548 | micSlider-> setValue ( 100 - m_mic_percent ); |
548 | if ( force || ( m_alarm_percent != old_ap )) | 549 | if ( force || ( m_alarm_percent != old_ap )) |
549 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 550 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
550 | if ( force || ( m_bass_percent != old_bass )) | 551 | if ( force || ( m_bass_percent != old_bass )) |
551 | bassSlider-> setValue ( 100 - m_bass_percent ); | 552 | bassSlider-> setValue ( 100 - m_bass_percent ); |
552 | if ( force || ( m_treble_percent != old_treble )) | 553 | if ( force || ( m_treble_percent != old_treble )) |
553 | trebleSlider-> setValue ( 100 - m_treble_percent ); | 554 | trebleSlider-> setValue ( 100 - m_treble_percent ); |
554 | 555 | ||
555 | 556 | ||
556 | if ( force || ( m_vol_muted != old_vm )) | 557 | if ( force || ( m_vol_muted != old_vm )) |
557 | volLed-> setOn ( !m_vol_muted ); | 558 | volLed-> setOn ( !m_vol_muted ); |
558 | if ( force || ( m_mic_muted != old_mm )) | 559 | if ( force || ( m_mic_muted != old_mm )) |
559 | micLed-> setOn ( !m_mic_muted ); | 560 | micLed-> setOn ( !m_mic_muted ); |
560 | if ( force || ( m_snd_alarm != old_sa )) | 561 | if ( force || ( m_snd_alarm != old_sa )) |
561 | alarmLed-> setOn ( m_snd_alarm ); | 562 | alarmLed-> setOn ( m_snd_alarm ); |
562 | 563 | ||
563 | if ( force || ( m_snd_key != old_sk )) | 564 | if ( force || ( m_snd_key != old_sk )) |
564 | keyBox-> setChecked ( m_snd_key ); | 565 | keyBox-> setChecked ( m_snd_key ); |
565 | if ( force || ( m_snd_touch != old_st )) | 566 | if ( force || ( m_snd_touch != old_st )) |
566 | tapBox-> setChecked ( m_snd_touch ); | 567 | tapBox-> setChecked ( m_snd_touch ); |
567 | if ( force || ( m_snd_alarm != old_sa )) | 568 | if ( force || ( m_snd_alarm != old_sa )) |
568 | alarmBox-> setChecked ( m_snd_alarm ); | 569 | alarmBox-> setChecked ( m_snd_alarm ); |
569 | } | 570 | } |
570 | 571 | ||
571 | 572 | ||
572 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 573 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
573 | { | 574 | { |
574 | int prevVol = m_vol_percent; | 575 | int prevVol = m_vol_percent; |
575 | bool prevMute = m_vol_muted; | 576 | bool prevMute = m_vol_muted; |
576 | 577 | ||
577 | readConfig ( ); | 578 | readConfig ( ); |
578 | 579 | ||
579 | // Handle case where muting it toggled | 580 | // Handle case where muting it toggled |
580 | if ( m_vol_muted != prevMute ) | 581 | if ( m_vol_muted != prevMute ) |
581 | m_icon-> redraw ( true ); | 582 | m_icon-> redraw ( true ); |
582 | else if ( prevVol != m_vol_percent ) // Avoid over repainting | 583 | else if ( prevVol != m_vol_percent ) // Avoid over repainting |
583 | m_icon-> redraw ( false ); | 584 | m_icon-> redraw ( false ); |
584 | } | 585 | } |
585 | 586 | ||
586 | void VolumeControl::micChanged ( bool nowMuted ) | 587 | void VolumeControl::micChanged ( bool nowMuted ) |
587 | { | 588 | { |
588 | if ( !nowMuted ) | 589 | if ( !nowMuted ) |
589 | readConfig ( ); | 590 | readConfig ( ); |
590 | m_mic_muted = nowMuted; | 591 | m_mic_muted = nowMuted; |
591 | } | 592 | } |
592 | 593 | ||
593 | void VolumeControl::screenTapToggled ( bool b ) | 594 | void VolumeControl::screenTapToggled ( bool b ) |
594 | { | 595 | { |
595 | m_snd_touch = b; | 596 | m_snd_touch = b; |
596 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); | 597 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); |
597 | } | 598 | } |
598 | 599 | ||
599 | void VolumeControl::keyClickToggled ( bool b ) | 600 | void VolumeControl::keyClickToggled ( bool b ) |
600 | { | 601 | { |
601 | m_snd_key = b; | 602 | m_snd_key = b; |
602 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); | 603 | writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); |
603 | } | 604 | } |
604 | 605 | ||
605 | void VolumeControl::alarmSoundToggled ( bool b ) | 606 | void VolumeControl::alarmSoundToggled ( bool b ) |
606 | { | 607 | { |
607 | m_snd_alarm = b; | 608 | m_snd_alarm = b; |
608 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 609 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
609 | } | 610 | } |
610 | 611 | ||
611 | void VolumeControl::volMuteToggled ( bool b ) | 612 | void VolumeControl::volMuteToggled ( bool b ) |
612 | { | 613 | { |
613 | m_vol_muted = !b; | 614 | m_vol_muted = !b; |
614 | 615 | ||
615 | m_icon-> redraw ( true ); | 616 | m_icon-> redraw ( true ); |
616 | 617 | ||
617 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 618 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
618 | } | 619 | } |
619 | 620 | ||
620 | void VolumeControl::micMuteToggled ( bool b ) | 621 | void VolumeControl::micMuteToggled ( bool b ) |
621 | { | 622 | { |
622 | m_mic_muted = !b; | 623 | m_mic_muted = !b; |
623 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 624 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
624 | } | 625 | } |
625 | 626 | ||
626 | 627 | ||
627 | void VolumeControl::volMoved ( int percent ) | 628 | void VolumeControl::volMoved ( int percent ) |
628 | { | 629 | { |
629 | m_vol_percent = 100 - percent; | 630 | m_vol_percent = 100 - percent; |
630 | 631 | ||
631 | // clamp volume percent to be between 0 and 100 | 632 | // clamp volume percent to be between 0 and 100 |
632 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 633 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
633 | // repaint just the little volume rectangle | 634 | // repaint just the little volume rectangle |
634 | m_icon-> redraw ( false ); | 635 | m_icon-> redraw ( false ); |
635 | 636 | ||
636 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 637 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
637 | } | 638 | } |
638 | 639 | ||
639 | void VolumeControl::micMoved ( int percent ) | 640 | void VolumeControl::micMoved ( int percent ) |
640 | { | 641 | { |
641 | m_mic_percent = 100 - percent; | 642 | m_mic_percent = 100 - percent; |
642 | 643 | ||
643 | // clamp volume percent to be between 0 and 100 | 644 | // clamp volume percent to be between 0 and 100 |
644 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); | 645 | m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); |
645 | 646 | ||
646 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); | 647 | writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); |
647 | } | 648 | } |
648 | 649 | ||
649 | void VolumeControl::alarmMoved ( int percent ) | 650 | void VolumeControl::alarmMoved ( int percent ) |
650 | { | 651 | { |
651 | m_alarm_percent = 100 - percent; | 652 | m_alarm_percent = 100 - percent; |
652 | 653 | ||
653 | // clamp volume percent to be between 0 and 100 | 654 | // clamp volume percent to be between 0 and 100 |
654 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 655 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
655 | 656 | ||
656 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 657 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | void VolumeControl::bassMoved ( int percent ) | 661 | void VolumeControl::bassMoved ( int percent ) |
661 | { | 662 | { |
662 | m_bass_percent = 100 - percent; | 663 | m_bass_percent = 100 - percent; |
663 | 664 | ||
664 | // clamp bass percent to be between 0 and 100 | 665 | // clamp bass percent to be between 0 and 100 |
665 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | 666 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); |
666 | 667 | ||
667 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | 668 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); |
668 | } | 669 | } |
669 | 670 | ||
670 | 671 | ||
671 | 672 | ||
672 | void VolumeControl::trebleMoved ( int percent ) | 673 | void VolumeControl::trebleMoved ( int percent ) |
673 | { | 674 | { |
674 | m_treble_percent = 100 - percent; | 675 | m_treble_percent = 100 - percent; |
675 | 676 | ||
676 | // clamp treble percent to be between 0 and 100 | 677 | // clamp treble percent to be between 0 and 100 |
677 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | 678 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); |
678 | 679 | ||
679 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | 680 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); |
680 | } | 681 | } |
681 | 682 | ||
682 | 683 | ||
683 | 684 | ||
684 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 685 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
685 | { | 686 | { |
686 | Config cfg ( "qpe" ); | 687 | Config cfg ( "qpe" ); |
687 | cfg. setGroup ( "Volume" ); | 688 | cfg. setGroup ( "Volume" ); |
688 | cfg. writeEntry ( entry, val ); | 689 | cfg. writeEntry ( entry, val ); |
689 | // cfg. write ( ); | 690 | // cfg. write ( ); |
690 | 691 | ||
691 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 692 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
692 | switch ( upd ) { | 693 | switch ( upd ) { |
693 | case UPD_Vol: { | 694 | case UPD_Vol: { |
694 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 695 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
695 | break; | 696 | break; |
696 | } | 697 | } |
697 | case UPD_Mic: { | 698 | case UPD_Mic: { |
698 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 699 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
699 | break; | 700 | break; |
700 | } | 701 | } |
701 | case UPD_Bass: { | 702 | case UPD_Bass: { |
702 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | 703 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; |
703 | break; | 704 | break; |
704 | } | 705 | } |
705 | case UPD_Treble: { | 706 | case UPD_Treble: { |
706 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | 707 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; |
707 | break; | 708 | break; |
708 | } | 709 | } |
709 | 710 | ||
710 | case UPD_None: | 711 | case UPD_None: |
711 | break; | 712 | break; |
712 | } | 713 | } |
713 | #endif | 714 | #endif |
714 | } | 715 | } |
715 | 716 | ||
716 | //=========================================================================== | 717 | //=========================================================================== |
717 | 718 | ||
718 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 719 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) |
719 | : QWidget( parent, name ) | 720 | : QWidget( parent, name ) |
720 | { | 721 | { |
721 | setFixedWidth ( AppLnk::smallIconSize() ); | 722 | setFixedWidth ( AppLnk::smallIconSize() ); |
722 | setFixedHeight ( AppLnk::smallIconSize()+4 ); | 723 | setFixedHeight ( AppLnk::smallIconSize()+4 ); |
723 | 724 | ||
724 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); | 725 | m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); |
725 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); | 726 | m_dialog = new VolumeControl ( this, true, this, "volumecontrol" ); |
726 | 727 | ||
727 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); | 728 | connect ( qApp, SIGNAL( volumeChanged(bool)), m_dialog, SLOT( volumeChanged(bool))); |
728 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); | 729 | connect ( qApp, SIGNAL( micChanged(bool)), m_dialog, SLOT ( micChanged(bool))); |
729 | } | 730 | } |
730 | 731 | ||
731 | VolumeApplet::~VolumeApplet() | 732 | VolumeApplet::~VolumeApplet() |
732 | { | 733 | { |
733 | delete m_pixmap; | 734 | delete m_pixmap; |
734 | } | 735 | } |
735 | 736 | ||
736 | int VolumeApplet::position() | 737 | int VolumeApplet::position() |
737 | { | 738 | { |
738 | return 6; | 739 | return 6; |
739 | } | 740 | } |
740 | 741 | ||
741 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) | 742 | void VolumeApplet::mousePressEvent ( QMouseEvent * ) |
742 | { | 743 | { |
743 | if ( m_dialog-> isVisible ( )) | 744 | if ( m_dialog-> isVisible ( )) |
744 | m_dialog-> hide ( ); | 745 | m_dialog-> hide ( ); |
745 | else | 746 | else |
746 | m_dialog-> show ( true ); | 747 | m_dialog-> show ( true ); |
747 | } | 748 | } |
748 | 749 | ||
749 | void VolumeApplet::redraw ( bool all ) | 750 | void VolumeApplet::redraw ( bool all ) |
750 | { | 751 | { |
751 | if ( all ) | 752 | if ( all ) |
752 | repaint ( true ); | 753 | repaint ( true ); |
753 | else | 754 | else |
754 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); | 755 | repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); |
755 | } | 756 | } |
756 | 757 | ||
757 | 758 | ||
758 | void VolumeApplet::paintEvent ( QPaintEvent * ) | 759 | void VolumeApplet::paintEvent ( QPaintEvent * ) |
759 | { | 760 | { |
760 | QPainter p ( this ); | 761 | QPainter p ( this ); |
761 | 762 | ||
762 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); | 763 | p. drawPixmap ( (width()- m_pixmap->width())/2, QMAX( (height()-4-m_pixmap->height() )/2, 1), *m_pixmap ); |
763 | p. setPen ( darkGray ); | 764 | p. setPen ( darkGray ); |
764 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); | 765 | p. drawRect ( 1, height() - 4, width() - 2, 4 ); |
765 | 766 | ||
766 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; | 767 | int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; |
767 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); | 768 | p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); |
768 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); | 769 | p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); |
769 | 770 | ||
770 | if ( m_dialog-> volMuted ( )) { | 771 | if ( m_dialog-> volMuted ( )) { |
771 | p. setPen ( red ); | 772 | p. setPen ( red ); |
772 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); | 773 | p. drawLine ( 1, 2, width() - 2, height() - 5 ); |
773 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); | 774 | p. drawLine ( 1, 3, width() - 2, height() - 4 ); |
774 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); | 775 | p. drawLine ( width() - 2, 2, 1, height() - 5 ); |
775 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); | 776 | p. drawLine ( width() - 2, 3, 1, height() - 4 ); |
776 | } | 777 | } |
777 | } | 778 | } |
778 | 779 | ||
779 | 780 | ||
780 | Q_EXPORT_INTERFACE() | 781 | EXPORT_OPIE_APPLET_v1( VolumeApplet ) |
781 | { | ||
782 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<VolumeApplet> ); | ||
783 | } | ||
diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro index b14956e..b478ed1 100644 --- a/core/applets/volumeapplet/volumeapplet.pro +++ b/core/applets/volumeapplet/volumeapplet.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS = volume.h oledbox.h | 3 | HEADERS = volume.h oledbox.h |
4 | SOURCES = volume.cpp oledbox.cpp | 4 | SOURCES = volume.cpp oledbox.cpp |
5 | TARGET = volumeapplet | 5 | TARGET = volumeapplet |
6 | DESTDIR = $(OPIEDIR)/plugins/applets | 6 | DESTDIR = $(OPIEDIR)/plugins/applets |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe -lopiecore2 |
10 | VERSION = 1.0.0 | 10 | VERSION = 1.0.0 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/applets/vtapplet/config.in b/core/applets/vtapplet/config.in index 85692a5..8fe4200 100644 --- a/core/applets/vtapplet/config.in +++ b/core/applets/vtapplet/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config VTAPPLET | 1 | config VTAPPLET |
2 | boolean "VT (switch to another virtual terminal)" | 2 | boolean "VT (switch to another virtual terminal)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/obex/config.in b/core/obex/config.in index ef09f7a..c0208d1 100644 --- a/core/obex/config.in +++ b/core/obex/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config OBEX | 1 | config OBEX |
2 | boolean "libopieobex0 (library needed for beaming in Opie)" | 2 | boolean "libopieobex0 (library needed for beaming in Opie)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIECORE2 |
diff --git a/core/obex/obex.cc b/core/obex/obex.cc index 50e5201..3c99af6 100644 --- a/core/obex/obex.cc +++ b/core/obex/obex.cc | |||
@@ -1,199 +1,200 @@ | |||
1 | 1 | ||
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include <opie/oprocess.h> | 5 | #include <opie2/oprocess.h> |
6 | #include "obex.h" | 6 | #include "obex.h" |
7 | 7 | ||
8 | using namespace OpieObex; | 8 | using namespace OpieObex; |
9 | 9 | ||
10 | using namespace Opie::Core; | ||
10 | /* TRANSLATOR OpieObex::Obex */ | 11 | /* TRANSLATOR OpieObex::Obex */ |
11 | 12 | ||
12 | Obex::Obex( QObject *parent, const char* name ) | 13 | Obex::Obex( QObject *parent, const char* name ) |
13 | : QObject(parent, name ) | 14 | : QObject(parent, name ) |
14 | { | 15 | { |
15 | m_rec = 0; | 16 | m_rec = 0; |
16 | m_send=0; | 17 | m_send=0; |
17 | m_count = 0; | 18 | m_count = 0; |
18 | m_receive = false; | 19 | m_receive = false; |
19 | connect( this, SIGNAL(error(int) ), // for recovering to receive | 20 | connect( this, SIGNAL(error(int) ), // for recovering to receive |
20 | SLOT(slotError() ) ); | 21 | SLOT(slotError() ) ); |
21 | connect( this, SIGNAL(sent(bool) ), | 22 | connect( this, SIGNAL(sent(bool) ), |
22 | SLOT(slotError() ) ); | 23 | SLOT(slotError() ) ); |
23 | }; | 24 | }; |
24 | Obex::~Obex() { | 25 | Obex::~Obex() { |
25 | delete m_rec; | 26 | delete m_rec; |
26 | delete m_send; | 27 | delete m_send; |
27 | } | 28 | } |
28 | void Obex::receive() { | 29 | void Obex::receive() { |
29 | m_receive = true; | 30 | m_receive = true; |
30 | m_outp = QString::null; | 31 | m_outp = QString::null; |
31 | qWarning("Receive" ); | 32 | qWarning("Receive" ); |
32 | m_rec = new OProcess(); | 33 | m_rec = new OProcess(); |
33 | *m_rec << "irobex_palm3"; | 34 | *m_rec << "irobex_palm3"; |
34 | // connect to the necessary slots | 35 | // connect to the necessary slots |
35 | connect(m_rec, SIGNAL(processExited(OProcess*) ), | 36 | connect(m_rec, SIGNAL(processExited(Opie::Core::OProcess*) ), |
36 | this, SLOT(slotExited(OProcess*) ) ); | 37 | this, SLOT(slotExited(Opie::Core::OProcess*) ) ); |
37 | 38 | ||
38 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 39 | connect(m_rec, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), |
39 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 40 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); |
40 | 41 | ||
41 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 42 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
42 | qWarning("could not start :("); | 43 | qWarning("could not start :("); |
43 | emit done( false ); | 44 | emit done( false ); |
44 | delete m_rec; | 45 | delete m_rec; |
45 | m_rec = 0; | 46 | m_rec = 0; |
46 | } | 47 | } |
47 | // emit currentTry(m_count ); | 48 | // emit currentTry(m_count ); |
48 | 49 | ||
49 | } | 50 | } |
50 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive | 51 | void Obex::send( const QString& fileName) { // if currently receiving stop it send receive |
51 | m_count = 0; | 52 | m_count = 0; |
52 | m_file = fileName; | 53 | m_file = fileName; |
53 | qWarning("send %s", fileName.latin1() ); | 54 | qWarning("send %s", fileName.latin1() ); |
54 | if (m_rec != 0 ) { | 55 | if (m_rec != 0 ) { |
55 | qWarning("running"); | 56 | qWarning("running"); |
56 | if (m_rec->isRunning() ) { | 57 | if (m_rec->isRunning() ) { |
57 | emit error(-1 ); | 58 | emit error(-1 ); |
58 | qWarning("is running"); | 59 | qWarning("is running"); |
59 | delete m_rec; | 60 | delete m_rec; |
60 | m_rec = 0; | 61 | m_rec = 0; |
61 | 62 | ||
62 | }else{ | 63 | }else{ |
63 | qWarning("is not running"); | 64 | qWarning("is not running"); |
64 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending | 65 | emit error( -1 ); // we did not delete yet but it's not running slotExited is pending |
65 | return; | 66 | return; |
66 | } | 67 | } |
67 | } | 68 | } |
68 | sendNow(); | 69 | sendNow(); |
69 | } | 70 | } |
70 | void Obex::sendNow(){ | 71 | void Obex::sendNow(){ |
71 | qWarning("sendNow"); | 72 | qWarning("sendNow"); |
72 | if ( m_count >= 25 ) { // could not send | 73 | if ( m_count >= 25 ) { // could not send |
73 | emit error(-1 ); | 74 | emit error(-1 ); |
74 | emit sent(false); | 75 | emit sent(false); |
75 | return; | 76 | return; |
76 | } | 77 | } |
77 | // OProcess inititialisation | 78 | // OProcess inititialisation |
78 | m_send = new OProcess(); | 79 | m_send = new OProcess(); |
79 | *m_send << "irobex_palm3"; | 80 | *m_send << "irobex_palm3"; |
80 | *m_send << QFile::encodeName(m_file); | 81 | *m_send << QFile::encodeName(m_file); |
81 | 82 | ||
82 | // connect to slots Exited and and StdOut | 83 | // connect to slots Exited and and StdOut |
83 | connect(m_send, SIGNAL(processExited(OProcess*) ), | 84 | connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), |
84 | this, SLOT(slotExited(OProcess*)) ); | 85 | this, SLOT(slotExited(Opie::Core::OProcess*)) ); |
85 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), | 86 | connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )), |
86 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 87 | this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); |
87 | 88 | ||
88 | // now start it | 89 | // now start it |
89 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 90 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
90 | qWarning("could not send" ); | 91 | qWarning("could not send" ); |
91 | m_count = 25; | 92 | m_count = 25; |
92 | emit error(-1 ); | 93 | emit error(-1 ); |
93 | delete m_send; | 94 | delete m_send; |
94 | m_send=0; | 95 | m_send=0; |
95 | } | 96 | } |
96 | // end | 97 | // end |
97 | m_count++; | 98 | m_count++; |
98 | emit currentTry( m_count ); | 99 | emit currentTry( m_count ); |
99 | } | 100 | } |
100 | 101 | ||
101 | void Obex::slotExited(OProcess* proc ){ | 102 | void Obex::slotExited(OProcess* proc ){ |
102 | if (proc == m_rec ) { // receive process | 103 | if (proc == m_rec ) { // receive process |
103 | received(); | 104 | received(); |
104 | }else if ( proc == m_send ) { | 105 | }else if ( proc == m_send ) { |
105 | sendEnd(); | 106 | sendEnd(); |
106 | } | 107 | } |
107 | } | 108 | } |
108 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | 109 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
109 | if ( proc == m_rec ) { // only receive | 110 | if ( proc == m_rec ) { // only receive |
110 | QByteArray ar( len ); | 111 | QByteArray ar( len ); |
111 | memcpy( ar.data(), buf, len ); | 112 | memcpy( ar.data(), buf, len ); |
112 | qWarning("parsed: %s", ar.data() ); | 113 | qWarning("parsed: %s", ar.data() ); |
113 | m_outp.append( ar ); | 114 | m_outp.append( ar ); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | void Obex::received() { | 118 | void Obex::received() { |
118 | if (m_rec->normalExit() ) { | 119 | if (m_rec->normalExit() ) { |
119 | if ( m_rec->exitStatus() == 0 ) { // we got one | 120 | if ( m_rec->exitStatus() == 0 ) { // we got one |
120 | QString filename = parseOut(); | 121 | QString filename = parseOut(); |
121 | qWarning("ACHTUNG %s", filename.latin1() ); | 122 | qWarning("ACHTUNG %s", filename.latin1() ); |
122 | emit receivedFile( filename ); | 123 | emit receivedFile( filename ); |
123 | } | 124 | } |
124 | }else{ | 125 | }else{ |
125 | emit done(false); | 126 | emit done(false); |
126 | }; | 127 | }; |
127 | delete m_rec; | 128 | delete m_rec; |
128 | m_rec = 0; | 129 | m_rec = 0; |
129 | receive(); | 130 | receive(); |
130 | } | 131 | } |
131 | 132 | ||
132 | void Obex::sendEnd() { | 133 | void Obex::sendEnd() { |
133 | if (m_send->normalExit() ) { | 134 | if (m_send->normalExit() ) { |
134 | if ( m_send->exitStatus() == 0 ) { | 135 | if ( m_send->exitStatus() == 0 ) { |
135 | delete m_send; | 136 | delete m_send; |
136 | m_send=0; | 137 | m_send=0; |
137 | qWarning("done" ); | 138 | qWarning("done" ); |
138 | emit sent(true); | 139 | emit sent(true); |
139 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | 140 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready |
140 | // let's try it again | 141 | // let's try it again |
141 | delete m_send; | 142 | delete m_send; |
142 | m_send = 0; | 143 | m_send = 0; |
143 | qWarning("try sending again" ); | 144 | qWarning("try sending again" ); |
144 | sendNow(); | 145 | sendNow(); |
145 | } | 146 | } |
146 | }else { | 147 | }else { |
147 | emit error( -1 ); | 148 | emit error( -1 ); |
148 | delete m_send; | 149 | delete m_send; |
149 | m_send = 0; | 150 | m_send = 0; |
150 | } | 151 | } |
151 | } | 152 | } |
152 | QString Obex::parseOut( ){ | 153 | QString Obex::parseOut( ){ |
153 | QString path; | 154 | QString path; |
154 | QStringList list = QStringList::split("\n", m_outp); | 155 | QStringList list = QStringList::split("\n", m_outp); |
155 | QStringList::Iterator it; | 156 | QStringList::Iterator it; |
156 | for (it = list.begin(); it != list.end(); ++it ) { | 157 | for (it = list.begin(); it != list.end(); ++it ) { |
157 | if ( (*it).startsWith("Wrote" ) ) { | 158 | if ( (*it).startsWith("Wrote" ) ) { |
158 | int pos = (*it).findRev('(' ); | 159 | int pos = (*it).findRev('(' ); |
159 | if ( pos > 0 ) { | 160 | if ( pos > 0 ) { |
160 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; | 161 | qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; |
161 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); | 162 | qWarning("%d %d", (*it).length(), (*it).length()-pos ); |
162 | 163 | ||
163 | path = (*it).remove( pos, (*it).length() - pos ); | 164 | path = (*it).remove( pos, (*it).length() - pos ); |
164 | qWarning("%s", path.latin1() ); | 165 | qWarning("%s", path.latin1() ); |
165 | path = path.mid(6 ); | 166 | path = path.mid(6 ); |
166 | path = path.stripWhiteSpace(); | 167 | path = path.stripWhiteSpace(); |
167 | qWarning("path %s", path.latin1() ); | 168 | qWarning("path %s", path.latin1() ); |
168 | } | 169 | } |
169 | } | 170 | } |
170 | } | 171 | } |
171 | return path; | 172 | return path; |
172 | } | 173 | } |
173 | /** | 174 | /** |
174 | * when sent is done slotError is called we will start receive again | 175 | * when sent is done slotError is called we will start receive again |
175 | */ | 176 | */ |
176 | void Obex::slotError() { | 177 | void Obex::slotError() { |
177 | qWarning("slotError"); | 178 | qWarning("slotError"); |
178 | if ( m_receive ) | 179 | if ( m_receive ) |
179 | receive(); | 180 | receive(); |
180 | }; | 181 | }; |
181 | void Obex::setReceiveEnabled( bool receive ) { | 182 | void Obex::setReceiveEnabled( bool receive ) { |
182 | if ( !receive ) { // | 183 | if ( !receive ) { // |
183 | m_receive = false; | 184 | m_receive = false; |
184 | shutDownReceive(); | 185 | shutDownReceive(); |
185 | } | 186 | } |
186 | } | 187 | } |
187 | 188 | ||
188 | void Obex::shutDownReceive() { | 189 | void Obex::shutDownReceive() { |
189 | if (m_rec != 0 ) { | 190 | if (m_rec != 0 ) { |
190 | qWarning("running"); | 191 | qWarning("running"); |
191 | if (m_rec->isRunning() ) { | 192 | if (m_rec->isRunning() ) { |
192 | emit error(-1 ); | 193 | emit error(-1 ); |
193 | qWarning("is running"); | 194 | qWarning("is running"); |
194 | delete m_rec; | 195 | delete m_rec; |
195 | m_rec = 0; | 196 | m_rec = 0; |
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
199 | } | 200 | } |
diff --git a/core/obex/obex.h b/core/obex/obex.h index 60f5d28..284cb12 100644 --- a/core/obex/obex.h +++ b/core/obex/obex.h | |||
@@ -1,84 +1,84 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #ifndef OpieObex_H | 3 | #ifndef OpieObex_H |
4 | #define OpieObex_H | 4 | #define OpieObex_H |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | 7 | ||
8 | class OProcess; | 8 | namespace Opie {namespace Core {class OProcess;}} |
9 | class QCopChannel; | 9 | class QCopChannel; |
10 | namespace OpieObex { | 10 | namespace OpieObex { |
11 | class Obex : public QObject { | 11 | class Obex : public QObject { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | public: | 13 | public: |
14 | /** | 14 | /** |
15 | * Obex c'tor look | 15 | * Obex c'tor look |
16 | */ | 16 | */ |
17 | Obex( QObject *parent, const char* name); | 17 | Obex( QObject *parent, const char* name); |
18 | /** | 18 | /** |
19 | * d'tor | 19 | * d'tor |
20 | */ | 20 | */ |
21 | ~Obex(); | 21 | ~Obex(); |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Starting listening to irda after enabled by the applet | 24 | * Starting listening to irda after enabled by the applet |
25 | * a signal gets emitted when recieved a file | 25 | * a signal gets emitted when recieved a file |
26 | */ | 26 | */ |
27 | void receive(); | 27 | void receive(); |
28 | void send( const QString& ); | 28 | void send( const QString& ); |
29 | void setReceiveEnabled( bool = false ); | 29 | void setReceiveEnabled( bool = false ); |
30 | signals: | 30 | signals: |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * a signal | 33 | * a signal |
34 | * @param path The path to the recieved file | 34 | * @param path The path to the recieved file |
35 | */ | 35 | */ |
36 | void receivedFile( const QString& path); | 36 | void receivedFile( const QString& path); |
37 | /** | 37 | /** |
38 | * error signal if the program couldn't be started or the | 38 | * error signal if the program couldn't be started or the |
39 | * the connection timed out | 39 | * the connection timed out |
40 | */ | 40 | */ |
41 | void error( int ); | 41 | void error( int ); |
42 | /** | 42 | /** |
43 | * The current try to receive data | 43 | * The current try to receive data |
44 | */ | 44 | */ |
45 | void currentTry(unsigned int); | 45 | void currentTry(unsigned int); |
46 | /** | 46 | /** |
47 | * signal sent The file got beamed to the remote location | 47 | * signal sent The file got beamed to the remote location |
48 | */ | 48 | */ |
49 | void sent(bool); | 49 | void sent(bool); |
50 | void done(bool); | 50 | void done(bool); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | uint m_count; | 53 | uint m_count; |
54 | QString m_file; | 54 | QString m_file; |
55 | QString m_outp; | 55 | QString m_outp; |
56 | OProcess *m_send; | 56 | Opie::Core::OProcess *m_send; |
57 | OProcess *m_rec; | 57 | Opie::Core::OProcess *m_rec; |
58 | bool m_receive : 1; | 58 | bool m_receive : 1; |
59 | void shutDownReceive(); | 59 | void shutDownReceive(); |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * send over palm obex | 64 | * send over palm obex |
65 | */ | 65 | */ |
66 | 66 | ||
67 | //void send(const QString&); | 67 | //void send(const QString&); |
68 | 68 | ||
69 | // the process exited | 69 | // the process exited |
70 | void slotExited(OProcess* proc) ; | 70 | void slotExited(Opie::Core::OProcess* proc) ; |
71 | void slotStdOut(OProcess*, char*, int); | 71 | void slotStdOut(Opie::Core::OProcess*, char*, int); |
72 | void slotError(); | 72 | void slotError(); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | void sendNow(); | 75 | void sendNow(); |
76 | QString parseOut(); | 76 | QString parseOut(); |
77 | void received(); | 77 | void received(); |
78 | void sendEnd(); | 78 | void sendEnd(); |
79 | 79 | ||
80 | }; | 80 | }; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | #endif | 84 | #endif |
diff --git a/core/obex/obex.pro b/core/obex/obex.pro index a296b2c..51fa300 100644 --- a/core/obex/obex.pro +++ b/core/obex/obex.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= obex.h obexhandler.h obexsend.h receiver.h | 3 | HEADERS= obex.h obexhandler.h obexsend.h receiver.h obeximpl.h |
4 | SOURCES= obex.cc obexsend.cpp obexhandler.cpp receiver.cpp | 4 | SOURCES= obex.cc obexsend.cpp obexhandler.cpp receiver.cpp obeximpl.cpp |
5 | TARGET = opieobex | 5 | TARGET = opieobex |
6 | DESTDIR = $(OPIEDIR)/plugins/obex | 6 | DESTDIR = $(OPIEDIR)/plugins/obex |
7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher | 7 | INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe -lopiecore2 | 9 | LIBS += -lqpe -lopiecore2 |
10 | VERSION = 0.0.2 | 10 | VERSION = 0.0.2 |
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
13 | target.path = $$prefix/plugins/applets | 13 | target.path = $$prefix/plugins/applets |
diff --git a/core/obex/obeximpl.cpp b/core/obex/obeximpl.cpp index 5b53644..ca6ce7b 100644 --- a/core/obex/obeximpl.cpp +++ b/core/obex/obeximpl.cpp | |||
@@ -1,32 +1,34 @@ | |||
1 | #include "obexhandler.h" | 1 | #include "obexhandler.h" |
2 | #include "obeximpl.h" | 2 | #include "obeximpl.h" |
3 | 3 | ||
4 | |||
5 | |||
4 | using namespace OpieObex; | 6 | using namespace OpieObex; |
5 | 7 | ||
6 | /* TRANSLATOR OpieObex::ObexImpl */ | 8 | /* TRANSLATOR OpieObex::ObexImpl */ |
7 | 9 | ||
8 | ObexImpl::ObexImpl() { | 10 | ObexImpl::ObexImpl() { |
9 | m_handler = new ObexHandler; | 11 | m_handler = new ObexHandler; |
10 | } | 12 | } |
11 | ObexImpl::~ObexImpl() { | 13 | ObexImpl::~ObexImpl() { |
12 | delete m_handler; | 14 | delete m_handler; |
13 | } | 15 | } |
14 | QRESULT ObexImpl::queryInterface( const QUuid& uuid, QUnknownInterface **iface ) { | 16 | QRESULT ObexImpl::queryInterface( const QUuid& uuid, QUnknownInterface **iface ) { |
15 | *iface = 0; | 17 | *iface = 0; |
16 | if ( uuid == IID_QUnknown ) { | 18 | if ( uuid == IID_QUnknown ) { |
17 | *iface = this; | 19 | *iface = this; |
18 | }else if ( uuid == IID_ObexInterface ) | 20 | }else if ( uuid == IID_ObexInterface ) |
19 | *iface = this; | 21 | *iface = this; |
20 | else | 22 | else |
21 | return QS_FALSE; | 23 | return QS_FALSE; |
22 | 24 | ||
23 | if (*iface) | 25 | if (*iface) |
24 | (*iface)->addRef(); | 26 | (*iface)->addRef(); |
25 | 27 | ||
26 | return QS_OK; | 28 | return QS_OK; |
27 | } | 29 | } |
28 | 30 | ||
29 | 31 | ||
30 | Q_EXPORT_INTERFACE() { | 32 | Q_EXPORT_INTERFACE() { |
31 | Q_CREATE_INSTANCE( ObexImpl ) | 33 | Q_CREATE_INSTANCE( ObexImpl ) |
32 | } | 34 | } |