kalarm

messagewin.h

Go to the documentation of this file.
00001 /*
00002  *  messagewin.h  -  displays an alarm message
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef MESSAGEWIN_H
00022 #define MESSAGEWIN_H
00023 
00026 #include "mainwindowbase.h"
00027 #include "alarmevent.h"
00028 
00029 class QPushButton;
00030 class KPushButton;
00031 class QLabel;
00032 class QTimer;
00033 class KWinModule;
00034 class AlarmTimeWidget;
00035 class DeferAlarmDlg;
00036 class KArtsDispatcher;
00037 namespace KDE { class PlayObject; }
00038 
00042 class MessageWin : public MainWindowBase
00043 {
00044         Q_OBJECT
00045     public:
00046         MessageWin();     // for session management restoration only
00047         MessageWin(const KAEvent&, const KAAlarm&, bool reschedule_event = true, bool allowDefer = true);
00048         MessageWin(const KAEvent&, const DateTime& alarmDateTime, const QStringList& errmsgs);
00049         ~MessageWin();
00050         void                repeat(const KAAlarm&);
00051         void                setRecreating()        { mRecreating = true; }
00052         const DateTime&     dateTime()             { return mDateTime; }
00053         KAAlarm::Type       alarmType() const      { return mAlarmType; }
00054         bool                hasDefer() const       { return !!mDeferButton; }
00055         bool                isValid() const        { return !mInvalid; }
00056         virtual void        show();
00057         virtual QSize       sizeHint() const;
00058         static int          instanceCount()        { return mWindowList.count(); }
00059         static MessageWin*  findEvent(const QString& eventID);
00060 
00061     protected:
00062         virtual void        showEvent(QShowEvent*);
00063         virtual void        moveEvent(QMoveEvent*);
00064         virtual void        resizeEvent(QResizeEvent*);
00065         virtual void        closeEvent(QCloseEvent*);
00066         virtual void        saveProperties(KConfig*);
00067         virtual void        readProperties(KConfig*);
00068 
00069     private slots:
00070         void                slotEdit();
00071         void                slotDefer();
00072         void                checkDeferralLimit();
00073         void                displayMainWindow();
00074         void                slotShowKMailMessage();
00075         void                slotSpeak();
00076         void                slotPlayAudio();
00077         void                checkAudioPlay();
00078         void                stopPlay();
00079         void                slotFade();
00080         void                enableButtons();
00081         void                setRemainingTextDay();
00082         void                setRemainingTextMinute();
00083         void                setMaxSize();
00084 
00085     private:
00086         void                initView();
00087 #ifndef WITHOUT_ARTS
00088         void                initAudio(bool firstTime);
00089         int                 getKMixVolume();
00090         void                setKMixVolume(int percent);
00091 #endif
00092         void                displayComplete();
00093         void                playAudio();
00094         void                setDeferralLimit(const KAEvent&);
00095 
00096         static QValueList<MessageWin*> mWindowList;  // list of existing message windows
00097         // Properties needed by readProperties()
00098         QString             mMessage;
00099         QFont               mFont;
00100         QColor              mBgColour, mFgColour;
00101         DateTime            mDateTime;        // date/time displayed in the message window
00102         QDateTime           mCloseTime;       // time at which window should be auto-closed
00103         QString             mEventID;
00104         QString             mAudioFile;
00105         float               mVolume;
00106         float               mFadeVolume;
00107         int                 mFadeSeconds;
00108         int                 mDefaultDeferMinutes;
00109         KAAlarm::Type       mAlarmType;
00110         KAEvent::Action     mAction;
00111         unsigned long       mKMailSerialNumber; // if email text, message's KMail serial number, else 0
00112         QStringList         mErrorMsgs;
00113         int                 mRestoreHeight;
00114         bool                mAudioRepeat;
00115         bool                mConfirmAck;
00116         bool                mShowEdit;        // display the Edit button
00117         bool                mNoDefer;         // don't display a Defer option
00118         bool                mInvalid;         // restored window is invalid
00119         // Sound file playing
00120         KArtsDispatcher*    mArtsDispatcher;
00121         KDE::PlayObject*    mPlayObject;
00122         QCString            mKMixName;        // DCOP name for KMix
00123         QString             mKMixError;       // error message starting KMix
00124         QTimer*             mPlayTimer;       // timer for repeating the sound file
00125         QTimer*             mFadeTimer;       // timer for fading the sound volume
00126         float               mOldVolume;       // volume before volume was set for sound file
00127         QString             mLocalAudioFile;  // local copy of audio file
00128         QTime               mAudioFileStart;  // time when audio file loading first started, or when play first started
00129         int                 mAudioFileLoadSecs;  // how many seconds it took to load audio file
00130         bool                mPlayedOnce;      // the sound file has started playing at least once
00131         bool                mPlayed;          // the PlayObject->play() has been called
00132         // Miscellaneous
00133         KAEvent             mEvent;           // the whole event, for updating the calendar file
00134         QLabel*             mRemainingText;   // the remaining time (for a reminder window)
00135         KPushButton*        mOkButton;
00136         QPushButton*        mEditButton;
00137         QPushButton*        mDeferButton;
00138         QPushButton*        mSilenceButton;
00139         QPushButton*        mKAlarmButton;
00140         QPushButton*        mKMailButton;
00141         DeferAlarmDlg*      mDeferDlg;
00142         QDateTime           mDeferLimit;      // last time to which the message can currently be deferred
00143         mutable KWinModule* mWinModule;
00144         int                 mFlags;
00145         int                 mLateCancel;
00146         int                 mButtonDelay;     // delay (ms) after window is shown before buttons are enabled
00147         bool                mErrorWindow;     // the window is simply an error message
00148         bool                mNoPostAction;    // don't execute any post-alarm action
00149         bool                mRecreating;      // window is about to be deleted and immediately recreated
00150         bool                mBeep;
00151         bool                mSpeak;           // the message should be spoken via kttsd
00152         bool                mRescheduleEvent; // true to delete event after message has been displayed
00153         bool                mShown;           // true once the window has been displayed
00154         bool                mPositioning;     // true when the window is being positioned initially
00155         bool                mNoCloseConfirm;  // the Defer or Edit button is closing the dialog
00156         bool                mUsingKMix;       // master volume is being set using kmix
00157 };
00158 
00159 #endif // MESSAGEWIN_H
KDE Home | KDE Accessibility Home | Description of Access Keys