Skip to content

Commit

Permalink
Cleanup EdgeTxTheme class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Mitchell committed Sep 6, 2023
1 parent d3ed7c1 commit be0039c
Show file tree
Hide file tree
Showing 35 changed files with 306 additions and 674 deletions.
17 changes: 0 additions & 17 deletions companion/src/firmwares/customisation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,6 @@ bool RadioLayout::CustomScreenData::isEmpty() const
return strlen(layoutId) == 0;
}

void RadioTheme::init(const char* themeName, ThemeData& themeData)
{
memset(&themeData, 0, sizeof(ThemeData));

memcpy(&themeData.themeName, themeName, THEME_NAME_LEN);

PersistentData& persistentData = themeData.themePersistentData;

persistentData.options[0].type =
zoneValueEnumFromType(ZoneOption::Type::Color);
setZoneOptionValue(persistentData.options[0].value, (unsigned int)WHITE);

persistentData.options[1].type =
zoneValueEnumFromType(ZoneOption::Type::Color);
setZoneOptionValue(persistentData.options[1].value, (unsigned int)RED);
}

void RadioLayout::init(const char* layoutId, CustomScreens& customScreens)
{
memset(&customScreens, 0, sizeof(CustomScreens));
Expand Down
18 changes: 0 additions & 18 deletions companion/src/firmwares/customisation_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/

constexpr int MAX_CUSTOM_SCREENS {10};
constexpr int THEME_NAME_LEN {8};
constexpr int MAX_THEME_OPTIONS {5};
constexpr int LEN_ZONE_OPTION_STRING {8};
constexpr int MAX_LAYOUT_ZONES {10};
Expand Down Expand Up @@ -146,23 +145,6 @@ typedef WidgetsContainerPersistentData<MAX_LAYOUT_ZONES, MAX_LAYOUT_OPTIONS>
typedef WidgetsContainerPersistentData<MAX_TOPBAR_ZONES, MAX_TOPBAR_OPTIONS>
TopBarPersistentData;

class RadioTheme
{
Q_DECLARE_TR_FUNCTIONS(RadioTheme)

public:
struct PersistentData {
ZoneOptionValueTyped options[MAX_THEME_OPTIONS];
};

struct ThemeData {
char themeName[THEME_NAME_LEN + 1];
PersistentData themePersistentData;
};

static void init(const char * themeName, ThemeData & themeData);
};

class RadioLayout
{
Q_DECLARE_TR_FUNCTIONS(RadioLayout)
Expand Down
6 changes: 0 additions & 6 deletions companion/src/firmwares/edgetx/yaml_generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
node["potsConfig"] = potsConfig;
}

// Color lcd theme settings are not used in EdgeTx
// RadioTheme::ThemeData themeData;

node["ownerRegistrationID"] = rhs.registrationId;

// Gyro (for now only xlites)
Expand Down Expand Up @@ -571,9 +568,6 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
}
}

// Color lcd theme settings are not used in EdgeTx
// RadioTheme::ThemeData themeData;

node["ownerRegistrationID"] >> rhs.registrationId;

// Gyro (for now only xlites)
Expand Down
2 changes: 0 additions & 2 deletions companion/src/firmwares/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ class GeneralSettings {
char sliderName[CPN_MAX_SLIDERS][HARDWARE_NAME_LEN + 1];
unsigned int sliderConfig[CPN_MAX_SLIDERS];

RadioTheme::ThemeData themeData;

char registrationId[REGISTRATION_ID_LEN + 1];
int gyroMax;
int gyroOffset;
Expand Down
16 changes: 0 additions & 16 deletions companion/src/firmwares/opentx/opentxeeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3339,15 +3339,6 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type
internalField.Append(new ZCharField<10>(this, generalData.bluetoothName, "Bluetooth name"));
}

if (IS_FAMILY_HORUS_OR_T16(board)) {
if (version >= 220) { // data from earlier versions cannot be converted so fields initialised in afterImport
internalField.Append(new CharField<8>(this, generalData.themeData.themeName, true, "Theme name"));
for (int i = 0; i < MAX_THEME_OPTIONS; i++) {
internalField.Append(new ZoneOptionValueTypedField(this, generalData.themeData.themePersistentData.options[i], board, version));
}
}
}

if (version >= 220) {
internalField.Append(new CharField<8>(this, generalData.registrationId, "ACCESS Registration ID"));
}
Expand Down Expand Up @@ -3392,13 +3383,6 @@ void OpenTxGeneralData::beforeExport()

void OpenTxGeneralData::afterImport()
{
if (IS_FAMILY_HORUS_OR_T16(board)) {
if (version < 220) { // re-initialise as no conversion possible
const char * themeName = IS_FLYSKY_NV14(board) ? "FlySky" : "EdgeTX";
RadioTheme::init(themeName, generalData.themeData);
}
}

if (Boards::getCapability((Board::Type)generalData.variant,
Board::SportMaxBaudRate) >= 400000)
generalData.internalModuleBaudrate =
Expand Down
7 changes: 0 additions & 7 deletions companion/src/modeledit/colorcustomscreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
ModelPanel(parent, model, generalSettings, firmware)
{
RadioTheme::ThemeData & td = generalSettings.themeData;

QString sdPath = QString(g.profile[g.id()].sdPath()).trimmed();

grid = new QGridLayout(this);
Expand Down Expand Up @@ -191,11 +189,6 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene

col = 0;

if (SHOW_RAW_INFO) {
addGridLabel(grid, tr("Theme"), row, col++);
grid->addLayout(addOptionsLayout<RadioTheme::PersistentData>(td.themePersistentData, MAX_THEME_OPTIONS), row, col);
}

// the grid must be fully built for the rowspan to work as required
foreach (QWidget * wgt, optswidgets) {
grid->addWidget(wgt, widgetdetailsrow, widgetdetailscol, 3, Qt::AlignTop);
Expand Down
6 changes: 3 additions & 3 deletions radio/src/datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ static inline void check_struct()
CHKSIZE(ModelData, 6706);
#elif defined(PCBHORUS)
#if defined(PCBX10)
CHKSIZE(RadioData, 916);
CHKSIZE(RadioData, 848);
CHKSIZE(ModelData, 15607);
#else
CHKSIZE(RadioData, 916);
CHKSIZE(RadioData, 848);
CHKSIZE(ModelData, 15607);
#endif
#elif defined(PCBNV14)
CHKSIZE(RadioData, 916);
CHKSIZE(RadioData, 848);
CHKSIZE(ModelData, 15463);
#endif

Expand Down
13 changes: 0 additions & 13 deletions radio/src/datastructs_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,6 @@ PACK(struct TrainerData {
BLUETOOTH_FIELDS
#endif

#if defined(COLORLCD) && !defined(BACKUP)
#include "theme.h"
#define THEME_NAME_LEN 8
#define THEME_DATA \
NOBACKUP(char themeName[THEME_NAME_LEN]); \
NOBACKUP(EdgeTxTheme::PersistentData themeData);
#else
#define THEME_DATA
#endif

#if defined(BUZZER)
#define BUZZER_FIELD int8_t buzzerMode:2 // -2=quiet, -1=only alarms, 0=no keys, 1=all (only used on AVR radios without audio hardware)
#else
Expand Down Expand Up @@ -934,8 +924,6 @@ PACK(struct RadioData {

EXTRA_GENERAL_FIELDS

THEME_DATA

char ownerRegistrationID[PXX2_LEN_REGISTRATION_ID];

CUST_ATTR(rotEncDirection, r_rotEncDirection, nullptr);
Expand Down Expand Up @@ -992,5 +980,4 @@ PACK(struct RadioData {
#undef SCRIPTS_DATA
#undef CUSTOM_SCREENS_DATA
#undef EXTRA_GENERAL_FIELDS
#undef THEME_DATA
#undef NOBACKUP
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "bitmaps.h"
#include "strhelpers.h"
#include "font.h"
#include "theme.h"

const uint8_t _LBM_CURVE_POINT[] = {
#include "mask_cvpoint.lbm"
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/draw_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "lcd.h"
#include "theme_manager.h"
#include "libopenui.h"
#include "theme.h"

#include "watchdog_driver.h"

Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/colorlcd/fab_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void FabButton::paint(BitmapBuffer * dc)
dc->drawBitmap((width() - bitmap->width()) / 2,
(FAB_BUTTON_SIZE - bitmap->height()) / 2, bitmap);

const BitmapBuffer* mask = theme->getIconMask(icon);
const BitmapBuffer* mask = EdgeTxTheme::instance()->getIconMask(icon);
if (mask) {
dc->drawMask((width() - mask->width()) / 2,
(FAB_BUTTON_SIZE - mask->height()) / 2, mask, COLOR2FLAGS(WHITE));
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/fullscreen_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "mainwindow.h"
#include "opentx.h"
#include "libopenui.h"
#include "theme.h"

#include "watchdog_driver.h"

Expand Down
1 change: 0 additions & 1 deletion radio/src/gui/colorlcd/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "popups.h"
#include "draw_functions.h"
#include "bitmaps.h"
#include "theme.h"

#define LOAD_MODEL_BITMAP()

Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "opentx.h"
#include "view_main.h"
#include "topbar_impl.h"
#include "theme.h"

WidgetsContainer * customScreens[MAX_CUSTOM_SCREENS] = {};

Expand Down
3 changes: 0 additions & 3 deletions radio/src/gui/colorlcd/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ class LayoutFactory

virtual const uint8_t* getBitmap() const = 0;

virtual void drawThumb(BitmapBuffer* dc, uint16_t x, uint16_t y,
LcdFlags flags) const = 0;

virtual const ZoneOption* getOptions() const = 0;

virtual WidgetsContainer* create(Window* parent,
Expand Down
5 changes: 0 additions & 5 deletions radio/src/gui/colorlcd/layouts/layout_factory_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ class BaseLayoutFactory: public LayoutFactory

const uint8_t* getBitmap() const override { return bitmap; }

void drawThumb(BitmapBuffer * dc, uint16_t x, uint16_t y, uint32_t flags) const override
{
dc->drawBitmapPattern(x, y, bitmap, flags);
}

const ZoneOption * getOptions() const override
{
return options;
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/layouts/topbar_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "topbar_impl.h"
#include "opentx.h"
#include "theme.h"

constexpr uint32_t TOPBAR_REFRESH = 1000 / 10; // 10 Hz

Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "mainwindow.h"
#include "keyboard_base.h"
#include "opentx.h"
#include "theme.h"

PageHeader::PageHeader(Page * parent, uint8_t icon):
FormWindow(parent, { 0, 0, LCD_W, MENU_HEADER_HEIGHT }, OPAQUE),
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/colorlcd/tabsgroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "mainwindow.h"
#include "view_main.h"
#include "static.h"
#include "theme.h"

#if defined(HARDWARE_TOUCH)
#include "keyboard_base.h"
Expand Down
Loading

0 comments on commit be0039c

Please sign in to comment.