File indexing completed on 2024-04-28 16:49:37

0001 /*
0002  * Copyright 2018  Michail Vourlakos <mvourlakos@gmail.com>
0003  *
0004  * This file is part of Latte-Dock
0005  *
0006  * Latte-Dock is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * Latte-Dock is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  *
0019  */
0020 
0021 #ifndef BACKGROUNDTRACKER_H
0022 #define BACKGROUNDTRACKER_H
0023 
0024 // local
0025 #include "plasma/extended/backgroundcache.h"
0026 
0027 // Qt
0028 #include <QObject>
0029 
0030 namespace Latte{
0031 
0032 class BackgroundTracker: public QObject
0033 {
0034     Q_OBJECT
0035 
0036     Q_PROPERTY(bool isBusy READ isBusy NOTIFY isBusyChanged)
0037 
0038     Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged)
0039 
0040     Q_PROPERTY(float currentBrightness READ currentBrightness NOTIFY currentBrightnessChanged)
0041 
0042     Q_PROPERTY(QString activity READ activity WRITE setActivity NOTIFY activityChanged)
0043     Q_PROPERTY(QString screenName READ screenName WRITE setScreenName NOTIFY screenNameChanged)
0044 
0045 public:
0046     BackgroundTracker(QObject *parent = nullptr);
0047     virtual ~BackgroundTracker();
0048 
0049     bool isBusy() const;
0050 
0051     int location() const;
0052     void setLocation(int location);
0053 
0054     float currentBrightness() const;
0055 
0056     QString activity() const;
0057     void setActivity(QString id);
0058 
0059     QString screenName() const;
0060     void setScreenName(QString name);
0061 
0062 public slots:
0063     Q_INVOKABLE void setBackgroundFromBroadcast(QString activity, QString screen, QString filename);
0064     Q_INVOKABLE void setBroadcastedBackgroundsEnabled(QString activity, QString screen, bool enabled);
0065 
0066 signals:
0067     void activityChanged();
0068     void currentBrightnessChanged();
0069     void isBusyChanged();
0070     void locationChanged();
0071     void screenNameChanged();
0072 
0073 private slots:
0074     void backgroundChanged(const QString &activity, const QString &screenName);
0075     void update();
0076 
0077 private:
0078     // local
0079     bool m_busy{false};
0080     float m_brightness{-1000};
0081     PlasmaExtended::BackgroundCache *m_cache{nullptr};
0082 
0083     // Qt
0084     QString m_activity;
0085     QString m_screenName;
0086 
0087     // Plasma
0088     Plasma::Types::Location m_location{Plasma::Types::BottomEdge};
0089 
0090 };
0091 
0092 }
0093 
0094 #endif