File indexing completed on 2024-05-12 16:21:31
0001 /** 0002 * SPDX-FileCopyrightText: 2023 Bart De Vries <bart@mogwai.be> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #ifndef Q_OS_ANDROID 0011 #include <QSystemTrayIcon> 0012 #endif 0013 0014 class SystrayIcon 0015 #ifndef Q_OS_ANDROID 0016 : public QSystemTrayIcon 0017 #else 0018 : public QObject 0019 #endif 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 enum IconColor { 0025 Colorful, 0026 Light, 0027 Dark, 0028 }; 0029 Q_ENUM(IconColor) 0030 0031 Q_PROPERTY(bool available READ available CONSTANT) 0032 0033 static SystrayIcon &instance() 0034 { 0035 static SystrayIcon _instance; 0036 return _instance; 0037 } 0038 0039 ~SystrayIcon() override; 0040 0041 [[nodiscard]] bool available() const; 0042 0043 void setIconColor(IconColor iconColor); 0044 0045 Q_SIGNALS: 0046 void raiseWindow(); 0047 0048 private: 0049 explicit SystrayIcon(QObject *parent = nullptr); 0050 int iconColorEnumToInt(IconColor iconColor); 0051 IconColor intToIconColorEnum(int iconColorCode); 0052 };