summaryrefslogtreecommitdiffabout
path: root/kalarmd/alarmdialog.cpp
Side-by-side diff
Diffstat (limited to 'kalarmd/alarmdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/alarmdialog.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp
index bdeee4a..53ff488 100644
--- a/kalarmd/alarmdialog.cpp
+++ b/kalarmd/alarmdialog.cpp
@@ -11,75 +11,76 @@
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.
*/
// $Id$
#include <qhbox.h>
#include <qvbox.h>
#include <qapp.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qfile.h>
#include <qtimer.h>
#include <qsound.h>
#include <qpushbutton.h>
+#include <qregexp.h>
#ifndef DESKTOP_VERSION
#define protected public
#include <qspinbox.h>
#undef protected
#else
#include <qspinbox.h>
#endif
#include <stdlib.h>
#ifndef _WIN32_
#include <unistd.h>
#include <sys/ioctl.h>
#endif
#include <stdio.h>
#include <fcntl.h>
#ifndef DESKTOP_VERSION
#include <qtopia/alarmserver.h>
#include <qpe/resource.h>
#include <qtopia/sound.h>
#endif
#include "alarmdialog.h"
AlarmDialog::AlarmDialog(QWidget *parent,const char *name)
- : QDialog (parent, name, true, Qt::WStyle_StaysOnTop )
+ : QDialog (parent, name, true, Qt::WStyle_Customize |Qt::WStyle_StaysOnTop | Qt::WStyle_DialogBorder)
{
setCaption( "KO/Pi Alarm!" );
QVBoxLayout* layout = new QVBoxLayout( this);
QLabel* l = new QLabel("The following event triggered alarm:",this);
layout->addWidget ( l );
l->setAlignment( AlignCenter);
mMessage = new QLabel ( " ", this );
int fs = 18;
int fs2 = 12;
int baseSize = 6;
if ( QApplication::desktop()->width() < 480 ) {
fs2 = 10;
fs = 12;
baseSize = 4;
}
layout->setSpacing( 3 );
layout->setMargin( 3 );
QFont fo = QApplication::font();
fo.setBold( true );
fo.setPointSize( fs2 );
l->setFont( fo );
fo.setPointSize( fs );
mMessage->setFont(fo );
mMessage->setAlignment( AlignCenter);
@@ -211,88 +212,90 @@ void AlarmDialog::setServerNotification( bool b )
int AlarmDialog::getSuspendTime( )
{
return mSuspendSpin->value();
}
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();
- mMissedAlarmsCombo->insertItem( mMessage->text().stripWhiteSpace() );
+ 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::playSound ()
{
if (mStopAlarm )
return;
- if (mSilent )
+ if ( mSilent )
return;
showNormal();
setActiveWindow();
+ raise();
mSuspendSpin->setFocus();
- raise();
- repaint();
+
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() );