CuteMarkEd icon indicating copy to clipboard operation
CuteMarkEd copied to clipboard

Check if map of custom shortcuts contains empty values before applying them

Open MPohlVIC opened this issue 9 years ago • 3 comments

Default shortcut did not always work because map with custom shortcuts might contain entries with empty values. Not sure why there are entries without value at all. But this fixes the problem for me.

MPohlVIC avatar Oct 05 '15 13:10 MPohlVIC

Hi @MPohlVIC,

Thank you for your contribution! I will take a look at it as fast as possible. My time is a little limited right now.

Bye, Christian

cloose avatar Oct 06 '15 07:10 cloose

The reason for empty entries is fairly easy. In OptionsDialog::saveState(), we go through the list of all rows in the shortcut table and add a custom shortcut regardless of the row content:

    // shortcut settings
    for (int i = 0; i < ui->shortcutsTable->rowCount(); ++i) {
        QKeySequence customKeySeq(ui->shortcutsTable->item(i, 1)->text());
        options->addCustomShortcut(actions[i]->objectName(), customKeySeq);
    }

Normally this should not be a problem, since initially all custom shortcuts are equal to the default shortcut of an action. So the custom shortcut can, AFAICS, only be empty if the default shortcut was empty.

Only exception I can think of is an later added default shortcut for an already existing action.

I would really like to understand the root cause of the problem.

cloose avatar Dec 09 '15 11:12 cloose

I tried to reproduce the error but I did not succeed. Maybe some issue with QSettings? I cleared them manually and it never re-surfaced again. I'll keep watching for it but in the meanwhile this pull request could be closed.

MPohlVIC avatar Feb 10 '16 17:02 MPohlVIC