File indexing completed on 2024-05-12 05:14:52
0001 /* 0002 * messagenotification.h - displays an alarm message in a system notification 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2020 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "messagedisplay.h" 0012 #include <KNotification> 0013 0014 using namespace KAlarmCal; 0015 0016 /** 0017 * MessageNotification: A window to display an alarm or error message 0018 */ 0019 class MessageNotification : public KNotification, public MessageDisplay 0020 { 0021 Q_OBJECT 0022 public: 0023 MessageNotification(const KAEvent&, const KAAlarm&, int flags); 0024 MessageNotification(const KAEvent&, const DateTime& alarmDateTime, const QStringList& errmsgs, 0025 const QString& dontShowAgain); 0026 ~MessageNotification() override; 0027 0028 /** Restore MessageNotification instances saved at session shutdown. */ 0029 static void sessionRestore(); 0030 0031 QWidget* displayParent() override; 0032 void closeDisplay() override; 0033 void showDisplay() override; 0034 void raiseDisplay() override; 0035 0036 void repeat(const KAAlarm&) override; 0037 bool hasDefer() const override; 0038 void showDefer() override; 0039 void showDateTime(const KAEvent&, const KAAlarm&) override; 0040 void cancelReminder(const KAEvent&, const KAAlarm&) override; 0041 static int notificationCount(); 0042 0043 protected Q_SLOTS: 0044 void textsChanged(MessageDisplayHelper::DisplayTexts::TextIds ids, const QString& change); 0045 0046 protected: 0047 void setUpDisplay() override; 0048 bool isDeferButtonEnabled() const override; 0049 void enableDeferButton(bool enable) override; 0050 void enableEditButton(bool enable) override; 0051 void saveProperties(KConfigGroup&); 0052 0053 private Q_SLOTS: 0054 void slotDefaultActivated(); 0055 void commandCompleted(bool success); 0056 void slotClosed(); 0057 0058 private: 0059 MessageNotification(const QString& eventId, MessageDisplayHelper* helper); 0060 void setNotificationTitle(const QString&); 0061 void setNotificationText(); 0062 void setNotificationButtons(); 0063 0064 static QList<MessageNotification*> mNotificationList; // list of notification instances 0065 // Miscellaneous 0066 QString mTimeText; // trigger time text 0067 QString mMessageText; // alarm message text 0068 QString mRemainingText; // remaining time text 0069 bool mEnableDefer {false}; // whether to show a Defer button 0070 bool mEnableEdit {false}; // whether to show an Edit button 0071 bool mInitialised {false}; // setUpDisplay() has been called to create the window's widgets 0072 bool mDisplayComplete {false}; // true once displayComplete() has been called 0073 bool mShown {false}; // true once the notification has been displayed 0074 bool mCommandInhibit {false}; // true to prevent display until command exits 0075 0076 friend class MNSessionManager; 0077 }; 0078 0079 // vim: et sw=4: