File indexing completed on 2024-04-28 09:41:54
0001 // SPDX-License-Identifier: GPL-3.0-or-later 0002 /* 0003 Copyright 2017 Martin Koller, kollix@aon.at 0004 0005 This file is part of liquidshell. 0006 0007 liquidshell is free software: you can redistribute it and/or modify 0008 it under the terms of the GNU General Public License as published by 0009 the Free Software Foundation, either version 3 of the License, or 0010 (at your option) any later version. 0011 0012 liquidshell is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 GNU General Public License for more details. 0016 0017 You should have received a copy of the GNU General Public License 0018 along with liquidshell. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #ifndef _NotificationList_H_ 0022 #define _NotificationList_H_ 0023 0024 #include <QScrollArea> 0025 #include <QFrame> 0026 #include <QLabel> 0027 #include <QIcon> 0028 #include <QMap> 0029 class QVBoxLayout; 0030 class QProgressBar; 0031 class NotificationServer; 0032 0033 class NotifyItem : public QFrame 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 NotifyItem(QWidget *parent, NotificationServer *server, uint theid, const QString &app, 0039 const QString &summary, const QString &body, const QIcon &icon, 0040 const QStringList &actions); 0041 0042 void destroySysResources(); 0043 0044 void setTimeout(int milliSecs); 0045 0046 uint id; 0047 QString appName, summary, body; 0048 QStringList actions; 0049 QLabel *timeLabel, *iconLabel, *textLabel; 0050 QProgressBar *timeoutBar; 0051 }; 0052 0053 //-------------------------------------------------------------------------------- 0054 0055 class NotificationList : public QWidget 0056 { 0057 Q_OBJECT 0058 0059 public: 0060 NotificationList(NotificationServer *parent); 0061 ~NotificationList() override; 0062 0063 void addItem(uint id, const QString &appName, const QString &summary, const QString &body, 0064 const QIcon &icon, const QStringList &actions, const QVariantMap &hints, int timeout); 0065 0066 void closeItem(uint id); 0067 0068 int itemCount() const { return items.count(); } 0069 QVector<NotifyItem *> getItems() const { return items; } 0070 0071 void setAvoidPopup(bool on); 0072 bool getAvoidPopup() const { return avoidPopup; } 0073 0074 Q_SIGNALS: 0075 void itemsCountChanged(); 0076 void listNowEmpty(); 0077 0078 private Q_SLOTS: 0079 void itemDestroyed(QObject *item); 0080 0081 private: 0082 void placeItems(); 0083 0084 private: 0085 QScrollArea *scrollArea; 0086 QVBoxLayout *listVbox; 0087 QMap<QString, int> appTimeouts; // appName, timeout (minutes) 0088 QVector<NotifyItem *> items; 0089 NotificationServer *server; 0090 bool avoidPopup = false; 0091 }; 0092 0093 #endif