feat(cpn): model notes and checklist files packaged with model files (#6578)
This commit is contained in:
@@ -2046,3 +2046,8 @@ const Board::SwitchType ModelData::getSwitchType(int sw, const GeneralSettings &
|
||||
}
|
||||
return gs.switchConfig[sw].type;
|
||||
}
|
||||
|
||||
QString ModelData::getChecklistFilename() const
|
||||
{
|
||||
return QString(name).replace(" ", "_").append(".txt").toLower();
|
||||
}
|
||||
|
||||
@@ -125,19 +125,6 @@ class ModelData {
|
||||
public:
|
||||
ModelData();
|
||||
ModelData(const ModelData & src);
|
||||
ModelData & operator = (const ModelData & src);
|
||||
|
||||
void convert(RadioDataConversionState & cstate);
|
||||
|
||||
ExpoData * insertInput(const int idx);
|
||||
void removeInput(const int idx, bool clearName = true);
|
||||
|
||||
bool isInputValid(const unsigned int idx) const;
|
||||
bool hasExpos(uint8_t inputIdx) const;
|
||||
bool hasMixes(uint8_t output) const;
|
||||
|
||||
QVector<const ExpoData *> expos(int input) const;
|
||||
QVector<const MixData *> mixes(int channel) const;
|
||||
|
||||
char semver[8 + 1];
|
||||
bool used;
|
||||
@@ -243,6 +230,22 @@ class ModelData {
|
||||
unsigned int usbJoystickCircularCut;
|
||||
USBJoystickChData usbJoystickCh[CPN_USBJ_MAX_JOYSTICK_CHANNELS];
|
||||
|
||||
QByteArray checklistData;
|
||||
|
||||
ModelData & operator = (const ModelData & src);
|
||||
|
||||
void convert(RadioDataConversionState & cstate);
|
||||
|
||||
ExpoData * insertInput(const int idx);
|
||||
void removeInput(const int idx, bool clearName = true);
|
||||
|
||||
bool isInputValid(const unsigned int idx) const;
|
||||
bool hasExpos(uint8_t inputIdx) const;
|
||||
bool hasMixes(uint8_t output) const;
|
||||
|
||||
QVector<const ExpoData *> expos(int input) const;
|
||||
QVector<const MixData *> mixes(int channel) const;
|
||||
|
||||
void clear();
|
||||
bool isEmpty() const;
|
||||
void setDefaultInputs(const GeneralSettings & settings);
|
||||
@@ -283,7 +286,9 @@ class ModelData {
|
||||
bool isFunctionSwitchSourceAllowed(int index) const;
|
||||
|
||||
const Board::SwitchType getSwitchType(int sw, const GeneralSettings & gs) const;
|
||||
|
||||
|
||||
QString getChecklistFilename() const;
|
||||
|
||||
enum ReferenceUpdateAction {
|
||||
REF_UPD_ACT_CLEAR,
|
||||
REF_UPD_ACT_SHIFT,
|
||||
|
||||
@@ -718,24 +718,6 @@ void TableLayout::setColumnStretch(int col, int stretch)
|
||||
#endif
|
||||
}
|
||||
|
||||
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 name = model->name;
|
||||
name.replace(" ", "_");
|
||||
name.append(".txt"); // TODO : add to constants
|
||||
return name;
|
||||
}
|
||||
|
||||
QString Helpers::getChecklistFilePath(const ModelData * model)
|
||||
{
|
||||
return getChecklistsPath() + getChecklistFilename(model);
|
||||
}
|
||||
|
||||
QString Helpers::removeAccents(const QString & str)
|
||||
{
|
||||
// UTF-8 ASCII Table
|
||||
|
||||
@@ -110,9 +110,6 @@ namespace Helpers
|
||||
|
||||
void exportAppSettings(QWidget * dlgParent = nullptr);
|
||||
|
||||
QString getChecklistsPath();
|
||||
QString getChecklistFilename(const ModelData * model);
|
||||
QString getChecklistFilePath(const ModelData * model);
|
||||
QString removeAccents(const QString & str);
|
||||
unsigned int getBitmappedValue(const unsigned int & field, const unsigned int index = 0, const unsigned int numbits = 1, const unsigned int offset = 0);
|
||||
void setBitmappedValue(unsigned int & field, unsigned int value, unsigned int index = 0, unsigned int numbits = 1, unsigned int offset = 0);
|
||||
|
||||
@@ -24,31 +24,32 @@
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
ChecklistDialog::ChecklistDialog(QWidget *parent, const ModelData * model):
|
||||
ChecklistDialog::ChecklistDialog(QWidget *parent, ModelData * model):
|
||||
QDialog(parent),
|
||||
ui(new Ui::ChecklistDialog),
|
||||
model(model),
|
||||
mDirty(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(CompanionIcon("edit.png"));
|
||||
|
||||
mChecklistFolder = Helpers::getChecklistsPath();
|
||||
mModelChecklist = Helpers::getChecklistFilePath(model);
|
||||
ui->file->setText("File: " + mModelChecklist);
|
||||
ui->pteCheck->setPlainText(readFile(mModelChecklist, QFile::exists(mModelChecklist)));
|
||||
|
||||
QFont f("Courier", 12, QFont::Normal); // fixed width font
|
||||
QFont f("Courier", 10, QFont::Normal); // fixed width font
|
||||
ui->pteCheck->setFont(f);
|
||||
|
||||
connect(ui->pteCheck, SIGNAL(textChanged()), this, SLOT(changed()));
|
||||
connect(ui->pteCheck, SIGNAL(cursorPositionChanged()), this, SLOT(cursorChanged()));
|
||||
connect(ui->pbImport, SIGNAL(clicked()), this, SLOT(import()));
|
||||
connect(ui->pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
connect(ui->pbOK, SIGNAL(clicked()), this, SLOT(update()));
|
||||
connect(ui->pteCheck, &QPlainTextEdit::textChanged, [&]() { mDirty = true; });
|
||||
connect(ui->pteCheck, &QPlainTextEdit::cursorPositionChanged, [&]()
|
||||
{
|
||||
QTextCursor tc = ui->pteCheck->textCursor();
|
||||
ui->lblCursorPos->setText(tr("Line %1, Col %2").arg(tc.blockNumber() + 1).arg(tc.positionInBlock() + 1));
|
||||
}
|
||||
);
|
||||
connect(ui->pbImport, &QPushButton::clicked, this, &ChecklistDialog::import);
|
||||
connect(ui->pbCancel, &QPushButton::clicked, [this]() { reject(); });
|
||||
connect(ui->pbOK, &QPushButton::clicked, this, &ChecklistDialog::update);
|
||||
|
||||
cursorChanged(); // force label to update
|
||||
ui->pteCheck->setPlainText(model->checklistData.data());
|
||||
mDirty = false;
|
||||
}
|
||||
|
||||
ChecklistDialog::~ChecklistDialog()
|
||||
@@ -56,57 +57,45 @@ ChecklistDialog::~ChecklistDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ChecklistDialog::changed()
|
||||
void ChecklistDialog::update()
|
||||
{
|
||||
mDirty = true;
|
||||
if (mDirty) {
|
||||
model->checklistData = Helpers::removeAccents(ui->pteCheck->toPlainText()).toUtf8();
|
||||
if (model->checklistData.trimmed().isEmpty())
|
||||
model->checklistData.clear();
|
||||
emit updated();
|
||||
}
|
||||
|
||||
emit accept();
|
||||
}
|
||||
|
||||
void ChecklistDialog::import()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open Checklist"), mChecklistFolder, tr("Checklist Files (*.txt)"));
|
||||
if (!filename.isNull())
|
||||
ui->pteCheck->setPlainText(readFile(filename,true));
|
||||
mDirty = true;
|
||||
}
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Import Checklist File"), QString(), tr("Checklist Files (*.txt)"));
|
||||
|
||||
void ChecklistDialog::update()
|
||||
{
|
||||
if (mDirty) {
|
||||
QFile file(mModelChecklist);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Text)) {
|
||||
QMessageBox::critical(this, tr("Model Checklist"), tr("Cannot open file for writing %1:\n%2.").arg(mModelChecklist, file.errorString()));
|
||||
}
|
||||
else {
|
||||
QTextStream out(&file);
|
||||
if (out.status()==QTextStream::Ok) {
|
||||
out << Helpers::removeAccents(ui->pteCheck->toPlainText());
|
||||
if (!(out.status()==QTextStream::Ok)) {
|
||||
QMessageBox::critical(this, tr("Model Checklist"), tr("Cannot write to file %1:\n%2.").arg(mModelChecklist, file.errorString()));
|
||||
if (!file.flush()) {
|
||||
QMessageBox::critical(this, tr("Model Checklist"), tr("Cannot write file %1:\n%2.").arg(mModelChecklist, file.errorString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
if (!filename.isEmpty()) {
|
||||
ui->pteCheck->setPlainText(readFile(filename,true));
|
||||
mDirty = true;
|
||||
}
|
||||
emit accept();
|
||||
}
|
||||
|
||||
QString ChecklistDialog::readFile(const QString & filepath, const bool exists)
|
||||
{
|
||||
QString data = "";
|
||||
|
||||
if (!filepath.isNull()) {
|
||||
QFile file(filepath);
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
if (exists) {
|
||||
QMessageBox::critical(this, tr("Model Checklist"), tr("Cannot open file %1:\n%2.").arg(QDir::toNativeSeparators(filepath), file.errorString()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
QTextStream in(&file);
|
||||
|
||||
if (in.status()==QTextStream::Ok) {
|
||||
data = Helpers::removeAccents(in.readAll());
|
||||
|
||||
if (!(in.status()==QTextStream::Ok)) {
|
||||
QMessageBox::critical(this, tr("Model Checklist"), tr("Cannot read file %1:\n%2.").arg(QDir::toNativeSeparators(filepath), file.errorString()));
|
||||
data = "";
|
||||
@@ -117,9 +106,3 @@ QString ChecklistDialog::readFile(const QString & filepath, const bool exists)
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void ChecklistDialog::cursorChanged()
|
||||
{
|
||||
QTextCursor tc = ui->pteCheck->textCursor();
|
||||
ui->lblCursorPos->setText(tr("Line %1, Col %2").arg(tc.blockNumber() + 1).arg(tc.positionInBlock() + 1));
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _CHECKLISTDIALOG_H_
|
||||
#define _CHECKLISTDIALOG_H_
|
||||
#pragma once
|
||||
|
||||
#include "modeldata.h"
|
||||
|
||||
@@ -34,21 +33,19 @@ class ChecklistDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChecklistDialog(QWidget *parent, const ModelData * model);
|
||||
ChecklistDialog(QWidget *parent, ModelData * model);
|
||||
~ChecklistDialog();
|
||||
|
||||
signals:
|
||||
void updated();
|
||||
|
||||
private slots:
|
||||
void import();
|
||||
void update();
|
||||
void changed();
|
||||
void cursorChanged();
|
||||
|
||||
private:
|
||||
Ui::ChecklistDialog *ui;
|
||||
QString mModelChecklist;
|
||||
QString mChecklistFolder;
|
||||
QString readFile(const QString & filepath, const bool exists);
|
||||
ModelData *model;
|
||||
bool mDirty;
|
||||
QString readFile(const QString & filepath, const bool exists);
|
||||
};
|
||||
|
||||
#endif // _CHECKLISTDIALOG_H_
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
<string>Edit Checklist</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -30,7 +30,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="pteCheck">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -44,26 +44,26 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
<enum>Qt::ScrollBarPolicy::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
<enum>Qt::ScrollBarPolicy::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
<enum>QPlainTextEdit::LineWrapMode::NoWrap</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="3" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblCursorPos">
|
||||
@@ -75,10 +75,10 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
<enum>QSizePolicy::Policy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -135,20 +135,10 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Please note, the maximum width displayable is radio model limited. Also, renaming the model will break the link to this checklist file.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="file">
|
||||
<property name="text">
|
||||
<string>File: unknown</string>
|
||||
<string>Please note, the maximum width displayable is limited by the physical radio screen</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
||||
@@ -180,7 +180,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
|
||||
if (!firmware->getCapability(HasDisplayText)) {
|
||||
ui->displayText->hide();
|
||||
ui->editText->hide();
|
||||
ui->editChecklist->hide();
|
||||
}
|
||||
|
||||
if (!firmware->getCapability(GlobalFunctions)) {
|
||||
@@ -322,8 +322,6 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
||||
}
|
||||
}
|
||||
|
||||
disableMouseScrolling();
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
@@ -646,17 +644,12 @@ void SetupPanel::onBeepCenterToggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void SetupPanel::on_editText_clicked()
|
||||
void SetupPanel::on_editChecklist_clicked()
|
||||
{
|
||||
const QString path = Helpers::getChecklistsPath();
|
||||
QDir d(path);
|
||||
if (!d.exists()) {
|
||||
QMessageBox::critical(this, tr("Profile Settings"), tr("SD structure path not specified or invalid"));
|
||||
}
|
||||
else {
|
||||
ChecklistDialog *g = new ChecklistDialog(this, model);
|
||||
g->exec();
|
||||
}
|
||||
ChecklistDialog *chk = new ChecklistDialog(this, model);
|
||||
connect(chk, &ChecklistDialog::updated, [this]() { emit modified(); });
|
||||
chk->exec();
|
||||
chk->deleteLater();
|
||||
}
|
||||
|
||||
void SetupPanel::onTimerCustomContextMenuRequested(QPoint pos)
|
||||
|
||||
@@ -69,7 +69,7 @@ class SetupPanel : public ModelPanel
|
||||
void startupSwitchToggled(bool checked);
|
||||
void potWarningToggled(bool checked);
|
||||
void on_potWarningMode_currentIndexChanged(int index);
|
||||
void on_editText_clicked();
|
||||
void on_editChecklist_clicked();
|
||||
void onTimerCustomContextMenuRequested(QPoint pos);
|
||||
void cmTimerClear(bool prompt = true);
|
||||
void cmTimerClearAll();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
<widget class="QLabel" name="label_timer1">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -28,7 +27,7 @@
|
||||
<string>Timer 1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -52,10 +51,10 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
<enum>QSizePolicy::Policy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -93,10 +92,10 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Panel</enum>
|
||||
<enum>QFrame::Shape::Panel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
@@ -112,7 +111,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_26">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -127,17 +126,16 @@
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
|
||||
<item row="0" column="0" alignment="Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -145,7 +143,7 @@
|
||||
<string>Model</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -153,7 +151,6 @@
|
||||
<widget class="QLabel" name="label_timer3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -161,17 +158,16 @@
|
||||
<string>Timer 3</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item alignment="Qt::AlignRight">
|
||||
<item alignment="Qt::AlignmentFlag::AlignRight">
|
||||
<widget class="QLabel" name="label_ttrace">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -179,15 +175,14 @@
|
||||
<string>Throttle Source</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<item alignment="Qt::AlignmentFlag::AlignRight">
|
||||
<widget class="QLabel" name="lblHatsMode">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -195,15 +190,14 @@
|
||||
<string>Hats Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<item alignment="Qt::AlignmentFlag::AlignRight">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -211,7 +205,7 @@
|
||||
<string>Trim Step</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -219,7 +213,6 @@
|
||||
<widget class="QLabel" name="labelTrimsDisplay">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -227,7 +220,7 @@
|
||||
<string>Trims Display</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -237,7 +230,6 @@
|
||||
<widget class="QLabel" name="toplcdTimerLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -245,11 +237,11 @@
|
||||
<string>Top LCD Timer</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
|
||||
<item row="10" column="0" alignment="Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QLabel" name="swwarn_label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
@@ -259,7 +251,6 @@
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -267,7 +258,7 @@
|
||||
<string>Warnings</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -289,7 +280,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -304,15 +295,14 @@
|
||||
<item row="7" column="1">
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" alignment="Qt::AlignRight|Qt::AlignVCenter">
|
||||
<item row="2" column="0" alignment="Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignVCenter">
|
||||
<widget class="QLabel" name="label_timer2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -320,14 +310,14 @@
|
||||
<string>Timer 2</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -345,7 +335,7 @@
|
||||
<item>
|
||||
<layout class="QGridLayout" name="switchesStartupLayout" rowstretch="0" columnstretch="0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
@@ -361,7 +351,7 @@
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -375,7 +365,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item alignment="Qt::AlignTop">
|
||||
<item alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QLabel" name="label_potWarning">
|
||||
<property name="text">
|
||||
<string>Pot/Slider Warnings</string>
|
||||
@@ -384,7 +374,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="potWarningLayout">
|
||||
<item row="0" column="0" alignment="Qt::AlignTop">
|
||||
<item row="0" column="0" alignment="Qt::AlignmentFlag::AlignTop">
|
||||
<widget class="QComboBox" name="potWarningMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
@@ -406,7 +396,7 @@
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -423,7 +413,7 @@
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -438,7 +428,7 @@
|
||||
<item row="5" column="1">
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -446,7 +436,6 @@
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -454,7 +443,7 @@
|
||||
<string>Center beep</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -529,7 +518,7 @@
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="throttleWarning">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Throttle Warning</string>
|
||||
@@ -539,7 +528,7 @@
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="enableCustomThrottleWarning">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom Throttle Warning</string>
|
||||
@@ -565,7 +554,7 @@
|
||||
<item row="2" column="3">
|
||||
<widget class="QCheckBox" name="displayText">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display Checklist</string>
|
||||
@@ -582,7 +571,7 @@
|
||||
<item row="3" column="3">
|
||||
<widget class="QCheckBox" name="checklistInteractive">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interactive Checklist</string>
|
||||
@@ -593,7 +582,6 @@
|
||||
<widget class="QLabel" name="label_jitterFilter">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
@@ -631,7 +619,7 @@
|
||||
<widget class="AutoComboBox" name="cboHatsMode"/>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QPushButton" name="editText">
|
||||
<widget class="QPushButton" name="editChecklist">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -646,7 +634,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="throttleTrim">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Throttle Trim Idle Only</string>
|
||||
@@ -662,7 +650,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reverse Throttle</string>
|
||||
@@ -679,7 +667,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="extendedTrims">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extended Trims</string>
|
||||
@@ -689,7 +677,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="extendedLimits">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
<enum>Qt::LayoutDirection::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extended Limits</string>
|
||||
@@ -709,7 +697,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
<item row="2" column="6">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
@@ -732,7 +720,7 @@ If this is checked the throttle will be reversed. Idle will be forward, trim wi
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
|
||||
@@ -1107,18 +1107,10 @@ QString ModelPrinter::printTelemetryScreen(unsigned int idx, unsigned int line,
|
||||
|
||||
QString ModelPrinter::printChecklist()
|
||||
{
|
||||
if (!model.displayChecklist)
|
||||
return "";
|
||||
QString str = tr("Error: Unable to open or read file!");
|
||||
QFile file(Helpers::getChecklistFilePath(&model));
|
||||
if (file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QTextStream in(&file);
|
||||
if (in.status() == QTextStream::Ok) {
|
||||
str = in.readAll();
|
||||
str.replace("\n", "<br />");
|
||||
str.remove("\r");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
if (!model.displayChecklist) return QString();
|
||||
|
||||
QString str(model.checklistData);
|
||||
str.replace("\n", "<br />");
|
||||
str.remove("\r");
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -90,12 +90,17 @@ bool EtxFormat::write(const RadioData & radioData)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool EtxFormat::loadFile(QByteArray & filedata, const QString & filename)
|
||||
bool EtxFormat::loadFile(QByteArray & filedata, const QString & filename, bool optional)
|
||||
{
|
||||
size_t size;
|
||||
void * data = mz_zip_reader_extract_file_to_heap(&zip_archive, qPrintable(filename), &size, 0);
|
||||
if (!data) {
|
||||
return false;
|
||||
if (optional) {
|
||||
//qDebug() << "File not found:" << filename;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << QString("Extracted file %1, size=%2").arg(filename).arg(size);
|
||||
|
||||
@@ -40,7 +40,7 @@ class EtxFormat : public LabelsStorageFormat
|
||||
virtual bool write(const RadioData & radioData);
|
||||
|
||||
protected:
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName);
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName, bool optional = false);
|
||||
virtual bool writeFile(const QByteArray & fileData, const QString & fileName);
|
||||
virtual bool getFileList(std::list<std::string>& filelist);
|
||||
virtual bool deleteFile(const QString & fileName) { return false; }
|
||||
|
||||
@@ -160,6 +160,9 @@ bool LabelsStorageFormat::load(RadioData & radioData)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!loadChecklist(model))
|
||||
return false;
|
||||
|
||||
model.modelIndex = modelIdx;
|
||||
strncpy(model.filename, mc.filename.c_str(), sizeof(model.filename)-1);
|
||||
|
||||
@@ -235,6 +238,9 @@ bool LabelsStorageFormat::write(const RadioData & radioData)
|
||||
writeModelToYaml(model, modelData);
|
||||
if (!writeFile(modelData, modelFilename))
|
||||
return false;
|
||||
|
||||
if (!writeChecklist(model))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasLabels) {
|
||||
@@ -245,3 +251,32 @@ bool LabelsStorageFormat::write(const RadioData & radioData)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LabelsStorageFormat::loadChecklist(ModelData & model)
|
||||
{
|
||||
const QString fname("MODELS/" + model.getChecklistFilename());
|
||||
//qDebug() << "Searching for checklist file:" << fname;
|
||||
|
||||
if (!loadFile(model.checklistData, fname, true)) {
|
||||
setError(tr("Cannot load ") + fname);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LabelsStorageFormat::writeChecklist(const ModelData & model)
|
||||
{
|
||||
const QString fname("MODELS/" + model.getChecklistFilename());
|
||||
|
||||
// not every model has a checklist
|
||||
if (!model.checklistData.isEmpty()) {
|
||||
//qDebug() << "Writing checklist file:" << fname;
|
||||
if (!writeFile(model.checklistData, fname)) {
|
||||
setError(tr("Cannot write ") + fname);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,13 @@ class LabelsStorageFormat : public StorageFormat
|
||||
virtual bool write(const RadioData & radioData);
|
||||
|
||||
protected:
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName) = 0;
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName, bool optional = false) = 0;
|
||||
virtual bool writeFile(const QByteArray & fileData, const QString & fileName) = 0;
|
||||
virtual bool getFileList(std::list<std::string>& filelist) = 0;
|
||||
virtual bool deleteFile(const QString & fileName) = 0;
|
||||
|
||||
StorageType probeFormat();
|
||||
|
||||
bool loadChecklist(ModelData &model);
|
||||
bool writeChecklist(const ModelData & model);
|
||||
};
|
||||
|
||||
@@ -31,10 +31,19 @@ bool SdcardFormat::write(const RadioData & radioData)
|
||||
return LabelsStorageFormat::write(radioData);
|
||||
}
|
||||
|
||||
bool SdcardFormat::loadFile(QByteArray & filedata, const QString & filename)
|
||||
bool SdcardFormat::loadFile(QByteArray & filedata, const QString & filename, bool optional)
|
||||
{
|
||||
QString path = this->filename + "/" + filename;
|
||||
QFile file(path);
|
||||
if (!file.exists()) {
|
||||
if (optional) {
|
||||
//qDebug() << "File not found:" << filename;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
setError(tr("Error opening file %1:\n%2.").arg(path).arg(file.errorString()));
|
||||
return false;
|
||||
|
||||
@@ -39,7 +39,7 @@ class SdcardFormat : public LabelsStorageFormat
|
||||
virtual bool write(const RadioData & radioData);
|
||||
|
||||
protected:
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName);
|
||||
virtual bool loadFile(QByteArray & fileData, const QString & fileName, bool optional = false);
|
||||
virtual bool writeFile(const QByteArray & fileData, const QString & fileName);
|
||||
virtual bool getFileList(std::list<std::string>& filelist);
|
||||
virtual bool deleteFile(const QString & fileName);
|
||||
|
||||
Reference in New Issue
Block a user