1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-17 21:35:27 +03:00

GeneralEdit class splitted as done previously for ModelEdit

This commit is contained in:
bsongis 2014-09-17 17:27:28 +02:00
parent 2f8b9347a4
commit 343e395652
23 changed files with 5094 additions and 4906 deletions

View file

@ -105,6 +105,7 @@ include_directories(
)
add_subdirectory(modeledit)
add_subdirectory(generaledit)
add_subdirectory(simulation)
set(common_SRCS
@ -145,7 +146,6 @@ set(companion_SRCS
# ${PROJECT_BINARY_DIR}/radio.cxx
helpers.cpp
mdichild.cpp
generaledit.cpp
modelslist.cpp
mountlist.cpp
avroutputdialog.cpp
@ -184,7 +184,6 @@ set(companion_MOC_HDRS
splashlabel.h
burndialog.h
downloaddialog.h
generaledit.h
modelslist.h
mdichild.h
mainwindow.h
@ -205,7 +204,6 @@ set(companion_UIS
fwpreferencesdialog.ui
burnconfigdialog.ui
downloaddialog.ui
generaledit.ui
printdialog.ui
contributorsdialog.ui
customizesplashdialog.ui
@ -283,7 +281,7 @@ ELSE( )
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion_SRCS} ${companion_QM} )
ENDIF( )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} modeledit simulation common ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} )
TARGET_LINK_LIBRARIES( ${PROJECT_NAME} generaledit modeledit simulation common ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} )
############# Standalone simu ###############

File diff suppressed because it is too large Load diff

View file

@ -1,143 +0,0 @@
#ifndef GENERALEDIT_H
#define GENERALEDIT_H
#include <QDialog>
#include "eeprominterface.h"
namespace Ui {
class GeneralEdit;
}
class GeneralEdit : public QDialog
{
Q_OBJECT
public:
explicit GeneralEdit(RadioData &radioData, QWidget *parent = 0);
~GeneralEdit();
void updateSettings();
private:
Ui::GeneralEdit *ui;
RadioData &radioData;
GeneralSettings g_eeGeneral;
bool switchDefPosEditLock;
bool voiceLangEditLock;
bool mavbaudEditLock;
void getGeneralSwitchDefPos(int i, bool val);
void setSwitchDefPos();
void updateVarioPitchRange();
void disableMouseScrolling();
protected:
virtual bool eventFilter(QObject *obj, QEvent *event);
signals:
void modelValuesChanged();
private slots:
void on_faimode_CB_stateChanged(int );
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_hapticStrength_valueChanged();
void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished();
void on_hapticmodeCB_currentIndexChanged(int index);
void on_hapticLengthCB_currentIndexChanged(int index);
void on_PPM_MultiplierDSB_editingFinished();
void on_splashScreenChkB_stateChanged(int);
void on_splashScreenDuration_currentIndexChanged(int index);
void on_alarmwarnChkB_stateChanged(int );
void on_gpsFormatCB_currentIndexChanged(int index);
void on_tabWidget_currentChanged(int index);
void on_displayTypeCB_currentIndexChanged(int index);
void on_BLBright_SB_editingFinished();
void on_backlightColor_SL_valueChanged();
void on_re_CB_currentIndexChanged(int index);
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_trnMode_1_currentIndexChanged(int index);
void on_trnChn_1_currentIndexChanged(int index);
void on_trnWeight_1_editingFinished();
void on_trnMode_2_currentIndexChanged(int index);
void on_trnChn_2_currentIndexChanged(int index);
void on_trnWeight_2_editingFinished();
void on_trnMode_3_currentIndexChanged(int index);
void on_trnChn_3_currentIndexChanged(int index);
void on_trnWeight_3_editingFinished();
void on_trnMode_4_currentIndexChanged(int index);
void on_trnChn_4_currentIndexChanged(int index);
void on_trnWeight_4_editingFinished();
void on_CurrentCalib_SB_editingFinished();
void on_ana1Neg_editingFinished();
void on_ana2Neg_editingFinished();
void on_ana3Neg_editingFinished();
void on_ana4Neg_editingFinished();
void on_ana5Neg_editingFinished();
void on_ana6Neg_editingFinished();
void on_ana7Neg_editingFinished();
void on_ana8Neg_editingFinished();
void on_ana1Mid_editingFinished();
void on_ana2Mid_editingFinished();
void on_ana3Mid_editingFinished();
void on_ana4Mid_editingFinished();
void on_ana5Mid_editingFinished();
void on_ana6Mid_editingFinished();
void on_ana7Mid_editingFinished();
void on_ana8Mid_editingFinished();
void on_ana1Pos_editingFinished();
void on_ana2Pos_editingFinished();
void on_ana3Pos_editingFinished();
void on_ana4Pos_editingFinished();
void on_ana5Pos_editingFinished();
void on_ana6Pos_editingFinished();
void on_ana7Pos_editingFinished();
void on_ana8Pos_editingFinished();
void on_PPM1_editingFinished();
void on_PPM2_editingFinished();
void on_PPM3_editingFinished();
void on_PPM4_editingFinished();
void on_beepVolume_SL_valueChanged();
void on_bgVolume_SL_valueChanged();
void on_varioVolume_SL_valueChanged();
void on_wavVolume_SL_valueChanged();
void on_varioP0_SB_editingFinished();
void on_varioPMax_SB_editingFinished();
void on_varioR0_SB_editingFinished();
void on_pot1Type_currentIndexChanged(int index);
void on_pot2Type_currentIndexChanged(int index);
void on_pot3Type_currentIndexChanged(int index);
void on_serialPortMode_currentIndexChanged(int index);
void on_stickmodeCB_currentIndexChanged(int index);
void on_channelorderCB_currentIndexChanged(int index);
void on_beeperCB_currentIndexChanged(int index);
void on_memwarnChkB_stateChanged(int );
void on_inactimerSB_editingFinished();
void on_backlightautoSB_editingFinished();
void on_backlightswCB_currentIndexChanged(int index);
void on_mavbaud_CB_currentIndexChanged(int index);
void on_voiceLang_CB_currentIndexChanged(int index);
void on_battCalibDSB_editingFinished();
void on_battwarningDSB_editingFinished();
void on_contrastSB_editingFinished();
void on_calretrieve_PB_clicked();
void on_calstore_PB_clicked();
void unlockSwitchEdited();
void setValues();
void shrink();
void stickReverseEdited();
void on_switchesDelay_valueChanged();
void on_blAlarm_ChkB_stateChanged();
};
#endif // GENERALEDIT_H

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(generaledit_NAMES
generaledit
setup
trainer
calibration
)
set(generaledit_SRCS
)
set(generaledit_HDRS
)
set(generaledit_UIS
)
foreach(name ${generaledit_NAMES})
set(generaledit_SRCS ${generaledit_SRCS} ${name}.cpp)
set(generaledit_HDRS ${generaledit_HDRS} ${name}.h)
set(generaledit_UIS ${generaledit_UIS} ${name}.ui)
endforeach()
qt4_wrap_ui(generaledit_SRCS ${generaledit_UIS})
qt4_wrap_cpp(generaledit_SRCS ${generaledit_HDRS})
add_library(generaledit ${generaledit_SRCS})

View file

