summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -198,27 +198,37 @@ VMemo::VMemo( QWidget *parent, const char *_name )
: QWidget( parent, _name )
{
- setFixedHeight( 18 );
- setFixedWidth( 14 );
+ setFixedHeight( 18 );
+ setFixedWidth( 14 );
- recording = FALSE;
+ 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)
- systemZaurus=TRUE;
- else {
- 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
- QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
- e << 4096;
- e << QString("QPE/VMemo");
- e << QString("toggleRecord()");
- }
- }
+ struct utsname name; /* check for embedix kernel running on the zaurus*/
+ if (uname(&name) != -1) {
+ QString release=name.release;
+ Config vmCfg("VMemo");
+ vmCfg.setGroup("Defaults");
+
+ if(release.find("embedix",0,TRUE) !=-1) {
+ int toggleKey = vmCfg.readNumEntry("toggleKey", -1);
+ systemZaurus=TRUE;
+ } 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&)) );
+
+ if( toggleKey != -1 ) {
+ QCopEnvelope e("QPE/Desktop", "keyRegister(int key, QString channel, QString message)");
+// e << 4096; // Key_Escape
+// e << Key_F5; //4148
+ e << toggleKey;
+ e << QString("QPE/VMemo");
+ e << QString("toggleRecord()");
+ }
+ }
}
@@ -229,11 +239,14 @@ 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);
- }
+ QDataStream stream( data, IO_ReadOnly );
+ if (msg == "toggleRecord()") {
+ if (recording) {
+ fromToggle = TRUE;
+ stopRecording();
+ } else {
+ fromToggle = TRUE;
+ startRecording();
+ }
+ }
}
@@ -244,21 +257,18 @@ void VMemo::paintEvent( QPaintEvent* )
}
-void VMemo::mousePressEvent( QMouseEvent *me )
+void VMemo::mousePressEvent( QMouseEvent * )
{
- // just to be safe
- if (recording) {
- recording = FALSE;
- return;
- }
+ startRecording();
+}
+
+void VMemo::mouseReleaseEvent( QMouseEvent * )
+{
+ stopRecording();
+}
+
+bool VMemo::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
-
+ if ( recording)
+ return FALSE;;
Config config( "Sound" );
config.setGroup( "System" );
@@ -277,5 +287,5 @@ void VMemo::mousePressEvent( QMouseEvent *me )
QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
recording = FALSE;
- return;
+ return FALSE;
}
@@ -286,6 +296,6 @@ void VMemo::mousePressEvent( QMouseEvent *me )
QString fName;
- Config cfg( "Sound" );
- cfg.setGroup( "System" );
+ Config cfg( "Sound" );
+ cfg.setGroup( "System" );
fName = QPEApplication::documentDir() ;
fileName = cfg.readEntry("RecLocation", fName);
@@ -298,10 +308,4 @@ void VMemo::mousePressEvent( QMouseEvent *me )
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";
@@ -319,5 +323,5 @@ void VMemo::mousePressEvent( QMouseEvent *me )
QMessageBox::critical(0, "VMemo", err, "Abort");
close(dsp);
- return;
+ return FALSE;
}
@@ -335,8 +339,8 @@ void VMemo::mousePressEvent( QMouseEvent *me )
record();
+ return TRUE;
}
-void VMemo::mouseReleaseEvent( QMouseEvent * )
-{
+void VMemo::stopRecording() {
recording = FALSE;
}
@@ -480,5 +484,5 @@ void VMemo::record(void)
}
- } else {
+ } else { // this is specific for ipaqs that do not have 8 bit capabilities
signed short sound[512], monoBuffer[512];
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
@@ -38,5 +38,6 @@ public slots:
void mouseReleaseEvent( QMouseEvent * );
void receive( const QCString &msg, const QByteArray &data );
-
+ bool startRecording();
+ void stopRecording();
private:
bool useAlerts;
@@ -45,5 +46,5 @@ private:
int openDSP();
int openWAV(const char *filename);
-
+ bool fromToggle;
QPixmap vmemoPixmap;
QCopChannel *myChannel;