diff --git a/src/gui/widget/keychooser.cpp b/src/gui/widget/keychooser.cpp index cfdc7b7aa..8cbf96e75 100644 --- a/src/gui/widget/keychooser.cpp +++ b/src/gui/widget/keychooser.cpp @@ -36,8 +36,8 @@ CKeyChooser::CKeyChooser(unsigned int * const Key, const neutrino_locale_t title keyName = CRCInput::getKeyName(*key); addIntroItems(); - addItem(new CMenuDForwarder(LOCALE_KEYCHOOSERMENU_SETNEW, true, NULL, new CKeyChooserItem(LOCALE_KEYCHOOSER_HEAD, key))); - addItem(new CMenuDForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, new CKeyChooserItemNoKey(key))); + addItem(new CMenuDForwarder(LOCALE_KEYCHOOSERMENU_SETNEW, true, NULL, new CKeyChooserItem(key, LOCALE_KEYCHOOSER_HEAD))); + addItem(new CMenuDForwarder(LOCALE_KEYCHOOSERMENU_SETNONE, true, NULL, new CKeyRemoverItem(key))); addItem(GenericMenuSeparatorLine); addItem(new CMenuForwarder(LOCALE_KEYCHOOSERMENU_CURRENTKEY, false, keyName)); } @@ -52,12 +52,6 @@ void CKeyChooser::paint() CMenuWidget::paint(); } -CKeyChooserItem::CKeyChooserItem(const neutrino_locale_t Name, unsigned int * Key) -{ - name = Name; - key = Key; -} - int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &) { neutrino_msg_t msg; @@ -84,7 +78,7 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &) timeoutEnd = CRCInput::calcTimeoutEnd(timeout); - get_Message: + get_Message: g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); if (msg != CRCInput::RC_timeout) @@ -101,3 +95,9 @@ int CKeyChooserItem::exec(CMenuTarget* parent, const std::string &) hintbox->hide(); return res; } + +int CKeyRemoverItem::exec(CMenuTarget* /*parent*/, const std::string &) +{ + *key = (unsigned int)CRCInput::RC_nokey; + return menu_return::RETURN_REPAINT; +} diff --git a/src/gui/widget/keychooser.h b/src/gui/widget/keychooser.h index 2e5852686..d6211dc04 100644 --- a/src/gui/widget/keychooser.h +++ b/src/gui/widget/keychooser.h @@ -47,29 +47,31 @@ class CKeyChooser : public CMenuWidget class CKeyChooserItem : public CMenuTarget { private: - neutrino_locale_t name; unsigned int *key; - public: - CKeyChooserItem(const neutrino_locale_t Name, unsigned int *Key); + neutrino_locale_t name; - int exec(CMenuTarget* parent, const std::string & actionKey); + public: + CKeyChooserItem(unsigned int *Key, const neutrino_locale_t Name) + { + key = Key; + name = Name; + } + + int exec(CMenuTarget* parent, const std::string & /*actionKey*/); }; -class CKeyChooserItemNoKey : public CMenuTarget +class CKeyRemoverItem : public CMenuTarget { - unsigned int *key; + private: + unsigned int *key; + public: - CKeyChooserItemNoKey(unsigned int *Key) + CKeyRemoverItem(unsigned int *Key) { key = Key; }; - int exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) - { - *key = (unsigned int)CRCInput::RC_nokey; - return menu_return::RETURN_REPAINT; - } + int exec(CMenuTarget* parent, const std::string & /*actionKey*/); }; - #endif