Control the volume by spinning the mouse wheel over the system tray icon. --- a/src/systray.cpp +++ b/src/systray.cpp @@ -25,6 +25,7 @@ #include "container.h" #include "LastFmSettings.h" #include "MooseCommon.h" +#include TrayIcon::TrayIcon( QObject* parent ) @@ -157,3 +158,20 @@ { m_animationTimer.stop(); } + + +bool +TrayIcon::event( QEvent* e ) +{ + // Beginning with Qt 4.3, QSystemTrayIcon supports wheel events, but only + // on X11. Let's make it adjust the volume. + if ( e->type() == QEvent::Wheel ) + { + int numDegrees = ((QWheelEvent*)e)->delta() / 8; + int numSteps = numDegrees / 15; + int volume = Container::instance().ui.playcontrols.volume->value() + ( 5 * numSteps ); + Container::instance().ui.playcontrols.volume->setValue( volume ); + return true; + } + return QSystemTrayIcon::event( e ); +} --- a/src/systray.h +++ b/src/systray.h @@ -35,6 +35,7 @@ TrayIcon( QObject* parent ); void startIpodScrobblingAnimation(); void stopIpodScrobblingAnimation(); + virtual bool event( QEvent* e ); public slots: void setTrack( const class MetaData &track ); --- a/src/container.h +++ b/src/container.h @@ -39,6 +39,7 @@ Q_OBJECT static Container* s_instance; + friend class TrayIcon; public: Container();