• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kalarm

  • sources
  • kde-4.14
  • kdepim
  • kalarm
messagewin.h
Go to the documentation of this file.
1 /*
2  * messagewin.h - displays an alarm message
3  * Program: kalarm
4  * Copyright © 2001-2013 by David Jarvie <djarvie@kde.org>
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 "autoqpointer.h"
27 #ifdef USE_AKONADI
28 #include "eventid.h"
29 #endif
30 #include "mainwindowbase.h"
31 
32 #include <kalarmcal/kaevent.h>
33 
34 #ifdef USE_AKONADI
35 #include <akonadi/collection.h>
36 #include <akonadi/item.h>
37 #endif
38 
39 #include <QList>
40 #include <QMap>
41 #include <QPointer>
42 
43 class QShowEvent;
44 class QMoveEvent;
45 class QResizeEvent;
46 class QCloseEvent;
47 class PushButton;
48 class MessageText;
49 class QCheckBox;
50 class QLabel;
51 class DeferAlarmDlg;
52 class EditAlarmDlg;
53 class ShellProcess;
54 class AudioThread;
55 
56 using namespace KAlarmCal;
57 
61 class MessageWin : public MainWindowBase
62 {
63  Q_OBJECT
64  public:
65  enum { // flags for constructor
66  NO_RESCHEDULE = 0x01, // don't reschedule the event once it has displayed
67  NO_DEFER = 0x02, // don't display the Defer button
68  ALWAYS_HIDE = 0x04, // never show the window (e.g. for audio-only alarms)
69  NO_INIT_VIEW = 0x08 // for internal MessageWin use only
70  };
71 
72  MessageWin(); // for session management restoration only
73  MessageWin(const KAEvent*, const KAAlarm&, int flags);
74  ~MessageWin();
75  void repeat(const KAAlarm&);
76  void setRecreating() { mRecreating = true; }
77  const DateTime& dateTime() { return mDateTime; }
78  KAAlarm::Type alarmType() const { return mAlarmType; }
79  bool hasDefer() const;
80  void showDefer();
81  void cancelReminder(const KAEvent&, const KAAlarm&);
82  void showDateTime(const KAEvent&, const KAAlarm&);
83  bool isValid() const { return !mInvalid; }
84  bool alwaysHidden() const { return mAlwaysHide; }
85  virtual void show();
86  virtual QSize sizeHint() const;
87  static int instanceCount(bool excludeAlwaysHidden = false);
88 #ifdef USE_AKONADI
89  static MessageWin* findEvent(const EventId& eventId, MessageWin* exclude = 0);
90 #else
91  static MessageWin* findEvent(const QString& eventId, MessageWin* exclude = 0);
92 #endif
93  static void redisplayAlarms();
94  static void stopAudio(bool wait = false);
95  static bool isAudioPlaying();
96  static void showError(const KAEvent&, const DateTime& alarmDateTime, const QStringList& errmsgs,
97  const QString& dontShowAgain = QString());
98  static bool spread(bool scatter);
99 
100  protected:
101  virtual void showEvent(QShowEvent*);
102  virtual void moveEvent(QMoveEvent*);
103  virtual void resizeEvent(QResizeEvent*);
104  virtual void closeEvent(QCloseEvent*);
105  virtual void saveProperties(KConfigGroup&);
106  virtual void readProperties(const KConfigGroup&);
107 
108  private slots:
109  void slotOk();
110  void slotEdit();
111  void slotDefer();
112  void editCloseOk();
113  void editCloseCancel();
114  void activeWindowChanged(WId);
115  void checkDeferralLimit();
116  void displayMainWindow();
117 #ifdef USE_AKONADI
118  void showRestoredAlarm();
119 #endif
120 #ifdef KMAIL_SUPPORTED
121  void slotShowKMailMessage();
122 #endif
123  void slotSpeak();
124  void audioTerminating();
125  void startAudio();
126  void playReady();
127  void playFinished();
128  void enableButtons();
129  void setRemainingTextDay();
130  void setRemainingTextMinute();
131  void frameDrawn();
132  void readProcessOutput(ShellProcess*);
133 
134  private:
135  MessageWin(const KAEvent*, const DateTime& alarmDateTime, const QStringList& errmsgs,
136  const QString& dontShowAgain);
137  void initView();
138  QString dateTimeToDisplay();
139  void displayComplete();
140  void setButtonsReadOnly(bool);
141  bool getWorkAreaAndModal();
142  void playAudio();
143  void setDeferralLimit(const KAEvent&);
144  void alarmShowing(KAEvent&);
145 #ifdef USE_AKONADI
146  bool retrieveEvent(KAEvent&, Akonadi::Collection&, bool& showEdit, bool& showDefer);
147 #else
148  bool retrieveEvent(KAEvent&, AlarmResource*&, bool& showEdit, bool& showDefer);
149 #endif
150  bool haveErrorMessage(unsigned msg) const;
151  void clearErrorMessage(unsigned msg) const;
152  void redisplayAlarm();
153 #ifdef USE_AKONADI
154  static bool reinstateFromDisplaying(const KCalCore::Event::Ptr&, KAEvent&, Akonadi::Collection&, bool& showEdit, bool& showDefer);
155 #else
156  static bool reinstateFromDisplaying(const KCal::Event*, KAEvent&, AlarmResource*&, bool& showEdit, bool& showDefer);
157 #endif
158  static bool isSpread(const QPoint& topLeft);
159 
160  static QList<MessageWin*> mWindowList; // list of existing message windows
161 #ifdef USE_AKONADI
162  static QMap<EventId, unsigned> mErrorMessages; // error messages currently displayed, by event ID
163 #else
164  static QMap<QString, unsigned> mErrorMessages; // error messages currently displayed, by event ID
165 #endif
166  static bool mRedisplayed; // redisplayAlarms() was called
167  // Sound file playing
168  static QPointer<AudioThread> mAudioThread; // thread to play audio file
169  // Properties needed by readProperties()
170  QString mMessage;
171  QFont mFont;
172  QColor mBgColour, mFgColour;
173  DateTime mDateTime; // date/time displayed in the message window
174  QDateTime mCloseTime; // UTC time at which window should be auto-closed
175 #ifdef USE_AKONADI
176  Akonadi::Item::Id mEventItemId;
177  EventId mEventId;
178 #else
179  QString mEventId;
180 #endif
181  QString mAudioFile;
182  float mVolume;
183  float mFadeVolume;
184  int mFadeSeconds;
185  int mDefaultDeferMinutes;
186  KAAlarm::Type mAlarmType;
187  KAEvent::SubAction mAction;
188  unsigned long mKMailSerialNumber; // if email text, message's KMail serial number, else 0
189  KAEvent::CmdErrType mCommandError;
190  QStringList mErrorMsgs;
191  QString mDontShowAgain; // non-null for don't-show-again option with error message
192  int mRestoreHeight;
193  int mAudioRepeatPause;
194  bool mConfirmAck;
195  bool mShowEdit; // display the Edit button
196  bool mNoDefer; // don't display a Defer option
197  bool mInvalid; // restored window is invalid
198  // Miscellaneous
199  KAEvent mEvent; // the whole event, for updating the calendar file
200  KAEvent mOriginalEvent; // the original event supplied to the constructor
201 #ifdef USE_AKONADI
202  Akonadi::Collection mCollection; // collection which the event comes/came from
203 #else
204  AlarmResource* mResource; // resource which the event comes/came from
205 #endif
206  QLabel* mTimeLabel; // trigger time label
207  QLabel* mRemainingText; // the remaining time (for a reminder window)
208  PushButton* mOkButton;
209  PushButton* mEditButton;
210  PushButton* mDeferButton;
211  PushButton* mSilenceButton;
212  PushButton* mKAlarmButton;
213  PushButton* mKMailButton;
214  MessageText* mCommandText; // shows output from command
215  QCheckBox* mDontShowAgainCheck;
216  EditAlarmDlg* mEditDlg; // alarm edit dialog invoked by Edit button
217  DeferAlarmDlg* mDeferDlg;
218  QDateTime mDeferLimit; // last UTC time to which the message can currently be deferred
219  int mButtonDelay; // delay (ms) after window is shown before buttons are enabled
220  int mScreenNumber; // screen to display on, or -1 for default
221  bool mAlwaysHide; // the window should never be displayed
222  bool mErrorWindow; // the window is simply an error message
223  bool mInitialised; // initView() has been called to create the window's widgets
224  bool mNoPostAction; // don't execute any post-alarm action
225  bool mRecreating; // window is about to be deleted and immediately recreated
226  bool mBeep;
227  bool mSpeak; // the message should be spoken via kttsd
228  bool mRescheduleEvent; // true to delete event after message has been displayed
229  bool mShown; // true once the window has been displayed
230  bool mPositioning; // true when the window is being positioned initially
231  bool mNoCloseConfirm; // the Defer or Edit button is closing the dialog
232  bool mDisableDeferral; // true if past deferral limit, so don't enable Defer button
233 };
234 
235 #endif // MESSAGEWIN_H
236 
237 // vim: et sw=4:
QResizeEvent
QMoveEvent
MessageWin::setRecreating
void setRecreating()
Definition: messagewin.h:76
QFont
MainWindowBase
The MainWindowBase class is a base class for KAlarm's main window and message window.
Definition: mainwindowbase.h:36
QMap
QPointer< AudioThread >
eventid.h
QPoint
DeferAlarmDlg
Definition: deferdlg.h:38
PushButton
QCloseEvent
MessageWin
MessageWin: A window to display an alarm or error message.
Definition: messagewin.h:61
autoqpointer.h
QShowEvent
QCheckBox
QString
QList< MessageWin * >
QColor
MessageWin::dateTime
const DateTime & dateTime()
Definition: messagewin.h:77
MessageWin::alarmType
KAAlarm::Type alarmType() const
Definition: messagewin.h:78
QStringList
QSize
MessageWin::isValid
bool isValid() const
Definition: messagewin.h:83
EventId
Unique event identifier for Akonadi.
Definition: eventid.h:38
AudioThread
Definition: messagewin_p.h:33
EditAlarmDlg
Definition: editdlg.h:60
QLabel
MessageWin::alwaysHidden
bool alwaysHidden() const
Definition: messagewin.h:84
ShellProcess
QDateTime
mainwindowbase.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal