File indexing completed on 2025-01-05 05:18:56

0001 // SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QQmlEngine>
0008 #include <QQuickItem>
0009 class SystemTray;
0010 class Controller : public QObject
0011 {
0012     Q_OBJECT
0013     QML_ELEMENT
0014     QML_SINGLETON
0015     Q_PROPERTY(bool supportSystemTray READ supportSystemTray CONSTANT)
0016 public:
0017     explicit Controller(QObject *parent = nullptr);
0018     ~Controller() override;
0019 
0020     static Controller &instance();
0021     static Controller *create(QQmlEngine *engine, QJSEngine *);
0022 
0023     [[nodiscard]] bool supportSystemTray() const;
0024 
0025 public Q_SLOTS:
0026     void saveWindowGeometry();
0027 
0028 private:
0029     void setQuitOnLastWindowClosed();
0030     void toggleWindow();
0031     SystemTray *mTrayIcon = nullptr;
0032 };