* Move simulator widgets to subfolder (no code changes).
* [Simulator] Major Simulator re-structuring to reduce code redundancies and allow for fully dynamic simulated hardware setup:
SimulatorDialog is no longer sub-classed by individual radio UIs, instead a new class is added which handles just the "skin," LCD, and navigation controls (also makes setting up new models much quicker);
All radio switches/knobs/sliders are populated dynamically based on loaded hardware configuration data (eeprom/bin), including control types and names (in case of no hardware config data, reasonable "factory defaults" are loaded);
Starting Horus sim with alternate path for RADIO and MODEL data folders is now supported (.otx file is WIP);
6-way switch now works properly and various other inconsistencies addressed (eg. some Horus analogs were backwards).
* Add missing OpenTX headers to new files.
* [Simulator] Fix loading of Horus hardware settings from Companion simulation.
* Update Travis CI build environment to Qt 5.7.
* [Simulator] Fix 9X missing colored side LCD images, an #include fix, and some cleanup.
* [TravisCI] Set up for parallel Travis builds and use Qt5.7 (#4263)
* Fix starting Simulator with non-existing file/folder structure (now properly creates new ones as needed, including Horus directories with default radio/model); Temporarily remove option for using .otx file with Horus (until that feature is added).
* Load correct simulator skin for X7 when launching from Companion.
* X7 hardware defaults changed to match production hardware
* Fix minor compiler warning in mdichild.cpp, and some cleanup in eeprominterface.cpp.
* [Simulator] Centralize radio UI flavor determination.
* [Simulator] Updates:
Add X7 UI flavor;
Centralize LCD settings;
Simplify drawing curved UI widgets;
LCD color can be changed for any 1/4-bit display radio;
Slight change on default LCD "off" color;
Refactor LcdWidget to not use globals.
* [Companion] X7 EEPROM import fix
+ cosmetics
+ compilation error fixed on Manjaro
* [Companion] 9XR-PRO EEPROM import fix
+ cosmetics
+ compilation error fixed on Manjaro
* Navigation fix
French translations
* [X7] Main view cosmetics
* Fix switch/ana custom name import
* [Simulator] Add white border above/below X7 bezel, and use white-colored padding on sides; Adjust X7 default LCD color.
* Does this work? (#4269)
Read an Horus SD card produces a temporary .otx file now
* Bsongis/companion warning before automatic conversions (#4271)
* Does this work?
* Warning before automatic conversions
* Force different file name after conversion (#4272)
* Force different file name after conversion
* More detailed instructions
* [Companion] Files automatically named during XXX => Horus conversions
128 lines
3.4 KiB
C++
128 lines
3.4 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef _RADIOKNOBWIDGET_H_
|
|
#define _RADIOKNOBWIDGET_H_
|
|
|
|
#include "radiowidget.h"
|
|
#include "radiodata.h"
|
|
|
|
#include <QDial>
|
|
#include <QMouseEvent>
|
|
#include <QDebug>
|
|
#include <math.h>
|
|
|
|
class RadioKnobWidget : public RadioWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
using potType_t = GeneralSettings::PotConfig;
|
|
|
|
explicit RadioKnobWidget(potType_t type = potType_t::POT_WITH_DETENT, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
|
RadioWidget(parent, f),
|
|
m_potType(type)
|
|
{
|
|
init();
|
|
}
|
|
explicit RadioKnobWidget(potType_t type, const QString &labelText, int value = 0, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()) :
|
|
RadioWidget(labelText, value, parent, f),
|
|
m_potType(type)
|
|
{
|
|
init();
|
|
}
|
|
|
|
void init()
|
|
{
|
|
m_type = RADIO_WIDGET_KNOB;
|
|
|
|
KnobWidget * pot = new KnobWidget(m_potType, this);
|
|
pot->setValue(m_value);
|
|
|
|
connect(pot, &KnobWidget::valueChanged, this, &RadioWidget::setValue);
|
|
connect(this, &RadioWidget::valueChanged, pot, &KnobWidget::setValue);
|
|
|
|
setWidget(pot);
|
|
}
|
|
|
|
private:
|
|
|
|
potType_t m_potType;
|
|
|
|
|
|
class KnobWidget : public QDial
|
|
{
|
|
friend class RadioKnobWidget;
|
|
using potType_t = RadioKnobWidget::potType_t;
|
|
|
|
public:
|
|
|
|
explicit KnobWidget(potType_t type, QWidget * parent = 0):
|
|
QDial(parent),
|
|
m_type(type),
|
|
m_positions(type == potType_t::POT_MULTIPOS_SWITCH ? 5 : 0)
|
|
{
|
|
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) {
|
|
// 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);
|
|
setNotchTarget(5.7);
|
|
}
|
|
else {
|
|
setPageStep(128);
|
|
setNotchTarget(64);
|
|
}
|
|
}
|
|
|
|
void setValue(int value)
|
|
{
|
|
if (m_positions) {
|
|
value = ((int)roundf((value + 1024) / (2048.0f / m_positions)) * (2048.0f / m_positions) - 1024);
|
|
}
|
|
QDial::setValue(value);
|
|
}
|
|
|
|
void mousePressEvent(QMouseEvent * event)
|
|
{
|
|
if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) {
|
|
setValue(0);
|
|
event->accept();
|
|
return;
|
|
}
|
|
QDial::mousePressEvent(event);
|
|
}
|
|
|
|
potType_t m_type;
|
|
quint8 m_positions;
|
|
};
|
|
|
|
};
|
|
|
|
|
|
#endif // _RADIOKNOBWIDGET_H_
|