1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 14:25:11 +03:00

Merge remote-tracking branch 'origin/next' into

bsongis/Issue713_more_custom_functions

Conflicts:
	radio/src/.gitignore
	radio/src/opentx.cpp
This commit is contained in:
Bertrand Songis 2014-02-21 14:26:11 +01:00
commit 9ade773618
432 changed files with 50699 additions and 11677 deletions

View file

@ -324,3 +324,4 @@ Leonard MacKey
Reginald H Millsom Reginald H Millsom
Emanuel Stassar Emanuel Stassar
Pierluigi Sommaruga Pierluigi Sommaruga
Rafael Eric Suarez Nordlow

View file

@ -72,50 +72,9 @@ ELSE( )
LINK_DIRECTORIES( /usr/local/lib ) LINK_DIRECTORIES( /usr/local/lib )
ENDIF( ) 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) set(RADIO_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/../../radio/src)
set(SIMU_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/simulation)
include_directories( set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR})
${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
)
add_custom_command( add_custom_command(
OUTPUT ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm OUTPUT ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm
@ -124,9 +83,20 @@ add_custom_command(
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
) )
add_subdirectory(modeledit) 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}
)
SET( companion_SRCS add_subdirectory(modeledit)
add_subdirectory(simulation)
set(companion_SRCS
eeprominterface.cpp eeprominterface.cpp
hexinterface.cpp hexinterface.cpp
flashinterface.cpp flashinterface.cpp
@ -135,10 +105,8 @@ SET( companion_SRCS
${PROJECT_BINARY_DIR}/radio.cxx ${PROJECT_BINARY_DIR}/radio.cxx
firmwares/th9x/th9xeeprom.cpp firmwares/th9x/th9xeeprom.cpp
firmwares/th9x/th9xinterface.cpp firmwares/th9x/th9xinterface.cpp
${TH9X_CHECKOUT_DIRECTORY}/th9xsimulator.cpp
firmwares/er9x/er9xeeprom.cpp firmwares/er9x/er9xeeprom.cpp
firmwares/er9x/er9xinterface.cpp firmwares/er9x/er9xinterface.cpp
${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp
firmwares/gruvin9x/gruvin9xeeprom.cpp firmwares/gruvin9x/gruvin9xeeprom.cpp
firmwares/gruvin9x/gruvin9xinterface.cpp firmwares/gruvin9x/gruvin9xinterface.cpp
firmwares/opentx/opentxeeprom.cpp firmwares/opentx/opentxeeprom.cpp
@ -153,8 +121,8 @@ SET( companion_SRCS
firmwares/opentx/opentxsimulator.cpp firmwares/opentx/opentxsimulator.cpp
firmwares/ersky9x/ersky9xeeprom.cpp firmwares/ersky9x/ersky9xeeprom.cpp
firmwares/ersky9x/ersky9xinterface.cpp firmwares/ersky9x/ersky9xinterface.cpp
${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp
${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm ${RADIO_SRC_DIRECTORY}/bitmaps/sticks.lbm
appdata.cpp
helpers.cpp helpers.cpp
mdichild.cpp mdichild.cpp
generaledit.cpp generaledit.cpp
@ -172,16 +140,14 @@ SET( companion_SRCS
fusesdialog.cpp fusesdialog.cpp
logsdialog.cpp logsdialog.cpp
downloaddialog.cpp downloaddialog.cpp
simulatordialog.cpp
xsimulatordialog.cpp
splashlibrary.cpp splashlibrary.cpp
mainwindow.cpp mainwindow.cpp
main.cpp companion.cpp
modelconfigdialog.cpp modelconfigdialog.cpp
qcustomplot.cpp qcustomplot.cpp
) )
SET( companion_MOC_HDRS set(companion_MOC_HDRS
avroutputdialog.h avroutputdialog.h
apppreferencesdialog.h apppreferencesdialog.h
fwpreferencesdialog.h fwpreferencesdialog.h
@ -196,23 +162,16 @@ SET( companion_MOC_HDRS
splashlabel.h splashlabel.h
burndialog.h burndialog.h
downloaddialog.h downloaddialog.h
cursorwidget.h
menuwidget.h
simulatordialog.h
xcursorwidget.h
xmenuwidget.h
xsimulatordialog.h
generaledit.h generaledit.h
modelslist.h modelslist.h
mdichild.h mdichild.h
mainwindow.h mainwindow.h
myslider.h
modelconfigdialog.h modelconfigdialog.h
qcustomplot.h qcustomplot.h
helpers.h helpers.h
) )
SET( companion_UIS set(companion_UIS
mdichild.ui mdichild.ui
avroutputdialog.ui avroutputdialog.ui
comparedialog.ui comparedialog.ui
@ -220,8 +179,6 @@ SET( companion_UIS
logsdialog.ui logsdialog.ui
apppreferencesdialog.ui apppreferencesdialog.ui
fwpreferencesdialog.ui fwpreferencesdialog.ui
simulatordialog.ui
xsimulatordialog.ui
burnconfigdialog.ui burnconfigdialog.ui
downloaddialog.ui downloaddialog.ui
generaledit.ui generaledit.ui
@ -233,26 +190,7 @@ SET( companion_UIS
modelconfigdialog.ui modelconfigdialog.ui
) )
IF ( SDL_FOUND ) set(companion_RCS
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 companion.qrc
${CMAKE_CURRENT_BINARY_DIR}/translations.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc
) )
@ -292,8 +230,6 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc.in ${CMAKE_CURRENT_B
# Subversion_WC_INFO( ${PROJECT_SOURCE_DIR}/../${FIRMWARE} G9X ) # 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) 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 ) IF( WIN32 )
SET( companion_SRCS ${companion_SRCS} icon.rc ) SET( companion_SRCS ${companion_SRCS} icon.rc )
IF ( NOT MSVC ) IF ( NOT MSVC )
@ -322,7 +258,88 @@ ELSE( )
ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion_SRCS} ${companion_QM} ) ADD_EXECUTABLE( ${PROJECT_NAME} WIN32 ${companion_SRCS} ${companion_QM} )
ENDIF( ) 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") IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
@ -366,7 +383,8 @@ IF( WIN32 )
ADD_CUSTOM_TARGET( installer ADD_CUSTOM_TARGET( installer
DEPENDS ${PROJECT_BINARY_DIR}/companionInstall.exe DEPENDS ${PROJECT_BINARY_DIR}/companionInstall.exe
SOURCES ${PROJECT_BINARY_DIR}/companion.nsi) SOURCES ${PROJECT_BINARY_DIR}/companion.nsi
)
ENDIF( ) ENDIF( )
IF( APPLE ) IF( APPLE )

643
companion/src/appdata.cpp Normal file
View file

@ -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<MAX_PROFILES; i++)
profile[i].init( i );
//Initialize the joysticks
for (int i=0; i<MAX_JOYSTICKS; i++)
joystick[i].init( i );
// Import settings from companion9x, but only do it one time.
// Use "location" tag as an indicator that the settings are missing
QSettings c9x_settings("companion9x", "companion9x");
QSettings settings(PRODUCT, COMPANY);
if (!settings.contains("locale"))
{
QStringList keys = c9x_settings.allKeys();
for (QStringList::iterator i=keys.begin(); i!=keys.end(); i++)
{
settings.setValue(*i, c9x_settings.value(*i));
}
// Convert firmware name
QString firmware = settings.value("firmware", "").toString();
firmware.replace("open9x","opentx");
firmware.replace("x9da","taranis");
// Move Companion9x settings to profile0, the new default profile
profile[0].firmware( firmware );
profile[0].name( settings.value( "Name", "" ).toString());
profile[0].sdPath( settings.value( "sdPath", "" ).toString());
profile[0].splashFile( settings.value( "SplashFileName", "" ).toString());
profile[0].burnFirmware( settings.value( "burnFirmware", false ).toBool());
profile[0].renameFwFiles( settings.value( "rename_firmware_files", false ).toBool());
profile[0].patchImage( settings.value( "patchImage", false ).toBool());
profile[0].channelOrder( settings.value( "default_channel_order", "0" ).toInt());
profile[0].defaultMode( settings.value( "default_mode", "1" ).toInt());
// Delete unused settings
settings.remove("firmware");
settings.remove("Name");
settings.remove("sdPath");
settings.remove("SplashFileName");
settings.remove("burnFirmware");
settings.remove("rename_firmware_files");
settings.remove("patchImage");
settings.remove("default_channel_order");
settings.remove("default_mode");
}
// Load and store all variables. Use default values if setting values are missing
getset( _recentFiles, "recentFileList" ,"" );
getset( _mainWinGeo, "mainWindowGeometry" ,"" );
getset( _mainWinState, "mainWindowState" ,"" );
getset( _modelEditGeo, "modelEditGeometry" ,"" );
getset( _armMcu, "arm_mcu" ,"at91sam3s4-9x" );
getset( _avrArguments, "avr_arguments" ,"" );
getset( _avrPort, "avr_port" ,"" );
getset( _avrdudeLocation, "avrdudeLocation" ,"" );
getset( _compileServer, "compilation-server" ,"" );
getset( _cpuId, "cpu_id" ,"" );
getset( _dfuArguments, "dfu_arguments" ,"-a 0" );
getset( _dfuLocation, "dfu_location" ,"" );
getset( _lastFw, "lastFw" ,"" );
getset( _locale, "locale" ,"" );
getset( _mcu, "mcu" ,"m64" );
getset( _programmer, "programmer" ,"usbasp" );
getset( _sambaLocation, "samba_location" ,"" );
getset( _sambaPort, "samba_port" ,"\\USBserial\\COM23" );
getset( _backupDir, "backupPath" ,"" );
getset( _gePath, "gePath" ,"" );
getset( _eepromDir, "lastDir" ,"" );
getset( _flashDir, "lastFlashDir" ,"" );
getset( _imagesDir, "lastImagesDir" ,"" );
getset( _logDir, "lastLogDir" ,"" );
getset( _libDir, "libraryPath" ,"" );
getset( _snapshotDir, "snapshotpath" ,"" );
getset( _updatesDir, "lastUpdatesDir" ,"" );
getset( _enableBackup, "backupEnable" ,false );
getset( _backupOnFlash, "backupOnFlash" ,true );
getset( _jsSupport, "js_support" ,false );
getset( _rev4aSupport, "rev4asupport" ,false );
getset( _maximized, "maximized" ,false );
getset( _showSplash, "show_splash" ,true );
getset( _snapToClpbrd, "snapshot_to_clipboard" ,false );
getset( _autoCheckApp, "startup_check_companion" ,true );
getset( _autoCheckFw, "startup_check_fw" ,true );
getset( _simuSW, "simuSW" ,false );
getset( _enableWizard, "wizardEnable" ,true );
getset( _backLight, "backLight" ,0 );
getset( _embedSplashes, "embedded_splashes" ,0 );
getset( _fwServerFails, "fwserver" ,0 );
getset( _generalEditTab, "generalEditTab" ,0 );
getset( _iconSize, "icon_size" ,2 );
getset( _jsCtrl, "js_ctrl" ,0 );
getset( _historySize, "history_size" ,10 );
getset( _modelEditTab, "modelEditTab" ,0 );
getset( _id, "profileId" ,0 );
getset( _theme, "theme" ,1 );
getset( _warningId, "warningId" ,0 );
}

355
companion/src/appdata.h Normal file
View file

@ -0,0 +1,355 @@
// Companion Application Data Class Definition.
// Author Kjell Kernen
// All temporary and permanent global variables are defined here to make
// initialization and storage safe and visible.
// Do not access variables in QSettings directly, it is not type safe!
#ifndef COMPANION_APPDATA_H
#define COMPANION_APPDATA_H
#include <QByteArray>
#include <QStringList>
#include <QString>
#include <QSettings>
#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

View file

@ -1,6 +1,7 @@
#include "apppreferencesdialog.h" #include "apppreferencesdialog.h"
#include "ui_apppreferencesdialog.h" #include "ui_apppreferencesdialog.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "appdata.h"
#include "helpers.h" #include "helpers.h"
#include "flashinterface.h" #include "flashinterface.h"
#ifdef JOYSTICKS #ifdef JOYSTICKS
@ -35,101 +36,87 @@ appPreferencesDialog::~appPreferencesDialog()
void appPreferencesDialog::writeValues() void appPreferencesDialog::writeValues()
{ {
QSettings settings; g.autoCheckApp(ui->startupCheck_companion9x->isChecked());
settings.setValue("startup_check_companion", ui->startupCheck_companion9x->isChecked()); g.autoCheckFw(ui->startupCheck_fw->isChecked());
settings.setValue("startup_check_fw", ui->startupCheck_fw->isChecked()); g.enableWizard(ui->wizardEnable_ChkB->isChecked());
settings.setValue("wizardEnable", ui->wizardEnable_ChkB->isChecked()); g.showSplash(ui->showSplash->isChecked());
settings.setValue("show_splash", ui->showSplash->isChecked()); g.simuSW(ui->simuSW->isChecked());
settings.setValue("simuSW", ui->simuSW->isChecked()); g.historySize(ui->historySize->value());
settings.setValue("history_size", ui->historySize->value()); g.backLight(ui->backLightColor->currentIndex());
settings.setValue("backLight", ui->backLightColor->currentIndex()); g.libDir(ui->libraryPath->text());
settings.setValue("libraryPath", ui->libraryPath->text()); g.gePath(ui->ge_lineedit->text());
settings.setValue("gePath", ui->ge_lineedit->text()); g.embedSplashes(ui->splashincludeCB->currentIndex());
settings.setValue("embedded_splashes", ui->splashincludeCB->currentIndex()); g.enableBackup(ui->backupEnable->isChecked());
settings.setValue("backupEnable", ui->backupEnable->isChecked());
if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) { if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) {
settings.setValue("js_support", ui->joystickChkB ->isChecked()); g.jsSupport(ui->joystickChkB ->isChecked());
settings.setValue("js_ctrl", ui->joystickCB ->currentIndex()); g.jsCtrl(ui->joystickCB ->currentIndex());
} }
else { else {
settings.remove("js_support"); g.jsSupport(false);
settings.remove("js_ctrl"); g.jsCtrl(0);
} }
settings.setValue("default_channel_order", ui->channelorderCB->currentIndex()); g.id(ui->profileIndexLE->text().toInt());
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked()); g.profile[g.id()].channelOrder(ui->channelorderCB->currentIndex());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked()); g.profile[g.id()].defaultMode(ui->stickmodeCB->currentIndex());
settings.setValue("profileId", ui->profileIndexLE->text()); g.profile[g.id()].renameFwFiles(ui->renameFirmware->isChecked());
settings.setValue("Name", ui->profileNameLE->text()); g.profile[g.id()].burnFirmware(ui->burnFirmware->isChecked());
settings.setValue("sdPath", ui->sdPath->text()); g.profile[g.id()].name(ui->profileNameLE->text());
settings.setValue("SplashFileName", ui->SplashFileName->text()); g.profile[g.id()].sdPath(ui->sdPath->text());
if (!ui->SplashFileName->text().isEmpty()) g.profile[g.id()].splashFile(ui->SplashFileName->text());
settings.setValue("SplashImage", ""); g.profile[g.id()].firmware(ui->firmwareLE->text());
settings.setValue("firmware", ui->firmwareLE->text());
saveProfile(); saveProfile();
} }
void appPreferencesDialog::on_snapshotPathButton_clicked() void appPreferencesDialog::on_snapshotPathButton_clicked()
{ {
QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), g.snapshotDir());
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your snapshot folder"), settings.value("snapshotPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("snapshotpath", fileName); g.snapshotDir(fileName);
settings.setValue("snapshot_to_clipboard", false); g.snapToClpbrd(false);
ui->snapshotPath->setText(fileName); ui->snapshotPath->setText(fileName);
} }
} }
void appPreferencesDialog::initSettings() void appPreferencesDialog::initSettings()
{ {
QSettings settings; ui->snapshotClipboardCKB->setChecked(g.snapToClpbrd());
ui->snapshotClipboardCKB->setChecked(settings.value("snapshot_to_clipboard", false).toBool()); ui->burnFirmware->setChecked(g.profile[g.id()].burnFirmware());
ui->burnFirmware->setChecked(settings.value("burnFirmware", true).toBool()); ui->snapshotPath->setText(g.snapshotDir());
QString Path=settings.value("snapshotPath", "").toString();
if (QDir(Path).exists()) {
ui->snapshotPath->setText(Path);
ui->snapshotPath->setReadOnly(true); ui->snapshotPath->setReadOnly(true);
} if (ui->snapshotClipboardCKB->isChecked())
if (ui->snapshotClipboardCKB->isChecked()) { {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true); ui->snapshotPathButton->setDisabled(true);
} }
ui->startupCheck_companion9x->setChecked(settings.value("startup_check_companion", true).toBool()); ui->startupCheck_companion9x->setChecked(g.autoCheckApp());
ui->startupCheck_fw->setChecked(settings.value("startup_check_fw", true).toBool()); ui->startupCheck_fw->setChecked(g.autoCheckFw());
ui->wizardEnable_ChkB->setChecked(settings.value("wizardEnable", true).toBool()); ui->wizardEnable_ChkB->setChecked(g.enableWizard());
ui->showSplash->setChecked(settings.value("show_splash", true).toBool()); ui->showSplash->setChecked(g.showSplash());
ui->historySize->setValue(settings.value("history_size", 10).toInt()); ui->historySize->setValue(g.historySize());
ui->backLightColor->setCurrentIndex(settings.value("backLight", 0).toInt()); ui->backLightColor->setCurrentIndex(g.backLight());
ui->simuSW->setChecked(settings.value("simuSW", false).toBool()); ui->simuSW->setChecked(g.simuSW());
ui->libraryPath->setText(g.libDir());
ui->ge_lineedit->setText(g.gePath());
Path=settings.value("libraryPath", "").toString(); if (!g.backupDir().isEmpty()) {
if (QDir(Path).exists()) { if (QDir(g.backupDir()).exists()) {
ui->libraryPath->setText(Path); ui->backupPath->setText(g.backupDir());
}
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);
ui->backupEnable->setEnabled(true); ui->backupEnable->setEnabled(true);
ui->backupEnable->setChecked(settings.value("backupEnable", true).toBool()); ui->backupEnable->setChecked(g.enableBackup());
} else { } else {
ui->backupEnable->setDisabled(true); ui->backupEnable->setDisabled(true);
} }
} else { } else {
ui->backupEnable->setDisabled(true); ui->backupEnable->setDisabled(true);
} }
ui->splashincludeCB->setCurrentIndex(settings.value("embedded_splashes", 0).toInt()); ui->splashincludeCB->setCurrentIndex(g.embedSplashes());
#ifdef JOYSTICKS #ifdef JOYSTICKS
ui->joystickChkB->setChecked(settings.value("js_support", false).toBool()); ui->joystickChkB->setChecked(g.jsSupport());
if (ui->joystickChkB->isChecked()) { if (ui->joystickChkB->isChecked()) {
QStringList joystickNames; QStringList joystickNames;
joystickNames << tr("No joysticks found"); joystickNames << tr("No joysticks found");
@ -147,7 +134,7 @@ void appPreferencesDialog::initSettings()
} }
ui->joystickCB->clear(); ui->joystickCB->clear();
ui->joystickCB->insertItems(0, joystickNames); ui->joystickCB->insertItems(0, joystickNames);
ui->joystickCB->setCurrentIndex(settings.value("js_ctrl", 0).toInt()); ui->joystickCB->setCurrentIndex(g.jsCtrl());
} }
else { else {
ui->joystickCB->clear(); ui->joystickCB->clear();
@ -156,58 +143,46 @@ void appPreferencesDialog::initSettings()
} }
#endif #endif
// Profile Tab Inits // Profile Tab Inits
ui->channelorderCB->setCurrentIndex(settings.value("default_channel_order", 0).toInt()); ui->channelorderCB->setCurrentIndex(g.profile[g.id()].channelOrder());
ui->stickmodeCB->setCurrentIndex(settings.value("default_mode", 1).toInt()); ui->stickmodeCB->setCurrentIndex(g.profile[g.id()].defaultMode());
ui->renameFirmware->setChecked(settings.value("rename_firmware_files", false).toBool()); ui->renameFirmware->setChecked(g.profile[g.id()].renameFwFiles());
Path=settings.value("sdPath", "").toString(); ui->sdPath->setText(g.profile[g.id()].sdPath());
if (QDir(Path).exists()) { ui->profileIndexLE->setText(QString("%1").arg(g.id()));
ui->sdPath->setText(Path); ui->profileNameLE->setText(g.profile[g.id()].name());
} ui->firmwareLE->setText(g.profile[g.id()].firmware());
ui->profileIndexLE->setText(settings.value("profileId", "").toString()); ui->SplashFileName->setText(g.profile[g.id()].splashFile());
ui->profileNameLE->setText(settings.value("Name", "").toString());
QString fileName=settings.value("SplashFileName","").toString(); displayImage( g.profile[g.id()].splashFile() );
if (!fileName.isEmpty()) {
QFile file(fileName);
if (file.exists()){
ui->SplashFileName->setText(fileName);
displayImage( fileName );
}
}
ui->firmwareLE->setText(settings.value("firmware","").toString());
} }
void appPreferencesDialog::on_libraryPathButton_clicked() void appPreferencesDialog::on_libraryPathButton_clicked()
{ {
QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), g.libDir());
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your library folder"), settings.value("libraryPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("libraryPath", fileName); g.libDir(fileName);
ui->libraryPath->setText(fileName); ui->libraryPath->setText(fileName);
} }
} }
void appPreferencesDialog::on_snapshotClipboardCKB_clicked() void appPreferencesDialog::on_snapshotClipboardCKB_clicked()
{ {
QSettings settings;
if (ui->snapshotClipboardCKB->isChecked()) { if (ui->snapshotClipboardCKB->isChecked()) {
ui->snapshotPath->setDisabled(true); ui->snapshotPath->setDisabled(true);
ui->snapshotPathButton->setDisabled(true); ui->snapshotPathButton->setDisabled(true);
settings.setValue("snapshot_to_clipboard", true); g.snapToClpbrd(true);
} else { } else {
ui->snapshotPath->setEnabled(true); ui->snapshotPath->setEnabled(true);
ui->snapshotPath->setReadOnly(true); ui->snapshotPath->setReadOnly(true);
ui->snapshotPathButton->setEnabled(true); ui->snapshotPathButton->setEnabled(true);
settings.setValue("snapshot_to_clipboard", false); g.snapToClpbrd(false);
} }
} }
void appPreferencesDialog::on_backupPathButton_clicked() void appPreferencesDialog::on_backupPathButton_clicked()
{ {
QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), g.backupDir());
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), settings.value("backupPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("backupPath", fileName); g.backupDir(fileName);
ui->backupPath->setText(fileName); ui->backupPath->setText(fileName);
} }
ui->backupEnable->setEnabled(true); ui->backupEnable->setEnabled(true);
@ -215,7 +190,6 @@ void appPreferencesDialog::on_backupPathButton_clicked()
void appPreferencesDialog::on_ge_pathButton_clicked() void appPreferencesDialog::on_ge_pathButton_clicked()
{ {
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text()); QString fileName = QFileDialog::getOpenFileName(this, tr("Select Google Earth executable"),ui->ge_lineedit->text());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->ge_lineedit->setText(fileName); ui->ge_lineedit->setText(fileName);
@ -259,8 +233,7 @@ void appPreferencesDialog::on_joystickcalButton_clicked() {
void appPreferencesDialog::on_sdPathButton_clicked() void appPreferencesDialog::on_sdPathButton_clicked()
{ {
QSettings settings; QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), g.profile[g.id()].sdPath());
QString fileName = QFileDialog::getExistingDirectory(this,tr("Select the folder replicating your SD structure"), settings.value("sdPath").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
ui->sdPath->setText(fileName); ui->sdPath->setText(fileName);
} }
@ -268,95 +241,45 @@ void appPreferencesDialog::on_sdPathButton_clicked()
void appPreferencesDialog::saveProfile() 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(); g.profile[g.id()].name( ui->profileNameLE->text() );
QString name=ui->profileNameLE->text(); g.profile[g.id()].channelOrder( ui->channelorderCB->currentIndex());
if (name.isEmpty()) { g.profile[g.id()].defaultMode( ui->stickmodeCB->currentIndex());
name = profile; g.profile[g.id()].burnFirmware( ui->burnFirmware->isChecked());
ui->profileNameLE->setText(name); g.profile[g.id()].renameFwFiles( ui->renameFirmware->isChecked());
} g.profile[g.id()].sdPath( ui->sdPath->text());
settings.beginGroup("Profiles"); g.profile[g.id()].splashFile( ui->SplashFileName->text());
settings.beginGroup(profile); g.profile[g.id()].firmware( ui->firmwareLE->text());
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" );
} }
void appPreferencesDialog::on_removeProfileButton_clicked() void appPreferencesDialog::on_removeProfileButton_clicked()
{ {
QSettings settings; if ( g.id() == 0 )
QString profileId = settings.value("profileId").toString();
if ( profileId == "1" )
QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed.")); QMessageBox::information(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
else else
{ {
QString profile=QString("profile") + profileId; g.profile[g.id()].remove();
settings.beginGroup("Profiles"); g.id( 0 );
settings.remove(profile);
settings.endGroup();
settings.setValue("profileId", "1");
loadProfile();
initSettings(); initSettings();
} }
} }
bool appPreferencesDialog::displayImage( QString fileName ) bool appPreferencesDialog::displayImage( QString fileName )
{ {
QSettings settings; // Start by clearing the pixmap
ui->imageLabel->setPixmap(QPixmap());
QImage image(fileName); QImage image(fileName);
if (image.isNull()) if (image.isNull())
return false; return false;
// This code below just figures out if the width of the latest firmware is 128 or 212. It works , but... // Use the firmware name to determine splash width
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;
int width = SPLASH_WIDTH; int width = SPLASH_WIDTH;
FlashInterface flash(filePath1); if (g.profile[g.id()].firmware().contains("taranis"))
if (flash.hasSplash()) width = SPLASHX9D_WIDTH;
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!
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT))); ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT)));
if (width==SPLASHX9D_WIDTH) { if (width==SPLASHX9D_WIDTH) {
@ -390,14 +313,13 @@ void appPreferencesDialog::on_SplashSelect_clicked()
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, 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 (!fileName.isEmpty()){
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); g.imagesDir(QFileInfo(fileName).dir().absolutePath());
if (displayImage(fileName)) displayImage(fileName);
ui->SplashFileName->setText(fileName); ui->SplashFileName->setText(fileName);
} }
} }

