MainWindow: Add function to display progress on taskbar
This commit is contained in:
parent
5bd8f35dc0
commit
dd6b9bb38d
@ -73,6 +73,10 @@
|
||||
#include <QToolButton>
|
||||
#include <QCheckBox>
|
||||
#include <QClipboard>
|
||||
#ifdef HAVE_DBUS
|
||||
# include <QDBusConnection>
|
||||
# include <QDBusMessage>
|
||||
#endif
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
@ -1269,6 +1273,11 @@ void MainWindow::Exit() {
|
||||
return; // Don't quit the application now: wait for the fadeout finished signal
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
DoExit();
|
||||
}
|
||||
|
||||
@ -1321,6 +1330,10 @@ void MainWindow::MediaStopped() {
|
||||
tray_icon_->SetProgress(0);
|
||||
tray_icon_->SetStopped();
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
song_playing_ = Song();
|
||||
song_ = Song();
|
||||
album_cover_ = AlbumCoverImageResult();
|
||||
@ -1397,6 +1410,10 @@ void MainWindow::SongChanged(const Song &song) {
|
||||
setWindowTitle(song.PrettyTitleWithArtist());
|
||||
tray_icon_->SetProgress(0);
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
SendNowPlaying();
|
||||
|
||||
const bool enable_change_art = song.is_collection_song() && !song.effective_albumartist().isEmpty() && !song.album().isEmpty();
|
||||
@ -1686,6 +1703,10 @@ void MainWindow::Seeked(const qint64 microseconds) {
|
||||
const qint64 length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec;
|
||||
tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / static_cast<double>(length) * 100.0));
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(true, position, length);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::UpdateTrackPosition() {
|
||||
@ -1700,6 +1721,10 @@ void MainWindow::UpdateTrackPosition() {
|
||||
// Update the tray icon every 10 seconds
|
||||
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / static_cast<double>(length) * 100.0));
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(true, position, length);
|
||||
#endif
|
||||
|
||||
// Send Scrobble
|
||||
if (app_->scrobbler()->enabled() && item->Metadata().is_metadata_good()) {
|
||||
Playlist *playlist = app_->playlist_manager()->active();
|
||||
@ -1726,6 +1751,21 @@ void MainWindow::UpdateTrackSliderPosition() {
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
void MainWindow::UpdateTaskbarProgress(const bool visible, const double position, const double length) {
|
||||
|
||||
QVariantMap map;
|
||||
QDBusMessage msg = QDBusMessage::createSignal(QStringLiteral("/org/strawberrymusicplayer/strawberry"), QStringLiteral("com.canonical.Unity.LauncherEntry"), QStringLiteral("Update"));
|
||||
|
||||
map.insert(QStringLiteral("progress-visible"), visible);
|
||||
map.insert(QStringLiteral("progress"), position / length);
|
||||
msg << QString("application://org.strawberrymusicplayer.strawberry.desktop") << map;
|
||||
|
||||
QDBusConnection::sessionBus().send(msg);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) {
|
||||
|
||||
switch (b) {
|
||||
|
@ -290,6 +290,10 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
void SetToggleScrobblingIcon(const bool value);
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
void UpdateTaskbarProgress(const bool visible, const double position, const double length);
|
||||
#endif
|
||||
|
||||
private:
|
||||
Ui_MainWindow *ui_;
|
||||
#ifdef Q_OS_WIN
|
||||
|
Loading…
x
Reference in New Issue
Block a user