From bb611bf655bb53f8f4624c35524def7bbdec4d9b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 20 Jun 2020 17:30:37 +0200 Subject: [PATCH] Dont use HTML in tooltip on KDE Fixes #466 --- data/data.qrc | 3 +-- data/html/playing-tooltip.html | 41 ++++++++++++++++++++++++++++++++++ src/core/qtsystemtrayicon.cpp | 25 +++++++++------------ 3 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 data/html/playing-tooltip.html diff --git a/data/data.qrc b/data/data.qrc index 1a09a1812..fafe99de3 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -15,8 +15,7 @@ schema/schema-12.sql schema/device-schema.sql style/strawberry.css - html/playing-tooltip-plain.html - html/playing-tooltip-table.html + html/playing-tooltip.html html/oauthsuccess.html pictures/strawberry.png pictures/strawberry-faded.png diff --git a/data/html/playing-tooltip.html b/data/html/playing-tooltip.html new file mode 100644 index 000000000..5a3de69fa --- /dev/null +++ b/data/html/playing-tooltip.html @@ -0,0 +1,41 @@ + + + + + + %image + + +
+

%appName

+
+ + + + + + + + + + + + + + + + + + + +
+

%titleKey

+
%titleValue
+

%artistKey

+
%artistValue
+

%albumKey

+
%albumValue
+
+

%lengthKey

+
%lengthValue
+
diff --git a/src/core/qtsystemtrayicon.cpp b/src/core/qtsystemtrayicon.cpp index eac8502af..0c3cefc6e 100644 --- a/src/core/qtsystemtrayicon.cpp +++ b/src/core/qtsystemtrayicon.cpp @@ -63,16 +63,11 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent) #ifndef Q_OS_WIN de_ = Utilities::DesktopEnvironment().toLower(); - QFile pattern_file; - if (de_ == "kde") { - pattern_file.setFileName(":/html/playing-tooltip-plain.html"); + QFile pattern_file(":/html/playing-tooltip.html"); + if (pattern_file.open(QIODevice::ReadOnly)) { + pattern_ = QString::fromLatin1(pattern_file.readAll()); + pattern_file.close(); } - else { - pattern_file.setFileName(":/html/playing-tooltip-table.html"); - } - pattern_file.open(QIODevice::ReadOnly); - pattern_ = QString::fromLatin1(pattern_file.readAll()); - pattern_file.close(); #endif @@ -245,6 +240,11 @@ void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QUrl &cover_url) { tray_->setToolTip(song.PrettyTitleWithArtist()); #else + if (de_ == "kde") { + tray_->setToolTip(song.PrettyTitleWithArtist()); + return; + } + int columns = cover_url.isEmpty() ? 1 : 2; QString tooltip(pattern_); @@ -264,12 +264,7 @@ void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QUrl &cover_url) { if (columns == 2) { QString final_path = cover_url.isLocalFile() ? cover_url.path() : cover_url.toString(); - if (de_ == "kde") { - tooltip.replace("%image", ""); - } - else { - tooltip.replace("%image", " "); - } + tooltip.replace("%image", " "); } else { tooltip.replace("%image", "");