@ -0,0 +1,299 @@
#include "calibration.h"
#include "ui_calibration.h"
CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::Calibration)
{
ui->setupUi(this);
if (firmware->getCapability(MultiposPots)) {
ui->pot1Type->setCurrentIndex(generalSettings.potsType[0]);
ui->pot2Type->setCurrentIndex(generalSettings.potsType[1]);
ui->pot3Type->setCurrentIndex(generalSettings.potsType[2]);
}
else {
ui->potsTypeSeparator->hide();
ui->pot1Type->hide();
ui->pot1TypeLabel->hide();
ui->pot2Type->hide();
ui->pot2TypeLabel->hide();
ui->pot3Type->hide();
ui->pot3TypeLabel->hide();
}
int potsCount = GetCurrentFirmware()->getCapability(Pots);
if (potsCount == 3) {
ui->label_pot4->hide();
ui->ana8Neg->hide();
ui->ana8Mid->hide();
ui->ana8Pos->hide();
}
if (IS_TARANIS(firmware->getBoard())) {
ui->serialPortMode->setCurrentIndex(generalSettings.hw_uartMode);
}
else {
ui->serialPortMode->hide();
ui->serialPortLabel->hide();
}
disableMouseScrolling();
}
CalibrationPanel::~CalibrationPanel()
{
delete ui;
}
void CalibrationPanel::on_PPM_MultiplierDSB_editingFinished()
{
generalSettings.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10;
emit modified();
}
void CalibrationPanel::on_PPM1_editingFinished()
{
generalSettings.trainer.calib[0] = ui->PPM1->value();
emit modified();
}
void CalibrationPanel::on_PPM2_editingFinished()
{
generalSettings.trainer.calib[1] = ui->PPM2->value();
emit modified();
}
void CalibrationPanel::on_PPM3_editingFinished()
{
generalSettings.trainer.calib[2] = ui->PPM3->value();
emit modified();
}
void CalibrationPanel::on_PPM4_editingFinished()
{
generalSettings.trainer.calib[3] = ui->PPM4->value();
emit modified();
}
void CalibrationPanel::on_CurrentCalib_SB_editingFinished()
{
generalSettings.currentCalib = ui->CurrentCalib_SB->value();
emit modified();
}
void CalibrationPanel::setValues()
{
ui->battCalibDSB->setValue((double)generalSettings.vBatCalib/10);
ui->CurrentCalib_SB->setValue((double)generalSettings.currentCalib);
ui->ana1Neg->setValue(generalSettings.calibSpanNeg[0]);
ui->ana2Neg->setValue(generalSettings.calibSpanNeg[1]);
ui->ana3Neg->setValue(generalSettings.calibSpanNeg[2]);
ui->ana4Neg->setValue(generalSettings.calibSpanNeg[3]);
ui->ana5Neg->setValue(generalSettings.calibSpanNeg[4]);
ui->ana6Neg->setValue(generalSettings.calibSpanNeg[5]);
ui->ana7Neg->setValue(generalSettings.calibSpanNeg[6]);
ui->ana8Neg->setValue(generalSettings.calibSpanNeg[7]);
ui->ana1Mid->setValue(generalSettings.calibMid[0]);
ui->ana2Mid->setValue(generalSettings.calibMid[1]);
ui->ana3Mid->setValue(generalSettings.calibMid[2]);
ui->ana4Mid->setValue(generalSettings.calibMid[3]);
ui->ana5Mid->setValue(generalSettings.calibMid[4]);
ui->ana6Mid->setValue(generalSettings.calibMid[5]);
ui->ana7Mid->setValue(generalSettings.calibMid[6]);
ui->ana8Mid->setValue(generalSettings.calibMid[7]);
ui->ana1Pos->setValue(generalSettings.calibSpanPos[0]);
ui->ana2Pos->setValue(generalSettings.calibSpanPos[1]);
ui->ana3Pos->setValue(generalSettings.calibSpanPos[2]);
ui->ana4Pos->setValue(generalSettings.calibSpanPos[3]);
ui->ana5Pos->setValue(generalSettings.calibSpanPos[4]);
ui->ana6Pos->setValue(generalSettings.calibSpanPos[5]);
ui->ana7Pos->setValue(generalSettings.calibSpanPos[6]);
ui->ana8Pos->setValue(generalSettings.calibSpanPos[7]);
ui->PPM1->setValue(generalSettings.trainer.calib[0]);
ui->PPM2->setValue(generalSettings.trainer.calib[1]);
ui->PPM3->setValue(generalSettings.trainer.calib[2]);
ui->PPM4->setValue(generalSettings.trainer.calib[3]);
ui->PPM_MultiplierDSB->setValue((qreal)(generalSettings.PPM_Multiplier+10)/10);
}
void CalibrationPanel::on_battCalibDSB_editingFinished()
{
generalSettings.vBatCalib = ui->battCalibDSB->value()*10;
emit modified();
}
void CalibrationPanel::on_ana1Neg_editingFinished()
{
generalSettings.calibSpanNeg[0] = ui->ana1Neg->value();
emit modified();
}
void CalibrationPanel::on_ana2Neg_editingFinished()
{
generalSettings.calibSpanNeg[1] = ui->ana2Neg->value();
emit modified();
}
void CalibrationPanel::on_ana3Neg_editingFinished()
{
generalSettings.calibSpanNeg[2] = ui->ana3Neg->value();
emit modified();
}
void CalibrationPanel::on_ana4Neg_editingFinished()
{
generalSettings.calibSpanNeg[3] = ui->ana4Neg->value();
emit modified();
}
void CalibrationPanel::on_ana5Neg_editingFinished()
{
generalSettings.calibSpanNeg[4] = ui->ana5Neg->value();
emit modified();
}
void CalibrationPanel::on_ana6Neg_editingFinished()
{
generalSettings.calibSpanNeg[5] = ui->ana6Neg->value();
emit modified();
}
void CalibrationPanel::on_ana7Neg_editingFinished()
{
generalSettings.calibSpanNeg[6] = ui->ana7Neg->value();
emit modified();
}
void CalibrationPanel::on_ana8Neg_editingFinished()
{
generalSettings.calibSpanNeg[7] = ui->ana8Neg->value();
emit modified();
}
void CalibrationPanel::on_ana1Mid_editingFinished()
{
generalSettings.calibMid[0] = ui->ana1Mid->value();
emit modified();
}
void CalibrationPanel::on_ana2Mid_editingFinished()
{
generalSettings.calibMid[1] = ui->ana2Mid->value();
emit modified();
}
void CalibrationPanel::on_ana3Mid_editingFinished()
{
generalSettings.calibMid[2] = ui->ana3Mid->value();
emit modified();
}
void CalibrationPanel::on_ana4Mid_editingFinished()
{
generalSettings.calibMid[3] = ui->ana4Mid->value();
emit modified();
}
void CalibrationPanel::on_ana5Mid_editingFinished()
{
generalSettings.calibMid[4] = ui->ana5Mid->value();
emit modified();
}
void CalibrationPanel::on_ana6Mid_editingFinished()
{
generalSettings.calibMid[5] = ui->ana6Mid->value();
emit modified();
}
void CalibrationPanel::on_ana7Mid_editingFinished()
{
generalSettings.calibMid[6] = ui->ana7Mid->value();
emit modified();
}
void CalibrationPanel::on_ana8Mid_editingFinished()
{
generalSettings.calibMid[7] = ui->ana8Mid->value();
emit modified();
}
void CalibrationPanel::on_ana1Pos_editingFinished()
{
generalSettings.calibSpanPos[0] = ui->ana1Pos->value();
emit modified();
}
void CalibrationPanel::on_ana2Pos_editingFinished()
{
generalSettings.calibSpanPos[1] = ui->ana2Pos->value();
emit modified();
}
void CalibrationPanel::on_ana3Pos_editingFinished()
{
generalSettings.calibSpanPos[2] = ui->ana3Pos->value();
emit modified();
}
void CalibrationPanel::on_ana4Pos_editingFinished()
{
generalSettings.calibSpanPos[3] = ui->ana4Pos->value();
emit modified();
}
void CalibrationPanel::on_ana5Pos_editingFinished()
{
generalSettings.calibSpanPos[4] = ui->ana5Pos->value();
emit modified();
}
void CalibrationPanel::on_ana6Pos_editingFinished()
{
generalSettings.calibSpanPos[5] = ui->ana6Pos->value();
emit modified();
}
void CalibrationPanel::on_ana7Pos_editingFinished()
{
generalSettings.calibSpanPos[6] = ui->ana7Pos->value();
emit modified();
}
void CalibrationPanel::on_ana8Pos_editingFinished()
{
generalSettings.calibSpanPos[7] = ui->ana8Pos->value();
emit modified();
}
void CalibrationPanel::on_pot1Type_currentIndexChanged(int index)
{
generalSettings.potsType[0] = index;
emit modified();
}
void CalibrationPanel::on_pot2Type_currentIndexChanged(int index)
{
generalSettings.potsType[1] = index;
emit modified();
}
void CalibrationPanel::on_pot3Type_currentIndexChanged(int index)
{
generalSettings.potsType[2] = index;
emit modified();
}
void CalibrationPanel::on_serialPortMode_currentIndexChanged(int index)
{
generalSettings.hw_uartMode = index;
emit modified();
}

View file

@ -0,0 +1,67 @@
#ifndef CALIBRATION_H
#define CALIBRATION_H
#include "generaledit.h"
namespace Ui {
class Calibration;
}
class CalibrationPanel : public GeneralPanel
{
Q_OBJECT
public:
CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~CalibrationPanel();
private slots:
void on_battCalibDSB_editingFinished();
void on_PPM1_editingFinished();
void on_PPM2_editingFinished();
void on_PPM3_editingFinished();
void on_PPM4_editingFinished();
void on_PPM_MultiplierDSB_editingFinished();
void on_CurrentCalib_SB_editingFinished();
void on_ana1Neg_editingFinished();
void on_ana2Neg_editingFinished();
void on_ana3Neg_editingFinished();
void on_ana4Neg_editingFinished();
void on_ana5Neg_editingFinished();
void on_ana6Neg_editingFinished();
void on_ana7Neg_editingFinished();
void on_ana8Neg_editingFinished();
void on_ana1Mid_editingFinished();
void on_ana2Mid_editingFinished();
void on_ana3Mid_editingFinished();
void on_ana4Mid_editingFinished();
void on_ana5Mid_editingFinished();
void on_ana6Mid_editingFinished();
void on_ana7Mid_editingFinished();
void on_ana8Mid_editingFinished();
void on_ana1Pos_editingFinished();
void on_ana2Pos_editingFinished();
void on_ana3Pos_editingFinished();
void on_ana4Pos_editingFinished();
void on_ana5Pos_editingFinished();
void on_ana6Pos_editingFinished();
void on_ana7Pos_editingFinished();
void on_ana8Pos_editingFinished();
void on_pot1Type_currentIndexChanged(int index);
void on_pot2Type_currentIndexChanged(int index);
void on_pot3Type_currentIndexChanged(int index);
void on_serialPortMode_currentIndexChanged(int index);
private:
Ui::Calibration *ui;
void setValues();
};
#endif // CALIBRATION_H

View file

