summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-05-26 23:41:26 (UTC)
committer llornkcor <llornkcor>2002-05-26 23:41:26 (UTC)
commitff4ab0f08fe935fd781be4caa245cb953e9f68ce (patch) (side-by-side diff)
tree3a20249c724552e4437677dea4e407397afc1610 /core
parentf0d0d53759436686f7f15fcd55a6706b1ecaa1cc (diff)
downloadopie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.zip
opie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.tar.gz
opie-ff4ab0f08fe935fd781be4caa245cb953e9f68ce.tar.bz2
changed visual alert to QLabel in the corner while recording, instead of nag screen when stopping recording. made pick-a-key record work
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp72
-rw-r--r--core/applets/vmemo/vmemo.h6
2 files changed, 69 insertions, 9 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index f5d2b20..e327098 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -205,9 +205,11 @@ VMemo::VMemo( QWidget *parent, const char *_name )
struct utsname name; /* check for embedix kernel running on the zaurus*/
if (uname(&name) != -1) {
QString release=name.release;
- Config vmCfg("VMemo");
+ Config vmCfg("Vmemo");
vmCfg.setGroup("Defaults");
- int toggleKey = vmCfg.readNumEntry("toggleKey", -1);
+ int toggleKey = setToggleButton(vmCfg.readNumEntry("toggleKey", -1));
+
+ qDebug("toggleKey %d", toggleKey);
if(release.find("embedix",0,TRUE) !=-1)
systemZaurus=TRUE;
@@ -269,9 +271,17 @@ bool VMemo::startRecording() {
if ( recording)
return FALSE;;
+
Config config( "Vmemo" );
config.setGroup( "System" );
+
useAlerts = config.readBoolEntry("Alert");
+ if(useAlerts) {
+
+ msgLabel = new QLabel( 0, "alertLabel" );
+ msgLabel->setText("<B><P><font size=+2>VMemo-Recording</font></B>");
+ msgLabel->show();
+ }
// if(useAlerts)
// QMessageBox::message("VMemo","Really Record?");//) ==1)
@@ -283,7 +293,7 @@ bool VMemo::startRecording() {
qDebug("Start recording");
recording = TRUE;
if (openDSP() == -1) {
- QMessageBox::critical(0, "VMemo", "Could not open dsp device.\n"+errorMsg, "Abort");
+ QMessageBox::critical(0, "vmemo", "Could not open dsp device.\n"+errorMsg, "Abort");
recording = FALSE;
return FALSE;
}
@@ -319,7 +329,7 @@ bool VMemo::startRecording() {
if(openWAV(fileName.latin1()) == -1) {
QString err("Could not open the output file\n");
err += fileName;
- QMessageBox::critical(0, "VMemo", err, "Abort");
+ QMessageBox::critical(0, "vmemo", err, "Abort");
close(dsp);
return FALSE;
}
@@ -336,12 +346,15 @@ bool VMemo::startRecording() {
l.setCategories(cats);
l.writeLink();
+
record();
return TRUE;
}
void VMemo::stopRecording() {
recording = FALSE;
+ if(useAlerts)
+ if( msgLabel) delete msgLabel;
}
int VMemo::openDSP()
@@ -429,26 +442,36 @@ int VMemo::openWAV(const char *filename)
void VMemo::record(void)
{
int length=0, result, value;
- qDebug("Recording");
+ QString msg;
+ msg.sprintf("Recording format %d", format);
+ qDebug(msg);
if(systemZaurus) {
signed short sound[512], monoBuffer[512];
if(format==AFMT_S16_LE) {
+
while(recording) {
+
result = read(dsp, sound, 512); // 8192
int j=0;
+
if(systemZaurus) {
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
+
length+=write(wav, monoBuffer, result);
+
} else { //ipaq /stereo inputs
+
for (int i = 0; i < result; i+=2) {
monoBuffer[j] = (sound[i]+sound[i+1])/2;
j++;
}
+
length+=write(wav, monoBuffer, result/2);
}
+ qApp->processEvents();
// printf("%d\r",length);
// fflush(stdout);
}
@@ -507,8 +530,43 @@ void VMemo::record(void)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
::close(dsp);
fileName = fileName.left(fileName.length()-4);
- if(useAlerts)
- QMessageBox::message("Vmemo"," Done recording\n"+ fileName);
+// if(useAlerts)
+// QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
qDebug("done recording "+fileName);
QSound::play(Resource::findSound("vmemoe"));
}
+
+int VMemo::setToggleButton(int tog) {
+
+ for( int i=0; i < 10;i++) {
+ switch (tog) {
+ case 0:
+ return -1;
+ break;
+ case 1:
+ return 0;
+ break;
+ case 2:
+ return Key_Escape;
+ break;
+ case 3:
+ return Key_Space;
+ 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;
+ };
+ }
+}
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 701663f..b33ab55 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -17,11 +17,13 @@
#ifndef __VMEMO_H__
#define __VMEMO_H__
+
#include <qwidget.h>
#include <qpixmap.h>
#include <qpe/applnk.h>
#include <qfile.h>
#include <qpe/qcopenvelope_qws.h>
+#include <qlabel.h>
class VMemo : public QWidget
{
@@ -31,7 +33,7 @@ public:
~VMemo();
QFile track;
QString fileName, errorMsg;
-
+ QLabel* msgLabel;
public slots:
void record();
void mousePressEvent( QMouseEvent * );
@@ -42,7 +44,7 @@ public slots:
private:
bool useAlerts;
void paintEvent( QPaintEvent* );
-
+ int setToggleButton(int);
int openDSP();
int openWAV(const char *filename);
bool fromToggle;