From ebf9ebf0802b6dff227bd9c229eb84944cb14118 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Wed, 8 Jul 2020 17:28:26 +0200 Subject: [PATCH] Show only a basic tooltip in the system tray For environments that implements the D-Bus http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/StatusNotifierItem specification HTML is not supported in the tool tip title. (It is supported in the tool tip subtitle but this field is not set by QSystemTrayIcon.) See the discussion in #6733 for more info. --- data/data.qrc | 1 - data/now_playing_tooltip.txt | 41 ------------------------------------ src/ui/qtsystemtrayicon.cpp | 40 ----------------------------------- src/ui/qtsystemtrayicon.h | 2 -- 4 files changed, 84 deletions(-) delete mode 100644 data/now_playing_tooltip.txt diff --git a/data/data.qrc b/data/data.qrc index 1e9a19e08..8d1da3038 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -282,7 +282,6 @@ mainwindow.css nocover.png nomusic.png - now_playing_tooltip.txt nyancat.png oauthsuccess.html osd_background.png diff --git a/data/now_playing_tooltip.txt b/data/now_playing_tooltip.txt deleted file mode 100644 index 5a3de69fa..000000000 --- a/data/now_playing_tooltip.txt +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - %image - - -
-

%appName

-
- - - - - - - - - - - - - - - - - - - -
-

%titleKey

-
%titleValue
-

%artistKey

-
%artistValue
-

%albumKey

-
%albumValue
-
-

%lengthKey

-
%lengthValue
-
diff --git a/src/ui/qtsystemtrayicon.cpp b/src/ui/qtsystemtrayicon.cpp index 2fb1e5728..abe6b0035 100644 --- a/src/ui/qtsystemtrayicon.cpp +++ b/src/ui/qtsystemtrayicon.cpp @@ -56,10 +56,6 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject* parent) tray_->installEventFilter(this); ClearNowPlaying(); - QFile pattern_file(":/now_playing_tooltip.txt"); - pattern_file.open(QIODevice::ReadOnly); - pattern_ = QString::fromLatin1(pattern_file.readAll()); - connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason))); } @@ -231,44 +227,8 @@ void QtSystemTrayIcon::SetVisible(bool visible) { tray_->setVisible(visible); } void QtSystemTrayIcon::SetNowPlaying(const Song& song, const QString& image_path) { -#ifdef Q_OS_WIN - // Windows doesn't support HTML in tooltips, so just show something basic tray_->setToolTip(song.PrettyTitleWithArtist()); return; -#endif - - int columns = image_path == nullptr ? 1 : 2; - - QString clone = pattern_; - - clone.replace("%columns", QString::number(columns)); - clone.replace("%appName", QCoreApplication::applicationName()); - - clone.replace("%titleKey", tr("Title") % ":"); - clone.replace("%titleValue", song.PrettyTitle().toHtmlEscaped()); - clone.replace("%artistKey", tr("Artist") % ":"); - clone.replace("%artistValue", song.artist().toHtmlEscaped()); - clone.replace("%albumKey", tr("Album") % ":"); - clone.replace("%albumValue", song.album().toHtmlEscaped()); - - clone.replace("%lengthKey", tr("Length") % ":"); - clone.replace("%lengthValue", song.PrettyLength().toHtmlEscaped()); - - if (columns == 2) { - QString final_path = - image_path.startsWith("file://") ? image_path.mid(7) : image_path; - clone.replace("%image", - " " - " " - " "); - } else { - clone.replace("%image", ""); - } - - // TODO: we should also repaint this - tray_->setToolTip(clone); } void QtSystemTrayIcon::ClearNowPlaying() { diff --git a/src/ui/qtsystemtrayicon.h b/src/ui/qtsystemtrayicon.h index 903e3d6b6..05330665e 100644 --- a/src/ui/qtsystemtrayicon.h +++ b/src/ui/qtsystemtrayicon.h @@ -66,8 +66,6 @@ class QtSystemTrayIcon : public SystemTrayIcon { QAction* action_mute_; QAction* action_love_; - QString pattern_; - QPixmap orange_icon_; QPixmap grey_icon_; };