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

Profiles can now be added and removed in a proper way.

This commit is contained in:
Kjell Kernen 2014-02-11 08:37:07 +01:00
parent 58e213f578
commit eedc5ea68f
8 changed files with 428 additions and 496 deletions

View file

@ -155,7 +155,6 @@ SET( companion_SRCS
modelslist.cpp
mountlist.cpp
avroutputdialog.cpp
preferencesdialog.cpp
apppreferencesdialog.cpp
fwpreferencesdialog.cpp
burnconfigdialog.cpp
@ -178,7 +177,6 @@ SET( companion_SRCS
SET( companion_MOC_HDRS
avroutputdialog.h
preferencesdialog.h
apppreferencesdialog.h
fwpreferencesdialog.h
burnconfigdialog.h
@ -214,7 +212,6 @@ SET( companion_UIS
comparedialog.ui
fusesdialog.ui
logsdialog.ui
preferencesdialog.ui
apppreferencesdialog.ui
fwpreferencesdialog.ui
simulatordialog.ui

View file

@ -60,16 +60,13 @@ void appPreferencesDialog::writeValues()
settings.setValue("default_mode", ui->stickmodeCB->currentIndex());
settings.setValue("rename_firmware_files", ui->renameFirmware->isChecked());
settings.setValue("burnFirmware", ui->burnFirmware->isChecked());
settings.setValue("profileId", ui->ProfSlot_SB->value());
settings.setValue("profileId", ui->profileIndexLE->text());
settings.setValue("sdPath", ui->sdPath->text());
settings.setValue("SplashFileName", ui->SplashFileName->text());
if (!ui->SplashFileName->text().isEmpty())
settings.setValue("SplashImage", "");
saveProfile();
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
}
void appPreferencesDialog::on_snapshotPathButton_clicked()
@ -163,8 +160,8 @@ void appPreferencesDialog::initSettings()
if (QDir(Path).exists()) {
ui->sdPath->setText(Path);
}
ui->ProfSlot_SB->setValue(settings.value("profileId", 1).toInt());
on_ProfSlot_SB_valueChanged();
ui->profileIndexLE->setText(settings.value("profileId", "").toString());
QString fileName=settings.value("SplashFileName","").toString();
if (!fileName.isEmpty()) {
QFile file(fileName);
@ -264,40 +261,11 @@ void appPreferencesDialog::on_sdPathButton_clicked()
}
}
void appPreferencesDialog::on_ProfSlot_SB_valueChanged()
{
QSettings settings;
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
ui->ProfName_LE->setText(name);
/* if (!(name.isEmpty())) {
QString firmwarename=settings.value("firmware", default_firmware_id).toString();
FirmwareInfo * fw = getFirmware(firmwarename);
int i=0;
foreach(FirmwareInfo * firmware, firmwares) {
if (fw == firmware) {
qDebug() << fw->id;
qDebug() << firmware->id;
qDebug() << i;
ui->downloadVerCB->setCurrentIndex(i);
break;
}
i++;
}
baseFirmwareChanged();
populateFirmwareOptions(fw);
}*/
settings.endGroup();
settings.endGroup();
}
void appPreferencesDialog::saveProfile()
{
QSettings settings;
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
QString profile=QString("profile") + settings.value("profileId").toString();
QString name=ui->ProfName_LE->text();
if (name.isEmpty()) {
name = profile;
@ -316,11 +284,51 @@ void appPreferencesDialog::saveProfile()
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" );
}
void appPreferencesDialog::on_removeProfileButton_clicked()
{
QSettings settings;
QString profile=QString("profile%1").arg(ui->ProfSlot_SB->value());
settings.remove(profile);
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."));
else
{
QString profile=QString("profile") + profileId;
settings.beginGroup("Profiles");
settings.remove(profile);
settings.endGroup();
settings.setValue("profileId", "1");
loadProfile();
initSettings();
}
}
bool appPreferencesDialog::displayImage( QString fileName )

View file

@ -25,6 +25,8 @@ private:
void initSettings();
bool displayImage( QString fileName );
void saveProfile();
void loadProfileString(QString profile, QString label);
void loadProfile();
private slots:
void writeValues();
@ -35,7 +37,6 @@ private slots:
void on_ge_pathButton_clicked();
void on_sdPathButton_clicked();
void on_ProfSlot_SB_valueChanged();
void on_removeProfileButton_clicked();
void on_SplashSelect_clicked();
void on_clearImageButton_clicked();

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>685</width>
<height>462</height>
<height>431</height>
</rect>
</property>
<property name="sizePolicy">
@ -493,324 +493,11 @@
<string>Radio Settings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="8" column="1" colspan="5">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_13">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Channel Order</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="1" colspan="3">
<widget class="QCheckBox" name="burnFirmware">
<property name="text">
<string>Offer to write FW to Tx after download</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="ProfName_LE">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="13" column="5">
<widget class="QPushButton" name="removeProfileButton">
<property name="text">
<string>Remove Profile</string>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="7" column="5">
<widget class="QPushButton" name="clearImageButton">
<property name="text">
<string>Clear Image</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="5">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="channelorderCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>Channel order
This is used by the templated to determine which channel goes to what number output.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string notr="true">R E T A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">R E A T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">R T E A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">R T A E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">R A E T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">R A T E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E R T A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E R A T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E T R A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E T A R</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E A R T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">E A T R</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T R E A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T R A E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T E R A</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T E A R</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T A R E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">T A E R</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A R E T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A R T E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A E R T</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A E T R</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A T R E</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">A T E R</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="sdPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="1">
<item row="10" column="1" colspan="4">
<widget class="QComboBox" name="stickmodeCB">
<property name="maximumSize">
<size>
<width>200</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
@ -860,7 +547,164 @@ Mode 4:
</item>
</widget>
</item>
<item row="9" column="0">
<item row="12" column="1" colspan="4">
<widget class="QComboBox" name="channelorderCB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="whatsThis">
<string>Channel order
This is used by the templated to determine which channel goes to what number output.</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>R E T A</string>
</property>
</item>
<item>
<property name="text">
<string>R E A T</string>
</property>
</item>
<item>
<property name="text">
<string>R T E A</string>
</property>
</item>
<item>
<property name="text">
<string>R T A E</string>
</property>
</item>
<item>
<property name="text">
<string>R A E T</string>
</property>
</item>
<item>
<property name="text">
<string>R A T E</string>
</property>
</item>
<item>
<property name="text">
<string>E R T A</string>
</property>
</item>
<item>
<property name="text">
<string>E R A T</string>
</property>
</item>
<item>
<property name="text">
<string>E T R A</string>
</property>
</item>
<item>
<property name="text">
<string>E T A R</string>
</property>
</item>
<item>
<property name="text">
<string>E A R T</string>
</property>
</item>
<item>
<property name="text">
<string>E A T R</string>
</property>
</item>
<item>
<property name="text">
<string>T R E A</string>
</property>
</item>
<item>
<property name="text">
<string>T R A E</string>
</property>
</item>
<item>
<property name="text">
<string>T E R A</string>
</property>
</item>
<item>
<property name="text">
<string>T E A R</string>
</property>
</item>
<item>
<property name="text">
<string>T A R E</string>
</property>
</item>
<item>
<property name="text">
<string>T A E R</string>
</property>
</item>
<item>
<property name="text">
<string>A R E T</string>
</property>
</item>
<item>
<property name="text">
<string>A R T E</string>
</property>
</item>
<item>
<property name="text">
<string>A E R T</string>
</property>
</item>
<item>
<property name="text">
<string>A E T R</string>
</property>
</item>
<item>
<property name="text">
<string>A T R E</string>
</property>
</item>
<item>
<property name="text">
<string>A T E R</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1" colspan="5">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@ -873,13 +717,26 @@ Mode 4:
</property>
</widget>
</item>
<item row="6" column="5">
<widget class="QPushButton" name="SplashSelect">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Select Image</string>
<string>Settings Profile</string>
</property>
</widget>
</item>
<item row="15" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
@ -893,53 +750,186 @@ Mode 4:
</property>
</widget>
</item>
<item row="12" column="1" colspan="3">
<item row="12" column="0">
<widget class="QLabel" name="label_13">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Channel Order</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="13" column="1" colspan="4">
<widget class="QCheckBox" name="renameFirmware">
<property name="text">
<string>Append version number to FW file name</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="2" column="0">
<widget class="QLabel" name="sdPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Settings Profile Name</string>
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="14" column="1">
<spacer name="verticalSpacer_3">
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="6">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Select Image</string>
</property>
</widget>
</item>
<item row="4" column="6">
<widget class="QLabel" name="imageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>64</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="ProfSlot_SB">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
<item row="14" column="1" colspan="4">
<widget class="QCheckBox" name="burnFirmware">
<property name="text">
<string>Offer to write FW to Tx after download</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<item row="14" column="6">
<widget class="QPushButton" name="removeProfileButton">
<property name="text">
<string>Profile Index</string>
<string>Remove Profile</string>
</property>
</widget>
</item>
<item row="8" column="6">
<widget class="QPushButton" name="clearImageButton">
<property name="text">
<string>Clear Image</string>
</property>
</widget>
</item>
<item row="2" column="6">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="ProfName_LE">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="9" column="1" colspan="6">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="profileIndexLE">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
@ -973,18 +963,12 @@ Mode 4:
<tabstop>joystickCB</tabstop>
<tabstop>joystickChkB</tabstop>
<tabstop>joystickcalButton</tabstop>
<tabstop>ProfName_LE</tabstop>
<tabstop>ProfSlot_SB</tabstop>
<tabstop>sdPath</tabstop>
<tabstop>sdPathButton</tabstop>
<tabstop>SplashFileName</tabstop>
<tabstop>SplashSelect</tabstop>
<tabstop>clearImageButton</tabstop>
<tabstop>stickmodeCB</tabstop>
<tabstop>channelorderCB</tabstop>
<tabstop>renameFirmware</tabstop>
<tabstop>burnFirmware</tabstop>
<tabstop>removeProfileButton</tabstop>
</tabstops>
<resources>
<include location="companion.qrc"/>

View file

@ -734,7 +734,7 @@ GeneralSettings::GeneralSettings()
QSettings settings;
templateSetup = settings.value("default_channel_order", 0).toInt();
stickMode = settings.value("default_mode", 1).toInt();
int profile_id = settings.value("ActiveProfile", 0).toInt();
int profile_id = settings.value("profileId", 0).toInt();
if (profile_id>0) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profile_id);

View file

@ -218,9 +218,6 @@ void fwPreferencesDialog::writeValues()
settings.setValue("cpu_id", ui->CPU_ID_LE->text());
current_firmware_variant = getFirmwareVariant();
settings.setValue("firmware", current_firmware_variant.id);
MainWindow * mw = (MainWindow *)this->parent();
mw->unloadProfile();
}
void fwPreferencesDialog::populateFirmwareOptions(const FirmwareInfo * firmware)

View file

@ -124,12 +124,6 @@ MainWindow::MainWindow():
updateMenus();
readSettings();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
} else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
setUnifiedTitleAndToolBarOnMac(true);
this->setWindowIcon(QIcon(":/icon.png"));
this->setIconSize(QSize(32,32));
@ -758,11 +752,10 @@ void MainWindow::loadProfile()
if (action) {
int profnum=action->data().toInt();
QSettings settings;
settings.setValue("ActiveProfile",profnum);
settings.setValue("profileId",profnum);
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(profnum);
settings.beginGroup(profile);
ActiveProfile=profnum;
ActiveProfileName=settings.value("Name", "").toString();
chord=settings.value("default_channel_order", 0).toInt();
defmod=settings.value("default_mode", 0).toInt();
@ -785,46 +778,15 @@ void MainWindow::loadProfile()
settings.setValue("SplashFileName", SplashFileName);
settings.setValue("SplashImage", SplashImage);
settings.setValue("firmware", firmware_id);
settings.setValue("profileId", profnum);
current_firmware_variant = GetFirmwareVariant(firmware_id);
FirmwareInfo *firmware = GetCurrentFirmware();
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
// settings.setValue("lastDir", QFileInfo(fileName).dir().absolutePath());
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
}
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
}
}
void MainWindow::unloadProfile()
{
ActiveProfile=0;
ActiveProfileName="";
QSettings settings;
settings.setValue("ActiveProfile", 0);
FirmwareInfo *firmware = GetCurrentFirmware();
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
void MainWindow::preferences()
{
preferencesDialog *pd = new preferencesDialog(this);
pd->exec();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
updateMenus();
}
else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
}
updateMenus();
}
void MainWindow::appPreferences()
@ -838,14 +800,6 @@ void MainWindow::fwPreferences()
{
fwPreferencesDialog *pd = new fwPreferencesDialog(this);
pd->exec();
FirmwareInfo *firmware = GetCurrentFirmware();
if (ActiveProfile) {
setWindowTitle(tr("Companion - Models and Settings Editor - %1 - profile %2").arg(firmware->name).arg(ActiveProfileName));
}
else {
setWindowTitle(tr("Companion - Models and Settings Editor - %1").arg(firmware->name));
}
foreach (QMdiSubWindow *window, mdiArea->subWindowList()) {
MdiChild *mdiChild = qobject_cast<MdiChild *>(window->widget());
mdiChild->eepromInterfaceChanged();
@ -1640,19 +1594,9 @@ void MainWindow::updateMenus()
compareAct->setEnabled(activeMdiChild());
updateRecentFileActions();
updateProfilesActions();
bool notfound=true;
QSettings settings;
settings.beginGroup("Profiles");
for (int i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) {
notfound=false;
}
settings.endGroup();
}
profileButton->setDisabled(notfound);
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->name).arg(settings.value("profileId").toString()));
}
MdiChild *MainWindow::createMdiChild()
@ -2015,8 +1959,12 @@ QMenu *MainWindow::createRecentFileMenu()
QMenu *MainWindow::createProfilesMenu()
{
QMenu *profilesMenu=new QMenu(tr("Radio Settings Profiles"));
for ( int i = 0; i < MAX_PROFILES; ++i)
int i;
for ( i = 0; i < MAX_PROFILES; ++i) {
profilesMenu->addAction(profileActs[i]);
}
if ( i>0 )
profilesMenu->addSeparator();
profilesMenu->addAction(createProfileAct);
profilesMenu->setIcon(CompanionIcon("profiles.png"));
return profilesMenu;
@ -2034,11 +1982,14 @@ void MainWindow::createToolBars()
case 1:
size=QSize(24,24);
break;
case 2:
size=QSize(32,32);
break;
case 3:
size=QSize(48,48);
break;
default:
size=QSize(32,32);
size=QSize(24,24);
break;
}
fileToolBar = addToolBar(tr("File"));
@ -2046,11 +1997,11 @@ void MainWindow::createToolBars()
fileToolBar->setObjectName("File");
fileToolBar->addAction(newAct);
fileToolBar->addAction(openAct);
QToolButton * recentToolButton = new QToolButton;
recentToolButton->setPopupMode(QToolButton::InstantPopup);
recentToolButton->setMenu(createRecentFileMenu());
recentToolButton->setIcon(CompanionIcon("recentdocument.png"));
recentToolButton->setToolTip(tr("Recent Files"));
QToolButton * recentToolButton = new QToolButton;
recentToolButton->setPopupMode(QToolButton::InstantPopup);
recentToolButton->setMenu(createRecentFileMenu());
recentToolButton->setIcon(CompanionIcon("recentdocument.png"));
recentToolButton->setToolTip(tr("Recent Files"));
fileToolBar->addWidget(recentToolButton);
fileToolBar->addAction(saveAct);
fileToolBar->addAction(logsAct);
@ -2058,24 +2009,12 @@ void MainWindow::createToolBars()
fileToolBar->addAction(appPreferencesAct);
fileToolBar->addAction(fwPreferencesAct);
fileToolBar->addAction(customizeSplashAct);
profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu());
profileButton->setIcon(CompanionIcon("profiles.png"));
profileButton->setToolTip(tr("Firmware Profiles"));
profileButton = new QToolButton;
profileButton->setPopupMode(QToolButton::InstantPopup);
profileButton->setMenu(createProfilesMenu());
profileButton->setIcon(CompanionIcon("profiles.png"));
profileButton->setToolTip(tr("Firmware Profiles"));
fileToolBar->addWidget(profileButton);
bool notfound=true;
settings.beginGroup("Profiles");
for (int i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
settings.beginGroup(profile);
QString name=settings.value("Name","").toString();
if (!name.isEmpty()) {
notfound=false;
}
settings.endGroup();
}
profileButton->setDisabled(notfound);
fileToolBar->addSeparator();
fileToolBar->addAction(simulateAct);
fileToolBar->addAction(printAct);
@ -2087,7 +2026,6 @@ void MainWindow::createToolBars()
editToolBar->addAction(cutAct);
editToolBar->addAction(copyAct);
editToolBar->addAction(pasteAct);
burnToolBar = new QToolBar(tr("Write"));
addToolBar( Qt::LeftToolBarArea, burnToolBar );
@ -2123,15 +2061,18 @@ void MainWindow::readSettings()
checkCompanion9x = settings.value("startup_check_companion", true).toBool();
checkFW = settings.value("startup_check_fw", true).toBool();
MaxRecentFiles =settings.value("history_size",10).toInt();
ActiveProfile=settings.value("activeprofile",0).toInt();
if (ActiveProfile) {
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(ActiveProfile);
settings.beginGroup(profile);
ActiveProfileName=settings.value("Name","").toString();
settings.endGroup();
settings.endGroup();
if (settings.value("profileId",0).toInt() == 0)
{
createProfile();
settings.setValue("profileId", "1");
}
int activeProfile=settings.value("profileId",0).toInt();
settings.beginGroup("Profiles");
QString profile=QString("profile%1").arg(activeProfile);
settings.beginGroup(profile);
ActiveProfileName=settings.value("Name","").toString();
settings.endGroup();
settings.endGroup();
}
MdiChild *MainWindow::activeMdiChild()
@ -2184,6 +2125,8 @@ void MainWindow::updateProfilesActions()
{
int i;
QSettings settings;
int activeProfile = settings.value("profileId").toInt();
settings.beginGroup("Profiles");
for (i=0; i<MAX_PROFILES; i++) {
QString profile=QString("profile%1").arg(i+1);
@ -2194,6 +2137,11 @@ void MainWindow::updateProfilesActions()
profileActs[i]->setText(text);
profileActs[i]->setData(i+1);
profileActs[i]->setVisible(true);
if ((i+1) == activeProfile)
profileActs[i]->setIcon(CompanionIcon("arrow-right.png"));
else
profileActs[i]->setIcon(CompanionIcon(""));
} else {
profileActs[i]->setVisible(false);
}

View file

@ -63,7 +63,6 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
friend class preferencesDialog;
friend class fwPreferencesDialog;
friend class MdiChild; // TODO GetAvrdudeArgs could be external to this class
@ -80,7 +79,6 @@ protected:
public slots:
void downloadLatestFW(FirmwareInfo *firmware, const QString & firmwareId);
void unloadProfile();
private slots:
void openDocumentURL();
@ -146,7 +144,6 @@ private slots:
void compare();
void print();
void loadBackup();
void preferences();
void appPreferences();
void fwPreferences();
void updateMenus();
@ -200,7 +197,7 @@ private:
bool needRename;
bool showcheckForUpdatesResult;
int MaxRecentFiles;
int ActiveProfile;
// int ActiveProfile;
int currentFWrev;
int currentFWrev_temp;
int NewFwRev;