summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp46
1 files changed, 36 insertions, 10 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index 2c3edf1..b77e3b8 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -233,65 +233,79 @@ VMemo::VMemo( QWidget *parent, const char *_name )
e << toggleKey;
e << QString("QPE/VMemo");
e << QString("toggleRecord()");
}
if(toggleKey == 1)
usingIcon=TRUE;
else
usingIcon=FALSE;
if( vmCfg.readNumEntry("hideIcon",0) == 1)
hide();
}
}
VMemo::~VMemo()
{
}
void VMemo::receive( const QCString &msg, const QByteArray &data )
{
qDebug("receive");
QDataStream stream( data, IO_ReadOnly );
if (msg == "toggleRecord()") {
if (recording) {
fromToggle = TRUE;
- stopRecording();
+ mouseReleaseEvent(NULL);
+// stopRecording();
} else {
fromToggle = TRUE;
+ // mousePressEvent(NULL);
startRecording();
}
}
}
void VMemo::paintEvent( QPaintEvent* )
{
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
-void VMemo::mousePressEvent( QMouseEvent * )
+void VMemo::mousePressEvent( QMouseEvent * me)
{
- if(!recording)
+ // just to be safe
+ if (recording) {
+ recording = FALSE;
+ return;
+ }
+ /* No mousePress/mouseRelease recording on the iPAQ. The REC button on the iPAQ calls these functions
+ mousePressEvent and mouseReleaseEvent with a NULL parameter. */
+ if ( me->button() != LeftButton)
+
+ // if (!systemZaurus && me != NULL)
+ return;
+
+ if(!recording)
startRecording();
else
stopRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * )
{
// if(usingIcon && !recording)
// stopRecording();
}
bool VMemo::startRecording() {
if ( recording)
return FALSE;
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert",1);
if(useAlerts) {
msgLabel = new QLabel( 0, "alertLabel" );
msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
@@ -326,56 +340,68 @@ bool VMemo::startRecording() {
config.setGroup( "System" );
fName = QPEApplication::documentDir() ;
fileName = config.readEntry("RecLocation", fName);
int s;
s=fileName.find(':');
if(s)
fileName=fileName.right(fileName.length()-s-2);
qDebug("pathname will be "+fileName);
if( fileName.left(1).find('/') == -1)
fileName="/"+fileName;
if( fileName.right(1).find('/') == -1)
fileName+="/";
fName = "vm_"+ dt.toString()+ ".wav";
fileName+=fName;
qDebug("filename is "+fileName);
// No spaces in the filename
fileName.replace(QRegExp("'"),"");
fileName.replace(QRegExp(" "),"_");
fileName.replace(QRegExp(":"),".");
fileName.replace(QRegExp(","),"");
- if(openWAV(fileName.latin1()) == -1) {
- // QString err("Could not open the output file\n");
- // err += fileName;
- // QMessageBox::critical(0, "vmemo", err, "Abort");
- close(dsp);
+// open tmp file here
+ char *pointer;
+ pointer=tmpnam(NULL);
+ qDebug("Opening tmp file %s",pointer);
+
+ if(openWAV(pointer ) == -1) {
+
+// if(openWAV(fileName.latin1()) == -1) {
+ QString err("Could not open the temp file\n");
+ err += fileName;
+ QMessageBox::critical(0, "vmemo", err, "Abort");
+ ::close(dsp);
return FALSE;
}
-
+ QString cmd;
+ cmd.sprintf("mv %s "+fileName,pointer);
+
+// move tmp file to regular file here
+ system(cmd.latin1());
+
QArray<int> cats(1);
cats[0] = config.readNumEntry("Category", 0);
QString dlName("vm_");
dlName += dt.toString();
DocLnk l;
l.setFile(fileName);
l.setName(dlName);
l.setType("audio/x-wav");
l.setCategories(cats);
l.writeLink();
record();
return TRUE;
}
void VMemo::stopRecording() {
show();
qDebug("Stopped recording");
recording = FALSE;
if(useAlerts) {
msgLabel->close();
msgLabel=0;
@@ -626,26 +652,26 @@ int VMemo::setToggleButton(int tog) {
break;
case 4:
return Key_F12;
break;
case 5:
return Key_F9;
break;
case 6:
return Key_F10;
break;
case 7:
return Key_F11;
break;
case 8:
return Key_F13;
break;
};
}
return -1;
}
void VMemo::timerBreak() {
//stop
stopRecording();
- QMessageBox::message("Vmemo","Vmemo recording has \ntimed out");
+ QMessageBox::message("Vmemo","Vmemo recording has ended");
}