Profiles working.
Next all duplicated variables will be removed from global and only exists in profile.
This commit is contained in:
+67
-15
@@ -230,8 +230,12 @@ class Profile:DataObj
|
|||||||
|
|
||||||
|
|
||||||
// All the set declarations
|
// All the set declarations
|
||||||
|
void Name (const QString str) { if (str.isEmpty()) // Name may never be empty!
|
||||||
|
store("----", _Name, "Name" ,"Profiles", QString("profile%1").arg(index));
|
||||||
|
else
|
||||||
|
store(str, _Name, "Name" ,"Profiles", QString("profile%1").arg(index));}
|
||||||
|
|
||||||
void firmware (const QString str) { store(str, _firmware, "firmware" ,"Profiles", QString("profile%1").arg(index));}
|
void firmware (const QString str) { store(str, _firmware, "firmware" ,"Profiles", QString("profile%1").arg(index));}
|
||||||
void Name (const QString str) { store(str, _Name, "Name" ,"Profiles", QString("profile%1").arg(index));}
|
|
||||||
void sdPath (const QString str) { store(str, _sdPath, "sdPath" ,"Profiles", QString("profile%1").arg(index));}
|
void sdPath (const QString str) { store(str, _sdPath, "sdPath" ,"Profiles", QString("profile%1").arg(index));}
|
||||||
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" ,"Profiles", QString("profile%1").arg(index));}
|
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" ,"Profiles", QString("profile%1").arg(index));}
|
||||||
void burnFirmware (const bool bl) { store(bl, _burnFirmware, "burnFirmware" ,"Profiles", QString("profile%1").arg(index));}
|
void burnFirmware (const bool bl) { store(bl, _burnFirmware, "burnFirmware" ,"Profiles", QString("profile%1").arg(index));}
|
||||||
@@ -258,17 +262,33 @@ class Profile:DataObj
|
|||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init(int newIndex)
|
void remove()
|
||||||
{
|
{
|
||||||
index = newIndex;
|
// Remove all profile values from settings file
|
||||||
|
QSettings settings(PRODUCT, COMPANY);
|
||||||
|
settings.beginGroup("Profiles");
|
||||||
|
settings.remove(QString("profile%1").arg(index));
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
QString pName;
|
// Reset all profile variables to initial values
|
||||||
retrieve( pName, "Name", "", "Profiles", QString("profile%1").arg(newIndex));
|
init(index);
|
||||||
if ( newIndex > 1 && pName.isEmpty())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
|
bool 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 flush()
|
||||||
|
{
|
||||||
// Load and store all variables. Use default values if setting values are missing
|
// Load and store all variables. Use default values if setting values are missing
|
||||||
|
|
||||||
getset( _firmware, "firmware" ,"" ,"Profiles", QString("profile%1").arg(index));
|
getset( _firmware, "firmware" ,"" ,"Profiles", QString("profile%1").arg(index));
|
||||||
getset( _Name, "Name" ,"----" ,"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( _sdPath, "sdPath" ,"" ,"Profiles", QString("profile%1").arg(index));
|
||||||
@@ -291,6 +311,42 @@ class Profile:DataObj
|
|||||||
getset( _VbatCalib, "VbatCalib" ,"" ,"Profiles", QString("profile%1").arg(index));
|
getset( _VbatCalib, "VbatCalib" ,"" ,"Profiles", QString("profile%1").arg(index));
|
||||||
getset( _vBatWarn, "vBatWarn" ,"" ,"Profiles", QString("profile%1").arg(index));
|
getset( _vBatWarn, "vBatWarn" ,"" ,"Profiles", QString("profile%1").arg(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init(int newIndex)
|
||||||
|
{
|
||||||
|
index = newIndex;
|
||||||
|
|
||||||
|
_firmware = "";
|
||||||
|
_Name = "";
|
||||||
|
_sdPath = "";
|
||||||
|
_SplashFileName = "";
|
||||||
|
_burnFirmware = false;
|
||||||
|
_rename_firmware_files = false;
|
||||||
|
_default_channel_order = 0;
|
||||||
|
_default_mode = 1;
|
||||||
|
|
||||||
|
_Beeper = "";
|
||||||
|
_countryCode = "";
|
||||||
|
_currentCalib = "";
|
||||||
|
_Display = "";
|
||||||
|
_GSStickMode = "";
|
||||||
|
_Haptic = "";
|
||||||
|
_PPM_Multiplier = "";
|
||||||
|
_Speaker = "";
|
||||||
|
_StickPotCalib = "";
|
||||||
|
_TrainerCalib = "";
|
||||||
|
_VbatCalib = "";
|
||||||
|
_vBatWarn = "";
|
||||||
|
|
||||||
|
QString pName;
|
||||||
|
retrieve( pName, "Name", "", "Profiles", QString("profile%1").arg(index));
|
||||||
|
|
||||||
|
// Do not write empty profiles to disk except the default (0) profile.
|
||||||
|
if ( index > 0 && !existsOnDisk())
|
||||||
|
return;
|
||||||
|
|
||||||
|
flush();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppData:DataObj
|
class AppData:DataObj
|
||||||
@@ -307,7 +363,6 @@ class AppData:DataObj
|
|||||||
QString _firmware;
|
QString _firmware;
|
||||||
QString _locale;
|
QString _locale;
|
||||||
QString _cpu_id;
|
QString _cpu_id;
|
||||||
QString _SplashImage;
|
|
||||||
QString _Name;
|
QString _Name;
|
||||||
QString _SplashFileName;
|
QString _SplashFileName;
|
||||||
QString _modelEditGeometry;
|
QString _modelEditGeometry;
|
||||||
@@ -360,7 +415,6 @@ public:
|
|||||||
QString firmware() { return _firmware; }
|
QString firmware() { return _firmware; }
|
||||||
QString locale() { return _locale; }
|
QString locale() { return _locale; }
|
||||||
QString cpu_id() { return _cpu_id; }
|
QString cpu_id() { return _cpu_id; }
|
||||||
QString SplashImage() { return _SplashImage; }
|
|
||||||
QString Name() { return _Name; }
|
QString Name() { return _Name; }
|
||||||
QString SplashFileName() { return _SplashFileName; }
|
QString SplashFileName() { return _SplashFileName; }
|
||||||
QString modelEditGeometry() { return _modelEditGeometry; }
|
QString modelEditGeometry() { return _modelEditGeometry; }
|
||||||
@@ -409,7 +463,6 @@ public:
|
|||||||
void firmware (const QString str) { store(str, _firmware, "firmware" );}
|
void firmware (const QString str) { store(str, _firmware, "firmware" );}
|
||||||
void locale (const QString str) { store(str, _locale, "locale" );}
|
void locale (const QString str) { store(str, _locale, "locale" );}
|
||||||
void cpu_id (const QString str) { store(str, _cpu_id, "cpu_id" );}
|
void cpu_id (const QString str) { store(str, _cpu_id, "cpu_id" );}
|
||||||
void SplashImage (const QString str) { store(str, _SplashImage, "SplashImage" );}
|
|
||||||
void Name (const QString str) { store(str, _Name, "Name" );}
|
void Name (const QString str) { store(str, _Name, "Name" );}
|
||||||
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" );}
|
void SplashFileName (const QString str) { store(str, _SplashFileName, "SplashFileName" );}
|
||||||
void modelEditGeometry (const QString str) { store(str, _modelEditGeometry, "modelEditGeometry" );}
|
void modelEditGeometry (const QString str) { store(str, _modelEditGeometry, "modelEditGeometry" );}
|
||||||
@@ -466,7 +519,7 @@ public:
|
|||||||
|
|
||||||
//Initialize the index variables of the profiles
|
//Initialize the index variables of the profiles
|
||||||
for (int i=0; i<MAX_PROFILES; i++)
|
for (int i=0; i<MAX_PROFILES; i++)
|
||||||
profile[i].init( i+1 );
|
profile[i].init( i );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -479,8 +532,7 @@ public:
|
|||||||
getset( _firmware, "firmware" ,"" );
|
getset( _firmware, "firmware" ,"" );
|
||||||
getset( _locale, "locale" ,"" );
|
getset( _locale, "locale" ,"" );
|
||||||
getset( _cpu_id, "cpu_id" ,"" );
|
getset( _cpu_id, "cpu_id" ,"" );
|
||||||
getset( _SplashImage, "SplashImage" ,"" );
|
getset( _Name, "Name" ,"----" );
|
||||||
getset( _Name, "Name" ,"profile1" );
|
|
||||||
getset( _SplashFileName, "SplashFileName" ,"" );
|
getset( _SplashFileName, "SplashFileName" ,"" );
|
||||||
getset( _modelEditGeometry, "modelEditGeometry" ,"" );
|
getset( _modelEditGeometry, "modelEditGeometry" ,"" );
|
||||||
|
|
||||||
@@ -516,7 +568,7 @@ public:
|
|||||||
getset( _js_ctrl, "js_ctrl" ,0 );
|
getset( _js_ctrl, "js_ctrl" ,0 );
|
||||||
getset( _history_size, "history_size" ,10 );
|
getset( _history_size, "history_size" ,10 );
|
||||||
getset( _modelEditTab, "modelEditTab" ,0 );
|
getset( _modelEditTab, "modelEditTab" ,0 );
|
||||||
getset( _profileId, "profileId" ,1 );
|
getset( _profileId, "profileId" ,0 );
|
||||||
getset( _theme, "theme" ,1 );
|
getset( _theme, "theme" ,1 );
|
||||||
getset( _warningId, "warningId" ,0 );
|
getset( _warningId, "warningId" ,0 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ void appPreferencesDialog::writeValues()
|
|||||||
glob.Name(ui->profileNameLE->text());
|
glob.Name(ui->profileNameLE->text());
|
||||||
glob.sdPath(ui->sdPath->text());
|
glob.sdPath(ui->sdPath->text());
|
||||||
glob.SplashFileName(ui->SplashFileName->text());
|
glob.SplashFileName(ui->SplashFileName->text());
|
||||||
if (!ui->SplashFileName->text().isEmpty())
|
|
||||||
glob.SplashImage("");
|
|
||||||
glob.firmware(ui->firmwareLE->text());
|
glob.firmware(ui->firmwareLE->text());
|
||||||
|
|
||||||
saveProfile();
|
saveProfile();
|
||||||
@@ -85,13 +83,10 @@ void appPreferencesDialog::initSettings()
|
|||||||
{
|
{
|
||||||
ui->snapshotClipboardCKB->setChecked(glob.snapshot_to_clipboard());
|
ui->snapshotClipboardCKB->setChecked(glob.snapshot_to_clipboard());
|
||||||
ui->burnFirmware->setChecked(glob.burnFirmware());
|
ui->burnFirmware->setChecked(glob.burnFirmware());
|
||||||
|
ui->snapshotPath->setText(glob.snapshotpath());
|
||||||
QString Path=glob.snapshotpath();
|
ui->snapshotPath->setReadOnly(true);
|
||||||
if (QDir(Path).exists()) {
|
if (ui->snapshotClipboardCKB->isChecked())
|
||||||
ui->snapshotPath->setText(Path);
|
{
|
||||||
ui->snapshotPath->setReadOnly(true);
|
|
||||||
}
|
|
||||||
if (ui->snapshotClipboardCKB->isChecked()) {
|
|
||||||
ui->snapshotPath->setDisabled(true);
|
ui->snapshotPath->setDisabled(true);
|
||||||
ui->snapshotPathButton->setDisabled(true);
|
ui->snapshotPathButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
@@ -102,19 +97,12 @@ void appPreferencesDialog::initSettings()
|
|||||||
ui->historySize->setValue(glob.history_size());
|
ui->historySize->setValue(glob.history_size());
|
||||||
ui->backLightColor->setCurrentIndex(glob.backLight());
|
ui->backLightColor->setCurrentIndex(glob.backLight());
|
||||||
ui->simuSW->setChecked(glob.simuSW());
|
ui->simuSW->setChecked(glob.simuSW());
|
||||||
|
ui->libraryPath->setText(glob.libraryPath());
|
||||||
|
ui->ge_lineedit->setText(glob.gePath());
|
||||||
|
|
||||||
Path=glob.libraryPath();
|
if (!glob.backupPath().isEmpty()) {
|
||||||
if (QDir(Path).exists()) {
|
if (QDir(glob.backupPath()).exists()) {
|
||||||
ui->libraryPath->setText(Path);
|
ui->backupPath->setText(glob.backupPath());
|
||||||
}
|
|
||||||
Path=glob.gePath();
|
|
||||||
if (QFile(Path).exists()) {
|
|
||||||
ui->ge_lineedit->setText(Path);
|
|
||||||
}
|
|
||||||
Path=glob.backupPath();
|
|
||||||
if (!Path.isEmpty()) {
|
|
||||||
if (QDir(Path).exists()) {
|
|
||||||
ui->backupPath->setText(Path);
|
|
||||||
ui->backupEnable->setEnabled(true);
|
ui->backupEnable->setEnabled(true);
|
||||||
ui->backupEnable->setChecked(glob.backupEnable());
|
ui->backupEnable->setChecked(glob.backupEnable());
|
||||||
} else {
|
} else {
|
||||||
@@ -156,22 +144,12 @@ void appPreferencesDialog::initSettings()
|
|||||||
ui->channelorderCB->setCurrentIndex(glob.default_channel_order());
|
ui->channelorderCB->setCurrentIndex(glob.default_channel_order());
|
||||||
ui->stickmodeCB->setCurrentIndex(glob.default_mode());
|
ui->stickmodeCB->setCurrentIndex(glob.default_mode());
|
||||||
ui->renameFirmware->setChecked(glob.rename_firmware_files());
|
ui->renameFirmware->setChecked(glob.rename_firmware_files());
|
||||||
Path=glob.sdPath();
|
ui->sdPath->setText(glob.sdPath());
|
||||||
if (QDir(Path).exists()) {
|
|
||||||
ui->sdPath->setText(Path);
|
|
||||||
}
|
|
||||||
ui->profileIndexLE->setText(QString("%1").arg(glob.profileId()));
|
ui->profileIndexLE->setText(QString("%1").arg(glob.profileId()));
|
||||||
ui->profileNameLE->setText(glob.Name());
|
ui->profileNameLE->setText(glob.Name());
|
||||||
|
|
||||||
QString fileName=glob.SplashFileName();
|
|
||||||
if (!fileName.isEmpty()) {
|
|
||||||
QFile file(fileName);
|
|
||||||
if (file.exists()){
|
|
||||||
ui->SplashFileName->setText(fileName);
|
|
||||||
displayImage( fileName );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ui->firmwareLE->setText(glob.firmware());
|
ui->firmwareLE->setText(glob.firmware());
|
||||||
|
ui->SplashFileName->setText(glob.SplashFileName());
|
||||||
|
displayImage( glob.SplashFileName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void appPreferencesDialog::on_libraryPathButton_clicked()
|
void appPreferencesDialog::on_libraryPathButton_clicked()
|
||||||
@@ -261,13 +239,10 @@ void appPreferencesDialog::on_sdPathButton_clicked()
|
|||||||
void appPreferencesDialog::saveProfile()
|
void appPreferencesDialog::saveProfile()
|
||||||
{
|
{
|
||||||
// The profile name may NEVER be empty
|
// The profile name may NEVER be empty
|
||||||
QString profile=QString("profile") + QString("%1").arg(glob.profileId());
|
if (ui->profileNameLE->text().isEmpty())
|
||||||
QString name=ui->profileNameLE->text();
|
ui->profileNameLE->setText("----");
|
||||||
if (name.isEmpty()) {
|
|
||||||
name = profile;
|
glob.profile[glob.profileId()].Name( ui->profileNameLE->text() );
|
||||||
ui->profileNameLE->setText(name);
|
|
||||||
}
|
|
||||||
glob.profile[glob.profileId()].Name( name );
|
|
||||||
glob.profile[glob.profileId()].default_channel_order( ui->channelorderCB->currentIndex());
|
glob.profile[glob.profileId()].default_channel_order( ui->channelorderCB->currentIndex());
|
||||||
glob.profile[glob.profileId()].default_mode( ui->stickmodeCB->currentIndex());
|
glob.profile[glob.profileId()].default_mode( ui->stickmodeCB->currentIndex());
|
||||||
glob.profile[glob.profileId()].burnFirmware( ui->burnFirmware->isChecked());
|
glob.profile[glob.profileId()].burnFirmware( ui->burnFirmware->isChecked());
|
||||||
@@ -293,16 +268,12 @@ void appPreferencesDialog::loadFromProfile()
|
|||||||
void appPreferencesDialog::on_removeProfileButton_clicked()
|
void appPreferencesDialog::on_removeProfileButton_clicked()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
if ( glob.profileId() == 1 )
|
if ( glob.profileId() == 0 )
|
||||||
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") + QString("%1").arg(glob.profileId());
|
glob.profile[glob.profileId()].remove();
|
||||||
settings.beginGroup("Profiles");
|
glob.profileId( 0 );
|
||||||
settings.remove(profile);
|
|
||||||
settings.endGroup();
|
|
||||||
glob.profileId( 1 );
|
|
||||||
|
|
||||||
loadFromProfile();
|
loadFromProfile();
|
||||||
initSettings();
|
initSettings();
|
||||||
}
|
}
|
||||||
@@ -310,6 +281,9 @@ void appPreferencesDialog::on_removeProfileButton_clicked()
|
|||||||
|
|
||||||
bool appPreferencesDialog::displayImage( QString fileName )
|
bool appPreferencesDialog::displayImage( QString fileName )
|
||||||
{
|
{
|
||||||
|
// Start by filling the pixmap with white
|
||||||
|
ui->imageLabel->setPixmap(QPixmap());
|
||||||
|
|
||||||
QImage image(fileName);
|
QImage image(fileName);
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
return false;
|
return false;
|
||||||
@@ -361,11 +335,11 @@ void appPreferencesDialog::on_SplashSelect_clicked()
|
|||||||
QString fileName = QFileDialog::getOpenFileName(this,
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
|
tr("Open Image to load"), glob.lastImagesDir(), tr("Images (%1)").arg(supportedImageFormats));
|
||||||
|
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()){
|
||||||
glob.lastImagesDir(QFileInfo(fileName).dir().absolutePath());
|
glob.lastImagesDir(QFileInfo(fileName).dir().absolutePath());
|
||||||
|
|
||||||
if (displayImage(fileName))
|
displayImage(fileName);
|
||||||
ui->SplashFileName->setText(fileName);
|
ui->SplashFileName->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -102,12 +102,6 @@ MainWindow::MainWindow():
|
|||||||
|
|
||||||
restoreState(glob.mainWindowState());
|
restoreState(glob.mainWindowState());
|
||||||
|
|
||||||
if (glob.profileId() == 0)
|
|
||||||
{
|
|
||||||
createProfile();
|
|
||||||
glob.profileId( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
this->setWindowIcon(QIcon(":/icon.png"));
|
this->setWindowIcon(QIcon(":/icon.png"));
|
||||||
this->setIconSize(QSize(32,32));
|
this->setIconSize(QSize(32,32));
|
||||||
@@ -708,42 +702,33 @@ 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;
|
glob.profileId( profnum );
|
||||||
settings.setValue("profileId",profnum);
|
|
||||||
settings.beginGroup("Profiles");
|
// Upgrade old firmware names
|
||||||
QString profile=QString("profile%1").arg(profnum);
|
QString firmware = glob.profile[profnum].firmware();
|
||||||
settings.beginGroup(profile);
|
firmware.replace("open9x","opentx");
|
||||||
QString profileName=settings.value("Name", "").toString();
|
firmware.replace("x9da","taranis");
|
||||||
int chord=settings.value("default_channel_order", 0).toInt();
|
glob.profile[profnum].firmware(firmware);
|
||||||
int defmod=settings.value("default_mode", 0).toInt();
|
|
||||||
bool burnfw=settings.value("burnFirmware", false).toBool();
|
// Copy profile data from profile to main variables
|
||||||
QString sdPath=settings.value("sdPath", ".").toString();
|
glob.Name( glob.profile[profnum].Name() );
|
||||||
bool renfw=settings.value("rename_firmware_files", false).toBool();
|
glob.default_channel_order( glob.profile[profnum].default_channel_order() );
|
||||||
QString SplashFileName=settings.value("SplashFileName","").toString();
|
glob.default_mode( glob.profile[profnum].default_mode() );
|
||||||
QString SplashImage=settings.value("SplashImage", "").toString();
|
glob.burnFirmware( glob.profile[profnum].burnFirmware() );
|
||||||
QString firmware_id=settings.value("firmware", default_firmware_variant.id).toString();
|
glob.rename_firmware_files( glob.profile[profnum].rename_firmware_files() );
|
||||||
firmware_id.replace("open9x","opentx");
|
glob.sdPath( glob.profile[profnum].sdPath() );
|
||||||
firmware_id.replace("x9da","taranis");
|
glob.SplashFileName( glob.profile[profnum].SplashFileName() );
|
||||||
settings.setValue("firmware", firmware_id);
|
glob.firmware( glob.profile[profnum].firmware() );
|
||||||
settings.endGroup();
|
|
||||||
settings.endGroup();
|
// TODO Get rid of this global variable - glob.firmware is the real source
|
||||||
settings.setValue("Name", profileName );
|
current_firmware_variant = GetFirmwareVariant(glob.firmware());
|
||||||
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());
|
||||||
@@ -1091,7 +1076,6 @@ 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);
|
||||||
@@ -1559,7 +1543,7 @@ void MainWindow::updateMenus()
|
|||||||
updateIconSizeActions();
|
updateIconSizeActions();
|
||||||
updateIconThemeActions();
|
updateIconThemeActions();
|
||||||
|
|
||||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( QString("%1").arg(glob.profileId()) ));
|
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg( glob.Name() ));
|
||||||
}
|
}
|
||||||
|
|
||||||
MdiChild *MainWindow::createMdiChild()
|
MdiChild *MainWindow::createMdiChild()
|
||||||
@@ -1802,8 +1786,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;
|
||||||
@@ -1996,52 +1980,34 @@ void MainWindow::updateIconThemeActions()
|
|||||||
|
|
||||||
void MainWindow::updateProfilesActions()
|
void MainWindow::updateProfilesActions()
|
||||||
{
|
{
|
||||||
int i;
|
for (int i=0; i<MAX_PROFILES; i++)
|
||||||
QSettings settings;
|
{
|
||||||
int activeProfile = glob.profileId();
|
if (!glob.profile[i].Name().isEmpty())
|
||||||
|
{
|
||||||
settings.beginGroup("Profiles");
|
QString text = tr("&%1: %2").arg(i).arg(glob.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 == glob.profileId())
|
||||||
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 && !glob.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));
|
glob.profile[i].Name( QString("profile%1").arg(i));
|
||||||
settings.setValue("Name",QString("profile%1").arg(firstFreeIndex));
|
glob.profile[i].flush();
|
||||||
settings.endGroup();
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
updateMenus();
|
updateMenus();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user