diff --git a/src/translations/ar.po b/src/translations/ar.po index 0f2cf3a83..e830cf4c7 100644 --- a/src/translations/ar.po +++ b/src/translations/ar.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: ar\n" "X-Launchpad-Export-Date: 2010-05-22 04:09+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/bg.po b/src/translations/bg.po index 9956232b7..1b38116e4 100644 --- a/src/translations/bg.po +++ b/src/translations/bg.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: bg\n" "X-Launchpad-Export-Date: 2010-07-25 04:25+0000\n" "X-Generator: Launchpad (build Unknown)\n" "Language: bg\n" diff --git a/src/translations/da.po b/src/translations/da.po index 156fd2546..42f1df6ad 100644 --- a/src/translations/da.po +++ b/src/translations/da.po @@ -15,6 +15,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: da\n" "X-Launchpad-Export-Date: 2010-07-25 04:25+0000\n" "X-Generator: Launchpad (build Unknown)\n" "Language: da\n" diff --git a/src/translations/en_CA.po b/src/translations/en_CA.po index e3d7c1f80..f5c6c0d3a 100644 --- a/src/translations/en_CA.po +++ b/src/translations/en_CA.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: \n" "X-Launchpad-Export-Date: 2010-06-18 03:42+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/en_GB.po b/src/translations/en_GB.po index e40d9e95c..3c0ac734d 100644 --- a/src/translations/en_GB.po +++ b/src/translations/en_GB.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: \n" "X-Launchpad-Export-Date: 2010-06-18 03:42+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/gl.po b/src/translations/gl.po index eaf47732f..0b48f5285 100644 --- a/src/translations/gl.po +++ b/src/translations/gl.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: gl\n" "X-Launchpad-Export-Date: 2010-04-28 03:53+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/kk.po b/src/translations/kk.po index 5ab6bab99..efd1054cb 100644 --- a/src/translations/kk.po +++ b/src/translations/kk.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: kk\n" "X-Launchpad-Export-Date: 2010-04-28 03:53+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/lt.po b/src/translations/lt.po index 21c82a42c..8141c666a 100644 --- a/src/translations/lt.po +++ b/src/translations/lt.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: lt\n" "X-Launchpad-Export-Date: 2010-07-25 04:26+0000\n" "X-Generator: Launchpad (build Unknown)\n" "Language: lt\n" diff --git a/src/translations/oc.po b/src/translations/oc.po index 645036ea6..3ebbf5d63 100644 --- a/src/translations/oc.po +++ b/src/translations/oc.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: \n" "X-Launchpad-Export-Date: 2010-05-22 04:09+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/ro.po b/src/translations/ro.po index 57645a9fe..380acd441 100644 --- a/src/translations/ro.po +++ b/src/translations/ro.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: ro\n" "X-Launchpad-Export-Date: 2010-05-04 03:52+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/translations/sr.po b/src/translations/sr.po index a706e0583..04363bca5 100644 --- a/src/translations/sr.po +++ b/src/translations/sr.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: sr\n" "X-Launchpad-Export-Date: 2010-07-25 04:26+0000\n" "X-Generator: Launchpad (build Unknown)\n" "Language: sr\n" diff --git a/src/translations/translations.pot b/src/translations/translations.pot index 357110187..b1c8eff35 100644 --- a/src/translations/translations.pot +++ b/src/translations/translations.pot @@ -1198,6 +1198,9 @@ msgstr "" msgid "Notifications" msgstr "" +msgid "Now Playing" +msgstr "" + msgid "OSD Preview" msgstr "" diff --git a/src/translations/zh_CN.po b/src/translations/zh_CN.po index b1e4dfda4..487cea468 100644 --- a/src/translations/zh_CN.po +++ b/src/translations/zh_CN.po @@ -14,6 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: \n" "X-Launchpad-Export-Date: 2010-06-08 03:51+0000\n" "X-Generator: Launchpad (build Unknown)\n" diff --git a/src/ui/macsystemtrayicon.h b/src/ui/macsystemtrayicon.h index 85eb48fd6..9688c59d4 100644 --- a/src/ui/macsystemtrayicon.h +++ b/src/ui/macsystemtrayicon.h @@ -35,6 +35,9 @@ public: QAction* stop_after, QAction* next, QAction* love, QAction* ban, QAction* quit); + void SetNowPlaying(const Song& song); + void ClearNowPlaying(); + private: void SetupMenuItem(QAction* action); diff --git a/src/ui/macsystemtrayicon.mm b/src/ui/macsystemtrayicon.mm index 9e88ad454..53eeab962 100644 --- a/src/ui/macsystemtrayicon.mm +++ b/src/ui/macsystemtrayicon.mm @@ -16,6 +16,8 @@ #include "macsystemtrayicon.h" +#include "core/song.h" + #include #include #include @@ -57,9 +59,32 @@ class MacSystemTrayIconPrivate : boost::noncopyable { MacSystemTrayIconPrivate() { dock_menu_ = [[NSMenu alloc] initWithTitle:@"DockMenu"]; + QString title = QT_TR_NOOP("Now Playing"); + NSString* t = [[NSString alloc] initWithUTF8String:title.toUtf8().constData()]; + now_playing_ = [[NSMenuItem alloc] + initWithTitle:t + action:NULL + keyEquivalent:@""]; + + now_playing_artist_ = [[NSMenuItem alloc] + initWithTitle:@"Nothing to see here" + action:NULL + keyEquivalent:@""]; + + now_playing_title_ = [[NSMenuItem alloc] + initWithTitle:@"Nothing to see here" + action:NULL + keyEquivalent:@""]; + + [dock_menu_ insertItem:now_playing_title_ atIndex:0]; + [dock_menu_ insertItem:now_playing_artist_ atIndex:0]; + [dock_menu_ insertItem:now_playing_ atIndex:0]; + // Don't look now. // This must be called after our custom NSApplicationDelegate has been set. [[NSApp delegate] setDockMenu:dock_menu_]; + + ClearNowPlaying(); } void AddMenuItem(QAction* action) { @@ -89,10 +114,43 @@ class MacSystemTrayIconPrivate : boost::noncopyable { [dock_menu_ addItem:separator]; } + void ShowNowPlaying(const QString& artist, const QString& title) { + ClearNowPlaying(); // Makes sure the order is consistent. + [now_playing_artist_ setTitle: + [[NSString alloc] initWithUTF8String: artist.toUtf8().constData()]]; + [now_playing_title_ setTitle: + [[NSString alloc] initWithUTF8String: title.toUtf8().constData()]]; + title.isEmpty() ? HideItem(now_playing_title_) : ShowItem(now_playing_title_); + artist.isEmpty() ? HideItem(now_playing_artist_) : ShowItem(now_playing_artist_); + artist.isEmpty() && title.isEmpty() ? HideItem(now_playing_) : ShowItem(now_playing_); + } + + void ClearNowPlaying() { + // Hiding doesn't seem to work in the dock menu. + HideItem(now_playing_); + HideItem(now_playing_artist_); + HideItem(now_playing_title_); + } + private: + void HideItem(NSMenuItem* item) { + if ([dock_menu_ indexOfItem:item] != -1) { + [dock_menu_ removeItem:item]; + } + } + + void ShowItem(NSMenuItem* item, int index = 0) { + if ([dock_menu_ indexOfItem:item] == -1) { + [dock_menu_ insertItem:item atIndex:index]; + } + } + QMap actions_; NSMenu* dock_menu_; + NSMenuItem* now_playing_; + NSMenuItem* now_playing_artist_; + NSMenuItem* now_playing_title_; }; MacSystemTrayIcon::MacSystemTrayIcon(QObject* parent) @@ -135,3 +193,11 @@ void MacSystemTrayIcon::ActionChanged() { QAction* action = qobject_cast(sender()); p_->ActionChanged(action); } + +void MacSystemTrayIcon::ClearNowPlaying() { + p_->ClearNowPlaying(); +} + +void MacSystemTrayIcon::SetNowPlaying(const Song& song) { + p_->ShowNowPlaying(song.artist(), song.PrettyTitle()); +} diff --git a/src/ui/systemtrayicon.h b/src/ui/systemtrayicon.h index e15e277b6..211caed98 100644 --- a/src/ui/systemtrayicon.h +++ b/src/ui/systemtrayicon.h @@ -21,6 +21,7 @@ #include class QAction; +class Song; class SystemTrayIcon : public QObject { Q_OBJECT @@ -39,6 +40,8 @@ class SystemTrayIcon : public QObject { // Called by the OSD virtual void ShowPopup(const QString& summary, const QString& message, int timeout) {} + virtual void SetNowPlaying(const Song& song) {} + virtual void ClearNowPlaying() {} static SystemTrayIcon* CreateSystemTrayIcon(QObject* parent = 0); diff --git a/src/widgets/osd.cpp b/src/widgets/osd.cpp index 46cc1f5b0..53c3b0ab3 100644 --- a/src/widgets/osd.cpp +++ b/src/widgets/osd.cpp @@ -79,6 +79,7 @@ void OSD::ReloadSettings() { } void OSD::SongChanged(const Song &song) { + tray_icon_->SetNowPlaying(song); QString summary(song.PrettyTitle()); if (!song.artist().isEmpty()) summary = QString("%1 - %2").arg(song.artist(), summary); @@ -120,6 +121,7 @@ void OSD::Paused() { } void OSD::Stopped() { + tray_icon_->ClearNowPlaying(); if (ignore_next_stopped_) { ignore_next_stopped_ = false; return;