[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
+81 -6
View File
@@ -24,16 +24,85 @@
#include <QColor>
#include <QDataStream>
#include <QDebug>
#include <QFile>
#include <QIcon>
#include <QPair>
#include <QString>
#define SIMULATOR_OPTIONS_VERSION 1
#define SIMULATOR_FLAGS_NOTX 0x01 // simulating a single model from Companion
#define SIMULATOR_FLAGS_STANDALONE 0x02 // started from stanalone simulator
namespace Simulator {
#define SIMULATOR_OPTIONS_VERSION 2
typedef QPair<QString, QString> keymapHelp_t;
namespace Simulator
{
}
typedef QPair<QString, QString> keymapHelp_t;
class SimulatorStyle
{
public:
SimulatorStyle() { }
static QString const basePath() { return ":/themes/default"; }
static QString const styleSheet()
{
QString css;
QFile fh(QString("%1/style.css").arg(basePath()));
if (fh.open(QFile::ReadOnly | QFile::Text)) {
css = fh.readAll();
fh.close();
}
#ifdef __APPLE__
fh.setFileName(QString("%1/style-osx.css").arg(basePath()));
if (fh.open(QFile::ReadOnly | QFile::Text)) {
css.append(fh.readAll());
fh.close();
}
#endif
return css;
}
}; // SimulatorStyle
class SimulatorIcon : public QIcon
{
public:
SimulatorIcon(const QString & baseImage)
{
QString baseFile = QString("%1/%2").arg(basePath(), baseImage);
addFile(QString("%1.svg").arg(baseFile));
QString addfile = QString("%1-on.svg").arg(baseFile);
if (QFile(addfile).exists())
addFile(addfile, QSize(), QIcon::Normal, QIcon::On);
addfile = QString("%1-active.svg").arg(baseFile);
if (QFile(addfile).exists())
addFile(addfile, QSize(), QIcon::Active, QIcon::Off);
addfile = QString("%1-disabled.svg").arg(baseFile);
if (QFile(addfile).exists())
addFile(addfile, QSize(), QIcon::Disabled, QIcon::Off);
}
static QString const basePath() { return ":/images/simulator/icons/svg"; }
static QSize const toolbarIconSize(int setting)
{
switch(setting) {
case 0:
return QSize(16, 16);
case 2:
return QSize(32, 32);
case 3:
return QSize(48, 48);
case 1:
default:
return QSize(24, 24);
}
}
}; // class SimulatorIcon
} // namespace Simulator
struct SimulatorOptions
{
@@ -54,14 +123,18 @@ struct SimulatorOptions
QString dataFile;
QString dataFolder;
QString sdPath;
QByteArray windowGeometry;
QByteArray windowGeometry; // SimulatorMainWindow geometry
QList<QByteArray> controlsState; // saved switch/pot/stick settings
QColor lcdColor;
// added in v2
QByteArray windowState; // SimulatorMainWindow dock/toolbar/options UI state
QByteArray dbgConsoleState; // DebugOutput UI state
QByteArray radioOutputsState; // RadioOutputsWidget UI state
friend QDataStream & operator << (QDataStream &out, const SimulatorOptions & o)
{
out << quint16(SIMULATOR_OPTIONS_VERSION) << o.startupDataType << o.firmwareId << o.dataFile << o.dataFolder
<< o.sdPath << o.windowGeometry << o.controlsState << o.lcdColor;
<< o.sdPath << o.windowGeometry << o.controlsState << o.lcdColor << o.windowState << o.dbgConsoleState << o.radioOutputsState;
return out;
}
@@ -70,6 +143,8 @@ struct SimulatorOptions
if (o._version <= SIMULATOR_OPTIONS_VERSION) {
in >> o._version >> o.startupDataType >> o.firmwareId >> o.dataFile >> o.dataFolder
>> o.sdPath >> o.windowGeometry >> o.controlsState >> o.lcdColor;
if (o._version >= 2)
in >> o.windowState >> o.dbgConsoleState >> o.radioOutputsState;
}
return in;
}