View file

@ -26,7 +26,7 @@ private:
bool displayImage( QString fileName ); bool displayImage( QString fileName );
void saveProfile(); void saveProfile();
void loadProfileString(QString profile, QString label); void loadProfileString(QString profile, QString label);
void loadProfile(); void loadFromProfile();
private slots: private slots:
void writeValues(); void writeValues();

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>685</width> <width>685</width>
<height>462</height> <height>446</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -839,16 +839,6 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QLineEdit" name="profileNameLE">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="9" column="1" colspan="6"> <item row="9" column="1" colspan="6">
<widget class="Line" name="line_6"> <widget class="Line" name="line_6">
<property name="orientation"> <property name="orientation">
@ -872,7 +862,35 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Firmware</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="firmwareLE">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="6">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Select Image</string>
</property>
</widget>
</item>
<item row="7" column="6">
<widget class="QPushButton" name="clearImageButton">
<property name="text">
<string>Clear Image</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLineEdit" name="profileIndexLE"> <widget class="QLineEdit" name="profileIndexLE">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -885,17 +903,13 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="1">
<widget class="QLabel" name="label"> <widget class="QLineEdit" name="profileNameLE">
<property name="text"> <property name="minimumSize">
<string>Firmware</string> <size>
</property> <width>0</width>
</widget> <height>0</height>
</item> </size>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="firmwareLE">
<property name="enabled">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -933,20 +947,6 @@ This is used by the templated to determine which channel goes to what number out
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="6">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Select Image</string>
</property>
</widget>
</item>
<item row="7" column="6">
<widget class="QPushButton" name="clearImageButton">
<property name="text">
<string>Clear Image</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

View file

