1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Tweaks to auto objects and fixup filesyncdialog compile

This commit is contained in:
elecpower 2021-03-16 23:16:11 +11:00
parent 099d5f7608
commit 38f1d249c9
6 changed files with 39 additions and 81 deletions

View file

@ -39,6 +39,8 @@
#include <QLineEdit> #include <QLineEdit>
#include <QMenu> #include <QMenu>
#include <QSpinBox> #include <QSpinBox>
#include <QMessageBox>
#include <QPushButton>
FileSyncDialog::FileSyncDialog(QWidget * parent, const SyncProcess::SyncOptions & syncOptions) : FileSyncDialog::FileSyncDialog(QWidget * parent, const SyncProcess::SyncOptions & syncOptions) :
QDialog(parent), QDialog(parent),

View file

@ -137,7 +137,7 @@ QString TimerData::persistentToString(const int value, const bool verbose)
// static // static
QString TimerData::pvalueToString(const int value) QString TimerData::pvalueToString(const int value)
{ {
return DataHelpers::timeToString(value, TIMESTR_MASK_HRSMINS | TIMESTR_MASK_HRSMINS); return DataHelpers::timeToString(value, TIMESTR_MASK_HRSMINS | TIMESTR_MASK_ZEROHRS);
} }
// static // static

View file

@ -112,10 +112,14 @@ void TimerPanel::update()
ui->persistentValue->setText(timer.pvalueToString()); ui->persistentValue->setText(timer.pvalueToString());
} }
ui->countdownStart->updateValue(); ui->countdownStart->updateValue();
if(timer.countdownBeep == TimerData::COUNTDOWNBEEP_SILENT) if(timer.countdownBeep == TimerData::COUNTDOWNBEEP_SILENT) {
ui->countdownStartLabel->setEnabled(false);
ui->countdownStart->setEnabled(false); ui->countdownStart->setEnabled(false);
else }
else {
ui->countdownStartLabel->setEnabled(true);
ui->countdownStart->setEnabled(true); ui->countdownStart->setEnabled(true);
}
lock = false; lock = false;
} }
@ -124,17 +128,6 @@ QWidget * TimerPanel::getLastFocus()
return ui->persistent; return ui->persistent;
} }
void TimerPanel::on_countdownBeep_currentIndexChanged(int index)
{
if (!lock) {
const unsigned int val = ui->countdownStart->itemData(index).toUInt();
if (val != timer.countdownBeep) {
timer.setCountdownBeep(val);
emit modified();
}
}
}
void TimerPanel::on_value_editingFinished() void TimerPanel::on_value_editingFinished()
{ {
if (!lock) { if (!lock) {
@ -158,26 +151,6 @@ void TimerPanel::onModeChanged(int index)
} }
} }
void TimerPanel::on_minuteBeep_toggled(bool checked)
{
if (!lock) {
timer.minuteBeep = checked;
emit modified();
}
}
void TimerPanel::on_name_editingFinished()
{
if (!lock) {
if (QString(timer.name) != ui->name->text()) {
int length = ui->name->maxLength();
strncpy(timer.name, ui->name->text().toLatin1(), length);
emit nameChanged();
emit modified();
}
}
}
void TimerPanel::connectItemModelEvents(const FilteredItemModel * itemModel) void TimerPanel::connectItemModelEvents(const FilteredItemModel * itemModel)
{ {
connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &TimerPanel::onItemModelAboutToBeUpdated); connect(itemModel, &FilteredItemModel::aboutToBeUpdated, this, &TimerPanel::onItemModelAboutToBeUpdated);
@ -199,28 +172,6 @@ void TimerPanel::onItemModelUpdateComplete()
} }
} }
void TimerPanel::on_countdownStart_currentIndexChanged(int index)
{
if (!lock) {
const int val = ui->countdownStart->itemData(index).toInt();
if (val != timer.countdownStart) {
timer.countdownStart = val;
emit modified();
}
}
}
void TimerPanel::on_persistent_currentIndexChanged(int index)
{
if (!lock) {
const unsigned int val = ui->persistent->itemData(index).toUInt();
if (val != timer.persistent) {
timer.persistent = val;
emit modified();
}
}
}
/******************************************************************************/ /******************************************************************************/
#define FAILSAFE_CHANNEL_HOLD 2000 #define FAILSAFE_CHANNEL_HOLD 2000

