kalarm

messagewin.h
Go to the documentation of this file.
1 /*
2  * messagewin.h - displays an alarm message
3  * Program: kalarm
4  * Copyright © 2001-2007 by David Jarvie <software@astrojar.org.uk>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef MESSAGEWIN_H
22 #define MESSAGEWIN_H
23 
26 #include <tqmap.h>
27 
28 #include "mainwindowbase.h"
29 #include "alarmevent.h"
30 
31 class TQPushButton;
32 class KPushButton;
33 class TQLabel;
34 class TQTimer;
35 class KWinModule;
36 class AlarmTimeWidget;
37 class DeferAlarmDlg;
38 class KArtsDispatcher;
39 namespace KDE { class PlayObject; }
40 
44 class MessageWin : public MainWindowBase
45 {
46  TQ_OBJECT
47 
48  public:
49  MessageWin(); // for session management restoration only
50  MessageWin(const KAEvent&, const KAAlarm&, bool reschedule_event = true, bool allowDefer = true);
51  MessageWin(const KAEvent&, const DateTime& alarmDateTime, const TQStringList& errmsgs);
52  ~MessageWin();
53  void repeat(const KAAlarm&);
54  void setRecreating() { mRecreating = true; }
55  const DateTime& dateTime() { return mDateTime; }
56  KAAlarm::Type alarmType() const { return mAlarmType; }
57  bool hasDefer() const { return !!mDeferButton; }
58  bool isValid() const { return !mInvalid; }
59  virtual void show();
60  virtual TQSize sizeHint() const;
61  static int instanceCount() { return mWindowList.count(); }
62  static MessageWin* findEvent(const TQString& eventID);
63 
64  protected:
65  virtual void showEvent(TQShowEvent*);
66  virtual void moveEvent(TQMoveEvent*);
67  virtual void resizeEvent(TQResizeEvent*);
68  virtual void closeEvent(TQCloseEvent*);
69  virtual void saveProperties(TDEConfig*);
70  virtual void readProperties(TDEConfig*);
71 
72  private slots:
73  void slotEdit();
74  void slotDefer();
75  void checkDeferralLimit();
76  void displayMainWindow();
77  void slotShowKMailMessage();
78  void slotSpeak();
79  void slotPlayAudio();
80  void checkAudioPlay();
81  void stopPlay();
82  void slotFade();
83  void enableButtons();
84  void setRemainingTextDay();
85  void setRemainingTextMinute();
86  void setMaxSize();
87 
88  private:
89  void initView();
90 #ifndef WITHOUT_ARTS
91  void initAudio(bool firstTime);
92  int getKMixVolume();
93  void setKMixVolume(int percent);
94 #endif
95  void displayComplete();
96  void playAudio();
97  void setDeferralLimit(const KAEvent&);
98  bool haveErrorMessage(unsigned msg) const;
99  void clearErrorMessage(unsigned msg) const;
100 
101  static TQValueList<MessageWin*> mWindowList; // list of existing message windows
102  static TQMap<TQString, unsigned> mErrorMessages; // error messages currently displayed, by event ID
103  // Properties needed by readProperties()
104  TQString mMessage;
105  TQFont mFont;
106  TQColor mBgColour, mFgColour;
107  DateTime mDateTime; // date/time displayed in the message window
108  TQDateTime mCloseTime; // time at which window should be auto-closed
109  TQString mEventID;
110  TQString mAudioFile;
111  float mVolume;
112  float mFadeVolume;
113  int mFadeSeconds;
114  int mDefaultDeferMinutes;
115  KAAlarm::Type mAlarmType;
116  KAEvent::Action mAction;
117  unsigned long mKMailSerialNumber; // if email text, message's KMail serial number, else 0
118  TQStringList mErrorMsgs;
119  int mRestoreHeight;
120  bool mAudioRepeat;
121  bool mConfirmAck;
122  bool mShowEdit; // display the Edit button
123  bool mNoDefer; // don't display a Defer option
124  bool mInvalid; // restored window is invalid
125  // Sound file playing
126  KArtsDispatcher* mArtsDispatcher;
127  KDE::PlayObject* mPlayObject;
128  TQCString mKMixName; // DCOP name for KMix
129  TQString mKMixError; // error message starting KMix
130  TQTimer* mPlayTimer; // timer for repeating the sound file
131  TQTimer* mFadeTimer; // timer for fading the sound volume
132  float mOldVolume; // volume before volume was set for sound file
133  TQString mLocalAudioFile; // local copy of audio file
134  TQTime mAudioFileStart; // time when audio file loading first started, or when play first started
135  int mAudioFileLoadSecs; // how many seconds it took to load audio file
136  bool mPlayedOnce; // the sound file has started playing at least once
137  bool mPlayed; // the PlayObject->play() has been called
138  // Miscellaneous
139  KAEvent mEvent; // the whole event, for updating the calendar file
140  TQLabel* mRemainingText; // the remaining time (for a reminder window)
141  KPushButton* mOkButton;
142  TQPushButton* mEditButton;
143  TQPushButton* mDeferButton;
144  TQPushButton* mSilenceButton;
145  TQPushButton* mKAlarmButton;
146  TQPushButton* mKMailButton;
147  DeferAlarmDlg* mDeferDlg;
148  TQDateTime mDeferLimit; // last time to which the message can currently be deferred
149  mutable KWinModule* mWinModule;
150  int mFlags;
151  int mLateCancel;
152  int mButtonDelay; // delay (ms) after window is shown before buttons are enabled
153  bool mErrorWindow; // the window is simply an error message
154  bool mNoPostAction; // don't execute any post-alarm action
155  bool mRecreating; // window is about to be deleted and immediately recreated
156  bool mBeep;
157  bool mSpeak; // the message should be spoken via kttsd
158  bool mRescheduleEvent; // true to delete event after message has been displayed
159  bool mShown; // true once the window has been displayed
160  bool mPositioning; // true when the window is being positioned initially
161  bool mNoCloseConfirm; // the Defer or Edit button is closing the dialog
162  bool mUsingKMix; // master volume is being set using kmix
163  bool mDisableDeferral; // true if past deferral limit, so don't enable Defer button
164 };
165 
166 #endif // MESSAGEWIN_H
represents calendar alarms and events
KAEvent corresponds to a KCal::Event instance.
Definition: alarmevent.h:232
The MainWindowBase class is a base class for KAlarm's main window and message window.
MessageWin: A window to display an alarm message.
Definition: messagewin.h:45