@ -0,0 +1,863 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Calibration</class>
<widget class="QWidget" name="Calibration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>717</width>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0" columnstretch="0,1,1,1,0,0,1,1,1">
<item row="1" column="7">
<widget class="QSpinBox" name="ana5Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QLabel" name="label_pot4">
<property name="text">
<string>Pot. 4</string>
</property>
</widget>
</item>
<item row="1" column="4" rowspan="4">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QLabel" name="label_pot3">
<property name="text">
<string>Pot. 3</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QSpinBox" name="ana5Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QLabel" name="label_pot2">
<property name="text">
<string>Pot. 2</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="label_pot1">
<property name="text">
<string>Pot. 1</string>
</property>
</widget>
</item>
<item row="19" column="1">
<widget class="QDoubleSpinBox" name="PPM_MultiplierDSB">
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>5.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>PPM 1</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Stick 3</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Negative span</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Mid value</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Positive span</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Stick 1</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="ana1Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="ana1Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="ana1Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Stick 2</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="ana2Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="ana2Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="ana2Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="ana3Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="ana3Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="ana3Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Stick 4</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="ana4Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QSpinBox" name="ana4Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="ana4Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="20" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Battery</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QDoubleSpinBox" name="battCalibDSB">
<property name="statusTip">
<string/>
</property>
<property name="suffix">
<string>v</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>-9.900000000000000</double>
</property>
<property name="maximum">
<double>9.900000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_30">
<property name="text">
<string>PPM Multiplier</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="4">
<widget class="Line" name="line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QSpinBox" name="PPM2">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="17" column="1">
<widget class="QSpinBox" name="PPM3">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="18" column="1">
<widget class="QSpinBox" name="PPM4">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QSpinBox" name="PPM1">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="16" column="0">
<widget class="QLabel" name="label_33">
<property name="text">
<string>PPM 2</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_34">
<property name="text">
<string>PPM 3</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_35">
<property name="text">
<string>PPM 4</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="CurrentCalib_SB">
<property name="minimum">
<number>-49</number>
</property>
<property name="maximum">
<number>49</number>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_CurrentCalib">
<property name="text">
<string>Current</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QSpinBox" name="ana5Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QSpinBox" name="ana6Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="7">
<widget class="QSpinBox" name="ana6Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="2" column="8">
<widget class="QSpinBox" name="ana6Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="6">
<widget class="QSpinBox" name="ana7Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="7">
<widget class="QSpinBox" name="ana7Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="3" column="8">
<widget class="QSpinBox" name="ana7Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="6">
<widget class="QSpinBox" name="ana8Neg">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="7">
<widget class="QSpinBox" name="ana8Mid">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="4" column="8">
<widget class="QSpinBox" name="ana8Pos">
<property name="statusTip">
<string/>
</property>
<property name="minimum">
<number>-9999</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="label">
<property name="text">
<string>Negative span</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Mid value</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Positive span</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<widget class="Line" name="potsTypeSeparator">
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="pot1Type">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
<property name="text">
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="pot1TypeLabel">
<property name="text">
<string>S1 Type</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="pot2Type">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
<property name="text">
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="pot2TypeLabel">
<property name="text">
<string>S2 Type</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="pot3TypeLabel">
<property name="text">
<string>S3 Type</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QComboBox" name="pot3Type">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Pot with detent (normal)</string>
</property>
</item>
<item>
<property name="text">
<string>Multipos Switch</string>
</property>
</item>
<item>
<property name="text">
<string>Pot without detent</string>
</property>
</item>
</widget>
</item>
<item row="6" column="3">
<widget class="QComboBox" name="serialPortMode">
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
<item>
<property name="text">
<string>S-Port Mirror</string>
</property>
</item>
<item>
<property name="text">
<string>Debug</string>
</property>
</item>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="serialPortLabel">
<property name="text">
<string>Serial Port</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -0,0 +1,239 @@
#include <QDateTime>
#include <QtGui>
#include <QScrollArea>
#include "generaledit.h"
#include "ui_generaledit.h"
#include "helpers.h"
#include "appdata.h"
#include "setup.h"
#include "trainer.h"
#include "calibration.h"
GeneralPanel::GeneralPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GenericPanel(parent),
generalSettings(generalSettings),
firmware(firmware)
{
}
GeneralPanel::~GeneralPanel()
{
}
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, FirmwareInterface * firmware) :
QDialog(parent),
ui(new Ui::GeneralEdit),
generalSettings(radioData.generalSettings),
firmware(firmware)
{
ui->setupUi(this);
this->setWindowIcon(CompanionIcon("open.png"));
QString firmware_id = g.profile[g.id()].fwType();
ui->tabWidget->setCurrentIndex( g.generalEditTab() );
QString name=g.profile[g.id()].name();
if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true);
}
ui->profile_CB->clear();
for (int i=0; i<MAX_PROFILES; ++i) {
QString name=g.profile[i].name();
if (!name.isEmpty()) {
ui->profile_CB->addItem(name, i);
if (i==g.id()) {
ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1);
}
}
}
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
}
GeneralEdit::~GeneralEdit()
{
delete ui;
}
void GeneralEdit::addTab(GeneralPanel *panel, QString text)
{
panels << panel;
QWidget * widget = new QWidget(ui->tabWidget);
QVBoxLayout *baseLayout = new QVBoxLayout(widget);
VerticalScrollArea * area = new VerticalScrollArea(widget, panel);
baseLayout->addWidget(area);
ui->tabWidget->addTab(widget, text);
connect(panel, SIGNAL(modified()), this, SLOT(onTabModified()));
}
void GeneralEdit::onTabModified()
{
emit modified();
}
void GeneralEdit::on_tabWidget_currentChanged(int index)
{
g.generalEditTab(index);
}
void GeneralEdit::on_calretrieve_PB_clicked()
{
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
QString calib=g.profile[profile_id].stickPotCalib();
int potsnum=GetCurrentFirmware()->getCapability(Pots);
if (calib.isEmpty()) {
return;
}
else {
QString trainercalib = g.profile[profile_id].trainerCalib();
int8_t vBatCalib = (int8_t)g.profile[profile_id].vBatCalib();
int8_t currentCalib = (int8_t)g.profile[profile_id].currentCalib();
int8_t PPM_Multiplier = (int8_t)g.profile[profile_id].ppmMultiplier();
uint8_t GSStickMode = (uint8_t)g.profile[profile_id].gsStickMode();
uint8_t vBatWarn = (uint8_t)g.profile[profile_id].vBatWarn();
QString DisplaySet = g.profile[profile_id].display();
QString BeeperSet = g.profile[profile_id].beeper();
QString HapticSet = g.profile[profile_id].haptic();
QString SpeakerSet = g.profile[profile_id].speaker();
QString CountrySet = g.profile[profile_id].countryCode();
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
QString Byte;
int16_t byte16;
bool ok;
for (int i=0; i<(NUM_STICKS+potsnum); i++) {
Byte=calib.mid(i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
generalSettings.calibMid[i]=byte16;
Byte=calib.mid(4+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
generalSettings.calibSpanNeg[i]=byte16;
Byte=calib.mid(8+i*12,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
generalSettings.calibSpanPos[i]=byte16;
}
for (int i=0; i<4; i++) {
Byte=trainercalib.mid(i*4,4);
byte16=(int16_t)Byte.toInt(&ok,16);
if (ok)
generalSettings.trainer.calib[i]=byte16;
}
generalSettings.currentCalib=currentCalib;
generalSettings.vBatCalib=vBatCalib;
generalSettings.vBatWarn=vBatWarn;
generalSettings.PPM_Multiplier=PPM_Multiplier;
} else {
QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, radio calibration was not retrieved"));
}
if ((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6)) {
generalSettings.stickMode=GSStickMode;
uint8_t byte8u;
int8_t byte8;
QString chars;
bool ok;
byte8=(int8_t)DisplaySet.mid(0,2).toInt(&ok,16);
if (ok)
generalSettings.optrexDisplay=(byte8==1 ? true : false);
byte8u=(uint8_t)DisplaySet.mid(2,2).toUInt(&ok,16);
if (ok)
generalSettings.contrast=byte8u;
byte8u=(uint8_t)DisplaySet.mid(4,2).toUInt(&ok,16);
if (ok)
generalSettings.backlightBright=byte8u;
byte8=(int8_t)BeeperSet.mid(0,2).toUInt(&ok,16);
if (ok)
generalSettings.beeperMode=(BeeperMode)byte8;
byte8=(int8_t)BeeperSet.mid(2,2).toInt(&ok,16);
if (ok)
generalSettings.beeperLength=byte8;
byte8=(int8_t)HapticSet.mid(0,2).toUInt(&ok,16);
if (ok)
generalSettings.hapticMode=(BeeperMode)byte8;
byte8=(int8_t)HapticSet.mid(2,2).toInt(&ok,16);
if (ok)
generalSettings.hapticStrength=byte8;
byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16);
if (ok)
generalSettings.hapticLength=byte8;
byte8u=(uint8_t)SpeakerSet.mid(0,2).toUInt(&ok,16);
if (ok)
generalSettings.speakerMode=byte8u;
byte8u=(uint8_t)SpeakerSet.mid(2,2).toUInt(&ok,16);
if (ok)
generalSettings.speakerPitch=byte8u;
byte8u=(uint8_t)SpeakerSet.mid(4,2).toUInt(&ok,16);
if (ok)
generalSettings.speakerVolume=byte8u;
if (CountrySet.length()==6) {
byte8u=(uint8_t)CountrySet.mid(0,2).toUInt(&ok,16);
if (ok)
generalSettings.countryCode=byte8u;
byte8u=(uint8_t)CountrySet.mid(2,2).toUInt(&ok,16);
if (ok)
generalSettings.imperial=byte8u;
chars=CountrySet.mid(4,2);
generalSettings.ttsLanguage[0]=chars[0].toAscii();
generalSettings.ttsLanguage[1]=chars[1].toAscii();
}
}
else {
QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, hw related parameters were not retrieved"));
}
}
emit modified();
}
void GeneralEdit::on_calstore_PB_clicked()
{
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
QString name=g.profile[profile_id].name();
int potsnum=GetCurrentFirmware()->getCapability(Pots);
if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true);
return;
}
else {
QString calib=g.profile[profile_id].stickPotCalib();
if (!(calib.isEmpty())) {
int ret = QMessageBox::question(this, "Companion",
tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) ,
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No) {
return;
}
}
calib.clear();
for (int i=0; i< (NUM_STICKS+potsnum); i++) {
calib.append(QString("%1").arg((uint16_t)generalSettings.calibMid[i], 4, 16, QChar('0')));
calib.append(QString("%1").arg((uint16_t)generalSettings.calibSpanNeg[i], 4, 16, QChar('0')));
calib.append(QString("%1").arg((uint16_t)generalSettings.calibSpanPos[i], 4, 16, QChar('0')));
}
g.profile[profile_id].stickPotCalib( calib );
calib.clear();
for (int i=0; i< 4; i++) {
calib.append(QString("%1").arg((uint16_t)generalSettings.trainer.calib[i], 4, 16, QChar('0')));
}
g.profile[profile_id].trainerCalib( calib );
g.profile[profile_id].vBatCalib( generalSettings.vBatCalib );
g.profile[profile_id].currentCalib( generalSettings.currentCalib );
g.profile[profile_id].vBatWarn( generalSettings.vBatWarn );
g.profile[profile_id].ppmMultiplier( generalSettings.PPM_Multiplier );
g.profile[profile_id].gsStickMode( generalSettings.stickMode );
g.profile[profile_id].display( QString("%1%2%3").arg((generalSettings.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)generalSettings.contrast, 2, 16, QChar('0')).arg((uint8_t)generalSettings.backlightBright, 2, 16, QChar('0')) );
g.profile[profile_id].beeper( QString("%1%2").arg(((uint8_t)generalSettings.beeperMode), 2, 16, QChar('0')).arg((uint8_t)generalSettings.beeperLength, 2, 16, QChar('0')));
g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)generalSettings.hapticMode), 2, 16, QChar('0')).arg((int8_t)generalSettings.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)generalSettings.hapticLength, 2, 16, QChar('0')));
g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)generalSettings.speakerMode, 2, 16, QChar('0')).arg((uint8_t)generalSettings.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)generalSettings.speakerVolume, 2, 16, QChar('0')));
g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)generalSettings.countryCode, 2, 16, QChar('0')).arg((uint8_t)generalSettings.imperial, 2, 16, QChar('0')).arg(generalSettings.ttsLanguage));
QDateTime dateTime = QDateTime::currentDateTime();
g.profile[profile_id].timeStamp(dateTime.toString("yyyy-MM-dd hh:mm"));
QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved."));
}
}

