Ticket #572: mc_reject_unrecognized_keys.diff

File mc_reject_unrecognized_keys.diff, 3.5 KB (added by anonymous, 20 years ago)
  • mythcontrols/mythcontrols/keygrabber.cpp

     
    4040    key_label = addLabel("Waiting for key press", Small, false);
    4141
    4242    ok_button = this->addButton(tr("OK"), this, SLOT(acceptBinding()));
    43     this->addButton(tr("Cancel"), this, SLOT(cancel()));
     43    cancel_button = this->addButton(tr("Cancel"), this, SLOT(cancel()));
    4444
    4545    this->grabKeyboard();
    4646}
     
    7171        key_name = modifiers + key_name;
    7272    }
    7373
    74     this->captured_key_event = key_name;
    75     this->key_label->setText("Add key, \"" + key_name + "\"?");
     74    /* keys without a name are no good to us */
     75    if (key_name.isEmpty())
     76    {
     77        this->key_label->setText("You have pressed an invalid key!");
     78        this->ok_button->setDisabled(true);
     79        this->cancel_button->setFocus();
     80    }
     81    else {
     82        this->captured_key_event = key_name;
     83        this->key_label->setText("Add key, \"" + key_name + "\"?");
     84        this->ok_button->setFocus();
     85    }
     86
    7687    this->releaseKeyboard();
    77     this->ok_button->setFocus();
    7888}
    7989
    8090
  • mythcontrols/mythcontrols/keygrabber.h

     
    5252
    5353public slots:
    5454
    55 /**
    56  * @brief Accept the captured keybinding.
    57  *
    58  * The QString provided in the constructor will be set to the
    59  * captured key value.
    60  */
    61 inline void acceptBinding(void) { done(1); }
     55    /**
     56     * @brief Accept the captured keybinding.
     57     *
     58     * The QString provided in the constructor will be set to the
     59     * captured key value.
     60     */
     61        inline void acceptBinding(void) { done(1); }
    6262
    6363    /**
    6464     * @brief Reject the captured key binding.
     
    8787    bool has_captured;
    8888    QString captured_key_event;
    8989    QButton *ok_button;
     90    QButton *cancel_button;
    9091    QLabel *key_label;
    9192};
    9293
     
    122123    inline int getOption(void) { return ExecPopup(this,SLOT(finish())); }
    123124
    124125protected slots:
    125 /**
    126  * @brief Close the popup.
    127  */
    128 inline void finish(void) { done(0); }
     126    /**
     127     * @brief Close the popup.
     128     */
     129    inline void finish(void) { done(0); }
    129130};
    130131
    131132
     
    154155
    155156public slots:
    156157
    157 /**
    158  * @brief Slot to connect to when the save button is pressed.
    159  */
    160 inline void save(void) { done(OptionsMenu::SAVE); }
     158    /**
     159     * @brief Slot to connect to when the save button is pressed.
     160     */
     161    inline void save(void) { done(OptionsMenu::SAVE); }
    161162
    162163    /**
    163164     * @brief Slot to connect to when the cancel button is pressed.
     
    193194
    194195public slots:
    195196
    196 /**
    197  * @brief Slot to connect to when the set button is pressed.
    198  */
    199 inline void set(void) { done(ActionMenu::SET); }
     197    /**
     198     * @brief Slot to connect to when the set button is pressed.
     199     */
     200    inline void set(void) { done(ActionMenu::SET); }
    200201
    201202    /**
    202203     * @brief Slot to connect to when the remove button is pressed.
     
    235236
    236237public slots:
    237238
    238 /**
    239  * @brief Slot to connect to when the save button is pressed.
    240  */
    241 inline void save(void) { done(UnsavedMenu::SAVE); }
     239    /**
     240     * @brief Slot to connect to when the save button is pressed.
     241     */
     242    inline void save(void) { done(UnsavedMenu::SAVE); }
    242243
    243244    /**
    244245     * @brief Slot to connect to when the cancel button is pressed.