[Simulator] Further Simulator improvements. (#4282)

* Refactor CompStoreObj to use templates. Clean up some formatting.

* [Simulator] Add SimulatorOptions type to replace individual simulator options; Fix storage handler for custom types; Cleanup some redundant code.

* [Simulator][Joystick] Rework the joystick options/calibration dialog.  Can now enable/disable/select the Joystick from there. Delay start of calibration until Start is pressed (otherwise looks like last calibration didn't work). And generally refactor a lot of it to be smarter.

* Cosmetics.

* [Simulator] Add state handling for RadioWidget class. Split code to cpp file.

* [Simulator] Add SimulatorStartupDialog as its own UI class.

* [Simulator] Multiple changes and new features:
    All Horus data source options are now fully supported with data properly saved after use (SD path, .otx file, or custom data path);
    Loading .otx files now works for all radio types (but not saving data back to .otx);
    Switch and knob/slider states are now saved to per radio profile;
    Joystick configuration/calibration is now available directly from inside Simulator;
    Due to refactoring, all previously saved per-profile simulator settings are now invalid;
    Further consolidated simulator dialog startup/shutdown, now handles temp. paths internally, etc;
    With WIN_USE_CONSOLE defined, Simulator and Companion when started from Windows command line will now use that console for all messages (instead of opening a new one). This allows full debug output to be seen at all stages of execution and after exit.

* [Simulator] Fix build w/out SDL Joystick support.

* [Simulator] Fix bogus throttle warning on simulator start; Add forgotten RadioWidgetState flags to stream handlers; Add debug state saver in SimulatorOptions.
This commit is contained in:
Max Paperno
2017-01-25 16:20:45 +01:00
committed by Bertrand Songis
parent b53ec7392c
commit 6e2474081f
22 changed files with 2869 additions and 1785 deletions
@@ -0,0 +1,357 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SimulatorStartupDialog</class>
<widget class="QDialog" name="SimulatorStartupDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>219</height>
</rect>
</property>
<property name="windowTitle">
<string>OpenTX Simulator - Startup Options</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Simulator Startup Options:</string>
</property>
<layout class="QFormLayout" name="layout_options">
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="horizontalSpacing">
<number>5</number>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>7</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Radio Profile:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="radioProfile">
<property name="toolTip">
<string>Existing radio profiles are shown here.&lt;br /&gt;
Create or edit profiles using the Companion application.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Radio Type:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="radioType">
<property name="toolTip">
<string>Existing radio simulators are shown here.&lt;br /&gt;
The radio type specified in the selected profile is used by default.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Data Source:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Data File:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Data Folder:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>SD Image Path:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="wdgt_dataFile" native="true">
<layout class="QHBoxLayout" name="layout_dataFile" stretch="1,0">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="dataFile">
<property name="toolTip">
<string>Radio data (.bin/.eeprom/.otx) image file to use. A new file with a default image will be created if necessary.&lt;br /&gt;
&lt;b&gt;NOTE&lt;/b&gt;: any existing EEPROM data incompatible with the selected radio type may be overwritten!</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSelectDataFile">
<property name="toolTip">
<string>Select data file...</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../companion.qrc">
<normaloff>:/themes/monoblue/16/open.png</normaloff>:/themes/monoblue/16/open.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QWidget" name="wdgt_dataFolder" native="true">
<layout class="QHBoxLayout" name="layout_dataFolder" stretch="1,0">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="dataFolder">
<property name="toolTip">
<string>Directory containing RADIO and MODELS folders to use.&lt;br /&gt;
New folder(s) with default radio/model will be created here if necessary.</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSelectDataFolder">
<property name="toolTip">
<string>Select data folder...</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../companion.qrc">
<normaloff>:/themes/monoblue/16/open.png</normaloff>:/themes/monoblue/16/open.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="1">
<widget class="QWidget" name="wdgt_sdPath" native="true">
<layout class="QHBoxLayout" name="layout_sdPath" stretch="1,0">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="sdPath">
<property name="toolTip">
<string>Directory containing the SD card image to use.&lt;br/&gt;
The default is configured in the chosen Radio Profile.</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnSelectSdPath">
<property name="toolTip">
<string>Select SD card image folder...</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../companion.qrc">
<normaloff>:/themes/monoblue/16/open.png</normaloff>:/themes/monoblue/16/open.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="wdgt_dataSource" native="true">
<property name="toolTip">
<string>Select which of the data sources (File/Folder/SD Card) you would like to start the simulator with.</string>
</property>
<layout class="QHBoxLayout" name="layout_dataSource">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="optFile">
<property name="text">
<string>File</string>
</property>
<attribute name="buttonGroup">
<string notr="true">optGrp_dataSource</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="optFolder">
<property name="text">
<string>Folder</string>
</property>
<attribute name="buttonGroup">
<string notr="true">optGrp_dataSource</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="optSdPath">
<property name="text">
<string>SD Path</string>
</property>
<attribute name="buttonGroup">
<string notr="true">optGrp_dataSource</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<zorder>groupBox</zorder>
<zorder>buttonBox</zorder>
</widget>
<resources>
<include location="../companion.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SimulatorStartupDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SimulatorStartupDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="optGrp_dataSource"/>
</buttongroups>
</ui>