File indexing completed on 2024-04-28 05:52:08

0001 /*
0002     SPDX-FileCopyrightText: 1998-1999 Matthias Hölzer-Klüpfel <matthias@hoelzer-kluepfel.de>
0003     SPDX-FileCopyrightText: 2002-2003 Martin Willers <willers@xm-arts.de>
0004     SPDX-FileCopyrightText: 2007-2009 Stefan Böhmann <kde@hilefoks.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 #ifndef TOPLEVEL_H
0009 #define TOPLEVEL_H
0010 
0011 #include "tea.h"
0012 
0013 #include <QSystemTrayIcon>
0014 #include <QPointer>
0015 
0016 
0017 class QAction;
0018 class QActionGroup;
0019 class QTimer;
0020 class KAboutData;
0021 class KActionCollection;
0022 class KHelpMenu;
0023 class KNotification;
0024 
0025 /**
0026  * @short the main class for KTeatime
0027  *
0028  * @author Stefan Böhmann <kde@hilefoks.org>
0029  */
0030 class TopLevel : public QSystemTrayIcon
0031 {
0032     public:
0033         explicit TopLevel(const KAboutData *aboutData,
0034                           const QString &trayIcon = QLatin1String("kteatime-symbolic"),
0035                           const QString &notificationIcon = QLatin1String("kteatime"),
0036                           QWidget *parent = nullptr);
0037         ~TopLevel() override;
0038         void setTeaList(const QList<Tea> &tealist);
0039         void runTea(const Tea &tea);
0040 
0041     private:
0042         void slotRunTea(QAction *a);
0043         void showSettingsDialog();
0044         void showTimeEditDialog();
0045         void teaTimeEvent();
0046         void cancelTea();
0047         void stopTea();
0048         void resumeTea();
0049         void showPopup(QSystemTrayIcon::ActivationReason reason);
0050         void checkState();
0051         void loadConfig();
0052         void loadTeaMenuItems();
0053         void repaintTrayIcon();
0054         void setTooltipText(const QString& content);
0055         void configureNotifications();
0056 
0057         QList<Tea> m_tealist;
0058         QAction *action = nullptr;
0059         QActionGroup *m_teaActionGroup = nullptr;
0060         KActionCollection *m_actionCollection = nullptr;
0061 
0062         KHelpMenu *m_helpMenu = nullptr;
0063         QTimer *m_timer = nullptr;
0064         QPointer<KNotification> m_popup;
0065         QString m_trayIconName;
0066         QString m_notificationIconName;
0067 
0068         int m_runningTeaTime;
0069         int m_pausedRemainingTeaTime;
0070         int m_nextNotificationTime;
0071         Tea m_runningTea;
0072 
0073         /** should we show a popup for events */
0074         bool m_usepopup;
0075 
0076         /** auto hide the popup? */
0077         bool m_autohide;
0078 
0079         /** time after the popup should be hide. */
0080         int m_autohidetime;
0081 
0082         /** remind us about a ready tea? */
0083         bool m_usereminder;
0084 
0085         /** the time bedween remind events */
0086         int m_remindertime;
0087 
0088         /** use a visual effect in the system tray icon. */
0089         bool m_usevisualize;
0090 };
0091 
0092 #endif
0093 
0094 // kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on;
0095 // vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: