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.
This commit is contained in:
parent
7d28e8700b
commit
ebf9ebf080
@ -282,7 +282,6 @@
|
||||
<file>mainwindow.css</file>
|
||||
<file>nocover.png</file>
|
||||
<file>nomusic.png</file>
|
||||
<file>now_playing_tooltip.txt</file>
|
||||
<file>nyancat.png</file>
|
||||
<file>oauthsuccess.html</file>
|
||||
<file>osd_background.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>
|
@ -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",
|
||||
" <td>"
|
||||
" <img src=\"" %
|
||||
final_path %
|
||||
"\" />"
|
||||
" </td>");
|
||||
} else {
|
||||
clone.replace("%image", "");
|
||||
}
|
||||
|
||||
// TODO: we should also repaint this
|
||||
tray_->setToolTip(clone);
|
||||
}
|
||||
|
||||
void QtSystemTrayIcon::ClearNowPlaying() {
|
||||
|
@ -66,8 +66,6 @@ class QtSystemTrayIcon : public SystemTrayIcon {
|
||||
QAction* action_mute_;
|
||||
QAction* action_love_;
|
||||
|
||||
QString pattern_;
|
||||
|
||||
QPixmap orange_icon_;
|
||||
QPixmap grey_icon_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user