1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2025-01-31 01:29:41 +01:00

Dont use HTML in tooltip on KDE

Fixes #466
This commit is contained in:
Jonas Kvinge 2020-06-20 17:30:37 +02:00
parent 24e8ca67c5
commit bb611bf655
3 changed files with 52 additions and 17 deletions

View File

@ -15,8 +15,7 @@
<file>schema/schema-12.sql</file>
<file>schema/device-schema.sql</file>
<file>style/strawberry.css</file>
<file>html/playing-tooltip-plain.html</file>
<file>html/playing-tooltip-table.html</file>
<file>html/playing-tooltip.html</file>
<file>html/oauthsuccess.html</file>
<file>pictures/strawberry.png</file>
<file>pictures/strawberry-faded.png</file>

View File

@ -0,0 +1,41 @@
<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>

View File

@ -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", "<img src=\"" % final_path % "\" />");
}
else {
tooltip.replace("%image", " <td> <img src=\"" % final_path % "\" /> </td>");
}
tooltip.replace("%image", " <td> <img src=\"" % final_path % "\" /> </td>");
}
else {
tooltip.replace("<td>%image</td>", "");