MW

Patching Kirocker Music Display for volume control via mouse scrolling

Kirocker is such a great application, it’s a pity the developer Sébastien Laoût has given up on it and is using Windows now!

Usually I only use the kicker applet, the full screen window is nice for parties though. But I didn’t like the way the applet handles scroll events: It seeks (if possible). Since I rarely seek when listening to music I’d rather have the behaviour of the Amarok tray icon: volume control!

I had a look inside the sources and found this part in src/coverdisplay.cpp:

    void CoverDisplay::wheelEvent(QWheelEvent *event)
    {
        if (areControlsShown()) {
          if (event->orientation() == Qt::Vertical) {
             PlayerInformation *infos = PlayerInformation::instance();
              if (infos->canSeek()) {
                 int deltaSeconds = 10 * (event->delta() > 0 ? 1 : -1);
                   m_infos->seekRelative(deltaSeconds);
                }
          } else {
               if (event->delta() > 0)
                  AmarokApi::volumeUp();
             else
                   AmarokApi::volumeDown();
           }
      }
    }

As you can see it already supports volume control via scrolling! The thing is I’ve disable four-way scrolling for my MX1000. Thus I’ve simply swapped the if statements and now I’m really happy with Kirocker. Here’s the updated snippet:

    void CoverDisplay::wheelEvent(QWheelEvent *event)
    {
        if (areControlsShown()) {
            if (event->orientation() == Qt::Vertical) {
                if (event->delta() > 0)
                    AmarokApi::volumeUp();
                else
                    AmarokApi::volumeDown();
            } else {
                PlayerInformation *infos = PlayerInformation::instance();
                if (infos->canSeek()) {
                    int deltaSeconds = 10 * (event->delta() > 0 ? 1 : -1);
                    m_infos->seekRelative(deltaSeconds);
                }
            }
        }
    }

Replace the old code, compile Kirocker, install it. Then restart kicker (killall kicker; sleep 1; kicker;) and Kirocker should accept scroll events in the way the Amarok tray icon does!

Comments

Want to comment? Send me an email!

Published on March 28, 2008.