Add function to display progress on taskbar
This commit is contained in:
parent
04ceec0739
commit
a41916c2cf
|
@ -73,8 +73,10 @@
|
|||
#include <QToolButton>
|
||||
#include <QCheckBox>
|
||||
#include <QClipboard>
|
||||
#ifdef HAVE_DBUS
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#endif
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
|
@ -1272,7 +1274,9 @@ void MainWindow::Exit() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
DoExit();
|
||||
}
|
||||
|
@ -1326,7 +1330,9 @@ void MainWindow::MediaStopped() {
|
|||
tray_icon_->SetProgress(0);
|
||||
tray_icon_->SetStopped();
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
song_playing_ = Song();
|
||||
song_ = Song();
|
||||
|
@ -1404,7 +1410,9 @@ void MainWindow::SongChanged(const Song &song) {
|
|||
setWindowTitle(song.PrettyTitleWithArtist());
|
||||
tray_icon_->SetProgress(0);
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
UpdateTaskbarProgress(false, 0, 0);
|
||||
#endif
|
||||
|
||||
SendNowPlaying();
|
||||
|
||||
|
@ -1695,7 +1703,9 @@ 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
|
||||
|
||||
}
|
||||
|
||||
|
@ -1711,7 +1721,9 @@ 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()) {
|
||||
|
@ -1739,12 +1751,11 @@ 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"));
|
||||
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);
|
||||
|
@ -1753,6 +1764,7 @@ void MainWindow::UpdateTaskbarProgress(const bool visible, const double position
|
|||
QDBusConnection::sessionBus().send(msg);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) {
|
||||
|
||||
|
|
|
@ -202,7 +202,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
|||
void Seeked(const qint64 microseconds);
|
||||
void UpdateTrackPosition();
|
||||
void UpdateTrackSliderPosition();
|
||||
#ifdef HAVE_DBUS
|
||||
void UpdateTaskbarProgress(const bool visible, const double position, const double length);
|
||||
#endif
|
||||
|
||||
void TaskCountChanged(const int count);
|
||||
|
||||
|
|
Loading…
Reference in New Issue