summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vmemo/vmemo.cpp40
-rw-r--r--core/applets/vmemo/vmemo.h2
2 files changed, 25 insertions, 17 deletions
diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp
index cb3e45e..2c3edf1 100644
--- a/core/applets/vmemo/vmemo.cpp
+++ b/core/applets/vmemo/vmemo.cpp
@@ -225,25 +225,28 @@ VMemo::VMemo( QWidget *parent, const char *_name )
connect( myChannel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT(receive(const QCString&, const QByteArray&)) );
if( toggleKey != -1 ) {
// QPEApplication::grabKeyboard();
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()");
}
-
+ 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");
@@ -258,30 +261,34 @@ void VMemo::receive( const QCString &msg, const QByteArray &data )
}
}
}
void VMemo::paintEvent( QPaintEvent* )
{
QPainter p(this);
p.drawPixmap( 0, 1,( const char** ) vmemo_xpm );
}
void VMemo::mousePressEvent( QMouseEvent * )
{
+ if(!recording)
startRecording();
+ else
+ stopRecording();
}
void VMemo::mouseReleaseEvent( QMouseEvent * )
{
- stopRecording();
+// if(usingIcon && !recording)
+// stopRecording();
}
bool VMemo::startRecording() {
if ( recording)
return FALSE;
Config config( "Vmemo" );
config.setGroup( "System" );
useAlerts = config.readBoolEntry("Alert",1);
if(useAlerts) {
@@ -351,36 +358,38 @@ bool VMemo::startRecording() {
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();
- // delete msgLabel;
+
return TRUE;
}
void VMemo::stopRecording() {
show();
qDebug("Stopped recording");
recording = FALSE;
- if(useAlerts)
- if( msgLabel) delete msgLabel;
+ if(useAlerts) {
+ msgLabel->close();
+ msgLabel=0;
+ delete msgLabel;
+ }
t_timer->stop();
Config cfg("Vmemo");
cfg.setGroup("Defaults");
if( cfg.readNumEntry("hideIcon",0) == 1 )
hide();
}
int VMemo::openDSP()
{
Config cfg("Vmemo");
cfg.setGroup("Record");
@@ -471,59 +480,58 @@ void VMemo::record(void)
msg.sprintf("Recording format %d", format);
qDebug(msg);
Config config("Vmemo");
config.setGroup("Record");
int sRate=config.readNumEntry("SizeLimit", 30);
t_timer->start( sRate * 1000+1000, TRUE);
if(systemZaurus) {
msg.sprintf("Recording format zaurus");
qDebug(msg);
- signed short sound[512], monoBuffer[512];
+ signed short sound[1024], monoBuffer[1024];
if(format==AFMT_S16_LE) {
while(recording) {
- result = read(dsp, sound, 512); // 8192
+ result = read(dsp, sound, 1024); // 8192
// int j=0;
for (int i = 0; i < result; i++) { //since Z is mono do normally
monoBuffer[i] = sound[i];
}
length+=write(wav, monoBuffer, result);
if(length<0)
recording=false;
-
// for (int i = 0; i < result; i+=2) {
// monoBuffer[j] = sound[i];
// // monoBuffer[j] = (sound[i]+sound[i+1])/2;
// j++;
// }
qApp->processEvents();
// printf("%d\r",length);
// fflush(stdout);
}
} else { //AFMT_U8
// 8bit unsigned
- unsigned short sound[512], monoBuffer[512];
+ unsigned short sound[1024], monoBuffer[1024];
while(recording) {
- result = read(dsp, sound, 512); // 8192
+ result = read(dsp, sound, 1024); // 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);
// for (int i = 0; i < result; i+=2) {
// monoBuffer[j] = (sound[i]+sound[i+1])/2;
@@ -535,32 +543,33 @@ void VMemo::record(void)
// fflush(stdout);
}
qApp->processEvents();
}
} else { // 16 bit only capabilities
msg.sprintf("Recording format other");
qDebug(msg);
- signed short sound[512];//, monoBuffer[512];
+ signed short sound[1024];//, monoBuffer[512];
while(recording) {
- result = read(dsp, sound, 512); // 8192
+ result = read(dsp, sound, 1024); // 8192
write(wav, sound, result);
length += result;
+
if(length<0) {
recording=false;
perror("dev/dsp's is a lookin' messy");
QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
}
// printf("%d\r",length);
// fflush(stdout);
qApp->processEvents();
}
// qDebug("file has length of %d lasting %d seconds",
// length, (( length / speed) / channels) / 2 );
@@ -580,25 +589,25 @@ void VMemo::record(void)
track.close();
qDebug("Track closed");
if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1)
perror("ioctl(\"SNDCTL_DSP_RESET\")");
::close(dsp);
fileName = fileName.left(fileName.length()-4);
// if(useAlerts)
// QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName);
qDebug("done recording "+fileName);
- QSound::play(Resource::findSound("vmemoe"));
+// QSound::play(Resource::findSound("vmemoe"));
Config cfg("qpe");
cfg.setGroup("Volume");
QString foo = cfg.readEntry("Mute","TRUE");
if(foo.find("TRUE",0,TRUE) != -1)
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
}
int VMemo::setToggleButton(int tog) {
for( int i=0; i < 10;i++) {
@@ -628,16 +637,15 @@ int VMemo::setToggleButton(int tog) {
return Key_F11;
break;
case 8:
return Key_F13;
break;
};
}
return -1;
}
void VMemo::timerBreak() {
//stop
- recording=false;
-
+ stopRecording();
QMessageBox::message("Vmemo","Vmemo recording has \ntimed out");
}
diff --git a/core/applets/vmemo/vmemo.h b/core/applets/vmemo/vmemo.h
index 51ace35..823c7b8 100644
--- a/core/applets/vmemo/vmemo.h
+++ b/core/applets/vmemo/vmemo.h
@@ -27,25 +27,25 @@
#include <qtimer.h>
class VMemo : public QWidget
{
Q_OBJECT
public:
VMemo( QWidget *parent, const char *name = NULL);
~VMemo();
QFile track;
QString fileName, errorMsg;
QLabel* msgLabel;
QTimer *t_timer;
-
+bool usingIcon;
public slots:
void record();
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void receive( const QCString &msg, const QByteArray &data );
bool startRecording();
void stopRecording();
void timerBreak();
private:
bool useAlerts;
void paintEvent( QPaintEvent* );
int setToggleButton(int);