diff --git a/DONATIONS.txt b/DONATIONS.txt index 3ceef39f1..f3bf27e41 100644 --- a/DONATIONS.txt +++ b/DONATIONS.txt @@ -324,3 +324,4 @@ Leonard MacKey Reginald H Millsom Emanuel Stassar Pierluigi Sommaruga +Rafael Eric Suarez Nordlow diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 6356ce744..5ac12bd16 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -72,50 +72,9 @@ ELSE( ) LINK_DIRECTORIES( /usr/local/lib ) ENDIF( ) -INCLUDE_DIRECTORIES( ${XSD_INCLUDE_DIR} ) - -FIND_PACKAGE( Subversion ) -SET( C9X_WC_REVISION 0 ) -IF( Subversion_FOUND ) - # Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} C9X ) -ENDIF( ) - set(RADIO_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/../../radio/src) - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${RADIO_SRC_DIRECTORY}/../.. - ${RADIO_SRC_DIRECTORY} - ${RADIO_SRC_DIRECTORY}/fonts/std - ${RADIO_SRC_DIRECTORY}/lua/src -) - -set(TH9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/th9x) -add_custom_command( - OUTPUT ${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp - COMMAND ${CMAKE_COMMAND} -E make_directory ${TH9X_CHECKOUT_DIRECTORY} - COMMAND cd ${TH9X_CHECKOUT_DIRECTORY} && svn checkout http://th9x.googlecode.com/svn/trunk/src@285 . - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp ${TH9X_CHECKOUT_DIRECTORY} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp -) - -set(ER9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/er9x) -add_custom_command( - OUTPUT ${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp - COMMAND ${CMAKE_COMMAND} -E make_directory ${ER9X_CHECKOUT_DIRECTORY} - COMMAND cd ${ER9X_CHECKOUT_DIRECTORY} && svn checkout http://er9x.googlecode.com/svn/trunk/src@790 . - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp ${ER9X_CHECKOUT_DIRECTORY} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp -) - -set(ERSKY9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/ersky9x) -add_custom_command( - OUTPUT ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp - COMMAND ${CMAKE_COMMAND} -E make_directory ${ERSKY9X_CHECKOUT_DIRECTORY} - COMMAND cd ${ERSKY9X_CHECKOUT_DIRECTORY} && svn checkout http://ersky9x.googlecode.com/svn/trunk/src@170 . - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp ${ERSKY9X_CHECKOUT_DIRECTORY} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp -) +set(SIMU_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/simulation) +set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}) add_custom_command( OUTPUT ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm @@ -124,137 +83,116 @@ add_custom_command( WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} ) +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/../.. + ${SIMU_SRC_DIRECTORY} + ${RADIO_SRC_DIRECTORY} + ${RADIO_SRC_DIRECTORY}/fonts/std + ${RADIO_SRC_DIRECTORY}/lua/src + ${XSD_INCLUDE_DIR} +) + add_subdirectory(modeledit) +add_subdirectory(simulation) -SET( companion_SRCS - eeprominterface.cpp - hexinterface.cpp - flashinterface.cpp - file.cpp - xmlinterface.cpp - ${PROJECT_BINARY_DIR}/radio.cxx - firmwares/th9x/th9xeeprom.cpp - firmwares/th9x/th9xinterface.cpp - ${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp - firmwares/er9x/er9xeeprom.cpp - firmwares/er9x/er9xinterface.cpp - ${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp - firmwares/gruvin9x/gruvin9xeeprom.cpp - firmwares/gruvin9x/gruvin9xinterface.cpp - firmwares/opentx/opentxeeprom.cpp - firmwares/opentx/open9xStockeeprom.cpp - firmwares/opentx/open9xGruvin9xeeprom.cpp - firmwares/opentx/open9xSky9xeeprom.cpp - firmwares/opentx/opentxinterface.cpp - firmwares/opentx/opentxTaranisSimulator.cpp - firmwares/opentx/opentxSky9xsimulator.cpp - firmwares/opentx/opentxGruvin9xsimulator.cpp - firmwares/opentx/opentxM128simulator.cpp - firmwares/opentx/opentxsimulator.cpp - firmwares/ersky9x/ersky9xeeprom.cpp - firmwares/ersky9x/ersky9xinterface.cpp - ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp - ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm - helpers.cpp - mdichild.cpp - generaledit.cpp - modelslist.cpp - mountlist.cpp - avroutputdialog.cpp - apppreferencesdialog.cpp - fwpreferencesdialog.cpp - burnconfigdialog.cpp - comparedialog.cpp - contributorsdialog.cpp - customizesplashdialog.cpp - burndialog.cpp - printdialog.cpp - fusesdialog.cpp - logsdialog.cpp - downloaddialog.cpp - simulatordialog.cpp - xsimulatordialog.cpp - splashlibrary.cpp - mainwindow.cpp - main.cpp - modelconfigdialog.cpp - qcustomplot.cpp +set(companion_SRCS + eeprominterface.cpp + hexinterface.cpp + flashinterface.cpp + file.cpp + xmlinterface.cpp + ${PROJECT_BINARY_DIR}/radio.cxx + firmwares/th9x/th9xeeprom.cpp + firmwares/th9x/th9xinterface.cpp + firmwares/er9x/er9xeeprom.cpp + firmwares/er9x/er9xinterface.cpp + firmwares/gruvin9x/gruvin9xeeprom.cpp + firmwares/gruvin9x/gruvin9xinterface.cpp + firmwares/opentx/opentxeeprom.cpp + firmwares/opentx/open9xStockeeprom.cpp + firmwares/opentx/open9xGruvin9xeeprom.cpp + firmwares/opentx/open9xSky9xeeprom.cpp + firmwares/opentx/opentxinterface.cpp + firmwares/opentx/opentxTaranisSimulator.cpp + firmwares/opentx/opentxSky9xsimulator.cpp + firmwares/opentx/opentxGruvin9xsimulator.cpp + firmwares/opentx/opentxM128simulator.cpp + firmwares/opentx/opentxsimulator.cpp + firmwares/ersky9x/ersky9xeeprom.cpp + firmwares/ersky9x/ersky9xinterface.cpp + ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm + appdata.cpp + helpers.cpp + mdichild.cpp + generaledit.cpp + modelslist.cpp + mountlist.cpp + avroutputdialog.cpp + apppreferencesdialog.cpp + fwpreferencesdialog.cpp + burnconfigdialog.cpp + comparedialog.cpp + contributorsdialog.cpp + customizesplashdialog.cpp + burndialog.cpp + printdialog.cpp + fusesdialog.cpp + logsdialog.cpp + downloaddialog.cpp + splashlibrary.cpp + mainwindow.cpp + companion.cpp + modelconfigdialog.cpp + qcustomplot.cpp ) -SET( companion_MOC_HDRS - avroutputdialog.h - apppreferencesdialog.h - fwpreferencesdialog.h - burnconfigdialog.h - comparedialog.h - printdialog.h - fusesdialog.h - logsdialog.h - contributorsdialog.h - customizesplashdialog.h - splashlibrary.h - splashlabel.h - burndialog.h - downloaddialog.h - cursorwidget.h - menuwidget.h - simulatordialog.h - xcursorwidget.h - xmenuwidget.h - xsimulatordialog.h - generaledit.h - modelslist.h - mdichild.h - mainwindow.h - myslider.h - modelconfigdialog.h - qcustomplot.h - helpers.h +set(companion_MOC_HDRS + avroutputdialog.h + apppreferencesdialog.h + fwpreferencesdialog.h + burnconfigdialog.h + comparedialog.h + printdialog.h + fusesdialog.h + logsdialog.h + contributorsdialog.h + customizesplashdialog.h + splashlibrary.h + splashlabel.h + burndialog.h + downloaddialog.h + generaledit.h + modelslist.h + mdichild.h + mainwindow.h + modelconfigdialog.h + qcustomplot.h + helpers.h ) -SET( companion_UIS - mdichild.ui - avroutputdialog.ui - comparedialog.ui - fusesdialog.ui - logsdialog.ui - apppreferencesdialog.ui - fwpreferencesdialog.ui - simulatordialog.ui - xsimulatordialog.ui - burnconfigdialog.ui - downloaddialog.ui - generaledit.ui - printdialog.ui - contributorsdialog.ui - customizesplashdialog.ui - splashlibrary.ui - burndialog.ui - modelconfigdialog.ui +set(companion_UIS + mdichild.ui + avroutputdialog.ui + comparedialog.ui + fusesdialog.ui + logsdialog.ui + apppreferencesdialog.ui + fwpreferencesdialog.ui + burnconfigdialog.ui + downloaddialog.ui + generaledit.ui + printdialog.ui + contributorsdialog.ui + customizesplashdialog.ui + splashlibrary.ui + burndialog.ui + modelconfigdialog.ui ) -IF ( SDL_FOUND ) - SET( companion_SRCS - ${companion_SRCS} - joystick.cpp - joystickdialog.cpp - ) - - SET( companion_MOC_HDRS - ${companion_MOC_HDRS} - joystick.h - joystickdialog.h - ) - - SET( companion_UIS - ${companion_UIS} - joystickdialog.ui - ) -ENDIF( ) - -SET( companion_RCS - companion.qrc - ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc +set(companion_RCS + companion.qrc + ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc ) MACRO (TODAY RESULT) @@ -292,8 +230,6 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc.in ${CMAKE_CURRENT_B # Subversion_WC_INFO( ${PROJECT_SOURCE_DIR}/../${FIRMWARE} G9X ) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/firmwares/opentx/stamp-opentx.h.in ${CMAKE_CURRENT_BINARY_DIR}/stamp-opentx.h @ONLY) -SET( PATCH_FLAGS "--binary" ) - IF( WIN32 ) SET( companion_SRCS ${companion_SRCS} icon.rc ) IF ( NOT MSVC ) @@ -322,7 +258,88 @@ ELSE( ) ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion_SRCS} ${companion_QM} ) ENDIF( ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} modeledit ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} modeledit simulation ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS} ) + +############# Standalone simu ############### + +set(TH9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/th9x) +add_custom_command( + OUTPUT ${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp + COMMAND ${CMAKE_COMMAND} -E make_directory ${TH9X_CHECKOUT_DIRECTORY} + COMMAND cd ${TH9X_CHECKOUT_DIRECTORY} && svn checkout http://th9x.googlecode.com/svn/trunk/src@285 . + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp ${TH9X_CHECKOUT_DIRECTORY} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/th9x/th9xsimulator.cpp +) + +set(ER9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/er9x) +add_custom_command( + OUTPUT ${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp + COMMAND ${CMAKE_COMMAND} -E make_directory ${ER9X_CHECKOUT_DIRECTORY} + COMMAND cd ${ER9X_CHECKOUT_DIRECTORY} && svn checkout http://er9x.googlecode.com/svn/trunk/src@790 . + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp ${ER9X_CHECKOUT_DIRECTORY} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/er9x/er9xsimulator.cpp +) + +set(ERSKY9X_CHECKOUT_DIRECTORY ${PROJECT_BINARY_DIR}/firmwares/ersky9x) +add_custom_command( + OUTPUT ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp + COMMAND ${CMAKE_COMMAND} -E make_directory ${ERSKY9X_CHECKOUT_DIRECTORY} + COMMAND cd ${ERSKY9X_CHECKOUT_DIRECTORY} && svn checkout http://ersky9x.googlecode.com/svn/trunk/src@170 . + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp ${ERSKY9X_CHECKOUT_DIRECTORY} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/firmwares/ersky9x/ersky9xsimulator.cpp +) + +set(simu_SRCS + eeprominterface.cpp + firmwares/th9x/th9xeeprom.cpp # TODO not needed + firmwares/th9x/th9xinterface.cpp + ${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp + firmwares/er9x/er9xeeprom.cpp # TODO not needed + firmwares/er9x/er9xinterface.cpp + ${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp + firmwares/gruvin9x/gruvin9xeeprom.cpp # TODO not needed + firmwares/gruvin9x/gruvin9xinterface.cpp + firmwares/opentx/opentxeeprom.cpp # TODO not needed + firmwares/opentx/open9xStockeeprom.cpp # TODO not needed + firmwares/opentx/open9xGruvin9xeeprom.cpp # TODO not needed + firmwares/opentx/open9xSky9xeeprom.cpp # TODO not needed + firmwares/opentx/opentxinterface.cpp + firmwares/opentx/opentxTaranisSimulator.cpp + firmwares/opentx/opentxSky9xsimulator.cpp + firmwares/opentx/opentxGruvin9xsimulator.cpp + firmwares/opentx/opentxM128simulator.cpp + firmwares/opentx/opentxsimulator.cpp + firmwares/ersky9x/ersky9xeeprom.cpp # TODO not needed + firmwares/ersky9x/ersky9xinterface.cpp + ${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp + ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm + file.cpp # TODO not needed + modeledit/node.cpp + modeledit/edge.cpp # TODO not needed + appdata.cpp + simulator.cpp +) + +set(simu_HDRS + modeledit/node.h +) + +qt4_wrap_cpp(simu_SRCS ${simu_HDRS} ) +qt4_add_resources(simu_SRCS companion.qrc) # TODO not needed + +if(WIN32) + set(simu_SRCS ${simu_SRCS} icon.rc) +endif() + +add_executable(simulator WIN32 ${simu_SRCS}) + +if(SDL_FOUND) + target_link_libraries(simulator simulation ${QT_LIBRARIES} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS}) +else() + target_link_libraries(simulator simulation ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS}) +endif() + +############# Packaging #################### IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) @@ -366,7 +383,8 @@ IF( WIN32 ) ADD_CUSTOM_TARGET( installer DEPENDS ${PROJECT_BINARY_DIR}/companionInstall.exe - SOURCES ${PROJECT_BINARY_DIR}/companion.nsi) + SOURCES ${PROJECT_BINARY_DIR}/companion.nsi + ) ENDIF( ) IF( APPLE ) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp new file mode 100644 index 000000000..a0f1fbb1c --- /dev/null +++ b/companion/src/appdata.cpp @@ -0,0 +1,643 @@ +// Companion Application Data Class Definition. +// Author Kjell Kernen + +#include "appdata.h" + +// Global data and storage object +AppData g; + +// ** CompStoreObj class******************** +void CompStoreObj::clear (const QString tag1, const QString tag2, const QString tag3) +{ + QSettings settings(PRODUCT, COMPANY); + if (tag2.isEmpty()) + { + settings.remove(tag1); + } + else if (tag3.isEmpty()) + { + settings.beginGroup(tag1); + settings.remove(tag2); + settings.endGroup(); + } + else + { + settings.beginGroup(tag1); + settings.beginGroup(tag2); + settings.remove(tag3); + settings.endGroup(); + settings.endGroup(); + } +} + +void CompStoreObj::store(const QByteArray newArray, QByteArray &array, const QString tag, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + settings.setValue(tag, newArray); + array = newArray; + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::store(const QStringList newSList, QStringList &stringList, const QString tag, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + settings.setValue(tag, newSList); + stringList = newSList; + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::store(const QString newString, QString &string, const QString tag, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + settings.setValue(tag, newString); + string = newString; + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::store(const bool newTruth, bool &truth, const QString tag, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + settings.setValue(tag, newTruth); + truth = newTruth; + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::store(const int newNumber, int &number, const QString tag, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + settings.setValue(tag, newNumber); + number = newNumber; + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +// Retrieval functions +void CompStoreObj::retrieve( QByteArray &array, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + array = settings.value(tag, def).toByteArray(); + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::retrieve( QStringList &stringList, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + stringList = settings.value(tag, def).toStringList(); + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::retrieve( QString &string, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + string = settings.value(tag, def).toString(); + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::retrieve( bool &truth, const QString tag, const bool def, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + truth = settings.value(tag, def).toBool(); + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +void CompStoreObj::retrieve( int &number, const QString tag, const int def, const QString group1, const QString group2 ) +{ + QSettings settings(PRODUCT, COMPANY); + if (!group1.isEmpty()) settings.beginGroup(group1); + if (!group2.isEmpty()) settings.beginGroup(group2); + + number = settings.value(tag, def).toInt(); + + if (!group1.isEmpty()) settings.endGroup(); + if (!group2.isEmpty()) settings.endGroup(); +} + +// Retrieve and Store functions +void CompStoreObj::getset( QByteArray &array, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + retrieve( array, tag, def, group1, group2); + store(array, array, tag, group1, group2); +} + +void CompStoreObj::getset( QStringList &stringList, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + retrieve( stringList, tag, def, group1, group2); + store(stringList, stringList, tag, group1, group2); +} + +void CompStoreObj::getset( QString &string, const QString tag, const QString def, const QString group1, const QString group2 ) +{ + retrieve( string, tag, def, group1, group2); + store(string, string, tag, group1, group2); +} + +void CompStoreObj::getset( bool &truth, const QString tag, const bool def, const QString group1, const QString group2 ) +{ + retrieve( truth, tag, def, group1, group2); + store(truth, truth, tag, group1, group2); +} + +void CompStoreObj::getset( int &number, const QString tag, const int def, const QString group1, const QString group2 ) +{ + retrieve( number, tag, def, group1, group2); + store(number, number, tag, group1, group2); +} + +// ** FwRevision class******************** +int FwRevision::get( const QString fwName ) +{ + QString result; + retrieve( result, fwName, "", "FwRevisions" ); + return result.toInt(); +} + +void FwRevision::set( const QString fwName, const int fwRevision ) +{ + QString tempString= QString("%1").arg(fwRevision); + store( tempString, tempString, fwName, "FwRevisions" ); +} + +void FwRevision::remove( const QString tag ) +{ + clear( "FwRevisions", tag ); +} + +// ** JStickData class******************** +// Get declarations +int JStickData::stick_axe() { return _stickAxe; } +int JStickData::stick_min() { return _stickMin; } +int JStickData::stick_med() { return _stickMed; } +int JStickData::stick_max() { return _stickMax; } +int JStickData::stick_inv() { return _stickInv; } + +// Set declarations +void JStickData::stick_axe(const int it) { store( it, _stickAxe, QString("stick%1_axe").arg(index), "JsCalibration" );} +void JStickData::stick_min(const int it) { store( it, _stickMin, QString("stick%1_min").arg(index), "JsCalibration" );} +void JStickData::stick_med(const int it) { store( it, _stickMed, QString("stick%1_med").arg(index), "JsCalibration" );} +void JStickData::stick_max(const int it) { store( it, _stickMax, QString("stick%1_max").arg(index), "JsCalibration" );} +void JStickData::stick_inv(const int it) { store( it, _stickInv, QString("stick%1_inv").arg(index), "JsCalibration" );} + +// Constructor +JStickData::JStickData() +{ + index = -1; +} + +void JStickData::remove() +{ + // Remove all JStickData values from settings file + QSettings settings(PRODUCT, COMPANY); + settings.beginGroup( "JsCalibration" ); + settings.remove( QString( "stick%1_axe").arg(index) ); + settings.remove( QString( "stick%1_min").arg(index) ); + settings.remove( QString( "stick%1_med").arg(index) ); + settings.remove( QString( "stick%1_max").arg(index) ); + settings.remove( QString( "stick%1_inv").arg(index) ); + settings.endGroup(); + + // Reset all JStickData variables to initial values + init(index); +} + +bool JStickData::existsOnDisk() +{ + QSettings settings(PRODUCT, COMPANY); + settings.beginGroup("JsCalibration"); + int axe = settings.value( QString("stick%1_axe").arg(index), -1 ).toInt(); + settings.endGroup(); + + return (axe > -1); +} + +void JStickData::init(int newIndex) +{ + index = newIndex; + _stickAxe = -1; + _stickMin = -32767; + _stickMed = 0; + _stickMax = 0; + _stickInv = 0; + + // Do not write empty joystick calibrations to disk. + if ( !existsOnDisk() ) + return; + + flush(); +} + +void JStickData::flush() +{ + getset( _stickAxe, QString("stick%1_axe").arg(index), -1, "JsCalibration" ); + getset( _stickMin, QString("stick%1_min").arg(index), -32767, "JsCalibration" ); + getset( _stickMed, QString("stick%1_med").arg(index), 0, "JsCalibration" ); + getset( _stickMax, QString("stick%1_max").arg(index), 0, "JsCalibration" ); + getset( _stickInv, QString("stick%1_inv").arg(index), 0, "JsCalibration" ); +} + +// ** Profile class******************** +// Get declarations +QString Profile::firmware() { return _firmware; } +QString Profile::name() { return _name; } +QString Profile::sdPath() { return _sdPath; } +QString Profile::splashFile() { return _splashFile; } +bool Profile::burnFirmware() { return _burnFirmware; } +bool Profile::renameFwFiles() { return _renameFwFiles; } +bool Profile::patchImage() { return _patchImage; } +int Profile::channelOrder() { return _channelOrder; } +int Profile::defaultMode() { return _defaultMode; } + +QString Profile::beeper() { return _beeper; } +QString Profile::countryCode() { return _countryCode; } +QString Profile::display() { return _display; } +QString Profile::haptic() { return _haptic; } +QString Profile::speaker() { return _speaker; } +QString Profile::stickPotCalib() { return _stickPotCalib; } +QString Profile::trainerCalib() { return _trainerCalib; } +int Profile::currentCalib() { return _currentCalib; } +int Profile::gsStickMode() { return _gsStickMode; } +int Profile::ppmMultiplier() { return _ppmMultiplier; } +int Profile::vBatCalib() { return _vBatCalib; } +int Profile::vBatWarn() { return _vBatWarn; } + +// Set declarations +void Profile::name (const QString x) { if (x.isEmpty()) // Name may never be empty! + store("----", _name, "Name", "Profiles", QString("profile%1").arg(index)); +else + store(x, _name, "Name", "Profiles", QString("profile%1").arg(index));} + +void Profile::firmware (const QString x) { store(x, _firmware, "firmware" ,"Profiles", QString("profile%1").arg(index));} +void Profile::sdPath (const QString x) { store(x, _sdPath, "sdPath" ,"Profiles", QString("profile%1").arg(index));} +void Profile::splashFile (const QString x) { store(x, _splashFile, "SplashFileName" ,"Profiles", QString("profile%1").arg(index));} +void Profile::burnFirmware (const bool x) { store(x, _burnFirmware, "burnFirmware" ,"Profiles", QString("profile%1").arg(index));} +void Profile::renameFwFiles (const bool x) { store(x, _renameFwFiles, "rename_firmware_files" ,"Profiles", QString("profile%1").arg(index));} +void Profile::patchImage (const bool x) { store(x, _patchImage, "patchImage" ,"Profiles", QString("profile%1").arg(index));} +void Profile::channelOrder (const int x) { store(x, _channelOrder, "default_channel_order" ,"Profiles", QString("profile%1").arg(index));} +void Profile::defaultMode (const int x) { store(x, _defaultMode, "default_mode" ,"Profiles", QString("profile%1").arg(index));} + +void Profile::beeper (const QString x) { store(x, _beeper, "Beeper" ,"Profiles", QString("profile%1").arg(index));} +void Profile::countryCode (const QString x) { store(x, _countryCode, "countryCode" ,"Profiles", QString("profile%1").arg(index));} +void Profile::display (const QString x) { store(x, _display, "Display" ,"Profiles", QString("profile%1").arg(index));} +void Profile::haptic (const QString x) { store(x, _haptic, "Haptic" ,"Profiles", QString("profile%1").arg(index));} +void Profile::speaker (const QString x) { store(x, _speaker, "Speaker" ,"Profiles", QString("profile%1").arg(index));} +void Profile::stickPotCalib (const QString x) { store(x, _stickPotCalib, "StickPotCalib" ,"Profiles", QString("profile%1").arg(index));} +void Profile::trainerCalib (const QString x) { store(x, _trainerCalib, "TrainerCalib" ,"Profiles", QString("profile%1").arg(index));} +void Profile::currentCalib (const int x) { store(x, _currentCalib, "currentCalib" ,"Profiles", QString("profile%1").arg(index));} +void Profile::gsStickMode (const int x) { store(x, _gsStickMode, "GSStickMode" ,"Profiles", QString("profile%1").arg(index));} +void Profile::ppmMultiplier (const int x) { store(x, _ppmMultiplier, "PPM_Multiplier" ,"Profiles", QString("profile%1").arg(index));} +void Profile::vBatCalib (const int x) { store(x, _vBatCalib, "VbatCalib" ,"Profiles", QString("profile%1").arg(index));} +void Profile::vBatWarn (const int x) { store(x, _vBatWarn, "vBatWarn" ,"Profiles", QString("profile%1").arg(index));} + +// Constructor +Profile::Profile() +{ + index = -1; +} + +void Profile::remove() +{ + // Remove all profile values from settings file + QSettings settings(PRODUCT, COMPANY); + settings.beginGroup("Profiles"); + settings.remove(QString("profile%1").arg(index)); + settings.endGroup(); + + // Reset all profile variables to initial values + init(index); +} + +bool Profile::existsOnDisk() +{ + QSettings settings(PRODUCT, COMPANY); + settings.beginGroup("Profiles"); + settings.beginGroup(QString("profile%1").arg(index)); + QStringList keyList = settings.allKeys(); + settings.endGroup(); + settings.endGroup(); + + return (keyList.length() > 0); +} + +void Profile::init(int newIndex) +{ + index = newIndex; + + _firmware = ""; + _name = ""; + _sdPath = ""; + _splashFile = ""; + _burnFirmware = false; + _renameFwFiles = false; + _patchImage = false; + _channelOrder = 0; + _defaultMode = 1; + + _beeper = ""; + _countryCode = ""; + _display = ""; + _haptic = ""; + _speaker = ""; + _stickPotCalib = ""; + _trainerCalib = ""; + + _currentCalib = 0; + _gsStickMode = 0; + _ppmMultiplier = 0; + _vBatCalib = 0; + _vBatWarn = 0; + + // Do not write empty profiles to disk except the default (0) profile. + if ( index > 0 && !existsOnDisk()) + return; + + flush(); +} + +void Profile::flush() +{ + // Load and store all variables. Use default values if setting values are missing + getset( _firmware, "firmware" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _name, "Name" ,"----" ,"Profiles", QString("profile%1").arg(index)); + getset( _sdPath, "sdPath" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _splashFile, "SplashFileName" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _burnFirmware, "burnFirmware" ,false ,"Profiles", QString("profile%1").arg(index)); + getset( _renameFwFiles, "rename_firmware_files" ,false ,"Profiles", QString("profile%1").arg(index)); + getset( _patchImage, "patchImage" ,false ,"Profiles", QString("profile%1").arg(index)); + getset( _channelOrder, "default_channel_order" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _defaultMode, "default_mode" ,1 ,"Profiles", QString("profile%1").arg(index)); + + getset( _beeper, "Beeper" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _countryCode, "countryCode" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _display, "Display" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _haptic, "Haptic" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _speaker, "Speaker" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _stickPotCalib, "StickPotCalib" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _trainerCalib, "TrainerCalib" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _currentCalib, "currentCalib" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _gsStickMode, "GSStickMode" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _ppmMultiplier, "PPM_Multiplier" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _vBatCalib, "VbatCalib" ,0 ,"Profiles", QString("profile%1").arg(index)); + getset( _vBatWarn, "vBatWarn" ,0 ,"Profiles", QString("profile%1").arg(index)); +} + + +// ** AppData class******************** + +// Get declarations +QStringList AppData::recentFiles() { return _recentFiles; } +QByteArray AppData::mainWinGeo() { return _mainWinGeo; } +QByteArray AppData::mainWinState() { return _mainWinState; } +QByteArray AppData::modelEditGeo() { return _modelEditGeo; } + +QString AppData::armMcu() { return _armMcu; } +QString AppData::avrArguments() { return _avrArguments; } +QString AppData::avrPort() { return _avrPort; } +QString AppData::avrdudeLocation() { return _avrdudeLocation; } +QString AppData::compileServer() { return _compileServer; } +QString AppData::cpuId() { return _cpuId; } +QString AppData::dfuArguments() { return _dfuArguments; } +QString AppData::dfuLocation() { return _dfuLocation; } +QString AppData::lastFw() { return _lastFw; } +QString AppData::locale() { return _locale; } +QString AppData::mcu() { return _mcu; } +QString AppData::programmer() { return _programmer; } +QString AppData::sambaLocation() { return _sambaLocation; } +QString AppData::sambaPort() { return _sambaPort; } + +QString AppData::backupDir() { return _backupDir; } +QString AppData::gePath() { return _gePath; } +QString AppData::eepromDir() { return _eepromDir; } +QString AppData::flashDir() { return _flashDir; } +QString AppData::imagesDir() { return _imagesDir; } +QString AppData::logDir() { return _logDir; } +QString AppData::libDir() { return _libDir; } +QString AppData::snapshotDir() { return _snapshotDir; } +QString AppData::updatesDir() { return _updatesDir; } + +bool AppData::enableBackup() { return _enableBackup; } +bool AppData::backupOnFlash() { return _backupOnFlash; } +bool AppData::jsSupport() { return _jsSupport; } +bool AppData::rev4aSupport() { return _rev4aSupport; } +bool AppData::maximized() { return _maximized; } +bool AppData::showSplash() { return _showSplash; } +bool AppData::snapToClpbrd() { return _snapToClpbrd; } +bool AppData::autoCheckApp() { return _autoCheckApp; } +bool AppData::autoCheckFw() { return _autoCheckFw; } +bool AppData::simuSW() { return _simuSW; } +bool AppData::enableWizard() { return _enableWizard; } + +int AppData::backLight() { return _backLight; } +int AppData::embedSplashes() { return _embedSplashes; } +int AppData::fwServerFails() { return _fwServerFails; } +int AppData::generalEditTab() { return _generalEditTab; } +int AppData::iconSize() { return _iconSize; } +int AppData::historySize() { return _historySize; } +int AppData::jsCtrl() { return _jsCtrl; } +int AppData::modelEditTab() { return _modelEditTab; } +int AppData::id() { return _id; } +int AppData::theme() { return _theme; } +int AppData::warningId() { return _warningId; } + +// Set declarations +void AppData::recentFiles (const QStringList x) { store(x, _recentFiles, "recentFileList" );} +void AppData::mainWinGeo (const QByteArray x) { store(x, _mainWinGeo, "mainWindowGeometry" );} +void AppData::mainWinState (const QByteArray x) { store(x, _mainWinState, "mainWindowState" );} +void AppData::modelEditGeo (const QByteArray x) { store(x, _modelEditGeo, "modelEditGeometry" );} + +void AppData::armMcu (const QString x) { store(x, _armMcu, "arm_mcu" );} +void AppData::avrArguments (const QString x) { store(x, _avrArguments, "avr_arguments" );} +void AppData::avrPort (const QString x) { store(x, _avrPort, "avr_port" );} +void AppData::avrdudeLocation (const QString x) { store(x, _avrdudeLocation, "avrdudeLocation" );} +void AppData::compileServer (const QString x) { store(x, _compileServer, "compilation-server" );} +void AppData::cpuId (const QString x) { store(x, _cpuId, "cpu_id" );} +void AppData::dfuArguments (const QString x) { store(x, _dfuArguments, "dfu_arguments" );} +void AppData::dfuLocation (const QString x) { store(x, _dfuLocation, "dfu_location" );} +void AppData::lastFw (const QString x) { store(x, _lastFw, "lastFw" );} +void AppData::locale (const QString x) { store(x, _locale, "locale" );} +void AppData::mcu (const QString x) { store(x, _mcu, "mcu" );} +void AppData::programmer (const QString x) { store(x, _programmer, "programmer" );} +void AppData::sambaLocation (const QString x) { store(x, _sambaLocation, "samba_location" );} +void AppData::sambaPort (const QString x) { store(x, _sambaPort, "samba_port" );} + +void AppData::backupDir (const QString x) { store(x, _backupDir, "backupPath" );} +void AppData::gePath (const QString x) { store(x, _gePath, "gePath" );} +void AppData::eepromDir (const QString x) { store(x, _eepromDir, "lastDir" );} +void AppData::flashDir (const QString x) { store(x, _flashDir, "lastFlashDir" );} +void AppData::imagesDir (const QString x) { store(x, _imagesDir, "lastImagesDir" );} +void AppData::logDir (const QString x) { store(x, _logDir, "lastLogDir" );} +void AppData::libDir (const QString x) { store(x, _libDir, "libraryPath" );} +void AppData::snapshotDir (const QString x) { store(x, _snapshotDir, "snapshotpath" );} +void AppData::updatesDir (const QString x) { store(x, _updatesDir, "lastUpdatesDir" );} + +void AppData::enableBackup (const bool x) { store(x, _enableBackup, "backupEnable" );} +void AppData::backupOnFlash (const bool x) { store(x, _backupOnFlash, "backupOnFlash" );} +void AppData::maximized (const bool x) { store(x, _maximized, "maximized" );} +void AppData::jsSupport (const bool x) { store(x, _jsSupport, "js_support" );} +void AppData::rev4aSupport (const bool x) { store(x, _rev4aSupport, "rev4asupport" );} +void AppData::showSplash (const bool x) { store(x, _showSplash, "show_splash" );} +void AppData::snapToClpbrd (const bool x) { store(x, _snapToClpbrd, "snapshot_to_clipboard" );} +void AppData::autoCheckApp (const bool x) { store(x, _autoCheckApp, "startup_check_companion" );} +void AppData::autoCheckFw (const bool x) { store(x, _autoCheckFw, "startup_check_fw" );} +void AppData::simuSW (const bool x) { store(x, _simuSW, "simuSW" );} +void AppData::enableWizard (const bool x) { store(x, _enableWizard, "wizardEnable" );} + +void AppData::backLight (const int x) { store(x, _backLight, "backLight" );} +void AppData::embedSplashes (const int x) { store(x, _embedSplashes, "embedded_splashes" );} +void AppData::fwServerFails (const int x) { store(x, _fwServerFails, "fwserver" );} +void AppData::generalEditTab (const int x) { store(x, _generalEditTab, "generalEditTab" );} +void AppData::iconSize (const int x) { store(x, _iconSize, "icon_size" );} +void AppData::historySize (const int x) { store(x, _historySize, "history_size" );} +void AppData::jsCtrl (const int x) { store(x, _jsCtrl, "js_ctrl" );} +void AppData::modelEditTab (const int x) { store(x, _modelEditTab, "modelEditTab" );} +void AppData::id (const int x) { store(x, _id, "profileId" );} +void AppData::theme (const int x) { store(x, _theme, "theme" );} +void AppData::warningId (const int x) { store(x, _warningId, "warningId" );} + +// Constructor +AppData::AppData() +{ + //Initialize the profiles + for (int i=0; i +#include +#include +#include + +#define COMPANY "OpenTX Companion" +#define PRODUCT "OpenTX" + +#define MAX_PROFILES 15 +#define MAX_JOYSTICKS 8 + +class CompStoreObj +{ + public: + void clear (const QString tag1="", const QString tag2="", const QString tag3=""); + void store(const QByteArray newArray, QByteArray &array, const QString tag, const QString group1="", const QString group2="" ); + void store(const QStringList newSList, QStringList &stringList, const QString tag, const QString group1="", const QString group2="" ); + void store(const QString newString, QString &string, const QString tag, const QString group1="", const QString group2="" ); + void store(const bool newTruth, bool &truth, const QString tag, const QString group1="", const QString group2="" ); + void store(const int newNumber, int &number, const QString tag, const QString group1="", const QString group2="" ); + + // Retrieval functions + void retrieve( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void retrieve( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void retrieve( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void retrieve( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" ); + void retrieve( int &number, const QString tag, const int def, const QString group1="", const QString group2="" ); + + // Retrieve and Store functions + void getset( QByteArray &array, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void getset( QStringList &stringList, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void getset( QString &string, const QString tag, const QString def, const QString group1="", const QString group2="" ); + void getset( bool &truth, const QString tag, const bool def, const QString group1="", const QString group2="" ); + void getset( int &number, const QString tag, const int def, const QString group1="", const QString group2="" ); +}; + +class FwRevision: protected CompStoreObj +{ + public: + int get( const QString); + void set( const QString, const int ); + void remove( const QString ); +}; + +class JStickData: protected CompStoreObj +{ + private: + int index; + + int _stickAxe; + int _stickMin; + int _stickMed; + int _stickMax; + int _stickInv; + + public: + // All the get definitions + int stick_axe(); + int stick_min(); + int stick_med(); + int stick_max(); + int stick_inv(); + + // All the set definitions + void stick_axe(const int); + void stick_min(const int); + void stick_med(const int); + void stick_max(const int); + void stick_inv(const int); + + JStickData(); + void remove(); + bool existsOnDisk(); + void init(int index); + void flush(); +}; + +class Profile: protected CompStoreObj +{ + private: + // Class Internal Variable + int index; + + // Application Variables + QString _firmware; + QString _name; + QString _sdPath; + QString _splashFile; + bool _burnFirmware; + bool _renameFwFiles; + bool _patchImage; + int _channelOrder; + int _defaultMode; + + // Firmware Variables + QString _beeper; + QString _countryCode; + QString _display; + QString _haptic; + QString _speaker; + QString _stickPotCalib; + QString _trainerCalib; + int _currentCalib; + int _gsStickMode; + int _ppmMultiplier; + int _vBatCalib; + int _vBatWarn; + + public: + // All the get definitions + QString firmware(); + QString name(); + QString sdPath(); + QString splashFile(); + bool burnFirmware(); + bool renameFwFiles(); + bool patchImage(); + int channelOrder(); + int defaultMode(); + + QString beeper(); + QString countryCode(); + QString display(); + QString haptic(); + QString speaker(); + QString stickPotCalib(); + QString trainerCalib(); + int currentCalib(); + int gsStickMode(); + int ppmMultiplier(); + int vBatCalib(); + int vBatWarn(); + + // All the set definitions + void name (const QString); + void firmware (const QString); + void sdPath (const QString); + void splashFile (const QString); + void burnFirmware (const bool); + void renameFwFiles (const bool); + void patchImage (const bool); + void channelOrder (const int); + void defaultMode (const int); + + void beeper (const QString); + void countryCode (const QString); + void display (const QString); + void haptic (const QString); + void speaker (const QString); + void stickPotCalib (const QString); + void trainerCalib (const QString); + void currentCalib (const int); + void gsStickMode (const int); + void ppmMultiplier (const int); + void vBatCalib (const int); + void vBatWarn (const int); + + Profile(); + void remove(); + bool existsOnDisk(); + void init(int newIndex); + void flush(); +}; + +class AppData: protected CompStoreObj +{ + // All the global variables + public: + Profile profile[MAX_PROFILES]; + JStickData joystick[MAX_JOYSTICKS]; + FwRevision fwRev; + + private: + QStringList _recentFiles; + QByteArray _mainWinGeo; + QByteArray _mainWinState; + QByteArray _modelEditGeo; + + QString _armMcu; + QString _avrArguments; + QString _avrPort; + QString _avrdudeLocation; + QString _compileServer; + QString _cpuId; + QString _dfuArguments; + QString _dfuLocation; + QString _lastFw; + QString _locale; + QString _mcu; + QString _programmer; + QString _sambaLocation; + QString _sambaPort; + + QString _backupDir; + QString _gePath; + QString _eepromDir; + QString _flashDir; + QString _imagesDir; + QString _logDir; + QString _libDir; + QString _snapshotDir; + QString _updatesDir; + + bool _enableBackup; + bool _backupOnFlash; + bool _maximized; + bool _jsSupport; + bool _rev4aSupport; + bool _showSplash; + bool _snapToClpbrd; + bool _autoCheckApp; + bool _autoCheckFw; + bool _simuSW; + bool _enableWizard; + + int _backLight; + int _embedSplashes; + int _fwServerFails; + int _generalEditTab; + int _iconSize; + int _jsCtrl; + int _historySize; + int _modelEditTab; + int _id; + int _theme; + int _warningId; + + public: + // All the get definitions + QStringList recentFiles(); + QByteArray mainWinGeo(); + QByteArray mainWinState(); + QByteArray modelEditGeo(); + + QString armMcu(); + QString avrArguments(); + QString avrPort(); + QString avrdudeLocation(); + QString compileServer(); + QString cpuId(); + QString dfuArguments(); + QString dfuLocation(); + QString lastFw(); + QString locale(); + QString mcu(); + QString programmer(); + QString sambaLocation(); + QString sambaPort(); + + QString backupDir(); + QString gePath(); + QString eepromDir(); + QString flashDir(); + QString imagesDir(); + QString logDir(); + QString libDir(); + QString snapshotDir(); + QString updatesDir(); + + bool enableBackup(); + bool backupOnFlash(); + bool jsSupport(); + bool rev4aSupport(); + bool maximized(); + bool showSplash(); + bool snapToClpbrd(); + bool autoCheckApp(); + bool autoCheckFw(); + bool simuSW(); + bool enableWizard(); + + int backLight(); + int embedSplashes(); + int fwServerFails(); + int generalEditTab(); + int iconSize(); + int historySize(); + int jsCtrl(); + int modelEditTab(); + int id(); + int theme(); + int warningId(); + + // All the set definitions + void recentFiles (const QStringList x); + void mainWinGeo (const QByteArray); + void mainWinState (const QByteArray); + void modelEditGeo (const QByteArray); + + void armMcu (const QString); + void avrArguments (const QString); + void avrPort (const QString); + void avrdudeLocation (const QString); + void compileServer (const QString); + void cpuId (const QString); + void dfuArguments (const QString); + void dfuLocation (const QString); + void lastFw (const QString); + void locale (const QString); + void mcu (const QString); + void programmer (const QString); + void sambaLocation (const QString); + void sambaPort (const QString); + + void backupDir (const QString); + void gePath (const QString); + void eepromDir (const QString); + void flashDir (const QString); + void imagesDir (const QString); + void logDir (const QString); + void libDir (const QString); + void snapshotDir (const QString); + void updatesDir (const QString); + + void enableBackup (const bool); + void backupOnFlash (const bool); + void maximized (const bool); + void jsSupport (const bool); + void rev4aSupport (const bool); + void showSplash (const bool); + void snapToClpbrd (const bool); + void autoCheckApp (const bool); + void autoCheckFw (const bool); + void simuSW (const bool); + void enableWizard (const bool); + + void backLight (const int); + void embedSplashes (const int); + void fwServerFails (const int); + void generalEditTab (const int); + void iconSize (const int); + void historySize (const int); + void jsCtrl (const int); + void modelEditTab (const int); + void id (const int); + void theme (const int); + void warningId (const int); + + // Constructor + AppData(); +}; + +extern AppData g; + +#endif // COMPANION_APPDATA_H diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index cfcb0b3de..1504051ee 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -1,6 +1,7 @@ #include "apppreferencesdialog.h" #include "ui_apppreferencesdialog.h" #include "mainwindow.h" +#include "appdata.h" #include "helpers.h" #include "flashinterface.h" #ifdef JOYSTICKS @@ -35,101 +36,87 @@ appPreferencesDialog::~appPreferencesDialog() void appPreferencesDialog::writeValues() { - QSettings settings; - settings.setValue("startup_check_companion", ui->startupCheck_companion9x->isChecked()); - settings.setValue("startup_check_fw", ui->startupCheck_fw->isChecked()); - settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked()); - settings.setValue("show_splash", ui->showSplash->isChecked()); - settings.setValue("simuSW", ui->simuSW->isChecked()); - settings.setValue("history_size", ui->historySize->value()); - settings.setValue("backLight", ui->backLightColor->currentIndex()); - settings.setValue("libraryPath", ui->libraryPath->text()); - settings.setValue("gePath", ui->ge_lineedit->text()); - settings.setValue("embedded_splashes", ui->splashincludeCB->currentIndex()); - settings.setValue("backupEnable", ui->backupEnable->isChecked()); + g.autoCheckApp(ui->startupCheck_companion9x->isChecked()); + g.autoCheckFw(ui->startupCheck_fw->isChecked()); + g.enableWizard(ui->wizardEnable_ChkB->isChecked()); + g.showSplash(ui->showSplash->isChecked()); + g.simuSW(ui->simuSW->isChecked()); + g.historySize(ui->historySize->value()); + g.backLight(ui->backLightColor->currentIndex()); + g.libDir(ui->libraryPath->text()); + g.gePath(ui->ge_lineedit->text()); + g.embedSplashes(ui->splashincludeCB->currentIndex()); + g.enableBackup(ui->backupEnable->isChecked()); if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) { - settings.setValue("js_support", ui->joystickChkB ->isChecked()); - settings.setValue("js_ctrl", ui->joystickCB ->currentIndex()); + g.jsSupport(ui->joystickChkB ->isChecked()); + g.jsCtrl(ui->joystickCB ->currentIndex()); } else { - settings.remove("js_support"); - settings.remove("js_ctrl"); + g.jsSupport(false); + g.jsCtrl(0); } - settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); - settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); - settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); - settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); - settings.setValue("profileId", ui->profileIndexLE->text()); - settings.setValue("Name", ui->profileNameLE->text()); - settings.setValue("sdPath", ui->sdPath->text()); - settings.setValue("SplashFileName", ui->SplashFileName->text()); - if (!ui->SplashFileName->text().isEmpty()) - settings.setValue("SplashImage", ""); - settings.setValue("firmware", ui->firmwareLE->text()); + g.id(ui->profileIndexLE->text().toInt()); + + g.profile[g.id()].channelOrder(ui->channelorderCB->currentIndex()); + g.profile[g.id()].defaultMode(ui->stickmodeCB->currentIndex()); + g.profile[g.id()].renameFwFiles(ui->renameFirmware->isChecked()); + g.profile[g.id()].burnFirmware(ui->burnFirmware->isChecked()); + g.profile[g.id()].name(ui->profileNameLE->text()); + g.profile[g.id()].sdPath(ui->sdPath->text()); + g.profile[g.id()].splashFile(ui->SplashFileName->text()); + g.profile[g.id()].firmware(ui->firmwareLE->text()); saveProfile(); } void appPreferencesDialog::on_snapshotPathButton_clicked() { - QSettings settings; - QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString()); + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), g.snapshotDir()); if (!fileName.isEmpty()) { - settings.setValue("snapshotpath", fileName); - settings.setValue("snapshot_to_clipboard", false); + g.snapshotDir(fileName); + g.snapToClpbrd(false); ui->snapshotPath->setText(fileName); } } void appPreferencesDialog::initSettings() { - QSettings settings; - ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool()); - ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool()); - - QString Path=settings.value("snapshotPath", "").toString(); - if (QDir(Path).exists()) { - ui->snapshotPath->setText(Path); - ui->snapshotPath->setReadOnly(true); - } - if (ui->snapshotClipboardCKB->isChecked()) { + ui->snapshotClipboardCKB->setChecked(g.snapToClpbrd()); + ui->burnFirmware->setChecked(g.profile[g.id()].burnFirmware()); + ui->snapshotPath->setText(g.snapshotDir()); + ui->snapshotPath->setReadOnly(true); + if (ui->snapshotClipboardCKB->isChecked()) + { ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); } - ui->startupCheck_companion9x->setChecked(settings.value("startup_check_companion", true).toBool()); - ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool()); - ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool()); - ui->showSplash->setChecked(settings.value("show_splash", true).toBool()); - ui->historySize->setValue(settings.value("history_size", 10).toInt()); - ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt()); - ui->simuSW->setChecked(settings.value("simuSW", false).toBool()); + ui->startupCheck_companion9x->setChecked(g.autoCheckApp()); + ui->startupCheck_fw->setChecked(g.autoCheckFw()); + ui->wizardEnable_ChkB->setChecked(g.enableWizard()); + ui->showSplash->setChecked(g.showSplash()); + ui->historySize->setValue(g.historySize()); + ui->backLightColor->setCurrentIndex(g.backLight()); + ui->simuSW->setChecked(g.simuSW()); + ui->libraryPath->setText(g.libDir()); + ui->ge_lineedit->setText(g.gePath()); - Path=settings.value("libraryPath", "").toString(); - if (QDir(Path).exists()) { - ui->libraryPath->setText(Path); - } - Path=settings.value("gePath", "").toString(); - if (QFile(Path).exists()) { - ui->ge_lineedit->setText(Path); - } - Path=settings.value("backupPath", "").toString(); - if (!Path.isEmpty()) { - if (QDir(Path).exists()) { - ui->backupPath->setText(Path); + if (!g.backupDir().isEmpty()) { + if (QDir(g.backupDir()).exists()) { + ui->backupPath->setText(g.backupDir()); ui->backupEnable->setEnabled(true); - ui->backupEnable->setChecked(settings.value("backupEnable", true).toBool()); + ui->backupEnable->setChecked(g.enableBackup()); } else { ui->backupEnable->setDisabled(true); } } else { ui->backupEnable->setDisabled(true); } - ui->splashincludeCB->setCurrentIndex(settings.value("embedded_splashes", 0).toInt()); + ui->splashincludeCB->setCurrentIndex(g.embedSplashes()); #ifdef JOYSTICKS - ui->joystickChkB->setChecked(settings.value("js_support", false).toBool()); + ui->joystickChkB->setChecked(g.jsSupport()); if (ui->joystickChkB->isChecked()) { QStringList joystickNames; joystickNames << tr("No joysticks found"); @@ -147,7 +134,7 @@ void appPreferencesDialog::initSettings() } ui->joystickCB->clear(); ui->joystickCB->insertItems(0, joystickNames); - ui->joystickCB->setCurrentIndex(settings.value("js_ctrl", 0).toInt()); + ui->joystickCB->setCurrentIndex(g.jsCtrl()); } else { ui->joystickCB->clear(); @@ -156,58 +143,46 @@ void appPreferencesDialog::initSettings() } #endif // Profile Tab Inits - ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt()); - ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt()); - ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool()); - Path=settings.value("sdPath", "").toString(); - if (QDir(Path).exists()) { - ui->sdPath->setText(Path); - } - ui->profileIndexLE->setText(settings.value("profileId", "").toString()); - ui->profileNameLE->setText(settings.value("Name", "").toString()); + ui->channelorderCB->setCurrentIndex(g.profile[g.id()].channelOrder()); + ui->stickmodeCB->setCurrentIndex(g.profile[g.id()].defaultMode()); + ui->renameFirmware->setChecked(g.profile[g.id()].renameFwFiles()); + ui->sdPath->setText(g.profile[g.id()].sdPath()); + ui->profileIndexLE->setText(QString("%1").arg(g.id())); + ui->profileNameLE->setText(g.profile[g.id()].name()); + ui->firmwareLE->setText(g.profile[g.id()].firmware()); + ui->SplashFileName->setText(g.profile[g.id()].splashFile()); - QString fileName=settings.value("SplashFileName","").toString(); - if (!fileName.isEmpty()) { - QFile file(fileName); - if (file.exists()){ - ui->SplashFileName->setText(fileName); - displayImage( fileName ); - } - } - ui->firmwareLE->setText(settings.value("firmware","").toString()); + displayImage( g.profile[g.id()].splashFile() ); } void appPreferencesDialog::on_libraryPathButton_clicked() { - QSettings settings; - QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString()); + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), g.libDir()); if (!fileName.isEmpty()) { - settings.setValue("libraryPath", fileName); + g.libDir(fileName); ui->libraryPath->setText(fileName); } } void appPreferencesDialog::on_snapshotClipboardCKB_clicked() { - QSettings settings; if (ui->snapshotClipboardCKB->isChecked()) { ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); - settings.setValue("snapshot_to_clipboard", true); + g.snapToClpbrd(true); } else { ui->snapshotPath->setEnabled(true); ui->snapshotPath->setReadOnly(true); ui->snapshotPathButton->setEnabled(true); - settings.setValue("snapshot_to_clipboard", false); + g.snapToClpbrd(false); } } void appPreferencesDialog::on_backupPathButton_clicked() { - QSettings settings; - QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString()); + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), g.backupDir()); if (!fileName.isEmpty()) { - settings.setValue("backupPath", fileName); + g.backupDir(fileName); ui->backupPath->setText(fileName); } ui->backupEnable->setEnabled(true); @@ -215,7 +190,6 @@ void appPreferencesDialog::on_backupPathButton_clicked() void appPreferencesDialog::on_ge_pathButton_clicked() { - QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text()); if (!fileName.isEmpty()) { ui->ge_lineedit->setText(fileName); @@ -259,8 +233,7 @@ void appPreferencesDialog::on_joystickcalButton_clicked() { void appPreferencesDialog::on_sdPathButton_clicked() { - QSettings settings; - QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString()); + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), g.profile[g.id()].sdPath()); if (!fileName.isEmpty()) { ui->sdPath->setText(fileName); } @@ -268,95 +241,45 @@ void appPreferencesDialog::on_sdPathButton_clicked() void appPreferencesDialog::saveProfile() { - QSettings settings; + // The profile name may NEVER be empty + if (ui->profileNameLE->text().isEmpty()) + ui->profileNameLE->setText("----"); - QString profile=QString("profile") + settings.value("profileId").toString(); - QString name=ui->profileNameLE->text(); - if (name.isEmpty()) { - name = profile; - ui->profileNameLE->setText(name); - } - settings.beginGroup("Profiles"); - settings.beginGroup(profile); - settings.setValue("Name",name); - settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); - settings.setValue("default_mode", ui->stickmodeCB->currentIndex()); - settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); - settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); - settings.setValue("sdPath", ui->sdPath->text()); - settings.setValue("SplashFileName", ui->SplashFileName->text()); - settings.setValue("firmware", ui->firmwareLE->text()); - settings.endGroup(); - settings.endGroup(); -} - -void appPreferencesDialog::loadProfileString(QString profile, QString label) -{ - QSettings settings; - QString value; - - settings.beginGroup("Profiles"); - settings.beginGroup(profile); - value = settings.value(label).toString(); - settings.endGroup(); - settings.endGroup(); - - settings.setValue( label, value ); -} - -void appPreferencesDialog::loadProfile() -{ - QSettings settings; - QString profile=QString("profile") + settings.value("profileId").toString(); - - loadProfileString( profile, "Name" ); - loadProfileString( profile, "default_channel_order" ); - loadProfileString( profile, "default_mode" ); - loadProfileString( profile, "burnFirmware" ); - loadProfileString( profile, "rename_firmware_files" ); - loadProfileString( profile, "sdPath" ); - loadProfileString( profile, "SplashFileName" ); - loadProfileString( profile, "firmware" ); + g.profile[g.id()].name( ui->profileNameLE->text() ); + g.profile[g.id()].channelOrder( ui->channelorderCB->currentIndex()); + g.profile[g.id()].defaultMode( ui->stickmodeCB->currentIndex()); + g.profile[g.id()].burnFirmware( ui->burnFirmware->isChecked()); + g.profile[g.id()].renameFwFiles( ui->renameFirmware->isChecked()); + g.profile[g.id()].sdPath( ui->sdPath->text()); + g.profile[g.id()].splashFile( ui->SplashFileName->text()); + g.profile[g.id()].firmware( ui->firmwareLE->text()); } void appPreferencesDialog::on_removeProfileButton_clicked() { - QSettings settings; - QString profileId = settings.value("profileId").toString(); - if ( profileId == "1" ) + if ( g.id() == 0 ) QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed.")); else { - QString profile=QString("profile") + profileId; - settings.beginGroup("Profiles"); - settings.remove(profile); - settings.endGroup(); - settings.setValue("profileId", "1"); - - loadProfile(); + g.profile[g.id()].remove(); + g.id( 0 ); initSettings(); } } bool appPreferencesDialog::displayImage( QString fileName ) { - QSettings settings; + // Start by clearing the pixmap + ui->imageLabel->setPixmap(QPixmap()); QImage image(fileName); if (image.isNull()) return false; -// This code below just figures out if the width of the latest firmware is 128 or 212. It works , but... - QString filePath1 = settings.value("lastFlashDir", "").toString() + "/" + settings.value("firmware", "").toString() + ".bin"; - QString filePath2 = settings.value("lastFlashDir", "").toString() + "/" + settings.value("firmware", "").toString() + ".hex"; - QFile file(filePath1); - if (!file.exists()) - filePath1 = filePath2; + // Use the firmware name to determine splash width int width = SPLASH_WIDTH; - FlashInterface flash(filePath1); - if (flash.hasSplash()) - width = flash.getSplashWidth(); // Returns SPLASHX9D_HEIGHT if filePath1 does not exist! -// There must be a cleaner way of finding out the width of the firmware splash! + if (g.profile[g.id()].firmware().contains("taranis")) + width = SPLASHX9D_WIDTH; ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT))); if (width==SPLASHX9D_WIDTH) { @@ -390,15 +313,14 @@ void appPreferencesDialog::on_SplashSelect_clicked() supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; } - QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); + tr("Open Image to load"), g.imagesDir(), tr("Images (%1)").arg(supportedImageFormats)); - if (!fileName.isEmpty()) { - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); - - if (displayImage(fileName)) - ui->SplashFileName->setText(fileName); + if (!fileName.isEmpty()){ + g.imagesDir(QFileInfo(fileName).dir().absolutePath()); + + displayImage(fileName); + ui->SplashFileName->setText(fileName); } } diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index b6f6c3896..18ce2f1e3 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -26,7 +26,7 @@ private: bool displayImage( QString fileName ); void saveProfile(); void loadProfileString(QString profile, QString label); - void loadProfile(); + void loadFromProfile(); private slots: void writeValues(); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index 9a7680a42..c15874915 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 685 - 462 + 446 @@ -839,16 +839,6 @@ This is used by the templated to determine which channel goes to what number out - - - - - 0 - 0 - - - - @@ -872,7 +862,35 @@ This is used by the templated to determine which channel goes to what number out - + + + + Firmware + + + + + + + false + + + + + + + Select Image + + + + + + + Clear Image + + + + false @@ -885,17 +903,13 @@ This is used by the templated to determine which channel goes to what number out - - - - Firmware - - - - - - - false + + + + + 0 + 0 + @@ -933,20 +947,6 @@ This is used by the templated to determine which channel goes to what number out - - - - Select Image - - - - - - - Clear Image - - - diff --git a/companion/src/burnconfigdialog.cpp b/companion/src/burnconfigdialog.cpp index e0ea4a63e..a2d08fd21 100644 --- a/companion/src/burnconfigdialog.cpp +++ b/companion/src/burnconfigdialog.cpp @@ -3,6 +3,7 @@ #include "avroutputdialog.h" #include "eeprominterface.h" #include "helpers.h" +#include "appdata.h" #include #if !defined WIN32 && defined __GNUC__ @@ -83,33 +84,42 @@ burnConfigDialog::~burnConfigDialog() void burnConfigDialog::getSettings() { - QSettings settings; + avrLoc = g.avrdudeLocation(); + sambaLoc = g.sambaLocation(); + dfuLoc = g.dfuLocation(); + #if defined WIN32 || !defined __GNUC__ - avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString(); - sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString(); - dfuLoc = settings.value("dfu_location", QFileInfo("dfu-util.exe").absoluteFilePath()).toString(); + if ( avrLoc.isEmpty()) + avrLoc = QFileInfo("avrdude.exe").absoluteFilePath(); + if ( sambaLoc.isEmpty()) + sambaLoc = QFileInfo("sam-ba.exe").absoluteFilePath(); + if ( dfuLoc.isEmpty()) + dfuLoc = QFileInfo("dfu-util.exe").absoluteFilePath(); #elif defined __APPLE__ - avrLoc = settings.value("avrdude_location", "/usr/local/bin/avrdude").toString(); - sambaLoc = settings.value("samba_location", "/usr/local/bin/sam-ba").toString(); - dfuLoc = settings.value("dfu_location", QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath()).toString(); + if ( avrLoc.isEmpty()) + avrLoc = "/usr/local/bin/avrdude"; + if ( sambaLoc.isEmpty()) + sambaLoc = "/usr/local/bin/sam-ba"; + if ( dfuLoc.isEmpty()) + dfuLoc = QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath(); #else - avrLoc = settings.value("avrdude_location", "/usr/bin/avrdude").toString(); - sambaLoc = settings.value("samba_location", "/usr/bin/sam-ba").toString(); - dfuLoc = settings.value("dfu_location", QFileInfo("/usr/bin/dfu-util").absoluteFilePath()).toString(); + if ( avrLoc.isEmpty()) + avrLoc = "/usr/bin/avrdude"; + if ( sambaLoc.isEmpty()) + sambaLoc = "/usr/bin/sam-ba"; + if ( dfuLoc.isEmpty()) + dfuLoc = QFileInfo("/usr/bin/dfu-util").absoluteFilePath(); #endif - QString str = settings.value("avr_arguments").toString(); - avrArgs = str.split(" ", QString::SkipEmptyParts); - avrProgrammer = settings.value("programmer", QString("usbasp")).toString(); - avrMCU = settings.value("mcu", QString("m64")).toString(); - armMCU = settings.value("arm_mcu", QString("at91sam3s4-9x")).toString(); + dfuArgs = g.dfuArguments().split(" ", QString::SkipEmptyParts); + avrArgs = g.avrArguments().split(" ", QString::SkipEmptyParts); + avrProgrammer = g.programmer(); + avrPort = g.avrPort(); + avrMCU = g.mcu(); + armMCU = g.armMcu(); + sambaPort = g.sambaPort(); - avrPort = settings.value("avr_port", "").toString(); - sambaPort = settings.value("samba_port", "\\USBserial\\COM23").toString(); - - str = settings.value("dfu_arguments", "-a 0").toString(); - dfuArgs = str.split(" ", QString::SkipEmptyParts); ui->avrdude_location->setText(getAVRDUDE()); ui->avrArgs->setText(getAVRArgs().join(" ")); @@ -137,17 +147,16 @@ void burnConfigDialog::getSettings() void burnConfigDialog::putSettings() { - QSettings settings; - settings.setValue("avrdude_location", avrLoc); - settings.setValue("programmer", avrProgrammer); - settings.setValue("mcu", avrMCU); - settings.setValue("avr_port", avrPort); - settings.setValue("avr_arguments", avrArgs.join(" ")); - settings.setValue("samba_location", sambaLoc); - settings.setValue("samba_port", sambaPort); - settings.setValue("arm_mcu", armMCU); - settings.setValue("dfu_location", dfuLoc); - settings.setValue("dfu_arguments", dfuArgs.join(" ")); + g.avrdudeLocation( avrLoc ); + g.programmer( avrProgrammer); + g.mcu( avrMCU ); + g.avrPort( avrPort ); + g.avrArguments( avrArgs.join(" ") ); + g.sambaLocation( sambaLoc ); + g.sambaPort( sambaPort ); + g.armMcu( armMCU ); + g.dfuLocation( dfuLoc ); + g.dfuArguments( dfuArgs.join(" ") ); } void burnConfigDialog::populateProgrammers() diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp index bfdf0bc76..e7f48e0b3 100644 --- a/companion/src/burndialog.cpp +++ b/companion/src/burndialog.cpp @@ -7,6 +7,7 @@ #include "splashlibrary.h" #include "flashinterface.h" #include "hexinterface.h" +#include "appdata.h" burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName): QDialog(parent), @@ -58,15 +59,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac else { setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName)); } - QSettings settings; - int profileid=settings.value("profileId", 1).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profileid); - settings.beginGroup(profile); - QString Name=settings.value("Name","").toString(); - settings.endGroup(); - settings.endGroup(); - ui->profile_label->setText(tr("Current profile")+QString(": ")+Name); + ui->profile_label->setText(tr("Current profile")+QString(": ")+g.profile[g.id()].name()); } if (!hexfileName->isEmpty()) { ui->FWFileName->setText(*hexfileName); @@ -76,20 +69,13 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac else { burnraw=false; if (checkeEprom(*hexfileName)) { - QSettings settings; - int profileid=settings.value("profileId", 1).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profileid); - settings.beginGroup(profile); - QString Name=settings.value("Name","").toString(); - QString calib=settings.value("StickPotCalib","").toString(); - QString trainercalib=settings.value("TrainerCalib","").toString(); - QString DisplaySet=settings.value("Display","").toString(); - QString BeeperSet=settings.value("Beeper","").toString(); - QString HapticSet=settings.value("Haptic","").toString(); - QString SpeakerSet=settings.value("Speaker","").toString(); - settings.endGroup(); - settings.endGroup(); + QString Name = g.profile[g.id()].name(); + QString calib = g.profile[g.id()].stickPotCalib(); + QString trainercalib = g.profile[g.id()].trainerCalib(); + QString DisplaySet = g.profile[g.id()].display(); + QString BeeperSet = g.profile[g.id()].beeper(); + QString HapticSet = g.profile[g.id()].haptic(); + QString SpeakerSet = g.profile[g.id()].speaker(); if (!Name.isEmpty()) { ui->profile_label->show(); ui->patchcalib_CB->show(); @@ -119,9 +105,8 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac hexfileName->clear(); } else if (Type==2) { - QSettings settings; QString FileName; - FileName = settings.value("lastFw").toString(); + FileName = g.lastFw(); QFile file(FileName); if (file.exists()) { checkFw(FileName); @@ -138,7 +123,7 @@ burnDialog::~burnDialog() void burnDialog::on_FlashLoadButton_clicked() { QString fileName; - QSettings settings; + ui->ImageLoadButton->setDisabled(true); ui->libraryButton->setDisabled(true); ui->InvertColorButton->setDisabled(true); @@ -155,11 +140,11 @@ void burnDialog::on_FlashLoadButton_clicked() ui->EEbackupCB->hide(); QTimer::singleShot(0, this, SLOT(shrink())); if (hexType==2) { - fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); + fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.flashDir(), FLASH_FILES_FILTER); checkFw(fileName); } else { - QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER)); + QString fileName = QFileDialog::getOpenFileName(this,tr("Choose file to load Models and Settings from"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); if (checkeEprom(fileName)) { if (burnraw==false) { ui->BurnFlashButton->setEnabled(true); @@ -191,7 +176,6 @@ void burnDialog::checkFw(QString fileName) if (fileName.isEmpty()) { return; } - QSettings settings; if (!IS_TARANIS(GetEepromInterface()->getBoard())) { ui->EEbackupCB->show(); } @@ -216,8 +200,8 @@ void burnDialog::checkFw(QString fileName) ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight()); ui->FwImage->show(); ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash())); - QString ImageStr = settings.value("SplashImage", "").toString(); - bool PatchFwCB = settings.value("patchImage", false).toBool(); + QString ImageStr = g.profile[g.id()].splashFile(); + bool PatchFwCB = g.profile[g.id()].patchImage(); if (!ImageStr.isEmpty()) { QImage Image = qstring2image(ImageStr); ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat()))); @@ -260,7 +244,7 @@ void burnDialog::checkFw(QString fileName) ui->BurnFlashButton->setEnabled(true); } QTimer::singleShot(0, this, SLOT(shrink())); - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); + g.flashDir( QFileInfo(fileName).dir().absolutePath() ); } bool burnDialog::checkeEprom(QString fileName) @@ -360,12 +344,11 @@ void burnDialog::on_ImageLoadButton_clicked() supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; } - QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); + tr("Open Image to load"), g.imagesDir(), tr("Images (%1)").arg(supportedImageFormats)); if (!fileName.isEmpty()) { - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); + g.imagesDir( QFileInfo(fileName).dir().absolutePath() ); QImage image(fileName); if (image.isNull()) { QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); @@ -442,11 +425,10 @@ void burnDialog::on_BurnFlashButton_clicked() if (hexType==2) { QString fileName=ui->FWFileName->text(); if (!fileName.isEmpty()) { - QSettings settings; - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); - settings.setValue("lastFw", fileName); + g.flashDir( QFileInfo(fileName).dir().absolutePath() ); + g.lastFw( fileName ); if (ui->PatchFWCB->isChecked()) { - settings.setValue("patchImage", true); + g.profile[g.id()].patchImage( true ); QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height()); if (!image.isNull()) { QString tempDir = QDir::tempPath(); @@ -469,7 +451,7 @@ void burnDialog::on_BurnFlashButton_clicked() QMessageBox::critical(this, tr("Warning"), tr("Custom image not found")); } } else { - settings.setValue("patchImage", false); + g.profile[g.id()].patchImage( false ); hexfileName->clear(); hexfileName->append(fileName); } @@ -479,26 +461,19 @@ void burnDialog::on_BurnFlashButton_clicked() } } if (hexType==1) { - QSettings settings; - int profileid=settings.value("profileId", 1).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profileid); - settings.beginGroup(profile); - QString calib=settings.value("StickPotCalib","").toString(); - QString trainercalib=settings.value("TrainerCalib","").toString(); + QString calib = g.profile[g.id()].stickPotCalib(); + QString trainercalib = g.profile[g.id()].trainerCalib(); int potsnum=GetEepromInterface()->getCapability(Pots); - int8_t vBatCalib=(int8_t)settings.value("VbatCalib", radioData.generalSettings.vBatCalib).toInt(); - int8_t currentCalib=(int8_t)settings.value("currentCalib", radioData.generalSettings.currentCalib).toInt(); - int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", radioData.generalSettings.PPM_Multiplier).toInt(); - uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", radioData.generalSettings.stickMode).toUInt(); - uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",radioData.generalSettings.vBatWarn).toUInt(); + int8_t vBatCalib=(int8_t) g.profile[g.id()].vBatCalib(); + int8_t currentCalib=(int8_t) g.profile[g.id()].currentCalib(); + int8_t PPM_Multiplier=(int8_t) g.profile[g.id()].ppmMultiplier(); + uint8_t GSStickMode=(uint8_t) g.profile[g.id()].gsStickMode(); + uint8_t vBatWarn=(uint8_t) g.profile[g.id()].vBatWarn(); - QString DisplaySet=settings.value("Display","").toString(); - QString BeeperSet=settings.value("Beeper","").toString(); - QString HapticSet=settings.value("Haptic","").toString(); - QString SpeakerSet=settings.value("Speaker","").toString(); - settings.endGroup(); - settings.endGroup(); + QString DisplaySet= g.profile[g.id()].display(); + QString BeeperSet= g.profile[g.id()].beeper(); + QString HapticSet= g.profile[g.id()].haptic(); + QString SpeakerSet= g.profile[g.id()].speaker(); bool patch=false; if (ui->patchcalib_CB->isChecked()) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { @@ -656,8 +631,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked) { QString tmpFileName; if (checked) { - QSettings settings; - QString ImageStr = settings.value("SplashImage", "").toString(); + QString ImageStr = g.profile[g.id()].splashFile(); if (!ImageStr.isEmpty()) { QImage Image = qstring2image(ImageStr); if (ui->imageLabel->width()!=128) { diff --git a/companion/src/main.cpp b/companion/src/companion.cpp similarity index 72% rename from companion/src/main.cpp rename to companion/src/companion.cpp index ffaea6801..96a6d5597 100644 --- a/companion/src/main.cpp +++ b/companion/src/companion.cpp @@ -45,12 +45,12 @@ #include #include #include -#include #include #include #include #include "mainwindow.h" #include "eeprominterface.h" +#include "appdata.h" #if defined WIN32 || !defined __GNUC__ #include @@ -86,46 +86,27 @@ int main(int argc, char *argv[]) app.setStyle(new MyProxyStyle); #endif - // Start by borrowing any left over settings from companion9x - QSettings c9x_settings("companion9x", "companion9x"); - QSettings settings; - - if (!settings.contains("pos")) { - QStringList keys = c9x_settings.allKeys(); - for (QStringList::iterator i=keys.begin(); i!=keys.end(); i++) { - settings.setValue(*i, c9x_settings.value(*i)); - } - } - - QString dir; - if (argc) dir = QFileInfo(argv[0]).canonicalPath() + "/lang"; - - QString locale = settings.value("locale",QLocale::system().name()).toString(); - bool showSplash = settings.value("show_splash", true).toBool(); - QTranslator companionTranslator; - companionTranslator.load(":/companion_" + locale); + companionTranslator.load(":/companion_" + g.locale()); QTranslator qtTranslator; - qtTranslator.load((QString)"qt_" + locale.left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + qtTranslator.load((QString)"qt_" + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&companionTranslator); app.installTranslator(&qtTranslator); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); - QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); - firmware_id.replace("open9x", "opentx"); - firmware_id.replace("x9da", "taranis"); + if (g.profile[g.id()].firmware().isEmpty()) + g.profile[g.id()].firmware(default_firmware_variant.id); - QPixmap pixmap = QPixmap(firmware_id.contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png"); + QPixmap pixmap = QPixmap(g.profile[g.id()].firmware().contains("taranis") ? ":/images/splasht.png" : ":/images/splash.png"); QSplashScreen *splash = new QSplashScreen(pixmap); RegisterFirmwares(); - settings.setValue("firmware", firmware_id); - current_firmware_variant = GetFirmwareVariant(firmware_id); + current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware()); MainWindow *mainWin = new MainWindow(); - if (showSplash) { + if (g.showSplash()) { splash->show(); QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); diff --git a/companion/src/companion.qrc b/companion/src/companion.qrc index 832e5ef2f..1c4550d1a 100644 --- a/companion/src/companion.qrc +++ b/companion/src/companion.qrc @@ -981,177 +981,177 @@ themes/monowhite/48/contributors.png themes/monowhite/48/stop.png themes/monowhite/48/write_eeprom.png - themes/new/16/paintbrush.png - themes/new/16/open.png - themes/new/16/edit.png - themes/new/16/information.png - themes/new/16/configure.png - themes/new/16/list.png - themes/new/16/wizard.png - themes/new/16/logs.png - themes/new/16/new.png - themes/new/16/save.png - themes/new/16/recentdocument.png - themes/new/16/simulate.png - themes/new/16/changelog.png - themes/new/16/copy.png - themes/new/16/write_flash.png - themes/new/16/read_eeprom_file.png - themes/new/16/clear.png - themes/new/16/play.png - themes/new/16/fuses.png - themes/new/16/arrow-right.png - themes/new/16/exit.png - themes/new/16/moveup.png - themes/new/16/read_eeprom.png - themes/new/16/cut.png - themes/new/16/arrow-left.png - themes/new/16/write_eeprom_file.png - themes/new/16/library.png - themes/new/16/profiles.png - themes/new/16/paste.png - themes/new/16/print.png - themes/new/16/compare.png - themes/new/16/saveas.png - themes/new/16/apppreferences.png - themes/new/16/fwpreferences.png - themes/new/16/movedown.png - themes/new/16/currentmodel.png - themes/new/16/read_flash.png - themes/new/16/duplicate.png - themes/new/16/add.png - themes/new/16/update.png - themes/new/16/contributors.png - themes/new/16/stop.png - themes/new/16/write_eeprom.png - themes/new/24/paintbrush.png - themes/new/24/open.png - themes/new/24/edit.png - themes/new/24/information.png - themes/new/24/configure.png - themes/new/24/list.png - themes/new/24/wizard.png - themes/new/24/logs.png - themes/new/24/new.png - themes/new/24/save.png - themes/new/24/recentdocument.png - themes/new/24/simulate.png - themes/new/24/changelog.png - themes/new/24/copy.png - themes/new/24/write_flash.png - themes/new/24/read_eeprom_file.png - themes/new/24/clear.png - themes/new/24/play.png - themes/new/24/fuses.png - themes/new/24/arrow-right.png - themes/new/24/exit.png - themes/new/24/moveup.png - themes/new/24/read_eeprom.png - themes/new/24/cut.png - themes/new/24/arrow-left.png - themes/new/24/write_eeprom_file.png - themes/new/24/library.png - themes/new/24/profiles.png - themes/new/24/paste.png - themes/new/24/print.png - themes/new/24/compare.png - themes/new/24/saveas.png - themes/new/24/apppreferences.png - themes/new/24/fwpreferences.png - themes/new/24/movedown.png - themes/new/24/currentmodel.png - themes/new/24/read_flash.png - themes/new/24/duplicate.png - themes/new/24/add.png - themes/new/24/update.png - themes/new/24/contributors.png - themes/new/24/stop.png - themes/new/24/write_eeprom.png - themes/new/32/paintbrush.png - themes/new/32/open.png - themes/new/32/edit.png - themes/new/32/information.png - themes/new/32/configure.png - themes/new/32/list.png - themes/new/32/wizard.png - themes/new/32/logs.png - themes/new/32/new.png - themes/new/32/save.png - themes/new/32/recentdocument.png - themes/new/32/simulate.png - themes/new/32/changelog.png - themes/new/32/copy.png - themes/new/32/write_flash.png - themes/new/32/read_eeprom_file.png - themes/new/32/clear.png - themes/new/32/play.png - themes/new/32/fuses.png - themes/new/32/arrow-right.png - themes/new/32/exit.png - themes/new/32/moveup.png - themes/new/32/read_eeprom.png - themes/new/32/cut.png - themes/new/32/arrow-left.png - themes/new/32/write_eeprom_file.png - themes/new/32/library.png - themes/new/32/profiles.png - themes/new/32/paste.png - themes/new/32/print.png - themes/new/32/compare.png - themes/new/32/saveas.png - themes/new/32/apppreferences.png - themes/new/32/fwpreferences.png - themes/new/32/movedown.png - themes/new/32/currentmodel.png - themes/new/32/read_flash.png - themes/new/32/duplicate.png - themes/new/32/add.png - themes/new/32/update.png - themes/new/32/contributors.png - themes/new/32/stop.png - themes/new/32/write_eeprom.png - themes/new/48/paintbrush.png - themes/new/48/open.png - themes/new/48/edit.png - themes/new/48/information.png - themes/new/48/configure.png - themes/new/48/list.png - themes/new/48/wizard.png - themes/new/48/logs.png - themes/new/48/new.png - themes/new/48/save.png - themes/new/48/recentdocument.png - themes/new/48/simulate.png - themes/new/48/changelog.png - themes/new/48/copy.png - themes/new/48/write_flash.png - themes/new/48/read_eeprom_file.png - themes/new/48/clear.png - themes/new/48/play.png - themes/new/48/fuses.png - themes/new/48/arrow-right.png - themes/new/48/exit.png - themes/new/48/moveup.png - themes/new/48/read_eeprom.png - themes/new/48/cut.png - themes/new/48/arrow-left.png - themes/new/48/write_eeprom_file.png - themes/new/48/library.png - themes/new/48/profiles.png - themes/new/48/paste.png - themes/new/48/print.png - themes/new/48/compare.png - themes/new/48/saveas.png - themes/new/48/apppreferences.png - themes/new/48/fwpreferences.png - themes/new/48/movedown.png - themes/new/48/currentmodel.png - themes/new/48/read_flash.png - themes/new/48/duplicate.png - themes/new/48/add.png - themes/new/48/update.png - themes/new/48/contributors.png - themes/new/48/stop.png - themes/new/48/write_eeprom.png + themes/yerico/16/paintbrush.png + themes/yerico/16/open.png + themes/yerico/16/edit.png + themes/yerico/16/information.png + themes/yerico/16/configure.png + themes/yerico/16/list.png + themes/yerico/16/wizard.png + themes/yerico/16/logs.png + themes/yerico/16/new.png + themes/yerico/16/save.png + themes/yerico/16/recentdocument.png + themes/yerico/16/simulate.png + themes/yerico/16/changelog.png + themes/yerico/16/copy.png + themes/yerico/16/write_flash.png + themes/yerico/16/read_eeprom_file.png + themes/yerico/16/clear.png + themes/yerico/16/play.png + themes/yerico/16/fuses.png + themes/yerico/16/arrow-right.png + themes/yerico/16/exit.png + themes/yerico/16/moveup.png + themes/yerico/16/read_eeprom.png + themes/yerico/16/cut.png + themes/yerico/16/arrow-left.png + themes/yerico/16/write_eeprom_file.png + themes/yerico/16/library.png + themes/yerico/16/profiles.png + themes/yerico/16/paste.png + themes/yerico/16/print.png + themes/yerico/16/compare.png + themes/yerico/16/saveas.png + themes/yerico/16/apppreferences.png + themes/yerico/16/fwpreferences.png + themes/yerico/16/movedown.png + themes/yerico/16/currentmodel.png + themes/yerico/16/read_flash.png + themes/yerico/16/duplicate.png + themes/yerico/16/add.png + themes/yerico/16/update.png + themes/yerico/16/contributors.png + themes/yerico/16/stop.png + themes/yerico/16/write_eeprom.png + themes/yerico/24/paintbrush.png + themes/yerico/24/open.png + themes/yerico/24/edit.png + themes/yerico/24/information.png + themes/yerico/24/configure.png + themes/yerico/24/list.png + themes/yerico/24/wizard.png + themes/yerico/24/logs.png + themes/yerico/24/new.png + themes/yerico/24/save.png + themes/yerico/24/recentdocument.png + themes/yerico/24/simulate.png + themes/yerico/24/changelog.png + themes/yerico/24/copy.png + themes/yerico/24/write_flash.png + themes/yerico/24/read_eeprom_file.png + themes/yerico/24/clear.png + themes/yerico/24/play.png + themes/yerico/24/fuses.png + themes/yerico/24/arrow-right.png + themes/yerico/24/exit.png + themes/yerico/24/moveup.png + themes/yerico/24/read_eeprom.png + themes/yerico/24/cut.png + themes/yerico/24/arrow-left.png + themes/yerico/24/write_eeprom_file.png + themes/yerico/24/library.png + themes/yerico/24/profiles.png + themes/yerico/24/paste.png + themes/yerico/24/print.png + themes/yerico/24/compare.png + themes/yerico/24/saveas.png + themes/yerico/24/apppreferences.png + themes/yerico/24/fwpreferences.png + themes/yerico/24/movedown.png + themes/yerico/24/currentmodel.png + themes/yerico/24/read_flash.png + themes/yerico/24/duplicate.png + themes/yerico/24/add.png + themes/yerico/24/update.png + themes/yerico/24/contributors.png + themes/yerico/24/stop.png + themes/yerico/24/write_eeprom.png + themes/yerico/32/paintbrush.png + themes/yerico/32/open.png + themes/yerico/32/edit.png + themes/yerico/32/information.png + themes/yerico/32/configure.png + themes/yerico/32/list.png + themes/yerico/32/wizard.png + themes/yerico/32/logs.png + themes/yerico/32/new.png + themes/yerico/32/save.png + themes/yerico/32/recentdocument.png + themes/yerico/32/simulate.png + themes/yerico/32/changelog.png + themes/yerico/32/copy.png + themes/yerico/32/write_flash.png + themes/yerico/32/read_eeprom_file.png + themes/yerico/32/clear.png + themes/yerico/32/play.png + themes/yerico/32/fuses.png + themes/yerico/32/arrow-right.png + themes/yerico/32/exit.png + themes/yerico/32/moveup.png + themes/yerico/32/read_eeprom.png + themes/yerico/32/cut.png + themes/yerico/32/arrow-left.png + themes/yerico/32/write_eeprom_file.png + themes/yerico/32/library.png + themes/yerico/32/profiles.png + themes/yerico/32/paste.png + themes/yerico/32/print.png + themes/yerico/32/compare.png + themes/yerico/32/saveas.png + themes/yerico/32/apppreferences.png + themes/yerico/32/fwpreferences.png + themes/yerico/32/movedown.png + themes/yerico/32/currentmodel.png + themes/yerico/32/read_flash.png + themes/yerico/32/duplicate.png + themes/yerico/32/add.png + themes/yerico/32/update.png + themes/yerico/32/contributors.png + themes/yerico/32/stop.png + themes/yerico/32/write_eeprom.png + themes/yerico/48/paintbrush.png + themes/yerico/48/open.png + themes/yerico/48/edit.png + themes/yerico/48/information.png + themes/yerico/48/configure.png + themes/yerico/48/list.png + themes/yerico/48/wizard.png + themes/yerico/48/logs.png + themes/yerico/48/new.png + themes/yerico/48/save.png + themes/yerico/48/recentdocument.png + themes/yerico/48/simulate.png + themes/yerico/48/changelog.png + themes/yerico/48/copy.png + themes/yerico/48/write_flash.png + themes/yerico/48/read_eeprom_file.png + themes/yerico/48/clear.png + themes/yerico/48/play.png + themes/yerico/48/fuses.png + themes/yerico/48/arrow-right.png + themes/yerico/48/exit.png + themes/yerico/48/moveup.png + themes/yerico/48/read_eeprom.png + themes/yerico/48/cut.png + themes/yerico/48/arrow-left.png + themes/yerico/48/write_eeprom_file.png + themes/yerico/48/library.png + themes/yerico/48/profiles.png + themes/yerico/48/paste.png + themes/yerico/48/print.png + themes/yerico/48/compare.png + themes/yerico/48/saveas.png + themes/yerico/48/apppreferences.png + themes/yerico/48/fwpreferences.png + themes/yerico/48/movedown.png + themes/yerico/48/currentmodel.png + themes/yerico/48/read_flash.png + themes/yerico/48/duplicate.png + themes/yerico/48/add.png + themes/yerico/48/update.png + themes/yerico/48/contributors.png + themes/yerico/48/stop.png + themes/yerico/48/write_eeprom.png diff --git a/companion/src/comparedialog.cpp b/companion/src/comparedialog.cpp index 1309857c4..3465037e8 100644 --- a/companion/src/comparedialog.cpp +++ b/companion/src/comparedialog.cpp @@ -29,6 +29,7 @@ compareDialog::compareDialog(QWidget *parent, GeneralSettings *gg) : ui(new Ui::compareDialog) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("compare.png")); g_eeGeneral = gg; eepromInterface = GetEepromInterface(); te = ui->textEdit; diff --git a/companion/src/comparedialog.ui b/companion/src/comparedialog.ui index 6f11bf138..4a26482b0 100644 --- a/companion/src/comparedialog.ui +++ b/companion/src/comparedialog.ui @@ -26,11 +26,7 @@ false - Dialog - - - - :/icon.png:/icon.png + Compare Models diff --git a/companion/src/contributorsdialog.cpp b/companion/src/contributorsdialog.cpp index 54d32f9f7..8aefa222b 100644 --- a/companion/src/contributorsdialog.cpp +++ b/companion/src/contributorsdialog.cpp @@ -1,6 +1,7 @@ #include "contributorsdialog.h" #include "ui_contributorsdialog.h" #include +#include "helpers.h" contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnurl) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), @@ -10,6 +11,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu switch (contest) { case 0: { + this->setWindowIcon(CompanionIcon("contributors.png")); QFile file(":/DONATIONS.txt"); QString str; str.append(""); @@ -79,6 +81,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu case 1: { + this->setWindowIcon(CompanionIcon("changelog.png")); QFile file(":/releasenotes.txt"); if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { ui->textEditor->setHtml(file.readAll()); @@ -91,6 +94,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu case 2: { if (!rnurl.isEmpty()) { + this->setWindowIcon(CompanionIcon("changelog.png")); this->setWindowTitle(tr("OpenTX Release Notes")); manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); diff --git a/companion/src/contributorsdialog.ui b/companion/src/contributorsdialog.ui index 6ae7866c8..5d7d670c1 100644 --- a/companion/src/contributorsdialog.ui +++ b/companion/src/contributorsdialog.ui @@ -13,10 +13,6 @@ Dialog - - - :/icon.png:/icon.png - diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 420266b7a..b4d901836 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -2,6 +2,7 @@ #include "ui_customizesplashdialog.h" #include +#include "appdata.h" #include "helpers.h" #include "burndialog.h" #include "splashlibrary.h" @@ -28,9 +29,10 @@ bool Side::displayImage( QString fileName, Source pictSource ) { QImage image; - if (fileName.isEmpty()) { + if (fileName.isEmpty()) return false; - } + + // Determine which picture format to use if (pictSource == FW ){ FlashInterface flash(fileName); if (!flash.hasSplash()) @@ -40,13 +42,16 @@ bool Side::displayImage( QString fileName, Source pictSource ) *format = (flash.getSplashWidth()==WIDTH_TARANIS ? LCDTARANIS : LCD9X); } else { - image.load(fileName); - if (pictSource== PICT) - *format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X; + image.load(fileName); + if (pictSource== PICT) + *format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X; + else if (pictSource == PROFILE) + *format = (g.profile[g.id()].firmware().contains("taranis")) ? LCDTARANIS : LCD9X; } if (image.isNull()) { return false; } + // Prepare and display image if (*format==LCDTARANIS) { image=image.convertToFormat(QImage::Format_RGB32); QRgb col; @@ -102,8 +107,6 @@ bool Side::refreshImage() bool Side::saveImage() { - QSettings settings; - if (*source == FW ) { FlashInterface flash(*saveToFileName); @@ -112,7 +115,7 @@ bool Side::saveImage() } QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) { - settings.setValue("lastFlashDir", QFileInfo(*saveToFileName).dir().absolutePath()); + g.flashDir( QFileInfo(*saveToFileName).dir().absolutePath() ); } else { return false; @@ -121,7 +124,7 @@ bool Side::saveImage() else if (*source == PICT) { QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); if (image.save(*saveToFileName)) { - settings.setValue("lastImagesDir", QFileInfo(*saveToFileName).dir().absolutePath()); + g.imagesDir( QFileInfo(*saveToFileName).dir().absolutePath() ); } else { return false; @@ -143,6 +146,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) : ui(new Ui::customizeSplashDialog) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("paint.png")); ui->leftLibraryButton->setIcon(CompanionIcon("library.png")); ui->rightLibraryButton->setIcon(CompanionIcon("library.png")); @@ -178,13 +182,12 @@ void customizeSplashDialog::on_leftLoadFwButton_clicked() {loadFirmware(left);} void customizeSplashDialog::on_rightLoadFwButton_clicked() {loadFirmware(right);} void customizeSplashDialog::loadFirmware(Side side) { - QSettings settings; - QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.flashDir(), FLASH_FILES_FILTER); if (!fileName.isEmpty()) { if (!side.displayImage( fileName, FW )) QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName)); else - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); + g.flashDir( QFileInfo(fileName).dir().absolutePath() ); } } @@ -196,15 +199,14 @@ void customizeSplashDialog::loadPicture(Side side) for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) { supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; } - QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, - tr("Open Image to load"), settings.value("lastImagesDir").toString(), tr("Images (%1)").arg(supportedImageFormats)); + tr("Open Image to load"), g.imagesDir(), tr("Images (%1)").arg(supportedImageFormats)); if (!fileName.isEmpty()) { if (!side.displayImage( fileName, PICT )) QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName)); else - settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); + g.imagesDir( QFileInfo(fileName).dir().absolutePath() ); } } @@ -212,8 +214,7 @@ void customizeSplashDialog::on_leftLoadProfileButton_clicked() {loadProfile(left void customizeSplashDialog::on_rightLoadProfileButton_clicked() {loadProfile(right);} void customizeSplashDialog::loadProfile(Side side) { - QSettings settings; - QString fileName=settings.value("SplashFileName","").toString(); + QString fileName=g.profile[g.id()].splashFile(); if (!fileName.isEmpty()) { if (!side.displayImage( fileName, PROFILE )) diff --git a/companion/src/customizesplashdialog.ui b/companion/src/customizesplashdialog.ui index fa6c57d9f..de4d68f24 100644 --- a/companion/src/customizesplashdialog.ui +++ b/companion/src/customizesplashdialog.ui @@ -9,7 +9,7 @@ 0 0 - 1086 + 1087 285 @@ -22,10 +22,6 @@ Transmitter Splash Screen Editor - - - :/icon.png:/icon.png - 6 diff --git a/companion/src/downloaddialog.cpp b/companion/src/downloaddialog.cpp index bfd425619..794dbbcd1 100644 --- a/companion/src/downloaddialog.cpp +++ b/companion/src/downloaddialog.cpp @@ -2,13 +2,14 @@ #include "ui_downloaddialog.h" #include #include +#include "helpers.h" downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) : QDialog(parent), ui(new Ui::downloadDialog) { ui->setupUi(this); - + this->setWindowIcon(CompanionIcon("fwpreferences.png")); ui->progressBar->setValue(1); ui->progressBar->setMinimum(0); ui->progressBar->setMaximum(0); diff --git a/companion/src/downloaddialog.ui b/companion/src/downloaddialog.ui index dcd05c405..f51dfd085 100644 --- a/companion/src/downloaddialog.ui +++ b/companion/src/downloaddialog.ui @@ -13,10 +13,6 @@ Downloading: - - - :/icon.png:/icon.png - diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index bb2861cf8..1df1f4e98 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -6,7 +6,7 @@ #include "firmwares/gruvin9x/gruvin9xinterface.h" #include "firmwares/opentx/opentxinterface.h" #include "firmwares/ersky9x/ersky9xinterface.h" -#include "qsettings.h" +#include "appdata.h" #include "helpers.h" QString EEPROMWarnings; @@ -37,6 +37,47 @@ void getEEPROMString(char *dst, const char *src, int size) } } +float ValToTim(int value) +{ + return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0); +} + +int TimToVal(float value) +{ + int temp; + if (value>60) { + temp=136+round((value-60)); + } + else if (value>2) { + temp=20+round((value-2.0)*2.0); + } + else { + temp=round(value*10.0); + } + return (temp-129); +} + +QString getSignedStr(int value) +{ + return value > 0 ? QString("+%1").arg(value) : QString("%1").arg(value); +} + +QString getGVarString(int16_t val, bool sign) +{ + if (val >= -10000 && val <= 10000) { + if (sign) + return QString("%1%").arg(getSignedStr(val)); + else + return QString("%1%").arg(val); + } + else { + if (val<0) + return QObject::tr("-GV%1").arg(-val-10000); + else + return QObject::tr("GV%1").arg(val-10000); + } +} + RawSourceRange RawSource::getRange(bool singleprec) { RawSourceRange result; @@ -731,34 +772,25 @@ GeneralSettings::GeneralSettings() calibSpanNeg[i] = 0x180; calibSpanPos[i] = 0x180; } - QSettings settings; - templateSetup = settings.value("default_channel_order", 0).toInt(); - stickMode = settings.value("default_mode", 1).toInt(); - int profile_id = settings.value("profileId", 0).toInt(); - if (profile_id>0) { - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profile_id); - settings.beginGroup(profile); - QString t_calib=settings.value("StickPotCalib","").toString(); + templateSetup = g.profile[g.id()].channelOrder(); + stickMode = g.profile[g.id()].defaultMode(); + + QString t_calib=g.profile[g.id()].stickPotCalib(); int potsnum=GetEepromInterface()->getCapability(Pots); if (t_calib.isEmpty()) { - settings.endGroup(); - settings.endGroup(); return; } else { - QString t_trainercalib=settings.value("TrainerCalib","").toString(); - int8_t t_vBatCalib=(int8_t)settings.value("VbatCalib", vBatCalib).toInt(); - int8_t t_currentCalib=(int8_t)settings.value("currentCalib", currentCalib).toInt(); - int8_t t_PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", PPM_Multiplier).toInt(); - uint8_t t_stickMode=(uint8_t)settings.value("GSStickMode", stickMode).toUInt(); - uint8_t t_vBatWarn=(uint8_t)settings.value("vBatWarn",vBatWarn).toUInt(); - QString t_DisplaySet=settings.value("Display","").toString(); - QString t_BeeperSet=settings.value("Beeper","").toString(); - QString t_HapticSet=settings.value("Haptic","").toString(); - QString t_SpeakerSet=settings.value("Speaker","").toString(); - QString t_CountrySet=settings.value("countryCode","").toString(); - settings.endGroup(); - settings.endGroup(); + QString t_trainercalib=g.profile[g.id()].trainerCalib(); + int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib(); + int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib(); + int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier(); + uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode(); + uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn(); + QString t_DisplaySet=g.profile[g.id()].display(); + QString t_BeeperSet=g.profile[g.id()].beeper(); + QString t_HapticSet=g.profile[g.id()].haptic(); + QString t_SpeakerSet=g.profile[g.id()].speaker(); + QString t_CountrySet=g.profile[g.id()].countryCode(); if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) { QString Byte; @@ -840,7 +872,7 @@ GeneralSettings::GeneralSettings() } } } - } + } ModelData::ModelData() @@ -990,15 +1022,13 @@ ModelData ModelData::removeGlobalVars() QList eepromInterfaces; void RegisterEepromInterfaces() { - QSettings settings; - int rev4a = settings.value("rev4asupport",0).toInt(); - eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK)); - eepromInterfaces.push_back(new Open9xInterface(BOARD_M128)); - eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X)); - eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X)); - eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS)); - if (rev4a) - eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a)); + eepromInterfaces.push_back(new OpenTxInterface(BOARD_STOCK)); + eepromInterfaces.push_back(new OpenTxInterface(BOARD_M128)); + eepromInterfaces.push_back(new OpenTxInterface(BOARD_GRUVIN9X)); + eepromInterfaces.push_back(new OpenTxInterface(BOARD_SKY9X)); + eepromInterfaces.push_back(new OpenTxInterface(BOARD_TARANIS)); + if (g.rev4aSupport()) + eepromInterfaces.push_back(new OpenTxInterface(BOARD_TARANIS_REV4a)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new Ersky9xInterface()); @@ -1010,26 +1040,11 @@ QList firmwares; FirmwareVariant default_firmware_variant; FirmwareVariant current_firmware_variant; -const char * ER9X_STAMP = "http://er9x.googlecode.com/svn/trunk/src/stamp-er9x.h"; -const char * ERSKY9X_STAMP = "http://ersky9x.googlecode.com/svn/trunk/src/stamp-ersky9x.h"; - void RegisterFirmwares() { - firmwares.push_back(new FirmwareInfo("th9x", QObject::tr("th9x"), new Th9xInterface(), "http://th9x.googlecode.com/svn/trunk/%1.bin", "http://th9x.googlecode.com/svn/trunk/src/stamp-th9x.h")); - - firmwares.push_back(new FirmwareInfo("er9x", QObject::tr("er9x"), new Er9xInterface(), "http://er9x.googlecode.com/svn/trunk/%1.hex", ER9X_STAMP)); - FirmwareInfo * er9x = firmwares.last(); - - Option er9x_options[] = { { "noht", "", 0 }, { "frsky", "", 0 }, { "frsky-noht", "", 0 }, { "jeti", "", 0 }, { "ardupilot", "", 0 }, { "nmea", "", 0 }, { NULL } }; - er9x->addOptions(er9x_options); - er9x->addOption("noht"); - RegisterOpen9xFirmwares(); -#ifndef __APPLE__ - firmwares.push_back(new FirmwareInfo("ersky9x", QObject::tr("ersky9x"), new Ersky9xInterface(), "http://ersky9x.googlecode.com/svn/trunk/ersky9x_rom.bin", ERSKY9X_STAMP)); -#endif default_firmware_variant = GetFirmwareVariant("opentx-9x-heli-templates-en"); - + current_firmware_variant = default_firmware_variant; RegisterEepromInterfaces(); } @@ -1070,7 +1085,6 @@ FirmwareVariant GetFirmwareVariant(QString id) FirmwareVariant result; foreach(FirmwareInfo * firmware, firmwares) { - if (id.contains(firmware->id+"-") || (!id.contains("-") && id.contains(firmware->id))) { result.id = id; result.firmware = firmware; diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 05d871592..6a85f8cf9 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -950,7 +950,6 @@ enum Capability { FlightPhases, FlightModesName, FlightPhasesHaveFades, - SimulatorType, Mixes, MixesWithoutExpo, Timers, @@ -1059,15 +1058,8 @@ enum Capability { HasFasOffset, HasMahPersistent, MultiposPots, - MultiposPotsPositions -}; - -enum UseContext { - DefaultContext, - TimerContext, - FlightPhaseContext, - MixerContext, - ExpoContext, + MultiposPotsPositions, + SimulatorVariant, }; class SimulatorInterface; @@ -1102,7 +1094,7 @@ class EEPROMInterface virtual int isAvailable(Protocol proto, int port=0) = 0; - virtual SimulatorInterface * getSimulator() = 0; + virtual SimulatorInterface * getSimulator() { return NULL; } virtual const int getEEpromSize() = 0; @@ -1124,6 +1116,12 @@ extern QString EEPROMWarnings; void setEEPROMString(char *dst, const char *src, int size); void getEEPROMString(char *dst, const char *src, int size); +float ValToTim(int value); +int TimToVal(float value); + +QString getSignedStr(int value); +QString getGVarString(int16_t val, bool sign=false); + inline int applyStickMode(int stick, unsigned int mode) { if (mode == 0 || mode > 4) { diff --git a/companion/src/firmwares/er9x/er9xinterface.cpp b/companion/src/firmwares/er9x/er9xinterface.cpp index d28b472b2..a45e5088b 100644 --- a/companion/src/firmwares/er9x/er9xinterface.cpp +++ b/companion/src/firmwares/er9x/er9xinterface.cpp @@ -19,6 +19,7 @@ #include "er9xeeprom.h" #include "er9xsimulator.h" #include "file.h" +#include "appdata.h" #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -44,8 +45,7 @@ const char * Er9xInterface::getName() const int Er9xInterface::getEEpromSize() { - QSettings settings; - QString avrMCU = settings.value("mcu", QString("m64")).toString(); + QString avrMCU = g.mcu(); if (avrMCU==QString("m128")) { return 2*EESIZE_STOCK; } @@ -303,7 +303,7 @@ int Er9xInterface::isAvailable(Protocol prot, int port) SimulatorInterface * Er9xInterface::getSimulator() { - return new Er9xSimulator(this); + return NULL; // new Er9xSimulator(this); } diff --git a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp index dd65c0c92..97ed8fd5b 100644 --- a/companion/src/firmwares/ersky9x/ersky9xinterface.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xinterface.cpp @@ -343,7 +343,7 @@ int Ersky9xInterface::isAvailable(Protocol prot, int port) SimulatorInterface * Ersky9xInterface::getSimulator() { - return new Ersky9xSimulator(this); + return NULL; // new Ersky9xSimulator(this); } diff --git a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp index c3d52923f..a7d1d6f1a 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xinterface.cpp @@ -18,6 +18,7 @@ #include "gruvin9xinterface.h" #include "gruvin9xeeprom.h" #include "file.h" +#include "appdata.h" #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -47,8 +48,7 @@ const char * Gruvin9xInterface::getName() const int Gruvin9xInterface::getEEpromSize() { if (board == BOARD_STOCK) { - QSettings settings; - QString avrMCU = settings.value("mcu", QString("m64")).toString(); + QString avrMCU = g.mcu(); if (avrMCU==QString("m128")) { return EESIZE_STOCK*2; } diff --git a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp index 0d2f07771..fb101b359 100644 --- a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.cpp @@ -105,7 +105,7 @@ uint8_t getStickMode() using namespace Open9xGruvin9x; -Open9xGruvin9xSimulator::Open9xGruvin9xSimulator(Open9xInterface * open9xInterface): +Open9xGruvin9xSimulator::Open9xGruvin9xSimulator(OpenTxInterface * open9xInterface): open9xInterface(open9xInterface) { } @@ -128,15 +128,23 @@ bool Open9xGruvin9xSimulator::lcdChanged(bool & lightEnable) #include "simulatorimport.h" } -void Open9xGruvin9xSimulator::start(RadioData &radioData, bool tests) +void Open9xGruvin9xSimulator::start(QByteArray & eeprom, bool tests) { g_rotenc[0] = 0; g_rotenc[1] = 0; - open9xInterface->save(&eeprom[0], radioData, SIMU_GRUVIN9X_VARIANTS); + memcpy(Open9xGruvin9x::eeprom, eeprom.data(), std::min(sizeof(Open9xGruvin9x::eeprom), eeprom.size())); StartEepromThread(NULL); StartMainThread(tests); } +void Open9xGruvin9xSimulator::start(const char * filename, bool tests) +{ + g_rotenc[0] = 0; + g_rotenc[1] = 0; + StartEepromThread(filename); + StartMainThread(tests); +} + void Open9xGruvin9xSimulator::stop() { StopMainThread(); diff --git a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h index 8216c7a04..6fb3e320a 100644 --- a/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h +++ b/companion/src/firmwares/opentx/opentxGruvin9xsimulator.h @@ -20,15 +20,17 @@ #include "simulatorinterface.h" class RadioData; -class Open9xInterface; +class OpenTxInterface; class Open9xGruvin9xSimulator : public SimulatorInterface { public: - Open9xGruvin9xSimulator(Open9xInterface *); + Open9xGruvin9xSimulator(OpenTxInterface *); - virtual void start(RadioData & radioData, bool tests); + virtual void start(QByteArray & eeprom, bool tests=true); + + virtual void start(const char * filename, bool tests=true); virtual void stop(); @@ -54,7 +56,7 @@ class Open9xGruvin9xSimulator : public SimulatorInterface { protected: - Open9xInterface * open9xInterface; + OpenTxInterface * open9xInterface; }; #endif diff --git a/companion/src/firmwares/opentx/opentxM128simulator.cpp b/companion/src/firmwares/opentx/opentxM128simulator.cpp index f169a10d3..a03045c2d 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.cpp +++ b/companion/src/firmwares/opentx/opentxM128simulator.cpp @@ -103,7 +103,7 @@ uint8_t getStickMode() using namespace Open9xM128; -Open9xM128Simulator::Open9xM128Simulator(Open9xInterface * open9xInterface): +Open9xM128Simulator::Open9xM128Simulator(OpenTxInterface * open9xInterface): open9xInterface(open9xInterface) { } @@ -126,13 +126,19 @@ bool Open9xM128Simulator::lcdChanged(bool & lightEnable) #include "simulatorimport.h" } -void Open9xM128Simulator::start(RadioData &radioData, bool tests) +void Open9xM128Simulator::start(QByteArray & eeprom, bool tests) { - open9xInterface->save(&eeprom[0], radioData, SIMU_M128_VARIANTS); + memcpy(Open9xM128::eeprom, eeprom.data(), std::min(sizeof(Open9xM128::eeprom), eeprom.size())); StartEepromThread(NULL); StartMainThread(tests); } +void Open9xM128Simulator::start(const char * filename, bool tests) +{ + StartEepromThread(filename); + StartMainThread(tests); +} + void Open9xM128Simulator::stop() { StopMainThread(); diff --git a/companion/src/firmwares/opentx/opentxM128simulator.h b/companion/src/firmwares/opentx/opentxM128simulator.h index dc43edc5f..862c7ada9 100644 --- a/companion/src/firmwares/opentx/opentxM128simulator.h +++ b/companion/src/firmwares/opentx/opentxM128simulator.h @@ -20,15 +20,17 @@ #include "simulatorinterface.h" class RadioData; -class Open9xInterface; +class OpenTxInterface; class Open9xM128Simulator : public SimulatorInterface { public: - Open9xM128Simulator(Open9xInterface *); + Open9xM128Simulator(OpenTxInterface *); - virtual void start(RadioData & radioData, bool tests); + virtual void start(QByteArray & eeprom, bool tests=true); + + virtual void start(const char * filename, bool tests=true); virtual void stop(); @@ -54,7 +56,7 @@ class Open9xM128Simulator : public SimulatorInterface { protected: - Open9xInterface * open9xInterface; + OpenTxInterface * open9xInterface; }; #endif diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp index b9f5f294e..e17a14be3 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.cpp @@ -16,6 +16,7 @@ #include "opentxSky9xsimulator.h" #include "opentxinterface.h" +#include "appdata.h" #define SIMU #define SIMU_EXCEPTIONS @@ -132,11 +133,10 @@ uint8_t getStickMode() using namespace Open9xSky9x; -Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface): +Open9xSky9xSimulator::Open9xSky9xSimulator(OpenTxInterface * open9xInterface): open9xInterface(open9xInterface) { - QSettings settings; - QString path=settings.value("sdPath", ".").toString()+"/"; + QString path=g.profile[g.id()].sdPath()+"/"; int i=0; for (i=0; i< std::min(path.length(),1022); i++) { simuSdDirectory[i]=path.at(i).toAscii(); @@ -162,14 +162,21 @@ bool Open9xSky9xSimulator::lcdChanged(bool & lightEnable) #include "simulatorimport.h" } -void Open9xSky9xSimulator::start(RadioData &radioData, bool tests) +void Open9xSky9xSimulator::start(QByteArray & eeprom, bool tests) { g_rotenc[0] = 0; - open9xInterface->save(&eeprom[0], radioData); + memcpy(Open9xSky9x::eeprom, eeprom.data(), std::min(sizeof(Open9xSky9x::eeprom), eeprom.size())); StartEepromThread(NULL); StartMainThread(tests); } +void Open9xSky9xSimulator::start(const char * filename, bool tests) +{ + g_rotenc[0] = 0; + StartEepromThread(filename); + StartMainThread(tests); +} + void Open9xSky9xSimulator::stop() { StopMainThread(); diff --git a/companion/src/firmwares/opentx/opentxSky9xsimulator.h b/companion/src/firmwares/opentx/opentxSky9xsimulator.h index 95463fbab..0489fea1d 100644 --- a/companion/src/firmwares/opentx/opentxSky9xsimulator.h +++ b/companion/src/firmwares/opentx/opentxSky9xsimulator.h @@ -20,15 +20,17 @@ #include "simulatorinterface.h" class RadioData; -class Open9xInterface; +class OpenTxInterface; class Open9xSky9xSimulator : public SimulatorInterface { public: - Open9xSky9xSimulator(Open9xInterface *); + Open9xSky9xSimulator(OpenTxInterface *); - virtual void start(RadioData & radioData, bool tests); + virtual void start(QByteArray & eeprom, bool tests=true); + + virtual void start(const char * filename, bool tests=true); virtual void stop(); @@ -54,7 +56,7 @@ class Open9xSky9xSimulator : public SimulatorInterface { protected: - Open9xInterface * open9xInterface; + OpenTxInterface * open9xInterface; }; #endif diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp index 266dd8c7f..13db450d7 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.cpp @@ -16,6 +16,7 @@ #include "opentxTaranisSimulator.h" #include "opentxinterface.h" +#include "appdata.h" #define SIMU #define SIMU_EXCEPTIONS @@ -177,12 +178,11 @@ void resetTrims() using namespace Open9xX9D; -OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface): +OpentxTaranisSimulator::OpentxTaranisSimulator(OpenTxInterface * open9xInterface): open9xInterface(open9xInterface) { taranisSimulatorBoard = GetEepromInterface()->getBoard(); - QSettings settings; - QString path=settings.value("sdPath", ".").toString()+"/"; + QString path=g.profile[g.id()].sdPath()+"/"; int i=0; for (i=0; i< std::min(path.length(),1022); i++) { simuSdDirectory[i]=path.at(i).toAscii(); @@ -208,13 +208,19 @@ bool OpentxTaranisSimulator::lcdChanged(bool & lightEnable) #include "simulatorimport.h" } -void OpentxTaranisSimulator::start(RadioData &radioData, bool tests) +void OpentxTaranisSimulator::start(QByteArray & eeprom, bool tests) { - open9xInterface->save(Open9xX9D::eeprom, radioData); + memcpy(Open9xX9D::eeprom, eeprom.data(), std::min(sizeof(Open9xX9D::eeprom), eeprom.size())); StartEepromThread(NULL); StartMainThread(tests); } +void OpentxTaranisSimulator::start(const char * filename, bool tests) +{ + StartEepromThread(filename); + StartMainThread(tests); +} + void OpentxTaranisSimulator::stop() { StopMainThread(); diff --git a/companion/src/firmwares/opentx/opentxTaranisSimulator.h b/companion/src/firmwares/opentx/opentxTaranisSimulator.h index c14f9c16c..bd2da1d2a 100644 --- a/companion/src/firmwares/opentx/opentxTaranisSimulator.h +++ b/companion/src/firmwares/opentx/opentxTaranisSimulator.h @@ -20,15 +20,17 @@ #include "simulatorinterface.h" class RadioData; -class Open9xInterface; +class OpenTxInterface; class OpentxTaranisSimulator : public SimulatorInterface { public: - OpentxTaranisSimulator(Open9xInterface *); + OpentxTaranisSimulator(OpenTxInterface *); - virtual void start(RadioData & radioData, bool tests); + virtual void start(QByteArray & eeprom, bool tests=true); + + virtual void start(const char * filename, bool tests=true); virtual void stop(); @@ -54,7 +56,7 @@ class OpentxTaranisSimulator : public SimulatorInterface { protected: - Open9xInterface * open9xInterface; + OpenTxInterface * open9xInterface; }; #endif diff --git a/companion/src/firmwares/opentx/opentxeeprom.h b/companion/src/firmwares/opentx/opentxeeprom.h index 50421ea0f..3a5f3ffa0 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.h +++ b/companion/src/firmwares/opentx/opentxeeprom.h @@ -30,8 +30,6 @@ #define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT) #define SIMU_M128_VARIANTS (M128_VARIANT|SIMU_STOCK_VARIANTS) -#define SIMU_GRUVIN9X_VARIANTS (0) -#define SIMU_ARM_VARIANTS (0) #define O9X_MAX_TIMERS 2 #define O9X_MAX_PHASES 5 diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index d61ef76f6..2f4b0409b 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -26,6 +26,7 @@ #include "opentxSky9xsimulator.h" #include "opentxTaranisSimulator.h" #include "file.h" +#include "appdata.h" #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -42,18 +43,18 @@ size_t SizeOfArray( T(&)[ N ] ) return N; } -Open9xInterface::Open9xInterface(BoardEnum board): +OpenTxInterface::OpenTxInterface(BoardEnum board): EEPROMInterface(board), efile(new EFile()) { } -Open9xInterface::~Open9xInterface() +OpenTxInterface::~OpenTxInterface() { delete efile; } -const char * Open9xInterface::getName() +const char * OpenTxInterface::getName() { switch (board) { case BOARD_STOCK: @@ -73,7 +74,7 @@ const char * Open9xInterface::getName() } } -const int Open9xInterface::getEEpromSize() +const int OpenTxInterface::getEEpromSize() { switch (board) { case BOARD_STOCK: @@ -93,7 +94,7 @@ const int Open9xInterface::getEEpromSize() } } -const int Open9xInterface::getMaxModels() +const int OpenTxInterface::getMaxModels() { if (IS_ARM(board)) return 60; @@ -106,7 +107,7 @@ const int Open9xInterface::getMaxModels() } template -bool Open9xInterface::loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode) +bool OpenTxInterface::loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode) { T _model; @@ -139,7 +140,7 @@ bool Open9xInterface::loadModel(ModelData &model, uint8_t *data, int index, unsi } template -bool Open9xInterface::loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant) +bool OpenTxInterface::loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant) { T open9xModel(model, board, version, variant); @@ -166,7 +167,7 @@ bool Open9xInterface::loadModelVariant(unsigned int index, ModelData &model, uin return true; } -bool Open9xInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode) +bool OpenTxInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode) { if (version == 201) { return loadModel(model, data, index, stickMode); @@ -247,7 +248,7 @@ bool Open9xInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data } template -bool Open9xInterface::loadGeneral(GeneralSettings &settings, unsigned int version) +bool OpenTxInterface::loadGeneral(GeneralSettings &settings, unsigned int version) { QByteArray eepromData(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct T open9xSettings(settings, board, version); @@ -263,7 +264,7 @@ bool Open9xInterface::loadGeneral(GeneralSettings &settings, unsigned int versio } template -bool Open9xInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant) +bool OpenTxInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant) { T open9xSettings(settings, board, version, variant); // open9xSettings.Dump(); @@ -274,7 +275,7 @@ bool Open9xInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, ui } template -bool Open9xInterface::saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant) +bool OpenTxInterface::saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant) { T open9xModel(model, board, version, variant); // open9xModel.Dump(); @@ -284,12 +285,12 @@ bool Open9xInterface::saveModel(unsigned int index, ModelData &model, unsigned i return (sz == eeprom.size()); } -bool Open9xInterface::loadxml(RadioData &radioData, QDomDocument &doc) +bool OpenTxInterface::loadxml(RadioData &radioData, QDomDocument &doc) { return false; } -bool Open9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size) +bool OpenTxInterface::load(RadioData &radioData, uint8_t *eeprom, int size) { std::cout << "trying " << getName() << " import..."; @@ -350,7 +351,7 @@ bool Open9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size) return true; } -int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version) +int OpenTxInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version) { EEPROMWarnings.clear(); @@ -403,7 +404,7 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian return size; } -int Open9xInterface::getSize(ModelData &model) +int OpenTxInterface::getSize(ModelData &model) { if (board == BOARD_SKY9X) return 0; @@ -426,7 +427,7 @@ int Open9xInterface::getSize(ModelData &model) return efile->size(0); } -int Open9xInterface::getSize(GeneralSettings &settings) +int OpenTxInterface::getSize(GeneralSettings &settings) { if (board == BOARD_SKY9X) return 0; @@ -446,7 +447,7 @@ int Open9xInterface::getSize(GeneralSettings &settings) return efile->size(0); } -int Open9xInterface::getCapability(const Capability capability) +int OpenTxInterface::getCapability(const Capability capability) { switch (capability) { case OwnerName: @@ -456,11 +457,6 @@ int Open9xInterface::getCapability(const Capability capability) return 1; else return 0; - case SimulatorType: - if (IS_TARANIS(board)) - return 1; - else - return 0; case HasBeeper: if (IS_ARM(board)) return 0; @@ -687,12 +683,19 @@ int Open9xInterface::getCapability(const Capability capability) return IS_TARANIS(board) ? 2 : 0; case MultiposPotsPositions: return IS_TARANIS(board) ? 6 : 0; + case SimulatorVariant: + if (board == BOARD_STOCK) + return SIMU_STOCK_VARIANTS; + else if (board == BOARD_M128) + return SIMU_M128_VARIANTS; + else + return 0; default: return 0; } } -int Open9xInterface::isAvailable(Protocol proto, int port) +int OpenTxInterface::isAvailable(Protocol proto, int port) { if (IS_TARANIS(board)) { switch (port) { @@ -777,7 +780,7 @@ int Open9xInterface::isAvailable(Protocol proto, int port) } } -SimulatorInterface * Open9xInterface::getSimulator() +SimulatorInterface * OpenTxInterface::getSimulator() { switch (board) { case BOARD_STOCK: @@ -789,7 +792,6 @@ SimulatorInterface * Open9xInterface::getSimulator() case BOARD_SKY9X: return new Open9xSky9xSimulator(this); case BOARD_TARANIS: - return new OpentxTaranisSimulator(this); case BOARD_TARANIS_REV4a: return new OpentxTaranisSimulator(this); default: @@ -802,7 +804,7 @@ size_t getSizeA(T (&)[SIZE]) { return SIZE; } -bool Open9xInterface::checkVersion(unsigned int version) +bool OpenTxInterface::checkVersion(unsigned int version) { switch(version) { case 201: @@ -868,7 +870,7 @@ bool Open9xInterface::checkVersion(unsigned int version) return true; } -bool Open9xInterface::checkVariant(unsigned int version, unsigned int variant) +bool OpenTxInterface::checkVariant(unsigned int version, unsigned int variant) { if (board == BOARD_M128 && !(variant & 0x8000)) { if (version == 212) { @@ -890,7 +892,7 @@ bool Open9xInterface::checkVariant(unsigned int version, unsigned int variant) } } -bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index) +bool OpenTxInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index) { std::cout << "trying " << getName() << " backup import..."; @@ -933,9 +935,11 @@ bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esiz QString geturl( int board) { - QSettings settings; - QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); - + QString url = g.compileServer(); + if (url.isEmpty()){ + url= OPENTX_FIRMWARE_DOWNLOADS; + g.compileServer(url); + } switch(board) { case BOARD_STOCK: case BOARD_M128: @@ -956,8 +960,11 @@ QString geturl( int board) QString getstamp( int board) { - QSettings settings; - QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); + QString url = g.compileServer(); + if (url.isEmpty()){ + url= OPENTX_FIRMWARE_DOWNLOADS; + g.compileServer(url); + } url.append("/stamp-opentx-"); switch(board) { case BOARD_STOCK: @@ -985,8 +992,11 @@ QString getstamp( int board) QString getrnurl( int board) { - QSettings settings; - QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); + QString url = g.compileServer(); + if (url.isEmpty()){ + url= OPENTX_FIRMWARE_DOWNLOADS; + g.compileServer(url); + } url.append("/releasenotes-"); switch(board) { case BOARD_STOCK: @@ -1015,7 +1025,7 @@ void RegisterOpen9xFirmwares() Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } }; /* 9x board */ - open9x = new Open9xFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); + open9x = new Open9xFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), new OpenTxInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1052,7 +1062,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9x board with M128 chip */ - open9x = new Open9xFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); + open9x = new Open9xFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), new OpenTxInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x->addOptions(ext_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1084,7 +1094,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9XR board */ - open9x = new Open9xFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false); + open9x = new Open9xFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), new OpenTxInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false); open9x->addOptions(extr_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1118,7 +1128,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* 9XR board with M128 chip */ - open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); + open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), new OpenTxInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false); open9x->addOptions(extr_options); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1148,7 +1158,7 @@ void RegisterOpen9xFirmwares() firmwares.push_back(open9x); /* Gruvin9x board */ - open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); + open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), new OpenTxInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false); open9x->setVariantBase(FRSKY_VARIANT); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1178,7 +1188,7 @@ void RegisterOpen9xFirmwares() #ifndef __APPLE__ /* SKY9X board */ - open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true); + open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), new OpenTxInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true); open9x->setVariantBase(FRSKY_VARIANT); open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); @@ -1203,7 +1213,7 @@ void RegisterOpen9xFirmwares() #endif /* Taranis board */ - open9x = new Open9xFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true); + open9x = new Open9xFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), new OpenTxInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("nogvars", QObject::tr("Disable Global variables")); @@ -1212,10 +1222,8 @@ void RegisterOpen9xFirmwares() open9x->addOptions(fai_options); firmwares.push_back(open9x); - QSettings settings; - int rev4a = settings.value("rev4asupport",0).toInt(); - if (rev4a) { - open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); + if (g.rev4aSupport()) { + open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new OpenTxInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("nogvars", QObject::tr("Disable Global variables")); diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index fb7f3df5c..aef381164 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -23,13 +23,13 @@ class EFile; -class Open9xInterface : public EEPROMInterface +class OpenTxInterface : public EEPROMInterface { public: - Open9xInterface(BoardEnum board); + OpenTxInterface(BoardEnum board); - virtual ~Open9xInterface(); + virtual ~OpenTxInterface(); virtual const char * getName(); diff --git a/companion/src/firmwares/opentx/opentxsimulator.cpp b/companion/src/firmwares/opentx/opentxsimulator.cpp index 9037afa86..dfb7025ea 100644 --- a/companion/src/firmwares/opentx/opentxsimulator.cpp +++ b/companion/src/firmwares/opentx/opentxsimulator.cpp @@ -107,7 +107,7 @@ uint8_t getStickMode() using namespace Open9x; -Open9xSimulator::Open9xSimulator(Open9xInterface * open9xInterface): +Open9xSimulator::Open9xSimulator(OpenTxInterface * open9xInterface): open9xInterface(open9xInterface) { #define INIT_IMPORT @@ -132,13 +132,20 @@ bool Open9xSimulator::lcdChanged(bool & lightEnable) #include "simulatorimport.h" } -void Open9xSimulator::start(RadioData &radioData, bool tests) +void Open9xSimulator::start(QByteArray & eeprom, bool tests) { - open9xInterface->save(&Open9x::eeprom[0], radioData, SIMU_STOCK_VARIANTS); + memcpy(&Open9x::eeprom[0], eeprom.data(), 2048); StartEepromThread(NULL); StartMainThread(tests); } +void Open9xSimulator::start(const char * filename, bool tests) +{ + // open9xInterface->save(&Open9x::eeprom[0], radioData, SIMU_STOCK_VARIANTS); + StartEepromThread(filename); + StartMainThread(tests); +} + void Open9xSimulator::stop() { StopMainThread(); diff --git a/companion/src/firmwares/opentx/opentxsimulator.h b/companion/src/firmwares/opentx/opentxsimulator.h index 84970eb1f..a4e24b3ba 100644 --- a/companion/src/firmwares/opentx/opentxsimulator.h +++ b/companion/src/firmwares/opentx/opentxsimulator.h @@ -19,15 +19,17 @@ #include "simulatorinterface.h" -class Open9xInterface; +class OpenTxInterface; class Open9xSimulator : public SimulatorInterface { public: - Open9xSimulator(Open9xInterface *); + Open9xSimulator(OpenTxInterface *); - virtual void start(RadioData &radioData, bool tests); + virtual void start(QByteArray & eeprom, bool tests=true); + + virtual void start(const char * filename, bool tests=true); virtual void stop(); @@ -53,7 +55,7 @@ class Open9xSimulator : public SimulatorInterface { protected: - Open9xInterface * open9xInterface; + OpenTxInterface * open9xInterface; }; diff --git a/companion/src/firmwares/th9x/th9xinterface.cpp b/companion/src/firmwares/th9x/th9xinterface.cpp index 8e3e36ab6..c0f4f7c4e 100644 --- a/companion/src/firmwares/th9x/th9xinterface.cpp +++ b/companion/src/firmwares/th9x/th9xinterface.cpp @@ -19,6 +19,7 @@ #include "th9xeeprom.h" #include "th9xsimulator.h" #include "file.h" +#include "appdata.h" #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -44,8 +45,7 @@ const char * Th9xInterface::getName() const int Th9xInterface::getEEpromSize() { - QSettings settings; - QString avrMCU = settings.value("mcu", QString("m64")).toString(); + QString avrMCU = g.mcu(); if (avrMCU==QString("m128")) { return 2*EESIZE_STOCK; } @@ -202,5 +202,5 @@ int Th9xInterface::isAvailable(Protocol proto, int port) SimulatorInterface * Th9xInterface::getSimulator() { - return new Th9xSimulator(this); + return NULL; // new Th9xSimulator(this); } diff --git a/companion/src/fusesdialog.cpp b/companion/src/fusesdialog.cpp index 106bc0b85..aad4bdad5 100644 --- a/companion/src/fusesdialog.cpp +++ b/companion/src/fusesdialog.cpp @@ -1,13 +1,14 @@ #include "fusesdialog.h" #include "ui_fusesdialog.h" - #include "burnconfigdialog.h" +#include "helpers.h" fusesDialog::fusesDialog(QWidget *parent) : QDialog(parent), ui(new Ui::fusesDialog) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("fuses.png")); } fusesDialog::~fusesDialog() diff --git a/companion/src/fusesdialog.ui b/companion/src/fusesdialog.ui index 1a32ff96c..f4ffe20bb 100644 --- a/companion/src/fusesdialog.ui +++ b/companion/src/fusesdialog.ui @@ -13,10 +13,6 @@ Fuses - - - :/icon.png:/icon.png - diff --git a/companion/src/fwpreferencesdialog.cpp b/companion/src/fwpreferencesdialog.cpp index 735e18acc..17c7c6caf 100644 --- a/companion/src/fwpreferencesdialog.cpp +++ b/companion/src/fwpreferencesdialog.cpp @@ -3,6 +3,7 @@ #include "mainwindow.h" #include "eeprominterface.h" #include "helpers.h" +#include "appdata.h" #include #include @@ -187,11 +188,8 @@ void fwPreferencesDialog::firmwareChanged() ui->CPU_ID_LE->hide(); ui->CPU_ID_LABEL->hide(); } - QSettings settings; - settings.beginGroup("FwRevisions"); - int fwrev = settings.value(variant.id, -1).toInt(); - settings.endGroup(); - if (fwrev != -1) { + int fwrev = g.fwRev.get(variant.id); + if (fwrev != 0) { ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev)); if (!stamp.isEmpty()) { ui->checkFWUpdates->show(); @@ -213,11 +211,9 @@ void fwPreferencesDialog::firmwareChanged() void fwPreferencesDialog::writeValues() { - QSettings settings; - - settings.setValue("cpu_id", ui->CPU_ID_LE->text()); + g.cpuId( ui->CPU_ID_LE->text() ); current_firmware_variant = getFirmwareVariant(); - settings.setValue("firmware", current_firmware_variant.id); + g.profile[g.id()].firmware( current_firmware_variant.id ); } void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) @@ -275,9 +271,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware) void fwPreferencesDialog::initSettings() { - QSettings settings; - - ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString()); + ui->CPU_ID_LE->setText(g.cpuId()); FirmwareInfo * current_firmware = GetCurrentFirmware(); foreach(FirmwareInfo * firmware, firmwares) { @@ -293,12 +287,10 @@ void fwPreferencesDialog::initSettings() void fwPreferencesDialog::on_checkFWUpdates_clicked() { - QSettings settings; - FirmwareVariant variant = getFirmwareVariant(); - if (settings.value("burnFirmware", true).toBool()) { + if (g.profile[g.id()].burnFirmware()) { current_firmware_variant = variant; - settings.setValue("firmware", variant.id); + g.profile[g.id()].firmware( variant.id ); } MainWindow * mw = (MainWindow *)this->parent(); mw->checkForUpdates(true, variant.id); @@ -307,14 +299,13 @@ void fwPreferencesDialog::on_checkFWUpdates_clicked() void fwPreferencesDialog::on_fw_dnld_clicked() { - QSettings settings; MainWindow * mw = (MainWindow *)this->parent(); FirmwareVariant variant = getFirmwareVariant(); writeValues(); if (!variant.firmware->getUrl(variant.id).isNull()) { - if (settings.value("burnFirmware", true).toBool()) { + if (g.profile[g.id()].burnFirmware()) { current_firmware_variant = getFirmwareVariant(); - settings.setValue("firmware", current_firmware_variant.id); + g.profile[g.id()].firmware( current_firmware_variant.id ); } mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id); } diff --git a/companion/src/generaledit.cpp b/companion/src/generaledit.cpp index f197eb7b1..6e96e0368 100644 --- a/companion/src/generaledit.cpp +++ b/companion/src/generaledit.cpp @@ -1,9 +1,9 @@ #include "generaledit.h" #include "ui_generaledit.h" #include "helpers.h" +#include "appdata.h" #include -#define MAX_PROFILES 10 #define BIT_WARN_THR ( 0x01 ) #define BIT_WARN_SW ( 0x02 ) #define BIT_WARN_MEM ( 0x04 ) @@ -18,20 +18,14 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) : g_eeGeneral(radioData.generalSettings) { ui->setupUi(this); - this->setWindowIcon(QIcon(":/icon.png")); + this->setWindowIcon(CompanionIcon("open.png")); - QSettings settings; - QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); - ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); - int profile_id=settings.value("profileId", 0).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profile_id); - settings.beginGroup(profile); - QString name=settings.value("Name","").toString(); + QString firmware_id = g.profile[g.id()].firmware(); + ui->tabWidget->setCurrentIndex( g.generalEditTab() ); + QString name=g.profile[g.id()].name(); if (name.isEmpty()) { ui->calstore_PB->setDisabled(true); } - settings.endGroup(); EEPROMInterface *eepromInterface = GetEepromInterface(); 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}; @@ -76,18 +70,14 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) : } ui->profile_CB->clear(); for ( int i = 0; i < MAX_PROFILES; ++i) { - QString profile=QString("profile%1").arg(i+1); - settings.beginGroup(profile); - QString name=settings.value("Name","").toString(); + QString name=g.profile[i].name(); if (!name.isEmpty()) { - ui->profile_CB->addItem(name, i+1); - if ((i+1)==profile_id) { - ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1); + ui->profile_CB->addItem(name, i); + if (i==g.id()) { + ui->profile_CB->setCurrentIndex(ui->profile_CB->count()); } } - settings.endGroup(); } - settings.endGroup(); QRegExp rx(CHAR_FOR_NAMES_REGEX); ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this)); @@ -970,9 +960,7 @@ void GeneralEdit::on_PPM4_editingFinished() void GeneralEdit::on_tabWidget_currentChanged(int index) { - // TODO why er9x here - QSettings settings; - settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex()); + g.generalEditTab(index); } @@ -1220,31 +1208,23 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int ) void GeneralEdit::on_calretrieve_PB_clicked() { - QSettings settings; int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profile_id); - settings.beginGroup(profile); - QString calib=settings.value("StickPotCalib","").toString(); + QString calib=g.profile[profile_id].stickPotCalib(); int potsnum=GetEepromInterface()->getCapability(Pots); if (calib.isEmpty()) { - settings.endGroup(); - settings.endGroup(); return; } else { - QString trainercalib=settings.value("TrainerCalib","").toString(); - int8_t vBatCalib=(int8_t)settings.value("VbatCalib", g_eeGeneral.vBatCalib).toInt(); - int8_t currentCalib=(int8_t)settings.value("currentCalib", g_eeGeneral.currentCalib).toInt(); - int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", g_eeGeneral.PPM_Multiplier).toInt(); - uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", g_eeGeneral.stickMode).toUInt(); - uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",g_eeGeneral.vBatWarn).toUInt(); - QString DisplaySet=settings.value("Display","").toString(); - QString BeeperSet=settings.value("Beeper","").toString(); - QString HapticSet=settings.value("Haptic","").toString(); - QString SpeakerSet=settings.value("Speaker","").toString(); - QString CountrySet=settings.value("countryCode","").toString(); - settings.endGroup(); - settings.endGroup(); + 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; @@ -1337,27 +1317,20 @@ void GeneralEdit::on_calretrieve_PB_clicked() void GeneralEdit::on_calstore_PB_clicked() { - QSettings settings; int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profile_id); - settings.beginGroup(profile); - QString name=settings.value("Name","").toString(); + + QString name=g.profile[profile_id].name(); int potsnum=GetEepromInterface()->getCapability(Pots); if (name.isEmpty()) { ui->calstore_PB->setDisabled(true); - settings.endGroup(); - settings.endGroup(); return; } else { - QString calib=settings.value("StickPotCalib","").toString(); + 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
overwriting existing calibration?").arg(name) , QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) { - settings.endGroup(); - settings.endGroup(); return; } } @@ -1367,24 +1340,22 @@ void GeneralEdit::on_calstore_PB_clicked() calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanNeg[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanPos[i], 4, 16, QChar('0'))); } - settings.setValue("StickPotCalib",calib); + g.profile[profile_id].stickPotCalib( calib ); calib.clear(); for (int i=0; i< 4; i++) { calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0'))); } - settings.setValue("TrainerCalib",calib); - settings.setValue("VbatCalib",g_eeGeneral.vBatCalib); - settings.setValue("currentCalib",g_eeGeneral.currentCalib); - settings.setValue("vBatWarn",g_eeGeneral.vBatWarn); - settings.setValue("PPM_Multiplier",g_eeGeneral.PPM_Multiplier); - settings.setValue("GSStickMode",g_eeGeneral.stickMode); - settings.setValue("Display",QString("%1%2%3").arg((g_eeGeneral.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.contrast, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.backlightBright, 2, 16, QChar('0'))); - settings.setValue("Beeper",QString("%1%2").arg(((uint8_t)g_eeGeneral.beeperMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.beeperLength, 2, 16, QChar('0'))); - settings.setValue("Haptic",QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0'))); - settings.setValue("Speaker",QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0'))); - settings.setValue("countryCode",QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage)); - settings.endGroup(); - settings.endGroup(); + g.profile[profile_id].trainerCalib( calib ); + g.profile[profile_id].vBatCalib( g_eeGeneral.vBatCalib ); + g.profile[profile_id].currentCalib( g_eeGeneral.currentCalib ); + g.profile[profile_id].vBatWarn( g_eeGeneral.vBatWarn ); + g.profile[profile_id].ppmMultiplier( g_eeGeneral.PPM_Multiplier ); + g.profile[profile_id].gsStickMode( g_eeGeneral.stickMode ); + g.profile[profile_id].display( QString("%1%2%3").arg((g_eeGeneral.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.contrast, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.backlightBright, 2, 16, QChar('0')) ); + g.profile[profile_id].beeper( QString("%1%2").arg(((uint8_t)g_eeGeneral.beeperMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.beeperLength, 2, 16, QChar('0'))); + g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)g_eeGeneral.hapticMode), 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.hapticLength, 2, 16, QChar('0'))); + g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)g_eeGeneral.speakerMode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.speakerVolume, 2, 16, QChar('0'))); + g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)g_eeGeneral.countryCode, 2, 16, QChar('0')).arg((uint8_t)g_eeGeneral.imperial, 2, 16, QChar('0')).arg(g_eeGeneral.ttsLanguage)); QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved.")); } } diff --git a/companion/src/generaledit.ui b/companion/src/generaledit.ui index 5de0449aa..8f66dcab1 100644 --- a/companion/src/generaledit.ui +++ b/companion/src/generaledit.ui @@ -19,10 +19,6 @@ General Edit - - - :/icon.png:/icon.png - true @@ -1559,10 +1555,10 @@ Acceptable values are 5v..10v QLayout::SetMinimumSize - + 0 - + 0 diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 9a9f2caf4..c17bdb1b1 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -1,5 +1,7 @@ #include +#include "appdata.h" #include "helpers.h" +#include "simulatordialog.h" QString getPhaseName(int val, char * phasename) { @@ -635,24 +637,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & b->setMaxVisibleItems(10); } -float ValToTim(int value) -{ - return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0); -} - -int TimToVal(float value) -{ - int temp; - if (value>60) { - temp=136+round((value-60)); - } else if (value>2) { - temp=20+round((value-2.0)*2.0); - } else { - temp=round(value*10.0); - } - return (temp-129); -} - void populateCSWCB(QComboBox *b, int value) { int order[] = { @@ -694,27 +678,6 @@ void populateCSWCB(QComboBox *b, int value) b->setMaxVisibleItems(10); } -QString getSignedStr(int value) -{ - return value > 0 ? QString("+%1").arg(value) : QString("%1").arg(value); -} - -QString getGVarString(int16_t val, bool sign) -{ - if (val >= -10000 && val <= 10000) { - if (sign) - return QString("%1%").arg(getSignedStr(val)); - else - return QString("%1%").arg(val); - } - else { - if (val<0) - return QObject::tr("-GV%1").arg(-val-10000); - else - return QObject::tr("GV%1").arg(val-10000); - } -} - QString image2qstring(QImage image) { if (image.isNull()) @@ -913,8 +876,7 @@ QString getCenterBeep(ModelData * g_model) QString getTheme() { - QSettings settings; - int theme_set = settings.value("theme", 1).toInt(); + int theme_set = g.theme(); QString Theme; switch(theme_set) { case 0: @@ -930,7 +892,7 @@ QString getTheme() Theme="monoblue"; break; default: - Theme="new"; + Theme="yerico"; break; } return Theme; @@ -945,3 +907,34 @@ CompanionIcon::CompanionIcon(QString baseimage) addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48)); } +void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) +{ + if (GetEepromInterface()->getSimulator()) { + RadioData * simuData = new RadioData(radioData); + unsigned int flags = 0; + if (modelIdx >= 0) { + flags |= SIMULATOR_FLAGS_NOTX; + simuData->generalSettings.currModel = modelIdx; + } + if (radioData.generalSettings.stickMode & 1) { + flags |= SIMULATOR_FLAGS_STICK_MODE_LEFT; + } + BoardEnum board = GetEepromInterface()->getBoard(); + SimulatorDialog * sd; + if (IS_TARANIS(board)) + sd = new SimulatorDialogTaranis(parent, flags); + else + sd = new SimulatorDialog9X(parent, flags); + QByteArray eeprom(GetEepromInterface()->getEEpromSize(), 0); + GetEepromInterface()->save((uint8_t *)eeprom.data(), *simuData, GetEepromInterface()->getCapability(SimulatorVariant)); + delete simuData; + sd->start(eeprom); + sd->exec(); + delete sd; + } + else { + QMessageBox::warning(NULL, + QObject::tr("Warning"), + QObject::tr("Simulator for this firmware is not yet available")); + } +} diff --git a/companion/src/helpers.h b/companion/src/helpers.h index ad22a4e7c..fdebcb170 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -109,8 +109,6 @@ void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & m void populateCSWCB(QComboBox *b, int value); QString getPhaseName(int val, char * phasename=NULL); QString getInputStr(ModelData & model, int index); -QString getSignedStr(int value); -QString getGVarString(int16_t val, bool sign=false); QString image2qstring(QImage image); QImage qstring2image(QString imagestr); int findmult(float value, float base); @@ -128,7 +126,6 @@ QString getFrSkyProtocol(int protocol); QString getFrSkyMeasure(int units); QString getFrSkySrc(int index); -float ValToTim(int value); -int TimToVal(float value); +void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx); #endif // HELPERS_H diff --git a/companion/src/images/originals/icons New/apppreferences.png b/companion/src/images/originals/icons New/apppreferences.png deleted file mode 100644 index 597a9f68d..000000000 Binary files a/companion/src/images/originals/icons New/apppreferences.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/compare.png b/companion/src/images/originals/icons New/compare.png deleted file mode 100644 index 5b7e41c4f..000000000 Binary files a/companion/src/images/originals/icons New/compare.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/configure.png b/companion/src/images/originals/icons New/configure.png deleted file mode 100644 index ec6fad759..000000000 Binary files a/companion/src/images/originals/icons New/configure.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/copy.png b/companion/src/images/originals/icons New/copy.png deleted file mode 100644 index 49e9835c0..000000000 Binary files a/companion/src/images/originals/icons New/copy.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/cut.png b/companion/src/images/originals/icons New/cut.png deleted file mode 100644 index 910dff020..000000000 Binary files a/companion/src/images/originals/icons New/cut.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/fwpreferences.png b/companion/src/images/originals/icons New/fwpreferences.png deleted file mode 100644 index 7574da86a..000000000 Binary files a/companion/src/images/originals/icons New/fwpreferences.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/information.png b/companion/src/images/originals/icons New/information.png deleted file mode 100644 index 44c08b858..000000000 Binary files a/companion/src/images/originals/icons New/information.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/logs.png b/companion/src/images/originals/icons New/logs.png deleted file mode 100644 index 8dc7ce194..000000000 Binary files a/companion/src/images/originals/icons New/logs.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/new.png b/companion/src/images/originals/icons New/new.png deleted file mode 100644 index 53dd74e30..000000000 Binary files a/companion/src/images/originals/icons New/new.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/open.png b/companion/src/images/originals/icons New/open.png deleted file mode 100644 index 4bf67c1b0..000000000 Binary files a/companion/src/images/originals/icons New/open.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/paintbrush.png b/companion/src/images/originals/icons New/paintbrush.png deleted file mode 100644 index 814fdb47e..000000000 Binary files a/companion/src/images/originals/icons New/paintbrush.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/paste.png b/companion/src/images/originals/icons New/paste.png deleted file mode 100644 index 2198b77c0..000000000 Binary files a/companion/src/images/originals/icons New/paste.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/print.png b/companion/src/images/originals/icons New/print.png deleted file mode 100644 index 62d994f9e..000000000 Binary files a/companion/src/images/originals/icons New/print.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/profiles.png b/companion/src/images/originals/icons New/profiles.png deleted file mode 100644 index bfa571cff..000000000 Binary files a/companion/src/images/originals/icons New/profiles.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/read_eeprom.png b/companion/src/images/originals/icons New/read_eeprom.png deleted file mode 100644 index 08e861b31..000000000 Binary files a/companion/src/images/originals/icons New/read_eeprom.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/read_eeprom_file.png b/companion/src/images/originals/icons New/read_eeprom_file.png deleted file mode 100644 index 67a41176b..000000000 Binary files a/companion/src/images/originals/icons New/read_eeprom_file.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/read_flash.png b/companion/src/images/originals/icons New/read_flash.png deleted file mode 100644 index c9065819b..000000000 Binary files a/companion/src/images/originals/icons New/read_flash.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/recentdocument.png b/companion/src/images/originals/icons New/recentdocument.png deleted file mode 100644 index 87ef05d0e..000000000 Binary files a/companion/src/images/originals/icons New/recentdocument.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/save.png b/companion/src/images/originals/icons New/save.png deleted file mode 100644 index 20352a4f9..000000000 Binary files a/companion/src/images/originals/icons New/save.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/saveas.png b/companion/src/images/originals/icons New/saveas.png deleted file mode 100644 index a7d234b20..000000000 Binary files a/companion/src/images/originals/icons New/saveas.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/simulate.png b/companion/src/images/originals/icons New/simulate.png deleted file mode 100644 index 429e12b9a..000000000 Binary files a/companion/src/images/originals/icons New/simulate.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/update.png b/companion/src/images/originals/icons New/update.png deleted file mode 100644 index 034ee58e8..000000000 Binary files a/companion/src/images/originals/icons New/update.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/write_eeprom.png b/companion/src/images/originals/icons New/write_eeprom.png deleted file mode 100644 index 15e58d0a3..000000000 Binary files a/companion/src/images/originals/icons New/write_eeprom.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/write_eeprom_file.png b/companion/src/images/originals/icons New/write_eeprom_file.png deleted file mode 100644 index 60d7c312e..000000000 Binary files a/companion/src/images/originals/icons New/write_eeprom_file.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/write_flash.png b/companion/src/images/originals/icons New/write_flash.png deleted file mode 100644 index 1664cb228..000000000 Binary files a/companion/src/images/originals/icons New/write_flash.png and /dev/null differ diff --git a/companion/src/images/originals/icons New/add.png b/companion/src/images/originals/icons Yerico/add.png similarity index 100% rename from companion/src/images/originals/icons New/add.png rename to companion/src/images/originals/icons Yerico/add.png diff --git a/companion/src/images/originals/icons New/arrow-left.png b/companion/src/images/originals/icons Yerico/arrow-left.png similarity index 100% rename from companion/src/images/originals/icons New/arrow-left.png rename to companion/src/images/originals/icons Yerico/arrow-left.png diff --git a/companion/src/images/originals/icons New/arrow-right.png b/companion/src/images/originals/icons Yerico/arrow-right.png similarity index 100% rename from companion/src/images/originals/icons New/arrow-right.png rename to companion/src/images/originals/icons Yerico/arrow-right.png diff --git a/companion/src/images/originals/icons New/changelog.png b/companion/src/images/originals/icons Yerico/changelog.png similarity index 100% rename from companion/src/images/originals/icons New/changelog.png rename to companion/src/images/originals/icons Yerico/changelog.png diff --git a/companion/src/images/originals/icons Yerico/clear.png b/companion/src/images/originals/icons Yerico/clear.png new file mode 100644 index 000000000..1941bedf7 Binary files /dev/null and b/companion/src/images/originals/icons Yerico/clear.png differ diff --git a/companion/src/images/originals/icons New/contributors.png b/companion/src/images/originals/icons Yerico/contributors.png similarity index 100% rename from companion/src/images/originals/icons New/contributors.png rename to companion/src/images/originals/icons Yerico/contributors.png diff --git a/companion/src/images/originals/icons New/currentmodel.png b/companion/src/images/originals/icons Yerico/currentmodel.png similarity index 100% rename from companion/src/images/originals/icons New/currentmodel.png rename to companion/src/images/originals/icons Yerico/currentmodel.png diff --git a/companion/src/images/originals/icons New/duplicate.png b/companion/src/images/originals/icons Yerico/duplicate.png similarity index 100% rename from companion/src/images/originals/icons New/duplicate.png rename to companion/src/images/originals/icons Yerico/duplicate.png diff --git a/companion/src/images/originals/icons New/edit.png b/companion/src/images/originals/icons Yerico/edit.png similarity index 100% rename from companion/src/images/originals/icons New/edit.png rename to companion/src/images/originals/icons Yerico/edit.png diff --git a/companion/src/images/originals/icons New/exit.png b/companion/src/images/originals/icons Yerico/exit.png similarity index 100% rename from companion/src/images/originals/icons New/exit.png rename to companion/src/images/originals/icons Yerico/exit.png diff --git a/companion/src/images/originals/icons New/fuses.png b/companion/src/images/originals/icons Yerico/fuses.png similarity index 100% rename from companion/src/images/originals/icons New/fuses.png rename to companion/src/images/originals/icons Yerico/fuses.png diff --git a/companion/src/images/originals/icons New/library.png b/companion/src/images/originals/icons Yerico/library.png similarity index 100% rename from companion/src/images/originals/icons New/library.png rename to companion/src/images/originals/icons Yerico/library.png diff --git a/companion/src/images/originals/icons New/list.png b/companion/src/images/originals/icons Yerico/list.png similarity index 100% rename from companion/src/images/originals/icons New/list.png rename to companion/src/images/originals/icons Yerico/list.png diff --git a/companion/src/images/originals/icons New/movedown.png b/companion/src/images/originals/icons Yerico/movedown.png similarity index 100% rename from companion/src/images/originals/icons New/movedown.png rename to companion/src/images/originals/icons Yerico/movedown.png diff --git a/companion/src/images/originals/icons New/moveup.png b/companion/src/images/originals/icons Yerico/moveup.png similarity index 100% rename from companion/src/images/originals/icons New/moveup.png rename to companion/src/images/originals/icons Yerico/moveup.png diff --git a/companion/src/images/originals/icons New/play.png b/companion/src/images/originals/icons Yerico/play.png similarity index 100% rename from companion/src/images/originals/icons New/play.png rename to companion/src/images/originals/icons Yerico/play.png diff --git a/companion/src/images/originals/icons New/stop.png b/companion/src/images/originals/icons Yerico/stop.png similarity index 100% rename from companion/src/images/originals/icons New/stop.png rename to companion/src/images/originals/icons Yerico/stop.png diff --git a/companion/src/images/originals/icons New/switch_dir.png b/companion/src/images/originals/icons Yerico/switch_dir.png similarity index 100% rename from companion/src/images/originals/icons New/switch_dir.png rename to companion/src/images/originals/icons Yerico/switch_dir.png diff --git a/companion/src/images/originals/icons New/wizard.png b/companion/src/images/originals/icons Yerico/wizard.png similarity index 100% rename from companion/src/images/originals/icons New/wizard.png rename to companion/src/images/originals/icons Yerico/wizard.png diff --git a/companion/src/images/originals/icons Yerico/yerico_icons_16.svg b/companion/src/images/originals/icons Yerico/yerico_icons_16.svg new file mode 100644 index 000000000..ff1c2b31a --- /dev/null +++ b/companion/src/images/originals/icons Yerico/yerico_icons_16.svg @@ -0,0 +1,5290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/images/originals/icons Yerico/yerico_icons_24.svg b/companion/src/images/originals/icons Yerico/yerico_icons_24.svg new file mode 100644 index 000000000..32221c916 --- /dev/null +++ b/companion/src/images/originals/icons Yerico/yerico_icons_24.svg @@ -0,0 +1,5677 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/images/originals/icons Yerico/yerico_icons_32.svg b/companion/src/images/originals/icons Yerico/yerico_icons_32.svg new file mode 100644 index 000000000..7e7ac35ba --- /dev/null +++ b/companion/src/images/originals/icons Yerico/yerico_icons_32.svg @@ -0,0 +1,8892 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/images/originals/icons Yerico/yerico_icons_48.svg b/companion/src/images/originals/icons Yerico/yerico_icons_48.svg new file mode 100644 index 000000000..45060b024 --- /dev/null +++ b/companion/src/images/originals/icons Yerico/yerico_icons_48.svg @@ -0,0 +1,8018 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/images/originals/icons Yerico/yerico_icons_all.svg b/companion/src/images/originals/icons Yerico/yerico_icons_all.svg new file mode 100644 index 000000000..2ee4a4c27 --- /dev/null +++ b/companion/src/images/originals/icons Yerico/yerico_icons_all.svg @@ -0,0 +1,16562 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/companion/src/logsdialog.cpp b/companion/src/logsdialog.cpp index 0c9702239..f39a41171 100644 --- a/companion/src/logsdialog.cpp +++ b/companion/src/logsdialog.cpp @@ -1,6 +1,8 @@ #include "logsdialog.h" +#include "appdata.h" #include "ui_logsdialog.h" #include "qcustomplot.h" +#include "helpers.h" #if defined WIN32 || !defined __GNUC__ #include #else @@ -14,6 +16,7 @@ logsDialog::logsDialog(QWidget *parent) : csvlog.clear(); srand(QDateTime::currentDateTime().toTime_t()); ui->setupUi(this); + this->setWindowIcon(CompanionIcon("logs.png")); palette.clear(); plotLock=false; for (int i=0; i< 60; i++) @@ -38,8 +41,7 @@ logsDialog::logsDialog(QWidget *parent) : ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setVisible(false); - QSettings settings; - QString Path=settings.value("gePath", "").toString(); + QString Path=g.gePath(); if (Path.isEmpty() || !QFile(Path).exists()) { ui->mapsButton->hide(); } @@ -202,8 +204,7 @@ void logsDialog::on_mapsButton_clicked() { ,F_F,F_F,F_F,F_F,I_F,I_F,I_F,I_F\ ,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F,I_F}; - QSettings settings; - QString gePath=settings.value("gePath", "").toString(); + QString gePath=g.gePath(); if (gePath.isEmpty() || !QFile(gePath).exists()) { ui->FieldsTW->setDisabled(false); ui->logTable->setDisabled(false); @@ -585,10 +586,9 @@ void logsDialog::moveLegend() void logsDialog::on_fileOpen_BT_clicked() { - QSettings settings; - QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), settings.value("lastLogDir").toString()); + QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), g.logDir()); if (!fileName.isEmpty()) { - settings.setValue("lastLogDir", fileName); + g.logDir( fileName ); ui->FileName_LE->setText(fileName); if (cvsFileParse()) { ui->FieldsTW->clear(); diff --git a/companion/src/logsdialog.ui b/companion/src/logsdialog.ui index c645110d0..0ea51523e 100644 --- a/companion/src/logsdialog.ui +++ b/companion/src/logsdialog.ui @@ -13,10 +13,6 @@ Companion Log Viewer - - - :/icon.png:/icon.png - true @@ -70,7 +66,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -188,7 +193,7 @@ 0 - true + false 18 diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 991861451..75d68038b 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -49,7 +49,6 @@ #include "avroutputdialog.h" #include "comparedialog.h" #include "logsdialog.h" -#include "preferencesdialog.h" #include "apppreferencesdialog.h" #include "fwpreferencesdialog.h" #include "flashinterface.h" @@ -63,6 +62,7 @@ #include "hexinterface.h" #include "warnings.h" #include "helpers.h" +#include "appdata.h" #include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include #define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" @@ -90,23 +90,17 @@ MainWindow::MainWindow(): mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setCentralWidget(mdiArea); - connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), - this, SLOT(updateMenus())); + connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus())); windowMapper = new QSignalMapper(this); - connect(windowMapper, SIGNAL(mapped(QWidget*)), - this, SLOT(setActiveSubWindow(QWidget*))); + connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*))); - MaxRecentFiles=MAX_RECENT; - QSettings settings; - - restoreGeometry(settings.value("mainWindowGeometry").toByteArray()); createActions(); - createMenus(); createToolBars(); createStatusBar(); updateMenus(); - readSettings(); + + restoreState(g.mainWinState()); setUnifiedTitleAndToolBarOnMac(true); this->setWindowIcon(QIcon(":/icon.png")); @@ -116,7 +110,7 @@ MainWindow::MainWindow(): // give time to the splash to disappear and main window to open before starting updates int updateDelay = 1000; - bool showSplash = settings.value("show_splash", true).toBool(); + bool showSplash = g.showSplash(); if (showSplash) { updateDelay += (SPLASH_TIME*1000); } @@ -169,8 +163,7 @@ MainWindow::MainWindow(): void MainWindow::displayWarnings() { - QSettings settings; - int warnId=settings.value("warningId", 0 ).toInt(); + int warnId=g.warningId(); if (warnId0) { @@ -181,10 +174,10 @@ void MainWindow::displayWarnings() res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No); } if (res == QMessageBox::No) { - settings.setValue("warningId", WARNING_ID); + g.warningId(WARNING_ID); } } else if (warnId==0) { - settings.setValue("warningId", WARNING_ID); + g.warningId(WARNING_ID); } } @@ -203,12 +196,11 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId) showcheckForUpdatesResult = ignoreSettings; check1done = true; check2done = true; - QSettings settings; fwToUpdate = fwId; QString stamp = GetFirmware(fwToUpdate)->stamp; if (!stamp.isEmpty()) { - if (checkFW || ignoreSettings) { + if (g.autoCheckFw() || ignoreSettings) { check1done=false; manager1 = new QNetworkAccessManager(this); connect(manager1, SIGNAL(finished(QNetworkReply*)), this, SLOT(reply1Finished(QNetworkReply*))); @@ -219,7 +211,7 @@ void MainWindow::checkForUpdates(bool ignoreSettings, QString & fwId) } } - if (checkCompanion || ignoreSettings) { + if (g.autoCheckApp() || ignoreSettings) { check2done = false; manager2 = new QNetworkAccessManager(this); connect(manager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForUpdateFinished(QNetworkReply*))); @@ -269,16 +261,14 @@ void MainWindow::checkForUpdateFinished(QNetworkReply * reply) "Would you like to download it?").arg(version) , QMessageBox::Yes | QMessageBox::No); - QSettings settings; - if (ret == QMessageBox::Yes) { #if defined __APPLE__ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastUpdatesDir").toString() + QString(C9X_INSTALLER).arg(version)); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(C9X_INSTALLER).arg(version)); #else - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastUpdatesDir").toString() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)")); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)")); #endif if (!fileName.isEmpty()) { - settings.setValue("lastUpdatesDir", QFileInfo(fileName).dir().absolutePath()); + g.updatesDir(QFileInfo(fileName).dir().absolutePath()); downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName); installer_fileName = fileName; connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); @@ -311,11 +301,10 @@ void MainWindow::updateDownloaded() void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId) { QString url, ext, cpuid; - QSettings settings; url = firmware->getUrl(firmwareId); - cpuid=settings.value("cpuid","").toString(); + cpuid=g.cpuId(); ext = url.mid(url.lastIndexOf(".")); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + firmwareId + ext); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + firmwareId + ext); if (!fileName.isEmpty()) { downloadedFW = firmwareId; needRename=true; @@ -324,7 +313,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw url.append("&cpuid="); url.append(cpuid); } - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); + g.flashDir(QFileInfo(fileName).dir().absolutePath()); downloadDialog * dd = new downloadDialog(this, url, fileName); connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); dd->exec(); @@ -334,8 +323,6 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw void MainWindow::reply1Accepted() { QString errormsg; - QSettings settings; - settings.beginGroup("FwRevisions"); if (downloadedFWFilename.isEmpty()) { if (!(downloadedFW.isEmpty())) { QFile file(downloadedFW); @@ -370,12 +357,11 @@ void MainWindow::reply1Accepted() } file.close(); QMessageBox::critical(this, tr("Error"), errormsg); - settings.endGroup(); return; } file.close(); currentFWrev = currentFWrev_temp; - settings.setValue(downloadedFW, currentFWrev); + g.fwRev.set(downloadedFW, currentFWrev); } } else { QFile file(downloadedFWFilename); @@ -410,7 +396,6 @@ void MainWindow::reply1Accepted() } file.close(); QMessageBox::critical(this, tr("Error"), errormsg); - settings.endGroup(); return; } file.close(); @@ -419,7 +404,7 @@ void MainWindow::reply1Accepted() int pos=rev.lastIndexOf("-r"); if (pos>0) { currentFWrev=rev.mid(pos+2).toInt(); - if (settings.value("rename_firmware_files", false).toBool() && needRename) { + if (g.profile[g.id()].renameFwFiles() && needRename) { QFileInfo fi(downloadedFWFilename); QString path=fi.path()+QDir::separator (); path.append(fi.completeBaseName()); @@ -431,8 +416,8 @@ void MainWindow::reply1Accepted() qd.rename(downloadedFWFilename,path); downloadedFWFilename=path; } - settings.setValue(downloadedFW, currentFWrev); - if (settings.value("burnFirmware", true).toBool()) { + g.fwRev.set(downloadedFW, currentFWrev); + if (g.profile[g.id()].burnFirmware()) { int ret = QMessageBox::question(this, "Companion", tr("Do you want to write the firmware to the transmitter now ?"), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::Yes) { writeFlash(downloadedFWFilename); @@ -440,7 +425,6 @@ void MainWindow::reply1Accepted() } } } - settings.endGroup(); } void MainWindow::reply1Finished(QNetworkReply * reply) @@ -456,8 +440,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply) // TODO delete downloadDialog_forWait? } - QSettings settings; - cpuid=settings.value("cpuid","").toString(); + cpuid=g.cpuId(); QByteArray qba = reply->readAll(); int i = qba.indexOf("SVN_VERS"); int warning = qba.indexOf("WARNING"); @@ -471,17 +454,13 @@ void MainWindow::reply1Finished(QNetworkReply * reply) if(!cres) { QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); - int server = settings.value("fwserver",0).toInt(); - server++; - settings.setValue("fwserver",server); + g.fwServerFails(g.fwServerFails()+1); return; } if(rev>0) { NewFwRev=rev; - settings.beginGroup("FwRevisions"); - OldFwRev = settings.value(fwToUpdate, 0).toInt(); - settings.endGroup(); + OldFwRev = g.fwRev.get(fwToUpdate); QMessageBox msgBox; QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QGridLayout* layout = (QGridLayout*)msgBox.layout(); @@ -552,9 +531,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply) if (ignore) { int res = QMessageBox::question(this, "Companion",tr("Ignore this version (r%1)?").arg(rev), QMessageBox::Yes | QMessageBox::No); if (res==QMessageBox::Yes) { - settings.beginGroup("FwRevisions"); - settings.setValue(fwToUpdate, NewFwRev); - settings.endGroup(); + g.fwRev.set(fwToUpdate, NewFwRev); } } else if (download == true) { if (warning>0) { @@ -571,12 +548,12 @@ void MainWindow::reply1Finished(QNetworkReply * reply) QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate); QString ext = url.mid(url.lastIndexOf(".")); needRename=false; - bool addversion=settings.value("rename_firmware_files", false).toBool(); + bool addversion=g.profile[g.id()].renameFwFiles(); QString fileName; if (addversion) { - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + fwToUpdate + newrev + ext); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + newrev + ext); } else { - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastFlashDir").toString() + "/" + fwToUpdate + ext); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.flashDir() + "/" + fwToUpdate + ext); } if (!fileName.isEmpty()) { if (!cpuid.isEmpty()) { @@ -584,7 +561,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply) url.append(cpuid); } downloadedFWFilename = fileName; - settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); + g.flashDir(QFileInfo(fileName).dir().absolutePath()); downloadDialog * dd = new downloadDialog(this, url, fileName); currentFWrev_temp = NewFwRev; connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); @@ -598,9 +575,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply) } else { if(check1done && check2done) { QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); - int server = settings.value("fwserver",0).toInt(); - server++; - settings.setValue("fwserver",server); + g.fwServerFails(g.fwServerFails()+1); return; } } @@ -608,9 +583,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply) void MainWindow::closeEvent(QCloseEvent *event) { - QSettings settings; - settings.setValue("mainWindowGeometry", saveGeometry()); - settings.setValue("mainWindowState", saveState()); + g.mainWinGeo(saveGeometry()); + g.mainWinState(saveState()); mdiArea->closeAllSubWindows(); if (mdiArea->currentSubWindow()) { event->ignore(); @@ -622,8 +596,7 @@ void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::setLanguage(QString langString) { - QSettings settings; - settings.setValue("locale", langString ); + g.locale( langString ); QMessageBox msgBox; msgBox.setText(tr("The selected language will be used the next time you start Companion.")); @@ -634,8 +607,7 @@ void MainWindow::setLanguage(QString langString) void MainWindow::setTheme(int index) { - QSettings settings; - settings.setValue("theme", index ); + g.theme( index ); QMessageBox msgBox; msgBox.setText(tr("The new theme will be loaded the next time you start Companion.")); @@ -646,8 +618,7 @@ void MainWindow::setTheme(int index) void MainWindow::setIconThemeSize(int index) { - QSettings settings; - settings.setValue("icon_size", index ); + g.iconSize( index ); QMessageBox msgBox; msgBox.setText(tr("The icon size will be used the next time you start Companion.")); @@ -671,10 +642,9 @@ void MainWindow::openDocURL() void MainWindow::openFile() { - QSettings settings; - QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.eepromDir(), tr(EEPROM_FILES_FILTER)); if (!fileName.isEmpty()) { - settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + g.eepromDir(QFileInfo(fileName).dir().absolutePath()); QMdiSubWindow *existing = findMdiChild(fileName); if (existing) { @@ -704,11 +674,9 @@ void MainWindow::saveAs() void MainWindow::openRecentFile() { - QSettings settings; QAction *action = qobject_cast(sender()); if (action) { QString fileName=action->data().toString(); - // settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); QMdiSubWindow *existing = findMdiChild(fileName); if (existing) { @@ -724,42 +692,17 @@ void MainWindow::openRecentFile() } } -void MainWindow::loadProfile() +void MainWindow::loadProfile() //TODO Load all variables - Also HW! { - QSettings settings; QAction *action = qobject_cast(sender()); if (action) { + // Set the new profile number int profnum=action->data().toInt(); - QSettings settings; - settings.setValue("profileId",profnum); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profnum); - settings.beginGroup(profile); - QString profileName=settings.value("Name", "").toString(); - int chord=settings.value("default_channel_order", 0).toInt(); - int defmod=settings.value("default_mode", 0).toInt(); - bool burnfw=settings.value("burnFirmware", false).toBool(); - QString sdPath=settings.value("sdPath", ".").toString(); - bool renfw=settings.value("rename_firmware_files", false).toBool(); - QString SplashFileName=settings.value("SplashFileName","").toString(); - QString SplashImage=settings.value("SplashImage", "").toString(); - QString firmware_id=settings.value("firmware", default_firmware_variant.id).toString(); - firmware_id.replace("open9x","opentx"); - firmware_id.replace("x9da","taranis"); - settings.setValue("firmware", firmware_id); - settings.endGroup(); - settings.endGroup(); - settings.setValue("Name", profileName ); - settings.setValue("default_channel_order", chord); - settings.setValue("default_mode", defmod); - settings.setValue("burnFirmware", burnfw); - settings.setValue("rename_firmware_files", renfw); - settings.setValue("sdPath", sdPath); - settings.setValue("SplashFileName", SplashFileName); - settings.setValue("SplashImage", SplashImage); - settings.setValue("firmware", firmware_id); - current_firmware_variant = GetFirmwareVariant(firmware_id); + g.id( profnum ); + + // TODO Get rid of this global variable - The profile.firmware is the real source + current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware()); foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { MdiChild *mdiChild = qobject_cast(window->widget()); @@ -1107,20 +1050,19 @@ void MainWindow::readEeprom() void MainWindow::writeFileToEeprom() { - QSettings settings; QString fileName; bool backup = false; burnDialog *cd = new burnDialog(this, 1, &fileName, &backup); cd->exec(); if (!fileName.isEmpty()) { - settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + g.eepromDir(QFileInfo(fileName).dir().absolutePath()); int ret = QMessageBox::question(this, "Companion", tr("Write Models and settings from %1 to the Tx?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No); if (ret != QMessageBox::Yes) return; if (!isValidEEPROM(fileName)) ret = QMessageBox::question(this, "Companion", tr("The file %1\nhas not been recognized as a valid Models and Settings file\nWrite anyway ?").arg(QFileInfo(fileName).fileName()), QMessageBox::Yes | QMessageBox::No); if (ret != QMessageBox::Yes) return; - bool backupEnable = settings.value("backupEnable", true).toBool(); - QString backupPath = settings.value("backupPath", "").toString(); + bool backupEnable = g.enableBackup(); + QString backupPath = g.backupDir(); if (!backupPath.isEmpty()) { if (!QDir(backupPath).exists()) { if (backupEnable) { @@ -1361,9 +1303,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString void MainWindow::writeFlash(QString fileToFlash) { - QSettings settings; QString fileName; - bool backup = settings.value("backupOnFlash", false).toBool(); + bool backup = g.backupOnFlash(); if(!fileToFlash.isEmpty()) fileName = fileToFlash; burnDialog *cd = new burnDialog(this, 2, &fileName, &backup); @@ -1371,12 +1312,12 @@ void MainWindow::writeFlash(QString fileToFlash) if (IS_TARANIS(GetEepromInterface()->getBoard())) backup=false; if (!fileName.isEmpty()) { - settings.setValue("backupOnFlash", backup); + g.backupOnFlash(backup); if (backup) { QString tempDir = QDir::tempPath(); QString backupFile = tempDir + "/backup.bin"; - bool backupEnable=settings.value("backupEnable", true).toBool(); - QString backupPath=settings.value("backupPath", "").toString(); + bool backupEnable=g.enableBackup(); + QString backupPath=g.backupDir(); if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) { if (!QDir(backupPath).exists()) { if (backupEnable) { @@ -1430,8 +1371,8 @@ void MainWindow::writeFlash(QString fileToFlash) } } else { - bool backupEnable=settings.value("backupEnable", true).toBool(); - QString backupPath=settings.value("backupPath", "").toString(); + bool backupEnable=g.enableBackup(); + QString backupPath=g.backupDir(); if (!QDir(backupPath).exists()) { if (backupEnable) { QMessageBox::warning(this, tr("Backup is impossible"), tr("The backup dir set in preferences does not exist")); @@ -1460,8 +1401,7 @@ void MainWindow::writeFlash(QString fileToFlash) void MainWindow::readEepromToFile() { - QSettings settings; - QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER)); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); if (!fileName.isEmpty()) { EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { @@ -1480,7 +1420,7 @@ void MainWindow::readEepromToFile() } } else { - settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + g.eepromDir(QFileInfo(fileName).dir().absolutePath()); QStringList str = GetReceiveEEpromCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); ad->setWindowIcon(CompanionIcon("read_eeprom.png")); @@ -1492,14 +1432,13 @@ void MainWindow::readEepromToFile() void MainWindow::readFlash() { - QSettings settings; - QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), settings.value("lastFlashDir").toString(),tr(FLASH_FILES_FILTER)); + QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), g.flashDir(),tr(FLASH_FILES_FILTER)); if (!fileName.isEmpty()) { QFile file(fileName); if (file.exists()) { file.remove(); } - settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath()); + g.flashDir(QFileInfo(fileName).dir().absolutePath()); QStringList str = GetReceiveFlashCommand(fileName); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); ad->setWindowIcon(CompanionIcon("read_flash.png")); @@ -1551,6 +1490,7 @@ void MainWindow::about() aboutStr.append("

