dialog: handle EXIT key properly
This commit is contained in:
committed by
Raphael Coeffic
parent
eb46c0f4c0
commit
ed70eaca13
@@ -190,18 +190,6 @@ void BindWaitDialog::checkEvents()
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void BindWaitDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ReceiverButton::ReceiverButton(FormGroup* parent, rect_t rect,
|
||||
uint8_t moduleIdx, uint8_t receiverIdx) :
|
||||
TextButton(parent, rect, STR_BIND,
|
||||
@@ -388,18 +376,6 @@ void RegisterDialog::checkEvents()
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void RegisterDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ModuleOptions::ModuleOptions(Window* parent, uint8_t moduleIdx):
|
||||
Dialog(parent, STR_MODULE_OPTIONS, {50, 73, LCD_W - 100, LCD_H - 146}),
|
||||
moduleIdx(moduleIdx)
|
||||
@@ -473,18 +449,6 @@ void ModuleOptions::checkEvents()
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void ModuleOptions::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t ModuleOptions::getModuleSettingsState()
|
||||
{
|
||||
const auto& hwSettings = getPXX2HardwareAndSettingsBuffer();
|
||||
@@ -717,18 +681,6 @@ void RxOptions::checkEvents()
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void RxOptions::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CH_ENABLE_SPORT 4
|
||||
#define CH_ENABLE_SBUS 5
|
||||
|
||||
|
||||
@@ -46,11 +46,7 @@ class BindWaitDialog : public Dialog
|
||||
{
|
||||
public:
|
||||
BindWaitDialog(Window* parent, uint8_t moduleIdx, uint8_t receiverIdx);
|
||||
|
||||
void checkEvents() override;
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
uint8_t moduleIdx;
|
||||
@@ -79,9 +75,6 @@ class RegisterDialog : public Dialog
|
||||
|
||||
void start();
|
||||
void checkEvents() override;
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
uint8_t moduleIdx;
|
||||
@@ -95,11 +88,7 @@ class ModuleOptions : public Dialog
|
||||
{
|
||||
public:
|
||||
ModuleOptions(Window* parent, uint8_t moduleIdx);
|
||||
|
||||
void checkEvents() override;
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@@ -127,11 +116,7 @@ class RxOptions : public Dialog
|
||||
{
|
||||
public:
|
||||
RxOptions(Window* parent, uint8_t moduleIdx, uint8_t rxIdx);
|
||||
|
||||
void checkEvents() override;
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -37,17 +37,16 @@ MessageDialog::MessageDialog(Window* parent, const char* title,
|
||||
setFocus();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void MessageDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
#if defined(HARDWARE_KEYS)
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Dialog::onEvent(event);
|
||||
}
|
||||
|
||||
DynamicMessageDialog::DynamicMessageDialog(
|
||||
Window* parent, const char* title, std::function<std::string()> textHandler,
|
||||
@@ -70,14 +69,13 @@ DynamicMessageDialog::DynamicMessageDialog(
|
||||
setFocus();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void DynamicMessageDialog::onEvent(event_t event)
|
||||
{
|
||||
TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(),
|
||||
event);
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
#if defined(HARDWARE_KEYS)
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
Dialog::onEvent(event);
|
||||
}
|
||||
#endif
|
||||
@@ -19,46 +19,40 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _MESSAGE_DIALOG_H_
|
||||
#define _MESSAGE_DIALOG_H_
|
||||
#pragma once
|
||||
|
||||
#include "dialog.h"
|
||||
#include "static.h"
|
||||
|
||||
class MessageDialog: public Dialog {
|
||||
public:
|
||||
MessageDialog(Window * parent, const char * title, const char * message, const char * info = "");
|
||||
class MessageDialog : public Dialog
|
||||
{
|
||||
public:
|
||||
MessageDialog(Window* parent, const char* title, const char* message,
|
||||
const char* info = "");
|
||||
|
||||
void setInfoText(std::string text)
|
||||
{
|
||||
infoWidget->setText(std::move(text));
|
||||
}
|
||||
void setInfoText(std::string text) { infoWidget->setText(std::move(text)); }
|
||||
|
||||
protected:
|
||||
StaticText * messageWidget;
|
||||
StaticText * infoWidget;
|
||||
protected:
|
||||
StaticText* messageWidget;
|
||||
StaticText* infoWidget;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override
|
||||
{
|
||||
return "MessageDialog";
|
||||
}
|
||||
std::string getName() const override { return "MessageDialog"; }
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
void onEvent(event_t event) override;
|
||||
};
|
||||
|
||||
class DynamicMessageDialog : public Dialog
|
||||
{
|
||||
public:
|
||||
DynamicMessageDialog(Window* parent, const char* title,
|
||||
std::function<std::string()> textHandler, const char* message = "", const int lineHeight = PAGE_LINE_HEIGHT,
|
||||
const LcdFlags textFlags = CENTERED);
|
||||
DynamicMessageDialog(Window* parent, const char* title,
|
||||
std::function<std::string()> textHandler,
|
||||
const char* message = "",
|
||||
const int lineHeight = PAGE_LINE_HEIGHT,
|
||||
const LcdFlags textFlags = CENTERED);
|
||||
// Attn.: FONT(XXL) is not supported by DynamicMessageDialog
|
||||
|
||||
|
||||
protected:
|
||||
StaticText* messageWidget;
|
||||
DynamicText* infoWidget;
|
||||
@@ -67,10 +61,5 @@ class DynamicMessageDialog : public Dialog
|
||||
std::string getName() const override { return "DynamicMessageDialog"; }
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif // _MESSAGE_DIALOG_H_
|
||||
|
||||
@@ -121,13 +121,6 @@ class ThemeDetailsDialog: public Dialog
|
||||
}, BUTTON_BACKGROUND | OPAQUE, textFont);
|
||||
}
|
||||
|
||||
void onEvent(event_t event) override
|
||||
{
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
ThemeFile theme;
|
||||
std::function<void(ThemeFile theme)> saveHandler = nullptr;
|
||||
|
||||
@@ -41,10 +41,10 @@ char *getVersion(char *str, PXX2Version version)
|
||||
}
|
||||
}
|
||||
|
||||
class versionDialog: public Dialog
|
||||
class VersionDialog: public Dialog
|
||||
{
|
||||
public:
|
||||
versionDialog(Window * parent, rect_t rect) :
|
||||
VersionDialog(Window * parent, rect_t rect) :
|
||||
Dialog(parent, STR_MODULES_RX_VERSION, rect)
|
||||
{
|
||||
memclear(&reusableBuffer.hardwareAndSettings.modules, sizeof(reusableBuffer.hardwareAndSettings.modules));
|
||||
@@ -175,16 +175,6 @@ class versionDialog: public Dialog
|
||||
Dialog::checkEvents();
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
void onEvent(event_t event) override
|
||||
{
|
||||
if (event == EVT_KEY_BREAK(KEY_EXIT) ||
|
||||
event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
deleteLater();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
rect_t rect;
|
||||
TextButton * exitButton;
|
||||
@@ -287,7 +277,7 @@ void RadioVersionPage::build(FormWindow * window)
|
||||
auto moduleVersions =
|
||||
new TextButton(window, grid.getLineSlot(), STR_MODULES_RX_VERSION);
|
||||
moduleVersions->setPressHandler([=]() -> uint8_t {
|
||||
new versionDialog(window, {50, 30, LCD_W - 100, 0});
|
||||
new VersionDialog(window, {50, 30, LCD_W - 100, 0});
|
||||
return 0;
|
||||
});
|
||||
#endif
|
||||
|
||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 7f8aa3890b...d31a31992b
Reference in New Issue
Block a user