Commit e2012e79 authored by Michael Pyne's avatar Michael Pyne
Browse files

systray: Make SHIFT+Mousewheel change the volume, not the song.

This fixes a bug that recently hit its 8 year anniversary. :(

The big issue was that there was no easy way to tell which keyboard
modifiers were set for the systray since Qt's event loop didn't actually
receive the keyboard events.

There's a separate function you can call, queryKeyboardModifiers, which
makes a specific query to the desktop, and works even if Qt event loop
didn't receive keyboard events. This fixes the bug here, and hopefully
for everyone else.

In fixing the bug I noticed that we can set out-of-bounds volumes due to
lack of checking, so I fixed that too.

parent 441cb735
......@@ -32,6 +32,7 @@
#include <QUrl>
#include <math.h>
#include <algorithm>
#include "playlistinterface.h"
#include "playeradaptor.h"
......@@ -353,7 +354,8 @@ void PlayerManager::volumeUp()
setVolume(volume() + 0.04); // 4% up
const auto newVolume = std::min(m_output->volume() + 0.04, 1.0);
m_output->setVolume(newVolume); // 4% up
void PlayerManager::volumeDown()
......@@ -361,7 +363,8 @@ void PlayerManager::volumeDown()
setVolume(volume() - 0.04); // 4% down
const auto newVolume = std::max(m_output->volume() - 0.04, 0.0);
m_output->setVolume(newVolume); // 4% down
void PlayerManager::setMuted(bool m)
......@@ -509,7 +509,7 @@ void SystemTray::scrollEvent(int delta, Qt::Orientation orientation)
if(orientation == Qt::Horizontal)
switch(QApplication::keyboardModifiers()) {
switch(QApplication::queryKeyboardModifiers()) {
case Qt::ShiftModifier:
if(delta > 0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment