summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp5
-rw-r--r--kalarmd/alarmdialog.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index 53ff488..65073f6 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -92,96 +92,97 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) );
playSoundTimer->stop();
layout->addWidget ( mMissedAlarms );
mMissedAlarmsCombo = new QComboBox ( this );
layout->addWidget ( mMissedAlarmsCombo );
QLabel* labb = new QLabel("Suspend duration (minutes):",this);
labb->setAlignment(AlignCenter);
layout->addWidget ( labb );
fo = font();
int pointSize = 36;
if ( QApplication::desktop()->width() <= 320 )
pointSize = 18;
fo.setPointSize( pointSize );
mSuspendSpin = new QSpinBox(1,1440,1,this);
mSuspendSpin->setFont( fo );
mSuspendSpin->setValue(7); // default suspend duration
mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
#if QT_VERSION < 0x030000
mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize ));
mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize ));
#endif
mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 );
mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus );
QHBoxLayout* layoutSpin = new QHBoxLayout( layout );
layoutSpin->addStretch ();
layoutSpin->addWidget ( mSuspendSpin );
layoutSpin->addStretch ();
QVBox * bbox = new QVBox ( this );
layout->addWidget ( bbox );
bbox->layout()->setSpacing( 2 );
labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox);
labb->setAlignment(AlignCenter);
mSuspendButton = new QPushButton( "Suspend", bbox);
QPushButton* silen = new QPushButton( " Stop sound ", bbox);
QPushButton* okbut = new QPushButton( "Ok", bbox);
mSuspendButton->setFont( fo );
silen->setFont( fo );
okbut->setFont( fo );
okbut->setDefault( true );
connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) );
connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) );
connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) );
+ connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) );
#ifndef _WIN32_
if ( QFile::exists ( "/dev/sharp_led" ) )
fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
else
#endif
fd_led = 0;
statusLED.which = SHARP_LED_SALARM;
mSilent = false;
mSuspendCounter = 0;
setServerNotification( true );
}
void AlarmDialog::reject ()
{
QTimer::singleShot ( 3000, this, SLOT (suspend()) );
slotSuspend();
}
AlarmDialog::~AlarmDialog()
{
}
void AlarmDialog::silent ()
{
mSilent = true;
}
void AlarmDialog::accept()
{
slotOk();
}
void AlarmDialog::suspend()
{
#ifdef DESKTOP_VERSION
#else
Sound::soundAlarm ();
#endif
}
void AlarmDialog::slotOk()
{
mStopAlarm = true;
mMissedAlarms->setText("(No missed Alarms)");
mMessage->setText("");
mMissedAlarmsCombo->clear();
#ifndef _WIN32_
if ( fd_led > 0 ) {
statusLED.status = LED_SALARM_OFF ;
ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
}
#endif
@@ -217,96 +218,100 @@ int AlarmDialog::getSuspendTime( )
void AlarmDialog::setSuspendTime( int val )
{
mSuspendSpin->setValue( val );
}
bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes)
{
if ( mess.left( 9) != "Suspended" )
mSuspendCounter = suspendtimes;
mPauseCount = pause;
mFileName = fn;
mPlayWav = playwav;
if ( !QFile::exists( fn ) )
mFileName = "";
alarmCounter = 0 ;
maxAlarmReplay = replay ;
mStopAlarm = false;
mSilent = false;
if ( !mMessage->text().stripWhiteSpace().isEmpty() ) {
mMissedAlarmsCombo->show();
QString newItem = mMessage->text().stripWhiteSpace();
newItem.replace( QRegExp("\n"), QString(" ") );
mMissedAlarmsCombo->insertItem( newItem );
mMissedAlarms->setText( "Missed alarms:");
} else
mMissedAlarmsCombo->hide();
mMessage->setText(mess);
int w =sizeHint().width() ;
int h = sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
show();
raise();
//qApp->processEvents();
//repaint();
qApp->processEvents();
#ifndef _WIN32_
if ( fd_led > 0 ) {
statusLED.status = LED_SALARM_ON ;
ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED);
}
#endif
playSoundTimer->start( 1000, true );
return true;
}
+void AlarmDialog::spinBoxChanged( int )
+{
+ mSilent = true;
+}
void AlarmDialog::playSound ()
{
if (mStopAlarm )
return;
if ( mSilent )
return;
showNormal();
setActiveWindow();
raise();
mSuspendSpin->setFocus();
qApp->processEvents();
if ( alarmCounter < maxAlarmReplay && ! mSilent) {
++alarmCounter;
#ifdef DESKTOP_VERSION
mPlayWav = true;
#endif
if ( !mPlayWav || mFileName.length() < 2 ) {
#ifdef DESKTOP_VERSION
qDebug("Sound play not possible - file not found");
#else
Sound::soundAlarm ();
#endif
} else
{
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
QSound::play ( mFileName );
#else
QString command = "playwave -r 22050 " + mFileName;
qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() );
int ret = system ( command.latin1() );
if ( ret != 0 ) {
qDebug("Sound play command failed: %s ",command.latin1() );
}
#endif
#else
QSound::play ( mFileName );
#endif
qDebug("BEEP!");
diff --git a/kalarmd/alarmdialog.h b/kalarmd/alarmdialog.h
index 896cf60..1e4636c 100644
--- a/kalarmd/alarmdialog.h
+++ b/kalarmd/alarmdialog.h
@@ -5,80 +5,81 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef ALARMDIALOG_H
#define ALARMDIALOG_H
#include <qdialog.h>
#include <qdatetime.h>
#include <qstring.h>
#include <qcombobox.h>
#include <qpushbutton.h>
#include "sharp_char.h"
class QSpinBox;
class QLabel;
class QString;
class AlarmDialog : public QDialog {
Q_OBJECT
public:
AlarmDialog( QWidget *parent = 0, const char *name = 0 );
virtual ~AlarmDialog();
bool eventNotification(QString m, int replay , QString m2 , bool, int, int );
int getSuspendTime( );
void setSuspendTime( int );
void setServerNotification( bool b );
public slots:
+ void spinBoxChanged( int );
void slotOk();
void slotSuspend();
void reject () ;
void silent () ;
void accept();
void suspend();
void playSound ();
signals:
// void suspendSignal(int duration);
void addAlarm(const QDateTime &, const QString & );
private:
int alarmCounter;
int mPauseCount;
int mSuspendCounter;
int maxAlarmReplay;
QTimer* playSoundTimer;
bool mStopAlarm;
bool mSilent;
bool mPlayWav;
bool mServerNotification;
QLabel* mMessage;
QLabel* mMissedAlarms;
QSpinBox *mSuspendSpin;
QComboBox *mMissedAlarmsCombo;
QPushButton* mSuspendButton;
QString mFileName;
int fd_led;
sharp_led_status statusLED;
};
#endif