View file

@ -0,0 +1,60 @@
#ifndef GENERALEDIT_H
#define GENERALEDIT_H
#include <QDialog>
#include "eeprominterface.h"
#include "helpers.h"
namespace Ui {
class GeneralEdit;
}
class GeneralPanel : public GenericPanel
{
Q_OBJECT
public:
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~GeneralPanel();
protected:
GeneralSettings & generalSettings;
FirmwareInterface * firmware;
};
class GeneralEdit : public QDialog
{
Q_OBJECT
public:
GeneralEdit(QWidget * parent, RadioData & radioData, FirmwareInterface * firmware);
~GeneralEdit();
private:
Ui::GeneralEdit *ui;
GeneralSettings & generalSettings;
bool switchDefPosEditLock;
bool voiceLangEditLock;
bool mavbaudEditLock;
void getGeneralSwitchDefPos(int i, bool val);
void setSwitchDefPos();
void updateVarioPitchRange();
signals:
void modified();
private slots:
void onTabModified();
void on_tabWidget_currentChanged(int index);
void on_calretrieve_PB_clicked();
void on_calstore_PB_clicked();
private:
FirmwareInterface * firmware;
QVector<GeneralPanel *> panels;
void addTab(GeneralPanel *panel, QString text);
};
#endif // GENERALEDIT_H

View file

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralEdit</class>
<widget class="QDialog" name="GeneralEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>787</width>
<height>509</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>General Edit</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_6" rowstretch="0,0">
<item row="1" column="1">
<widget class="QPushButton" name="calretrieve_PB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Retrieve calib. and hw settings from profile</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="calstore_PB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Store calib. and hw settings in selected profile</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="QComboBox" name="profile_CB"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis">
<string>General settings used throught the transmitter.
These will be relevant for all models in the same EEPROM.</string>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../companion.qrc"/>
</resources>
<connections/>
<designerdata>
<property name="gridDeltaX">
<number>10</number>
</property>
<property name="gridDeltaY">
<number>10</number>
</property>
<property name="gridSnapX">
<bool>true</bool>
</property>
<property name="gridSnapY">
<bool>true</bool>
</property>
<property name="gridVisible">
<bool>true</bool>
</property>
</designerdata>
</ui>

View file

