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