Commit c45f60b6 authored by Scott Wheeler's avatar Scott Wheeler

Patch from Daniel to add tooltip support to the systray dock icon. Centralized

the formatting code in JuK::playingString()

svn path=/trunk/kdemultimedia/juk/; revision=207221
parent 8439bc18
......@@ -170,6 +170,8 @@ void JuK::setupSystemTray()
connect(systemTray, SIGNAL(pause()), this, SLOT(pause()));
connect(systemTray, SIGNAL(back()), this, SLOT(back()));
connect(systemTray, SIGNAL(forward()), this, SLOT(forward()));
connect(this, SIGNAL(newSongSignal(const QString&)), systemTray, SLOT(slotNewSong(const QString&)));
if(player && player->paused())
systemTray->slotPause();
......@@ -326,6 +328,18 @@ void JuK::invokeEditSlot( const char *slotName, const char *slot )
disconnect(this, SIGNAL(editSignal()), object, slot);
}
QString JuK::playingString() const
{
QString s;
if(splitter->playingArtist().isEmpty())
s = splitter->playingTrack().simplifyWhiteSpace();
else
s = splitter->playingArtist().simplifyWhiteSpace() + " - " + splitter->playingTrack().simplifyWhiteSpace();
return s;
}
////////////////////////////////////////////////////////////////////////////////
// private slot definitions
////////////////////////////////////////////////////////////////////////////////
......@@ -582,7 +596,9 @@ void JuK::play(const QString &file)
sliderAction->getTrackPositionSlider()->setEnabled(true);
playTimer->start(pollInterval);
statusLabel->setPlayingItemInfo(splitter->playingTrack(), splitter->playingArtist(), splitter->playingList());
statusLabel->setPlayingItemInfo(playingString(), splitter->playingList());
emit newSongSignal(playingString());
if(systemTray)
systemTray->slotPlay();
......
......@@ -48,6 +48,7 @@ public:
signals:
void editSignal();
void newSongSignal(const QString& songTitle);
private:
// private methods
......@@ -69,6 +70,7 @@ private:
virtual bool queryClose();
void invokeEditSlot(const char *slotName, const char *slot);
QString playingString() const;
private slots:
void playlistChanged();
......
......@@ -110,11 +110,11 @@ void StatusLabel::setPlaylistCount(int c)
trackLabel->setText(QString::number(c) + " " + i18n("Item(s)"));
}
void StatusLabel::setPlayingItemInfo(const QString &name, const QString &artist, const QString &playlist)
void StatusLabel::setPlayingItemInfo(const QString &track, const QString &playlist)
{
mode = PlayingItemInfo;
trackLabel->setText(artist.simplifyWhiteSpace() + " - " + name.simplifyWhiteSpace());
trackLabel->setText(track);
playlistLabel->setText(playlist.simplifyWhiteSpace());
}
......
......@@ -40,7 +40,7 @@ public slots:
*/
void setPlaylistInfo(const QString &name, int count);
void setPlaylistCount(int c);
void setPlayingItemInfo(const QString &name, const QString &artist, const QString &playlist);
void setPlayingItemInfo(const QString &track, const QString &playlist);
/**
* This clears the information about the playing items and frees that status
......
......@@ -20,6 +20,7 @@
#include <klocale.h>
#include <qtimer.h>
#include <qtooltip.h>
#include "systemtray.h"
......@@ -38,7 +39,7 @@ SystemTray::SystemTray(QWidget *parent, const char *name) : KSystemTray(parent,
setPixmap(appPix);
KPopupMenu *cm = contextMenu();
cm->insertTitle(i18n("Playing"));
//cm->insertTitle(i18n("Playing"));
cm->insertItem(playPix, i18n("Play"), this, SIGNAL(play()));
cm->insertItem(pausePix, i18n("Pause"), this, SIGNAL(pause()));
cm->insertItem(SmallIcon("player_stop"), i18n("Stop"), this, SIGNAL(stop()));
......@@ -57,6 +58,12 @@ SystemTray::~SystemTray()
// public slots
////////////////////////////////////////////////////////////////////////////////
void SystemTray::slotNewSong(const QString& songName)
{
QToolTip::remove(this);
QToolTip::add(this, songName);
}
void SystemTray::slotPlay()
{
currentPix = playPix;
......@@ -73,6 +80,7 @@ void SystemTray::slotStop()
{
blinkTimer->stop();
setPixmap(appPix);
QToolTip::remove(this);
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -32,6 +32,7 @@ public:
virtual ~SystemTray();
public slots:
void slotNewSong(const QString& songName);
void slotPlay();
void slotStop();
void slotPause();
......
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