[mythtv] Key mapping for BOOKMARK

Michael T. Dean mtdean at thirdcontact.com
Sat Mar 17 04:59:07 UTC 2018


On 03/16/2018 10:08 AM, Peter Bennett wrote:
>
>
> On 03/15/2018 01:56 PM, Michael T. Dean wrote:
>> I'd prefer the approach that changes SELECT to no longer have 
>> anything to do with bookmarks and, instead, change SELECT to do 
>> something far more commonly-used--like, for example, bring up your 
>> navigation OSD (which, BTW, thank you for working on that--it is/was 
>> something on my TODO list***), since navigation is something that is 
>> very commonly done during playback.  You're welcome to do it the 
>> other way, but--if I ever get a chance to make time to work on MythTV 
>> code, again--I would likely eventually remove the SELECT stuff and 
>> the setting and just use the SET_/TOGGLE_BOOKMARK actions.
>>
>> Also, we have been working to remove all of the settings that are 
>> just key bindings in the wrong place--settings that change the way a 
>> key works--and making all approaches available through different key 
>> bindings to give more configurability (and discoverability) for 
>> users.  (At least more discoverable from the standpoint that a user 
>> should assume the answer to the question, "How do I modify how my 
>> keys work?" should be, "Through key bindings," and not, "Through 
>> settings."**)
>>
>> And I think since you're adding the bookmark functionality to the nav 
>> menu, it covers the "discoverable for new users, even if the default 
>> key list is empty" case.
>>
>> Thanks for all the work you're doing on MythTV--and for helping to 
>> pare down my TODO list by doing things I had hoped to one day do, 
>> like the nav OSD. :)
>>
>> Mike
> Hi Mike
>
> See  https://code.mythtv.org/trac/ticket/13234#comment:19 . I think 
> that does everything the way you are recommending. Let me know if you 
> see anything wrong there.

Looks good, but why not do the part that tests to see if they're 
currently using the SELECT keys for bookmarks as a one-time DB update 
instead of having to do it every startup?  It would be something like 
the attached (totally untested) patch.  The main benefit of this 
approach is that it doesn't clutter up tv_play.cpp with code we'll 
always wonder how long we need to keep and it takes care of all the 
hosts in the system at one time and is done forever.  Then, you can just 
use the new-host default keylists in the REG_KEY lines in tv_play.cpp 
for SETBOOKMARK and TOGGLEBOOKMARK (which would be the empty string, "").

Mike
-------------- next part --------------
    if (dbver == "1348")
    {
        LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1349");

        // Any already-existing host with a value for AltClearSavedPosition
        // is using the "legacy" SELECT for bookmark control, so map those keys
        // to TV Playback/SETBOOKMARK or TV Playback/TOGGLEBOOKMARK
        MSqlQuery toggle_query(MSqlQuery::InitCon());
        toggle_query.prepare("SELECT hostname, data FROM settings "
                             " WHERE value = 'AltClearSavedPosition'");

        if (!toggle_query.exec())
        {
            MythDB::DBError("Unable to retrieve AltClearSavedPosition values.",
                            toggle_query);
        }
        else
        {
            MSqlQuery select_query(MSqlQuery::InitCon());
            select_query.prepare("SELECT keylist FROM keybindings "
                                 " WHERE context = 'Global' "
                                 "   AND action = 'SELECT' "
                                 "   AND hostname = :HOSTNAME");

            MSqlQuery update(MSqlQuery::InitCon());
            update.prepare("REPLACE INTO keybindings "
                           "  VALUES (:CONTEXT, :ACTION, :DESCRIPTION, "
                           "          :KEYLIST, :HOSTNAME)");"

            while (toggle_query.next())
            {
                QString hostname = toggle_query.value(0).toString();
                QString toggle_on = toggle_query.value(1).toString();

                QString context = "TV Playback";
                QString action;
                QString description;
                QString keylist;
                select_query.bindValue(":HOSTNAME", hostname);
                if (!select_query.exec())
                {
                    MythDB::DBError("Unable to retrieve keylist for SELECT.",
                                    select_query);
                }
                else
                {
                    while (select_query.next())
                    {
                        keylist = select_query.value(0).toString();
                    }

                    if ("1" == toggle_on)
                    {
                        action = "TOGGLEBOOKMARK";
                        description = QT_TRANSLATE_NOOP("MythControls",
                                                        "Toggle Bookmark");
                    }
                    else
                    {
                        action = "SETBOOKMARK";
                        description = QT_TRANSLATE_NOOP("MythControls",
                                                        "Add Bookmark");
                    }

                    // Map same keys used for SELECT to action
                    update.bindValue(":CONTEXT", context);
                    update.bindValue(":ACTION", action);
                    update.bindValue(":DESCRIPTION", description);
                    update.bindValue(":KEYLIST", keylist);
                    update.bindValue(":HOSTNAME", hostname);
                    if (!update.exec())
                    {
                         MythDB::DBError("Unable to update keybindings",
                                         update);
                    }
                }
            }
        }

        if (!UpdateDBVersionNumber("1349", dbver))
            return false;
    }


More information about the mythtv-dev mailing list