@ -0,0 +1,610 @@
#include "setup.h"
#include "ui_setup.h"
#include <QMessageBox>
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::Setup)
{
ui->setupUi(this);
QLabel * pmsl[] = {ui->ro_label,ui->ro1_label,ui->ro2_label,ui->ro3_label,ui->ro4_label,ui->ro5_label,ui->ro6_label,ui->ro7_label,ui->ro8_label, NULL};
QSlider * tpmsld[] = {ui->chkSA, ui->chkSB, ui->chkSC, ui->chkSD, ui->chkSE, ui->chkSF, ui->chkSG, ui->chkSH, NULL};
if (IS_TARANIS(firmware->getBoard())) {
ui->contrastSB->setMinimum(0);
if (firmware->getId().contains("readonly")) {
uint16_t switchstate = generalSettings.switchUnlockStates;
ui->chkSA->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSB->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSC->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSD->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSE->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSF->setValue((switchstate & 0x3)/2);
switchstate >>= 2;
ui->chkSG->setValue(switchstate & 0x3);
switchstate >>= 2;
ui->chkSH->setValue(switchstate & 0x3);
}
else {
for (int i=0; pmsl[i]; i++) {
pmsl[i]->hide();
}
for (int i=0; tpmsld[i]; i++) {
tpmsld[i]->hide();
}
this->layout()->removeItem(ui->TaranisReadOnlyUnlock);
}
}
else {
for (int i=0; pmsl[i]; i++) {
pmsl[i]->hide();
}
for (int i=0; tpmsld[i]; i++) {
tpmsld[i]->hide();
}
this->layout()->removeItem(ui->TaranisReadOnlyUnlock);
}
lock = true;
populateBacklightCB();
if (!firmware->getCapability(MultiLangVoice)) {
ui->VoiceLang_label->hide();
ui->voiceLang_CB->hide();
}
else {
populateVoiceLangCB();
}
if (!firmware->getCapability(MavlinkTelemetry)) {
ui->mavbaud_CB->hide();
ui->mavbaud_label->hide();
}
else {
ui->mavbaud_CB->setCurrentIndex(generalSettings.mavbaud);
// TODO why ??? populateVoiceLangCB(ui->voiceLang_CB, generalSettings.ttsLanguage);
}
if (!firmware->getCapability(HasSoundMixer)) {
ui->beepVolume_SL->hide();
ui->beepVolume_label->hide();
ui->varioVolume_SL->hide();
ui->varioVolume_label->hide();
ui->bgVolume_SL->hide();
ui->bgVolume_label->hide();
ui->wavVolume_SL->hide();
ui->wavVolume_label->hide();
ui->varioP0_label->hide();
ui->varioP0_SB->hide();
ui->varioPMax_label->hide();
ui->varioPMax_SB->hide();
ui->varioR0_label->hide();
ui->varioR0_SB->hide();
}
else {
ui->beepVolume_SL->setValue(generalSettings.beepVolume);
ui->varioVolume_SL->setValue(generalSettings.varioVolume);
ui->bgVolume_SL->setValue(generalSettings.backgroundVolume);
ui->wavVolume_SL->setValue(generalSettings.wavVolume);
ui->varioP0_SB->setValue(700+(generalSettings.varioPitch*10));
updateVarioPitchRange();
ui->varioPMax_SB->setValue(700+(generalSettings.varioPitch*10)+1000+(generalSettings.varioRange*10));
ui->varioR0_SB->setValue(500+(generalSettings.varioRepeat*10));
}
if (!firmware->getCapability(HasFAIMode)) {
ui->faimode_CB->hide();
ui->label_faimode->hide();
}
else {
ui->faimode_CB->setChecked(generalSettings.fai);
}
if (!firmware->getCapability(HasPxxCountry)) {
ui->countrycode_label->hide();
ui->countrycode_CB->hide();
}
else {
ui->countrycode_CB->setCurrentIndex(generalSettings.countryCode);
}
if (!firmware->getCapability(HasGeneralUnits)) {
ui->units_label->hide();
ui->units_CB->hide();
}
else {
ui->units_CB->setCurrentIndex(generalSettings.imperial);
}
if (!firmware->getCapability(TelemetryTimeshift)) {
ui->label_timezone->hide();
ui->timezoneSB->hide();
ui->timezoneSB->setDisabled(true);
ui->gpsFormatCB->hide();
ui->gpsFormatLabel->hide();
}
ui->gpsFormatCB->setCurrentIndex(generalSettings.gpsFormat);
ui->timezoneSB->setValue(generalSettings.timezone);
if (!firmware->getCapability(OptrexDisplay)) {
ui->label_displayType->hide();
ui->displayTypeCB->setDisabled(true);
ui->displayTypeCB->hide();
}
if (!firmware->getCapability(HasVolume)) {
ui->volume_SB->hide();
ui->volume_SB->setDisabled(true);
ui->label_volume->hide();
}
else {
ui->volume_SB->setMaximum(firmware->getCapability(MaxVolume));
}
if (!firmware->getCapability(HasBrightness)) {
ui->BLBright_SB->hide();
ui->BLBright_SB->setDisabled(true);
ui->label_BLBright->hide();
}
if (!firmware->getCapability(SoundMod)) {
ui->soundModeCB->setDisabled(true);
ui->label_soundMode->hide();
ui->soundModeCB->hide();
}
if (!firmware->getCapability(SoundPitch)) {
ui->speakerPitchSB->setDisabled(true);
ui->label_speakerPitch->hide();
ui->speakerPitchSB->hide();
}
if (!firmware->getCapability(Haptic)) {
ui->hapticStrength->setDisabled(true);
ui->hapticmodeCB->setDisabled(true);
}
int reCount = firmware->getCapability(RotaryEncoders);
if (reCount==0) {
ui->re_label->hide();
ui->re_CB->hide();
}
else {
populateRotEncCB(reCount);
}
ui->contrastSB->setValue(generalSettings.contrast);
ui->battwarningDSB->setValue((double)generalSettings.vBatWarn/10);
ui->backlightautoSB->setValue(generalSettings.backlightDelay*5);
ui->inactimerSB->setValue(generalSettings.inactivityTimer);
ui->memwarnChkB->setChecked(!generalSettings.disableMemoryWarning); //Default is zero=checked
ui->alarmwarnChkB->setChecked(!generalSettings.disableAlarmWarning);//Default is zero=checked
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->splashScreenChkB->hide();
ui->splashScreenDuration->setCurrentIndex(3-generalSettings.splashDuration);
}
else {
ui->splashScreenDuration->hide();
ui->splashScreenChkB->setChecked(!generalSettings.splashMode);
}
setValues();
lock = false;
for (int i=0; tpmsld[i]; i++) {
connect(tpmsld[i], SIGNAL(valueChanged(int)),this,SLOT(unlockSwitchEdited()));
}
if (!IS_TARANIS(firmware->getBoard())) {
ui->stickReverse1->setChecked(generalSettings.stickReverse & (1 << 0));
ui->stickReverse2->setChecked(generalSettings.stickReverse & (1 << 1));
ui->stickReverse3->setChecked(generalSettings.stickReverse & (1 << 2));
ui->stickReverse4->setChecked(generalSettings.stickReverse & (1 << 3));
connect(ui->stickReverse1, SIGNAL(toggled(bool)), this, SLOT(stickReverseEdited()));
connect(ui->stickReverse2, SIGNAL(toggled(bool)), this, SLOT(stickReverseEdited()));
connect(ui->stickReverse3, SIGNAL(toggled(bool)), this, SLOT(stickReverseEdited()));
connect(ui->stickReverse4, SIGNAL(toggled(bool)), this, SLOT(stickReverseEdited()));
}
else {
ui->stickReverseLB->hide();
ui->stickReverse1->hide();
ui->stickReverse2->hide();
ui->stickReverse3->hide();
ui->stickReverse4->hide();
}
if (IS_TARANIS_PLUS(firmware->getBoard())) {
ui->backlightColor_SL->setValue(generalSettings.backlightColor);
}
else {
ui->backlightColor_label->hide();
ui->backlightColor_SL->hide();
ui->backlightColor1_label->hide();
ui->backlightColor2_label->hide();
}
if (IS_ARM(firmware->getBoard())) {
ui->switchesDelay->setValue(10*(generalSettings.switchesDelay+15));
}
else {
ui->switchesDelay->hide();
ui->switchesDelayLabel->hide();
}
ui->blAlarm_ChkB->setChecked(generalSettings.flashBeep);
disableMouseScrolling();
}
GeneralSetupPanel::~GeneralSetupPanel()
{
delete ui;
}
void GeneralSetupPanel::populateBacklightCB()
{
QComboBox * b = ui->backlightswCB;
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
b->clear();
for (int i=0; !strings[i].isNull(); i++) {
b->addItem(strings[i], 0);
if (generalSettings.backlightMode == i) {
b->setCurrentIndex(b->count()-1);
}
}
}
void GeneralSetupPanel::populateVoiceLangCB()
{
QComboBox * b = ui->voiceLang_CB;
QString strings[] = { QObject::tr("English"), QObject::tr("Finnish"), QObject::tr("French"), QObject::tr("Italian"), QObject::tr("German"), QObject::tr("Czech"), QObject::tr("Slovak"), QObject::tr("Spanish"), QObject::tr("Polish"), QObject::tr("Portuguese"), QObject::tr("Swedish"), NULL};
QString langcode[] = { "en", "fi","fr", "it", "de", "cz", "sk", "es", "pl", "pt", "se", NULL};
b->clear();
for (int i=0; strings[i]!=NULL; i++) {
b->addItem(strings[i],langcode[i]);
if (generalSettings.ttsLanguage == langcode[i]) {
b->setCurrentIndex(b->count()-1);
}
}
}
void GeneralSetupPanel::on_backlightswCB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.backlightMode = ui->backlightswCB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_backlightColor_SL_valueChanged()
{
if (!lock) {
generalSettings.backlightColor = ui->backlightColor_SL->value();
emit modified();
}
}
void GeneralSetupPanel::on_mavbaud_CB_currentIndexChanged(int index)
{
if (!lock) {
generalSettings.mavbaud = ui->mavbaud_CB->currentIndex();
emit modified();
}
}
void GeneralSetupPanel::on_voiceLang_CB_currentIndexChanged(int index)
{
if (!lock) {
QString code = ui->voiceLang_CB->itemData(index).toString();
for (int i=0; i<2; i++) {
generalSettings.ttsLanguage[i] = code.at(i).toAscii();
}
generalSettings.ttsLanguage[2] = '\0';
emit modified();
}
}
void GeneralSetupPanel::updateVarioPitchRange()
{
ui->varioPMax_SB->setMaximum(700+(generalSettings.varioPitch*10)+1000+800);
ui->varioPMax_SB->setMinimum(700+(generalSettings.varioPitch*10)+1000-800);
}
void GeneralSetupPanel::populateRotEncCB(int reCount)
{
QString strings[] = { QObject::tr("No"), QObject::tr("RotEnc A"), QObject::tr("Rot Enc B"), QObject::tr("Rot Enc C"), QObject::tr("Rot Enc D"), QObject::tr("Rot Enc E")};
QComboBox * b = ui->re_CB;
b->clear();
for (int i=0; i<=reCount; i++) {
b->addItem(strings[i]);
}
b->setCurrentIndex(generalSettings.reNavigation);
}
void GeneralSetupPanel::setValues()
{
ui->beeperCB->setCurrentIndex(generalSettings.beeperMode+2);
ui->channelorderCB->setCurrentIndex(generalSettings.templateSetup);
ui->stickmodeCB->setCurrentIndex(generalSettings.stickMode);
if (GetCurrentFirmware()->getCapability(Haptic)) {
ui->hapticLengthCB->setCurrentIndex(generalSettings.hapticLength+2);
}
else {
ui->label_HL->hide();
ui->hapticLengthCB->hide();
}
ui->BLBright_SB->setValue(100-generalSettings.backlightBright);
ui->soundModeCB->setCurrentIndex(generalSettings.speakerMode);
ui->volume_SB->setValue(generalSettings.speakerVolume);
ui->beeperlenCB->setCurrentIndex(generalSettings.beeperLength+2);
ui->speakerPitchSB->setValue(generalSettings.speakerPitch);
ui->hapticStrength->setValue(generalSettings.hapticStrength);
ui->hapticmodeCB->setCurrentIndex(generalSettings.hapticMode+2);
}
void GeneralSetupPanel::on_faimode_CB_stateChanged(int)
{
if (ui->faimode_CB->isChecked()) {
int ret = QMessageBox::question(this, "Companion",
tr("If you enable FAI, you loose the vario, the play functions, the telemetry screen.\nThis function cannot be disabled by the radio.\nAre you sure ?") ,
QMessageBox::Yes | QMessageBox::No);
if (ret==QMessageBox::Yes) {
generalSettings.fai = true;
}
else {
ui->faimode_CB->setChecked(false);
}
}
else {
generalSettings.fai = false;
}
emit modified();
}
void GeneralSetupPanel::on_speakerPitchSB_editingFinished()
{
generalSettings.speakerPitch = ui->speakerPitchSB->value();
emit modified();
}
void GeneralSetupPanel::on_hapticStrength_valueChanged()
{
generalSettings.hapticStrength = ui->hapticStrength->value();
emit modified();
}
void GeneralSetupPanel::on_soundModeCB_currentIndexChanged(int index)
{
generalSettings.speakerMode = index;
emit modified();
}
void GeneralSetupPanel::on_splashScreenChkB_stateChanged(int )
{
generalSettings.splashMode = ui->splashScreenChkB->isChecked() ? 0 : 1;
emit modified();
}
void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index)
{
generalSettings.splashDuration = 3-index;
emit modified();
}
void GeneralSetupPanel::on_beepVolume_SL_valueChanged()
{
generalSettings.beepVolume=ui->beepVolume_SL->value();
emit modified();
}
void GeneralSetupPanel::on_wavVolume_SL_valueChanged()
{
generalSettings.wavVolume=ui->wavVolume_SL->value();
emit modified();
}
void GeneralSetupPanel::on_varioVolume_SL_valueChanged()
{
generalSettings.varioVolume=ui->varioVolume_SL->value();
emit modified();
}
void GeneralSetupPanel::on_bgVolume_SL_valueChanged()
{
generalSettings.backgroundVolume=ui->bgVolume_SL->value();
emit modified();
}
void GeneralSetupPanel::on_varioP0_SB_editingFinished()
{
generalSettings.varioPitch = (ui->varioP0_SB->value()-700)/10;
updateVarioPitchRange();
emit modified();
}
void GeneralSetupPanel::on_varioPMax_SB_editingFinished()
{
generalSettings.varioRange = (ui->varioPMax_SB->value()-(700+(generalSettings.varioPitch*10))-1000)/10;
emit modified();
}
void GeneralSetupPanel::on_varioR0_SB_editingFinished()
{
generalSettings.varioRepeat = (ui->varioR0_SB->value()-500)/10;
emit modified();
}
void GeneralSetupPanel::on_BLBright_SB_editingFinished()
{
generalSettings.backlightBright = 100 - ui->BLBright_SB->value();
emit modified();
}
void GeneralSetupPanel::on_volume_SB_editingFinished()
{
generalSettings.speakerVolume = ui->volume_SB->value();
emit modified();
}
void GeneralSetupPanel::on_contrastSB_editingFinished()
{
generalSettings.contrast = ui->contrastSB->value();
emit modified();
}
void GeneralSetupPanel::on_battwarningDSB_editingFinished()
{
generalSettings.vBatWarn = (int)(ui->battwarningDSB->value()*10);
emit modified();
}
void GeneralSetupPanel::on_re_CB_currentIndexChanged(int index)
{
generalSettings.reNavigation = ui->re_CB->currentIndex();
emit modified();
}
void GeneralSetupPanel::on_countrycode_CB_currentIndexChanged(int index)
{
generalSettings.countryCode = ui->countrycode_CB->currentIndex();
emit modified();
}
void GeneralSetupPanel::on_units_CB_currentIndexChanged(int index)
{
generalSettings.imperial = ui->units_CB->currentIndex();
emit modified();
}
void GeneralSetupPanel::on_beeperlenCB_currentIndexChanged(int index)
{
generalSettings.beeperLength = index-2;
emit modified();
}
void GeneralSetupPanel::on_hapticLengthCB_currentIndexChanged(int index)
{
generalSettings.hapticLength = index-2;
emit modified();
}
void GeneralSetupPanel::on_gpsFormatCB_currentIndexChanged(int index)
{
generalSettings.gpsFormat = index;
emit modified();
}
void GeneralSetupPanel::on_backlightautoSB_editingFinished()
{
int i = ui->backlightautoSB->value()/5;
if((i*5)!=ui->backlightautoSB->value())
ui->backlightautoSB->setValue(i*5);
else
{
generalSettings.backlightDelay = i;
emit modified();
}
}
void GeneralSetupPanel::on_switchesDelay_valueChanged()
{
generalSettings.switchesDelay = (ui->switchesDelay->value() / 10) - 15;
emit modified();
}
void GeneralSetupPanel::on_timezoneSB_editingFinished()
{
generalSettings.timezone = ui->timezoneSB->value();
emit modified();
}
void GeneralSetupPanel::on_inactimerSB_editingFinished()
{
generalSettings.inactivityTimer = ui->inactimerSB->value();
emit modified();
}
void GeneralSetupPanel::on_memwarnChkB_stateChanged(int )
{
generalSettings.disableMemoryWarning = ui->memwarnChkB->isChecked() ? 0 : 1;
emit modified();
}
void GeneralSetupPanel::on_alarmwarnChkB_stateChanged(int )
{
generalSettings.disableAlarmWarning = ui->alarmwarnChkB->isChecked() ? 0 : 1;
emit modified();
}
void GeneralSetupPanel::on_beeperCB_currentIndexChanged(int index)
{
generalSettings.beeperMode = (BeeperMode)(index-2);
emit modified();
}
void GeneralSetupPanel::on_displayTypeCB_currentIndexChanged(int index)
{
generalSettings.optrexDisplay = index;
emit modified();
}
void GeneralSetupPanel::on_hapticmodeCB_currentIndexChanged(int index)
{
generalSettings.hapticMode = (BeeperMode)(index-2);
emit modified();
}
void GeneralSetupPanel::on_channelorderCB_currentIndexChanged(int index)
{
generalSettings.templateSetup = index;
emit modified();
}
void GeneralSetupPanel::on_stickmodeCB_currentIndexChanged(int index)
{
generalSettings.stickMode = index;
emit modified();
}
void GeneralSetupPanel::unlockSwitchEdited()
{
int i=0;
i|=(((uint16_t)ui->chkSA->value()));
i|=(((uint16_t)ui->chkSB->value())<<2);
i|=(((uint16_t)ui->chkSC->value())<<4);
i|=(((uint16_t)ui->chkSD->value())<<6);
i|=(((uint16_t)ui->chkSE->value())<<8);
i|=(((uint16_t)ui->chkSF->value())<<10);
i|=(((uint16_t)ui->chkSG->value())<<12);
i|=(((uint16_t)ui->chkSH->value())<<14);
generalSettings.switchUnlockStates=i;
emit modified();
}
void GeneralSetupPanel::on_blAlarm_ChkB_stateChanged()
{
generalSettings.flashBeep = ui->blAlarm_ChkB->isChecked();
emit modified();
}
void GeneralSetupPanel::stickReverseEdited()
{
generalSettings.stickReverse = ((int)ui->stickReverse1->isChecked()) | ((int)ui->stickReverse2->isChecked()<<1) | ((int)ui->stickReverse3->isChecked()<<2) | ((int)ui->stickReverse4->isChecked()<<3);
emit modified();
}

