Volume OSD

This commit is contained in:
David Sansome 2010-01-08 16:40:34 +00:00
parent 62794cdf70
commit 8095e3ce1e
6 changed files with 13 additions and 3 deletions

View File

@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(player_, SIGNAL(Paused()), osd_, SLOT(Paused()));
connect(player_, SIGNAL(Stopped()), osd_, SLOT(Stopped()));
connect(player_, SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int)));
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song)));
connect(ui_.playlist, SIGNAL(doubleClicked(QModelIndex)), SLOT(PlayIndex(QModelIndex)));

View File

@ -11,9 +11,11 @@ OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent)
}
void OSD::SongChanged(const Song &song) {
QString summary(song.PrettyTitleWithArtist());
QStringList message_parts;
QString summary(song.PrettyTitle());
if (!song.artist().isNull())
summary = QString("%1 - %2").arg(song.artist(), summary);
QStringList message_parts;
if (!song.album().isEmpty())
message_parts << song.album();
if (song.disc() > 0)
@ -31,3 +33,7 @@ void OSD::Paused() {
void OSD::Stopped() {
ShowMessage(QCoreApplication::applicationName(), "Playlist finished");
}
void OSD::VolumeChanged(int value) {
ShowMessage(QCoreApplication::applicationName(), QString("Volume %1%").arg(value));
}

View File

@ -28,6 +28,7 @@ class OSD : public QObject {
void SongChanged(const Song& song);
void Paused();
void Stopped();
void VolumeChanged(int value);
private:
QSystemTrayIcon* tray_icon_;

View File

@ -103,6 +103,7 @@ void Player::EngineStateChanged(Engine::State state) {
void Player::SetVolume(int value) {
settings_.setValue("volume", value);
engine_->setVolume(value);
emit VolumeChanged(value);
}
int Player::GetVolume() const {

View File

@ -35,6 +35,7 @@ class Player : public QObject {
void Playing();
void Paused();
void Stopped();
void VolumeChanged(int volume);
void Error(const QString& message);
private slots:

View File

@ -250,7 +250,7 @@ QString Song::PrettyTitleWithArtist() const {
if (title.isEmpty())
title = QFileInfo(filename_).baseName();
if (!compilation_ && !artist_.isEmpty())
if (compilation_ && !artist_.isEmpty())
title = artist_ + " - " + title;
return title;