[Simulator] New main UI window, debug console, separate outputs window, more. (#4385)

* [package] Add QtSvg support DLLs for Windows.

* [Simulator] Add images/css resources for new version; Create SimulatorIcon and SimulatorStyle classes; Build with SVG support, remove unused bitmaps.

* [Simulator] Improve and simplify VirtualJoystickWidget resize event (sticks maintain X/Y position) & improve values layout w/out trims.

* [Simulator] Refactor Trainer simulator to use VirtualJoystickWidget, gains lock/hold buttons and X/Y position readout.

* [Simulator] More compact layout for Telemetry simulator, reduces min. width and adds scrolling columns to allow smaller window sizes.

* [Simulator] Add new SimulatorMainWindow and RadioOutputsWidget UI classes.

* [storage] Add non-persistent sessionId() to AppData for tracking currently active radio profile ID.

* [Simulator] Major UI updates:
    * Use a MainWindow interface with dockable/floatable windows, proper toolbar & menu;
    * Persistent size/layout state of all windows/docks/etc between uses, per radio profile;
    * Completely separate radio Outputs window with configurable layout (also persistent between uses);
    * Translations now enabled in standalone Simulator, follows main Companion setting (they need a lot of updates);
    * New custom icons throughout, toolbar icon sizes adhere to user preference in Companion.

* [Simulator] Debug Output console updates:
    * New filter feature with optional full RegEx support, can work in inclusive or exclusive modes (full help text is included in UI);
    * Up to 50 user-defined filters are saved to permanent settings, also a few predefined filters are provided;
    * Saves/restores the last filter used and if it was en/disabled;
    * Added word wrap and clear screen features;
    * Configurable scroll-back buffer size;
    * Increased efficiency & performance of the buffering/printing process.

* [Simulator][OSX] Visual UI tweaks for OS X.

* [Simulator] Fix some debug console settings not being restored properly.

* [Simulator] Add ability to hide/show menu bar; Persist view state of menu bar and radio title bar; Reduce font size on OS X; Other small visual tweaks and improvements.

* [build] Add QtSvg to Linux build scripts (a guess for Dockerfile).

* [build] Fix for Qt 5.3.

* Add OpenTx headers to new files.

* [Companion][storage] Update GeneralSettings() initializer to use current sessionId for profile data retrieval, removes workaround for standalone Simulator being started with arbitrary profile; AppData: always update sessionId when global id() changes.

* [X10] Fixes for new simulator
This commit is contained in:
Max Paperno
2017-02-04 11:59:42 +01:00
committed by Bertrand Songis
parent b493973d7d
commit 2f9d9c1a99
62 changed files with 6357 additions and 3095 deletions
+35 -78
View File
@@ -22,37 +22,45 @@
#include "trainersimu.h"
#include "ui_trainersimu.h"
#include "helpers.h"
#define GBALL_SIZE 20
#define RESX 512
#include "virtualjoystickwidget.h"
TrainerSimulator::TrainerSimulator(QWidget * parent, SimulatorInterface * simulator):
QDialog(parent),
QWidget(parent),
ui(new Ui::TrainerSimulator),
simulator(simulator)
{
ui->setupUi(this);
leftStick = ui->leftStick;
rightStick = ui->rightStick;
setupSticks();
vJoyLeft = new VirtualJoystickWidget(this, 'L', false);
vJoyLeft->setStickColor(Qt::cyan);
ui->leftStickLayout->addWidget(vJoyLeft);
// resize(0, 0); // to force min height, min width
setFixedSize(width(), height());
vJoyRight = new VirtualJoystickWidget(this, 'R', false);
vJoyRight->setStickColor(Qt::cyan);
ui->rightStickLayout->addWidget(vJoyRight);
timer = new QTimer(this);
timer->setInterval(10);
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
}
TrainerSimulator::~TrainerSimulator()
{
timer->stop();
if (timer) {
timer->stop();
delete timer;
}
if (vJoyLeft)
delete vJoyLeft;
if (vJoyRight)
delete vJoyRight;
delete ui;
}
void TrainerSimulator::showEvent(QShowEvent *event)
{
timer->start(10);
timer->start();
event->accept();
}
@@ -64,71 +72,13 @@ void TrainerSimulator::closeEvent(QCloseEvent *event)
void TrainerSimulator::centerSticks()
{
if (leftStick->scene())
nodeLeft->stepToCenter();
if (vJoyLeft)
vJoyLeft->centerStick();
if (rightStick->scene())
nodeRight->stepToCenter();
if (vJoyRight)
vJoyRight->centerStick();
}
void TrainerSimulator::setupSticks()
{
QGraphicsScene *leftScene = new QGraphicsScene(leftStick);
leftScene->setItemIndexMethod(QGraphicsScene::NoIndex);
leftStick->setScene(leftScene);
// leftStick->scene()->addLine(0,10,20,30);
QGraphicsScene *rightScene = new QGraphicsScene(rightStick);
rightScene->setItemIndexMethod(QGraphicsScene::NoIndex);
rightStick->setScene(rightScene);
// rightStick->scene()->addLine(0,10,20,30);
nodeLeft = new Node();
nodeLeft->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
nodeLeft->setBallSize(GBALL_SIZE);
leftScene->addItem(nodeLeft);
nodeRight = new Node();
nodeRight->setPos(-GBALL_SIZE/2,-GBALL_SIZE/2);
nodeRight->setBallSize(GBALL_SIZE);
rightScene->addItem(nodeRight);
}
void TrainerSimulator::resizeEvent(QResizeEvent *event)
{
if (leftStick->scene()) {
QRect qr = leftStick->contentsRect();
qreal w = (qreal)qr.width() - GBALL_SIZE;
qreal h = (qreal)qr.height() - GBALL_SIZE;
qreal cx = (qreal)qr.width()/2;
qreal cy = (qreal)qr.height()/2;
leftStick->scene()->setSceneRect(-cx,-cy,w,h);
QPointF p = nodeLeft->pos();
p.setX(qMin(cx, qMax(p.x(), -cx)));
p.setY(qMin(cy, qMax(p.y(), -cy)));
nodeLeft->setPos(p);
}
if (rightStick->scene()) {
QRect qr = rightStick->contentsRect();
qreal w = (qreal)qr.width() - GBALL_SIZE;
qreal h = (qreal)qr.height() - GBALL_SIZE;
qreal cx = (qreal)qr.width()/2;
qreal cy = (qreal)qr.height()/2;
rightStick->scene()->setSceneRect(-cx,-cy,w,h);
QPointF p = nodeRight->pos();
p.setX(qMin(cx, qMax(p.x(), -cx)));
p.setY(qMin(cy, qMax(p.y(), -cy)));
nodeRight->setPos(p);
}
QDialog::resizeEvent(event);
}
void TrainerSimulator::onTimerEvent()
{
centerSticks();
@@ -137,8 +87,15 @@ void TrainerSimulator::onTimerEvent()
void TrainerSimulator::setTrainerInputs()
{
simulator->setTrainerInput(0, int( 512* nodeLeft->getX())); // LEFT HORZ
simulator->setTrainerInput(1, int(-512* nodeLeft->getY())); // LEFT VERT
simulator->setTrainerInput(2, int(-512*nodeRight->getY())); // RGHT VERT
simulator->setTrainerInput(3, int( 512*nodeRight->getX())); // RGHT HORZ
}
if (!simulator)
return;
if (vJoyLeft) {
simulator->setTrainerInput(0, int( 512 * vJoyLeft->getStickX())); // LEFT HORZ
simulator->setTrainerInput(1, int(-512 * vJoyLeft->getStickY())); // LEFT VERT
}
if (vJoyRight) {
simulator->setTrainerInput(2, int(-512 * vJoyRight->getStickY())); // RGHT VERT
simulator->setTrainerInput(3, int( 512 * vJoyRight->getStickX())); // RGHT HORZ
}
}