View file

@ -0,0 +1,75 @@
#ifndef SETUP_H
#define SETUP_H
#include "generaledit.h"
#include "eeprominterface.h"
namespace Ui {
class Setup;
}
class GeneralSetupPanel : public GeneralPanel
{
Q_OBJECT
public:
GeneralSetupPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~GeneralSetupPanel();
private slots:
void on_splashScreenChkB_stateChanged(int);
void on_splashScreenDuration_currentIndexChanged(int index);
void on_alarmwarnChkB_stateChanged(int );
void on_gpsFormatCB_currentIndexChanged(int index);
void on_displayTypeCB_currentIndexChanged(int index);
void on_BLBright_SB_editingFinished();
void on_re_CB_currentIndexChanged(int index);
void on_countrycode_CB_currentIndexChanged(int index);
void on_units_CB_currentIndexChanged(int index);
void on_faimode_CB_stateChanged(int );
void on_speakerPitchSB_editingFinished();
void on_timezoneSB_editingFinished();
void on_hapticStrength_valueChanged();
void on_soundModeCB_currentIndexChanged(int index);
void on_beeperlenCB_currentIndexChanged(int index);
void on_volume_SB_editingFinished();
void on_hapticmodeCB_currentIndexChanged(int index);
void on_hapticLengthCB_currentIndexChanged(int index);
void on_backlightswCB_currentIndexChanged(int index);
void on_backlightColor_SL_valueChanged();
void on_mavbaud_CB_currentIndexChanged(int index);
void on_voiceLang_CB_currentIndexChanged(int index);
void stickReverseEdited();
void on_switchesDelay_valueChanged();
void on_blAlarm_ChkB_stateChanged();
void unlockSwitchEdited();
void on_beepVolume_SL_valueChanged();
void on_bgVolume_SL_valueChanged();
void on_varioVolume_SL_valueChanged();
void on_wavVolume_SL_valueChanged();
void on_varioP0_SB_editingFinished();
void on_varioPMax_SB_editingFinished();
void on_varioR0_SB_editingFinished();
void on_stickmodeCB_currentIndexChanged(int index);
void on_channelorderCB_currentIndexChanged(int index);
void on_beeperCB_currentIndexChanged(int index);
void on_memwarnChkB_stateChanged(int );
void on_inactimerSB_editingFinished();
void on_backlightautoSB_editingFinished();
void on_battwarningDSB_editingFinished();
void on_contrastSB_editingFinished();
private:
Ui::Setup *ui;
void setValues();
void populateBacklightCB();
void populateVoiceLangCB();
void populateRotEncCB(int reCount);
void updateVarioPitchRange();
};
#endif // SETUP_H

