author | llornkcor <llornkcor> | 2002-05-19 17:00:41 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-19 17:00:41 (UTC) |
commit | 61a917bec9006516115d94be8c49acadf4eba222 (patch) (side-by-side diff) | |
tree | 5cf91393455b95749978f28ab3f2a251c4c08b07 /core/applets | |
parent | 602ff2a6f588584bf47afa6faae08ce60b49047f (diff) | |
download | opie-61a917bec9006516115d94be8c49acadf4eba222.zip opie-61a917bec9006516115d94be8c49acadf4eba222.tar.gz opie-61a917bec9006516115d94be8c49acadf4eba222.tar.bz2 |
changed keypress stuff, and added a secret key/button for zaurus, available from config [Defaults] toggleKey = 4148 (or the int for the wanted keypress), ipaqs is 4096=KeyEscape -record button
-rw-r--r-- | core/applets/vmemo/vmemo.cpp | 68 | ||||
-rw-r--r-- | core/applets/vmemo/vmemo.h | 5 |
2 files changed, 39 insertions, 34 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 @@ -202,23 +202,33 @@ VMemo::VMemo( QWidget *parent, const char *_name ) recording = FALSE; struct utsname name; /* check for embedix kernel running on the zaurus*/ if (uname(&name) != -1) { QString release=name.release; - if(release.find("embedix",0,TRUE) !=-1) + Config vmCfg("VMemo"); + vmCfg.setGroup("Defaults"); + + if(release.find("embedix",0,TRUE) !=-1) { + int toggleKey = vmCfg.readNumEntry("toggleKey", -1); systemZaurus=TRUE; - else { + } else { + int toggleKey = vmCfg.readNumEntry("toggleKey", 4096); +//default key for ipaq record button is Key_Escape = 4096 systemZaurus=FALSE; + } + myChannel = new QCopChannel( "QPE/VMemo", this ); connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); -// // Register the REC key press, for ipaq only + if( toggleKey != -1 ) { QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)"); - e << 4096; +// e << 4096; // Key_Escape +// e << Key_F5; //4148 + e << toggleKey; e << QString("QPE/VMemo"); e << QString("toggleRecord()"); } } } @@ -227,42 +237,42 @@ VMemo::~VMemo() } void VMemo::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if (msg == "toggleRecord()") { - if (recording) - mouseReleaseEvent(NULL); - else - mousePressEvent(NULL); + if (recording) { + fromToggle = TRUE; + stopRecording(); + } else { + fromToggle = TRUE; + startRecording(); + } } } void VMemo::paintEvent( QPaintEvent* ) { QPainter p(this); p.drawPixmap( 0, 1,( const char** ) vmemo_xpm ); } -void VMemo::mousePressEvent( QMouseEvent *me ) +void VMemo::mousePressEvent( QMouseEvent * ) { - // just to be safe - if (recording) { - recording = FALSE; - return; + startRecording(); } - /* - No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions - mousePressEvent and mouseReleaseEvent with a NULL parameter. - */ -// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) -// if (!systemZaurus ) -// return; -// #endif +void VMemo::mouseReleaseEvent( QMouseEvent * ) +{ + stopRecording(); +} + +bool VMemo::startRecording() { + if ( recording) + return FALSE;; Config config( "Sound" ); config.setGroup( "System" ); useAlerts = config.readBoolEntry("Alert"); // if(useAlerts) // QMessageBox::message("VMemo","Really Record?");//) ==1) @@ -273,13 +283,13 @@ void VMemo::mousePressEvent( QMouseEvent *me ) // } qDebug("Start recording"); recording = TRUE; if (openDSP() == -1) { QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort"); recording = FALSE; - return; + return FALSE; } Config vmCfg("VMemo"); vmCfg.setGroup("Defaults"); QDateTime dt = QDateTime::currentDateTime(); @@ -294,18 +304,12 @@ void VMemo::mousePressEvent( QMouseEvent *me ) s=fileName.find(':'); if(s) fileName=fileName.right(fileName.length()-s-2); qDebug("filename will be "+fileName); if( fileName.right(1).find('/') == -1) fileName+="/"; - -// if(systemZaurus) -// fileName=vmCfg.readEntry("Dir", "/mnt/cf/"); // zaurus does not have /mnt/ramfs -// else -// fileName=vmCfg.readEntry("Dir", "/mnt/ramfs/"); - fName = "vm_"+ dt.toString()+ ".wav"; fileName+=fName; qDebug("filename is "+fileName); // No spaces in the filename fileName.replace(QRegExp("'"),""); @@ -315,13 +319,13 @@ void VMemo::mousePressEvent( QMouseEvent *me ) if(openWAV(fileName.latin1()) == -1) { QString err("Could not open the output file\n"); err += fileName; QMessageBox::critical(0, "VMemo", err, "Abort"); close(dsp); - return; + return FALSE; } QArray<int> cats(1); cats[0] = vmCfg.readNumEntry("Category", 0); QString dlName("vm_"); @@ -331,16 +335,16 @@ void VMemo::mousePressEvent( QMouseEvent *me ) l.setName(dlName); l.setType("audio/x-wav"); l.setCategories(cats); l.writeLink(); record(); + return TRUE; } -void VMemo::mouseReleaseEvent( QMouseEvent * ) -{ +void VMemo::stopRecording() { recording = FALSE; } int VMemo::openDSP() { Config cfg("Sound"); @@ -476,13 +480,13 @@ void VMemo::record(void) // fflush(stdout); } qApp->processEvents(); } - } else { + } else { // this is specific for ipaqs that do not have 8 bit capabilities signed short sound[512], monoBuffer[512]; while(recording) { result = read(dsp, sound, 512); // 8192 write(wav, sound, result); 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 @@ -34,20 +34,21 @@ public: public slots: void record(); void mousePressEvent( QMouseEvent * ); void mouseReleaseEvent( QMouseEvent * ); void receive( const QCString &msg, const QByteArray &data ); - + bool startRecording(); + void stopRecording(); private: bool useAlerts; void paintEvent( QPaintEvent* ); int openDSP(); int openWAV(const char *filename); - + bool fromToggle; QPixmap vmemoPixmap; QCopChannel *myChannel; bool systemZaurus; int dsp, wav, rate, speed, channels, format, resolution; bool recording; }; |