View file

@ -48,13 +48,8 @@ class TimerPanel : public ModelPanel
private slots: private slots:
void onModeChanged(int index); void onModeChanged(int index);
void on_value_editingFinished(); void on_value_editingFinished();
void on_minuteBeep_toggled(bool checked);
void on_countdownBeep_currentIndexChanged(int index);
void on_name_editingFinished();
void onItemModelAboutToBeUpdated(); void onItemModelAboutToBeUpdated();
void onItemModelUpdateComplete(); void onItemModelUpdateComplete();
void on_countdownStart_currentIndexChanged(int index);
void on_persistent_currentIndexChanged(int index);
signals: signals:
void nameChanged(); void nameChanged();

View file

@ -21,23 +21,23 @@
#pragma once #pragma once
#include <QCheckBox> #include <QCheckBox>
#include "modeledit/modeledit.h" #include "genericpanel.h"
class AutoCheckBox: public QCheckBox class AutoCheckBox: public QCheckBox
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AutoCheckBox(QWidget *parent = 0): explicit AutoCheckBox(QWidget * parent = nullptr):
QCheckBox(parent), QCheckBox(parent),
field(NULL), field(nullptr),
panel(NULL), panel(nullptr),
lock(false) lock(false)
{ {
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
} }
void setField(bool & field, ModelPanel * panel=NULL) void setField(bool & field, GenericPanel * panel = nullptr)
{ {
this->field = &field; this->field = &field;
this->panel = panel; this->panel = panel;
@ -51,26 +51,31 @@ class AutoCheckBox: public QCheckBox
void updateValue() void updateValue()
{ {
if (!field)
return;
lock = true; lock = true;
if (field) { setChecked(*field);
setChecked(*field);
}
lock = false; lock = false;
} }
signals:
void currentDataChanged(bool value);
protected slots: protected slots:
void onToggled(bool checked) void onToggled(bool checked)
{ {
if (panel && panel->lock)
return;
if (field && !lock) { if (field && !lock) {
*field = checked; *field = checked;
if (panel) { emit currentDataChanged(checked);
if (panel)
emit panel->modified(); emit panel->modified();
}
} }
} }
protected: protected:
bool * field; bool *field = nullptr;
ModelPanel * panel; GenericPanel *panel = nullptr;
bool lock; bool lock = false;
}; };

View file

@ -28,8 +28,13 @@ class AutoComboBox: public QComboBox
Q_OBJECT Q_OBJECT
public: public:
explicit AutoComboBox(QWidget *parent = nullptr): explicit AutoComboBox(QWidget * parent = nullptr):
QComboBox(parent) QComboBox(parent),
field(nullptr),
panel(nullptr),
next(0),
lock(false),
hasModel(false)
{ {
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int))); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
} }
@ -69,14 +74,14 @@ class AutoComboBox: public QComboBox
} }
} }
void setField(unsigned int & field, GenericPanel * panel=nullptr) void setField(unsigned int & field, GenericPanel * panel = nullptr)
{ {
this->field = (int *)&field; this->field = (int *)&field;
this->panel = panel; this->panel = panel;
updateValue(); updateValue();
} }
void setField(int & field, GenericPanel * panel=nullptr) void setField(int & field, GenericPanel * panel = nullptr)
{ {
this->field = &field; this->field = &field;
this->panel = panel; this->panel = panel;
@ -122,16 +127,16 @@ class AutoComboBox: public QComboBox
const int val = itemData(index).toInt(); const int val = itemData(index).toInt();
if (field && !lock) { if (field && !lock) {
*field = val; *field = val;
emit currentDataChanged(val);
if (panel) if (panel)
emit panel->modified(); emit panel->modified();
} }
emit currentDataChanged(val);
} }
} }
protected: protected:
int * field = nullptr; int *field = nullptr;
GenericPanel * panel = nullptr; GenericPanel *panel = nullptr;
int next = 0; int next = 0;
bool lock = false; bool lock = false;
bool hasModel = false; bool hasModel = false;