1939
companion/src/generaledit/setup.ui Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,101 @@
#include "trainer.h"
#include "ui_trainer.h"
TrainerPanel::TrainerPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
GeneralPanel(parent, generalSettings, firmware),
ui(new Ui::Trainer)
{
ui->setupUi(this);
ui->trnMode_1->setCurrentIndex(generalSettings.trainer.mix[0].mode);
ui->trnChn_1->setCurrentIndex(generalSettings.trainer.mix[0].src);
ui->trnWeight_1->setValue(generalSettings.trainer.mix[0].weight);
ui->trnMode_2->setCurrentIndex(generalSettings.trainer.mix[1].mode);
ui->trnChn_2->setCurrentIndex(generalSettings.trainer.mix[1].src);
ui->trnWeight_2->setValue(generalSettings.trainer.mix[1].weight);
ui->trnMode_3->setCurrentIndex(generalSettings.trainer.mix[2].mode);
ui->trnChn_3->setCurrentIndex(generalSettings.trainer.mix[2].src);
ui->trnWeight_3->setValue(generalSettings.trainer.mix[2].weight);
ui->trnMode_4->setCurrentIndex(generalSettings.trainer.mix[3].mode);
ui->trnChn_4->setCurrentIndex(generalSettings.trainer.mix[3].src);
ui->trnWeight_4->setValue(generalSettings.trainer.mix[3].weight);
}
TrainerPanel::~TrainerPanel()
{
delete ui;
}
void TrainerPanel::on_trnMode_1_currentIndexChanged(int index)
{
generalSettings.trainer.mix[0].mode = index;
emit modified();
}
void TrainerPanel::on_trnChn_1_currentIndexChanged(int index)
{
generalSettings.trainer.mix[0].src = index;
emit modified();
}
void TrainerPanel::on_trnWeight_1_editingFinished()
{
generalSettings.trainer.mix[0].weight = ui->trnWeight_1->value();
emit modified();
}
void TrainerPanel::on_trnMode_2_currentIndexChanged(int index)
{
generalSettings.trainer.mix[1].mode = index;
emit modified();
}
void TrainerPanel::on_trnChn_2_currentIndexChanged(int index)
{
generalSettings.trainer.mix[1].src = index;
emit modified();
}
void TrainerPanel::on_trnWeight_2_editingFinished()
{
generalSettings.trainer.mix[1].weight = ui->trnWeight_2->value();
emit modified();
}
void TrainerPanel::on_trnMode_3_currentIndexChanged(int index)
{
generalSettings.trainer.mix[2].mode = index;
emit modified();
}
void TrainerPanel::on_trnChn_3_currentIndexChanged(int index)
{
generalSettings.trainer.mix[2].src = index;
emit modified();
}
void TrainerPanel::on_trnWeight_3_editingFinished()
{
generalSettings.trainer.mix[2].weight = ui->trnWeight_3->value();
emit modified();
}
void TrainerPanel::on_trnMode_4_currentIndexChanged(int index)
{
generalSettings.trainer.mix[3].mode = index;
emit modified();
}
void TrainerPanel::on_trnChn_4_currentIndexChanged(int index)
{
generalSettings.trainer.mix[3].src = index;
emit modified();
}
void TrainerPanel::on_trnWeight_4_editingFinished()
{
generalSettings.trainer.mix[3].weight = ui->trnWeight_4->value();
emit modified();
}

View file

@ -0,0 +1,39 @@
#ifndef TRAINER_H
#define TRAINER_H
#include "generaledit.h"
#include "eeprominterface.h"
namespace Ui {
class Trainer;
}
class TrainerPanel : public GeneralPanel
{
Q_OBJECT
public:
TrainerPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~TrainerPanel();
private slots:
void on_trnMode_1_currentIndexChanged(int index);
void on_trnChn_1_currentIndexChanged(int index);
void on_trnWeight_1_editingFinished();
void on_trnMode_2_currentIndexChanged(int index);
void on_trnChn_2_currentIndexChanged(int index);
void on_trnWeight_2_editingFinished();
void on_trnMode_3_currentIndexChanged(int index);
void on_trnChn_3_currentIndexChanged(int index);
void on_trnWeight_3_editingFinished();
void on_trnMode_4_currentIndexChanged(int index);
void on_trnChn_4_currentIndexChanged(int index);
void on_trnWeight_4_editingFinished();
private:
Ui::Trainer *ui;
void setValues();
};
#endif // TRAINER_H

View file

@ -0,0 +1,475 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Trainer</class>
<widget class="QWidget" name="Trainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="3">
<widget class="QSpinBox" name="trnWeight_3">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_37">
<property name="text">
<string>Input</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_38">
<property name="text">
<string>Weight</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="trnLabel_1">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Rud</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="trnMode_1">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>+= (Sum)</string>
</property>
</item>
<item>
<property name="text">
<string>:= (Replace)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="trnChn_1">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>chn1</string>
</property>
</item>
<item>
<property name="text">
<string>chn2</string>
</property>
</item>
<item>
<property name="text">
<string>chn3</string>
</property>
</item>
<item>
<property name="text">
<string>chn4</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="trnWeight_1">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="trnLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ele</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="trnMode_2">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>+= (Sum)</string>
</property>
</item>
<item>
<property name="text">
<string>:= (Replace)</string>
</property>
</item>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="trnChn_2">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>chn1</string>
</property>
</item>
<item>
<property name="text">
<string>chn2</string>
</property>
</item>
<item>
<property name="text">
<string>chn3</string>
</property>
</item>
<item>
<property name="text">
<string>chn4</string>
</property>
</item>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="trnChn_3">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>chn1</string>
</property>
</item>
<item>
<property name="text">
<string>chn2</string>
</property>
</item>
<item>
<property name="text">
<string>chn3</string>
</property>
</item>
<item>
<property name="text">
<string>chn4</string>
</property>
</item>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="trnWeight_2">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="trnLabel_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Thr</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="trnMode_3">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>+= (Sum)</string>
</property>
</item>
<item>
<property name="text">
<string>:= (Replace)</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="trnLabel_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ail</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="trnMode_4">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<item>
<property name="text">
<string>+= (Sum)</string>
</property>
</item>
<item>
<property name="text">
<string>:= (Replace)</string>
</property>
</item>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="trnChn_4">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string>Beeper volume
0 - Quiet. No beeps at all.
1 - No Keys. Normal beeps but menu keys do not beep.
2 - Normal.
3 - Loud.
4 - Extra loud.</string>
</property>
<item>
<property name="text">
<string>chn1</string>
</property>
</item>
<item>
<property name="text">
<string>chn2</string>
</property>
</item>
<item>
<property name="text">
<string>chn3</string>
</property>
</item>
<item>
<property name="text">
<string>chn4</string>
</property>
</item>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="trnWeight_4">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string/>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="minimum">
<number>-125</number>
</property>
<property name="maximum">
<number>125</number>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -95,31 +95,6 @@ void populateGvSourceCB(QComboBox *b, int value)
b->setCurrentIndex(value);
}
void populateVoiceLangCB(QComboBox *b, QString language)
{
QString strings[] = { QObject::tr("English"), QObject::tr("Finnish"), QObject::tr("French"), QObject::tr("Italian"), QObject::tr("German"), QObject::tr("Czech"), QObject::tr("Slovak"), QObject::tr("Spanish"), QObject::tr("Polish"), QObject::tr("Portuguese"), QObject::tr("Swedish"), NULL};
QString langcode[] = { "en", "fi","fr", "it", "de", "cz", "sk", "es", "pl", "pt", "se", NULL};
b->clear();
for (int i=0; strings[i]!=NULL; i++) {
b->addItem(strings[i],langcode[i]);
if (language==langcode[i]) {
b->setCurrentIndex(b->count()-1);
}
}
}
void populateRotEncCB(QComboBox *b, int value, int renumber)
{
QString strings[] = { QObject::tr("No"), QObject::tr("RotEnc A"), QObject::tr("Rot Enc B"), QObject::tr("Rot Enc C"), QObject::tr("Rot Enc D"), QObject::tr("Rot Enc E")};
b->clear();
for (int i=0; i<= renumber; i++) {
b->addItem(strings[i]);
}
b->setCurrentIndex(value);
}
QString getProtocolStr(const int proto)
{
static const char *strings[] = { "OFF",
@ -384,18 +359,6 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase)
}
}
void populateBacklightCB(QComboBox *b, const uint8_t value)
{
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
b->clear();
for (int i=0; !strings[i].isNull(); i++) {
b->addItem(strings[i], 0);
if (value == i) b->setCurrentIndex(b->count()-1);
}
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettings & generalSettings, SwitchContext context)
{
RawSwitch item;
@ -1034,3 +997,116 @@ QString generateProcessUniqueTempFileName(const QString & fileName)
sanitizedFileName.remove('/');
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
}
GenericPanel::GenericPanel(QWidget * parent):
QWidget(parent),
lock(false)
{
}
GenericPanel::~GenericPanel()
{
}
void GenericPanel::update()
{
}
void GenericPanel::addLabel(QGridLayout * gridLayout, QString text, int col, bool minimize)
{
QLabel *label = new QLabel(this);
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter);
label->setMargin(5);
label->setText(text);
if (!minimize)
label->setMinimumWidth(100);
gridLayout->addWidget(label, 0, col, 1, 1);
}
void GenericPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
{
QLabel *label = new QLabel(this);
label->setText("");
gridLayout->addWidget(label, 0, col, 1, 1);
}
void GenericPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
gridLayout->addItem(spacer, row, col);
}
void GenericPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
void GenericPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
bool GenericPanel::eventFilter(QObject *object, QEvent * event)
{
QWidget * widget = qobject_cast<QWidget*>(object);
if (widget) {
if (event->type() == QEvent::Wheel) {
if (widget->focusPolicy() == Qt::WheelFocus) {
event->accept();
return false;
}
else {
event->ignore();
return true;
}
}
else if (event->type() == QEvent::FocusIn) {
widget->setFocusPolicy(Qt::WheelFocus);
}
else if (event->type() == QEvent::FocusOut) {
widget->setFocusPolicy(Qt::StrongFocus);
}
}
return QWidget::eventFilter(object, event);
}
void GenericPanel::disableMouseScrolling()
{
Q_FOREACH(QComboBox * cb, findChildren<QComboBox*>()) {
cb->installEventFilter(this);
cb->setFocusPolicy(Qt::StrongFocus);
}
Q_FOREACH(QAbstractSpinBox * sb, findChildren<QAbstractSpinBox*>()) {
sb->installEventFilter(this);
sb->setFocusPolicy(Qt::StrongFocus);
}
Q_FOREACH(QSlider * slider, findChildren<QSlider*>()) {
slider->installEventFilter(this);
slider->setFocusPolicy(Qt::StrongFocus);
}
}
VerticalScrollArea::VerticalScrollArea(QWidget * parent, GenericPanel * panel):
QScrollArea(parent),
panel(panel),
parent(parent)
{
setWidgetResizable(true);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setWidget(panel);
panel->installEventFilter(this);
}
bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e)
{
if (o == panel && e->type() == QEvent::Resize) {
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
}
return false;
}

