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

0001 /*
0002 *  Copyright 2016  Smith AR <audoban@openmailbox.org>
0003 *                  Michail Vourlakos <mvourlakos@gmail.com>
0004 *
0005 *  This file is part of Latte-Dock
0006 *
0007 *  Latte-Dock is free software; you can redistribute it and/or
0008 *  modify it under the terms of the GNU General Public License as
0009 *  published by the Free Software Foundation; either version 2 of
0010 *  the License, or (at your option) any later version.
0011 *
0012 *  Latte-Dock 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 this program.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 
0021 #ifndef QUICKWINDOWSYSTEM_H
0022 #define QUICKWINDOWSYSTEM_H
0023 
0024 // Qt
0025 #include <QObject>
0026 #include <QQmlEngine>
0027 #include <QJSEngine>
0028 
0029 namespace Latte {
0030 
0031 /**
0032  * @brief The QuickWindowSystem class,
0033  * is a tiny class that provide basic information of WindowSystem
0034  */
0035 class QuickWindowSystem final : public QObject
0036 {
0037     Q_OBJECT
0038 
0039     Q_PROPERTY(bool compositingActive READ compositingActive NOTIFY compositingChanged FINAL)
0040     Q_PROPERTY(bool isPlatformWayland READ isPlatformWayland NOTIFY isPlatformWaylandChanged FINAL)
0041 
0042     Q_PROPERTY(uint frameworksVersion READ frameworksVersion NOTIFY frameworksVersionChanged)
0043     Q_PROPERTY(uint plasmaDesktopVersion READ plasmaDesktopVersion NOTIFY plasmaDesktopVersionChanged)
0044 
0045 public:
0046     explicit QuickWindowSystem(QObject *parent = nullptr);
0047     virtual ~QuickWindowSystem();
0048 
0049     bool compositingActive() const;
0050     bool isPlatformWayland() const;
0051 
0052     uint frameworksVersion() const;
0053     uint plasmaDesktopVersion();
0054 
0055 public slots:
0056     Q_INVOKABLE uint makeVersion(uint major, uint minor, uint release) const;
0057 
0058 signals:
0059     void compositingChanged();
0060     void frameworksVersionChanged();
0061     void isPlatformWaylandChanged();
0062     void plasmaDesktopVersionChanged();
0063 
0064 private:
0065     void loadPlasmaDesktopVersion();
0066 
0067     uint identifyPlasmaDesktopVersion();
0068 
0069 private:
0070     bool m_compositing{true};
0071 
0072     int m_plasmaDesktopVersion{ -1};
0073 };
0074 
0075 static QObject *windowsystem_qobject_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
0076 {
0077     Q_UNUSED(engine)
0078     Q_UNUSED(scriptEngine)
0079 
0080 // NOTE: QML engine is the owner of this resource
0081     return new QuickWindowSystem;
0082 }
0083 
0084 }
0085 
0086 #endif // QUICKWINDOWSYSTEM_H