@ -3,6 +3,7 @@
#include "avroutputdialog.h" #include "avroutputdialog.h"
#include "eeprominterface.h" #include "eeprominterface.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QtGui> #include <QtGui>
#if !defined WIN32 && defined __GNUC__ #if !defined WIN32 && defined __GNUC__
@ -83,33 +84,42 @@ burnConfigDialog::~burnConfigDialog()
void burnConfigDialog::getSettings() void burnConfigDialog::getSettings()
{ {
QSettings settings; avrLoc = g.avrdudeLocation();
sambaLoc = g.sambaLocation();
dfuLoc = g.dfuLocation();
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
avrLoc = settings.value("avrdude_location", QFileInfo("avrdude.exe").absoluteFilePath()).toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", QFileInfo("sam-ba.exe").absoluteFilePath()).toString(); avrLoc = QFileInfo("avrdude.exe").absoluteFilePath();
dfuLoc = settings.value("dfu_location", QFileInfo("dfu-util.exe").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = QFileInfo("sam-ba.exe").absoluteFilePath();
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("dfu-util.exe").absoluteFilePath();
#elif defined __APPLE__ #elif defined __APPLE__
avrLoc = settings.value("avrdude_location", "/usr/local/bin/avrdude").toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", "/usr/local/bin/sam-ba").toString(); avrLoc = "/usr/local/bin/avrdude";
dfuLoc = settings.value("dfu_location", QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = "/usr/local/bin/sam-ba";
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("/opt/local/bin/dfu-util").absoluteFilePath();
#else #else
avrLoc = settings.value("avrdude_location", "/usr/bin/avrdude").toString(); if ( avrLoc.isEmpty())
sambaLoc = settings.value("samba_location", "/usr/bin/sam-ba").toString(); avrLoc = "/usr/bin/avrdude";
dfuLoc = settings.value("dfu_location", QFileInfo("/usr/bin/dfu-util").absoluteFilePath()).toString(); if ( sambaLoc.isEmpty())
sambaLoc = "/usr/bin/sam-ba";
if ( dfuLoc.isEmpty())
dfuLoc = QFileInfo("/usr/bin/dfu-util").absoluteFilePath();
#endif #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(); dfuArgs = g.dfuArguments().split(" ", QString::SkipEmptyParts);
armMCU = settings.value("arm_mcu", QString("at91sam3s4-9x")).toString(); 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->avrdude_location->setText(getAVRDUDE());
ui->avrArgs->setText(getAVRArgs().join(" ")); ui->avrArgs->setText(getAVRArgs().join(" "));
@ -137,17 +147,16 @@ void burnConfigDialog::getSettings()
void burnConfigDialog::putSettings() void burnConfigDialog::putSettings()
{ {
QSettings settings; g.avrdudeLocation( avrLoc );
settings.setValue("avrdude_location", avrLoc); g.programmer( avrProgrammer);
settings.setValue("programmer", avrProgrammer); g.mcu( avrMCU );
settings.setValue("mcu", avrMCU); g.avrPort( avrPort );
settings.setValue("avr_port", avrPort); g.avrArguments( avrArgs.join(" ") );
settings.setValue("avr_arguments", avrArgs.join(" ")); g.sambaLocation( sambaLoc );
settings.setValue("samba_location", sambaLoc); g.sambaPort( sambaPort );
settings.setValue("samba_port", sambaPort); g.armMcu( armMCU );
settings.setValue("arm_mcu", armMCU); g.dfuLocation( dfuLoc );
settings.setValue("dfu_location", dfuLoc); g.dfuArguments( dfuArgs.join(" ") );
settings.setValue("dfu_arguments", dfuArgs.join(" "));
} }
void burnConfigDialog::populateProgrammers() void burnConfigDialog::populateProgrammers()

View file

@ -7,6 +7,7 @@
#include "splashlibrary.h" #include "splashlibrary.h"
#include "flashinterface.h" #include "flashinterface.h"
#include "hexinterface.h" #include "hexinterface.h"
#include "appdata.h"
burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName): burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName):
QDialog(parent), QDialog(parent),
@ -58,15 +59,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
else { else {
setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName)); setWindowTitle(tr("Write Models and Settings in %1 to TX").arg(DocName));
} }
QSettings settings; ui->profile_label->setText(tr("Current profile")+QString(": ")+g.profile[g.id()].name());
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);
} }
if (!hexfileName->isEmpty()) { if (!hexfileName->isEmpty()) {
ui->FWFileName->setText(*hexfileName); ui->FWFileName->setText(*hexfileName);
@ -76,20 +69,13 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
else { else {
burnraw=false; burnraw=false;
if (checkeEprom(*hexfileName)) { if (checkeEprom(*hexfileName)) {
QSettings settings; QString Name = g.profile[g.id()].name();
int profileid=settings.value("profileId", 1).toInt(); QString calib = g.profile[g.id()].stickPotCalib();
settings.beginGroup("Profiles"); QString trainercalib = g.profile[g.id()].trainerCalib();
QString profile=QString("profile%1").arg(profileid); QString DisplaySet = g.profile[g.id()].display();
settings.beginGroup(profile); QString BeeperSet = g.profile[g.id()].beeper();
QString Name=settings.value("Name","").toString(); QString HapticSet = g.profile[g.id()].haptic();
QString calib=settings.value("StickPotCalib","").toString(); QString SpeakerSet = g.profile[g.id()].speaker();
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();
if (!Name.isEmpty()) { if (!Name.isEmpty()) {
ui->profile_label->show(); ui->profile_label->show();
ui->patchcalib_CB->show(); ui->patchcalib_CB->show();
@ -119,9 +105,8 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexfileName->clear(); hexfileName->clear();
} }
else if (Type==2) { else if (Type==2) {
QSettings settings;
QString FileName; QString FileName;
FileName = settings.value("lastFw").toString(); FileName = g.lastFw();
QFile file(FileName); QFile file(FileName);
if (file.exists()) { if (file.exists()) {
checkFw(FileName); checkFw(FileName);
@ -138,7 +123,7 @@ burnDialog::~burnDialog()
void burnDialog::on_FlashLoadButton_clicked() void burnDialog::on_FlashLoadButton_clicked()
{ {
QString fileName; QString fileName;
QSettings settings;
ui->ImageLoadButton->setDisabled(true); ui->ImageLoadButton->setDisabled(true);
ui->libraryButton->setDisabled(true); ui->libraryButton->setDisabled(true);
ui->InvertColorButton->setDisabled(true); ui->InvertColorButton->setDisabled(true);
@ -155,11 +140,11 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->EEbackupCB->hide(); ui->EEbackupCB->hide();
QTimer::singleShot(0, this, SLOT(shrink())); QTimer::singleShot(0, this, SLOT(shrink()));
if (hexType==2) { 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); checkFw(fileName);
} }
else { 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 (checkeEprom(fileName)) {
if (burnraw==false) { if (burnraw==false) {
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
@ -191,7 +176,6 @@ void burnDialog::checkFw(QString fileName)
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
return; return;
} }
QSettings settings;
if (!IS_TARANIS(GetEepromInterface()->getBoard())) { if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->show(); ui->EEbackupCB->show();
} }
@ -216,8 +200,8 @@ void burnDialog::checkFw(QString fileName)
ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight()); ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
ui->FwImage->show(); ui->FwImage->show();
ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash())); ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash()));
QString ImageStr = settings.value("SplashImage", "").toString(); QString ImageStr = g.profile[g.id()].splashFile();
bool PatchFwCB = settings.value("patchImage", false).toBool(); bool PatchFwCB = g.profile[g.id()].patchImage();
if (!ImageStr.isEmpty()) { if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr); QImage Image = qstring2image(ImageStr);
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat()))); ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat())));
@ -260,7 +244,7 @@ void burnDialog::checkFw(QString fileName)
ui->BurnFlashButton->setEnabled(true); ui->BurnFlashButton->setEnabled(true);
} }
QTimer::singleShot(0, this, SLOT(shrink())); QTimer::singleShot(0, this, SLOT(shrink()));
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); g.flashDir( QFileInfo(fileName).dir().absolutePath() );
} }
bool burnDialog::checkeEprom(QString fileName) bool burnDialog::checkeEprom(QString fileName)
@ -360,12 +344,11 @@ void burnDialog::on_ImageLoadButton_clicked()
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, 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 (!fileName.isEmpty()) {
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath()); g.imagesDir( QFileInfo(fileName).dir().absolutePath() );
QImage image(fileName); QImage image(fileName);
if (image.isNull()) { if (image.isNull()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
@ -442,11 +425,10 @@ void burnDialog::on_BurnFlashButton_clicked()
if (hexType==2) { if (hexType==2) {
QString fileName=ui->FWFileName->text(); QString fileName=ui->FWFileName->text();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QSettings settings; g.flashDir( QFileInfo(fileName).dir().absolutePath() );
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); g.lastFw( fileName );
settings.setValue("lastFw", fileName);
if (ui->PatchFWCB->isChecked()) { 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()); QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height());
if (!image.isNull()) { if (!image.isNull()) {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
@ -469,7 +451,7 @@ void burnDialog::on_BurnFlashButton_clicked()
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found")); QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
} }
} else { } else {
settings.setValue("patchImage", false); g.profile[g.id()].patchImage( false );
hexfileName->clear(); hexfileName->clear();
hexfileName->append(fileName); hexfileName->append(fileName);
} }
@ -479,26 +461,19 @@ void burnDialog::on_BurnFlashButton_clicked()
} }
} }
if (hexType==1) { if (hexType==1) {
QSettings settings; QString calib = g.profile[g.id()].stickPotCalib();
int profileid=settings.value("profileId", 1).toInt(); QString trainercalib = g.profile[g.id()].trainerCalib();
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();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", radioData.generalSettings.vBatCalib).toInt(); int8_t vBatCalib=(int8_t) g.profile[g.id()].vBatCalib();
int8_t currentCalib=(int8_t)settings.value("currentCalib", radioData.generalSettings.currentCalib).toInt(); int8_t currentCalib=(int8_t) g.profile[g.id()].currentCalib();
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", radioData.generalSettings.PPM_Multiplier).toInt(); int8_t PPM_Multiplier=(int8_t) g.profile[g.id()].ppmMultiplier();
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", radioData.generalSettings.stickMode).toUInt(); uint8_t GSStickMode=(uint8_t) g.profile[g.id()].gsStickMode();
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",radioData.generalSettings.vBatWarn).toUInt(); uint8_t vBatWarn=(uint8_t) g.profile[g.id()].vBatWarn();
QString DisplaySet=settings.value("Display","").toString(); QString DisplaySet= g.profile[g.id()].display();
QString BeeperSet=settings.value("Beeper","").toString(); QString BeeperSet= g.profile[g.id()].beeper();
QString HapticSet=settings.value("Haptic","").toString(); QString HapticSet= g.profile[g.id()].haptic();
QString SpeakerSet=settings.value("Speaker","").toString(); QString SpeakerSet= g.profile[g.id()].speaker();
settings.endGroup();
settings.endGroup();
bool patch=false; bool patch=false;
if (ui->patchcalib_CB->isChecked()) { if (ui->patchcalib_CB->isChecked()) {
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
@ -656,8 +631,7 @@ void burnDialog::on_PreferredImageCB_toggled(bool checked)
{ {
QString tmpFileName; QString tmpFileName;
if (checked) { if (checked) {
QSettings settings; QString ImageStr = g.profile[g.id()].splashFile();
QString ImageStr = settings.value("SplashImage", "").toString();
if (!ImageStr.isEmpty()) { if (!ImageStr.isEmpty()) {
QImage Image = qstring2image(ImageStr); QImage Image = qstring2image(ImageStr);
if (ui->imageLabel->width()!=128) { if (ui->imageLabel->width()!=128) {

View file

@ -45,12 +45,12 @@
#include <QString> #include <QString>
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QSettings>
#include <QSplashScreen> #include <QSplashScreen>
#include <QThread> #include <QThread>
#include <iostream> #include <iostream>
#include "mainwindow.h" #include "mainwindow.h"
#include "eeprominterface.h" #include "eeprominterface.h"
#include "appdata.h"
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
#include <windows.h> #include <windows.h>
@ -86,46 +86,27 @@ int main(int argc, char *argv[])
app.setStyle(new MyProxyStyle); app.setStyle(new MyProxyStyle);
#endif #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; QTranslator companionTranslator;
companionTranslator.load(":/companion_" + locale); companionTranslator.load(":/companion_" + g.locale());
QTranslator qtTranslator; 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(&companionTranslator);
app.installTranslator(&qtTranslator); app.installTranslator(&qtTranslator);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); if (g.profile[g.id()].firmware().isEmpty())
firmware_id.replace("open9x", "opentx"); g.profile[g.id()].firmware(default_firmware_variant.id);
firmware_id.replace("x9da", "taranis");
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); QSplashScreen *splash = new QSplashScreen(pixmap);
RegisterFirmwares(); RegisterFirmwares();
settings.setValue("firmware", firmware_id); current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware());
current_firmware_variant = GetFirmwareVariant(firmware_id);
MainWindow *mainWin = new MainWindow(); MainWindow *mainWin = new MainWindow();
if (showSplash) { if (g.showSplash()) {
splash->show(); splash->show();
QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close())); QTimer::singleShot(1000*SPLASH_TIME, splash, SLOT(close()));
QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show())); QTimer::singleShot(1000*SPLASH_TIME, mainWin, SLOT(show()));

View file

@ -981,177 +981,177 @@
<file>themes/monowhite/48/contributors.png</file> <file>themes/monowhite/48/contributors.png</file>
<file>themes/monowhite/48/stop.png</file> <file>themes/monowhite/48/stop.png</file>
<file>themes/monowhite/48/write_eeprom.png</file> <file>themes/monowhite/48/write_eeprom.png</file>
<file>themes/new/16/paintbrush.png</file> <file>themes/yerico/16/paintbrush.png</file>
<file>themes/new/16/open.png</file> <file>themes/yerico/16/open.png</file>
<file>themes/new/16/edit.png</file> <file>themes/yerico/16/edit.png</file>
<file>themes/new/16/information.png</file> <file>themes/yerico/16/information.png</file>
<file>themes/new/16/configure.png</file> <file>themes/yerico/16/configure.png</file>
<file>themes/new/16/list.png</file> <file>themes/yerico/16/list.png</file>
<file>themes/new/16/wizard.png</file> <file>themes/yerico/16/wizard.png</file>
<file>themes/new/16/logs.png</file> <file>themes/yerico/16/logs.png</file>
<file>themes/new/16/new.png</file> <file>themes/yerico/16/new.png</file>
<file>themes/new/16/save.png</file> <file>themes/yerico/16/save.png</file>
<file>themes/new/16/recentdocument.png</file> <file>themes/yerico/16/recentdocument.png</file>
<file>themes/new/16/simulate.png</file> <file>themes/yerico/16/simulate.png</file>
<file>themes/new/16/changelog.png</file> <file>themes/yerico/16/changelog.png</file>
<file>themes/new/16/copy.png</file> <file>themes/yerico/16/copy.png</file>
<file>themes/new/16/write_flash.png</file> <file>themes/yerico/16/write_flash.png</file>
<file>themes/new/16/read_eeprom_file.png</file> <file>themes/yerico/16/read_eeprom_file.png</file>
<file>themes/new/16/clear.png</file> <file>themes/yerico/16/clear.png</file>
<file>themes/new/16/play.png</file> <file>themes/yerico/16/play.png</file>
<file>themes/new/16/fuses.png</file> <file>themes/yerico/16/fuses.png</file>
<file>themes/new/16/arrow-right.png</file> <file>themes/yerico/16/arrow-right.png</file>
<file>themes/new/16/exit.png</file> <file>themes/yerico/16/exit.png</file>
<file>themes/new/16/moveup.png</file> <file>themes/yerico/16/moveup.png</file>
<file>themes/new/16/read_eeprom.png</file> <file>themes/yerico/16/read_eeprom.png</file>
<file>themes/new/16/cut.png</file> <file>themes/yerico/16/cut.png</file>
<file>themes/new/16/arrow-left.png</file> <file>themes/yerico/16/arrow-left.png</file>
<file>themes/new/16/write_eeprom_file.png</file> <file>themes/yerico/16/write_eeprom_file.png</file>
<file>themes/new/16/library.png</file> <file>themes/yerico/16/library.png</file>
<file>themes/new/16/profiles.png</file> <file>themes/yerico/16/profiles.png</file>
<file>themes/new/16/paste.png</file> <file>themes/yerico/16/paste.png</file>
<file>themes/new/16/print.png</file> <file>themes/yerico/16/print.png</file>
<file>themes/new/16/compare.png</file> <file>themes/yerico/16/compare.png</file>
<file>themes/new/16/saveas.png</file> <file>themes/yerico/16/saveas.png</file>
<file>themes/new/16/apppreferences.png</file> <file>themes/yerico/16/apppreferences.png</file>
<file>themes/new/16/fwpreferences.png</file> <file>themes/yerico/16/fwpreferences.png</file>
<file>themes/new/16/movedown.png</file> <file>themes/yerico/16/movedown.png</file>
<file>themes/new/16/currentmodel.png</file> <file>themes/yerico/16/currentmodel.png</file>
<file>themes/new/16/read_flash.png</file> <file>themes/yerico/16/read_flash.png</file>
<file>themes/new/16/duplicate.png</file> <file>themes/yerico/16/duplicate.png</file>
<file>themes/new/16/add.png</file> <file>themes/yerico/16/add.png</file>
<file>themes/new/16/update.png</file> <file>themes/yerico/16/update.png</file>
<file>themes/new/16/contributors.png</file> <file>themes/yerico/16/contributors.png</file>
<file>themes/new/16/stop.png</file> <file>themes/yerico/16/stop.png</file>
<file>themes/new/16/write_eeprom.png</file> <file>themes/yerico/16/write_eeprom.png</file>
<file>themes/new/24/paintbrush.png</file> <file>themes/yerico/24/paintbrush.png</file>
<file>themes/new/24/open.png</file> <file>themes/yerico/24/open.png</file>
<file>themes/new/24/edit.png</file> <file>themes/yerico/24/edit.png</file>
<file>themes/new/24/information.png</file> <file>themes/yerico/24/information.png</file>
<file>themes/new/24/configure.png</file> <file>themes/yerico/24/configure.png</file>
<file>themes/new/24/list.png</file> <file>themes/yerico/24/list.png</file>
<file>themes/new/24/wizard.png</file> <file>themes/yerico/24/wizard.png</file>
<file>themes/new/24/logs.png</file> <file>themes/yerico/24/logs.png</file>
<file>themes/new/24/new.png</file> <file>themes/yerico/24/new.png</file>
<file>themes/new/24/save.png</file> <file>themes/yerico/24/save.png</file>
<file>themes/new/24/recentdocument.png</file> <file>themes/yerico/24/recentdocument.png</file>
<file>themes/new/24/simulate.png</file> <file>themes/yerico/24/simulate.png</file>
<file>themes/new/24/changelog.png</file> <file>themes/yerico/24/changelog.png</file>
<file>themes/new/24/copy.png</file> <file>themes/yerico/24/copy.png</file>
<file>themes/new/24/write_flash.png</file> <file>themes/yerico/24/write_flash.png</file>
<file>themes/new/24/read_eeprom_file.png</file> <file>themes/yerico/24/read_eeprom_file.png</file>
<file>themes/new/24/clear.png</file> <file>themes/yerico/24/clear.png</file>
<file>themes/new/24/play.png</file> <file>themes/yerico/24/play.png</file>
<file>themes/new/24/fuses.png</file> <file>themes/yerico/24/fuses.png</file>
<file>themes/new/24/arrow-right.png</file> <file>themes/yerico/24/arrow-right.png</file>
<file>themes/new/24/exit.png</file> <file>themes/yerico/24/exit.png</file>
<file>themes/new/24/moveup.png</file> <file>themes/yerico/24/moveup.png</file>
<file>themes/new/24/read_eeprom.png</file> <file>themes/yerico/24/read_eeprom.png</file>
<file>themes/new/24/cut.png</file> <file>themes/yerico/24/cut.png</file>
<file>themes/new/24/arrow-left.png</file> <file>themes/yerico/24/arrow-left.png</file>
<file>themes/new/24/write_eeprom_file.png</file> <file>themes/yerico/24/write_eeprom_file.png</file>
<file>themes/new/24/library.png</file> <file>themes/yerico/24/library.png</file>
<file>themes/new/24/profiles.png</file> <file>themes/yerico/24/profiles.png</file>
<file>themes/new/24/paste.png</file> <file>themes/yerico/24/paste.png</file>
<file>themes/new/24/print.png</file> <file>themes/yerico/24/print.png</file>
<file>themes/new/24/compare.png</file> <file>themes/yerico/24/compare.png</file>
<file>themes/new/24/saveas.png</file> <file>themes/yerico/24/saveas.png</file>
<file>themes/new/24/apppreferences.png</file> <file>themes/yerico/24/apppreferences.png</file>
<file>themes/new/24/fwpreferences.png</file> <file>themes/yerico/24/fwpreferences.png</file>
<file>themes/new/24/movedown.png</file> <file>themes/yerico/24/movedown.png</file>
<file>themes/new/24/currentmodel.png</file> <file>themes/yerico/24/currentmodel.png</file>
<file>themes/new/24/read_flash.png</file> <file>themes/yerico/24/read_flash.png</file>
<file>themes/new/24/duplicate.png</file> <file>themes/yerico/24/duplicate.png</file>
<file>themes/new/24/add.png</file> <file>themes/yerico/24/add.png</file>
<file>themes/new/24/update.png</file> <file>themes/yerico/24/update.png</file>
<file>themes/new/24/contributors.png</file> <file>themes/yerico/24/contributors.png</file>
<file>themes/new/24/stop.png</file> <file>themes/yerico/24/stop.png</file>
<file>themes/new/24/write_eeprom.png</file> <file>themes/yerico/24/write_eeprom.png</file>
<file>themes/new/32/paintbrush.png</file> <file>themes/yerico/32/paintbrush.png</file>
<file>themes/new/32/open.png</file> <file>themes/yerico/32/open.png</file>
<file>themes/new/32/edit.png</file> <file>themes/yerico/32/edit.png</file>
<file>themes/new/32/information.png</file> <file>themes/yerico/32/information.png</file>
<file>themes/new/32/configure.png</file> <file>themes/yerico/32/configure.png</file>
<file>themes/new/32/list.png</file> <file>themes/yerico/32/list.png</file>
<file>themes/new/32/wizard.png</file> <file>themes/yerico/32/wizard.png</file>
<file>themes/new/32/logs.png</file> <file>themes/yerico/32/logs.png</file>
<file>themes/new/32/new.png</file> <file>themes/yerico/32/new.png</file>
<file>themes/new/32/save.png</file> <file>themes/yerico/32/save.png</file>
<file>themes/new/32/recentdocument.png</file> <file>themes/yerico/32/recentdocument.png</file>
<file>themes/new/32/simulate.png</file> <file>themes/yerico/32/simulate.png</file>
<file>themes/new/32/changelog.png</file> <file>themes/yerico/32/changelog.png</file>
<file>themes/new/32/copy.png</file> <file>themes/yerico/32/copy.png</file>
<file>themes/new/32/write_flash.png</file> <file>themes/yerico/32/write_flash.png</file>
<file>themes/new/32/read_eeprom_file.png</file> <file>themes/yerico/32/read_eeprom_file.png</file>
<file>themes/new/32/clear.png</file> <file>themes/yerico/32/clear.png</file>
<file>themes/new/32/play.png</file> <file>themes/yerico/32/play.png</file>
<file>themes/new/32/fuses.png</file> <file>themes/yerico/32/fuses.png</file>
<file>themes/new/32/arrow-right.png</file> <file>themes/yerico/32/arrow-right.png</file>
<file>themes/new/32/exit.png</file> <file>themes/yerico/32/exit.png</file>
<file>themes/new/32/moveup.png</file> <file>themes/yerico/32/moveup.png</file>
<file>themes/new/32/read_eeprom.png</file> <file>themes/yerico/32/read_eeprom.png</file>
<file>themes/new/32/cut.png</file> <file>themes/yerico/32/cut.png</file>
<file>themes/new/32/arrow-left.png</file> <file>themes/yerico/32/arrow-left.png</file>
<file>themes/new/32/write_eeprom_file.png</file> <file>themes/yerico/32/write_eeprom_file.png</file>
<file>themes/new/32/library.png</file> <file>themes/yerico/32/library.png</file>
<file>themes/new/32/profiles.png</file> <file>themes/yerico/32/profiles.png</file>
<file>themes/new/32/paste.png</file> <file>themes/yerico/32/paste.png</file>
<file>themes/new/32/print.png</file> <file>themes/yerico/32/print.png</file>
<file>themes/new/32/compare.png</file> <file>themes/yerico/32/compare.png</file>
<file>themes/new/32/saveas.png</file> <file>themes/yerico/32/saveas.png</file>
<file>themes/new/32/apppreferences.png</file> <file>themes/yerico/32/apppreferences.png</file>
<file>themes/new/32/fwpreferences.png</file> <file>themes/yerico/32/fwpreferences.png</file>
<file>themes/new/32/movedown.png</file> <file>themes/yerico/32/movedown.png</file>
<file>themes/new/32/currentmodel.png</file> <file>themes/yerico/32/currentmodel.png</file>
<file>themes/new/32/read_flash.png</file> <file>themes/yerico/32/read_flash.png</file>
<file>themes/new/32/duplicate.png</file> <file>themes/yerico/32/duplicate.png</file>
<file>themes/new/32/add.png</file> <file>themes/yerico/32/add.png</file>
<file>themes/new/32/update.png</file> <file>themes/yerico/32/update.png</file>
<file>themes/new/32/contributors.png</file> <file>themes/yerico/32/contributors.png</file>
<file>themes/new/32/stop.png</file> <file>themes/yerico/32/stop.png</file>
<file>themes/new/32/write_eeprom.png</file> <file>themes/yerico/32/write_eeprom.png</file>
<file>themes/new/48/paintbrush.png</file> <file>themes/yerico/48/paintbrush.png</file>
<file>themes/new/48/open.png</file> <file>themes/yerico/48/open.png</file>
<file>themes/new/48/edit.png</file> <file>themes/yerico/48/edit.png</file>
<file>themes/new/48/information.png</file> <file>themes/yerico/48/information.png</file>
<file>themes/new/48/configure.png</file> <file>themes/yerico/48/configure.png</file>
<file>themes/new/48/list.png</file> <file>themes/yerico/48/list.png</file>
<file>themes/new/48/wizard.png</file> <file>themes/yerico/48/wizard.png</file>
<file>themes/new/48/logs.png</file> <file>themes/yerico/48/logs.png</file>
<file>themes/new/48/new.png</file> <file>themes/yerico/48/new.png</file>
<file>themes/new/48/save.png</file> <file>themes/yerico/48/save.png</file>
<file>themes/new/48/recentdocument.png</file> <file>themes/yerico/48/recentdocument.png</file>
<file>themes/new/48/simulate.png</file> <file>themes/yerico/48/simulate.png</file>
<file>themes/new/48/changelog.png</file> <file>themes/yerico/48/changelog.png</file>
<file>themes/new/48/copy.png</file> <file>themes/yerico/48/copy.png</file>
<file>themes/new/48/write_flash.png</file> <file>themes/yerico/48/write_flash.png</file>
<file>themes/new/48/read_eeprom_file.png</file> <file>themes/yerico/48/read_eeprom_file.png</file>
<file>themes/new/48/clear.png</file> <file>themes/yerico/48/clear.png</file>
<file>themes/new/48/play.png</file> <file>themes/yerico/48/play.png</file>
<file>themes/new/48/fuses.png</file> <file>themes/yerico/48/fuses.png</file>
<file>themes/new/48/arrow-right.png</file> <file>themes/yerico/48/arrow-right.png</file>
<file>themes/new/48/exit.png</file> <file>themes/yerico/48/exit.png</file>
<file>themes/new/48/moveup.png</file> <file>themes/yerico/48/moveup.png</file>
<file>themes/new/48/read_eeprom.png</file> <file>themes/yerico/48/read_eeprom.png</file>
<file>themes/new/48/cut.png</file> <file>themes/yerico/48/cut.png</file>
<file>themes/new/48/arrow-left.png</file> <file>themes/yerico/48/arrow-left.png</file>
<file>themes/new/48/write_eeprom_file.png</file> <file>themes/yerico/48/write_eeprom_file.png</file>
<file>themes/new/48/library.png</file> <file>themes/yerico/48/library.png</file>
<file>themes/new/48/profiles.png</file> <file>themes/yerico/48/profiles.png</file>
<file>themes/new/48/paste.png</file> <file>themes/yerico/48/paste.png</file>
<file>themes/new/48/print.png</file> <file>themes/yerico/48/print.png</file>
<file>themes/new/48/compare.png</file> <file>themes/yerico/48/compare.png</file>
<file>themes/new/48/saveas.png</file> <file>themes/yerico/48/saveas.png</file>
<file>themes/new/48/apppreferences.png</file> <file>themes/yerico/48/apppreferences.png</file>
<file>themes/new/48/fwpreferences.png</file> <file>themes/yerico/48/fwpreferences.png</file>
<file>themes/new/48/movedown.png</file> <file>themes/yerico/48/movedown.png</file>
<file>themes/new/48/currentmodel.png</file> <file>themes/yerico/48/currentmodel.png</file>
<file>themes/new/48/read_flash.png</file> <file>themes/yerico/48/read_flash.png</file>
<file>themes/new/48/duplicate.png</file> <file>themes/yerico/48/duplicate.png</file>
<file>themes/new/48/add.png</file> <file>themes/yerico/48/add.png</file>
<file>themes/new/48/update.png</file> <file>themes/yerico/48/update.png</file>
<file>themes/new/48/contributors.png</file> <file>themes/yerico/48/contributors.png</file>
<file>themes/new/48/stop.png</file> <file>themes/yerico/48/stop.png</file>
<file>themes/new/48/write_eeprom.png</file> <file>themes/yerico/48/write_eeprom.png</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -29,6 +29,7 @@ compareDialog::compareDialog(QWidget *parent, GeneralSettings *gg) :
ui(new Ui::compareDialog) ui(new Ui::compareDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("compare.png"));
g_eeGeneral = gg; g_eeGeneral = gg;
eepromInterface = GetEepromInterface(); eepromInterface = GetEepromInterface();
te = ui->textEdit; te = ui->textEdit;

View file

@ -26,11 +26,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Compare Models</string>
</property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">

View file

@ -1,6 +1,7 @@
#include "contributorsdialog.h" #include "contributorsdialog.h"
#include "ui_contributorsdialog.h" #include "ui_contributorsdialog.h"
#include <QtGui> #include <QtGui>
#include "helpers.h"
contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnurl) : contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnurl) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
@ -10,6 +11,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
switch (contest) { switch (contest) {
case 0: case 0:
{ {
this->setWindowIcon(CompanionIcon("contributors.png"));
QFile file(":/DONATIONS.txt"); QFile file(":/DONATIONS.txt");
QString str; QString str;
str.append("<html><head>"); str.append("<html><head>");
@ -79,6 +81,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
case 1: case 1:
{ {
this->setWindowIcon(CompanionIcon("changelog.png"));
QFile file(":/releasenotes.txt"); QFile file(":/releasenotes.txt");
if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { if(file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
ui->textEditor->setHtml(file.readAll()); ui->textEditor->setHtml(file.readAll());
@ -91,6 +94,7 @@ contributorsDialog::contributorsDialog(QWidget *parent, int contest, QString rnu
case 2: case 2:
{ {
if (!rnurl.isEmpty()) { if (!rnurl.isEmpty()) {
this->setWindowIcon(CompanionIcon("changelog.png"));
this->setWindowTitle(tr("OpenTX Release Notes")); this->setWindowTitle(tr("OpenTX Release Notes"));
manager = new QNetworkAccessManager(this); manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));

View file

@ -13,10 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTextEdit" name="textEditor"/> <widget class="QTextEdit" name="textEditor"/>

View file

@ -2,6 +2,7 @@
#include "ui_customizesplashdialog.h" #include "ui_customizesplashdialog.h"
#include <QtGui> #include <QtGui>
#include "appdata.h"
#include "helpers.h" #include "helpers.h"
#include "burndialog.h" #include "burndialog.h"
#include "splashlibrary.h" #include "splashlibrary.h"
@ -28,9 +29,10 @@ bool Side::displayImage( QString fileName, Source pictSource )
{ {
QImage image; QImage image;
if (fileName.isEmpty()) { if (fileName.isEmpty())
return false; return false;
}
// Determine which picture format to use
if (pictSource == FW ){ if (pictSource == FW ){
FlashInterface flash(fileName); FlashInterface flash(fileName);
if (!flash.hasSplash()) if (!flash.hasSplash())
@ -43,10 +45,13 @@ bool Side::displayImage( QString fileName, Source pictSource )
image.load(fileName); image.load(fileName);
if (pictSource== PICT) if (pictSource== PICT)
*format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X; *format = image.width()>WIDTH_9X ? LCDTARANIS : LCD9X;
else if (pictSource == PROFILE)
*format = (g.profile[g.id()].firmware().contains("taranis")) ? LCDTARANIS : LCD9X;
} }
if (image.isNull()) { if (image.isNull()) {
return false; return false;
} }
// Prepare and display image
if (*format==LCDTARANIS) { if (*format==LCDTARANIS) {
image=image.convertToFormat(QImage::Format_RGB32); image=image.convertToFormat(QImage::Format_RGB32);
QRgb col; QRgb col;
@ -102,8 +107,6 @@ bool Side::refreshImage()
bool Side::saveImage() bool Side::saveImage()
{ {
QSettings settings;
if (*source == FW ) if (*source == FW )
{ {
FlashInterface flash(*saveToFileName); FlashInterface flash(*saveToFileName);
@ -112,7 +115,7 @@ bool Side::saveImage()
} }
QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight()); QImage image = imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) { if (flash.setSplash(image) && (flash.saveFlash(*saveToFileName) > 0)) {
settings.setValue("lastFlashDir", QFileInfo(*saveToFileName).dir().absolutePath()); g.flashDir( QFileInfo(*saveToFileName).dir().absolutePath() );
} }
else { else {
return false; return false;
@ -121,7 +124,7 @@ bool Side::saveImage()
else if (*source == PICT) { else if (*source == PICT) {
QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8); QImage image = imageLabel->pixmap()->toImage().scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
if (image.save(*saveToFileName)) { if (image.save(*saveToFileName)) {
settings.setValue("lastImagesDir", QFileInfo(*saveToFileName).dir().absolutePath()); g.imagesDir( QFileInfo(*saveToFileName).dir().absolutePath() );
} }
else { else {
return false; return false;
@ -143,6 +146,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
ui(new Ui::customizeSplashDialog) ui(new Ui::customizeSplashDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("paint.png"));
ui->leftLibraryButton->setIcon(CompanionIcon("library.png")); ui->leftLibraryButton->setIcon(CompanionIcon("library.png"));
ui->rightLibraryButton->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::on_rightLoadFwButton_clicked() {loadFirmware(right);}
void customizeSplashDialog::loadFirmware(Side side) void customizeSplashDialog::loadFirmware(Side side)
{ {
QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.flashDir(), FLASH_FILES_FILTER);
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, FW )) if (!side.displayImage( fileName, FW ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load embedded FW image from %1.").arg(fileName));
else 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++) { for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex]; supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
} }
QSettings settings;
QString fileName = QFileDialog::getOpenFileName(this, 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 (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PICT )) if (!side.displayImage( fileName, PICT ))
QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName)); QMessageBox::critical(this, tr("Error"), tr("Cannot load the image file %1.").arg(fileName));
else 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::on_rightLoadProfileButton_clicked() {loadProfile(right);}
void customizeSplashDialog::loadProfile(Side side) void customizeSplashDialog::loadProfile(Side side)
{ {
QSettings settings; QString fileName=g.profile[g.id()].splashFile();
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!side.displayImage( fileName, PROFILE )) if (!side.displayImage( fileName, PROFILE ))

View file

@ -9,7 +9,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1086</width> <width>1087</width>
<height>285</height> <height>285</height>
</rect> </rect>
</property> </property>
@ -22,10 +22,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Transmitter Splash Screen Editor</string> <string>Transmitter Splash Screen Editor</string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>

View file

@ -2,13 +2,14 @@
#include "ui_downloaddialog.h" #include "ui_downloaddialog.h"
#include <QMessageBox> #include <QMessageBox>
#include <QtGui> #include <QtGui>
#include "helpers.h"
downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) : downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt) :
QDialog(parent), QDialog(parent),
ui(new Ui::downloadDialog) ui(new Ui::downloadDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("fwpreferences.png"));
ui->progressBar->setValue(1); ui->progressBar->setValue(1);
ui->progressBar->setMinimum(0); ui->progressBar->setMinimum(0);
ui->progressBar->setMaximum(0); ui->progressBar->setMaximum(0);

View file

@ -13,10 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Downloading: </string> <string>Downloading: </string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">

View file

@ -6,7 +6,7 @@
#include "firmwares/gruvin9x/gruvin9xinterface.h" #include "firmwares/gruvin9x/gruvin9xinterface.h"
#include "firmwares/opentx/opentxinterface.h" #include "firmwares/opentx/opentxinterface.h"
#include "firmwares/ersky9x/ersky9xinterface.h" #include "firmwares/ersky9x/ersky9xinterface.h"
#include "qsettings.h" #include "appdata.h"
#include "helpers.h" #include "helpers.h"
QString EEPROMWarnings; 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 RawSource::getRange(bool singleprec)
{ {
RawSourceRange result; RawSourceRange result;
@ -731,34 +772,25 @@ GeneralSettings::GeneralSettings()
calibSpanNeg[i] = 0x180; calibSpanNeg[i] = 0x180;
calibSpanPos[i] = 0x180; calibSpanPos[i] = 0x180;
} }
QSettings settings; templateSetup = g.profile[g.id()].channelOrder();
templateSetup = settings.value("default_channel_order", 0).toInt(); stickMode = g.profile[g.id()].defaultMode();
stickMode = settings.value("default_mode", 1).toInt();
int profile_id = settings.value("profileId", 0).toInt(); QString t_calib=g.profile[g.id()].stickPotCalib();
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();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (t_calib.isEmpty()) { if (t_calib.isEmpty()) {
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString t_trainercalib=settings.value("TrainerCalib","").toString(); QString t_trainercalib=g.profile[g.id()].trainerCalib();
int8_t t_vBatCalib=(int8_t)settings.value("VbatCalib", vBatCalib).toInt(); int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib();
int8_t t_currentCalib=(int8_t)settings.value("currentCalib", currentCalib).toInt(); int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib();
int8_t t_PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", PPM_Multiplier).toInt(); int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier();
uint8_t t_stickMode=(uint8_t)settings.value("GSStickMode", stickMode).toUInt(); uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode();
uint8_t t_vBatWarn=(uint8_t)settings.value("vBatWarn",vBatWarn).toUInt(); uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn();
QString t_DisplaySet=settings.value("Display","").toString(); QString t_DisplaySet=g.profile[g.id()].display();
QString t_BeeperSet=settings.value("Beeper","").toString(); QString t_BeeperSet=g.profile[g.id()].beeper();
QString t_HapticSet=settings.value("Haptic","").toString(); QString t_HapticSet=g.profile[g.id()].haptic();
QString t_SpeakerSet=settings.value("Speaker","").toString(); QString t_SpeakerSet=g.profile[g.id()].speaker();
QString t_CountrySet=settings.value("countryCode","").toString(); QString t_CountrySet=g.profile[g.id()].countryCode();
settings.endGroup();
settings.endGroup();
if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) { if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) {
QString Byte; QString Byte;
@ -840,7 +872,7 @@ GeneralSettings::GeneralSettings()
} }
} }
} }
}
} }
ModelData::ModelData() ModelData::ModelData()
@ -990,15 +1022,13 @@ ModelData ModelData::removeGlobalVars()
QList<EEPROMInterface *> eepromInterfaces; QList<EEPROMInterface *> eepromInterfaces;
void RegisterEepromInterfaces() void RegisterEepromInterfaces()
{ {
QSettings settings; eepromInterfaces.push_back(new OpenTxInterface(BOARD_STOCK));
int rev4a = settings.value("rev4asupport",0).toInt(); eepromInterfaces.push_back(new OpenTxInterface(BOARD_M128));
eepromInterfaces.push_back(new Open9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new OpenTxInterface(BOARD_GRUVIN9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_M128)); eepromInterfaces.push_back(new OpenTxInterface(BOARD_SKY9X));
eepromInterfaces.push_back(new Open9xInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new OpenTxInterface(BOARD_TARANIS));
eepromInterfaces.push_back(new Open9xInterface(BOARD_SKY9X)); if (g.rev4aSupport())
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS)); eepromInterfaces.push_back(new OpenTxInterface(BOARD_TARANIS_REV4a));
if (rev4a)
eepromInterfaces.push_back(new Open9xInterface(BOARD_TARANIS_REV4a));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_STOCK));
eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X)); eepromInterfaces.push_back(new Gruvin9xInterface(BOARD_GRUVIN9X));
eepromInterfaces.push_back(new Ersky9xInterface()); eepromInterfaces.push_back(new Ersky9xInterface());
@ -1010,26 +1040,11 @@ QList<FirmwareInfo *> firmwares;
FirmwareVariant default_firmware_variant; FirmwareVariant default_firmware_variant;
FirmwareVariant current_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() 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(); 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"); default_firmware_variant = GetFirmwareVariant("opentx-9x-heli-templates-en");
current_firmware_variant = default_firmware_variant;
RegisterEepromInterfaces(); RegisterEepromInterfaces();
} }
@ -1070,7 +1085,6 @@ FirmwareVariant GetFirmwareVariant(QString id)
FirmwareVariant result; FirmwareVariant result;
foreach(FirmwareInfo * firmware, firmwares) { foreach(FirmwareInfo * firmware, firmwares) {
if (id.contains(firmware->id+"-") || (!id.contains("-") && id.contains(firmware->id))) { if (id.contains(firmware->id+"-") || (!id.contains("-") && id.contains(firmware->id))) {
result.id = id; result.id = id;
result.firmware = firmware; result.firmware = firmware;

View file

@ -950,7 +950,6 @@ enum Capability {
FlightPhases, FlightPhases,
FlightModesName, FlightModesName,
FlightPhasesHaveFades, FlightPhasesHaveFades,
SimulatorType,
Mixes, Mixes,
MixesWithoutExpo, MixesWithoutExpo,
Timers, Timers,
@ -1059,15 +1058,8 @@ enum Capability {
HasFasOffset, HasFasOffset,
HasMahPersistent, HasMahPersistent,
MultiposPots, MultiposPots,
MultiposPotsPositions MultiposPotsPositions,
}; SimulatorVariant,
enum UseContext {
DefaultContext,
TimerContext,
FlightPhaseContext,
MixerContext,
ExpoContext,
}; };
class SimulatorInterface; class SimulatorInterface;
@ -1102,7 +1094,7 @@ class EEPROMInterface
virtual int isAvailable(Protocol proto, int port=0) = 0; virtual int isAvailable(Protocol proto, int port=0) = 0;
virtual SimulatorInterface * getSimulator() = 0; virtual SimulatorInterface * getSimulator() { return NULL; }
virtual const int getEEpromSize() = 0; virtual const int getEEpromSize() = 0;
@ -1124,6 +1116,12 @@ extern QString EEPROMWarnings;
void setEEPROMString(char *dst, const char *src, int size); void setEEPROMString(char *dst, const char *src, int size);
void getEEPROMString(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) inline int applyStickMode(int stick, unsigned int mode)
{ {
if (mode == 0 || mode > 4) { if (mode == 0 || mode > 4) {

View file

@ -19,6 +19,7 @@
#include "er9xeeprom.h" #include "er9xeeprom.h"
#include "er9xsimulator.h" #include "er9xsimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -44,8 +45,7 @@ const char * Er9xInterface::getName()
const int Er9xInterface::getEEpromSize() const int Er9xInterface::getEEpromSize()
{ {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;
} }
@ -303,7 +303,7 @@ int Er9xInterface::isAvailable(Protocol prot, int port)
SimulatorInterface * Er9xInterface::getSimulator() SimulatorInterface * Er9xInterface::getSimulator()
{ {
return new Er9xSimulator(this); return NULL; // new Er9xSimulator(this);
} }

View file

@ -343,7 +343,7 @@ int Ersky9xInterface::isAvailable(Protocol prot, int port)
SimulatorInterface * Ersky9xInterface::getSimulator() SimulatorInterface * Ersky9xInterface::getSimulator()
{ {
return new Ersky9xSimulator(this); return NULL; // new Ersky9xSimulator(this);
} }

View file

@ -18,6 +18,7 @@
#include "gruvin9xinterface.h" #include "gruvin9xinterface.h"
#include "gruvin9xeeprom.h" #include "gruvin9xeeprom.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -47,8 +48,7 @@ const char * Gruvin9xInterface::getName()
const int Gruvin9xInterface::getEEpromSize() const int Gruvin9xInterface::getEEpromSize()
{ {
if (board == BOARD_STOCK) { if (board == BOARD_STOCK) {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return EESIZE_STOCK*2; return EESIZE_STOCK*2;
} }

View file

@ -105,7 +105,7 @@ uint8_t getStickMode()
using namespace Open9xGruvin9x; using namespace Open9xGruvin9x;
Open9xGruvin9xSimulator::Open9xGruvin9xSimulator(Open9xInterface * open9xInterface): Open9xGruvin9xSimulator::Open9xGruvin9xSimulator(OpenTxInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
} }
@ -128,15 +128,23 @@ bool Open9xGruvin9xSimulator::lcdChanged(bool & lightEnable)
#include "simulatorimport.h" #include "simulatorimport.h"
} }
void Open9xGruvin9xSimulator::start(RadioData &radioData, bool tests) void Open9xGruvin9xSimulator::start(QByteArray & eeprom, bool tests)
{ {
g_rotenc[0] = 0; g_rotenc[0] = 0;
g_rotenc[1] = 0; g_rotenc[1] = 0;
open9xInterface->save(&eeprom[0], radioData, SIMU_GRUVIN9X_VARIANTS); memcpy(Open9xGruvin9x::eeprom, eeprom.data(), std::min<int>(sizeof(Open9xGruvin9x::eeprom), eeprom.size()));
StartEepromThread(NULL); StartEepromThread(NULL);
StartMainThread(tests); 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() void Open9xGruvin9xSimulator::stop()
{ {
StopMainThread(); StopMainThread();

View file

@ -20,15 +20,17 @@
#include "simulatorinterface.h" #include "simulatorinterface.h"
class RadioData; class RadioData;
class Open9xInterface; class OpenTxInterface;
class Open9xGruvin9xSimulator : public SimulatorInterface { class Open9xGruvin9xSimulator : public SimulatorInterface {
public: 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(); virtual void stop();
@ -54,7 +56,7 @@ class Open9xGruvin9xSimulator : public SimulatorInterface {
protected: protected:
Open9xInterface * open9xInterface; OpenTxInterface * open9xInterface;
}; };
#endif #endif

View file

@ -103,7 +103,7 @@ uint8_t getStickMode()
using namespace Open9xM128; using namespace Open9xM128;
Open9xM128Simulator::Open9xM128Simulator(Open9xInterface * open9xInterface): Open9xM128Simulator::Open9xM128Simulator(OpenTxInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
} }
@ -126,13 +126,19 @@ bool Open9xM128Simulator::lcdChanged(bool & lightEnable)
#include "simulatorimport.h" #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<int>(sizeof(Open9xM128::eeprom), eeprom.size()));
StartEepromThread(NULL); StartEepromThread(NULL);
StartMainThread(tests); StartMainThread(tests);
} }
void Open9xM128Simulator::start(const char * filename, bool tests)
{
StartEepromThread(filename);
StartMainThread(tests);
}
void Open9xM128Simulator::stop() void Open9xM128Simulator::stop()
{ {
StopMainThread(); StopMainThread();

View file

@ -20,15 +20,17 @@
#include "simulatorinterface.h" #include "simulatorinterface.h"
class RadioData; class RadioData;
class Open9xInterface; class OpenTxInterface;
class Open9xM128Simulator : public SimulatorInterface { class Open9xM128Simulator : public SimulatorInterface {
public: 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(); virtual void stop();
@ -54,7 +56,7 @@ class Open9xM128Simulator : public SimulatorInterface {
protected: protected:
Open9xInterface * open9xInterface; OpenTxInterface * open9xInterface;
}; };
#endif #endif

View file

@ -16,6 +16,7 @@
#include "opentxSky9xsimulator.h" #include "opentxSky9xsimulator.h"
#include "opentxinterface.h" #include "opentxinterface.h"
#include "appdata.h"
#define SIMU #define SIMU
#define SIMU_EXCEPTIONS #define SIMU_EXCEPTIONS
@ -132,11 +133,10 @@ uint8_t getStickMode()
using namespace Open9xSky9x; using namespace Open9xSky9x;
Open9xSky9xSimulator::Open9xSky9xSimulator(Open9xInterface * open9xInterface): Open9xSky9xSimulator::Open9xSky9xSimulator(OpenTxInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
QSettings settings; QString path=g.profile[g.id()].sdPath()+"/";
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii(); simuSdDirectory[i]=path.at(i).toAscii();
@ -162,14 +162,21 @@ bool Open9xSky9xSimulator::lcdChanged(bool & lightEnable)
#include "simulatorimport.h" #include "simulatorimport.h"
} }
void Open9xSky9xSimulator::start(RadioData &radioData, bool tests) void Open9xSky9xSimulator::start(QByteArray & eeprom, bool tests)
{ {
g_rotenc[0] = 0; g_rotenc[0] = 0;
open9xInterface->save(&eeprom[0], radioData); memcpy(Open9xSky9x::eeprom, eeprom.data(), std::min<int>(sizeof(Open9xSky9x::eeprom), eeprom.size()));
StartEepromThread(NULL); StartEepromThread(NULL);
StartMainThread(tests); StartMainThread(tests);
} }
void Open9xSky9xSimulator::start(const char * filename, bool tests)
{
g_rotenc[0] = 0;
StartEepromThread(filename);
StartMainThread(tests);
}
void Open9xSky9xSimulator::stop() void Open9xSky9xSimulator::stop()
{ {
StopMainThread(); StopMainThread();

View file

@ -20,15 +20,17 @@
#include "simulatorinterface.h" #include "simulatorinterface.h"
class RadioData; class RadioData;
class Open9xInterface; class OpenTxInterface;
class Open9xSky9xSimulator : public SimulatorInterface { class Open9xSky9xSimulator : public SimulatorInterface {
public: 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(); virtual void stop();
@ -54,7 +56,7 @@ class Open9xSky9xSimulator : public SimulatorInterface {
protected: protected:
Open9xInterface * open9xInterface; OpenTxInterface * open9xInterface;
}; };
#endif #endif

View file

@ -16,6 +16,7 @@
#include "opentxTaranisSimulator.h" #include "opentxTaranisSimulator.h"
#include "opentxinterface.h" #include "opentxinterface.h"
#include "appdata.h"
#define SIMU #define SIMU
#define SIMU_EXCEPTIONS #define SIMU_EXCEPTIONS
@ -177,12 +178,11 @@ void resetTrims()
using namespace Open9xX9D; using namespace Open9xX9D;
OpentxTaranisSimulator::OpentxTaranisSimulator(Open9xInterface * open9xInterface): OpentxTaranisSimulator::OpentxTaranisSimulator(OpenTxInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
taranisSimulatorBoard = GetEepromInterface()->getBoard(); taranisSimulatorBoard = GetEepromInterface()->getBoard();
QSettings settings; QString path=g.profile[g.id()].sdPath()+"/";
QString path=settings.value("sdPath", ".").toString()+"/";
int i=0; int i=0;
for (i=0; i< std::min(path.length(),1022); i++) { for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii(); simuSdDirectory[i]=path.at(i).toAscii();
@ -208,13 +208,19 @@ bool OpentxTaranisSimulator::lcdChanged(bool & lightEnable)
#include "simulatorimport.h" #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<int>(sizeof(Open9xX9D::eeprom), eeprom.size()));
StartEepromThread(NULL); StartEepromThread(NULL);
StartMainThread(tests); StartMainThread(tests);
} }
void OpentxTaranisSimulator::start(const char * filename, bool tests)
{
StartEepromThread(filename);
StartMainThread(tests);
}
void OpentxTaranisSimulator::stop() void OpentxTaranisSimulator::stop()
{ {
StopMainThread(); StopMainThread();

View file

@ -20,15 +20,17 @@
#include "simulatorinterface.h" #include "simulatorinterface.h"
class RadioData; class RadioData;
class Open9xInterface; class OpenTxInterface;
class OpentxTaranisSimulator : public SimulatorInterface { class OpentxTaranisSimulator : public SimulatorInterface {
public: 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(); virtual void stop();
@ -54,7 +56,7 @@ class OpentxTaranisSimulator : public SimulatorInterface {
protected: protected:
Open9xInterface * open9xInterface; OpenTxInterface * open9xInterface;
}; };
#endif #endif

View file

@ -30,8 +30,6 @@
#define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT) #define SIMU_STOCK_VARIANTS (GVARS_VARIANT|FRSKY_VARIANT)
#define SIMU_M128_VARIANTS (M128_VARIANT|SIMU_STOCK_VARIANTS) #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_TIMERS 2
#define O9X_MAX_PHASES 5 #define O9X_MAX_PHASES 5

View file

@ -26,6 +26,7 @@
#include "opentxSky9xsimulator.h" #include "opentxSky9xsimulator.h"
#include "opentxTaranisSimulator.h" #include "opentxTaranisSimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -42,18 +43,18 @@ size_t SizeOfArray( T(&)[ N ] )
return N; return N;
} }
Open9xInterface::Open9xInterface(BoardEnum board): OpenTxInterface::OpenTxInterface(BoardEnum board):
EEPROMInterface(board), EEPROMInterface(board),
efile(new EFile()) efile(new EFile())
{ {
} }
Open9xInterface::~Open9xInterface() OpenTxInterface::~OpenTxInterface()
{ {
delete efile; delete efile;
} }
const char * Open9xInterface::getName() const char * OpenTxInterface::getName()
{ {
switch (board) { switch (board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -73,7 +74,7 @@ const char * Open9xInterface::getName()
} }
} }
const int Open9xInterface::getEEpromSize() const int OpenTxInterface::getEEpromSize()
{ {
switch (board) { switch (board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -93,7 +94,7 @@ const int Open9xInterface::getEEpromSize()
} }
} }
const int Open9xInterface::getMaxModels() const int OpenTxInterface::getMaxModels()
{ {
if (IS_ARM(board)) if (IS_ARM(board))
return 60; return 60;
@ -106,7 +107,7 @@ const int Open9xInterface::getMaxModels()
} }
template <class T> template <class T>
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; T _model;
@ -139,7 +140,7 @@ bool Open9xInterface::loadModel(ModelData &model, uint8_t *data, int index, unsi
} }
template <class T> template <class T>
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); T open9xModel(model, board, version, variant);
@ -166,7 +167,7 @@ bool Open9xInterface::loadModelVariant(unsigned int index, ModelData &model, uin
return true; 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) { if (version == 201) {
return loadModel<Open9xModelData_v201>(model, data, index, stickMode); return loadModel<Open9xModelData_v201>(model, data, index, stickMode);
@ -247,7 +248,7 @@ bool Open9xInterface::loadModel(uint8_t version, ModelData &model, uint8_t *data
} }
template <class T> template <class T>
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 QByteArray eepromData(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct
T open9xSettings(settings, board, version); T open9xSettings(settings, board, version);
@ -263,7 +264,7 @@ bool Open9xInterface::loadGeneral(GeneralSettings &settings, unsigned int versio
} }
template <class T> template <class T>
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); T open9xSettings(settings, board, version, variant);
// open9xSettings.Dump(); // open9xSettings.Dump();
@ -274,7 +275,7 @@ bool Open9xInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, ui
} }
template <class T> template <class T>
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); T open9xModel(model, board, version, variant);
// open9xModel.Dump(); // open9xModel.Dump();
@ -284,12 +285,12 @@ bool Open9xInterface::saveModel(unsigned int index, ModelData &model, unsigned i
return (sz == eeprom.size()); return (sz == eeprom.size());
} }
bool Open9xInterface::loadxml(RadioData &radioData, QDomDocument &doc) bool OpenTxInterface::loadxml(RadioData &radioData, QDomDocument &doc)
{ {
return false; 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..."; std::cout << "trying " << getName() << " import...";
@ -350,7 +351,7 @@ bool Open9xInterface::load(RadioData &radioData, uint8_t *eeprom, int size)
return true; 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(); EEPROMWarnings.clear();
@ -403,7 +404,7 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
return size; return size;
} }
int Open9xInterface::getSize(ModelData &model) int OpenTxInterface::getSize(ModelData &model)
{ {
if (board == BOARD_SKY9X) if (board == BOARD_SKY9X)
return 0; return 0;
@ -426,7 +427,7 @@ int Open9xInterface::getSize(ModelData &model)
return efile->size(0); return efile->size(0);
} }
int Open9xInterface::getSize(GeneralSettings &settings) int OpenTxInterface::getSize(GeneralSettings &settings)
{ {
if (board == BOARD_SKY9X) if (board == BOARD_SKY9X)
return 0; return 0;
@ -446,7 +447,7 @@ int Open9xInterface::getSize(GeneralSettings &settings)
return efile->size(0); return efile->size(0);
} }
int Open9xInterface::getCapability(const Capability capability) int OpenTxInterface::getCapability(const Capability capability)
{ {
switch (capability) { switch (capability) {
case OwnerName: case OwnerName:
@ -456,11 +457,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 1; return 1;
else else
return 0; return 0;
case SimulatorType:
if (IS_TARANIS(board))
return 1;
else
return 0;
case HasBeeper: case HasBeeper:
if (IS_ARM(board)) if (IS_ARM(board))
return 0; return 0;
@ -687,12 +683,19 @@ int Open9xInterface::getCapability(const Capability capability)
return IS_TARANIS(board) ? 2 : 0; return IS_TARANIS(board) ? 2 : 0;
case MultiposPotsPositions: case MultiposPotsPositions:
return IS_TARANIS(board) ? 6 : 0; 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: default:
return 0; return 0;
} }
} }
int Open9xInterface::isAvailable(Protocol proto, int port) int OpenTxInterface::isAvailable(Protocol proto, int port)
{ {
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
switch (port) { switch (port) {
@ -777,7 +780,7 @@ int Open9xInterface::isAvailable(Protocol proto, int port)
} }
} }
SimulatorInterface * Open9xInterface::getSimulator() SimulatorInterface * OpenTxInterface::getSimulator()
{ {
switch (board) { switch (board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -789,7 +792,6 @@ SimulatorInterface * Open9xInterface::getSimulator()
case BOARD_SKY9X: case BOARD_SKY9X:
return new Open9xSky9xSimulator(this); return new Open9xSky9xSimulator(this);
case BOARD_TARANIS: case BOARD_TARANIS:
return new OpentxTaranisSimulator(this);
case BOARD_TARANIS_REV4a: case BOARD_TARANIS_REV4a:
return new OpentxTaranisSimulator(this); return new OpentxTaranisSimulator(this);
default: default:
@ -802,7 +804,7 @@ size_t getSizeA(T (&)[SIZE]) {
return SIZE; return SIZE;
} }
bool Open9xInterface::checkVersion(unsigned int version) bool OpenTxInterface::checkVersion(unsigned int version)
{ {
switch(version) { switch(version) {
case 201: case 201:
@ -868,7 +870,7 @@ bool Open9xInterface::checkVersion(unsigned int version)
return true; 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 (board == BOARD_M128 && !(variant & 0x8000)) {
if (version == 212) { 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..."; std::cout << "trying " << getName() << " backup import...";
@ -933,9 +935,11 @@ bool Open9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esiz
QString geturl( int board) QString geturl( int board)
{ {
QSettings settings; QString url = g.compileServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
case BOARD_M128: case BOARD_M128:
@ -956,8 +960,11 @@ QString geturl( int board)
QString getstamp( int board) QString getstamp( int board)
{ {
QSettings settings; QString url = g.compileServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
url.append("/stamp-opentx-"); url.append("/stamp-opentx-");
switch(board) { switch(board) {
case BOARD_STOCK: case BOARD_STOCK:
@ -985,8 +992,11 @@ QString getstamp( int board)
QString getrnurl( int board) QString getrnurl( int board)
{ {
QSettings settings; QString url = g.compileServer();
QString url = settings.value("compilation-server", OPENTX_FIRMWARE_DOWNLOADS).toString(); if (url.isEmpty()){
url= OPENTX_FIRMWARE_DOWNLOADS;
g.compileServer(url);
}
url.append("/releasenotes-"); url.append("/releasenotes-");
switch(board) { switch(board) {
case BOARD_STOCK: 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 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 } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
/* 9x board */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1052,7 +1062,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9x board with M128 chip */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1084,7 +1094,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board */ /* 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->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1118,7 +1128,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board with M128 chip */ /* 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->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1148,7 +1158,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* Gruvin9x board */ /* 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->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1178,7 +1188,7 @@ void RegisterOpen9xFirmwares()
#ifndef __APPLE__ #ifndef __APPLE__
/* SKY9X board */ /* 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->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1203,7 +1213,7 @@ void RegisterOpen9xFirmwares()
#endif #endif
/* Taranis board */ /* 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("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));
@ -1212,10 +1222,8 @@ void RegisterOpen9xFirmwares()
open9x->addOptions(fai_options); open9x->addOptions(fai_options);
firmwares.push_back(open9x); firmwares.push_back(open9x);
QSettings settings; if (g.rev4aSupport()) {
int rev4a = settings.value("rev4asupport",0).toInt(); 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);
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);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));

View file

@ -23,13 +23,13 @@
class EFile; class EFile;
class Open9xInterface : public EEPROMInterface class OpenTxInterface : public EEPROMInterface
{ {
public: public:
Open9xInterface(BoardEnum board); OpenTxInterface(BoardEnum board);
virtual ~Open9xInterface(); virtual ~OpenTxInterface();
virtual const char * getName(); virtual const char * getName();

View file

@ -107,7 +107,7 @@ uint8_t getStickMode()
using namespace Open9x; using namespace Open9x;
Open9xSimulator::Open9xSimulator(Open9xInterface * open9xInterface): Open9xSimulator::Open9xSimulator(OpenTxInterface * open9xInterface):
open9xInterface(open9xInterface) open9xInterface(open9xInterface)
{ {
#define INIT_IMPORT #define INIT_IMPORT
@ -132,13 +132,20 @@ bool Open9xSimulator::lcdChanged(bool & lightEnable)
#include "simulatorimport.h" #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); StartEepromThread(NULL);
StartMainThread(tests); 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() void Open9xSimulator::stop()
{ {
StopMainThread(); StopMainThread();

View file

@ -19,15 +19,17 @@
#include "simulatorinterface.h" #include "simulatorinterface.h"
class Open9xInterface; class OpenTxInterface;
class Open9xSimulator : public SimulatorInterface { class Open9xSimulator : public SimulatorInterface {
public: 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(); virtual void stop();
@ -53,7 +55,7 @@ class Open9xSimulator : public SimulatorInterface {
protected: protected:
Open9xInterface * open9xInterface; OpenTxInterface * open9xInterface;
}; };

View file

@ -19,6 +19,7 @@
#include "th9xeeprom.h" #include "th9xeeprom.h"
#include "th9xsimulator.h" #include "th9xsimulator.h"
#include "file.h" #include "file.h"
#include "appdata.h"
#define FILE_TYP_GENERAL 1 #define FILE_TYP_GENERAL 1
#define FILE_TYP_MODEL 2 #define FILE_TYP_MODEL 2
@ -44,8 +45,7 @@ const char * Th9xInterface::getName()
const int Th9xInterface::getEEpromSize() const int Th9xInterface::getEEpromSize()
{ {
QSettings settings; QString avrMCU = g.mcu();
QString avrMCU = settings.value("mcu", QString("m64")).toString();
if (avrMCU==QString("m128")) { if (avrMCU==QString("m128")) {
return 2*EESIZE_STOCK; return 2*EESIZE_STOCK;
} }
@ -202,5 +202,5 @@ int Th9xInterface::isAvailable(Protocol proto, int port)
SimulatorInterface * Th9xInterface::getSimulator() SimulatorInterface * Th9xInterface::getSimulator()
{ {
return new Th9xSimulator(this); return NULL; // new Th9xSimulator(this);
} }

View file

@ -1,13 +1,14 @@
#include "fusesdialog.h" #include "fusesdialog.h"
#include "ui_fusesdialog.h" #include "ui_fusesdialog.h"
#include "burnconfigdialog.h" #include "burnconfigdialog.h"
#include "helpers.h"
fusesDialog::fusesDialog(QWidget *parent) : fusesDialog::fusesDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::fusesDialog) ui(new Ui::fusesDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("fuses.png"));
} }
fusesDialog::~fusesDialog() fusesDialog::~fusesDialog()

View file

@ -13,10 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Fuses</string> <string>Fuses</string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<widget class="QPushButton" name="readFuses"> <widget class="QPushButton" name="readFuses">

View file

@ -3,6 +3,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "eeprominterface.h" #include "eeprominterface.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QDesktopServices> #include <QDesktopServices>
#include <QtGui> #include <QtGui>
@ -187,11 +188,8 @@ void fwPreferencesDialog::firmwareChanged()
ui->CPU_ID_LE->hide(); ui->CPU_ID_LE->hide();
ui->CPU_ID_LABEL->hide(); ui->CPU_ID_LABEL->hide();
} }
QSettings settings; int fwrev = g.fwRev.get(variant.id);
settings.beginGroup("FwRevisions"); if (fwrev != 0) {
int fwrev = settings.value(variant.id, -1).toInt();
settings.endGroup();
if (fwrev != -1) {
ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev)); ui->FwInfo->setText(tr("Last downloaded release: %1").arg(fwrev));
if (!stamp.isEmpty()) { if (!stamp.isEmpty()) {
ui->checkFWUpdates->show(); ui->checkFWUpdates->show();
@ -213,11 +211,9 @@ void fwPreferencesDialog::firmwareChanged()
void fwPreferencesDialog::writeValues() void fwPreferencesDialog::writeValues()
{ {
QSettings settings; g.cpuId( ui->CPU_ID_LE->text() );
settings.setValue("cpu_id", ui->CPU_ID_LE->text());
current_firmware_variant = getFirmwareVariant(); 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) void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
@ -275,9 +271,7 @@ void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)
void fwPreferencesDialog::initSettings() void fwPreferencesDialog::initSettings()
{ {
QSettings settings; ui->CPU_ID_LE->setText(g.cpuId());
ui->CPU_ID_LE->setText(settings.value("cpu_id", "").toString());
FirmwareInfo * current_firmware = GetCurrentFirmware(); FirmwareInfo * current_firmware = GetCurrentFirmware();
foreach(FirmwareInfo * firmware, firmwares) { foreach(FirmwareInfo * firmware, firmwares) {
@ -293,12 +287,10 @@ void fwPreferencesDialog::initSettings()
void fwPreferencesDialog::on_checkFWUpdates_clicked() void fwPreferencesDialog::on_checkFWUpdates_clicked()
{ {
QSettings settings;
FirmwareVariant variant = getFirmwareVariant(); FirmwareVariant variant = getFirmwareVariant();
if (settings.value("burnFirmware", true).toBool()) { if (g.profile[g.id()].burnFirmware()) {
current_firmware_variant = variant; current_firmware_variant = variant;
settings.setValue("firmware", variant.id); g.profile[g.id()].firmware( variant.id );
} }
MainWindow * mw = (MainWindow *)this->parent(); MainWindow * mw = (MainWindow *)this->parent();
mw->checkForUpdates(true, variant.id); mw->checkForUpdates(true, variant.id);
@ -307,14 +299,13 @@ void fwPreferencesDialog::on_checkFWUpdates_clicked()
void fwPreferencesDialog::on_fw_dnld_clicked() void fwPreferencesDialog::on_fw_dnld_clicked()
{ {
QSettings settings;
MainWindow * mw = (MainWindow *)this->parent(); MainWindow * mw = (MainWindow *)this->parent();
FirmwareVariant variant = getFirmwareVariant(); FirmwareVariant variant = getFirmwareVariant();
writeValues(); writeValues();
if (!variant.firmware->getUrl(variant.id).isNull()) { if (!variant.firmware->getUrl(variant.id).isNull()) {
if (settings.value("burnFirmware", true).toBool()) { if (g.profile[g.id()].burnFirmware()) {
current_firmware_variant = getFirmwareVariant(); 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); mw->downloadLatestFW(current_firmware_variant.firmware, current_firmware_variant.id);
} }

View file

@ -1,9 +1,9 @@
#include "generaledit.h" #include "generaledit.h"
#include "ui_generaledit.h" #include "ui_generaledit.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QtGui> #include <QtGui>
#define MAX_PROFILES 10
#define BIT_WARN_THR ( 0x01 ) #define BIT_WARN_THR ( 0x01 )
#define BIT_WARN_SW ( 0x02 ) #define BIT_WARN_SW ( 0x02 )
#define BIT_WARN_MEM ( 0x04 ) #define BIT_WARN_MEM ( 0x04 )
@ -18,20 +18,14 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) :
g_eeGeneral(radioData.generalSettings) g_eeGeneral(radioData.generalSettings)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(QIcon(":/icon.png")); this->setWindowIcon(CompanionIcon("open.png"));
QSettings settings; QString firmware_id = g.profile[g.id()].firmware();
QString firmware_id = settings.value("firmware", default_firmware_variant.id).toString(); ui->tabWidget->setCurrentIndex( g.generalEditTab() );
ui->tabWidget->setCurrentIndex(settings.value("generalEditTab", 0).toInt()); QString name=g.profile[g.id()].name();
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();
if (name.isEmpty()) { if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true); ui->calstore_PB->setDisabled(true);
} }
settings.endGroup();
EEPROMInterface *eepromInterface = GetEepromInterface(); 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}; 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}; 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(); ui->profile_CB->clear();
for ( int i = 0; i < MAX_PROFILES; ++i) { for ( int i = 0; i < MAX_PROFILES; ++i) {
QString profile=QString("profile%1").arg(i+1); QString name=g.profile[i].name();
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) { if (!name.isEmpty()) {
ui->profile_CB->addItem(name, i+1); ui->profile_CB->addItem(name, i);
if ((i+1)==profile_id) { if (i==g.id()) {
ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1); ui->profile_CB->setCurrentIndex(ui->profile_CB->count());
} }
} }
settings.endGroup();
} }
settings.endGroup();
QRegExp rx(CHAR_FOR_NAMES_REGEX); QRegExp rx(CHAR_FOR_NAMES_REGEX);
ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this)); ui->ownerNameLE->setValidator(new QRegExpValidator(rx, this));
@ -970,9 +960,7 @@ void GeneralEdit::on_PPM4_editingFinished()
void GeneralEdit::on_tabWidget_currentChanged(int index) void GeneralEdit::on_tabWidget_currentChanged(int index)
{ {
// TODO why er9x here g.generalEditTab(index);
QSettings settings;
settings.setValue("generalEditTab",index);//ui->tabWidget->currentIndex());
} }
@ -1220,31 +1208,23 @@ void GeneralEdit::on_swGEAChkB_stateChanged(int )
void GeneralEdit::on_calretrieve_PB_clicked() void GeneralEdit::on_calretrieve_PB_clicked()
{ {
QSettings settings;
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles"); QString calib=g.profile[profile_id].stickPotCalib();
QString profile=QString("profile%1").arg(profile_id);
settings.beginGroup(profile);
QString calib=settings.value("StickPotCalib","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (calib.isEmpty()) { if (calib.isEmpty()) {
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString trainercalib=settings.value("TrainerCalib","").toString(); QString trainercalib = g.profile[profile_id].trainerCalib();
int8_t vBatCalib=(int8_t)settings.value("VbatCalib", g_eeGeneral.vBatCalib).toInt(); int8_t vBatCalib = (int8_t)g.profile[profile_id].vBatCalib();
int8_t currentCalib=(int8_t)settings.value("currentCalib", g_eeGeneral.currentCalib).toInt(); int8_t currentCalib = (int8_t)g.profile[profile_id].currentCalib();
int8_t PPM_Multiplier=(int8_t)settings.value("PPM_Multiplier", g_eeGeneral.PPM_Multiplier).toInt(); int8_t PPM_Multiplier = (int8_t)g.profile[profile_id].ppmMultiplier();
uint8_t GSStickMode=(uint8_t)settings.value("GSStickMode", g_eeGeneral.stickMode).toUInt(); uint8_t GSStickMode = (uint8_t)g.profile[profile_id].gsStickMode();
uint8_t vBatWarn=(uint8_t)settings.value("vBatWarn",g_eeGeneral.vBatWarn).toUInt(); uint8_t vBatWarn = (uint8_t)g.profile[profile_id].vBatWarn();
QString DisplaySet=settings.value("Display","").toString(); QString DisplaySet = g.profile[profile_id].display();
QString BeeperSet=settings.value("Beeper","").toString(); QString BeeperSet = g.profile[profile_id].beeper();
QString HapticSet=settings.value("Haptic","").toString(); QString HapticSet = g.profile[profile_id].haptic();
QString SpeakerSet=settings.value("Speaker","").toString(); QString SpeakerSet = g.profile[profile_id].speaker();
QString CountrySet=settings.value("countryCode","").toString(); QString CountrySet = g.profile[profile_id].countryCode();
settings.endGroup();
settings.endGroup();
if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) {
QString Byte; QString Byte;
@ -1337,27 +1317,20 @@ void GeneralEdit::on_calretrieve_PB_clicked()
void GeneralEdit::on_calstore_PB_clicked() void GeneralEdit::on_calstore_PB_clicked()
{ {
QSettings settings;
int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id); QString name=g.profile[profile_id].name();
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
int potsnum=GetEepromInterface()->getCapability(Pots); int potsnum=GetEepromInterface()->getCapability(Pots);
if (name.isEmpty()) { if (name.isEmpty()) {
ui->calstore_PB->setDisabled(true); ui->calstore_PB->setDisabled(true);
settings.endGroup();
settings.endGroup();
return; return;
} else { } else {
QString calib=settings.value("StickPotCalib","").toString(); QString calib=g.profile[profile_id].stickPotCalib();
if (!(calib.isEmpty())) { if (!(calib.isEmpty())) {
int ret = QMessageBox::question(this, "Companion", int ret = QMessageBox::question(this, "Companion",
tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) , tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) ,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::No) { if (ret == QMessageBox::No) {
settings.endGroup();
settings.endGroup();
return; 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.calibSpanNeg[i], 4, 16, QChar('0')));
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.calibSpanPos[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(); calib.clear();
for (int i=0; i< 4; i++) { for (int i=0; i< 4; i++) {
calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)g_eeGeneral.trainer.calib[i], 4, 16, QChar('0')));
} }
settings.setValue("TrainerCalib",calib); g.profile[profile_id].trainerCalib( calib );
settings.setValue("VbatCalib",g_eeGeneral.vBatCalib); g.profile[profile_id].vBatCalib( g_eeGeneral.vBatCalib );
settings.setValue("currentCalib",g_eeGeneral.currentCalib); g.profile[profile_id].currentCalib( g_eeGeneral.currentCalib );
settings.setValue("vBatWarn",g_eeGeneral.vBatWarn); g.profile[profile_id].vBatWarn( g_eeGeneral.vBatWarn );
settings.setValue("PPM_Multiplier",g_eeGeneral.PPM_Multiplier); g.profile[profile_id].ppmMultiplier( g_eeGeneral.PPM_Multiplier );
settings.setValue("GSStickMode",g_eeGeneral.stickMode); g.profile[profile_id].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'))); 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')) );
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'))); 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')));
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'))); 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')));
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'))); 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')));
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)); 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));
settings.endGroup();
settings.endGroup();
QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved.")); QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved."));
} }
} }

View file

@ -19,10 +19,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>General Edit</string> <string>General Edit</string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1559,10 +1555,10 @@ Acceptable values are 5v..10v</string>
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum> <enum>QLayout::SetMinimumSize</enum>
</property> </property>
<property name="verticalSpacing"> <property name="topMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="verticalSpacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="2"> <item row="0" column="2">

View file

@ -1,5 +1,7 @@
#include <QtGui> #include <QtGui>
#include "appdata.h"
#include "helpers.h" #include "helpers.h"
#include "simulatordialog.h"
QString getPhaseName(int val, char * phasename) QString getPhaseName(int val, char * phasename)
{ {
@ -635,24 +637,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
b->setMaxVisibleItems(10); 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) void populateCSWCB(QComboBox *b, int value)
{ {
int order[] = { int order[] = {
@ -694,27 +678,6 @@ void populateCSWCB(QComboBox *b, int value)
b->setMaxVisibleItems(10); 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) QString image2qstring(QImage image)
{ {
if (image.isNull()) if (image.isNull())
@ -913,8 +876,7 @@ QString getCenterBeep(ModelData * g_model)
QString getTheme() QString getTheme()
{ {
QSettings settings; int theme_set = g.theme();
int theme_set = settings.value("theme", 1).toInt();
QString Theme; QString Theme;
switch(theme_set) { switch(theme_set) {
case 0: case 0:
@ -930,7 +892,7 @@ QString getTheme()
Theme="monoblue"; Theme="monoblue";
break; break;
default: default:
Theme="new"; Theme="yerico";
break; break;
} }
return Theme; return Theme;
@ -945,3 +907,34 @@ CompanionIcon::CompanionIcon(QString baseimage)
addFile(":/themes/"+theme+"/48/"+baseimage, QSize(48,48)); 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"));
}
}

View file

@ -109,8 +109,6 @@ void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & m
void populateCSWCB(QComboBox *b, int value); void populateCSWCB(QComboBox *b, int value);
QString getPhaseName(int val, char * phasename=NULL); QString getPhaseName(int val, char * phasename=NULL);
QString getInputStr(ModelData & model, int index); QString getInputStr(ModelData & model, int index);
QString getSignedStr(int value);
QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image); QString image2qstring(QImage image);
QImage qstring2image(QString imagestr); QImage qstring2image(QString imagestr);
int findmult(float value, float base); int findmult(float value, float base);
@ -128,7 +126,6 @@ QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units); QString getFrSkyMeasure(int units);
QString getFrSkySrc(int index); QString getFrSkySrc(int index);
float ValToTim(int value); void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx);
int TimToVal(float value);
#endif // HELPERS_H #endif // HELPERS_H

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 589 B

After

Width:  |  Height:  |  Size: 589 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 746 B

View file

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 312 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 307 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 329 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 429 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 400 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 959 KiB

View file

@ -1,6 +1,8 @@
#include "logsdialog.h" #include "logsdialog.h"
#include "appdata.h"
#include "ui_logsdialog.h" #include "ui_logsdialog.h"
#include "qcustomplot.h" #include "qcustomplot.h"
#include "helpers.h"
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
#include <windows.h> #include <windows.h>
#else #else
@ -14,6 +16,7 @@ logsDialog::logsDialog(QWidget *parent) :
csvlog.clear(); csvlog.clear();
srand(QDateTime::currentDateTime().toTime_t()); srand(QDateTime::currentDateTime().toTime_t());
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("logs.png"));
palette.clear(); palette.clear();
plotLock=false; plotLock=false;
for (int i=0; i< 60; i++) for (int i=0; i< 60; i++)
@ -38,8 +41,7 @@ logsDialog::logsDialog(QWidget *parent) :
ui->customPlot->legend->setSelectedFont(legendFont); ui->customPlot->legend->setSelectedFont(legendFont);
ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items ui->customPlot->legend->setSelectable(QCPLegend::spItems); // legend box shall not be selectable, only legend items
ui->customPlot->legend->setVisible(false); ui->customPlot->legend->setVisible(false);
QSettings settings; QString Path=g.gePath();
QString Path=settings.value("gePath", "").toString();
if (Path.isEmpty() || !QFile(Path).exists()) { if (Path.isEmpty() || !QFile(Path).exists()) {
ui->mapsButton->hide(); 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\ ,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}; ,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=g.gePath();
QString gePath=settings.value("gePath", "").toString();
if (gePath.isEmpty() || !QFile(gePath).exists()) { if (gePath.isEmpty() || !QFile(gePath).exists()) {
ui->FieldsTW->setDisabled(false); ui->FieldsTW->setDisabled(false);
ui->logTable->setDisabled(false); ui->logTable->setDisabled(false);
@ -585,10 +586,9 @@ void logsDialog::moveLegend()
void logsDialog::on_fileOpen_BT_clicked() void logsDialog::on_fileOpen_BT_clicked()
{ {
QSettings settings; QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), g.logDir());
QString fileName = QFileDialog::getOpenFileName(this,tr("Select your log file"), settings.value("lastLogDir").toString());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("lastLogDir", fileName); g.logDir( fileName );
ui->FileName_LE->setText(fileName); ui->FileName_LE->setText(fileName);
if (cvsFileParse()) { if (cvsFileParse()) {
ui->FieldsTW->clear(); ui->FieldsTW->clear();

View file

@ -13,10 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Companion Log Viewer</string> <string>Companion Log Viewer</string>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<property name="sizeGripEnabled"> <property name="sizeGripEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -70,7 +66,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -188,7 +193,7 @@
<number>0</number> <number>0</number>
</property> </property>
<attribute name="verticalHeaderVisible"> <attribute name="verticalHeaderVisible">
<bool>true</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="verticalHeaderDefaultSectionSize"> <attribute name="verticalHeaderDefaultSectionSize">
<number>18</number> <number>18</number>

View file

@ -49,7 +49,6 @@
#include "avroutputdialog.h" #include "avroutputdialog.h"
#include "comparedialog.h" #include "comparedialog.h"
#include "logsdialog.h" #include "logsdialog.h"
#include "preferencesdialog.h"
#include "apppreferencesdialog.h" #include "apppreferencesdialog.h"
#include "fwpreferencesdialog.h" #include "fwpreferencesdialog.h"
#include "flashinterface.h" #include "flashinterface.h"
@ -63,6 +62,7 @@
#include "hexinterface.h" #include "hexinterface.h"
#include "warnings.h" #include "warnings.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include #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" #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->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setCentralWidget(mdiArea); setCentralWidget(mdiArea);
connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), connect(mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(updateMenus()));
this, SLOT(updateMenus()));
windowMapper = new QSignalMapper(this); windowMapper = new QSignalMapper(this);
connect(windowMapper, SIGNAL(mapped(QWidget*)), connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
this, SLOT(setActiveSubWindow(QWidget*)));
MaxRecentFiles=MAX_RECENT;
QSettings settings;
restoreGeometry(settings.value("mainWindowGeometry").toByteArray());
createActions(); createActions();
createMenus(); createMenus();
createToolBars(); createToolBars();
createStatusBar(); createStatusBar();
updateMenus(); updateMenus();
readSettings();
restoreState(g.mainWinState());
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
this->setWindowIcon(QIcon(":/icon.png")); 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 // give time to the splash to disappear and main window to open before starting updates
int updateDelay = 1000; int updateDelay = 1000;
bool showSplash = settings.value("show_splash", true).toBool(); bool showSplash = g.showSplash();
if (showSplash) { if (showSplash) {
updateDelay += (SPLASH_TIME*1000); updateDelay += (SPLASH_TIME*1000);
} }
@ -169,8 +163,7 @@ MainWindow::MainWindow():
void MainWindow::displayWarnings() void MainWindow::displayWarnings()
{ {
QSettings settings; int warnId=g.warningId();
int warnId=settings.value("warningId", 0 ).toInt();
if (warnId<WARNING_ID && warnId!=0) { if (warnId<WARNING_ID && warnId!=0) {
int res=0; int res=0;
if (WARNING_LEVEL>0) { if (WARNING_LEVEL>0) {
@ -181,10 +174,10 @@ void MainWindow::displayWarnings()
res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No); res = QMessageBox::question(this, "Companion",tr("Display previous message again at startup ?"),QMessageBox::Yes | QMessageBox::No);
} }
if (res == QMessageBox::No) { if (res == QMessageBox::No) {
settings.setValue("warningId", WARNING_ID); g.warningId(WARNING_ID);
} }
} else if (warnId==0) { } 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; showcheckForUpdatesResult = ignoreSettings;
check1done = true; check1done = true;
check2done = true; check2done = true;
QSettings settings;
fwToUpdate = fwId; fwToUpdate = fwId;
QString stamp = GetFirmware(fwToUpdate)->stamp; QString stamp = GetFirmware(fwToUpdate)->stamp;
if (!stamp.isEmpty()) { if (!stamp.isEmpty()) {
if (checkFW || ignoreSettings) { if (g.autoCheckFw() || ignoreSettings) {
check1done=false; check1done=false;
manager1 = new QNetworkAccessManager(this); manager1 = new QNetworkAccessManager(this);
connect(manager1, SIGNAL(finished(QNetworkReply*)), this, SLOT(reply1Finished(QNetworkReply*))); 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; check2done = false;
manager2 = new QNetworkAccessManager(this); manager2 = new QNetworkAccessManager(this);
connect(manager2, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForUpdateFinished(QNetworkReply*))); 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) , "Would you like to download it?").arg(version) ,
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
QSettings settings;
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
#if defined __APPLE__ #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 #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 #endif
if (!fileName.isEmpty()) { 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); downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName);
installer_fileName = fileName; installer_fileName = fileName;
connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded()));
@ -311,11 +301,10 @@ void MainWindow::updateDownloaded()
void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId) void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmwareId)
{ {
QString url, ext, cpuid; QString url, ext, cpuid;
QSettings settings;
url = firmware->getUrl(firmwareId); url = firmware->getUrl(firmwareId);
cpuid=settings.value("cpuid","").toString(); cpuid=g.cpuId();
ext = url.mid(url.lastIndexOf(".")); 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()) { if (!fileName.isEmpty()) {
downloadedFW = firmwareId; downloadedFW = firmwareId;
needRename=true; needRename=true;
@ -324,7 +313,7 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
url.append("&cpuid="); url.append("&cpuid=");
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); downloadDialog * dd = new downloadDialog(this, url, fileName);
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
dd->exec(); dd->exec();
@ -334,8 +323,6 @@ void MainWindow::downloadLatestFW(FirmwareInfo * firmware, const QString & firmw
void MainWindow::reply1Accepted() void MainWindow::reply1Accepted()
{ {
QString errormsg; QString errormsg;
QSettings settings;
settings.beginGroup("FwRevisions");
if (downloadedFWFilename.isEmpty()) { if (downloadedFWFilename.isEmpty()) {
if (!(downloadedFW.isEmpty())) { if (!(downloadedFW.isEmpty())) {
QFile file(downloadedFW); QFile file(downloadedFW);
@ -370,12 +357,11 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
QMessageBox::critical(this, tr("Error"), errormsg); QMessageBox::critical(this, tr("Error"), errormsg);
settings.endGroup();
return; return;
} }
file.close(); file.close();
currentFWrev = currentFWrev_temp; currentFWrev = currentFWrev_temp;
settings.setValue(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
} }
} else { } else {
QFile file(downloadedFWFilename); QFile file(downloadedFWFilename);
@ -410,7 +396,6 @@ void MainWindow::reply1Accepted()
} }
file.close(); file.close();
QMessageBox::critical(this, tr("Error"), errormsg); QMessageBox::critical(this, tr("Error"), errormsg);
settings.endGroup();
return; return;
} }
file.close(); file.close();
@ -419,7 +404,7 @@ void MainWindow::reply1Accepted()
int pos=rev.lastIndexOf("-r"); int pos=rev.lastIndexOf("-r");
if (pos>0) { if (pos>0) {
currentFWrev=rev.mid(pos+2).toInt(); 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); QFileInfo fi(downloadedFWFilename);
QString path=fi.path()+QDir::separator (); QString path=fi.path()+QDir::separator ();
path.append(fi.completeBaseName()); path.append(fi.completeBaseName());
@ -431,8 +416,8 @@ void MainWindow::reply1Accepted()
qd.rename(downloadedFWFilename,path); qd.rename(downloadedFWFilename,path);
downloadedFWFilename=path; downloadedFWFilename=path;
} }
settings.setValue(downloadedFW, currentFWrev); g.fwRev.set(downloadedFW, currentFWrev);
if (settings.value("burnFirmware", true).toBool()) { 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); 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) { if (ret == QMessageBox::Yes) {
writeFlash(downloadedFWFilename); writeFlash(downloadedFWFilename);
@ -440,7 +425,6 @@ void MainWindow::reply1Accepted()
} }
} }
} }
settings.endGroup();
} }
void MainWindow::reply1Finished(QNetworkReply * reply) void MainWindow::reply1Finished(QNetworkReply * reply)
@ -456,8 +440,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
// TODO delete downloadDialog_forWait? // TODO delete downloadDialog_forWait?
} }
QSettings settings; cpuid=g.cpuId();
cpuid=settings.value("cpuid","").toString();
QByteArray qba = reply->readAll(); QByteArray qba = reply->readAll();
int i = qba.indexOf("SVN_VERS"); int i = qba.indexOf("SVN_VERS");
int warning = qba.indexOf("WARNING"); int warning = qba.indexOf("WARNING");
@ -471,17 +454,13 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
if(!cres) { if(!cres) {
QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
int server = settings.value("fwserver",0).toInt(); g.fwServerFails(g.fwServerFails()+1);
server++;
settings.setValue("fwserver",server);
return; return;
} }
if(rev>0) { if(rev>0) {
NewFwRev=rev; NewFwRev=rev;
settings.beginGroup("FwRevisions"); OldFwRev = g.fwRev.get(fwToUpdate);
OldFwRev = settings.value(fwToUpdate, 0).toInt();
settings.endGroup();
QMessageBox msgBox; QMessageBox msgBox;
QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout* layout = (QGridLayout*)msgBox.layout(); QGridLayout* layout = (QGridLayout*)msgBox.layout();
@ -552,9 +531,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
if (ignore) { if (ignore) {
int res = QMessageBox::question(this, "Companion",tr("Ignore this version (r%1)?").arg(rev), QMessageBox::Yes | QMessageBox::No); int res = QMessageBox::question(this, "Companion",tr("Ignore this version (r%1)?").arg(rev), QMessageBox::Yes | QMessageBox::No);
if (res==QMessageBox::Yes) { if (res==QMessageBox::Yes) {
settings.beginGroup("FwRevisions"); g.fwRev.set(fwToUpdate, NewFwRev);
settings.setValue(fwToUpdate, NewFwRev);
settings.endGroup();
} }
} else if (download == true) { } else if (download == true) {
if (warning>0) { if (warning>0) {
@ -571,12 +548,12 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate); QString url = GetFirmware(fwToUpdate)->getUrl(fwToUpdate);
QString ext = url.mid(url.lastIndexOf(".")); QString ext = url.mid(url.lastIndexOf("."));
needRename=false; needRename=false;
bool addversion=settings.value("rename_firmware_files", false).toBool(); bool addversion=g.profile[g.id()].renameFwFiles();
QString fileName; QString fileName;
if (addversion) { 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 { } 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 (!fileName.isEmpty()) {
if (!cpuid.isEmpty()) { if (!cpuid.isEmpty()) {
@ -584,7 +561,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
url.append(cpuid); url.append(cpuid);
} }
downloadedFWFilename = fileName; downloadedFWFilename = fileName;
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath()); g.flashDir(QFileInfo(fileName).dir().absolutePath());
downloadDialog * dd = new downloadDialog(this, url, fileName); downloadDialog * dd = new downloadDialog(this, url, fileName);
currentFWrev_temp = NewFwRev; currentFWrev_temp = NewFwRev;
connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted())); connect(dd, SIGNAL(accepted()), this, SLOT(reply1Accepted()));
@ -598,9 +575,7 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
} else { } else {
if(check1done && check2done) { if(check1done && check2done) {
QMessageBox::warning(this, "Companion", tr("Unable to check for updates.")); QMessageBox::warning(this, "Companion", tr("Unable to check for updates."));
int server = settings.value("fwserver",0).toInt(); g.fwServerFails(g.fwServerFails()+1);
server++;
settings.setValue("fwserver",server);
return; return;
} }
} }
@ -608,9 +583,8 @@ void MainWindow::reply1Finished(QNetworkReply * reply)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
QSettings settings; g.mainWinGeo(saveGeometry());
settings.setValue("mainWindowGeometry", saveGeometry()); g.mainWinState(saveState());
settings.setValue("mainWindowState", saveState());
mdiArea->closeAllSubWindows(); mdiArea->closeAllSubWindows();
if (mdiArea->currentSubWindow()) { if (mdiArea->currentSubWindow()) {
event->ignore(); event->ignore();
@ -622,8 +596,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::setLanguage(QString langString) void MainWindow::setLanguage(QString langString)
{ {
QSettings settings; g.locale( langString );
settings.setValue("locale", langString );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The selected language will be used the next time you start Companion.")); 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) void MainWindow::setTheme(int index)
{ {
QSettings settings; g.theme( index );
settings.setValue("theme", index );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The new theme will be loaded the next time you start Companion.")); 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) void MainWindow::setIconThemeSize(int index)
{ {
QSettings settings; g.iconSize( index );
settings.setValue("icon_size", index );
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText(tr("The icon size will be used the next time you start Companion.")); 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() void MainWindow::openFile()
{ {
QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.eepromDir(), tr(EEPROM_FILES_FILTER));
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); g.eepromDir(QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) { if (existing) {
@ -704,11 +674,9 @@ void MainWindow::saveAs()
void MainWindow::openRecentFile() void MainWindow::openRecentFile()
{ {
QSettings settings;
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
if (action) { if (action) {
QString fileName=action->data().toString(); QString fileName=action->data().toString();
// settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) { 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<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
if (action) { if (action) {
// Set the new profile number
int profnum=action->data().toInt(); int profnum=action->data().toInt();
QSettings settings; g.id( profnum );
settings.setValue("profileId",profnum);
settings.beginGroup("Profiles"); // TODO Get rid of this global variable - The profile.firmware is the real source
QString profile=QString("profile%1").arg(profnum); current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].firmware());
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);
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) { foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget()); MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
@ -1107,20 +1050,19 @@ void MainWindow::readEeprom()
void MainWindow::writeFileToEeprom() void MainWindow::writeFileToEeprom()
{ {
QSettings settings;
QString fileName; QString fileName;
bool backup = false; bool backup = false;
burnDialog *cd = new burnDialog(this, 1, &fileName, &backup); burnDialog *cd = new burnDialog(this, 1, &fileName, &backup);
cd->exec(); cd->exec();
if (!fileName.isEmpty()) { 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); 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 (ret != QMessageBox::Yes) return;
if (!isValidEEPROM(fileName)) 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); 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; if (ret != QMessageBox::Yes) return;
bool backupEnable = settings.value("backupEnable", true).toBool(); bool backupEnable = g.enableBackup();
QString backupPath = settings.value("backupPath", "").toString(); QString backupPath = g.backupDir();
if (!backupPath.isEmpty()) { if (!backupPath.isEmpty()) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -1361,9 +1303,8 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
void MainWindow::writeFlash(QString fileToFlash) void MainWindow::writeFlash(QString fileToFlash)
{ {
QSettings settings;
QString fileName; QString fileName;
bool backup = settings.value("backupOnFlash", false).toBool(); bool backup = g.backupOnFlash();
if(!fileToFlash.isEmpty()) if(!fileToFlash.isEmpty())
fileName = fileToFlash; fileName = fileToFlash;
burnDialog *cd = new burnDialog(this, 2, &fileName, &backup); burnDialog *cd = new burnDialog(this, 2, &fileName, &backup);
@ -1371,12 +1312,12 @@ void MainWindow::writeFlash(QString fileToFlash)
if (IS_TARANIS(GetEepromInterface()->getBoard())) if (IS_TARANIS(GetEepromInterface()->getBoard()))
backup=false; backup=false;
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
settings.setValue("backupOnFlash", backup); g.backupOnFlash(backup);
if (backup) { if (backup) {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString backupFile = tempDir + "/backup.bin"; QString backupFile = tempDir + "/backup.bin";
bool backupEnable=settings.value("backupEnable", true).toBool(); bool backupEnable=g.enableBackup();
QString backupPath=settings.value("backupPath", "").toString(); QString backupPath=g.backupDir();
if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) { if (!backupPath.isEmpty() && !IS_TARANIS(GetEepromInterface()->getBoard())) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -1430,8 +1371,8 @@ void MainWindow::writeFlash(QString fileToFlash)
} }
} }
else { else {
bool backupEnable=settings.value("backupEnable", true).toBool(); bool backupEnable=g.enableBackup();
QString backupPath=settings.value("backupPath", "").toString(); QString backupPath=g.backupDir();
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
QMessageBox::warning(this, tr("Backup is impossible"), tr("The backup dir set in preferences does not exist")); 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() void MainWindow::readEepromToFile()
{ {
QSettings settings; QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER));
QString fileName = QFileDialog::getSaveFileName(this, tr("Save transmitter Models and Settings to File"), settings.value("lastDir").toString(), tr(EXTERNAL_EEPROM_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_TARANIS(eepromInterface->getBoard())) { if (IS_TARANIS(eepromInterface->getBoard())) {
@ -1480,7 +1420,7 @@ void MainWindow::readEepromToFile()
} }
} }
else { else {
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath()); g.eepromDir(QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveEEpromCommand(fileName); QStringList str = GetReceiveEEpromCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx")); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, tr("Read Models and Settings From Tx"));
ad->setWindowIcon(CompanionIcon("read_eeprom.png")); ad->setWindowIcon(CompanionIcon("read_eeprom.png"));
@ -1492,14 +1432,13 @@ void MainWindow::readEepromToFile()
void MainWindow::readFlash() void MainWindow::readFlash()
{ {
QSettings settings; QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), g.flashDir(),tr(FLASH_FILES_FILTER));
QString fileName = QFileDialog::getSaveFileName(this,tr("Read Tx Firmware to File"), settings.value("lastFlashDir").toString(),tr(FLASH_FILES_FILTER));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
QFile file(fileName); QFile file(fileName);
if (file.exists()) { if (file.exists()) {
file.remove(); file.remove();
} }
settings.setValue("lastFlashDir",QFileInfo(fileName).dir().absolutePath()); g.flashDir(QFileInfo(fileName).dir().absolutePath());
QStringList str = GetReceiveFlashCommand(fileName); QStringList str = GetReceiveFlashCommand(fileName);
avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx"); avrOutputDialog *ad = new avrOutputDialog(this, GetAvrdudeLocation(), str, "Read Firmware From Tx");
ad->setWindowIcon(CompanionIcon("read_flash.png")); ad->setWindowIcon(CompanionIcon("read_flash.png"));
@ -1551,6 +1490,7 @@ void MainWindow::about()
aboutStr.append("<br/><br/>"); aboutStr.append("<br/><br/>");
aboutStr.append(tr("Copyright") + " Bertrand Songis & Romolo Manfredini<br/>&copy; 2011-2014<br/>"); aboutStr.append(tr("Copyright") + " Bertrand Songis & Romolo Manfredini<br/>&copy; 2011-2014<br/>");
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowIcon(CompanionIcon("information.png"));
msgBox.setWindowTitle(tr("About Companion")); msgBox.setWindowTitle(tr("About Companion"));
msgBox.setText(aboutStr); msgBox.setText(aboutStr);
msgBox.exec(); msgBox.exec();
@ -1578,8 +1518,7 @@ void MainWindow::updateMenus()
updateIconSizeActions(); updateIconSizeActions();
updateIconThemeActions(); updateIconThemeActions();
QSettings settings; setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( g.profile[g.id()].name() ));
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString()));
} }
MdiChild *MainWindow::createMdiChild() MdiChild *MainWindow::createMdiChild()
@ -1630,7 +1569,7 @@ void MainWindow::createActions()
separatorAct = new QAction(this); separatorAct = new QAction(this);
separatorAct->setSeparator(true); 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] = new QAction(this);
recentFileActs[i]->setVisible(false); recentFileActs[i]->setVisible(false);
connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
@ -1658,7 +1597,7 @@ void MainWindow::createActions()
QActionGroup *themeAlignGroup = new QActionGroup(this); QActionGroup *themeAlignGroup = new QActionGroup(this);
classicThemeAct = addAct( themeAlignGroup, tr("Classical"), tr("The classical Companion icon theme"), SLOT(setClassicTheme())); 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())); 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())); 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())); monoBlueAct = addAct( themeAlignGroup, tr("MonoBlue"), tr("A monochrome blue icon theme"), SLOT(setMonoBlueTheme()));
@ -1728,7 +1667,7 @@ void MainWindow::createMenus()
fileMenu->addAction(saveAsAct); fileMenu->addAction(saveAsAct);
fileMenu->addMenu(recentFileMenu); fileMenu->addMenu(recentFileMenu);
recentFileMenu->setIcon(CompanionIcon("recentdocument.png")); recentFileMenu->setIcon(CompanionIcon("recentdocument.png"));
for (int i=0; i<MaxRecentFiles; ++i) for (int i=0; i<MAX_RECENT; ++i)
recentFileMenu->addAction(recentFileActs[i]); recentFileMenu->addAction(recentFileActs[i]);
fileMenu->addSeparator(); fileMenu->addSeparator();
fileMenu->addAction(logsAct); fileMenu->addAction(logsAct);
@ -1763,7 +1702,7 @@ void MainWindow::createMenus()
settingsMenu->addMenu(themeMenu); settingsMenu->addMenu(themeMenu);
themeMenu->addAction(classicThemeAct); themeMenu->addAction(classicThemeAct);
themeMenu->addAction(newThemeAct); themeMenu->addAction(yericoThemeAct);
themeMenu->addAction(monoThemeAct); themeMenu->addAction(monoThemeAct);
themeMenu->addAction(monoBlueAct); themeMenu->addAction(monoBlueAct);
themeMenu->addAction(monoWhiteAct); themeMenu->addAction(monoWhiteAct);
@ -1810,7 +1749,7 @@ void MainWindow::createMenus()
QMenu *MainWindow::createRecentFileMenu() QMenu *MainWindow::createRecentFileMenu()
{ {
QMenu *recentFileMenu = new QMenu(this); QMenu *recentFileMenu = new QMenu(this);
for ( int i = 0; i < MaxRecentFiles; ++i) for ( int i = 0; i < MAX_RECENT; ++i)
recentFileMenu->addAction(recentFileActs[i]); recentFileMenu->addAction(recentFileActs[i]);
return recentFileMenu; return recentFileMenu;
} }
@ -1822,8 +1761,8 @@ QMenu *MainWindow::createProfilesMenu()
for ( i = 0; i < MAX_PROFILES; ++i) { for ( i = 0; i < MAX_PROFILES; ++i) {
profilesMenu->addAction(profileActs[i]); profilesMenu->addAction(profileActs[i]);
} }
if ( i>0 )
profilesMenu->addSeparator(); profilesMenu->addSeparator();
profilesMenu->addAction(createProfileAct); profilesMenu->addAction(createProfileAct);
profilesMenu->setIcon(CompanionIcon("profiles.png")); profilesMenu->setIcon(CompanionIcon("profiles.png"));
return profilesMenu; return profilesMenu;
@ -1831,10 +1770,8 @@ QMenu *MainWindow::createProfilesMenu()
void MainWindow::createToolBars() void MainWindow::createToolBars()
{ {
QSettings settings;
int icon_size=settings.value("icon_size",2 ).toInt();
QSize size; QSize size;
switch(icon_size) { switch(g.iconSize()) {
case 0: case 0:
size=QSize(16,16); size=QSize(16,16);
break; break;
@ -1919,20 +1856,6 @@ void MainWindow::createStatusBar()
statusBar()->showMessage(tr("Ready")); 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() MdiChild *MainWindow::activeMdiChild()
{ {
if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow()) if (QMdiSubWindow *activeSubWindow = mdiArea->activeSubWindow())
@ -1961,27 +1884,31 @@ void MainWindow::setActiveSubWindow(QWidget *window)
void MainWindow::updateRecentFileActions() void MainWindow::updateRecentFileActions()
{ {
int i,j, numRecentFiles; int i, numRecentFiles;
QSettings settings;
QStringList files = settings.value("recentFileList").toStringList();
numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); // Hide all document slots
for ( i=0 ; i < g.historySize(); i++)
recentFileActs[i]->setVisible(false);
for ( i = 0; i < numRecentFiles; ++i) { // Fill slots with content and unhide them
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); QStringList files = g.recentFiles();
numRecentFiles = qMin(files.size(), g.historySize());
for ( i = 0; i < numRecentFiles; i++) {
QString text = strippedName(files[i]);
if (!text.trimmed().isEmpty())
{
recentFileActs[i]->setText(text); recentFileActs[i]->setText(text);
recentFileActs[i]->setData(files[i]); recentFileActs[i]->setData(files[i]);
recentFileActs[i]->setVisible(true); recentFileActs[i]->setVisible(true);
} }
for ( j = numRecentFiles; j < MaxRecentFiles; ++j) }
recentFileActs[j]->setVisible(false);
} }
void MainWindow::updateIconSizeActions() void MainWindow::updateIconSizeActions()
{ {
QSettings settings; switch (g.iconSize())
int size = settings.value("icon_size","0").toInt(); {
switch (size){
case 0: smallIconAct->setChecked(true); break; case 0: smallIconAct->setChecked(true); break;
case 1: normalIconAct->setChecked(true); break; case 1: normalIconAct->setChecked(true); break;
case 2: bigIconAct->setChecked(true); break; case 2: bigIconAct->setChecked(true); break;
@ -1991,8 +1918,7 @@ void MainWindow::updateIconSizeActions()
void MainWindow::updateLanguageActions() void MainWindow::updateLanguageActions()
{ {
QSettings settings; QString langId = g.locale();
QString langId = settings.value("locale","").toString();
if (langId=="") if (langId=="")
sysLangAct->setChecked(true); sysLangAct->setChecked(true);
@ -2022,11 +1948,10 @@ void MainWindow::updateLanguageActions()
void MainWindow::updateIconThemeActions() void MainWindow::updateIconThemeActions()
{ {
QSettings settings; switch (g.theme())
int size = settings.value("theme","1").toInt(); {
switch (size){
case 0: classicThemeAct->setChecked(true); break; 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 2: monoWhiteAct->setChecked(true); break;
case 3: monoThemeAct->setChecked(true); break; case 3: monoThemeAct->setChecked(true); break;
case 4: monoBlueAct->setChecked(true); break; case 4: monoBlueAct->setChecked(true); break;
@ -2035,52 +1960,34 @@ void MainWindow::updateIconThemeActions()
void MainWindow::updateProfilesActions() void MainWindow::updateProfilesActions()
{ {
int i; for (int i=0; i<MAX_PROFILES; i++)
QSettings settings; {
int activeProfile = settings.value("profileId").toInt(); if (!g.profile[i].name().isEmpty())
{
settings.beginGroup("Profiles"); QString text = tr("&%1: %2").arg(i).arg(g.profile[i].name());
for (i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) {
QString text = tr("&%1 %2").arg(i + 1).arg(name);
profileActs[i]->setText(text); profileActs[i]->setText(text);
profileActs[i]->setData(i+1); profileActs[i]->setData(i);
profileActs[i]->setVisible(true); profileActs[i]->setVisible(true);
if ((i+1) == activeProfile) if (i == g.id())
profileActs[i]->setChecked(true); profileActs[i]->setChecked(true);
} }
else { else
{
profileActs[i]->setVisible(false); profileActs[i]->setVisible(false);
} }
settings.endGroup();
} }
} }
void MainWindow::createProfile() void MainWindow::createProfile()
{ { int i;
int firstFreeIndex = 0; for (i=0; i<MAX_PROFILES && !g.profile[i].name().isEmpty(); i++)
QSettings settings; ;
settings.beginGroup("Profiles"); if (i==MAX_PROFILES) //Failed to find free slot
for (int i=0; firstFreeIndex ==0 && i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (name.isEmpty())
firstFreeIndex = i+1;
settings.endGroup();
}
settings.endGroup();
if (firstFreeIndex == 0) // Could not find free index
return; return;
settings.beginGroup("Profiles"); // Create profile name and force a flush to file
settings.beginGroup(QString("profile%1").arg(firstFreeIndex)); g.profile[i].name( QString("profile%1").arg(i));
settings.setValue("Name",QString("profile%1").arg(firstFreeIndex)); g.profile[i].flush();
settings.endGroup();
settings.endGroup();
updateMenus(); updateMenus();
} }
@ -2182,8 +2089,7 @@ void MainWindow::dropEvent(QDropEvent *event)
QString fileName = urls.first().toLocalFile(); QString fileName = urls.first().toLocalFile();
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
QSettings settings; g.eepromDir(QFileInfo(fileName).dir().absolutePath());
settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
QMdiSubWindow *existing = findMdiChild(fileName); QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) { if (existing) {

View file

@ -48,9 +48,9 @@
#include "downloaddialog.h" #include "downloaddialog.h"
#include "eeprominterface.h" #include "eeprominterface.h"
#define MAX_RECENT 15
#define MAX_PROFILES 10
#define SPLASH_TIME 5 #define SPLASH_TIME 5
#define MAX_RECENT 10
#define MAX_PROFILES 15
class MdiChild; class MdiChild;
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -99,7 +99,7 @@ private slots:
void setTheme(int index); void setTheme(int index);
void setClassicTheme() {setTheme(0);}; void setClassicTheme() {setTheme(0);};
void setNewTheme() {setTheme(1);}; void setYericoTheme() {setTheme(1);};
void setMonoWhiteTheme() {setTheme(2);}; void setMonoWhiteTheme() {setTheme(2);};
void setMonochromeTheme(){setTheme(3);}; void setMonochromeTheme(){setTheme(3);};
void setMonoBlueTheme() {setTheme(4);}; void setMonoBlueTheme() {setTheme(4);};
@ -165,7 +165,6 @@ private:
void createMenus(); void createMenus();
void createToolBars(); void createToolBars();
void createStatusBar(); void createStatusBar();
void readSettings();
void updateRecentFileActions(); void updateRecentFileActions();
void updateProfilesActions(); void updateProfilesActions();
void updateIconSizeActions(); void updateIconSizeActions();
@ -201,11 +200,8 @@ private:
QString downloadedFWFilename; QString downloadedFWFilename;
downloadDialog * downloadDialog_forWait; downloadDialog * downloadDialog_forWait;
bool checkCompanion;
bool checkFW;
bool needRename; bool needRename;
bool showcheckForUpdatesResult; bool showcheckForUpdatesResult;
int MaxRecentFiles;
int currentFWrev; int currentFWrev;
int currentFWrev_temp; int currentFWrev_temp;
int NewFwRev; int NewFwRev;
@ -260,7 +256,7 @@ private:
QAction *profileActs[MAX_PROFILES]; QAction *profileActs[MAX_PROFILES];
QAction *createProfileAct; QAction *createProfileAct;
QAction *classicThemeAct; QAction *classicThemeAct;
QAction *newThemeAct; QAction *yericoThemeAct;
QAction *monoThemeAct; QAction *monoThemeAct;
QAction *monoBlueAct; QAction *monoBlueAct;
QAction *monoWhiteAct; QAction *monoWhiteAct;

View file

@ -48,11 +48,10 @@
#include "generaledit.h" #include "generaledit.h"
#include "avroutputdialog.h" #include "avroutputdialog.h"
#include "burnconfigdialog.h" #include "burnconfigdialog.h"
#include "simulatordialog.h"
#include "xsimulatordialog.h"
#include "printdialog.h" #include "printdialog.h"
#include "burndialog.h" #include "burndialog.h"
#include "helpers.h" #include "helpers.h"
#include "appdata.h"
#include <QFileInfo> #include <QFileInfo>
#if defined WIN32 || !defined __GNUC__ #if defined WIN32 || !defined __GNUC__
@ -69,6 +68,7 @@ MdiChild::MdiChild():
fileChanged(false) fileChanged(false)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowIcon(CompanionIcon("open.png"));
ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png")); ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png"));
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -142,25 +142,7 @@ void MdiChild::setModified()
void MdiChild::on_SimulateTxButton_clicked() void MdiChild::on_SimulateTxButton_clicked()
{ {
if (GetEepromInterface()->getSimulator()) { startSimulation(this, radioData, -1);
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"));
}
} }
void MdiChild::OpenEditWindow(bool wizard=false) void MdiChild::OpenEditWindow(bool wizard=false)
@ -179,8 +161,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
} }
if (isNew && !wizard) { if (isNew && !wizard) {
int ret; int ret;
QSettings settings; bool wizardEnable=g.enableWizard();
bool wizardEnable=settings.value("wizardEnable", true).toBool();
if (wizardEnable) { if (wizardEnable) {
ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
@ -189,7 +170,7 @@ void MdiChild::OpenEditWindow(bool wizard=false)
qSleep(500); qSleep(500);
ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No); ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No);
if (ret == 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) bool MdiChild::saveAs(bool isNew)
{ {
QSettings settings;
QString fileName; QString fileName;
if (GetEepromInterface()->getBoard() == BOARD_SKY9X) { if (GetEepromInterface()->getBoard() == BOARD_SKY9X) {
curFile.replace(".eepe", ".bin"); curFile.replace(".eepe", ".bin");
QFileInfo fi(curFile); QFileInfo fi(curFile);
#ifdef __APPLE__ #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 #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 #endif
} }
else { else {
QFileInfo fi(curFile); QFileInfo fi(curFile);
#ifdef __APPLE__ #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 #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 #endif
} }
if (fileName.isEmpty()) if (fileName.isEmpty())
return false; return false;
if (fileName.contains("rev4a")) { if (fileName.contains("rev4a")) {
settings.setValue("rev4asupport", 1); g.rev4aSupport( true );
} }
if (fileName.contains("norev4a")) { 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) if (isNew)
return saveFile(fileName); return saveFile(fileName);
else else
@ -490,15 +470,14 @@ void MdiChild::setCurrentFile(const QString &fileName)
fileChanged = false; fileChanged = false;
setWindowModified(false); setWindowModified(false);
updateTitle(); updateTitle();
QSettings settings; int MaxRecentFiles = g.historySize();
int MaxRecentFiles =settings.value("history_size",10).toInt(); QStringList files = g.recentFiles();
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
while (files.size() > MaxRecentFiles) while (files.size() > MaxRecentFiles)
files.removeLast(); files.removeLast();
settings.setValue("recentFileList", files); g.recentFiles( files );
} }
QString MdiChild::strippedName(const QString &fullFileName) QString MdiChild::strippedName(const QString &fullFileName)
@ -508,9 +487,8 @@ QString MdiChild::strippedName(const QString &fullFileName)
void MdiChild::writeEeprom() // write to Tx void MdiChild::writeEeprom() // write to Tx
{ {
QSettings settings; bool backupEnable=g.enableBackup();
bool backupEnable=settings.value("backupEnable", true).toBool(); QString backupPath=g.backupDir();
QString backupPath=settings.value("backupPath", "").toString();
if (!backupPath.isEmpty()) { if (!backupPath.isEmpty()) {
if (!QDir(backupPath).exists()) { if (!QDir(backupPath).exists()) {
if (backupEnable) { if (backupEnable) {
@ -521,13 +499,7 @@ void MdiChild::writeEeprom() // write to Tx
} else { } else {
backupEnable=false; backupEnable=false;
} }
int profileid=settings.value("profileId", 1).toInt(); QString stickCal=g.profile[g.id()].stickPotCalib();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profileid);
settings.beginGroup(profile);
QString stickCal=settings.value("StickPotCalib","").toString();
settings.endGroup();
settings.endGroup();
burnConfigDialog bcd; burnConfigDialog bcd;
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString tempFile = tempDir + "/temp.bin"; QString tempFile = tempDir + "/temp.bin";
@ -647,21 +619,8 @@ void MdiChild::writeEeprom() // write to Tx
void MdiChild::simulate() void MdiChild::simulate()
{ {
if(ui->modelsList->currentRow()<1) return; if (ui->modelsList->currentRow() >= 1) {
if (GetEepromInterface()->getSimulator()) { startSimulation(this, radioData, ui->modelsList->currentRow()-1);
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"));
} }
} }
@ -690,8 +649,7 @@ void MdiChild::setEEpromAvail(int eavail)
bool MdiChild::loadBackup() bool MdiChild::loadBackup()
{ {
QSettings settings; QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), g.eepromDir(),tr(EEPROM_FILES_FILTER));
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastDir").toString(),tr(EEPROM_FILES_FILTER));
if (fileName.isEmpty()) if (fileName.isEmpty())
return false; return false;
QFile file(fileName); QFile file(fileName);

View file

@ -13,10 +13,6 @@
<property name="windowTitle"> <property name="windowTitle">
<string/> <string/>
</property> </property>
<property name="windowIcon">
<iconset resource="companion.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="ModelsListWidget" name="modelsList"/> <widget class="ModelsListWidget" name="modelsList"/>

Some files were not shown because too many files have changed in this diff Show more