chore(cpn): Increase number of profiles that can be created (#4373)

This commit is contained in:
philmoz
2023-12-06 10:45:24 +10:00
committed by GitHub
parent 8e8feca046
commit 5d8ffcc244
5 changed files with 231 additions and 178 deletions
+2
View File
@@ -76,6 +76,7 @@ void AppPreferencesDialog::accept()
Profile & profile = g.currentProfile();
g.showSplash(ui->showSplash->isChecked());
g.sortProfiles(ui->sortProfiles->isChecked());
g.promptProfile(ui->chkPromptProfile->isChecked());
g.simuSW(ui->simuSW->isChecked());
g.disableJoystickWarning(ui->joystickWarningCB->isChecked());
@@ -232,6 +233,7 @@ void AppPreferencesDialog::initSettings()
}
ui->showSplash->setChecked(g.showSplash());
ui->sortProfiles->setChecked(g.sortProfiles());
ui->chkPromptProfile->setChecked(g.promptProfile());
ui->historySize->setValue(g.historySize());
ui->backLightColor->setCurrentIndex(g.backLight());
+194 -173
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>865</width>
<height>692</height>
<height>703</height>
</rect>
</property>
<property name="sizePolicy">
@@ -45,7 +45,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="profileTab">
<attribute name="title">
@@ -748,10 +748,120 @@ Mode 4:
<property name="spacing">
<number>6</number>
</property>
<item row="11" column="0" rowspan="2" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remember</string>
</property>
</widget>
</item>
<item row="26" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
<item row="26" column="1">
<widget class="QCheckBox" name="chkPromptInstall">
<property name="text">
<string>Prompt to run installer after update</string>
</property>
</widget>
</item>
<item row="22" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLineEdit" name="ge_lineedit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ge_pathButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select Executable</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="24" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="opt_appDebugLog">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Keep a log of all debugging messages generated by the desktop Companion/Simulator applications. An EdgeTX developer may request this to help diagnose an issue.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Application (Companion/Simulator)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_fwTraceLog">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Keep a log of all messages generated by the radio firmware when running in Simulator. This is the same information one would also see in the Simulator &lt;span style=&quot; font-style:italic;&quot;&gt;Debug Output&lt;/span&gt; window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Radio Firmware (in Simulator)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="22" column="0">
<widget class="QLabel" name="ge_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Google Earth Executable</string>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Debug Output Logging</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="cboNewModelAction"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatic Backup Folder</string>
</property>
</widget>
</item>
@@ -779,97 +889,14 @@ Mode 4:
</item>
</layout>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatic Backup Folder</string>
<item row="11" column="0" rowspan="2" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QComboBox" name="cboNewModelAction"/>
</item>
<item row="23" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Debug Output Logging</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="ge_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Google Earth Executable</string>
</property>
</widget>
</item>
<item row="23" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="opt_appDebugLog">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Keep a log of all debugging messages generated by the desktop Companion/Simulator applications. An EdgeTX developer may request this to help diagnose an issue.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Application (Companion/Simulator)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_fwTraceLog">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Keep a log of all messages generated by the radio firmware when running in Simulator. This is the same information one would also see in the Simulator &lt;span style=&quot; font-style:italic;&quot;&gt;Debug Output&lt;/span&gt; window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Radio Firmware (in Simulator)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="21" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QLineEdit" name="ge_lineedit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="ge_pathButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Select Executable</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="19" column="0" rowspan="2" colspan="2">
<item row="20" column="0" rowspan="2" colspan="2">
<widget class="Line" name="line_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -883,14 +910,14 @@ Mode 4:
</property>
</widget>
</item>
<item row="15" column="0" rowspan="2" colspan="2">
<item row="16" column="0" rowspan="2" colspan="2">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="24" column="0">
<item row="25" column="0">
<widget class="QLabel" name="lbl_appLogsDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
@@ -913,14 +940,7 @@ Mode 4:
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="chkPromptProfile">
<property name="text">
<string>Prompt for radio profile</string>
</property>
</widget>
</item>
<item row="17" column="1">
<item row="18" column="1">
<widget class="QComboBox" name="splashincludeCB">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -940,43 +960,7 @@ Mode 4:
</item>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="opt_removeBlankSlots">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option maintains the behaviour from older OpenTx versions where empty model slots are preserved when a model is deleted or moved. &lt;/p&gt;&lt;p&gt;When this option is de-selected, the other models may be re-arranged to fill the gap left by the removed model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Remove empty model slots when deleting models (only applies for radios w/out labels)</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>User Splash Screens</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Action on New Model</string>
</property>
</widget>
</item>
<item row="18" column="1">
<item row="19" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLineEdit" name="libraryPath">
@@ -1003,6 +987,52 @@ Mode 4:
</item>
</layout>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Action on New Model</string>
</property>
</widget>
</item>
<item row="19" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>User Splash Screens</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="backupEnable">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Enable automatic backup before writing firmware</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="chkPromptProfile">
<property name="text">
<string>Prompt for radio profile</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_10" stretch="0,1">
<property name="spacing">
@@ -1039,7 +1069,7 @@ Mode 4:
</item>
</layout>
</item>
<item row="17" column="0">
<item row="18" column="0">
<widget class="QLabel" name="label_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
@@ -1065,14 +1095,24 @@ Mode 4:
</property>
</widget>
</item>
<item row="22" column="0" colspan="2">
<item row="23" column="0" colspan="2">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="24" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="opt_removeBlankSlots">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This option maintains the behaviour from older OpenTx versions where empty model slots are preserved when a model is deleted or moved. &lt;/p&gt;&lt;p&gt;When this option is de-selected, the other models may be re-arranged to fill the gap left by the removed model.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Remove empty model slots when deleting models (only applies for radios w/out labels)</string>
</property>
</widget>
</item>
<item row="25" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="appLogsDir">
@@ -1093,43 +1133,24 @@ Mode 4:
</item>
</layout>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="backupEnable">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="28" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Enable automatic backup before writing firmware</string>
<string>Radio Profiles</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="28" column="1">
<widget class="QCheckBox" name="sortProfiles">
<property name="text">
<string>Remember</string>
<string>Move selected Radio Profile to the top of the list</string>
</property>
</widget>
</item>
<item row="25" column="1">
<widget class="QCheckBox" name="chkPromptInstall">
<property name="text">
<string>Prompt to run installer after update</string>
</property>
</widget>
</item>
<item row="25" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Update</string>
<item row="27" column="0" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
+13 -4
View File
@@ -1248,6 +1248,7 @@ void MainWindow::onChangeWindowAction(QAction * act)
void MainWindow::onCurrentProfileChanged()
{
g.moveCurrentProfileToTop();
Firmware::setCurrentVariant(Firmware::getFirmwareForId(g.currentProfile().fwType()));
emit firmwareChanged();
QApplication::clipboard()->clear();
@@ -1259,8 +1260,10 @@ int MainWindow::newProfile(bool loadProfile)
int i;
for (i=0; i < MAX_PROFILES && g.profile[i].existsOnDisk(); i++)
;
if (i == MAX_PROFILES) //Failed to find free slot
if (i == MAX_PROFILES) { //Failed to find free slot
QMessageBox::warning(this, tr("Cannot add profile"), tr("There is no space left to add a new profile. Delete an exsting profile before adding a new one."));
return -1;
}
Firmware *newfw = Firmware::getDefaultVariant();
g.profile[i].init();
@@ -1300,9 +1303,14 @@ void MainWindow::deleteProfile(const int pid)
QMessageBox::warning(this, tr("Companion :: Open files warning"), tr("Please save or close modified file(s) before deleting the active profile."));
return;
}
int newPid = 0;
if (pid == 0) {
QMessageBox::warning(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
return;
// Find valid profile
for (newPid = 1; newPid < MAX_PROFILES && !g.profile[newPid].existsOnDisk(); newPid += 1);
if (newPid == MAX_PROFILES) {
QMessageBox::warning(this, tr("Not possible to remove profile"), tr("The default profile can not be removed."));
return;
}
}
int ret = QMessageBox::question(this,
tr("Confirm Delete Profile"),
@@ -1311,7 +1319,8 @@ void MainWindow::deleteProfile(const int pid)
return;
g.getProfile(pid).resetAll();
loadProfileId(0);
loadProfileId(newPid);
g.moveCurrentProfileToTop();
}
void MainWindow::deleteCurrentProfile()
+17
View File
@@ -304,6 +304,11 @@ Profile::Profile() : CompStoreObj(), index(-1)
CompStoreObj::addObjectMapping(propertyGroup(), this);
}
Profile::Profile(const Profile & rhs) : CompStoreObj(), index(-1)
{
*this = rhs;
}
// The default copy operator can not be used since the index variable would be destroyed
Profile & Profile::operator= (const Profile & rhs)
{
@@ -661,6 +666,18 @@ QMap<int, QString> AppData::getActiveProfiles() const
return active;
}
void AppData::moveCurrentProfileToTop()
{
if (g.sortProfiles() && m_sessionId > 0) {
Profile tmpProfile(g.profile[m_sessionId]);
for (int i = m_sessionId; i > 0; i -= 1) {
g.profile[i] = g.profile[i - 1];
}
g.profile[0] = tmpProfile;
id(0);
}
}
void AppData::convertSettings(QSettings & settings)
{
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
+5 -1
View File
@@ -58,7 +58,7 @@
#define CPN_SETTINGS_INI_FILE QString(PRODUCT % " " % QCoreApplication::translate("Companion", "settings") % " %1.ini")
#define CPN_SETTINGS_INI_PATH QString(CPN_SETTINGS_BACKUP_DIR % "/" % CPN_SETTINGS_INI_FILE)
#define MAX_PROFILES 20
#define MAX_PROFILES 32
#define MAX_JS_AXES 10
#define MAX_JS_BUTTONS 32
#define MAX_COMPONENTS 10
@@ -472,6 +472,7 @@ class Profile: public CompStoreObj
protected:
explicit Profile();
explicit Profile(const Profile & rhs);
void setIndex(int idx) { index = idx; }
inline QString propertyGroup() const override { return QStringLiteral("Profiles"); }
inline QString settingsPath() const override { return QString("%1/profile%2/").arg(propertyGroup()).arg(index); }
@@ -685,6 +686,8 @@ class AppData: public CompStoreObj
const Profile & getProfile(int index) const;
//! List of all active profiles mapped by index.
QMap<int, QString> getActiveProfiles() const;
// Move the currently selected profile to the top of the list
void moveCurrentProfileToTop();
//! Get a modifiable (non-const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
ComponentData & getComponent(int index);
@@ -791,6 +794,7 @@ class AppData: public CompStoreObj
PROPERTY4(bool, jsSupport, "js_support", false)
PROPERTY4(bool, showSplash, "show_splash", true)
PROPERTY4(bool, sortProfiles, "sort_profiles", false)
PROPERTY4(bool, snapToClpbrd, "snapshot_to_clipboard", false)
PROPERTY(UpdateCheckFreq, updateCheckFreq, UPDATE_CHECK_MANUAL)