1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-25 17:25:10 +03:00

Re #1489, #1270, Re #1466: Allow only one instance of new dialogs

This commit is contained in:
Damjan Adamic 2015-01-04 20:06:03 +01:00
parent bb921a0a7f
commit 5037dff0d4
8 changed files with 57 additions and 14 deletions

View file

@ -41,5 +41,3 @@ void DebugOutput::traceCallback(const QString & text)
ui->Output->verticalScrollBar()->triggerAction(QAbstractSlider::SliderToMaximum);
}
}

View file

@ -270,24 +270,45 @@ void SimulatorDialog::onTrimReleased()
void SimulatorDialog::openTelemetrySimulator()
{
TelemetrySimu = new TelemetrySimulator(this, simulator);
TelemetrySimu->setAttribute(Qt::WA_DeleteOnClose, true);
TelemetrySimu->show();
// allow only one instance
if (TelemetrySimu == 0) {
TelemetrySimu = new TelemetrySimulator(this, simulator);
TelemetrySimu->show();
}
else if (!TelemetrySimu->isVisible()) {
TelemetrySimu->show();
}
}
void SimulatorDialog::openTrainerSimulator()
{
TrainerSimu = new TrainerSimulator(this, simulator);
TrainerSimu->setAttribute(Qt::WA_DeleteOnClose, true);
TrainerSimu->show();
// allow only one instance
if (TrainerSimu == 0) {
TrainerSimu = new TrainerSimulator(this, simulator);
TrainerSimu->show();
}
else if (!TrainerSimu->isVisible()) {
TrainerSimu->show();
}
}
void SimulatorDialog::openDebugOutput()
{
DebugOut = new DebugOutput(this);
DebugOut->setAttribute(Qt::WA_DeleteOnClose, true);
DebugOut->traceCallback(traceBuffer);
DebugOut->show();
// allow only one instance, but install signal handler to catch dialog destruction just in case
if (DebugOut == 0) {
DebugOut = new DebugOutput(this);
QObject::connect(DebugOut, SIGNAL(destroyed()), this, SLOT(onDebugOutputClose()));
DebugOut->traceCallback(traceBuffer);
DebugOut->show();
}
else if (!DebugOut->isVisible()) {
DebugOut->show();
}
}
void SimulatorDialog::onDebugOutputClose()
{
DebugOut = 0;
}
void SimulatorDialog::keyPressEvent (QKeyEvent *event)

View file

@ -140,6 +140,7 @@ class SimulatorDialog : public QDialog
void openTelemetrySimulator();
void openTrainerSimulator();
void openDebugOutput();
void onDebugOutputClose();
#ifdef JOYSTICKS
void onjoystickAxisValueChanged(int axis, int value);

View file

@ -28,6 +28,12 @@ void TelemetrySimulator::onTimerEvent()
}
}
void TelemetrySimulator::closeEvent(QCloseEvent *event)
{
ui->Simulate->setChecked(false);
event->accept();
}
void setSportPacketCrc(uint8_t * packet)
{
short crc = 0;

View file

@ -2,6 +2,7 @@
#define telemetrysimu_h
#include <QCloseEvent>
#include <QDialog>
#include <QTimer>
#include "simulatorinterface.h"
@ -21,6 +22,7 @@ class TelemetrySimulator : public QDialog
protected:
virtual void closeEvent(QCloseEvent *event);
private:
Ui::TelemetrySimulator * ui;

View file

@ -22,7 +22,6 @@ TrainerSimulator::TrainerSimulator(QWidget * parent, SimulatorInterface * simula
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
timer->start(10);
}
TrainerSimulator::~TrainerSimulator()
@ -31,6 +30,18 @@ TrainerSimulator::~TrainerSimulator()
delete ui;
}
void TrainerSimulator::showEvent(QShowEvent *event)
{
timer->start(10);
event->accept();
}
void TrainerSimulator::closeEvent(QCloseEvent *event)
{
timer->stop();
event->accept();
}
void TrainerSimulator::centerSticks()
{
if (leftStick->scene())

View file

@ -2,6 +2,8 @@
#define trainersimu_h
#include <QShowEvent>
#include <QCloseEvent>
#include <QDialog>
#include <QTimer>
#include "modeledit/node.h"
@ -22,6 +24,8 @@ class TrainerSimulator : public QDialog
protected:
virtual void showEvent(QShowEvent *event);
virtual void closeEvent(QCloseEvent *event);
private:
Ui::TrainerSimulator * ui;

View file

@ -206,7 +206,7 @@ void per10ms()
}
#endif
#if defined(FRSKY) || defined(JETI)
#if defined(FRSKY) || defined(JETI) || defined(SIMU)
if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol[0]))
telemetryInterrupt10ms();
#endif