[Simulator] Further improvements (reload radio, momentary switches, etc.) (#4303)

* [Simulator] Add ability to reload all radio data w/out exiting simulator (will also adjust UI for any hardware changes); Refactor how keymap help text is generated.

* [Simulator] Only update channel/logical switch/GVar output displays if the corresponding tab is actually visible (further CPU usage reductions).

* [Simulator] Implement momentary toggle switches with "latch" function.

* [Simulator] Mouse wheel event over multi-position knobs now properly rotates them to detent positions.

* [Simulator] Fix mouse wheel event propagation after multi-position knob rotation; Cosmetics.

* [Simulator] Internals: Greatly improve object cleanup on exit; Refactor SimulatedUIWidget timer event triggering.

* [Simulator] Fix throttle stick position/lock not being set properly upon repeated launches from Companion.

* [Simulator] Fix build w/out SDL. KnobWidget cleanup.

* [Companion] Do NOT delete SimulatorInterface on simulator dialog exit (fix possible crash on dialog close).

* [Simulator] Ensure joystick is NULL at start.

* [Simulator] Fix/improve color blending on 4-bit screens with different BG colors; Cosmetics.

* [Simulator] Fix LCD screenshot folder path; Fix timer slot for Qt backwards compatibility.

* [TravisCI] Set Qt version to 5.3 to match release build servers.

* Fixed segfault when saving setup with no models defined [Horus]

* Fixed radio data import [Horus] (broken in 0f90ff0b65)

* [Simulator] Always keep toggle switch active while held with mouse button.
This commit is contained in:
Max Paperno
2017-01-28 13:43:56 +01:00
committed by Bertrand Songis
parent f40e64c2aa
commit de68db0905
16 changed files with 539 additions and 298 deletions
@@ -68,29 +68,27 @@ class RadioKnobWidget : public RadioWidget
class KnobWidget : public QDial
{
friend class RadioKnobWidget;
public:
explicit KnobWidget(Board::PotType type, QWidget * parent = 0):
QDial(parent),
m_type(type),
m_positions(type == Board::POT_MULTIPOS_SWITCH ? 5 : 0)
QDial(parent)
{
setToolTip(tr("Right-double-click to reset to center."));
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setFixedSize(QSize(42, 42));
setMinimum(-1024);
setMaximum(1024);
setNotchesVisible(true);
if (m_positions) {
if (type == Board::POT_MULTIPOS_SWITCH) {
m_stepSize = 2048 / 5;
// this is a bit of a hack to get the notch markers to display correctly
// the actual notches/value are constrained in setValue()
setSingleStep(2048 / m_positions / 10);
setPageStep(2048 / m_positions);
setSingleStep(m_stepSize / 10);
setPageStep(m_stepSize);
setNotchTarget(5.7);
}
else {
m_stepSize = 1;
setToolTip(tr("Right-double-click to reset to center."));
setPageStep(128);
setNotchTarget(64);
}
@@ -98,15 +96,15 @@ class RadioKnobWidget : public RadioWidget
void setValue(int value)
{
if (m_positions) {
value = ((int)roundf((value + 1024) / (2048.0f / m_positions)) * (2048.0f / m_positions) - 1024);
if (m_stepSize > 1) {
value = (value + 1024) / m_stepSize * m_stepSize - 1024;
}
QDial::setValue(value);
}
void mousePressEvent(QMouseEvent * event)
{
if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) {
if (m_stepSize == 1 && event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) {
setValue(0);
event->accept();
return;
@@ -114,8 +112,21 @@ class RadioKnobWidget : public RadioWidget
QDial::mousePressEvent(event);
}
Board::PotType m_type;
quint8 m_positions;
void wheelEvent(QWheelEvent * event)
{
if (event->angleDelta().isNull())
return;
if (m_stepSize > 1) {
int numSteps = event->angleDelta().y() / 8 / 15 * m_stepSize; // one step per 15deg
setValue(value() + numSteps);
event->accept();
return;
}
QDial::wheelEvent(event);
}
quint16 m_stepSize;
};
};