Tue, 09 Apr 2013 18:23:07 +0300
Added a button to clear a keyboard shortcut.
zz_configDialog.cpp | file | annotate | diff | comparison | revisions | |
zz_configDialog.h | file | annotate | diff | comparison | revisions |
--- a/zz_configDialog.cpp Tue Apr 09 18:16:01 2013 +0300 +++ b/zz_configDialog.cpp Tue Apr 09 18:23:07 2013 +0300 @@ -158,15 +158,18 @@ ++i; } - qBTN_setShortcut = new QPushButton ("Set"); - qBTN_resetShortcut = new QPushButton ("Reset"); + qSetShortcut = new QPushButton ("Set"); + qResetShortcut = new QPushButton ("Reset"); + qClearShortcut = new QPushButton ("Clear"); - connect (qBTN_setShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ())); - connect (qBTN_resetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ())); + connect (qSetShortcut, SIGNAL (clicked ()), this, SLOT (slot_setShortcut ())); + connect (qResetShortcut, SIGNAL (clicked ()), this, SLOT (slot_resetShortcut ())); + connect (qClearShortcut, SIGNAL (clicked ()), this, SLOT (slot_clearShortcut ())); QVBoxLayout* qButtonLayout = new QVBoxLayout; - qButtonLayout->addWidget (qBTN_setShortcut); - qButtonLayout->addWidget (qBTN_resetShortcut); + qButtonLayout->addWidget (qSetShortcut); + qButtonLayout->addWidget (qResetShortcut); + qButtonLayout->addWidget (qClearShortcut); qButtonLayout->addStretch (10); qLayout->addWidget (qShortcutList, 0, 0); @@ -277,9 +280,6 @@ for (QListWidgetItem* qItem : qaSel) { long idx = getItemRow (qItem); - if (idx == -1) - continue; - actionmeta meta = g_ActionMeta[idx]; keyseqconfig* conf = g_ActionMeta[idx].conf; @@ -291,6 +291,23 @@ } // ============================================================================= +void ConfigDialog::slot_clearShortcut () { + QList<QListWidgetItem*> qaSel = qShortcutList->selectedItems (); + QKeySequence qDummySeq; + + for (QListWidgetItem* qItem : qaSel) { + long idx = getItemRow (qItem); + + actionmeta meta = g_ActionMeta[idx]; + keyseqconfig* conf = g_ActionMeta[idx].conf; + conf->value = qDummySeq; + + (*meta.qAct)->setShortcut (*conf); + setShortcutText (qItem, meta); + } +} + +// ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ConfigDialog::setShortcutText (QListWidgetItem* qItem, actionmeta meta) {
--- a/zz_configDialog.h Tue Apr 09 18:16:01 2013 +0300 +++ b/zz_configDialog.h Tue Apr 09 18:23:07 2013 +0300 @@ -46,7 +46,7 @@ // ========================================================================= // Shortcuts tab QListWidget* qShortcutList; - QPushButton* qBTN_setShortcut, *qBTN_resetShortcut; + QPushButton* qSetShortcut, *qResetShortcut, *qClearShortcut; std::vector<QListWidgetItem*> qaShortcutItems; QDialogButtonBox* qButtons; @@ -71,6 +71,7 @@ void slot_setGLForeground (); void slot_setShortcut (); void slot_resetShortcut (); + void slot_clearShortcut (); }; // =============================================================================