View file

@ -26,9 +26,7 @@ extern const QColor colors[C9X_MAX_CURVES];
#define TRIM_MODE_NONE 0x1F // 0b11111
void populateGvSourceCB(QComboBox *b, int value);
void populateVoiceLangCB(QComboBox *b, QString language);
void populateRotEncCB(QComboBox *b, int value, int renumber);
void populateBacklightCB(QComboBox *b, const uint8_t value);
QString getTheme();
@ -151,4 +149,44 @@ int qunlink(const QString & fileName);
QString generateProcessUniqueTempFileName(const QString & fileName);
class GenericPanel : public QWidget
{
Q_OBJECT
friend class QUnsignedAutoComboBox;
public:
GenericPanel(QWidget *parent);
virtual ~GenericPanel();
signals:
void modified();
public slots:
virtual void update();
protected:
bool lock;
void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
void addEmptyLabel(QGridLayout * gridLayout, int col);
void addHSpring(QGridLayout *, int col, int row);
void addVSpring(QGridLayout *, int col, int row);
void addDoubleSpring(QGridLayout *, int col, int row);
virtual bool eventFilter(QObject *obj, QEvent *event);
void disableMouseScrolling();
};
class VerticalScrollArea : public QScrollArea
{
public:
VerticalScrollArea(QWidget * parent, GenericPanel * panel);
protected:
virtual bool eventFilter(QObject *o, QEvent *e);
private:
GenericPanel * panel;
QWidget * parent;
};
#endif // HELPERS_H

View file

@ -45,7 +45,7 @@
#include "hexinterface.h"
#include "mainwindow.h"
#include "modeledit/modeledit.h"
#include "generaledit.h"
#include "generaledit/generaledit.h"
#include "avroutputdialog.h"
#include "burnconfigdialog.h"
#include "printdialog.h"
@ -163,8 +163,8 @@ void MdiChild::checkAndInitModel(int row)
void MdiChild::generalEdit()
{
GeneralEdit *t = new GeneralEdit(radioData, this);
connect(t, SIGNAL(modelValuesChanged()), this, SLOT(setModified()));
GeneralEdit *t = new GeneralEdit(this, radioData, GetCurrentFirmware()/*firmware*/);
connect(t, SIGNAL(modified()), this, SLOT(setModified()));
t->show();
}

View file

@ -55,38 +55,6 @@ void ModelEdit::closeEvent(QCloseEvent *event)
g.modelEditGeo( saveGeometry() );
}
class VerticalScrollArea : public QScrollArea
{
public:
VerticalScrollArea(QWidget * parent, ModelPanel * panel);
protected:
virtual bool eventFilter(QObject *o, QEvent *e);
private:
ModelPanel * panel;
QWidget * parent;
};
VerticalScrollArea::VerticalScrollArea(QWidget * parent, ModelPanel * panel):
QScrollArea(parent),
panel(panel),
parent(parent)
{
setWidgetResizable(true);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setWidget(panel);
panel->installEventFilter(this);
}
bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e)
{
if (o == panel && e->type() == QEvent::Resize) {
setMinimumWidth(panel->minimumSizeHint().width() + verticalScrollBar()->width());
}
return false;
}
void ModelEdit::addTab(ModelPanel *panel, QString text)
{
panels << panel;

View file

@ -4,11 +4,10 @@
#include <QSpinBox>
ModelPanel::ModelPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
QWidget(parent),
GenericPanel(parent),
model(model),
generalSettings(generalSettings),
firmware(firmware),
lock(false)
firmware(firmware)
{
}
@ -16,87 +15,3 @@ ModelPanel::~ModelPanel()
{
}
void ModelPanel::update()
{
}
void ModelPanel::addLabel(QGridLayout * gridLayout, QString text, int col, bool minimize)
{
QLabel *label = new QLabel(this);
label->setFrameShape(QFrame::Panel);
label->setFrameShadow(QFrame::Raised);
label->setMidLineWidth(0);
label->setAlignment(Qt::AlignCenter);
label->setMargin(5);
label->setText(text);
if (!minimize)
label->setMinimumWidth(100);
gridLayout->addWidget(label, 0, col, 1, 1);
}
void ModelPanel::addEmptyLabel(QGridLayout * gridLayout, int col)
{
QLabel *label = new QLabel(this);
label->setText("");
gridLayout->addWidget(label, 0, col, 1, 1);
}
void ModelPanel::addHSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addVSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
void ModelPanel::addDoubleSpring(QGridLayout * gridLayout, int col, int row)
{
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding );
gridLayout->addItem(spacer, row, col);
}
bool ModelPanel::eventFilter(QObject *object, QEvent * event)
{
QWidget * widget = qobject_cast<QWidget*>(object);
if (widget) {
if (event->type() == QEvent::Wheel) {
if (widget->focusPolicy() == Qt::WheelFocus) {
event->accept();
return false;
}
else {
event->ignore();
return true;
}
}
else if (event->type() == QEvent::FocusIn) {
widget->setFocusPolicy(Qt::WheelFocus);
}
else if (event->type() == QEvent::FocusOut) {
widget->setFocusPolicy(Qt::StrongFocus);
}
}
return QWidget::eventFilter(object, event);
}
void ModelPanel::disableMouseScrolling()
{
Q_FOREACH(QComboBox * cb, findChildren<QComboBox*>()) {
cb->installEventFilter(this);
cb->setFocusPolicy(Qt::StrongFocus);
}
Q_FOREACH(QAbstractSpinBox * sb, findChildren<QAbstractSpinBox*>()) {
sb->installEventFilter(this);
sb->setFocusPolicy(Qt::StrongFocus);
}
Q_FOREACH(QSlider * slider, findChildren<QSlider*>()) {
slider->installEventFilter(this);
slider->setFocusPolicy(Qt::StrongFocus);
}
}

View file

@ -1,38 +1,21 @@
#ifndef MODELPANEL_H
#define MODELPANEL_H
#include <QWidget>
#include <QGridLayout>
#include "eeprominterface.h"
#include "helpers.h"
class ModelPanel : public QWidget
class ModelPanel : public GenericPanel
{
Q_OBJECT
friend class QUnsignedAutoComboBox;
Q_OBJECT
public:
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
virtual ~ModelPanel();
signals:
void modified();
public slots:
virtual void update();
protected:
ModelData & model;
GeneralSettings & generalSettings;
FirmwareInterface * firmware;
bool lock;
void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
void addEmptyLabel(QGridLayout * gridLayout, int col);
void addHSpring(QGridLayout *, int col, int row);
void addVSpring(QGridLayout *, int col, int row);
void addDoubleSpring(QGridLayout *, int col, int row);
virtual bool eventFilter(QObject *obj, QEvent *event);
void disableMouseScrolling();
};
#endif // CHANNELS_H