feat(cpn): reorganise and refactor Edit Settings (Profile/Application/Simulator/Update) dialog (#7623)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
|
||||
project(prefsedit)
|
||||
|
||||
set(${PROJECT_NAME}_NAMES
|
||||
prefs_panel
|
||||
prefs_edit
|
||||
prefs_app
|
||||
prefs_profile
|
||||
prefs_simu
|
||||
prefs_update
|
||||
)
|
||||
|
||||
AddHeadersSources()
|
||||
|
||||
add_library(${PROJECT_NAME}
|
||||
${${PROJECT_NAME}_HDRS}
|
||||
${${PROJECT_NAME}_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${CPN_COMMON_LIB}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_LIST_DIR}"
|
||||
)
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_app.h"
|
||||
#include "ui_prefs_app.h"
|
||||
#include "appdata.h"
|
||||
|
||||
PrefsAppPanel::PrefsAppPanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof) :
|
||||
PrefsPanel(parent, fw, bd, prof),
|
||||
ui(new Ui::PrefsApp)
|
||||
{
|
||||
lock = true;
|
||||
ui->setupUi(this);
|
||||
|
||||
sectionGeneral();
|
||||
sectionRadioProfiles();
|
||||
sectionFolders();
|
||||
sectionLogging();
|
||||
sectionGoogleEarth();
|
||||
sectionSplashScreens();
|
||||
|
||||
update();
|
||||
shrink();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
PrefsAppPanel::~PrefsAppPanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefsAppPanel::save()
|
||||
{
|
||||
AbstractPanel::save();
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionFolders()
|
||||
{
|
||||
QGridLayout *layFolders = ui->csectFolders->start(tr("Folders"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblBackupsPath = new AutoLabel(this, tr("Backups"));
|
||||
layFolders->addWidget(lblBackupsPath, row, col++);
|
||||
|
||||
leBackupsPath = newPathWidget(this);
|
||||
leBackupsPath->setValue(g.backupDir());
|
||||
leBackupsPath->setBindSave([this] {
|
||||
g.backupDir(this->leBackupsPath->text());
|
||||
});
|
||||
layFolders->addWidget(leBackupsPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnBackupsPath = new AutoDirectorySelectButton(this);
|
||||
btnBackupsPath->setup(tr("Select backups folder"), g.backupDir(), leBackupsPath);;
|
||||
layFolders->addWidget(btnBackupsPath, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblLogsPath = new AutoLabel(this, tr("Logs"));
|
||||
layFolders->addWidget(lblLogsPath, row, col++);
|
||||
|
||||
leLogsPath = newPathWidget(this);
|
||||
leLogsPath->setValue(g.logDir());
|
||||
leLogsPath->setBindSave([this] {
|
||||
g.logDir(this->leLogsPath->text());
|
||||
});
|
||||
layFolders->addWidget(leLogsPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnLogsPath = new AutoDirectorySelectButton(this);
|
||||
btnLogsPath->setup(tr("Select logs folder"), g.logDir(), leLogsPath);;
|
||||
layFolders->addWidget(btnLogsPath, row, col++);
|
||||
|
||||
/* TODO implement
|
||||
++row; col = 0;
|
||||
AutoLabel *lblSDPath = new AutoLabel(this, tr("Models"));
|
||||
layFolders->addWidget(lblSDPath, row, col++);
|
||||
|
||||
leModelsPath = newPathWidget(this);
|
||||
leModelsPath->setValue(g.modelsDir());
|
||||
leModelsPath->setBindSave([this] {
|
||||
g.modelsDir(this->leModelsPath->text());
|
||||
});
|
||||
layFolders->addWidget(leModelsPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnModelsPath = new AutoDirectorySelectButton(this);
|
||||
btnModelsPath->setup(tr("Select models folder"), g.modelsDir(), leModelsPath);;
|
||||
layFolders->addWidget(btnModelsPath, row, col++);
|
||||
*/
|
||||
|
||||
ui->csectFolders->finish(-1, -1, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionGeneral()
|
||||
{
|
||||
QGridLayout *layGeneral = ui->csectGeneral->start(tr("General"));
|
||||
row = col = 0;
|
||||
AutoLabel *lblShowSplash = new AutoLabel(this, tr("Show splash screen"));
|
||||
layGeneral->addWidget(lblShowSplash, row, col++);
|
||||
chkSplash = new AutoCheckBox(this);
|
||||
chkSplash->setValue(g.showSplash());
|
||||
chkSplash->setBindSave([this] {
|
||||
g.showSplash(this->chkSplash->isChecked());
|
||||
});
|
||||
layGeneral->addWidget(chkSplash, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblProfPrmpt = new AutoLabel(this, tr("Prompt for radio profile on startup"));
|
||||
layGeneral->addWidget(lblProfPrmpt, row, col++);
|
||||
chkProfPrmpt = new AutoCheckBox(this);
|
||||
chkProfPrmpt->setValue(g.promptProfile());
|
||||
chkProfPrmpt->setBindSave([this] {
|
||||
g.promptProfile(this->chkProfPrmpt->isChecked());
|
||||
});
|
||||
layGeneral->addWidget(chkProfPrmpt, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblRecentFiles = new AutoLabel(this, tr("Most recently used files"));
|
||||
layGeneral->addWidget(lblRecentFiles, row, col++);
|
||||
sbxRecentFiles = new AutoSpinBox(this);
|
||||
sbxRecentFiles->setRange(1, 50);
|
||||
sbxRecentFiles->setValue(g.historySize());
|
||||
sbxRecentFiles->setBindSave([this] {
|
||||
g.historySize(this->sbxRecentFiles->value());
|
||||
});
|
||||
layGeneral->addWidget(sbxRecentFiles, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblModelNew = new AutoLabel(this, tr("New models action"));
|
||||
layGeneral->addWidget(lblModelNew, row, col++);
|
||||
cboModelNew = new AutoComboBox(this);
|
||||
cboModelNew->addItems(AppData::newModelActionsList());
|
||||
cboModelNew->setValue((int)g.newModelAction());
|
||||
cboModelNew->setBindSave([this] {
|
||||
g.newModelAction((AppData::NewModelAction)this->cboModelNew->currentData().toInt());
|
||||
});
|
||||
layGeneral->addWidget(cboModelNew, row, col++);
|
||||
|
||||
// TODO implement profile level setting as override
|
||||
++row; col = 0;
|
||||
AutoLabel *lblModelDelete = new AutoLabel(this, tr("B&W remove empty slot on delete)"));
|
||||
layGeneral->addWidget(lblModelDelete, row, col++);
|
||||
chkModelDelete = new AutoCheckBox(this);
|
||||
chkModelDelete->setValue(g.removeModelSlots());
|
||||
chkModelDelete->setBindSave([this] {
|
||||
g.removeModelSlots(this->chkModelDelete->isChecked());
|
||||
});
|
||||
layGeneral->addWidget(chkModelDelete, row, col++);
|
||||
ui->csectGeneral->finish(row, col, [this] { this->shrink(); }, true);
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionGoogleEarth()
|
||||
{
|
||||
QGridLayout *layGoogle = ui->csectGoogleEarth->start(tr("Google Earth"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblGoogleExe = new AutoLabel(this, tr("Executable"));
|
||||
layGoogle->addWidget(lblGoogleExe, row, col++);
|
||||
|
||||
leGoogleExe = newPathWidget(this);
|
||||
leGoogleExe->setValue(g.gePath());
|
||||
leGoogleExe->setBindSave([this] {
|
||||
g.gePath(this->leGoogleExe->text());
|
||||
});
|
||||
layGoogle->addWidget(leGoogleExe, row, col++);
|
||||
|
||||
AutoFileSelectButton *btnGoogleExe = new AutoFileSelectButton(this);
|
||||
btnGoogleExe->setup(tr("Select Google Earth executable"), g.gePath(), "", leGoogleExe);;
|
||||
layGoogle->addWidget(btnGoogleExe, row, col++);
|
||||
|
||||
ui->csectGoogleEarth->finish(-1, -1, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionLogging()
|
||||
{
|
||||
QGridLayout *layLogging = ui->csectLogging->start(tr("Logging"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblLogApp = new AutoLabel(this, tr("Application (Companion/Simulator)"));
|
||||
layLogging->addWidget(lblLogApp, row, col++);
|
||||
|
||||
chkLogApp = new AutoCheckBox(this);
|
||||
chkLogApp->setValue(g.appDebugLog());
|
||||
chkLogApp->setBindSave([this] {
|
||||
g.appDebugLog(this->chkLogApp->isChecked());
|
||||
});
|
||||
layLogging->addWidget(chkLogApp, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblLogFW = new AutoLabel(this, tr("Radio Firmware (in Simulator)"));
|
||||
layLogging->addWidget(lblLogFW, row, col++);
|
||||
|
||||
chkLogFW = new AutoCheckBox(this);
|
||||
chkLogFW->setValue(g.fwTraceLog());
|
||||
chkLogFW->setBindSave([this] {
|
||||
g.fwTraceLog(this->chkLogFW->isChecked());
|
||||
});
|
||||
layLogging->addWidget(chkLogFW, row, col++);
|
||||
|
||||
ui->csectLogging->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionRadioProfiles()
|
||||
{
|
||||
QGridLayout *layProfiles = ui->csectProfiles->start(tr("Radio Profiles"));
|
||||
row = col = 0;
|
||||
|
||||
chkProfileTop = new AutoCheckBox(this, tr("Move selected profile to the top of the list"));
|
||||
chkProfileTop->setValue(g.sortProfiles());
|
||||
chkProfileTop->setBindSave([this] {
|
||||
g.sortProfiles(this->chkProfileTop->isChecked());
|
||||
});
|
||||
layProfiles->addWidget(chkProfileTop, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
chkBackupFirmware = new AutoCheckBox(this, tr("Prompt to backup current firmware before flashing new firmware"));
|
||||
chkBackupFirmware->setValue(g.enableBackup());
|
||||
chkBackupFirmware->setBindSave([this] {
|
||||
g.enableBackup(this->chkBackupFirmware->isChecked());
|
||||
});
|
||||
layProfiles->addWidget(chkBackupFirmware, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
chkUseSavedSettings = new AutoCheckBox(this, tr("Use radio settings backup for new models and settings files"));
|
||||
chkUseSavedSettings->setValue(g.useSavedSettings());
|
||||
chkUseSavedSettings->setBindSave([this] {
|
||||
g.useSavedSettings(this->chkUseSavedSettings->isChecked());
|
||||
});
|
||||
layProfiles->addWidget(chkUseSavedSettings, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
chkConfirmDeleteWrite = new AutoCheckBox(this, tr("Do not prompt to delete exisiting models on write to radio or SD path"));
|
||||
chkConfirmDeleteWrite->setValue(g.confirmWriteModelsAndSettings());
|
||||
chkConfirmDeleteWrite->setBindSave([this] {
|
||||
g.confirmWriteModelsAndSettings(this->chkConfirmDeleteWrite->isChecked());
|
||||
});
|
||||
layProfiles->addWidget(chkConfirmDeleteWrite, row, col++);
|
||||
|
||||
ui->csectProfiles->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsAppPanel::sectionSplashScreens()
|
||||
{
|
||||
QGridLayout *laySplash = ui->csectSplash->start(tr("Splash Screens (B&&W radios)"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblSplashLibraries = new AutoLabel(this, tr("Libraries"));
|
||||
laySplash->addWidget(lblSplashLibraries, row, col++);
|
||||
|
||||
cboSplashLibraries = new AutoComboBox(this);
|
||||
cboSplashLibraries->addItems(AppData::splashLibsList());
|
||||
cboSplashLibraries->setValue(g.embedSplashes());
|
||||
cboSplashLibraries->setBindSave([this] {
|
||||
g.embedSplashes(this->cboSplashLibraries->currentData().toInt());
|
||||
});
|
||||
laySplash->addWidget(cboSplashLibraries, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblSplashUserPath = new AutoLabel(this, tr("User folder"));
|
||||
laySplash->addWidget(lblSplashUserPath, row, col++);
|
||||
|
||||
leSplashUserPath = newPathWidget(this);
|
||||
leSplashUserPath->setValue(g.libDir());
|
||||
leSplashUserPath->setBindSave([this] {
|
||||
g.libDir(this->leSplashUserPath->text());
|
||||
});
|
||||
laySplash->addWidget(leSplashUserPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnSplashUser = new AutoDirectorySelectButton(this);
|
||||
btnSplashUser->setup(tr("Select user splash folder"), g.libDir(), leSplashUserPath);;
|
||||
laySplash->addWidget(btnSplashUser, row, col++);
|
||||
|
||||
ui->csectSplash->finish(-1, -1, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsAppPanel::update()
|
||||
{
|
||||
AbstractPanel::update();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "prefs_edit.h"
|
||||
|
||||
namespace Ui {
|
||||
class PrefsApp;
|
||||
}
|
||||
|
||||
class PrefsAppPanel : public PrefsPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrefsAppPanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof);
|
||||
virtual ~PrefsAppPanel();
|
||||
|
||||
virtual void save() override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
Ui::PrefsApp * ui;
|
||||
|
||||
AutoCheckBox *chkSplash;
|
||||
AutoCheckBox *chkProfPrmpt;
|
||||
AutoSpinBox *sbxRecentFiles;
|
||||
AutoComboBox *cboModelNew;
|
||||
AutoCheckBox *chkModelDelete;
|
||||
AutoCheckBox *chkProfileTop;
|
||||
AutoCheckBox *chkBackupFirmware;
|
||||
AutoCheckBox *chkUseSavedSettings;
|
||||
AutoCheckBox *chkConfirmDeleteWrite;
|
||||
AutoLineEdit *leModelsPath;
|
||||
AutoLineEdit *leBackupsPath;
|
||||
AutoLineEdit *leLogsPath;
|
||||
AutoCheckBox *chkLogApp;
|
||||
AutoCheckBox *chkLogFW;
|
||||
AutoComboBox *cboLogLevel;
|
||||
AutoCheckBox *chkLogVerbose;
|
||||
AutoLineEdit *leGoogleExe;
|
||||
AutoComboBox *cboSplashLibraries;
|
||||
AutoLineEdit *leSplashUserPath;
|
||||
|
||||
void sectionFolders();
|
||||
void sectionGeneral();
|
||||
void sectionGoogleEarth();
|
||||
void sectionLogging();
|
||||
void sectionRadioProfiles();
|
||||
void sectionSplashScreens();
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefsApp</class>
|
||||
<widget class="QWidget" name="PrefsApp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>648</width>
|
||||
<height>132</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectGeneral" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectProfiles" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectFolders" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectLogging" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectGoogleEarth" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectSplash" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AutoCollapsibleSection</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>autocollapsiblesection.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_edit.h"
|
||||
#include "prefs_profile.h"
|
||||
#include "prefs_app.h"
|
||||
#include "prefs_simu.h"
|
||||
#include "prefs_update.h"
|
||||
#include "ui_prefs_edit.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
PrefsEditDialog::PrefsEditDialog(QWidget * parent, UpdateFactories * factories) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::PrefsEdit),
|
||||
mainWinHasDirtyChild(false),
|
||||
firmware(getCurrentFirmware()),
|
||||
board(getCurrentBoard()),
|
||||
profile(g.currentProfile()),
|
||||
dirty(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowIcon(CompanionIcon("apppreferences.png"));
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
PrefsProfilePanel *prefsProfPanel = new PrefsProfilePanel(this, firmware, board, profile);
|
||||
addTab(prefsProfPanel, tr("Radio Profile"));
|
||||
connect(prefsProfPanel, &PrefsProfilePanel::radioChanged, this, &PrefsEditDialog::onRadioChanged);
|
||||
|
||||
addTab(new PrefsAppPanel(this, firmware, board, profile), tr("Application"));
|
||||
addTab(new PrefsSimuPanel(this, firmware, board, profile), tr("Simulator"));
|
||||
|
||||
PrefsUpdatePanel *prefsUpdatePanel = new PrefsUpdatePanel(this, firmware, board, profile, factories);
|
||||
addTab(prefsUpdatePanel, tr("Update"));
|
||||
|
||||
connect(prefsProfPanel, &PrefsProfilePanel::sdPathChanged, prefsUpdatePanel, &PrefsUpdatePanel::onSDPathChanged);
|
||||
|
||||
bool hasSavedGeo = restoreGeometry(g.prefsEditGeo());
|
||||
|
||||
if (!hasSavedGeo)
|
||||
shrink();
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
PrefsEditDialog::~PrefsEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefsEditDialog::accept()
|
||||
{
|
||||
if (!save())
|
||||
return;
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void PrefsEditDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!maybeSave())
|
||||
return;
|
||||
|
||||
QDialog::closeEvent(event);
|
||||
}
|
||||
|
||||
void PrefsEditDialog::reject()
|
||||
{
|
||||
if (!maybeSave())
|
||||
return;
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
PrefsPanel * PrefsEditDialog::addTab(PrefsPanel * panel, QString text)
|
||||
{
|
||||
panels << panel;
|
||||
PrefsScrollArea *scrollArea = new PrefsScrollArea(ui->tabWidget, panel);
|
||||
ui->tabWidget->addTab(scrollArea, text);
|
||||
connect(panel, &PrefsPanel::modified, this, [this] { this->dirty = true; });
|
||||
return panel;
|
||||
}
|
||||
|
||||
void PrefsEditDialog::done(int r)
|
||||
{
|
||||
if (!isMaximized())
|
||||
g.prefsEditGeo(saveGeometry());
|
||||
|
||||
QDialog::done(r);
|
||||
}
|
||||
|
||||
bool PrefsEditDialog::maybeSave()
|
||||
{
|
||||
if (dirty) {
|
||||
int ret = QMessageBox::question(this, tr("Edit Preferences"),
|
||||
tr("Preferences have been modified.\nDo you want to save your changes?"),
|
||||
(QMessageBox::Save | QMessageBox::Discard), QMessageBox::Save);
|
||||
|
||||
if (ret == QMessageBox::Save)
|
||||
return save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrefsEditDialog::save()
|
||||
{
|
||||
if (dirty) {
|
||||
bool fwchange = false;
|
||||
// If a new fw type has been choosen, several things need to reset
|
||||
if (getCurrentFirmware()->getFirmwareBase()->getId() != firmware->getFirmwareBase()->getId()) {
|
||||
// check if we're going to be converting to a new radio type and there are unsaved files in the main window
|
||||
if (mainWinHasDirtyChild && !Boards::isBoardCompatible(getCurrentBoard(), firmware->getBoard())) {
|
||||
QString q = tr("<p><b>You cannot change Radio Types while there are unsaved model file changes. What do you wish to do?</b></p> <ul>" \
|
||||
"<li><i>Save All</i> - save all open model file(s) before saving preferences.<li>" \
|
||||
"<li><i>Reset</i> - revert Radio Type and Build Options before saving all other preferences.</li>" \
|
||||
"<li><i>Cancel</i> - return to the editing preferences.</li></ul>");
|
||||
int resp = QMessageBox::question(this, windowTitle(), q, (QMessageBox::SaveAll | QMessageBox::Reset | QMessageBox::Cancel), QMessageBox::Cancel);
|
||||
if (resp == QMessageBox::SaveAll) {
|
||||
// signal main window to save files
|
||||
// need to do this before the current firmware actually changes
|
||||
emit profileFirmwareAboutToChange();
|
||||
fwchange = true;
|
||||
} else if (resp == QMessageBox::Reset) {
|
||||
// reset firmware to that at time of dialog ctor
|
||||
onRadioChanged(getCurrentFirmware());
|
||||
} else {
|
||||
// we do not accept the dialog close
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
fwchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
// save preferences for every tab
|
||||
for (const auto panel : panels)
|
||||
panel->save();
|
||||
|
||||
// prevent re-prompting
|
||||
dirty = false;
|
||||
|
||||
hide();
|
||||
|
||||
if (fwchange) {
|
||||
// do not keep incompatible backup settings
|
||||
profile.generalSettings(QByteArray());
|
||||
profile.timeStamp(QString());
|
||||
// used by flash firmware so no longer applicable
|
||||
profile.fwName(QString());
|
||||
emit profileFirmwareChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrefsEditDialog::setMainWinHasDirtyChild(bool value)
|
||||
{
|
||||
mainWinHasDirtyChild = value;
|
||||
}
|
||||
|
||||
void PrefsEditDialog::shrink()
|
||||
{
|
||||
// adjustSize() only accounts for the currently visible tab, since
|
||||
// QStackedWidget doesn't lay out hidden pages. Walk every tab once so
|
||||
// each panel reports its real size hint, and size the dialog to fit
|
||||
// the largest one so switching tabs later doesn't resize the window.
|
||||
QSize maxHint;
|
||||
const int current = ui->tabWidget->currentIndex();
|
||||
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
ui->tabWidget->setCurrentIndex(i);
|
||||
ui->tabWidget->currentWidget()->adjustSize();
|
||||
maxHint = maxHint.expandedTo(ui->tabWidget->currentWidget()->sizeHint());
|
||||
}
|
||||
|
||||
ui->tabWidget->setCurrentIndex(current);
|
||||
adjustSize();
|
||||
resize(maxHint.expandedTo(size()));
|
||||
}
|
||||
|
||||
void PrefsEditDialog::onRadioChanged(Firmware * newFirmware)
|
||||
{
|
||||
firmware = newFirmware;
|
||||
|
||||
for (const auto panel : panels)
|
||||
panel->onRadioChanged(firmware);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "prefs_panel.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class Firmware;
|
||||
class UpdateFactories;
|
||||
|
||||
namespace Ui {
|
||||
class PrefsEdit;
|
||||
}
|
||||
|
||||
class PrefsEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefsEditDialog(QWidget * parent, UpdateFactories * factories);
|
||||
virtual ~PrefsEditDialog();
|
||||
|
||||
public slots:
|
||||
void setMainWinHasDirtyChild(bool value);
|
||||
|
||||
signals:
|
||||
void profileFirmwareChanged();
|
||||
void profileFirmwareAboutToChange(bool saveFiles = true);
|
||||
void resetFirmware();
|
||||
|
||||
protected slots:
|
||||
void accept() Q_DECL_OVERRIDE;
|
||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
void done(int r) Q_DECL_OVERRIDE;
|
||||
void reject() Q_DECL_OVERRIDE;
|
||||
|
||||
void onRadioChanged(Firmware * firmware);
|
||||
|
||||
private:
|
||||
Ui::PrefsEdit *ui;
|
||||
bool mainWinHasDirtyChild;
|
||||
Firmware *firmware;
|
||||
Board::Type board;
|
||||
Profile &profile;
|
||||
QList<PrefsPanel *> panels;
|
||||
bool dirty;
|
||||
|
||||
PrefsPanel * addTab(PrefsPanel * panel, QString text);
|
||||
bool maybeSave();
|
||||
bool save();
|
||||
void shrink();
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefsEdit</class>
|
||||
<widget class="QDialog" name="PrefsEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>PrefsEdit</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>PrefsEdit</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_panel.h"
|
||||
|
||||
PrefsPanel::PrefsPanel(QWidget * parent, Firmware * firmware, Board::Type & board, Profile & profile):
|
||||
AbstractPanel(parent),
|
||||
firmware(firmware),
|
||||
board(board),
|
||||
profile(profile),
|
||||
row(0),
|
||||
col(0)
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel::~PrefsPanel()
|
||||
{
|
||||
}
|
||||
|
||||
AutoLineEdit * PrefsPanel::newPathWidget(QWidget * parent)
|
||||
{
|
||||
AutoLineEditPath *wgt = new AutoLineEditPath(parent, true);
|
||||
setPathWidget(wgt);
|
||||
return wgt;
|
||||
}
|
||||
|
||||
void PrefsPanel::setPathWidget(AutoLineEdit * wgt)
|
||||
{
|
||||
wgt->setMinimumWidth(PATH_MIN_WIDTH);
|
||||
wgt->setSizePolicy(PATH_SIZE_POLICY);
|
||||
wgt->setEditSignal(true);
|
||||
wgt->setClearButtonEnabled(true);
|
||||
}
|
||||
|
||||
void PrefsPanel::onRadioChanged(Firmware * firmware, bool deferUpdate)
|
||||
{
|
||||
this->firmware = firmware;
|
||||
board = this->firmware->getBoard();
|
||||
|
||||
if (!deferUpdate)
|
||||
update();
|
||||
}
|
||||
|
||||
/*
|
||||
PrefsScrollArea
|
||||
*/
|
||||
|
||||
PrefsScrollArea::PrefsScrollArea(QWidget * parent, PrefsPanel * panel):
|
||||
QScrollArea(parent),
|
||||
panel(panel)
|
||||
{
|
||||
setWidgetResizable(true);
|
||||
setWidget(panel);
|
||||
panel->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool PrefsScrollArea::eventFilter(QObject * o, QEvent * e)
|
||||
{
|
||||
if (o == panel && e->type() == QEvent::Resize)
|
||||
setMinimumWidth(panel->minimumSizeHint().width());
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "appdata.h"
|
||||
#include "abstractpanel.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "gridlayout.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
|
||||
class PrefsEditDialog;
|
||||
|
||||
// use to help Qt formatting
|
||||
constexpr int PATH_MIN_WIDTH {250};
|
||||
constexpr QSizePolicy PATH_SIZE_POLICY {QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)};
|
||||
|
||||
class PrefsPanel : public AbstractPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
friend class PrefsEditDialog;
|
||||
|
||||
explicit PrefsPanel(QWidget * parent, Firmware * firmware, Board::Type & board, Profile & profile) ;
|
||||
virtual ~PrefsPanel();
|
||||
|
||||
virtual void save() override {};
|
||||
|
||||
signals:
|
||||
void radioChanged(Firmware * firmware);
|
||||
|
||||
protected slots:
|
||||
virtual void onRadioChanged(Firmware * firmware, bool deferUpdate = false);
|
||||
|
||||
protected:
|
||||
Firmware *firmware;
|
||||
Board::Type board;
|
||||
Profile &profile;
|
||||
int row;
|
||||
int col;
|
||||
|
||||
AutoLineEdit * newPathWidget(QWidget * parent);
|
||||
void setPathWidget(AutoLineEdit * wgt);
|
||||
|
||||
};
|
||||
|
||||
class PrefsScrollArea : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefsScrollArea(QWidget * parent, PrefsPanel * panel);
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
private:
|
||||
PrefsPanel * panel;
|
||||
};
|
||||
@@ -0,0 +1,508 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_profile.h"
|
||||
#include "ui_prefs_profile.h"
|
||||
#include "eeprominterface.h"
|
||||
#include "moduledata.h"
|
||||
#include "firmwarepicker.h"
|
||||
#include "firmwarepicker.h"
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QFileInfo>
|
||||
#include <QImageReader>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
constexpr char FIM_TEMPLATESETUP[] {"Template Setup"};
|
||||
|
||||
PrefsProfilePanel::PrefsProfilePanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof) :
|
||||
PrefsPanel(parent, fw, bd, prof),
|
||||
ui(new Ui::PrefsProfile)
|
||||
{
|
||||
lock = true;
|
||||
ui->setupUi(this);
|
||||
|
||||
panelItemModels->registerItemModel(new FilteredItemModel(GeneralSettings::templateSetupItemModel()), FIM_TEMPLATESETUP);
|
||||
panelItemModels->getItemModel(FIM_TEMPLATESETUP)->setFilterFlags(Boards::isAir() ? GeneralSettings::RadioTypeContextAir :
|
||||
GeneralSettings::RadioTypeContextSurface);
|
||||
|
||||
// name
|
||||
// The profile name may NEVER be empty
|
||||
if (profile.name().isEmpty())
|
||||
profile.name(tr("My Radio"));
|
||||
|
||||
ui->leName->setValue(profile.name(), this);
|
||||
ui->leName->setEditSignal(true);
|
||||
ui->leName->setBindSave([this] {
|
||||
profile.name(ui->leName->text());
|
||||
|
||||
if (profile.name().isEmpty())
|
||||
profile.name(tr("My Radio"));
|
||||
});
|
||||
|
||||
// radio
|
||||
// this widget is for data management
|
||||
fwTypeData = new AutoLineEdit(this, true);
|
||||
fwTypeData->setHidden(true);
|
||||
fwTypeData->setValue(profile.fwType());
|
||||
fwTypeData->setBindSave([this] {
|
||||
this->profile.fwType(this->fwTypeData->text());
|
||||
});
|
||||
fwTypeData->setBindPostChanged([this] {
|
||||
// appending "-xxx" forces the associated Board definition to be loaded if not already loaded
|
||||
// TODO fix as part of refactoring Firmware and Boards
|
||||
Firmware *fw = Firmware::getFirmwareForId(this->fwTypeData->text() % "-xxx");
|
||||
// this will be trapped by PrefsEditDialog which will trigger onRadioChanged for each panel
|
||||
// including this panel which has an override onRadioChanged function
|
||||
emit radioChanged(fw);
|
||||
});
|
||||
|
||||
// this widget displays the firmware full name
|
||||
ui->leFirmwareType->setReadOnly(true);
|
||||
ui->leFirmwareType->setBindText([this] {
|
||||
return Firmware::getFirmwareForId(this->fwTypeData->text())->getFullName();
|
||||
});
|
||||
ui->leFirmwareType->setMinimumWidth(PATH_MIN_WIDTH);
|
||||
ui->leFirmwareType->setSizePolicy(PATH_SIZE_POLICY);
|
||||
|
||||
connect(ui->btnFirmwareType, &QPushButton::pressed, this, &PrefsProfilePanel::onFirmwareTypePressed);
|
||||
|
||||
sectionNewFile();
|
||||
sectionFolders();
|
||||
sectionFirmwareOpts();
|
||||
sectionSplash();
|
||||
|
||||
update();
|
||||
shrink();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
PrefsProfilePanel::~PrefsProfilePanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::onFirmwareTypePressed()
|
||||
{
|
||||
FirmwarePicker * picker = new FirmwarePicker(this, fwTypeData->text());
|
||||
connect(picker, &FirmwarePicker::firmwareTypeChanged, this, [this] (const QString newType) {
|
||||
this->fwTypeData->setText(newType);
|
||||
this->update();
|
||||
});
|
||||
picker->exec();
|
||||
picker->deleteLater();
|
||||
}
|
||||
|
||||
QString PrefsProfilePanel::getLanguage()
|
||||
{
|
||||
return !profile.fwLanguage().isEmpty() ?
|
||||
profile.fwLanguage() :
|
||||
QLocale::languageToString(QLocale().language()).split("_").first();
|
||||
}
|
||||
|
||||
QStringList PrefsProfilePanel::getSelectedOptions()
|
||||
{
|
||||
QStringList opts;
|
||||
|
||||
if (chkFirmwareBuildOpts.size()) {
|
||||
QMutableMapIterator<QString, AutoCheckBox *> it(chkFirmwareBuildOpts);
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
AutoCheckBox * chk = it.value();
|
||||
|
||||
if (chk->isChecked())
|
||||
opts.append(it.key());
|
||||
}
|
||||
}
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
||||
QString PrefsProfilePanel::getSplashFileFilter()
|
||||
{
|
||||
QString fmts;
|
||||
|
||||
for (int idx = 0; idx < QImageReader::supportedImageFormats().count(); idx++) {
|
||||
fmts += QLatin1String(" *.") + QImageReader::supportedImageFormats()[idx];
|
||||
}
|
||||
|
||||
return fmts;
|
||||
}
|
||||
|
||||
QAbstractItemModel * PrefsProfilePanel::languageModel()
|
||||
{
|
||||
QStandardItemModel * mdl = new QStandardItemModel(this);
|
||||
|
||||
for (const char *lang : firmware->getFirmwareBase()->languageList()) {
|
||||
QStandardItem * item = new QStandardItem();
|
||||
item->setText(lang);
|
||||
item->setData(lang, Qt::UserRole);
|
||||
mdl->appendRow(item);
|
||||
}
|
||||
|
||||
QSortFilterProxyModel *smdl = new QSortFilterProxyModel(this);
|
||||
smdl->setSourceModel(mdl);
|
||||
smdl->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
smdl->sort(0);
|
||||
return smdl;
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::onOptionChanged(QString name)
|
||||
{
|
||||
AutoCheckBox *chk = chkFirmwareBuildOpts.value(name, nullptr);
|
||||
|
||||
if (!(chk && chk->isChecked())) return;
|
||||
|
||||
const Firmware::OptionsList & fwOpts = firmware->getFirmwareBase()->optionGroups();
|
||||
|
||||
// This de-selects any mutually exlusive options (that is, members of the same QList<Option> list).
|
||||
for (const Firmware::OptionsGroup & optGrp : fwOpts) {
|
||||
for (const Firmware::Option & opt : optGrp) {
|
||||
if (name == opt.name) {
|
||||
AutoCheckBox *ochk = nullptr;
|
||||
|
||||
foreach(const Firmware::Option & other, optGrp) {
|
||||
if (other.name != opt.name && (ochk = chkFirmwareBuildOpts.value(other.name, nullptr)))
|
||||
ochk->setValue(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::populateFirmwareOptions(QStringList opts)
|
||||
{
|
||||
QStringList currOpts = opts;
|
||||
|
||||
if (!opts.size() && chkFirmwareBuildOpts.size()) {
|
||||
currOpts.clear();
|
||||
QMutableMapIterator<QString, AutoCheckBox *> it(chkFirmwareBuildOpts);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
QCheckBox * chk = it.value();
|
||||
|
||||
if (chk->isChecked())
|
||||
currOpts.append(it.key()); // keep previous selections
|
||||
|
||||
layFirmwareBuildOpts->removeWidget(chk);
|
||||
chk->deleteLater();
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
QWidget * prevFocus = cboFirmwareLanguage;
|
||||
|
||||
for (const Firmware::OptionsGroup &optGrp : firmware->getFirmwareBase()->optionGroups()) {
|
||||
for (const Firmware::Option &opt : optGrp) {
|
||||
AutoCheckBox * chk = new AutoCheckBox(this, opt.name);
|
||||
chk->setValue(currOpts.contains(opt.name));
|
||||
chk->setToolTip(opt.tooltip);
|
||||
// connect to duplicates check handler if this option is part of a group
|
||||
if (optGrp.size() > 1)
|
||||
chk->setBindPostChanged([=] { this->onOptionChanged(opt.name); });
|
||||
|
||||
layFirmwareBuildOpts->addWidget(chk, index / 4, index % 4);
|
||||
chkFirmwareBuildOpts.insert(opt.name, chk);
|
||||
QWidget::setTabOrder(prevFocus, chk);
|
||||
prevFocus = chk;
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
shrink();
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::save()
|
||||
{
|
||||
profile.fwOptions(getSelectedOptions().join("-"));
|
||||
AbstractPanel::save();
|
||||
}
|
||||
|
||||
// options TODO split into those supported by Cloud Build and others
|
||||
void PrefsProfilePanel::sectionFirmwareOpts()
|
||||
{
|
||||
QGridLayout *layFirmwareOpts = ui->csectFirmwareOpts->start(tr("Firmware Options"));
|
||||
row = col = 0;
|
||||
|
||||
// language
|
||||
QLabel *lblFirmwareLanguage = new QLabel(tr("Language"), this);
|
||||
layFirmwareOpts->addWidget(lblFirmwareLanguage, row, col++);
|
||||
|
||||
QHBoxLayout *layLanguage = new QHBoxLayout();
|
||||
cboFirmwareLanguage = new AutoComboBox(this);
|
||||
cboFirmwareLanguage->setModel(languageModel());
|
||||
cboFirmwareLanguage->setValue(profile.fwLanguage());
|
||||
cboFirmwareLanguage->setBindSave([this] {
|
||||
this->profile.fwLanguage(this->cboFirmwareLanguage->currentData().toString());
|
||||
});
|
||||
layLanguage->addWidget(cboFirmwareLanguage);
|
||||
QLabel *spacerLanguage = new QLabel();
|
||||
spacerLanguage->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
layLanguage->addWidget(spacerLanguage);
|
||||
layFirmwareOpts->addLayout(layLanguage, row, col++);
|
||||
|
||||
// other options
|
||||
++row; col = 0;
|
||||
AutoLabel *lblFirmwareOptions = new AutoLabel(this, tr("Build"));
|
||||
layFirmwareOpts->addWidget(lblFirmwareOptions, row, col++, Qt::AlignTop);
|
||||
|
||||
layFirmwareBuildOpts = new QGridLayout();
|
||||
layFirmwareOpts->addLayout(layFirmwareBuildOpts, row, col++);
|
||||
populateFirmwareOptions(profile.fwOptions().split("-", Qt::SkipEmptyParts));
|
||||
// flashing
|
||||
++row; col = 0;
|
||||
AutoLabel *lblBackupBeforeFlash = new AutoLabel(this, tr("Flashing"));
|
||||
layFirmwareOpts->addWidget(lblBackupBeforeFlash, row, col++, Qt::AlignTop);
|
||||
|
||||
chkBackupBeforeFlash = new AutoCheckBox(this, tr("prompt to backup current firmware before flashing"));
|
||||
chkBackupBeforeFlash->setValue(profile.penableBackup());
|
||||
chkBackupBeforeFlash->setBindSave([this] {
|
||||
this->profile.penableBackup(this->chkBackupBeforeFlash->isChecked());
|
||||
});
|
||||
layFirmwareOpts->addWidget(chkBackupBeforeFlash, row, col++);
|
||||
|
||||
ui->csectFirmwareOpts->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::sectionFolders()
|
||||
{
|
||||
QGridLayout *layFolders = ui->csectFolders->start(tr("Folders"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblSDPath = new AutoLabel(this, tr("SD Path"));
|
||||
layFolders->addWidget(lblSDPath, row, col++);
|
||||
|
||||
leSDPath = newPathWidget(this);
|
||||
leSDPath->setValue(profile.sdPath());
|
||||
leSDPath->setBindSave([this] {
|
||||
this->profile.sdPath(this->leSDPath->text());
|
||||
});
|
||||
leSDPath->setBindPostChanged([this] {
|
||||
// alert other tabs eg Updates
|
||||
emit this->sdPathChanged(this->leSDPath->text());
|
||||
});
|
||||
layFolders->addWidget(leSDPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnSDPath = new AutoDirectorySelectButton(this);
|
||||
btnSDPath->setup(tr("Select SD path folder"), profile.sdPath(), leSDPath);;
|
||||
layFolders->addWidget(btnSDPath, row, col++);
|
||||
// Backups path
|
||||
++row; col = 0;
|
||||
AutoLabel *lblBackupsPath = new AutoLabel(this, tr("Backups"));
|
||||
layFolders->addWidget(lblBackupsPath, row, col++);
|
||||
|
||||
leBackupsPath = newPathWidget(this);
|
||||
leBackupsPath->setValue(profile.pBackupDir());
|
||||
leBackupsPath->setBindSave([this] {
|
||||
this->profile.pBackupDir(this->leBackupsPath->text());
|
||||
});
|
||||
layFolders->addWidget(leBackupsPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnBackupsPath = new AutoDirectorySelectButton(this);
|
||||
btnBackupsPath->setup(tr("Select backups folder"), profile.pBackupDir(), leBackupsPath);;
|
||||
layFolders->addWidget(btnBackupsPath, row, col++);
|
||||
|
||||
/* TODO implement
|
||||
++row; col = 0;
|
||||
AutoLabel *lblModelsPath = new AutoLabel(this, tr("Models"));
|
||||
layFolders->addWidget(lblModelsPath, row, col++);
|
||||
|
||||
leModelsPath = newPathWidget(this);
|
||||
leModelsPath->setValue(profile.modelsDir());
|
||||
leModelsPath->setBindSave([this] {
|
||||
this->profile.modelsDir(this->leModelsPath->text());
|
||||
});
|
||||
layFolders->addWidget(leModelsPath, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnModelsPath = new AutoDirectorySelectButton(this);
|
||||
btnModelsPath->setup(tr("Select models folder"), profile.modelsDir(), leModelsPath);;
|
||||
layFolders->addWidget(btnModelsPath, row, col++);
|
||||
*/
|
||||
|
||||
ui->csectFolders->finish(-1, -1, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::sectionNewFile()
|
||||
{
|
||||
QGridLayout *layNewFile = ui->csectNewFile->start(tr("New Models and Settings Files"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblUseSettingsBackup = new AutoLabel(this, tr("Use backup settings"));
|
||||
layNewFile->addWidget(lblUseSettingsBackup, row, col++);
|
||||
chkUseSettingsBackup = new AutoCheckBox(this, " ");
|
||||
chkUseSettingsBackup->setValue(profile.useSavedSettings());
|
||||
chkUseSettingsBackup->setBindSave([this] {
|
||||
this->profile.useSavedSettings(this->chkUseSettingsBackup->isChecked());
|
||||
});
|
||||
chkUseSettingsBackup->setBindPostChanged([this] { this->update(); });
|
||||
layNewFile->addWidget(chkUseSettingsBackup, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
lblSettingsBackup = new AutoLabel(this);
|
||||
lblSettingsBackup->setBindText([this] (){
|
||||
if (profile.generalSettings().isEmpty()) {
|
||||
return tr("No backup available for this profile");
|
||||
} else {
|
||||
QString str = profile.timeStamp();
|
||||
if (str.isEmpty())
|
||||
return tr("Backup available of unknown age");
|
||||
else
|
||||
return tr("Backup available dated %1").arg(str);
|
||||
}
|
||||
});
|
||||
layNewFile->addWidget(lblSettingsBackup, row, 1);
|
||||
|
||||
// Stick Mode
|
||||
++row; col = 0;
|
||||
AutoLabel *lblStickMode = new AutoLabel(this, tr("Default Stick Mode"));
|
||||
lblStickMode->setBindEnabled([this] {
|
||||
return (!this->chkUseSettingsBackup->isChecked() ||
|
||||
(this->chkUseSettingsBackup->isChecked() &&
|
||||
this->profile.generalSettings().isEmpty()));
|
||||
});
|
||||
lblStickMode->setBindVisible([this] { return Boards::isAir(); });
|
||||
layNewFile->addWidget(lblStickMode, row, col++);
|
||||
|
||||
cboStickMode = new AutoComboBox(this);
|
||||
cboStickMode->setModel(GeneralSettings::stickModeItemModel());
|
||||
cboStickMode->setValue(profile.defaultMode());
|
||||
cboStickMode->setBindSave([this] {
|
||||
this->profile.defaultMode(this->cboStickMode->currentData().toInt());
|
||||
});
|
||||
cboStickMode->setBindEnabled([this] {
|
||||
return (!this->chkUseSettingsBackup->isChecked() ||
|
||||
(this->chkUseSettingsBackup->isChecked() &&
|
||||
this->profile.generalSettings().isEmpty()));
|
||||
});
|
||||
cboStickMode->setBindVisible([this] { return Boards::isAir(); });
|
||||
layNewFile->addWidget(cboStickMode, row, col++);
|
||||
// Channel Order
|
||||
++row; col = 0;
|
||||
AutoLabel *lblChannelOrder = new AutoLabel(this, tr("Default Channel Order"));
|
||||
lblChannelOrder->setBindEnabled([this] {
|
||||
return (!this->chkUseSettingsBackup->isChecked() ||
|
||||
(this->chkUseSettingsBackup->isChecked() &&
|
||||
this->profile.generalSettings().isEmpty()));
|
||||
});
|
||||
layNewFile->addWidget(lblChannelOrder, row, col++);
|
||||
|
||||
cboChannelOrder = new AutoComboBox(this);
|
||||
cboChannelOrder->setModel(panelItemModels->getItemModel(FIM_TEMPLATESETUP));
|
||||
cboChannelOrder->setValue(profile.channelOrder());
|
||||
cboChannelOrder->setBindSave([this] {
|
||||
this->profile.channelOrder(this->cboChannelOrder->currentData().toInt());
|
||||
});
|
||||
cboChannelOrder->setBindEnabled([this] {
|
||||
return (!this->chkUseSettingsBackup->isChecked() ||
|
||||
(this->chkUseSettingsBackup->isChecked() &&
|
||||
this->profile.generalSettings().isEmpty()));
|
||||
});
|
||||
layNewFile->addWidget(cboChannelOrder, row, col++);
|
||||
// Internal Module
|
||||
++row; col = 0;
|
||||
AutoLabel *lblModuleInternal = new AutoLabel(this, tr("Default Internal Module"));
|
||||
layNewFile->addWidget(lblModuleInternal, row, col++);
|
||||
cboModuleInternal = new AutoComboBox(this);
|
||||
cboModuleInternal->setModel(ModuleData::internalModuleItemModel());
|
||||
cboModuleInternal->setValue(profile.defaultInternalModule());
|
||||
cboModuleInternal->setBindSave([this] {
|
||||
profile.defaultInternalModule(this->cboModuleInternal->currentData().toInt());
|
||||
});
|
||||
layNewFile->addWidget(cboModuleInternal, row, col++);
|
||||
// External Module
|
||||
++row; col = 0;
|
||||
AutoLabel *lblModuleExternal = new AutoLabel(this, tr("External Module Size"));
|
||||
layNewFile->addWidget(lblModuleExternal, row, col++);
|
||||
|
||||
cboModuleExternal = new AutoComboBox(this);
|
||||
cboModuleExternal->setModel(Boards::externalModuleSizeItemModel());
|
||||
cboModuleExternal->setValue(profile.externalModuleSize());
|
||||
cboModuleExternal->setBindSave([this] {
|
||||
this->profile.externalModuleSize(this->cboModuleExternal->currentData().toInt());
|
||||
});
|
||||
layNewFile->addWidget(cboModuleExternal, row, col++);
|
||||
|
||||
ui->csectNewFile->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::sectionSplash()
|
||||
{
|
||||
QGridLayout *laySplash = ui->csectSplash->start(tr("Splash Screen"));
|
||||
ui->csectSplash->setBindVisible([this] {
|
||||
return !Boards::getCapability(this->board, Board::HasColorLcd);
|
||||
});
|
||||
row = col = 0;
|
||||
|
||||
leSplashPath = newPathWidget(this);
|
||||
leSplashPath->setValue(profile.splashFile());
|
||||
leSplashPath->setBindSave([this] {
|
||||
this->profile.splashFile(this->leSplashPath->text());
|
||||
});
|
||||
laySplash->addWidget(leSplashPath, row, col++);
|
||||
// Splash folder select
|
||||
AutoFileSelectButton *btnSplashSelect = new AutoFileSelectButton(this);
|
||||
btnSplashSelect->setup(tr("Open Image to load"), g.imagesDir(),
|
||||
tr("Images (%1)").arg(getSplashFileFilter()), leSplashPath);
|
||||
btnSplashSelect->setBindPostChanged([this] {
|
||||
if (!this->leSplashPath->text().isEmpty()){
|
||||
g.imagesDir(QFileInfo(this->leSplashPath->text()).dir().absolutePath());
|
||||
}
|
||||
});
|
||||
laySplash->addWidget(btnSplashSelect, row, col++);
|
||||
// Splash image
|
||||
++row; col = 0;
|
||||
imgSplash = new AutoImage(this, leSplashPath->text());
|
||||
// change of firmware and thus board can effect the image
|
||||
imgSplash->setBindPreUpdate([this] {
|
||||
imgSplash->setDimensions(Boards::getCapability(this->board, Board::LcdWidth),
|
||||
Boards::getCapability(this->board, Board::LcdHeight),
|
||||
Boards::getCapability(this->board, Board::LcdDepth));
|
||||
});
|
||||
laySplash->addWidget(imgSplash, row, col++);
|
||||
// Splash clear
|
||||
AutoPushButton *btnSplashClear = new AutoPushButton(this, tr("Clear"));
|
||||
btnSplashClear->setBindClicked([this] {
|
||||
this->imgSplash->clear();
|
||||
this->leSplashPath->clear();
|
||||
});
|
||||
laySplash->addWidget(btnSplashClear, row, col++);
|
||||
|
||||
ui->csectSplash->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
// called directly by PrefsEditDialog
|
||||
// slot not used due to risk of Qt events not being processed in required sequence
|
||||
void PrefsProfilePanel::onRadioChanged(Firmware * firmware, bool deferUpdate)
|
||||
{
|
||||
PrefsPanel::onRadioChanged(firmware, true);
|
||||
fwTypeData->setText(firmware->getFirmwareBase()->getId());
|
||||
populateFirmwareOptions(profile.fwOptions().split("-"));
|
||||
update();
|
||||
}
|
||||
|
||||
void PrefsProfilePanel::update()
|
||||
{
|
||||
AbstractPanel::update();
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "prefs_edit.h"
|
||||
|
||||
namespace Ui {
|
||||
class PrefsProfile;
|
||||
}
|
||||
|
||||
class Firmware;
|
||||
|
||||
class PrefsProfilePanel : public PrefsPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrefsProfilePanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof);
|
||||
virtual ~PrefsProfilePanel();
|
||||
|
||||
virtual void save() override;
|
||||
virtual void update() override;
|
||||
|
||||
signals:
|
||||
void sdPathChanged(QString path);
|
||||
|
||||
public slots:
|
||||
void onOptionChanged(QString name);
|
||||
void onFirmwareTypePressed();
|
||||
|
||||
protected slots:
|
||||
virtual void onRadioChanged(Firmware * firmware, bool deferUpdate = true) override;
|
||||
|
||||
private:
|
||||
Ui::PrefsProfile * ui;
|
||||
|
||||
AutoLineEdit *fwTypeData;
|
||||
AutoCheckBox *chkUseSettingsBackup;
|
||||
AutoLabel *lblSettingsBackup;
|
||||
AutoComboBox *cboStickMode;
|
||||
AutoComboBox *cboChannelOrder;
|
||||
AutoComboBox *cboModuleInternal;
|
||||
AutoComboBox *cboModuleExternal;
|
||||
AutoLineEdit *leSDPath;
|
||||
AutoLineEdit *leModelsPath;
|
||||
AutoLineEdit *leBackupsPath;
|
||||
AutoComboBox *cboFirmwareLanguage;
|
||||
AutoImage *imgSplash;
|
||||
AutoLineEdit *leSplashPath;
|
||||
QStringList strlBuildOpts;
|
||||
QGridLayout *layFirmwareBuildOpts;
|
||||
QMap<QString, AutoCheckBox *> chkFirmwareBuildOpts;
|
||||
AutoCheckBox *chkBackupBeforeFlash;
|
||||
|
||||
QString getLanguage();
|
||||
QStringList getSelectedOptions();
|
||||
QString getSplashFileFilter();
|
||||
QAbstractItemModel *languageModel();
|
||||
void populateFirmwareOptions(QStringList opts = QStringList());
|
||||
void sectionFirmwareOpts();
|
||||
void sectionFolders();
|
||||
void sectionNewFile();
|
||||
void sectionSplash();
|
||||
};
|
||||
@@ -0,0 +1,182 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefsProfile</class>
|
||||
<widget class="QWidget" name="PrefsProfile">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>710</width>
|
||||
<height>184</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>70</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>544</width>
|
||||
<height>52</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetNoConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblFirmwareType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Firmware Type</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="btnFirmwareType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" 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>25</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="AutoLineEdit" name="leName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="AutoLineEdit" name="leFirmwareType"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectFirmwareOpts" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectFolders" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectNewFile" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoCollapsibleSection" name="csectSplash" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AutoCollapsibleSection</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>autocollapsiblesection.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>autolineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_simu.h"
|
||||
#include "ui_prefs_simu.h"
|
||||
#include "eeprominterface.h"
|
||||
|
||||
#if defined(USE_SDL)
|
||||
#include "joystick.h"
|
||||
#include "joystickdialog.h"
|
||||
#endif
|
||||
|
||||
PrefsSimuPanel::PrefsSimuPanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof) :
|
||||
PrefsPanel(parent, fw, bd, prof),
|
||||
ui(new Ui::PrefsSimu)
|
||||
{
|
||||
lock = true;
|
||||
ui->setupUi(this);
|
||||
|
||||
// fix ups TODO move to Appdata load
|
||||
if (g.snapshotDir().isEmpty() && !g.snapToClpbrd())
|
||||
g.snapToClpbrd(true);
|
||||
|
||||
ui->chkScrnshotClipbd->setValue(g.snapToClpbrd(), this);
|
||||
ui->chkScrnshotClipbd->setBindSave([this] { g.snapToClpbrd(ui->chkScrnshotClipbd->isChecked()); });
|
||||
ui->chkScrnshotClipbd->setBindPostChanged([this] { this->update(); });
|
||||
|
||||
setPathWidget(ui->leScrnshotPath);
|
||||
ui->leScrnshotPath->setValue(g.snapshotDir(), this);
|
||||
ui->leScrnshotPath->setBindSave([this] { g.snapshotDir(ui->leScrnshotPath->text()); });
|
||||
ui->leScrnshotPath->setBindEnabled([this] { return !ui->chkScrnshotClipbd->isChecked(); });
|
||||
ui->leScrnshotPath->setBindPostChanged([this] {
|
||||
if (ui->leScrnshotPath->text().isEmpty()) {
|
||||
ui->chkScrnshotClipbd->setChecked(true);
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
ui->btnScrnshotFldr->setup(tr("Select snapshot folder"), g.snapshotDir(), ui->leScrnshotPath);
|
||||
ui->btnScrnshotFldr->addBuddyParentWidget(ui->leScrnshotPath);
|
||||
|
||||
ui->btnClearSavedPosn->setBindClicked([this] {
|
||||
SimulatorOptions opts = this->profile.simulatorOptions();
|
||||
opts.controlsState.clear();
|
||||
this->profile.simulatorOptions(opts);
|
||||
});
|
||||
|
||||
ui->chkSaveControls->setValue(g.simuSW(), this);
|
||||
ui->chkSaveControls->setBindSave([this] { g.simuSW(ui->chkSaveControls->isChecked()); });
|
||||
|
||||
ui->chkJoystickWarning->setValue(g.disableJoystickWarning(), this);
|
||||
ui->chkJoystickWarning->setBindSave([this] { g.disableJoystickWarning(ui->chkJoystickWarning->isChecked()); });
|
||||
|
||||
ui->chkScrollButtons->setValue(g.simuScrollButtons(), this);
|
||||
ui->chkScrollButtons->setBindSave([this] { g.simuScrollButtons(ui->chkScrollButtons->isChecked()); });
|
||||
|
||||
ui->cboGenericKeysPos->addItems(AppData::simuGenericKeysPosList());
|
||||
ui->cboGenericKeysPos->setValue((int)g.simuGenericKeysPos(), this);
|
||||
ui->cboGenericKeysPos->setBindSave([this] {
|
||||
g.simuGenericKeysPos((AppData::SimuGenericKeysPos)ui->cboGenericKeysPos->currentIndex());
|
||||
});
|
||||
|
||||
ui->dsbVolumeGain->setValue(profile.volumeGain() / 10.0, this);
|
||||
ui->dsbVolumeGain->setBindSave([this] { this->profile.volumeGain(ui->dsbVolumeGain->value() * 10.0); });
|
||||
|
||||
ui->lblBackLightColor->setBindVisible([this] { return Boards::getCapability(board, Board::HasBacklightColor); });
|
||||
|
||||
ui->cboBackLightColor->addItems(AppData::simuBackLightColorList());
|
||||
ui->cboBackLightColor->setValue((int)g.backLight(), this);
|
||||
ui->cboBackLightColor->setBindSave([this] { g.backLight(ui->cboBackLightColor->currentIndex()); });
|
||||
ui->cboBackLightColor->setBindVisible([this] { return Boards::getCapability(board, Board::HasBacklightColor); });
|
||||
|
||||
ui->lblCaseColorSample->setBindSave([this] {
|
||||
this->profile.radioSimCaseColor(ui->lblCaseColorSample->palette().button().color());
|
||||
});
|
||||
ui->lblCaseColorSample->setPalette(profile.radioSimCaseColor());
|
||||
|
||||
ui->btnCaseColor->setup(ui->lblCaseColorSample->palette().button().color(), ui->lblCaseColorSample);
|
||||
|
||||
ui->chkBtnClkUseOSTheme->setValue(profile.simBtnClickedUseOSTheme(), this);
|
||||
ui->chkBtnClkUseOSTheme->setBindSave([this] {
|
||||
return this->profile.simBtnClickedUseOSTheme(ui->chkBtnClkUseOSTheme->isChecked());
|
||||
});
|
||||
ui->chkBtnClkUseOSTheme->setBindPostChanged([this] { this->update(); });
|
||||
|
||||
ui->lblBtnClkColorSample->setPalette(profile.simBtnClickedColor());
|
||||
ui->lblBtnClkColorSample->setBindSave([this] {
|
||||
return this->profile.simBtnClickedColor(ui->lblBtnClkColorSample->palette().button().color());
|
||||
});
|
||||
ui->lblBtnClkColorSample->setBindEnabled([this] { return !ui->chkBtnClkUseOSTheme->isChecked(); });
|
||||
ui->lblBtnClkColorSample->setBindVisible([this] { return !ui->chkBtnClkUseOSTheme->isChecked(); });
|
||||
|
||||
ui->btnBtnClkColor->setup(ui->lblBtnClkColorSample->palette().button().color(), ui->lblBtnClkColorSample);
|
||||
ui->btnBtnClkColor->setBindEnabled([this] { return !ui->chkBtnClkUseOSTheme->isChecked(); });
|
||||
ui->btnBtnClkColor->setBindVisible([this] { return !ui->chkBtnClkUseOSTheme->isChecked(); });
|
||||
|
||||
#if defined(USE_SDL)
|
||||
ui->chkJoystickEnable->setValue(g.jsSupport(), this);
|
||||
ui->chkJoystickEnable->setBindSave([this] { g.jsSupport(ui->chkJoystickEnable->isChecked()); });
|
||||
|
||||
ui->cboJoystick->addItems(joysticksList());
|
||||
ui->cboJoystick->setValue(profile.jsName(), this, false);
|
||||
ui->cboJoystick->setBindEnabled([this] { return ui->chkJoystickEnable->isChecked();} );
|
||||
ui->cboJoystick->setBindSave([this] {
|
||||
if (ui->cboJoystick->isEnabled()) {
|
||||
this->profile.jsName(ui->cboJoystick->currentText());
|
||||
g.loadNamedJS();
|
||||
}
|
||||
});
|
||||
|
||||
ui->btnJoystickCalib->setBindEnabled([this] { return ui->chkJoystickEnable->isChecked();} );
|
||||
ui->btnJoystickCalib->setBindClicked([this] {
|
||||
this->profile.jsName(ui->cboJoystick->currentText());
|
||||
joystickDialog *jd = new joystickDialog(this);
|
||||
jd->exec();
|
||||
delete jd;
|
||||
});
|
||||
#endif
|
||||
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
PrefsSimuPanel::~PrefsSimuPanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefsSimuPanel::save()
|
||||
{
|
||||
AbstractPanel::save();
|
||||
}
|
||||
|
||||
void PrefsSimuPanel::update()
|
||||
{
|
||||
AbstractPanel::update();
|
||||
}
|
||||
|
||||
#if defined(USE_SDL)
|
||||
QStringList PrefsSimuPanel::joysticksList() {
|
||||
QStringList lst;
|
||||
Joystick *joystick = new Joystick(nullptr, 0, false, 0);
|
||||
|
||||
if ( joystick && joystick->joystickNames.count() > 0 ) {
|
||||
lst = joystick->joystickNames;
|
||||
joystick->close();
|
||||
} else {
|
||||
lst << tr("No joysticks found");
|
||||
}
|
||||
|
||||
return lst;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "prefs_panel.h"
|
||||
|
||||
namespace Ui {
|
||||
class PrefsSimu;
|
||||
}
|
||||
|
||||
class PrefsSimuPanel : public PrefsPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefsSimuPanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof);
|
||||
virtual ~PrefsSimuPanel();
|
||||
|
||||
virtual void update() override;
|
||||
virtual void save() override;
|
||||
|
||||
private:
|
||||
Ui::PrefsSimu * ui;
|
||||
|
||||
#if defined(USE_SDL)
|
||||
QStringList joysticksList();
|
||||
#endif
|
||||
};
|
||||
@@ -0,0 +1,450 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefsSimu</class>
|
||||
<widget class="QWidget" name="PrefsSimu">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>617</width>
|
||||
<height>322</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Simulation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="AutoLabel" name="lblScrnshotCap">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Screenshot Capture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="AutoCheckBox" name="chkScrnshotClipbd">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Only to clipboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="AutoLineEdit" name="leScrnshotPath">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="2">
|
||||
<widget class="AutoDirectorySelectButton" name="btnScrnshotFldr">
|
||||
<property name="text">
|
||||
<string>Folder...</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="AutoLabel" name="lblControls">
|
||||
<property name="text">
|
||||
<string>Controls</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="AutoCheckBox" name="chkSaveControls">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save switch and pot positions on exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3" colspan="2">
|
||||
<widget class="AutoPushButton" name="btnClearSavedPosn">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="AutoCheckBox" name="chkJoystickWarning">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable 'Cannot open joystick, joystick disabled' warning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="AutoCheckBox" name="chkScrollButtons">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display Scroll Buttons (mouse without scroll wheel)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="AutoLabel" name="lblKeys">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keys</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoComboBox" name="cboGenericKeysPos">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPad0">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="AutoLabel" name="lblVolumeGain">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Volume Gain</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="AutoDoubleSpinBox" name="dsbVolumeGain">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="AutoLabel" name="lblBackLightColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>BackLight Colour</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="AutoComboBox" name="cboBackLightColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" rowspan="2">
|
||||
<widget class="AutoLabel" name="lblCaseColor">
|
||||
<property name="text">
|
||||
<string>Case Colour</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" rowspan="2">
|
||||
<widget class="AutoLabel" name="lblCaseColorSample">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="3" rowspan="2" colspan="2">
|
||||
<widget class="AutoColorSelectButton" name="btnCaseColor">
|
||||
<property name="text">
|
||||
<string>Colour...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="AutoLabel" name="lblBtnClkColor">
|
||||
<property name="text">
|
||||
<string>Button Clicked Colour</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="AutoCheckBox" name="chkBtnClkUseOSTheme">
|
||||
<property name="text">
|
||||
<string>Operating System theme</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoLabel" name="lblBtnClkColorSample">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="10" column="3" colspan="2">
|
||||
<widget class="AutoColorSelectButton" name="btnBtnClkColor">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Colour...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="AutoLabel" name="lblJoystick">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Joystick</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="AutoCheckBox" name="chkJoystickEnable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoComboBox" name="cboJoystick">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::SizeAdjustPolicy::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPad1">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="11" column="3" colspan="2">
|
||||
<widget class="AutoPushButton" name="btnJoystickCalib">
|
||||
<property name="text">
|
||||
<string>Calibrate...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AutoCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>autocheckbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>autolineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>autolabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>autocombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoDoubleSpinBox</class>
|
||||
<extends>QDoubleSpinBox</extends>
|
||||
<header>autodoublespinbox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoPushButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>autopushbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoColorSelectButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>autocolorselectbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoDirectorySelectButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>autodirectoryselectbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,395 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "prefs_update.h"
|
||||
#include "ui_prefs_update.h"
|
||||
#include "updates/updatefactories.h"
|
||||
#include "updates/updateoptionsdialog.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
PrefsUpdatePanel::PrefsUpdatePanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof, UpdateFactories * factories):
|
||||
PrefsPanel(parent, fw, bd, prof),
|
||||
ui(new Ui::PrefsUpdate),
|
||||
factories(factories)
|
||||
{
|
||||
lock = true;
|
||||
ui->setupUi(this);
|
||||
// need to track latest value in editor so
|
||||
// save before changed in profile preferences ui
|
||||
// updated by onSDPathChanged;
|
||||
profileSDPath = profile.sdPath().trimmed();
|
||||
|
||||
ui->cboCheckFreq->addItems(AppData::updateCheckFreqsList());
|
||||
ui->cboCheckFreq->setPanel(this);
|
||||
ui->cboCheckFreq->setBindSave([this] {
|
||||
g.updateCheckFreq((AppData::UpdateCheckFreq)this->ui->cboCheckFreq->currentData().toInt());
|
||||
});
|
||||
|
||||
ui->btnResetToDefaults->setBindClicked([this] {
|
||||
if (QMessageBox::question(this, CPN_STR_APP_NAME, tr("Reset ALL update settings to defaults. Are you sure?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
|
||||
g.resetUpdatesSettings();
|
||||
this->setValuesFromSettings();
|
||||
emit this->modified();
|
||||
QMessageBox::warning(this, CPN_STR_APP_NAME,
|
||||
tr("Please save changed preferences.\nThen close and restart Companion to avoid unexpected behaviour!"));
|
||||
}
|
||||
});
|
||||
|
||||
sectionFolders();
|
||||
sectionComponents();
|
||||
sectionOptions();
|
||||
sectionPostUpdate();
|
||||
|
||||
setValuesFromSettings();
|
||||
shrink();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
PrefsUpdatePanel::~PrefsUpdatePanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::onSDPathChanged(QString path)
|
||||
{
|
||||
profileSDPath = path.trimmed();
|
||||
|
||||
if (profileSDPath.isEmpty())
|
||||
chkUpdateDirUseSD->setValue(false);
|
||||
else if (chkUpdateDirUseSD->isChecked())
|
||||
leUpdateDir->setValue(path);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::save()
|
||||
{
|
||||
QStringList msgs;
|
||||
|
||||
if (leDownloadDir->text().trimmed().isEmpty())
|
||||
msgs.append(tr("Download folder path missing!"));
|
||||
|
||||
if (leDecompressDir->text().trimmed().isEmpty())
|
||||
msgs.append(tr("Decompress folder path missing!"));
|
||||
|
||||
if (leUpdateDir->text().trimmed().isEmpty())
|
||||
msgs.append(tr("Update folder path missing!"));
|
||||
|
||||
if (!chkDecompressDirUseDwnld->isChecked() &&
|
||||
leDecompressDir->text().trimmed() == leDownloadDir->text().trimmed())
|
||||
msgs.append(tr("Decompress and download folders have the same path!"));
|
||||
|
||||
if (msgs.count() > 0) {
|
||||
QMessageBox::warning(this, CPN_STR_APP_NAME, tr("Update Preferences:\n%1").arg(msgs.join("\n")));
|
||||
}
|
||||
|
||||
AbstractPanel::save();
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::sectionComponents()
|
||||
{
|
||||
QGridLayout *layComponents = ui->csectComponents->start(tr("Components"));
|
||||
row = 0; col = 1; // leave col 0 blank
|
||||
|
||||
QLabel *lblCheck = new QLabel(tr("Check"));
|
||||
layComponents->addWidget(lblCheck, row, col++);
|
||||
|
||||
QLabel *lblReleaseChannel = new QLabel(tr("Release channel"));
|
||||
layComponents->addWidget(lblReleaseChannel, row, col++);
|
||||
|
||||
col++; // options button
|
||||
|
||||
QSpacerItem * spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
||||
layComponents->addItem(spacer, row, col++);
|
||||
|
||||
QMapIterator<QString, int> it(factories->sortedComponentsList());
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
int i = it.value();
|
||||
|
||||
row++; col = 0;
|
||||
|
||||
lblName[i] = new AutoLabel();
|
||||
layComponents->addWidget(lblName[i], row, col++);
|
||||
|
||||
chkCheckForUpdate[i] = new AutoCheckBox(this);
|
||||
// workaround Qt 6.9.0 Qt::AlignHCenter causes text to overlap checkbox rhs
|
||||
chkCheckForUpdate[i]->setStyleSheet("spacing: 10px");
|
||||
chkCheckForUpdate[i]->setBindSave([this, i] {
|
||||
g.component[i].checkForUpdate(this->chkCheckForUpdate[i]->isChecked());
|
||||
});
|
||||
layComponents->addWidget(chkCheckForUpdate[i], row, col++);
|
||||
layComponents->setAlignment(chkCheckForUpdate[i], Qt::AlignHCenter);
|
||||
|
||||
cboReleaseChannel[i] = new AutoComboBox(this);
|
||||
cboReleaseChannel[i]->addItems(ComponentData::releaseChannelsList());
|
||||
cboReleaseChannel[i]->setBindSave([this, i] {
|
||||
g.component[i].releaseChannel((ComponentData::ReleaseChannel)this->cboReleaseChannel[i]->currentData().toInt());
|
||||
});
|
||||
layComponents->addWidget(cboReleaseChannel[i], row, col++);
|
||||
|
||||
btnComponentOptions[i] = new AutoPushButton(this, tr("Options"));
|
||||
connect(btnComponentOptions[i], &QPushButton::clicked, [=]() {
|
||||
UpdateOptionsDialog *dlg = new UpdateOptionsDialog(this, factories->instance(i), i, false);
|
||||
dlg->exec();
|
||||
dlg->deleteLater();
|
||||
});
|
||||
layComponents->addWidget(btnComponentOptions[i], row, col++);
|
||||
}
|
||||
|
||||
ui->csectComponents->finish(row, col, [this] { this->shrink(); });
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
int i = it.value();
|
||||
|
||||
g.component[i].checkForUpdate(chkCheckForUpdate[i]->isChecked());
|
||||
g.component[i].releaseChannel((ComponentData::ReleaseChannel)cboReleaseChannel[i]->currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::sectionFolders()
|
||||
{
|
||||
QGridLayout *layFolders = ui->csectFolders->start(tr("Folders"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblDownloadDir = new AutoLabel(this, tr("Download"));
|
||||
layFolders->addWidget(lblDownloadDir, row, col++);
|
||||
|
||||
leDownloadDir = newPathWidget(this);
|
||||
leDownloadDir->setBindSave([this] {
|
||||
g.downloadDir(this->leDownloadDir->text().trimmed());
|
||||
});
|
||||
leDownloadDir->setBindPostChanged([this] {
|
||||
if (this->chkDecompressDirUseDwnld->isChecked()) {
|
||||
this->leDecompressDir->setValue(this->leDownloadDir->text().trimmed());
|
||||
|
||||
if (this->leDownloadDir->text().trimmed().isEmpty())
|
||||
this->chkDecompressDirUseDwnld->setValue(false);
|
||||
}
|
||||
|
||||
this->update();
|
||||
});
|
||||
layFolders->addWidget(leDownloadDir, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnDownloadDir = new AutoDirectorySelectButton(this);
|
||||
btnDownloadDir->setup(tr("Select download folder"), g.downloadDir(), leDownloadDir);
|
||||
btnDownloadDir->addBuddyParentWidget(leDownloadDir);
|
||||
layFolders->addWidget(btnDownloadDir, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblDecompressDir = new AutoLabel(this, tr("Decompress"));
|
||||
layFolders->addWidget(lblDecompressDir, row, col++);
|
||||
|
||||
chkDecompressDirUseDwnld = new AutoCheckBox(this, tr("create sub-folders in Download folder"));
|
||||
chkDecompressDirUseDwnld->setBindSave([this] {
|
||||
g.decompressDirUseDwnld(this->chkDecompressDirUseDwnld->isChecked());
|
||||
});
|
||||
chkDecompressDirUseDwnld->setBindEnabled([this] {
|
||||
return !this->leDownloadDir->text().trimmed().isEmpty();
|
||||
});
|
||||
chkDecompressDirUseDwnld->setBindPostChanged([this] {
|
||||
if (chkDecompressDirUseDwnld->isChecked())
|
||||
this->leDecompressDir->setValue(this->leDownloadDir->text());
|
||||
this->update();
|
||||
});
|
||||
layFolders->addWidget(chkDecompressDirUseDwnld, row, col++);
|
||||
|
||||
++row; col = 1; // skip col 0
|
||||
leDecompressDir = newPathWidget(this);
|
||||
leDecompressDir->setBindEnabled([this] {
|
||||
return (!this->chkDecompressDirUseDwnld->isChecked() ||
|
||||
this->leDownloadDir->text().trimmed().isEmpty());
|
||||
});
|
||||
leDecompressDir->setBindSave([this] {
|
||||
g.decompressDir(this->leDecompressDir->text().trimmed());
|
||||
});
|
||||
layFolders->addWidget(leDecompressDir, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnDecompressDir = new AutoDirectorySelectButton(this);
|
||||
btnDecompressDir->setup(tr("Select decompression folder"), g.decompressDir(), leDecompressDir);;
|
||||
btnDecompressDir->addBuddyParentWidget(leDecompressDir);
|
||||
layFolders->addWidget(btnDecompressDir, row, col++);
|
||||
|
||||
++row; col = 0;
|
||||
AutoLabel *lblUpdateDir = new AutoLabel(this, tr("Update"));
|
||||
layFolders->addWidget(lblUpdateDir, row, col++);
|
||||
|
||||
chkUpdateDirUseSD = new AutoCheckBox(this, tr("use Radio Profile SD path"));
|
||||
chkUpdateDirUseSD->setBindEnabled([this] {
|
||||
return !this->profileSDPath.isEmpty();
|
||||
});
|
||||
chkUpdateDirUseSD->setBindSave([this] {
|
||||
g.updateDirUseSD(this->chkUpdateDirUseSD->isChecked());
|
||||
});
|
||||
chkUpdateDirUseSD->setBindPostChanged([this] {
|
||||
if (this->chkUpdateDirUseSD->isChecked()) {
|
||||
this->leUpdateDir->setValue(profileSDPath);
|
||||
}
|
||||
this->update();
|
||||
});
|
||||
layFolders->addWidget(chkUpdateDirUseSD, row, col++);
|
||||
|
||||
++row; col = 1; // skip col 0
|
||||
leUpdateDir = newPathWidget(this);
|
||||
leUpdateDir->setBindEnabled([this] {
|
||||
return !this->chkUpdateDirUseSD->isChecked() ||
|
||||
this->profileSDPath.isEmpty();
|
||||
});
|
||||
leUpdateDir->setBindSave([this] {
|
||||
g.updateDir(this->leUpdateDir->text().trimmed());
|
||||
});
|
||||
layFolders->addWidget(leUpdateDir, row, col++);
|
||||
|
||||
AutoDirectorySelectButton *btnUpdateDir = new AutoDirectorySelectButton(this);
|
||||
btnUpdateDir->setup(tr("Select update folder"), g.updateDir(), leUpdateDir);;
|
||||
btnUpdateDir->addBuddyParentWidget(leUpdateDir);
|
||||
layFolders->addWidget(btnUpdateDir, row, col++);
|
||||
|
||||
ui->csectFolders->finish(-1, -1, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::sectionOptions()
|
||||
{
|
||||
QGridLayout *layOptions = ui->csectOptions->start(tr("Options"));
|
||||
row = col = 0;
|
||||
|
||||
AutoLabel *lblDelDownloads = new AutoLabel(this, tr("Delete downloads"));
|
||||
layOptions->addWidget(lblDelDownloads, row, col++);
|
||||
|
||||
chkDelDownloads = new AutoCheckBox(this);
|
||||
chkDelDownloads->setBindSave([this] {
|
||||
g.updDelDownloads(this->chkDelDownloads->isChecked());
|
||||
});
|
||||
chkDelDownloads->setBindEnabled([this] {
|
||||
return !this->chkDecompressDirUseDwnld->isChecked() ||
|
||||
this->chkDelDecompress->isChecked();
|
||||
});
|
||||
layOptions->addWidget(chkDelDownloads, row, col++);
|
||||
|
||||
row++; col = 0;
|
||||
AutoLabel *lblDelDecompress = new AutoLabel(this, tr("Delete decompressions"));
|
||||
layOptions->addWidget(lblDelDecompress, row, col++);
|
||||
|
||||
chkDelDecompress = new AutoCheckBox(this);
|
||||
chkDelDecompress->setBindSave([this] {
|
||||
g.updDelDecompress(this->chkDelDecompress->isChecked());
|
||||
});
|
||||
chkDelDecompress->setBindPostChanged([this] {
|
||||
if (!this->chkDelDecompress->isChecked()) {
|
||||
if (this->chkDecompressDirUseDwnld->isChecked()) {
|
||||
this->chkDelDownloads->setValue(false);
|
||||
}
|
||||
} else {
|
||||
this->chkDelDownloads->setEnabled(true);
|
||||
}
|
||||
|
||||
update();
|
||||
});
|
||||
layOptions->addWidget(chkDelDecompress, row, col++);
|
||||
|
||||
row++; col = 0;
|
||||
QLabel *lblLogLevel = new QLabel(tr("Log level"), this);
|
||||
layOptions->addWidget(lblLogLevel, row, col++);
|
||||
|
||||
cboLogLevel = new AutoComboBox(this);
|
||||
cboLogLevel->addItems(AppData::updateLogLevelsList());
|
||||
cboLogLevel->setBindSave([this] {
|
||||
g.updLogLevel(this->cboLogLevel->currentData().toInt());
|
||||
});
|
||||
layOptions->addWidget(cboLogLevel, row, col++);
|
||||
|
||||
ui->csectOptions->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::sectionPostUpdate()
|
||||
{
|
||||
QGridLayout *layPostUpdate = ui->csectPostUpdate->start(tr("Post Update"));
|
||||
row = col = 0;
|
||||
|
||||
chkPrmptFlash = new AutoCheckBox(this, tr("Prompt to flash firmware"));
|
||||
chkPrmptFlash->setBindSave([this] {
|
||||
profile.burnFirmware(this->chkPrmptFlash->isChecked());
|
||||
});
|
||||
layPostUpdate->addWidget(chkPrmptFlash, row, col++);
|
||||
|
||||
row++; col = 0;
|
||||
chkPrmptSDSync = new AutoCheckBox(this, tr("Prompt to run SD Sync"));
|
||||
chkPrmptSDSync->setBindSave([this] {
|
||||
profile.runSDSync(this->chkPrmptSDSync->isChecked());
|
||||
});
|
||||
layPostUpdate->addWidget(chkPrmptSDSync, row, col++);
|
||||
|
||||
row++; col = 0;
|
||||
chkPrmptCpnInstall = new AutoCheckBox(this, tr("Prompt to run Companion installer"));
|
||||
chkPrmptCpnInstall->setBindSave([this] {
|
||||
g.runAppInstaller(this->chkPrmptCpnInstall->isChecked());
|
||||
});
|
||||
layPostUpdate->addWidget(chkPrmptCpnInstall, row, col++);
|
||||
|
||||
ui->csectPostUpdate->finish(row, col, [this] { this->shrink(); });
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::setValuesFromSettings()
|
||||
{
|
||||
lock = true;
|
||||
ui->cboCheckFreq->setValue(g.updateCheckFreq());
|
||||
|
||||
// folders
|
||||
leDownloadDir->setValue(g.downloadDir());
|
||||
chkDecompressDirUseDwnld->setValue(g.decompressDirUseDwnld());
|
||||
leDecompressDir->setValue(g.decompressDir());
|
||||
chkUpdateDirUseSD->setValue(g.updateDirUseSD());
|
||||
leUpdateDir->setValue(g.updateDir());
|
||||
|
||||
// components
|
||||
QMapIterator<QString, int> it(factories->sortedComponentsList());
|
||||
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
int i = it.value();
|
||||
|
||||
lblName[i]->setText(it.key());
|
||||
chkCheckForUpdate[i]->setValue(g.component[i].checkForUpdate());
|
||||
cboReleaseChannel[i]->setValue(g.component[i].releaseChannel());
|
||||
}
|
||||
|
||||
// options
|
||||
chkDelDownloads->setValue(g.updDelDownloads());
|
||||
chkDelDecompress->setValue(g.updDelDecompress());
|
||||
cboLogLevel->setValue(g.updLogLevel());
|
||||
|
||||
// post update
|
||||
chkPrmptFlash->setValue(profile.burnFirmware());
|
||||
chkPrmptSDSync->setValue(profile.runSDSync());
|
||||
chkPrmptCpnInstall->setValue(g.runAppInstaller());
|
||||
|
||||
update();
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void PrefsUpdatePanel::update()
|
||||
{
|
||||
AbstractPanel::update();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "prefs_edit.h"
|
||||
|
||||
namespace Ui {
|
||||
class PrefsUpdate;
|
||||
}
|
||||
|
||||
class UpdateFactories;
|
||||
|
||||
class PrefsUpdatePanel : public PrefsPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PrefsUpdatePanel(QWidget * parent, Firmware * fw, Board::Type & bd, Profile & prof, UpdateFactories * factories);
|
||||
virtual ~PrefsUpdatePanel();
|
||||
|
||||
virtual void save() override;
|
||||
virtual void update() override;
|
||||
|
||||
public slots:
|
||||
void onSDPathChanged(QString path);
|
||||
|
||||
private:
|
||||
Ui::PrefsUpdate *ui;
|
||||
UpdateFactories *factories;
|
||||
// general
|
||||
// folders
|
||||
AutoLineEdit *leDownloadDir;
|
||||
AutoCheckBox *chkDecompressDirUseDwnld;
|
||||
AutoLineEdit *leDecompressDir;
|
||||
AutoCheckBox *chkUpdateDirUseSD;
|
||||
AutoLineEdit *leUpdateDir;
|
||||
//components
|
||||
AutoLabel *lblName[MAX_COMPONENTS];
|
||||
AutoCheckBox *chkCheckForUpdate[MAX_COMPONENTS];
|
||||
AutoComboBox *cboReleaseChannel[MAX_COMPONENTS];
|
||||
AutoPushButton *btnComponentOptions[MAX_COMPONENTS];
|
||||
// options
|
||||
AutoCheckBox *chkDelDownloads;
|
||||
AutoCheckBox *chkDelDecompress;
|
||||
AutoComboBox *cboLogLevel;
|
||||
// post update
|
||||
AutoCheckBox *chkPrmptFlash;
|
||||
AutoCheckBox *chkPrmptSDSync;
|
||||
AutoCheckBox *chkPrmptCpnInstall;
|
||||
|
||||
QString profileSDPath;
|
||||
|
||||
void sectionFolders();
|
||||
void sectionComponents();
|
||||
void sectionOptions();
|
||||
void sectionPostUpdate();
|
||||
|
||||
void setValuesFromSettings();
|
||||
};
|
||||
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrefsUpdate</class>
|
||||
<widget class="QWidget" name="PrefsUpdate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>622</width>
|
||||
<height>156</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0">
|
||||
<widget class="AutoCollapsibleSection" name="csectOptions" native="true"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="AutoCollapsibleSection" name="csectPostUpdate" native="true"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="AutoCollapsibleSection" name="csectComponents" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="AutoCollapsibleSection" name="csectFolders" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>591</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="AutoLabel" name="lblCheckFreq">
|
||||
<property name="text">
|
||||
<string>Check frequency</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoComboBox" name="cboCheckFreq"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AutoPushButton" name="btnResetToDefaults">
|
||||
<property name="text">
|
||||
<string>Reset to Defaults</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AutoCollapsibleSection</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>autocollapsiblesection.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoPushButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>autopushbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>autocombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AutoLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>autolabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user