File indexing completed on 2024-04-21 05:54:05

0001 /*
0002     SPDX-FileCopyrightText: 2005-2006 Tom Albers <toma@kde.org>
0003     SPDX-FileCopyrightText: 2006 Bram Schoenmakers <bramschoenmakers@kde.nl>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 
0007 */
0008 
0009 #ifndef RSIWIDGET_H
0010 #define RSIWIDGET_H
0011 
0012 #include "notificator.h"
0013 #include "rsitimer.h"
0014 
0015 class RSIDock;
0016 class RSIRelaxPopup;
0017 class BreakBase;
0018 
0019 /**
0020  * @class RSIObject
0021  * This controls all RSIBreak components
0022  * @author Tom Albers <toma.org>
0023  */
0024 class RSIObject : public QObject
0025 {
0026     Q_OBJECT
0027     Q_CLASSINFO("D-Bus Interface", "org.rsibreak.rsiwidget")
0028 
0029 public:
0030     enum Effects { SimpleGray = 0, Plasma, SlideShow, Popup };
0031 
0032     /**
0033      * Constructor
0034      * @param parent Parent Widget
0035      * @param name Name
0036      */
0037     explicit RSIObject(QWidget *parent = nullptr);
0038 
0039     /**
0040      * Destructor
0041      */
0042     ~RSIObject();
0043 
0044     /**
0045      * Access to the timer
0046      */
0047     RSITimer *timer()
0048     {
0049         return m_timer;
0050     };
0051 
0052 private slots:
0053     void slotWelcome();
0054     void slotLock();
0055     void minimize();
0056     void maximize();
0057     void setCounters(int);
0058     void updateIdleAvg(double);
0059     void readConfig();
0060     void tinyBreakSkipped();
0061     void bigBreakSkipped();
0062 
0063 protected:
0064     /** Sets appropriate icon in tooltip and docker. */
0065     void setIcon(int);
0066 
0067 private:
0068     void findImagesInFolder(const QString &folder);
0069     void loadImage();
0070     void configureTimer();
0071 
0072     RSIDock *m_tray;
0073     RSITimer *m_timer;
0074     BreakBase *m_effect;
0075 
0076     bool m_useImages;
0077 
0078     bool m_usePlasma;
0079     bool m_usePlasmaRO;
0080 
0081     RSIRelaxPopup *m_relaxpopup;
0082 
0083     QString m_currentIcon;
0084 
0085     Notificator m_notificator;
0086 
0087     /* Available through D-Bus */
0088 public Q_SLOTS:
0089     void resume();
0090     void suspend();
0091     int idleTime()
0092     {
0093         return timer()->idleTime();
0094     }
0095     int tinyLeft()
0096     {
0097         return timer()->tinyLeft();
0098     }
0099     int bigLeft()
0100     {
0101         return timer()->bigLeft();
0102     }
0103     QString currentIcon()
0104     {
0105         return m_currentIcon;
0106     }
0107 };
0108 
0109 #endif