"); aboutStr.append(tr("Copyright") + " Bertrand Songis & Romolo Manfredini
© 2011-2014
"); QMessageBox msgBox(this); + msgBox.setWindowIcon(CompanionIcon("information.png")); msgBox.setWindowTitle(tr("About Companion")); msgBox.setText(aboutStr); msgBox.exec(); @@ -1578,8 +1518,7 @@ void MainWindow::updateMenus() updateIconSizeActions(); updateIconThemeActions(); - QSettings settings; - setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString())); + setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( g.profile[g.id()].name() )); } MdiChild *MainWindow::createMdiChild() @@ -1630,7 +1569,7 @@ void MainWindow::createActions() separatorAct = new QAction(this); separatorAct->setSeparator(true); - for (int i = 0; i < MaxRecentFiles; ++i) { + for (int i = 0; i < MAX_RECENT; ++i) { recentFileActs[i] = new QAction(this); recentFileActs[i]->setVisible(false); connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); @@ -1658,7 +1597,7 @@ void MainWindow::createActions() QActionGroup *themeAlignGroup = new QActionGroup(this); classicThemeAct = addAct( themeAlignGroup, tr("Classical"), tr("The classical Companion icon theme"), SLOT(setClassicTheme())); - newThemeAct = addAct( themeAlignGroup, tr("New"), tr("The new Companion 2 icon theme"), SLOT(setNewTheme())); + yericoThemeAct = addAct( themeAlignGroup, tr("Yerico"), tr("Yellow round honey sweet icon theme"), SLOT(setYericoTheme())); monoThemeAct = addAct( themeAlignGroup, tr("Monochrome"), tr("A monochrome black icon theme"), SLOT(setMonochromeTheme())); monoWhiteAct = addAct( themeAlignGroup, tr("MonoWhite"), tr("A monochrome white icon theme"), SLOT(setMonoWhiteTheme())); monoBlueAct = addAct( themeAlignGroup, tr("MonoBlue"), tr("A monochrome blue icon theme"), SLOT(setMonoBlueTheme())); @@ -1728,7 +1667,7 @@ void MainWindow::createMenus() fileMenu->addAction(saveAsAct); fileMenu->addMenu(recentFileMenu); recentFileMenu->setIcon(CompanionIcon("recentdocument.png")); - for (int i=0; iaddAction(recentFileActs[i]); fileMenu->addSeparator(); fileMenu->addAction(logsAct); @@ -1763,7 +1702,7 @@ void MainWindow::createMenus() settingsMenu->addMenu(themeMenu); themeMenu->addAction(classicThemeAct); - themeMenu->addAction(newThemeAct); + themeMenu->addAction(yericoThemeAct); themeMenu->addAction(monoThemeAct); themeMenu->addAction(monoBlueAct); themeMenu->addAction(monoWhiteAct); @@ -1810,7 +1749,7 @@ void MainWindow::createMenus() QMenu *MainWindow::createRecentFileMenu() { QMenu *recentFileMenu = new QMenu(this); - for ( int i = 0; i < MaxRecentFiles; ++i) + for ( int i = 0; i < MAX_RECENT; ++i) recentFileMenu->addAction(recentFileActs[i]); return recentFileMenu; } @@ -1822,8 +1761,8 @@ QMenu *MainWindow::createProfilesMenu() for ( i = 0; i < MAX_PROFILES; ++i) { profilesMenu->addAction(profileActs[i]); } - if ( i>0 ) - profilesMenu->addSeparator(); + profilesMenu->addSeparator(); + profilesMenu->addAction(createProfileAct); profilesMenu->setIcon(CompanionIcon("profiles.png")); return profilesMenu; @@ -1831,10 +1770,8 @@ QMenu *MainWindow::createProfilesMenu() void MainWindow::createToolBars() { - QSettings settings; - int icon_size=settings.value("icon_size",2 ).toInt(); QSize size; - switch(icon_size) { + switch(g.iconSize()) { case 0: size=QSize(16,16); break; @@ -1919,20 +1856,6 @@ void MainWindow::createStatusBar() statusBar()->showMessage(tr("Ready")); } -void MainWindow::readSettings() -{ - QSettings settings; - restoreState(settings.value("mainWindowState").toByteArray()); - checkCompanion = settings.value("startup_check_companion", true).toBool(); - checkFW = settings.value("startup_check_fw", true).toBool(); - MaxRecentFiles =settings.value("history_size",10).toInt(); - if (settings.value("profileId",0).toInt() == 0) - { - createProfile(); - settings.setValue("profileId", "1"); - } -} - MdiChild *MainWindow::activeMdiChild() { if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow()) @@ -1961,27 +1884,31 @@ void MainWindow::setActiveSubWindow(QWidget *window) void MainWindow::updateRecentFileActions() { - int i,j, numRecentFiles; - QSettings settings; - QStringList files = settings.value("recentFileList").toStringList(); + int i, numRecentFiles; - numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); + // Hide all document slots + for ( i=0 ; i < g.historySize(); i++) + recentFileActs[i]->setVisible(false); + + // Fill slots with content and unhide them + QStringList files = g.recentFiles(); + numRecentFiles = qMin(files.size(), g.historySize()); - for ( i = 0; i < numRecentFiles; ++i) { - QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); - recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); - recentFileActs[i]->setVisible(true); + for ( i = 0; i < numRecentFiles; i++) { + QString text = strippedName(files[i]); + if (!text.trimmed().isEmpty()) + { + recentFileActs[i]->setText(text); + recentFileActs[i]->setData(files[i]); + recentFileActs[i]->setVisible(true); + } } - for ( j = numRecentFiles; j < MaxRecentFiles; ++j) - recentFileActs[j]->setVisible(false); } void MainWindow::updateIconSizeActions() { - QSettings settings; - int size = settings.value("icon_size","0").toInt(); - switch (size){ + switch (g.iconSize()) + { case 0: smallIconAct->setChecked(true); break; case 1: normalIconAct->setChecked(true); break; case 2: bigIconAct->setChecked(true); break; @@ -1991,8 +1918,7 @@ void MainWindow::updateIconSizeActions() void MainWindow::updateLanguageActions() { - QSettings settings; - QString langId = settings.value("locale","").toString(); + QString langId = g.locale(); if (langId=="") sysLangAct->setChecked(true); @@ -2022,11 +1948,10 @@ void MainWindow::updateLanguageActions() void MainWindow::updateIconThemeActions() { - QSettings settings; - int size = settings.value("theme","1").toInt(); - switch (size){ + switch (g.theme()) + { case 0: classicThemeAct->setChecked(true); break; - case 1: newThemeAct->setChecked(true); break; + case 1: yericoThemeAct->setChecked(true); break; case 2: monoWhiteAct->setChecked(true); break; case 3: monoThemeAct->setChecked(true); break; case 4: monoBlueAct->setChecked(true); break; @@ -2035,52 +1960,34 @@ void MainWindow::updateIconThemeActions() void MainWindow::updateProfilesActions() { - int i; - QSettings settings; - int activeProfile = settings.value("profileId").toInt(); - - settings.beginGroup("Profiles"); - for (i=0; isetText(text); - profileActs[i]->setData(i+1); + profileActs[i]->setData(i); profileActs[i]->setVisible(true); - if ((i+1) == activeProfile) + if (i == g.id()) profileActs[i]->setChecked(true); } - else { + else + { profileActs[i]->setVisible(false); } - settings.endGroup(); } } void MainWindow::createProfile() -{ - int firstFreeIndex = 0; - QSettings settings; - settings.beginGroup("Profiles"); - for (int i=0; firstFreeIndex ==0 && i #if defined WIN32 || !defined __GNUC__ @@ -69,6 +68,7 @@ MdiChild::MdiChild(): fileChanged(false) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("open.png")); ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png")); setAttribute(Qt::WA_DeleteOnClose); @@ -142,25 +142,7 @@ void MdiChild::setModified() void MdiChild::on_SimulateTxButton_clicked() { - if (GetEepromInterface()->getSimulator()) { - if (GetEepromInterface()->getCapability(SimulatorType)==1) { - xsimulatorDialog * sd = new xsimulatorDialog(this); - sd->loadParams(radioData); - sd->exec(); - delete sd; - } - else { - simulatorDialog * sd = new simulatorDialog(this); - sd->loadParams(radioData); - sd->exec(); - delete sd; - } - } - else { - QMessageBox::warning(NULL, - QObject::tr("Warning"), - QObject::tr("Simulator for this firmware is not yet available")); - } + startSimulation(this, radioData, -1); } void MdiChild::OpenEditWindow(bool wizard=false) @@ -179,8 +161,7 @@ void MdiChild::OpenEditWindow(bool wizard=false) } if (isNew && !wizard) { int ret; - QSettings settings; - bool wizardEnable=settings.value("wizardEnable", true).toBool(); + bool wizardEnable=g.enableWizard(); if (wizardEnable) { ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::Yes) { @@ -189,7 +170,7 @@ void MdiChild::OpenEditWindow(bool wizard=false) qSleep(500); ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) { - settings.setValue("wizardEnable", false); + g.enableWizard( false ); } } } @@ -346,34 +327,33 @@ bool MdiChild::save() bool MdiChild::saveAs(bool isNew) { - QSettings settings; QString fileName; if (GetEepromInterface()->getBoard() == BOARD_SKY9X) { curFile.replace(".eepe", ".bin"); QFileInfo fi(curFile); #ifdef __APPLE__ - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName()); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName()); #else - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(BIN_FILES_FILTER)); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER)); #endif } else { QFileInfo fi(curFile); #ifdef __APPLE__ - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName()); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName()); #else - fileName = QFileDialog::getSaveFileName(this, tr("Save As"), settings.value("lastDir").toString() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER)); + fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER)); #endif } if (fileName.isEmpty()) return false; if (fileName.contains("rev4a")) { - settings.setValue("rev4asupport", 1); + g.rev4aSupport( true ); } if (fileName.contains("norev4a")) { - settings.setValue("rev4asupport", 0); + g.rev4aSupport( false ); } - settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); + g.eepromDir( QFileInfo(fileName).dir().absolutePath() ); if (isNew) return saveFile(fileName); else @@ -490,15 +470,14 @@ void MdiChild::setCurrentFile(const QString &fileName) fileChanged = false; setWindowModified(false); updateTitle(); - QSettings settings; - int MaxRecentFiles =settings.value("history_size",10).toInt(); - QStringList files = settings.value("recentFileList").toStringList(); + int MaxRecentFiles = g.historySize(); + QStringList files = g.recentFiles(); files.removeAll(fileName); files.prepend(fileName); while (files.size() > MaxRecentFiles) files.removeLast(); - settings.setValue("recentFileList", files); + g.recentFiles( files ); } QString MdiChild::strippedName(const QString &fullFileName) @@ -508,9 +487,8 @@ QString MdiChild::strippedName(const QString &fullFileName) void MdiChild::writeEeprom() // write to Tx { - QSettings settings; - bool backupEnable=settings.value("backupEnable", true).toBool(); - QString backupPath=settings.value("backupPath", "").toString(); + bool backupEnable=g.enableBackup(); + QString backupPath=g.backupDir(); if (!backupPath.isEmpty()) { if (!QDir(backupPath).exists()) { if (backupEnable) { @@ -521,13 +499,7 @@ void MdiChild::writeEeprom() // write to Tx } else { backupEnable=false; } - int profileid=settings.value("profileId", 1).toInt(); - settings.beginGroup("Profiles"); - QString profile=QString("profile%1").arg(profileid); - settings.beginGroup(profile); - QString stickCal=settings.value("StickPotCalib","").toString(); - settings.endGroup(); - settings.endGroup(); + QString stickCal=g.profile[g.id()].stickPotCalib(); burnConfigDialog bcd; QString tempDir = QDir::tempPath(); QString tempFile = tempDir + "/temp.bin"; @@ -647,22 +619,9 @@ void MdiChild::writeEeprom() // write to Tx void MdiChild::simulate() { - if(ui->modelsList->currentRow()<1) return; - if (GetEepromInterface()->getSimulator()) { - if (GetEepromInterface()->getCapability(SimulatorType)) { - xsimulatorDialog sd(this); - sd.loadParams(radioData, ui->modelsList->currentRow()-1); - sd.exec(); - } else { - simulatorDialog sd(this); - sd.loadParams(radioData, ui->modelsList->currentRow()-1); - sd.exec(); - } - } else { - QMessageBox::warning(NULL, - QObject::tr("Warning"), - QObject::tr("Simulator for this firmware is not yet available")); - } + if (ui->modelsList->currentRow() >= 1) { + startSimulation(this, radioData, ui->modelsList->currentRow()-1); + } } void MdiChild::print(int model, QString filename) @@ -690,8 +649,7 @@ void MdiChild::setEEpromAvail(int eavail) bool MdiChild::loadBackup() { - QSettings settings; - QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER)); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.eepromDir(),tr(EEPROM_FILES_FILTER)); if (fileName.isEmpty()) return false; QFile file(fileName); diff --git a/companion/src/mdichild.ui b/companion/src/mdichild.ui index b2fb21e2f..538e36b74 100644 --- a/companion/src/mdichild.ui +++ b/companion/src/mdichild.ui @@ -13,10 +13,6 @@ - - - :/icon.png:/icon.png - diff --git a/companion/src/modelconfigdialog.cpp b/companion/src/modelconfigdialog.cpp index 49c4a8df0..4badaa906 100644 --- a/companion/src/modelconfigdialog.cpp +++ b/companion/src/modelconfigdialog.cpp @@ -3,7 +3,10 @@ #include "helpers.h" #include "eeprominterface.h" #include +#include "helpers.h" + #define NUM_CH 10 + modelConfigDialog::modelConfigDialog(RadioData &radioData, uint64_t * result, QWidget *parent) : QDialog(parent), ui(new Ui::modelConfigDialog), @@ -12,6 +15,7 @@ modelConfigDialog::modelConfigDialog(RadioData &radioData, uint64_t * result, QW generalSettings(radioData.generalSettings) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("wizard.png")); rxLock=false; ruddercolor << "#ffd100" << "#ffff00"; throttlecolor << "#e40000"; diff --git a/companion/src/modelconfigdialog.ui b/companion/src/modelconfigdialog.ui index f9c7abba6..afa4dd0bd 100644 --- a/companion/src/modelconfigdialog.ui +++ b/companion/src/modelconfigdialog.ui @@ -6,8 +6,8 @@ 0 0 - 773 - 591 + 793 + 599
@@ -25,10 +25,6 @@ Model Configuration Wizard - - - :/icon.png:/icon.png - diff --git a/companion/src/modeledit/customfunctions.cpp b/companion/src/modeledit/customfunctions.cpp index 49f7630e8..c9ba53ba5 100644 --- a/companion/src/modeledit/customfunctions.cpp +++ b/companion/src/modeledit/customfunctions.cpp @@ -6,6 +6,7 @@ #include #include #include "helpers.h" +#include "appdata.h" RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam): QComboBox(parent), @@ -74,8 +75,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, } } - QSettings settings; - QString path = settings.value("sdPath", ".").toString(); + QString path = g.profile[g.id()].sdPath(); path.append("/SOUNDS/"); QString lang = generalSettings.ttsLanguage; if (lang.isEmpty()) @@ -225,8 +225,7 @@ void CustomFunctionsPanel::playMusic() QPushButton *playButton = qobject_cast(sender()); int index=playButton->objectName().mid(5,2).toInt(); QString function=playButton->objectName().left(4); - QSettings settings; - QString path = settings.value("sdPath", ".").toString(); + QString path = g.profile[g.id()].sdPath(); QDir qd(path); QString track; if (qd.exists()) { diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 9336f913b..c3c24b14b 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -11,6 +11,7 @@ #include "customswitches.h" #include "customfunctions.h" #include "telemetry.h" +#include "appdata.h" #include ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool isNew, QWidget *parent) : @@ -21,8 +22,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i generalSettings(radioData.generalSettings) { ui->setupUi(this); - QSettings settings; - restoreGeometry(settings.value("modelEditGeometry").toByteArray()); + restoreGeometry(g.modelEditGeo()); ui->pushButton->setIcon(CompanionIcon("simulate.png")); addTab(new Setup(this, model), tr("Setup")); addTab(new HeliPanel(this, model), tr("Heli")); @@ -45,8 +45,7 @@ ModelEdit::~ModelEdit() void ModelEdit::closeEvent(QCloseEvent *event) { - QSettings settings; - settings.setValue("modelEditGeometry", saveGeometry()); + g.modelEditGeo( saveGeometry() ); } class VerticalScrollArea : public QScrollArea @@ -107,35 +106,13 @@ void ModelEdit::on_pushButton_clicked() launchSimulation(); } -// TODO merge both -#include "simulatordialog.h" -#include "xsimulatordialog.h" - void ModelEdit::launchSimulation() { - if (GetEepromInterface()->getSimulator()) { - RadioData *simuData = new RadioData(); - simuData->generalSettings = generalSettings; - simuData->models[modelId] = model; - if (GetEepromInterface()->getCapability(SimulatorType)) { - xsimulatorDialog *sd = new xsimulatorDialog(this); - sd->loadParams(*simuData, modelId); - sd->exec(); - delete sd; - } - else { - simulatorDialog *sd = new simulatorDialog(this); - sd->loadParams(*simuData, modelId); - sd->exec(); - delete sd; - } - delete simuData; - } - else { - QMessageBox::warning(NULL, - QObject::tr("Warning"), - QObject::tr("Simulator for this firmware is not yet available")); - } + RadioData *simuData = new RadioData(); + simuData->generalSettings = generalSettings; + simuData->models[0] = model; + startSimulation(this, *simuData, 0); + delete simuData; } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 8042ccfe3..6dd46c3e0 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -3,6 +3,7 @@ #include "ui_setup_timer.h" #include "ui_setup_module.h" #include "helpers.h" +#include "appdata.h" TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer): ModelPanel(parent, model), @@ -347,8 +348,7 @@ Setup::Setup(QWidget *parent, ModelData & model): if (GetEepromInterface()->getCapability(ModelImage)) { QStringList items; items.append(""); - QSettings settings; - QString path = settings.value("sdPath", ".").toString(); + QString path = g.profile[g.id()].sdPath(); path.append("/BMP/"); QDir qd(path); int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4; @@ -476,7 +476,7 @@ void Setup::on_extendedLimits_toggled(bool checked) void Setup::on_throttleWarning_toggled(bool checked) { - model.disableThrottleWarning = checked; + model.disableThrottleWarning = !checked; emit modified(); } @@ -515,8 +515,7 @@ void Setup::on_image_currentIndexChanged(int index) { if (!lock) { strncpy(model.bitmap, ui->image->currentText().toAscii(), GetEepromInterface()->getCapability(VoicesMaxLength)); - QSettings settings; - QString path=settings.value("sdPath", ".").toString(); + QString path=g.profile[g.id()].sdPath(); path.append("/BMP/"); QDir qd(path); if (qd.exists()) { @@ -550,7 +549,7 @@ void Setup::update() ui->throttleReverse->setChecked(model.throttleReversed); populateTTraceCB(ui->throttleSource, model.thrTraceSrc); - ui->throttleWarning->setChecked(model.disableThrottleWarning); + ui->throttleWarning->setChecked(!model.disableThrottleWarning); //trim inc, thro trim, thro expo, instatrim ui->trimIncrement->setCurrentIndex(model.trimInc+2); diff --git a/companion/src/modeledit/telemetry.cpp b/companion/src/modeledit/telemetry.cpp index 1b5fd285f..099ba56ab 100644 --- a/companion/src/modeledit/telemetry.cpp +++ b/companion/src/modeledit/telemetry.cpp @@ -3,6 +3,7 @@ #include "ui_telemetry_analog.h" #include "ui_telemetry_customscreen.h" #include "helpers.h" +#include "appdata.h" TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog): QWidget(parent), @@ -456,8 +457,7 @@ TelemetryPanel::~TelemetryPanel() void TelemetryPanel::setup() { - QSettings settings; - QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); + QString firmware_id = g.profile[g.id()].firmware(); lock=true; diff --git a/companion/src/preferencesdialog.cpp b/companion/src/preferencesdialog.cpp deleted file mode 100644 index 7b4ce1707..000000000 --- a/companion/src/preferencesdialog.cpp +++ /dev/null @@ -1,827 +0,0 @@ -#include "preferencesdialog.h" -#include "ui_preferencesdialog.h" -#include "mainwindow.h" -#include "eeprominterface.h" -#include "splashlibrary.h" -#include "helpers.h" -#ifdef JOYSTICKS -#include "joystick.h" -#include "joystickdialog.h" -#endif -#include -#include - -preferencesDialog::preferencesDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::preferencesDialog), - updateLock(false) -{ - ui->setupUi(this); - setWindowIcon(CompanionIcon("preferences.png")); - ui->splashLibraryButton->setIcon(CompanionIcon("library.png")); - ui->clearImageButton->setIcon(CompanionIcon("clear.png")); - - QCheckBox * OptionCheckBox[]= { - ui->optionCheckBox_1, ui->optionCheckBox_2, ui->optionCheckBox_3, ui->optionCheckBox_4, ui->optionCheckBox_5, ui->optionCheckBox_6, ui->optionCheckBox_7, - ui->optionCheckBox_8, ui->optionCheckBox_9, ui->optionCheckBox_10, ui->optionCheckBox_11, ui->optionCheckBox_12, ui->optionCheckBox_13, ui->optionCheckBox_14, - ui->optionCheckBox_15,ui->optionCheckBox_16, ui->optionCheckBox_17, ui->optionCheckBox_18, ui->optionCheckBox_19, ui->optionCheckBox_20, ui->optionCheckBox_21, - ui->optionCheckBox_22, ui->optionCheckBox_23, ui->optionCheckBox_24, ui->optionCheckBox_25, ui->optionCheckBox_26, ui->optionCheckBox_27, ui->optionCheckBox_28, - ui->optionCheckBox_29, ui->optionCheckBox_30, ui->optionCheckBox_31, ui->optionCheckBox_32, ui->optionCheckBox_33, ui->optionCheckBox_34, ui->optionCheckBox_35, - ui->optionCheckBox_36, ui->optionCheckBox_37, ui->optionCheckBox_38, ui->optionCheckBox_39, ui->optionCheckBox_40, ui->optionCheckBox_41, ui->optionCheckBox_42, - NULL }; - - voice=NULL; - - connect(ui->langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged())); - connect(ui->voiceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(firmwareLangChanged())); - - for (int i=0; OptionCheckBox[i]; i++) { - optionsCheckBoxes.push_back(OptionCheckBox[i]); - connect(OptionCheckBox[i], SIGNAL(toggled(bool)), this, SLOT(firmwareOptionChanged(bool))); - } - - initSettings(); - connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged())); - connect(this, SIGNAL(accepted()), this, SLOT(writeValues())); -#ifndef JOYSTICKS - ui->joystickCB->hide(); - ui->joystickCB->setDisabled(true); - ui->joystickcalButton->hide(); - ui->joystickChkB->hide(); - ui->label_11->hide(); -#endif - resize(0,0); -} - - -preferencesDialog::~preferencesDialog() -{ - delete ui; -} - -void preferencesDialog::baseFirmwareChanged() -{ - QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex()); - voice=NULL; - foreach(FirmwareInfo * firmware, firmwares) { - if (firmware->id == selected_firmware) { - if (firmware->voice) { - ui->voiceLabel->show(); - ui->voiceCombo->show(); - ui->voice_dnld->show(); - ui->sdPathButton->show(); - ui->sdPath->show(); - ui->sdPathLabel->show(); - ui->voiceLabel->setEnabled(true); - ui->voiceCombo->setEnabled(true); - ui->voice_dnld->setEnabled(true); - ui->sdPathButton->setEnabled(true); - ui->sdPath->setEnabled(true); - ui->ge_label->show(); - ui->ge_lineedit->show(); - ui->ge_pathButton->show(); - } else { - ui->voiceLabel->hide(); - ui->voiceCombo->hide(); - ui->voice_dnld->hide(); - ui->sdPathButton->hide(); - ui->sdPath->hide(); - ui->sdPathLabel->hide(); - ui->ge_label->hide(); - ui->ge_lineedit->hide(); - ui->ge_pathButton->hide(); - } - populateFirmwareOptions(firmware); - int width=firmware->eepromInterface->getCapability(LCDWidth); - ui->imageLabel->setFixedWidth(width); - break; - } - } - firmwareChanged(); -} - -FirmwareVariant preferencesDialog::getFirmwareVariant() -{ - QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex()); - bool voice=false; - foreach(FirmwareInfo * firmware, firmwares) { - if (firmware->id == selected_firmware) { - QString id = firmware->id; - foreach(QCheckBox *cb, optionsCheckBoxes) { - if (cb->isChecked()) { - if (cb->text()=="voice" && cb->isChecked()) - voice=true; - id += QString("-") + cb->text(); - } - } - if (! firmware->eepromInterface->getCapability(MultiLangVoice)) { - if (ui->voiceCombo->count() && (voice || firmware->voice)) - id += QString("-tts") + ui->voiceCombo->currentText(); - } - if (ui->langCombo->count()) - id += QString("-") + ui->langCombo->currentText(); - - return GetFirmwareVariant(id); - } - } - - // Should never occur... - return default_firmware_variant; -} - -void preferencesDialog::firmwareLangChanged() -{ - firmwareChanged(); -} - -void preferencesDialog::firmwareOptionChanged(bool state) -{ - QCheckBox *cb = qobject_cast(sender()); - FirmwareInfo * firmware=NULL; - if (cb && state) { - QVariant selected_firmware = ui->downloadVerCB->itemData(ui->downloadVerCB->currentIndex()); - foreach(firmware, firmwares) { - if (firmware->id == selected_firmware) { - foreach(QList