Commit 52fc08fa authored by Michael Pyne's avatar Michael Pyne

Add cover information to the JuK tooltip. If the playing track has no cover...

Add cover information to the JuK tooltip.  If the playing track has no cover the JuK icon is used instead.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=433497
parent 745fe33a
......@@ -212,8 +212,10 @@ void SystemTray::slotPlay()
if(!PlayerManager::instance()->playing())
return;
QPixmap cover = PlayerManager::instance()->playingFile().coverInfo()->pixmap(CoverInfo::Thumbnail);
setPixmap(m_playPix);
setToolTip(PlayerManager::instance()->playingString());
setToolTip(PlayerManager::instance()->playingString(), cover);
createPopup();
}
......@@ -509,14 +511,31 @@ QColor SystemTray::interpolateColor(int step, int steps)
);
}
void SystemTray::setToolTip(const QString &tip)
void SystemTray::setToolTip(const QString &tip, const QPixmap &cover)
{
QToolTip::remove(this);
if(tip.isNull())
QToolTip::add(this, "JuK");
else
QToolTip::add(this, tip);
QToolTip::add(this, i18n("JuK"));
else {
QPixmap myCover = cover;
if(cover.isNull())
myCover = DesktopIcon("juk");
QImage coverImage = myCover.convertToImage();
if(coverImage.size().width() > 32 || coverImage.size().height() > 32)
coverImage = coverImage.smoothScale(32, 32);
QMimeSourceFactory::defaultFactory()->setImage("tipCover", coverImage);
QString html = i18n("%1 is Cover Art, %2 is the playing track, %3 is the appname",
"<center><table cellspacing=\"2\"><tr><td valign=\"middle\">%1</td>"
"<td valign=\"middle\">%2</td></tr></table><em>%3</em></center>");
html = html.arg("<img valign=\"middle\" src=\"tipCover\"");
html = html.arg(QString("<nobr>%1</nobr>").arg(tip), i18n("JuK"));
QToolTip::add(this, html);
}
}
void SystemTray::wheelEvent(QWheelEvent *e)
......
......@@ -78,7 +78,7 @@ private:
virtual void wheelEvent(QWheelEvent *e);
void createPopup();
void setToolTip(const QString &tip = QString::null);
void setToolTip(const QString &tip = QString::null, const QPixmap &cover = QPixmap());
void mousePressEvent(QMouseEvent *e);
QPixmap createPixmap(const QString &pixName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment