Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions companion/src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#define CPN_MAX_SCRIPTS 9
#define CPN_MAX_SCRIPT_INPUTS 10

#define CPN_STR_MODELNOTES_EXT ".txt"

#define CPN_STR_APP_NAME QCoreApplication::translate("Companion", "EdgeTX Companion")
#define CPN_STR_TTL_INFO QCoreApplication::translate("Companion", "Information") // shared Title Case words, eg. for a window title or section heading
#define CPN_STR_TTL_WARNING QCoreApplication::translate("Companion", "Warning")
Expand Down
2 changes: 2 additions & 0 deletions companion/src/firmwares/edgetx/yaml_modeldata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ Node convert<ModelData>::encode(const ModelData& rhs)
}

node["modelRegistrationID"] = rhs.registrationId;
node["modelNotesFileName"] = rhs.modelNotesFileName;

if (Boards::getCapability(getCurrentBoard(), Board::FunctionSwitches)) {
node["functionSwitchConfig"] = rhs.functionSwitchConfig;
Expand Down Expand Up @@ -1130,6 +1131,7 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)

node["view"] >> rhs.view;
node["modelRegistrationID"] >> rhs.registrationId;
node["modelNotesFileName"] >> rhs.modelNotesFileName;

node["functionSwitchConfig"] >> rhs.functionSwitchConfig;
node["functionSwitchGroup"] >> rhs.functionSwitchGroup;
Expand Down
3 changes: 2 additions & 1 deletion companion/src/firmwares/modeldata.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class ModelData {
unsigned int view;

char registrationId[8+1];

char modelNotesFileName[15+1];

enum FunctionSwitchConfig {
FUNC_SWITCH_CONFIG_NONE,
FUNC_SWITCH_CONFIG_FIRST = FUNC_SWITCH_CONFIG_NONE,
Expand Down
17 changes: 12 additions & 5 deletions companion/src/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,17 +685,24 @@ QString Helpers::getChecklistsPath()
return QDir::toNativeSeparators(g.profile[g.id()].sdPath() + "/MODELS/"); // TODO : add sub folder to constants
}

QString Helpers::getChecklistFilename(const ModelData * model)
QString Helpers::getChecklistFilename(const ModelData * model, bool appendExtension)
{
QString name = model->name;
name.replace(" ", "_");
name.append(".txt"); // TODO : add to constants
QString name;
if (!strlen(model->modelNotesFileName) == 0) {
name = model->modelNotesFileName;
} else {
name = model->name;
name.replace(" ", "_");
}
if (appendExtension) {
name.append(CPN_STR_MODELNOTES_EXT);
}
return name;
}

QString Helpers::getChecklistFilePath(const ModelData * model)
{
return getChecklistsPath() + getChecklistFilename(model);
return getChecklistsPath() + getChecklistFilename(model, true);
}

QString Helpers::removeAccents(const QString & str)
Expand Down
2 changes: 1 addition & 1 deletion companion/src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace Helpers
void exportAppSettings(QWidget * dlgParent = nullptr);

QString getChecklistsPath();
QString getChecklistFilename(const ModelData * model);
QString getChecklistFilename(const ModelData * model, bool appendExtension);
QString getChecklistFilePath(const ModelData * model);
QString removeAccents(const QString & str);
unsigned int getBitmappedValue(const unsigned int & field, const unsigned int index, const unsigned int numbits = 1, const unsigned int offset = 0);
Expand Down
12 changes: 12 additions & 0 deletions companion/src/modeledit/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,17 @@ void SetupPanel::on_name_editingFinished()
}
}

void SetupPanel::on_notesFile_editingFinished()
{
if (QString(model->modelNotesFileName) != ui->notesFile->text())
{
int length = ui->notesFile->maxLength();
strncpy(model->modelNotesFileName, ui->notesFile->text().toLatin1(),
length);
emit modified();
}
}

void SetupPanel::on_image_currentIndexChanged(int index)
{
if (!lock) {
Expand Down Expand Up @@ -1663,6 +1674,7 @@ void SetupPanel::update()
ui->displayText->setChecked(model->displayChecklist);
ui->gfEnabled->setChecked(!model->noGlobalFunctions);
ui->jitterFilter->setCurrentIndex(model->jitterFilter);
ui->notesFile->setText(Helpers::getChecklistFilename(model, false));

updateBeepCenter();
updateStartupSwitches();
Expand Down
1 change: 1 addition & 0 deletions companion/src/modeledit/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class SetupPanel : public ModelPanel
void onModuleUpdateItemModels();
void onFunctionSwitchesUpdateItemModels();
void on_jitterFilter_currentIndexChanged(int index);
void on_notesFile_editingFinished();

private:
Ui::Setup *ui;
Expand Down
Loading