mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-07 23:38:48 +01:00
Remove use of HTML in system tray icon tooltip
This commit is contained in:
parent
318c3bb422
commit
a3e37fbfe2
@ -17,7 +17,6 @@
|
||||
<file>schema/device-schema.sql</file>
|
||||
<file>style/strawberry.css</file>
|
||||
<file>style/smartplaylistsearchterm.css</file>
|
||||
<file>html/playing-tooltip.html</file>
|
||||
<file>html/oauthsuccess.html</file>
|
||||
<file>pictures/strawberry.png</file>
|
||||
<file>pictures/strawberry-faded.png</file>
|
||||
|
@ -1,41 +0,0 @@
|
||||
<table cellspacing="5" cellpadding="5">
|
||||
<tr>
|
||||
<td colspan="%columns">
|
||||
<center><h4>%appName</h4></center>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
%image
|
||||
<td>
|
||||
<table cellspacing="1" cellpadding="1">
|
||||
<tr>
|
||||
<td>
|
||||
<p align="right">%titleKey</p>
|
||||
</td>
|
||||
<td>%titleValue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p align="right">%artistKey</p>
|
||||
</td>
|
||||
<td>%artistValue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p align="right">%albumKey</p>
|
||||
</td>
|
||||
<td>%albumValue</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" height="20" />
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p align="right">%lengthKey</p>
|
||||
</td>
|
||||
<td>%lengthValue</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -61,16 +61,6 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject *parent)
|
||||
tray_->installEventFilter(this);
|
||||
ClearNowPlaying();
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
de_ = Utilities::DesktopEnvironment().toLower();
|
||||
QFile pattern_file(":/html/playing-tooltip.html");
|
||||
if (pattern_file.open(QIODevice::ReadOnly)) {
|
||||
pattern_ = QString::fromLatin1(pattern_file.readAll());
|
||||
pattern_file.close();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
connect(tray_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(Clicked(QSystemTrayIcon::ActivationReason)));
|
||||
|
||||
}
|
||||
@ -231,50 +221,9 @@ void QtSystemTrayIcon::SetVisible(bool visible) {
|
||||
tray_->setVisible(visible);
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QUrl &cover_url) {
|
||||
void QtSystemTrayIcon::SetNowPlaying(const Song &song, const QUrl&) {
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
Q_UNUSED(song);
|
||||
Q_UNUSED(cover_url);
|
||||
// Windows doesn't support HTML in tooltips, so just show something basic
|
||||
tray_->setToolTip(song.PrettyTitleWithArtist());
|
||||
#else
|
||||
|
||||
if (de_ == "kde" || de_ == "cinnamon" || de_ == "x-cinnamon") {
|
||||
tray_->setToolTip(song.PrettyTitleWithArtist());
|
||||
return;
|
||||
}
|
||||
|
||||
int columns = cover_url.isEmpty() ? 1 : 2;
|
||||
|
||||
QString tooltip(pattern_);
|
||||
|
||||
tooltip.replace("%columns" , QString::number(columns));
|
||||
tooltip.replace("%appName" , app_name_);
|
||||
|
||||
tooltip.replace("%titleKey" , tr("Title") % ":");
|
||||
tooltip.replace("%titleValue" , song.PrettyTitle().toHtmlEscaped());
|
||||
tooltip.replace("%artistKey" , tr("Artist") % ":");
|
||||
tooltip.replace("%artistValue", song.artist().toHtmlEscaped());
|
||||
tooltip.replace("%albumKey" , tr("Album") % ":");
|
||||
tooltip.replace("%albumValue" , song.album().toHtmlEscaped());
|
||||
|
||||
tooltip.replace("%lengthKey" , tr("Length") % ":");
|
||||
tooltip.replace("%lengthValue", song.PrettyLength().toHtmlEscaped());
|
||||
|
||||
if (columns == 2) {
|
||||
QString final_path = cover_url.isLocalFile() ? cover_url.path() : cover_url.toString();
|
||||
tooltip.replace("%image", " <td> <img src=\"" % final_path % "\" /> </td>");
|
||||
}
|
||||
else {
|
||||
tooltip.replace("<td>%image</td>", "");
|
||||
tooltip.replace("%image", "");
|
||||
}
|
||||
|
||||
// TODO: we should also repaint this
|
||||
tray_->setToolTip(tooltip);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
|
||||
void ShowPopup(const QString &summary, const QString &message, int timeout) override;
|
||||
|
||||
void SetNowPlaying(const Song &song, const QUrl &cover_url) override;
|
||||
void SetNowPlaying(const Song &song, const QUrl&) override;
|
||||
void ClearNowPlaying() override;
|
||||
|
||||
bool MuteEnabled() const override { return action_mute_->isVisible(); }
|
||||
@ -88,11 +88,6 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
QAction *action_mute_;
|
||||
QAction *action_love_;
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QString de_;
|
||||
QString pattern_;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // QTSYSTEMTRAYICON_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user