[mythtv] keypressEvent improvement: Add actionEvent in mythuitype class

Xavier Hervy xavier.hervy at bluebottle.com
Sun Nov 23 11:43:05 UTC 2008


Hi,

I would like to modify keypressEvent in mythui to make use of a new 
public  method "actionEvent" in mythuitype as below :
    virtual bool keyPressEvent(QKeyEvent *);

Here is a example of implementation with  mythuibutton:

bool MythUIButton::actionEvent(QString action)
{
    if (action == "SELECT")
    {
        if (!IsEnabled())
            return false;

        if (m_Pushed)
            UnPush();
        else
            Push();
    }
    else
        handled = false;
}

bool MythUIButton::keyPressEvent(QKeyEvent *e)
{
    QStringList actions;
    bool handled = false;
    GetMythMainWindow()->TranslateKeyPress("Global", e, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        handled = actionEvent(action);
    }

    return handled;
}

This would allow the network protocol to use action instead of key to 
send command to the frontend, preventing to break any client using the 
network control protocol when the default key binding is modified by the 
user.
The telnet interface could easily implement :
action SELECT to send an action to the frontend.

This is a minor change but on a lot of file which is why I like to have 
a feedback before doing any patch (especially from stuart).

Regqrds,
Xavier


More information about the mythtv-dev mailing list