diff --git a/src/core/player.cpp b/src/core/player.cpp index 8f60ea259..58daadb07 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -301,11 +301,11 @@ void Player::SeekTo(int seconds) { } void Player::SeekForward() { - SeekTo(engine()->position_nanosec() / kNsecPerSec + 5); + SeekTo(engine()->position_nanosec() / kNsecPerSec + 10); } void Player::SeekBackward() { - SeekTo(engine()->position_nanosec() / kNsecPerSec - 5); + SeekTo(engine()->position_nanosec() / kNsecPerSec - 10); } void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) { diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index e4218d32c..ae923ffcf 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -387,6 +387,7 @@ MainWindow::MainWindow( connect(player_, SIGNAL(Paused()), SLOT(MediaPaused())); connect(player_, SIGNAL(Playing()), SLOT(MediaPlaying())); connect(player_, SIGNAL(Stopped()), SLOT(MediaStopped())); + connect(player_, SIGNAL(Seeked(qlonglong)), SLOT(Seeked(qlonglong))); connect(player_, SIGNAL(TrackSkipped(PlaylistItemPtr)), SLOT(TrackSkipped(PlaylistItemPtr))); connect(player_, SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged(int))); @@ -541,6 +542,10 @@ MainWindow::MainWindow( ui_->action_ban, ui_->action_quit); connect(tray_icon_, SIGNAL(PlayPause()), player_, SLOT(PlayPause())); + connect(tray_icon_, SIGNAL(SeekForward()), player_, SLOT(SeekForward())); + connect(tray_icon_, SIGNAL(SeekBackward()), player_, SLOT(SeekBackward())); + connect(tray_icon_, SIGNAL(NextTrack()), player_, SLOT(Next())); + connect(tray_icon_, SIGNAL(PreviousTrack()), player_, SLOT(Previous())); connect(tray_icon_, SIGNAL(ShowHide()), SLOT(ToggleShowHide())); connect(tray_icon_, SIGNAL(ChangeVolume(int)), SLOT(VolumeWheelEvent(int))); @@ -967,6 +972,12 @@ void MainWindow::FilePathChanged(const QString& path) { settings_.setValue("file_path", path); } +void MainWindow::Seeked(qlonglong microseconds) { + const int position = microseconds / kUsecPerSec; + const int length = player_->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec; + tray_icon_->SetProgress(double(position) / length * 100); +} + void MainWindow::UpdateTrackPosition() { // Track position in seconds PlaylistItemPtr item(player_->GetCurrentItem()); diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h index 1fbef5745..98b1a17c1 100644 --- a/src/ui/mainwindow.h +++ b/src/ui/mainwindow.h @@ -188,6 +188,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { void VolumeWheelEvent(int delta); void ToggleShowHide(); + void Seeked(qlonglong microseconds); void UpdateTrackPosition(); void LastFMButtonVisibilityChanged(bool value); diff --git a/src/ui/qtsystemtrayicon.cpp b/src/ui/qtsystemtrayicon.cpp index 0483f91c4..1585d2258 100644 --- a/src/ui/qtsystemtrayicon.cpp +++ b/src/ui/qtsystemtrayicon.cpp @@ -77,7 +77,21 @@ bool QtSystemTrayIcon::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::Wheel) { QWheelEvent* e = static_cast(event); - emit ChangeVolume(e->delta()); + if (e->modifiers() == Qt::ShiftModifier) { + if (e->delta() > 0) { + emit SeekForward(); + } else { + emit SeekBackward(); + } + } else if (e->modifiers() == Qt::ControlModifier) { + if (e->delta() < 0) { + emit NextTrack(); + } else { + emit PreviousTrack(); + } + } else { + emit ChangeVolume(e->delta()); + } return true; } diff --git a/src/ui/systemtrayicon.h b/src/ui/systemtrayicon.h index 0f9feff4c..db66ca854 100644 --- a/src/ui/systemtrayicon.h +++ b/src/ui/systemtrayicon.h @@ -59,6 +59,10 @@ class SystemTrayIcon : public QObject { signals: void ChangeVolume(int delta); + void SeekForward(); + void SeekBackward(); + void NextTrack(); + void PreviousTrack(); void ShowHide(); void PlayPause();