diff --git a/.reuse/dep5 b/.reuse/dep5 index 58ab9193..6d98be4f 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -14,7 +14,7 @@ Files: android/res/drawable/splash.xml Copyright: 2020 Tobias Fella License: BSD-2-Clause -Files: kasts.svg kasts-android-square.svg icons/kasts-tray.svg logo.png android/ic_launcher-playstore.png android/res/drawable/kasts.png android/res/drawable-v24/ic_launcher_background.xml android/res/drawable-v24/ic_launcher_foreground.xml android/res/mipmap-hdpi/ic_launcher.png android/res/mipmap-mdpi/ic_launcher.png android/res/mipmap-xhdpi/ic_launcher.png android/res/mipmap-xxhdpi/ic_launcher.png android/res/mipmap-xxxhdpi/ic_launcher.png icons/16-apps-kasts.png icons/24-apps-kasts.png icons/32-apps-kasts.png icons/48-apps-kasts.png icons/64-apps-kasts.png icons/128-apps-kasts.png +Files: kasts.svg kasts-android-square.svg icons/kasts-tray-light.svg icons/kasts-tray-dark.svg logo.png android/ic_launcher-playstore.png android/res/drawable/kasts.png android/res/drawable-v24/ic_launcher_background.xml android/res/drawable-v24/ic_launcher_foreground.xml android/res/mipmap-hdpi/ic_launcher.png android/res/mipmap-mdpi/ic_launcher.png android/res/mipmap-xhdpi/ic_launcher.png android/res/mipmap-xxhdpi/ic_launcher.png android/res/mipmap-xxxhdpi/ic_launcher.png icons/16-apps-kasts.png icons/24-apps-kasts.png icons/32-apps-kasts.png icons/48-apps-kasts.png icons/64-apps-kasts.png icons/128-apps-kasts.png Copyright: 2021 Mathis BrĂ¼chert License: CC-BY-SA-4.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index fdaee405..93b3543b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,8 @@ ki18n_install(po) install(PROGRAMS org.kde.kasts.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install(FILES org.kde.kasts.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) install(FILES kasts.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps) -install(FILES icons/kasts-tray.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps) +install(FILES icons/kasts-tray-dark.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps) +install(FILES icons/kasts-tray-light.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps) install(FILES icons/media-playback-start-cloud.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/actions) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/android/version.gradle.in ${CMAKE_BINARY_DIR}/version.gradle) diff --git a/icons/kasts-tray.svg b/icons/kasts-tray-dark.svg similarity index 100% rename from icons/kasts-tray.svg rename to icons/kasts-tray-dark.svg diff --git a/icons/kasts-tray-light.svg b/icons/kasts-tray-light.svg new file mode 100644 index 00000000..7459c1bb --- /dev/null +++ b/icons/kasts-tray-light.svg @@ -0,0 +1,51 @@ + + + + + + + + diff --git a/src/qml/Settings/GeneralSettingsPage.qml b/src/qml/Settings/GeneralSettingsPage.qml index 4974639e..34f8893f 100644 --- a/src/qml/Settings/GeneralSettingsPage.qml +++ b/src/qml/Settings/GeneralSettingsPage.qml @@ -53,6 +53,7 @@ Kirigami.ScrollablePage { MobileForm.FormCheckDelegate { id: showTrayIcon + visible: SystrayIcon.available enabled: SystrayIcon.available text: i18n("Show icon in system tray") checked: SettingsManager.showTrayIcon @@ -64,6 +65,7 @@ Kirigami.ScrollablePage { MobileForm.FormCheckDelegate { id: minimizeToTray + visible: SystrayIcon.available enabled: SettingsManager.showTrayIcon && SystrayIcon.available text: i18n("Minimize to tray instead of closing") checked: SettingsManager.minimizeToTray @@ -72,6 +74,25 @@ Kirigami.ScrollablePage { SettingsManager.save(); } } + + MobileForm.FormComboBoxDelegate { + id: trayIconType + visible: SystrayIcon.available + enabled: SettingsManager.showTrayIcon && SystrayIcon.available + text: i18nc("Label for selecting the color of the tray icon", "Tray icon type") + + textRole: "text" + valueRole: "value" + + model: [{"text": i18nc("Label describing style of tray icon", "Colorful"), "value": 0}, + {"text": i18nc("Label describing style of tray icon", "Light"), "value": 1}, + {"text": i18nc("Label describing style of tray icon", "Dark"), "value": 2}] + Component.onCompleted: currentIndex = indexOfValue(SettingsManager.trayIconType) + onActivated: { + SettingsManager.trayIconType = currentValue; + SettingsManager.save(); + } + } } } diff --git a/src/resources.qrc b/src/resources.qrc index aa562e33..ad027567 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -46,7 +46,8 @@ qml/FilterInlineMessage.qml qtquickcontrols2.conf ../kasts.svg - ../icons/kasts-tray.svg + ../icons/kasts-tray-light.svg + ../icons/kasts-tray-dark.svg ../icons/media-playback-start-cloud.svg diff --git a/src/settingsmanager.kcfg b/src/settingsmanager.kcfg index a30f75a0..4bcac20c 100644 --- a/src/settingsmanager.kcfg +++ b/src/settingsmanager.kcfg @@ -9,6 +9,21 @@ false + + + + + + + + + + + + + + Dark + true diff --git a/src/systrayicon.cpp b/src/systrayicon.cpp index 4e5a045c..b1ef8dcf 100644 --- a/src/systrayicon.cpp +++ b/src/systrayicon.cpp @@ -20,8 +20,7 @@ SystrayIcon::SystrayIcon(QObject *parent) : QSystemTrayIcon(parent) { - // do not specify svg-extension; icon will not be visible due to [QTBUG-53550] - setIcon(QIcon(QStringLiteral(":/kasts-tray"))); + setIconColor(intToIconColorEnum(SettingsManager::self()->trayIconType())); QMenu *menu = new QMenu(); @@ -39,6 +38,10 @@ SystrayIcon::SystrayIcon(QObject *parent) } }); + connect(SettingsManager::self(), &SettingsManager::trayIconTypeChanged, this, [this]() { + setIconColor(intToIconColorEnum(SettingsManager::self()->trayIconType())); + }); + // Seek backward QAction *skipBackwardAction = new QAction(i18nc("@action:inmenu", "Seek Backward"), this); skipBackwardAction->setIcon(QIcon::fromTheme(QStringLiteral("media-seek-backward"))); @@ -137,3 +140,47 @@ bool SystrayIcon::available() const return false; #endif } + +void SystrayIcon::setIconColor(SystrayIcon::IconColor iconColor) +{ +#ifndef Q_OS_ANDROID + // do not specify svg-extension; icon will not be visible due to [QTBUG-53550] + switch (iconColor) { + case SystrayIcon::IconColor::Colorful: + setIcon(QIcon(QStringLiteral(":/logo"))); + break; + case SystrayIcon::IconColor::Light: + setIcon(QIcon(QStringLiteral(":/kasts-tray-light"))); + break; + case SystrayIcon::IconColor::Dark: + setIcon(QIcon(QStringLiteral(":/kasts-tray-dark"))); + break; + } +#endif +} + +int SystrayIcon::iconColorEnumToInt(SystrayIcon::IconColor iconColor) +{ + switch (iconColor) { + case SystrayIcon::IconColor::Light: + return 1; + case SystrayIcon::IconColor::Dark: + return 2; + case SystrayIcon::IconColor::Colorful: + default: + return 0; + } +} + +SystrayIcon::IconColor SystrayIcon::intToIconColorEnum(int iconColorCode) +{ + switch (iconColorCode) { + case 1: + return SystrayIcon::IconColor::Light; + case 2: + return SystrayIcon::IconColor::Dark; + case 0: + default: + return SystrayIcon::IconColor::Colorful; + } +} diff --git a/src/systrayicon.h b/src/systrayicon.h index e9895d92..30a1ff93 100644 --- a/src/systrayicon.h +++ b/src/systrayicon.h @@ -21,6 +21,13 @@ class SystrayIcon Q_OBJECT public: + enum IconColor { + Colorful, + Light, + Dark, + }; + Q_ENUM(IconColor) + Q_PROPERTY(bool available READ available CONSTANT) static SystrayIcon &instance() @@ -33,9 +40,13 @@ public: [[nodiscard]] bool available() const; + void setIconColor(IconColor iconColor); + Q_SIGNALS: void raiseWindow(); private: explicit SystrayIcon(QObject *parent = nullptr); + int iconColorEnumToInt(IconColor iconColor); + IconColor intToIconColorEnum(int iconColorCode); };