Add more trayicon mouse wheel actions.

Update issue 1597
Status: Fixed
Thanks for the patch!
This commit is contained in:
John Maguire 2011-03-21 15:15:17 +00:00
parent fa20af4516
commit eceb4164c1
5 changed files with 33 additions and 3 deletions

View File

@ -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) {

View File

@ -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());

View File

@ -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);

View File

@ -77,7 +77,21 @@ bool QtSystemTrayIcon::eventFilter(QObject* object, QEvent* event) {
if (event->type() == QEvent::Wheel) {
QWheelEvent* e = static_cast<QWheelEvent*>(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;
}

View File

@ -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();