[mythtv] New feature: Using the mouse-wheel to navigate the menus

Mario Smit mario.smit at tiscali.nl
Tue Nov 28 15:46:40 UTC 2006


Hi all,

I am using a Logitech Media Desktop with Remote. This remote is actually
sending its information as keystrokes and mouse events. It has a nice
roller that behaves like a mouse-wheel. 

So I tried getting this roller to work in MythTV. It was actually pretty
simple. It involves a small change in libs/libmythui/mythmainwindow.cpp,
shown below.

Now you can use a mouse-wheel to navigate the menus or in my case use
the Logitech remote. It would be nice to include this in the next
release because it adds functionality for all users.

Best regards,

Mario

-------------------------------------------------------------------

bool MythMainWindow::eventFilter(QObject *, QEvent *e)
{
    MythGestureEvent *ge;

    /* dont let anything through if input is disallowed. */
    if (!d->AllowInput)
        return true;

    switch (e->type())
    {
	....
	.... INSERTED CODE STARTS HERE
	....
	case QEvent::Wheel:
	{
	    QWheelEvent* qmw = dynamic_cast<QWheelEvent*>(e);
	    int delta = qmw->delta();
	    if (delta>0)
	    {
		qmw->accept();
	       	// UP
		QKeyEvent *key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, 0,
Qt::NoButton);
                QObject *key_target = getTarget(*key);
            	if (!key_target)
                    QApplication::postEvent(this, key);
            	else
                    QApplication::postEvent(key_target, key);
	    }
	    if (delta<0)
	    {
		qmw->accept();
	       	// DOWN
		QKeyEvent *key = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, 0,
Qt::NoButton);
                QObject *key_target = getTarget(*key);
                if (!key_target)
                    QApplication::postEvent(this, key);
            	else
                    QApplication::postEvent(key_target, key);
	    }
	    break;	    
	}
	....
	.... INSERTED CODE ENDS HERE
	....
    }
    return false;
}



More information about the mythtv-dev mailing list