Allow tray icon type to be set (dark, light, colorful)

This commit is contained in:
Bart De Vries 2023-02-27 13:12:03 +01:00
parent 7dcf3c52e2
commit 8f6de91577
9 changed files with 152 additions and 5 deletions

View File

@ -14,7 +14,7 @@ Files: android/res/drawable/splash.xml
Copyright: 2020 Tobias Fella <fella@posteo.de>
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 <mbblp@protonmail.ch>
License: CC-BY-SA-4.0

View File

@ -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)

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg90"
sodipodi:docname="kasts-tray-light.svg"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs94" />
<sodipodi:namedview
id="namedview92"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
showgrid="false"
inkscape:zoom="14.89381"
inkscape:cx="23.801834"
inkscape:cy="24.976819"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg90" />
<path
d="m 6.351,2.24718 -2.8985,8.6915 h 0.56017 l 1.1322,-3.3962 3.3962,3.3962 H 9.24749 L 9.22785,10.87925 9.00512,10.21056 Z m 0,1.6759 0.48524,1.4557 -1.2904,0.95963 z m 0.66198,1.9849 1.3782,4.1346 -2.96,-2.9595 z"
color="#000000"
style="font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-variant-east-asian:normal;font-feature-settings:normal;font-variation-settings:normal;text-indent:0;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;shape-margin:0;inline-size:0;display:inline;isolation:auto;mix-blend-mode:normal;image-rendering:auto;stroke:none;stroke-opacity:1;stroke-width:1.000125;stroke-dasharray:none;fill:#eff0f1;fill-opacity:1"
id="path72" />
<circle
cx="6.3499999"
cy="2.24898"
r="0.92603999"
id="circle74"
style="display:inline;stroke-width:1.000125;stroke-dasharray:none;fill:#eff0f1;fill-opacity:1" />
<path
d="M 1.21181,1.05833 A 5.27676,5.27676 0 0 0 1.07435,2.24586 V 2.24792 C 1.0745,4.19806 2.13641,5.9021 3.71243,6.8151 L 3.88297,6.30402 C 2.51554,5.47186 1.60364,3.96848 1.60352,2.24793 1.60418,1.86835 1.64976,1.48946 1.74046,1.12087 L 1.75596,1.05834 H 1.21181 Z m 9.73584,0 0.01499,0.05891 a 4.75166,4.75166 0 0 1 0.13694,1.13068 c -1.2e-4,1.72096 -0.9125,3.2246 -2.28048,4.0566 L 8.98963,6.8156 c 1.57658,-0.9128 2.63898,-2.61715 2.63912,-4.56768 -2e-4,-0.39998 -0.04625,-0.7999 -0.13643,-1.18959 z m -7.54992,0 C 3.24481,1.43576 3.16473,1.83767 3.16415,2.24586 v 0.00206 c 3e-5,1.02083 0.48343,1.93073 1.233,2.51406 L 4.57543,4.22662 C 4.03353,3.74085 3.69333,3.03523 3.69331,2.24792 3.69385,1.87519 3.77364,1.50605 3.92586,1.16582 L 3.97392,1.05833 h -0.5762 z m 5.333,0 0.04858,0.10749 c 0.15157,0.34037 0.22847,0.7095 0.2284,1.0821 C 9.0077,3.03511 8.66784,3.74034 8.12664,4.2261 L 8.30492,4.76198 C 9.05408,4.17866 9.53686,3.26888 9.53689,2.24792 A 3.18624,3.18624 0 0 0 9.30693,1.05833 Z"
color="#000000"
style="display:inline;-inkscape-stroke:none;fill:#eff0f1;fill-opacity:1"
id="path76" />
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -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();
}
}
}
}

View File

@ -46,7 +46,8 @@
<file alias="FilterInlineMessage.qml">qml/FilterInlineMessage.qml</file>
<file>qtquickcontrols2.conf</file>
<file alias="logo.svg">../kasts.svg</file>
<file alias="kasts-tray.svg">../icons/kasts-tray.svg</file>
<file alias="kasts-tray-light.svg">../icons/kasts-tray-light.svg</file>
<file alias="kasts-tray-dark.svg">../icons/kasts-tray-dark.svg</file>
<file alias="media-playback-start-cloud">../icons/media-playback-start-cloud.svg</file>
</qresource>
</RCC>

View File

@ -9,6 +9,21 @@
<label>Show icon in system tray</label>
<default>false</default>
</entry>
<entry name="trayIconType" type="Enum">
<label>Color/type of the tray icon</label>
<choices>
<choice name="Colorful">
<label>Colorful</label>
</choice>
<choice name="Light">
<label>Light</label>
</choice>
<choice name="Dark">
<label>Dark</label>
</choice>
</choices>
<default>Dark</default>
</entry>
<entry name="minimizeToTray" type="Bool">
<label>Minimize to system tray instead of closing application</label>
<default>true</default>

View File

@ -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;
}
}

View File

@ -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);
};