[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
@@ -47,7 +47,7 @@ class RadioFaderWidget : public RadioWidget
SliderWidget * sl = new SliderWidget(this);
sl->setOrientation(Qt::Vertical);
sl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
sl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
sl->setMinimumHeight(75);
//sl->setMaximumHeight(75);
sl->setTickPosition(QSlider::TicksBothSides);
@@ -23,6 +23,7 @@
#include "radiowidget.h"
#include "boards.h"
#include "simulator.h"
#include <QSlider>
#include <QTimer>
@@ -65,11 +66,8 @@ class RadioSwitchWidget : public RadioWidget
m_slider->setValue(m_value);
if (swType == Board::SWITCH_TOGGLE) {
QIcon icon;
icon.addFile(QStringLiteral(":/images/simulator/icons/8/lock-locked.png"), QSize(8, 8), QIcon::Normal, QIcon::On);
icon.addFile(QStringLiteral(":/images/simulator/icons/8/lock-unlocked.png"), QSize(8, 8), QIcon::Normal, QIcon::Off);
QToolButton * lockBtn = new QToolButton(this);
lockBtn->setIcon(icon);
lockBtn->setIcon(Simulator::SimulatorIcon("toggle_lock"));
lockBtn->setIconSize(QSize(8, 8));
lockBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
lockBtn->setToolButtonStyle(Qt::ToolButtonIconOnly);
@@ -78,7 +76,7 @@ class RadioSwitchWidget : public RadioWidget
lockBtn->setToolTip(tr("Latch/unlatch the momentary switch."));
QWidget * container = new QWidget(this);
container->setFixedHeight(50);
container->setFixedHeight(56);
container->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
QVBoxLayout * cl = new QVBoxLayout(container);
cl->setContentsMargins(0, 0, 0, 0);
@@ -94,7 +92,7 @@ class RadioSwitchWidget : public RadioWidget
connect(this, &RadioWidget::flagsChanged, lockBtn, &QToolButton::setChecked);
}
else {
m_slider->setFixedHeight(50);
m_slider->setFixedHeight(56);
setWidget(m_slider);
}
@@ -18,6 +18,9 @@
* GNU General Public License for more details.
*/
#define GBALL_SIZE 20
#define RESX 1024
#include "virtualjoystickwidget.h"
#include "constants.h"
#include "sliderwidget.h"
@@ -50,7 +53,9 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
gv = new QGraphicsView(this);
gv->setSizePolicy(sizePolicy);
gv->setMinimumSize(QSize(150, 150));
gv->setMinimumSize(size);
// gv->setMaximumSize(size + size * 3);
// gv->setFixedSize(prefSize);
gv->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
gv->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -88,6 +93,9 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
vTrimSlider = vTrimWidget->findChild<SliderWidget *>();
extraSize += QSize(vTrimWidget->sizeHint().width(), hTrimWidget->sizeHint().height());
}
else {
colvx = colvy = colvt;
}
if (showBtns) {
QVBoxLayout * btnbox = new QVBoxLayout();
@@ -106,8 +114,17 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
if (showValues) {
QLayout * valX = createNodeValueLayout('X', nodeLabelX);
QLayout * valY = createNodeValueLayout('Y', nodeLabelY);
layout->addLayout(valX, 2, colvx, 1, 1);
layout->addLayout(valY, 2, colvy, 1, 1);
if (!showTrims) {
QVBoxLayout * vertXY = new QVBoxLayout();
vertXY->addLayout(valX);
vertXY->addLayout(valY);
layout->addLayout(vertXY, 1, colvx, 1, 1);
extraSize += QSize(nodeLabelX->sizeHint().width(), 0);
}
else {
layout->addLayout(valX, 2, colvx, 1, 1);
layout->addLayout(valY, 2, colvy, 1, 1);
}
}
layout->addItem(new QSpacerItem(0, 0), 0, 0, 1, 5); // r0 c0-4: top v spacer
@@ -119,7 +136,7 @@ VirtualJoystickWidget::VirtualJoystickWidget(QWidget *parent, QChar side, bool s
connect(node, SIGNAL(xChanged()), this, SLOT(updateNodeValueLabels()));
connect(node, SIGNAL(yChanged()), this, SLOT(updateNodeValueLabels()));
setSize(prefSize);
setSize(prefSize, frameSize());
}
void VirtualJoystickWidget::setStickX(qreal x)
@@ -144,12 +161,12 @@ void VirtualJoystickWidget::centerStick()
qreal VirtualJoystickWidget::getStickX()
{
return node->getX();
return getStickPos().x();
}
qreal VirtualJoystickWidget::getStickY()
{
return node->getY();
return getStickPos().y();
}
QPointF VirtualJoystickWidget::getStickPos()
@@ -205,7 +222,22 @@ void VirtualJoystickWidget::setStickConstraint(int which, bool active)
}
}
void VirtualJoystickWidget::setSize(QSize size)
void VirtualJoystickWidget::setStickColor(const QColor & color)
{
node->setColor(color);
}
QSize VirtualJoystickWidget::sizeHint() const {
return prefSize;
}
void VirtualJoystickWidget::resizeEvent(QResizeEvent * event)
{
QWidget::resizeEvent(event);
setSize(event->size(), event->oldSize());
}
void VirtualJoystickWidget::setSize(const QSize & size, const QSize &)
{
float thisAspectRatio = (float)size.width() / size.height();
float newGvSz, spacerSz;
@@ -237,28 +269,24 @@ void VirtualJoystickWidget::setSize(QSize size)
layout->setColumnStretch(2, newGvSz);
layout->setRowStretch(1, newGvSz);
prefSize = QSize(newGvSz + extraSize.width(), newGvSz + extraSize.height());
//prefSize = QSize(newGvSz + extraSize.width(), newGvSz + extraSize.height());
gv->resize(newGvSz, newGvSz);
gv->updateGeometry();
repositionNode();
//qDebug() << thisAspectRatio << size << newGvSz << spacerSz << extraSize << gv->geometry() << gv->contentsRect() << gv->frameRect() << getStickPos();
}
void VirtualJoystickWidget::repositionNode()
{
QRect qr = gv->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;
QRectF qr = (QRectF)gv->contentsRect();
qreal w = qr.width() - GBALL_SIZE;
qreal h = qr.height() - GBALL_SIZE;
qreal cx = qr.width() / 2;
qreal cy = qr.height() / 2;
qreal nodeX = node->getX();
qreal nodeY = node->getY();
scene->setSceneRect(-cx,-cy,w,h);
QPointF p = node->pos();
p.setX(qMin(cx, qMax(p.x(), -cx)));
p.setY(qMin(cy, qMax(p.y(), -cy)));
node->setPos(p);
node->setX(nodeX);
node->setY(nodeY);
updateNodeValueLabels();
//qDebug() << thisAspectRatio << size << newGvSz << spacerSz << extraSize << gv->geometry() << gv->contentsRect() << gv->frameRect() << getStickPos();
}
QWidget *VirtualJoystickWidget::createTrimWidget(QChar type)
@@ -382,6 +410,7 @@ QLayout *VirtualJoystickWidget::createNodeValueLayout(QChar type, QLabel *& valL
val->setObjectName(QString("val_%1").arg(type));
val->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
val->setAlignment(Qt::AlignCenter);
val->setMinimumWidth(val->fontMetrics().width("-100 "));
QVBoxLayout * layout = new QVBoxLayout();
layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(2);
@@ -33,9 +33,6 @@
class Node;
class SliderWidget;
#define GBALL_SIZE 20
#define RESX 1024
class VirtualJoystickWidget : public QWidget
{
Q_OBJECT
@@ -55,7 +52,7 @@ class VirtualJoystickWidget : public QWidget
FIX_Y
};
explicit VirtualJoystickWidget(QWidget * parent = NULL, QChar side = 'L', bool showTrims = true, bool showBtns = true, bool showValues = true, QSize size = QSize(245, 245));
explicit VirtualJoystickWidget(QWidget * parent = NULL, QChar side = 'L', bool showTrims = true, bool showBtns = true, bool showValues = true, QSize size = QSize(125, 125));
void setStickX(qreal x);
void setStickY(qreal y);
@@ -70,17 +67,10 @@ class VirtualJoystickWidget : public QWidget
int getTrimValue(int which);
void setStickConstraint(int which, bool active);
void setStickColor(const QColor & color);
virtual QSize sizeHint() const
{
return prefSize;
}
virtual void resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
setSize(event->size());
}
virtual QSize sizeHint() const;
virtual void resizeEvent(QResizeEvent *event);
signals:
void trimButtonPressed(int which);
@@ -94,8 +84,7 @@ class VirtualJoystickWidget : public QWidget
void updateNodeValueLabels();
protected:
void setSize(QSize size);
void repositionNode();
void setSize(const QSize & size, const QSize &);
QWidget * createTrimWidget(QChar type);
QPushButton * createButtonWidget(int type);
QLayout * createNodeValueLayout(QChar type, QLabel *& valLabel);