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

kalarm

  • sources
  • kde-4.12
  • 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);
90 #else
91  static MessageWin* findEvent(const QString& eventId);
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 KMAIL_SUPPORTED
118  void slotShowKMailMessage();
119 #endif
120  void slotSpeak();
121  void audioTerminating();
122  void startAudio();
123  void playReady();
124  void playFinished();
125  void enableButtons();
126  void setRemainingTextDay();
127  void setRemainingTextMinute();
128  void frameDrawn();
129  void readProcessOutput(ShellProcess*);
130 
131  private:
132  MessageWin(const KAEvent*, const DateTime& alarmDateTime, const QStringList& errmsgs,
133  const QString& dontShowAgain);
134  void initView();
135  QString dateTimeToDisplay();
136  void displayComplete();
137  void setButtonsReadOnly(bool);
138  bool getWorkAreaAndModal();
139  void playAudio();
140  void setDeferralLimit(const KAEvent&);
141  void alarmShowing(KAEvent&);
142 #ifdef USE_AKONADI
143  bool retrieveEvent(KAEvent&, Akonadi::Collection&, bool& showEdit, bool& showDefer);
144 #else
145  bool retrieveEvent(KAEvent&, AlarmResource*&, bool& showEdit, bool& showDefer);
146 #endif
147  bool haveErrorMessage(unsigned msg) const;
148  void clearErrorMessage(unsigned msg) const;
149 #ifdef USE_AKONADI
150  static bool reinstateFromDisplaying(const KCalCore::Event::Ptr&, KAEvent&, Akonadi::Collection&, bool& showEdit, bool& showDefer);
151 #else
152  static bool reinstateFromDisplaying(const KCal::Event*, KAEvent&, AlarmResource*&, bool& showEdit, bool& showDefer);
153 #endif
154  static bool isSpread(const QPoint& topLeft);
155 
156  static QList<MessageWin*> mWindowList; // list of existing message windows
157 #ifdef USE_AKONADI
158  static QMap<EventId, unsigned> mErrorMessages; // error messages currently displayed, by event ID
159 #else
160  static QMap<QString, unsigned> mErrorMessages; // error messages currently displayed, by event ID
161 #endif
162  // Sound file playing
163  static QPointer<AudioThread> mAudioThread; // thread to play audio file
164  // Properties needed by readProperties()
165  QString mMessage;
166  QFont mFont;
167  QColor mBgColour, mFgColour;
168  DateTime mDateTime; // date/time displayed in the message window
169  QDateTime mCloseTime; // UTC time at which window should be auto-closed
170 #ifdef USE_AKONADI
171  Akonadi::Item::Id mEventItemId;
172  EventId mEventId;
173 #else
174  QString mEventId;
175 #endif
176  QString mAudioFile;
177  float mVolume;
178  float mFadeVolume;
179  int mFadeSeconds;
180  int mDefaultDeferMinutes;
181  KAAlarm::Type mAlarmType;
182  KAEvent::SubAction mAction;
183  unsigned long mKMailSerialNumber; // if email text, message's KMail serial number, else 0
184  KAEvent::CmdErrType mCommandError;
185  QStringList mErrorMsgs;
186  QString mDontShowAgain; // non-null for don't-show-again option with error message
187  int mRestoreHeight;
188  int mAudioRepeatPause;
189  bool mConfirmAck;
190  bool mShowEdit; // display the Edit button
191  bool mNoDefer; // don't display a Defer option
192  bool mInvalid; // restored window is invalid
193  // Miscellaneous
194  KAEvent mEvent; // the whole event, for updating the calendar file
195  KAEvent mOriginalEvent; // the original event supplied to the constructor
196 #ifdef USE_AKONADI
197  Akonadi::Collection mCollection; // collection which the event comes/came from
198 #else
199  AlarmResource* mResource; // resource which the event comes/came from
200 #endif
201  QLabel* mTimeLabel; // trigger time label
202  QLabel* mRemainingText; // the remaining time (for a reminder window)
203  PushButton* mOkButton;
204  PushButton* mEditButton;
205  PushButton* mDeferButton;
206  PushButton* mSilenceButton;
207  PushButton* mKAlarmButton;
208  PushButton* mKMailButton;
209  MessageText* mCommandText; // shows output from command
210  QCheckBox* mDontShowAgainCheck;
211  EditAlarmDlg* mEditDlg; // alarm edit dialog invoked by Edit button
212  DeferAlarmDlg* mDeferDlg;
213  QDateTime mDeferLimit; // last UTC time to which the message can currently be deferred
214  int mButtonDelay; // delay (ms) after window is shown before buttons are enabled
215  int mScreenNumber; // screen to display on, or -1 for default
216  bool mAlwaysHide; // the window should never be displayed
217  bool mErrorWindow; // the window is simply an error message
218  bool mInitialised; // initView() has been called to create the window's widgets
219  bool mNoPostAction; // don't execute any post-alarm action
220  bool mRecreating; // window is about to be deleted and immediately recreated
221  bool mBeep;
222  bool mSpeak; // the message should be spoken via kttsd
223  bool mRescheduleEvent; // true to delete event after message has been displayed
224  bool mShown; // true once the window has been displayed
225  bool mPositioning; // true when the window is being positioned initially
226  bool mNoCloseConfirm; // the Defer or Edit button is closing the dialog
227  bool mDisableDeferral; // true if past deferral limit, so don't enable Defer button
228 };
229 
230 #endif // MESSAGEWIN_H
231 
232 // vim: et sw=4:
MessageWin::setRecreating
void setRecreating()
Definition: messagewin.h:76
MainWindowBase
The MainWindowBase class is a base class for KAlarm's main window and message window.
Definition: mainwindowbase.h:36
eventid.h
DeferAlarmDlg
Definition: deferdlg.h:38
QPointer< AudioThread >
PushButton
MessageWin
MessageWin: A window to display an alarm or error message.
Definition: messagewin.h:61
autoqpointer.h
MessageWin::dateTime
const DateTime & dateTime()
Definition: messagewin.h:77
MessageWin::alarmType
KAAlarm::Type alarmType() const
Definition: messagewin.h:78
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:61
QLabel
QCheckBox
MessageWin::alwaysHidden
bool alwaysHidden() const
Definition: messagewin.h:84
ShellProcess
QList< MessageWin * >
mainwindowbase.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:10 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

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