Make TextEdit diry storage

This commit is contained in:
3djc
2021-04-18 11:49:27 +02:00
parent 1588d87d4d
commit 5932c4c5a8
12 changed files with 69 additions and 19 deletions
+1
View File
@@ -55,6 +55,7 @@
#include "curveedit.h"
#include "coloredit.h"
#include "draw_functions.h"
#include "textedits.h"
inline MessageDialog * createPopupInformation(const char * message)
{
+2 -2
View File
@@ -67,7 +67,7 @@ class CurveEditWindow : public Page
// Name
new StaticText(window, grid.getFieldSlot(), STR_NAME);
grid.nextLine();
new TextEdit(window, grid.getFieldSlot(), curve.name, sizeof(curve.name));
new RadioTextEdit(window, grid.getFieldSlot(), curve.name, sizeof(curve.name));
grid.nextLine();
// Type
@@ -149,7 +149,7 @@ class CurveEditWindow : public Page
// Name
new StaticText(window, grid.getLabelSlot(), STR_NAME);
new TextEdit(window, grid.getFieldSlot(), curve.name, sizeof(curve.name));
new RadioTextEdit(window, grid.getFieldSlot(), curve.name, sizeof(curve.name));
grid.nextLine();
// Type
+1 -1
View File
@@ -89,7 +89,7 @@ void ModelFlightModesPage::build(FormWindow * window)
// Flight mode name
new StaticText(group, grid.getLabelSlot(true), STR_NAME);
new TextEdit(group, grid.getFieldSlot(), g_model.flightModeData[i].name, LEN_FLIGHT_MODE_NAME);
new ModelTextEdit(group, grid.getFieldSlot(), g_model.flightModeData[i].name, LEN_FLIGHT_MODE_NAME);
grid.nextLine();
// Flight mode switch
+1 -1
View File
@@ -242,7 +242,7 @@ void GVarEditWindow::buildBody(FormWindow * window)
grid.spacer(8);
new StaticText(window, grid.getLabelSlot(), STR_NAME);
new TextEdit(window, grid.getFieldSlot(), gvar->name, LEN_GVAR_NAME);
new RadioTextEdit(window, grid.getFieldSlot(), gvar->name, LEN_GVAR_NAME);
grid.nextLine();
+2 -2
View File
@@ -186,7 +186,7 @@ class InputEditWindow: public Page
// Input Name
new StaticText(window, grid.getLabelSlot(), STR_INPUTNAME);
new TextEdit(window, grid.getFieldSlot(), g_model.inputNames[line->chn], sizeof(g_model.inputNames[line->chn]));
new ModelTextEdit(window, grid.getFieldSlot(), g_model.inputNames[line->chn], sizeof(g_model.inputNames[line->chn]));
grid.nextLine();
// Switch
@@ -208,7 +208,7 @@ class InputEditWindow: public Page
// Name
new StaticText(window, grid.getLabelSlot(), STR_EXPONAME);
new TextEdit(window, grid.getFieldSlot(), line->name, sizeof(line->name));
new ModelTextEdit(window, grid.getFieldSlot(), line->name, sizeof(line->name));
grid.nextLine();
// Source
+1 -1
View File
@@ -84,7 +84,7 @@ class MixEditWindow : public Page {
// Mix name
new StaticText(window, grid.getLabelSlot(), STR_MIXNAME);
new TextEdit(window, grid.getFieldSlot(), mix->name, sizeof(mix->name));
new RadioTextEdit(window, grid.getFieldSlot(), mix->name, sizeof(mix->name));
grid.nextLine();
// Source
+1 -1
View File
@@ -54,7 +54,7 @@ class OutputEditWindow : public Page {
// Name
new StaticText(window, grid.getLabelSlot(), STR_NAME);
new TextEdit(window, grid.getFieldSlot(), output->name, sizeof(output->name));
new RadioTextEdit(window, grid.getFieldSlot(), output->name, sizeof(output->name));
grid.nextLine();
// Offset
+4 -4
View File
@@ -171,7 +171,7 @@ class RegisterDialog: public Dialog {
// Register ID
new StaticText(form, grid.getLabelSlot(), STR_REG_ID);
auto edit = new TextEdit(form, grid.getFieldSlot(), g_model.modelRegistrationID, sizeof(g_model.modelRegistrationID));
auto edit = new RadioTextEdit(form, grid.getFieldSlot(), g_model.modelRegistrationID, sizeof(g_model.modelRegistrationID));
grid.nextLine();
// UID
@@ -218,7 +218,7 @@ class RegisterDialog: public Dialog {
rect_t rect = waiting->getRect();
waiting->deleteLater();
rxName = new TextEdit(&content->form, rect, reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME);
rxName = new RadioTextEdit(&content->form, rect, reusableBuffer.moduleSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME);
rect = exitButton->getRect();
auto okButton = new TextButton(&content->form, rect, "OK",
[=]() -> int8_t {
@@ -998,7 +998,7 @@ void ModelSetupPage::build(FormWindow * window)
// Model name
new StaticText(window, grid.getLabelSlot(), STR_MODELNAME);
auto text = new TextEdit(window, grid.getFieldSlot(), g_model.header.name, sizeof(g_model.header.name));
auto text = new RadioTextEdit(window, grid.getFieldSlot(), g_model.header.name, sizeof(g_model.header.name));
text->setChangeHandler([=] {
modelslist.load();
auto model = modelslist.getCurrentModel();
@@ -1035,7 +1035,7 @@ void ModelSetupPage::build(FormWindow * window)
// Timer name
new StaticText(window, grid.getLabelSlot(true), STR_NAME);
grid.nextLine();
new TextEdit(group, timerGrid.getSlot(), timer->name, LEN_TIMER_NAME);
new RadioTextEdit(group, timerGrid.getSlot(), timer->name, LEN_TIMER_NAME);
timerGrid.nextLine();
// Timer mode
+1 -1
View File
@@ -324,7 +324,7 @@ class SensorEditWindow : public Page {
// Sensor name
new StaticText(window, grid.getLabelSlot(), STR_NAME);
new TextEdit(window, grid.getFieldSlot(), sensor->label, sizeof(sensor->label));
new RadioTextEdit(window, grid.getFieldSlot(), sensor->label, sizeof(sensor->label));
grid.nextLine();
// Type
+5 -5
View File
@@ -136,7 +136,7 @@ class BluetoothConfigWindow : public FormGroup
// BT radio name
new StaticText(this, grid.getLabelSlot(true), STR_NAME);
new TextEdit(this, grid.getFieldSlot(), g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME);
new RadioTextEdit(this, grid.getFieldSlot(), g_eeGeneral.bluetoothName, LEN_BLUETOOTH_NAME);
grid.nextLine();
}
@@ -175,7 +175,7 @@ void RadioHardwarePage::build(FormWindow * window)
grid.nextLine();
for (int i = 0; i < NUM_STICKS; i++) {
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, (i + 1)));
new TextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i], LEN_ANA_NAME);
new RadioTextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i], LEN_ANA_NAME);
grid.nextLine();
}
@@ -184,7 +184,7 @@ void RadioHardwarePage::build(FormWindow * window)
grid.nextLine();
for (int i = 0; i < NUM_POTS; i++) {
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, (i + NUM_STICKS + 1)));
new TextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME);
new RadioTextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME);
new Choice(window, grid.getFieldSlot(2,1), STR_POTTYPES, POT_NONE, POT_WITHOUT_DETENT,
[=]() -> int {
return bfGet<uint32_t>(g_eeGeneral.potsConfig, 2*i, 2);
@@ -201,7 +201,7 @@ void RadioHardwarePage::build(FormWindow * window)
grid.nextLine();
for (int i = 0; i < NUM_SLIDERS; i++) {
new StaticText(window, grid.getLabelSlot(true), TEXT_AT_INDEX(STR_VSRCRAW, (i + NUM_STICKS + NUM_POTS + 1)));
new TextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME);
new RadioTextEdit(window, grid.getFieldSlot(2,0), g_eeGeneral.anaNames[i + NUM_STICKS], LEN_ANA_NAME);
new Choice(window, grid.getFieldSlot(2,1), STR_SLIDERTYPES, SLIDER_NONE, SLIDER_WITH_DETENT,
[=]() -> int {
uint8_t mask = (0x01 << i);
@@ -221,7 +221,7 @@ void RadioHardwarePage::build(FormWindow * window)
grid.nextLine();
for (int i = 0; i < NUM_SWITCHES; i++) {
new SwitchDynamicLabel(window, grid.getLabelSlot(true), i);
new TextEdit(window, grid.getFieldSlot(2, 0), g_eeGeneral.switchNames[i], LEN_SWITCH_NAME);
new RadioTextEdit(window, grid.getFieldSlot(2, 0), g_eeGeneral.switchNames[i], LEN_SWITCH_NAME);
new Choice(window, grid.getFieldSlot(2, 1), STR_SWTYPES, SWITCH_NONE, SWITCH_TYPE_MAX(i),
[=]() -> int {
return SWITCH_CONFIG(i);
+1 -1
View File
@@ -400,7 +400,7 @@ void RadioSetupPage::build(FormWindow * window)
#if defined(PXX2)
// Owner ID
new StaticText(window, grid.getLabelSlot(), STR_OWNER_ID);
new TextEdit(window, grid.getFieldSlot(), g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
new RadioTextEdit(window, grid.getFieldSlot(), g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
grid.nextLine();
#endif
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "libopenui.h"
#include "textedit.h"
#include "storage/storage.h"
class ModelTextEdit: public TextEdit
{
public:
ModelTextEdit(Window * parent, const rect_t & rect, char * value, uint8_t length, LcdFlags windowFlags = 0):
TextEdit(parent, rect, value, length, windowFlags)
{
setChangeHandler([](){
storageDirty(EE_MODEL);
});
}
};
class RadioTextEdit: public TextEdit
{
public:
RadioTextEdit(Window * parent, const rect_t & rect, char * value, uint8_t length, LcdFlags windowFlags = 0):
TextEdit(parent, rect, value, length, windowFlags)
{
setChangeHandler([](){
storageDirty(EE_GENERAL);
});
}
};