summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp116
-rw-r--r--core/applets/vmemo/vmemo.h5
2 files changed, 63 insertions, 58 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index e14d532..7e91ef0 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -197,29 +197,39 @@ static char * vmemo_xpm[] = {
197VMemo::VMemo( QWidget *parent, const char *_name ) 197VMemo::VMemo( QWidget *parent, const char *_name )
198 : QWidget( parent, _name ) 198 : QWidget( parent, _name )
199{ 199{
200 setFixedHeight( 18 ); 200 setFixedHeight( 18 );
201 setFixedWidth( 14 ); 201 setFixedWidth( 14 );
202 202
203 recording = FALSE; 203 recording = FALSE;
204 204
205 struct utsname name; /* check for embedix kernel running on the zaurus*/ 205 struct utsname name; /* check for embedix kernel running on the zaurus*/
206 if (uname(&name) != -1) { 206 if (uname(&name) != -1) {
207 QString release=name.release; 207 QString release=name.release;
208 if(release.find("embedix",0,TRUE) !=-1) 208 Config vmCfg("VMemo");
209 systemZaurus=TRUE; 209 vmCfg.setGroup("Defaults");
210 else { 210
211 systemZaurus=FALSE; 211 if(release.find("embedix",0,TRUE) !=-1) {
212 myChannel = new QCopChannel( "QPE/VMemo", this ); 212 int toggleKey = vmCfg.readNumEntry("toggleKey", -1);
213 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), 213 systemZaurus=TRUE;
214 this, SLOT(receive(const QCString&, const QByteArray&)) ); 214 } else {
215 215 int toggleKey = vmCfg.readNumEntry("toggleKey", 4096);
216// // Register the REC key press, for ipaq only 216//default key for ipaq record button is Key_Escape = 4096
217 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); 217 systemZaurus=FALSE;
218 e << 4096; 218 }
219 e << QString("QPE/VMemo"); 219
220 e << QString("toggleRecord()"); 220 myChannel = new QCopChannel( "QPE/VMemo", this );
221 } 221 connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
222 } 222 this, SLOT(receive(const QCString&, const QByteArray&)) );
223
224 if( toggleKey != -1 ) {
225 QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
226// e << 4096; // Key_Escape
227// e << Key_F5; //4148
228 e << toggleKey;
229 e << QString("QPE/VMemo");
230 e << QString("toggleRecord()");
231 }
232 }
223} 233}
224 234
225VMemo::~VMemo() 235VMemo::~VMemo()
@@ -228,13 +238,16 @@ VMemo::~VMemo()
228 238
229void VMemo::receive( const QCString &msg, const QByteArray &data ) 239void VMemo::receive( const QCString &msg, const QByteArray &data )
230{ 240{
231 QDataStream stream( data, IO_ReadOnly ); 241 QDataStream stream( data, IO_ReadOnly );
232 if (msg == "toggleRecord()") { 242 if (msg == "toggleRecord()") {
233 if (recording) 243 if (recording) {
234 mouseReleaseEvent(NULL); 244 fromToggle = TRUE;
235 else 245 stopRecording();
236 mousePressEvent(NULL); 246 } else {
237 } 247 fromToggle = TRUE;
248 startRecording();
249 }
250 }
238} 251}
239 252
240void VMemo::paintEvent( QPaintEvent* ) 253void VMemo::paintEvent( QPaintEvent* )
@@ -243,23 +256,20 @@ void VMemo::paintEvent( QPaintEvent* )
243 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); 256 p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
244} 257}
245 258
246void VMemo::mousePressEvent( QMouseEvent *me ) 259void VMemo::mousePressEvent( QMouseEvent * )
247{ 260{
248 // just to be safe 261 startRecording();
249 if (recording) { 262}
250 recording = FALSE; 263
251 return; 264void VMemo::mouseReleaseEvent( QMouseEvent * )
252 } 265{
266 stopRecording();
267}
268
269bool VMemo::startRecording() {
253 270
254 /* 271 if ( recording)
255 No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions 272 return FALSE;;
256 mousePressEvent and mouseReleaseEvent with a NULL parameter.
257 */
258// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
259// if (!systemZaurus )
260// return;
261// #endif
262
263 Config config( "Sound" ); 273 Config config( "Sound" );
264 config.setGroup( "System" ); 274 config.setGroup( "System" );
265 useAlerts = config.readBoolEntry("Alert"); 275 useAlerts = config.readBoolEntry("Alert");
@@ -276,7 +286,7 @@ void VMemo::mousePressEvent( QMouseEvent *me )
276 if (openDSP() == -1) { 286 if (openDSP() == -1) {
277 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); 287 QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
278 recording = FALSE; 288 recording = FALSE;
279 return; 289 return FALSE;
280 } 290 }
281 291
282 Config vmCfg("VMemo"); 292 Config vmCfg("VMemo");
@@ -285,8 +295,8 @@ void VMemo::mousePressEvent( QMouseEvent *me )
285 QDateTime dt = QDateTime::currentDateTime(); 295 QDateTime dt = QDateTime::currentDateTime();
286 296
287 QString fName; 297 QString fName;
288 Config cfg( "Sound" ); 298 Config cfg( "Sound" );
289 cfg.setGroup( "System" ); 299 cfg.setGroup( "System" );
290 fName = QPEApplication::documentDir() ; 300 fName = QPEApplication::documentDir() ;
291 fileName = cfg.readEntry("RecLocation", fName); 301 fileName = cfg.readEntry("RecLocation", fName);
292 302
@@ -297,12 +307,6 @@ void VMemo::mousePressEvent( QMouseEvent *me )
297 qDebug("filename will be "+fileName); 307 qDebug("filename will be "+fileName);
298 if( fileName.right(1).find('/') == -1) 308 if( fileName.right(1).find('/') == -1)
299 fileName+="/"; 309 fileName+="/";
300
301// if(systemZaurus)
302// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs
303// else
304// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/");
305
306 fName = "vm_"+ dt.toString()+ ".wav"; 310 fName = "vm_"+ dt.toString()+ ".wav";
307 311
308 fileName+=fName; 312 fileName+=fName;
@@ -318,7 +322,7 @@ void VMemo::mousePressEvent( QMouseEvent *me )
318 err += fileName; 322 err += fileName;
319 QMessageBox::critical(0, "VMemo", err, "Abort"); 323 QMessageBox::critical(0, "VMemo", err, "Abort");
320 close(dsp); 324 close(dsp);
321 return; 325 return FALSE;
322 } 326 }
323 327
324 QArray<int> cats(1); 328 QArray<int> cats(1);
@@ -334,10 +338,10 @@ void VMemo::mousePressEvent( QMouseEvent *me )
334 l.writeLink(); 338 l.writeLink();
335 339
336 record(); 340 record();
341 return TRUE;
337} 342}
338 343
339void VMemo::mouseReleaseEvent( QMouseEvent * ) 344void VMemo::stopRecording() {
340{
341 recording = FALSE; 345 recording = FALSE;
342} 346}
343 347
@@ -479,7 +483,7 @@ void VMemo::record(void)
479 qApp->processEvents(); 483 qApp->processEvents();
480 } 484 }
481 485
482 } else { 486 } else { // this is specific for ipaqs that do not have 8 bit capabilities
483 487
484 signed short sound[512], monoBuffer[512]; 488 signed short sound[512], monoBuffer[512];
485 489
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 3972877..701663f 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -37,14 +37,15 @@ public slots:
37 void mousePressEvent( QMouseEvent * ); 37 void mousePressEvent( QMouseEvent * );
38 void mouseReleaseEvent( QMouseEvent * ); 38 void mouseReleaseEvent( QMouseEvent * );
39 void receive( const QCString &msg, const QByteArray &data ); 39 void receive( const QCString &msg, const QByteArray &data );
40 40 bool startRecording();
41 void stopRecording();
41private: 42private:
42 bool useAlerts; 43 bool useAlerts;
43 void paintEvent( QPaintEvent* ); 44 void paintEvent( QPaintEvent* );
44 45
45 int openDSP(); 46 int openDSP();
46 int openWAV(const char *filename); 47 int openWAV(const char *filename);
47 48 bool fromToggle;
48 QPixmap vmemoPixmap; 49 QPixmap vmemoPixmap;
49 QCopChannel *myChannel; 50 QCopChannel *myChannel;
50 bool systemZaurus; 51 bool systemZaurus;