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