toplevel.h 3.08 KB
Newer Older
1
/*
2
 * Copyright 1998-1999 by Matthias Hölzer-Klüpfel <matthias@hoelzer-kluepfel.de>
Stefan Böhmann's avatar
Stefan Böhmann committed
3 4
 * Copyright 2002-2003 by Martin Willers <willers@xm-arts.de>
 * Copyright 2007-2009 by Stefan Böhmann <kde@hilefoks.org>
5
 *
Stefan Böhmann's avatar
Stefan Böhmann committed
6 7 8 9
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
10
 *
Stefan Böhmann's avatar
Stefan Böhmann committed
11 12 13 14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
15
 *
Stefan Böhmann's avatar
Stefan Böhmann committed
16 17
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
Benjamin Meyer's avatar
Benjamin Meyer committed
19 20
#ifndef TOPLEVEL_H
#define TOPLEVEL_H
Matthias Hoelzer-Kluepfel's avatar
Matthias Hoelzer-Kluepfel committed
21

Daniel Teske's avatar
Daniel Teske committed
22 23
#include "tea.h"

24
#include <QSystemTrayIcon>
25
#include <QPointer>
Arto Hytönen's avatar
Arto Hytönen committed
26

Matthias Hoelzer-Kluepfel's avatar
Matthias Hoelzer-Kluepfel committed
27

Daniel Teske's avatar
Daniel Teske committed
28 29
class QAction;
class QActionGroup;
Andrius Štikonas's avatar
Andrius Štikonas committed
30 31 32
class QTimer;
class KAboutData;
class KActionCollection;
Daniel Teske's avatar
Daniel Teske committed
33
class KHelpMenu;
34
class KNotification;
Daniel Teske's avatar
Daniel Teske committed
35 36 37 38

/**
 * @short the main class for KTeatime
 *
Stefan Böhmann's avatar
Stefan Böhmann committed
39
 * @author Stefan Böhmann <kde@hilefoks.org>
Daniel Teske's avatar
Daniel Teske committed
40
 */
41
class TopLevel : public QSystemTrayIcon
Matthias Hoelzer-Kluepfel's avatar
Matthias Hoelzer-Kluepfel committed
42
{
Daniel Teske's avatar
Daniel Teske committed
43
    public:
Laurent Montel's avatar
Laurent Montel committed
44
        explicit TopLevel(const KAboutData *aboutData, const QString &icon = QLatin1String("kteatime"), QWidget *parent = nullptr);
Daniel Teske's avatar
Daniel Teske committed
45
        ~TopLevel();
Stefan Böhmann's avatar
Stefan Böhmann committed
46 47 48
        void setTeaList(const QList<Tea> &tealist);
        void runTea(const Tea &tea);

Andrius Štikonas's avatar
Andrius Štikonas committed
49
    private:
50
        void slotRunTea(QAction *a);
Stefan Böhmann's avatar
Stefan Böhmann committed
51 52 53 54
        void showSettingsDialog();
        void showTimeEditDialog();
        void teaTimeEvent();
        void cancelTea();
Fabio Bolz's avatar
Fabio Bolz committed
55 56
        void stopTea();
        void resumeTea();
57
        void showPopup(QSystemTrayIcon::ActivationReason reason);
Daniel Teske's avatar
Daniel Teske committed
58 59 60 61
        void checkState();
        void loadConfig();
        void loadTeaMenuItems();
        void repaintTrayIcon();
62
        void setTooltipText(const QString& content);
Andrius Štikonas's avatar
Andrius Štikonas committed
63
        void configureNotifications();
Daniel Teske's avatar
Daniel Teske committed
64 65

        QList<Tea> m_tealist;
66 67 68
        QAction *action = nullptr;
        QActionGroup *m_teaActionGroup = nullptr;
        KActionCollection *m_actionCollection = nullptr;
Daniel Teske's avatar
Daniel Teske committed
69

70 71
        KHelpMenu *m_helpMenu = nullptr;
        QTimer *m_timer = nullptr;
72
        QPointer<KNotification> m_popup;
73
        QString m_iconName;
Daniel Teske's avatar
Daniel Teske committed
74 75

        int m_runningTeaTime;
Fabio Bolz's avatar
Fabio Bolz committed
76
        int m_pausedRemainingTeaTime;
Daniel Teske's avatar
Daniel Teske committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
        int m_nextNotificationTime;
        Tea m_runningTea;

        /** should we show a popup for events */
        bool m_usepopup;

        /** auto hide the popup? */
        bool m_autohide;

        /** time after the popup should be hide. */
        int m_autohidetime;

        /** remind us about a ready tea? */
        bool m_usereminder;

        /** the time bedween remind events */
        int m_remindertime;

        /** use a visual effect in the system tray icon. */
        bool m_usevisualize;
Matthias Hoelzer-Kluepfel's avatar
Matthias Hoelzer-Kluepfel committed
97 98 99
};

#endif
Daniel Teske's avatar
Daniel Teske committed
100

Stefan Böhmann's avatar
Stefan Böhmann committed
101 102
// 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;
// vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: