feat(cpn): flashing add profile check option (#6680)

This commit is contained in:
Neil Horne
2025-10-18 20:43:00 +10:00
committed by GitHub
parent 2fe2c6cbe8
commit dfe035cf51
7 changed files with 393 additions and 115 deletions
+138 -94
View File
@@ -29,27 +29,42 @@
#include "progresswidget.h" #include "progresswidget.h"
#include "splashlibrarydialog.h" #include "splashlibrarydialog.h"
#include "storage.h" #include "storage.h"
#include "autocollapsiblesection.h"
#include <QTimer>
FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent) : FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::FlashFirmwareDialog), ui(new Ui::FlashFirmwareDialog),
fwName(g.profile[g.id()].fwName()) fwName(g.profile[g.id()].fwName()),
imageSource(FIRMWARE),
imageFile(""),
connectionMode(CONNECTION_NONE)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->checkBackup->setChecked(g.backupOnFlash());
if (!g.currentProfile().splashFile().isEmpty()){ ui->advancedWidget->setTitle(tr("Advanced"));
ui->advancedWidget->setAnimationDuration(300);
QVBoxLayout *advLayout = new QVBoxLayout();
chkHWComp = new QCheckBox(tr("check hardware compatibility (recommended)"), ui->advancedWidget);
chkHWComp->setChecked(true);
advLayout->addWidget(chkHWComp);
chkProfComp = new QCheckBox(tr("check profile compatibility"), ui->advancedWidget);
chkProfComp->setChecked(true);
advLayout->addWidget(chkProfComp);
ui->advancedWidget->setContentLayout(*advLayout);
const QString splashFile(g.currentProfile().splashFile());
if (!splashFile.isEmpty() && QFile(splashFile).exists()){
imageSource = PROFILE; imageSource = PROFILE;
imageFile = g.currentProfile().splashFile(); imageFile = splashFile;
ui->useProfileSplash->setChecked(true); ui->useProfileSplash->setChecked(true);
} else { } else {
imageSource = FIRMWARE;
imageFile = "";
ui->useProfileSplash->setDisabled(true); ui->useProfileSplash->setDisabled(true);
} }
ui->checkHardwareCompatibility->setChecked(g.checkHardwareCompatibility());
ui->checkBackup->setChecked(g.backupOnFlash());
detectClicked(true); detectClicked(true);
updateUI(); updateUI();
@@ -60,7 +75,8 @@ FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent) :
connect(ui->useLibrarySplash, &QRadioButton::clicked, this, &FlashFirmwareDialog::useLibrarySplashClicked); connect(ui->useLibrarySplash, &QRadioButton::clicked, this, &FlashFirmwareDialog::useLibrarySplashClicked);
connect(ui->useExternalSplash, &QRadioButton::clicked, this, &FlashFirmwareDialog::useExternalSplashClicked); connect(ui->useExternalSplash, &QRadioButton::clicked, this, &FlashFirmwareDialog::useExternalSplashClicked);
connect(ui->writeButton, &QPushButton::clicked, this, &FlashFirmwareDialog::writeButtonClicked); connect(ui->writeButton, &QPushButton::clicked, this, &FlashFirmwareDialog::writeButtonClicked);
connect(ui->cancelButton, &QPushButton::clicked, [this]() { close(); } ); connect(ui->cancelButton, &QPushButton::clicked, [this] () { close(); } );
connect(ui->advancedWidget, &AutoCollapsibleSection::resized, this, &FlashFirmwareDialog::shrink);
} }
FlashFirmwareDialog::~FlashFirmwareDialog() FlashFirmwareDialog::~FlashFirmwareDialog()
@@ -70,62 +86,65 @@ FlashFirmwareDialog::~FlashFirmwareDialog()
void FlashFirmwareDialog::updateUI() void FlashFirmwareDialog::updateUI()
{ {
ui->firmwareFilename->setText(fwName); if (connectionMode && isFileConnectionCompatible() && QFile(fwName).exists()) {
ui->firmwareFilename->setText(fwName);
if (connectionMode) {
ui->loadButton->setEnabled(true); ui->loadButton->setEnabled(true);
ui->writeButton->setEnabled(isFileConnectionCompatible() && QFile(fwName).exists()); ui->writeButton->setEnabled(true);
} else {
ui->loadButton->setEnabled(false);
ui->writeButton->setEnabled(false);
}
FirmwareInterface firmware(fwName); FirmwareInterface firmware(fwName);
if (firmware.isValid()) {
ui->firmwareInfoFrame->show();
ui->date->setText(firmware.getDate() + " " + firmware.getTime());
ui->version->setText(firmware.getVersion());
ui->variant->setText(firmware.getFlavour());
ui->date->setEnabled(true);
ui->version->setEnabled(true);
ui->variant->setEnabled(true);
if (firmware.hasSplash()) { if (firmware.isValid()) {
ui->splashFrame->show(); ui->firmwareInfoFrame->show();
ui->splash->setFixedSize(firmware.getSplashWidth(), firmware.getSplashHeight()); ui->date->setText(firmware.getDate() + " " + firmware.getTime());
ui->version->setText(firmware.getVersion());
ui->variant->setText(firmware.getFlavour());
if (firmware.hasSplash()) {
ui->splashFrame->show();
ui->splash->setFixedSize(firmware.getSplashWidth(), firmware.getSplashHeight());
QImage image;
switch (imageSource) {
case FIRMWARE:
ui->useFirmwareSplash->setChecked(true);
image = firmware.getSplash();
break;
case PROFILE:
ui->useProfileSplash->setChecked(true);
image.load(g.currentProfile().splashFile());
break;
case LIBRARY:
ui->useLibrarySplash->setChecked(true);
image.load(imageFile);
break;
case EXTERNAL:
ui->useExternalSplash->setChecked(true);
image.load(imageFile);
break;
}
if (!image.isNull())
ui->splash->setPixmap(makePixMap(image));
else
ui->splash->setPixmap(QPixmap());
} else {
ui->splashFrame->hide();
}
} else { } else {
ui->firmwareInfoFrame->hide();
ui->splashFrame->hide(); ui->splashFrame->hide();
} }
} else { } else {
imageSource = FIRMWARE; ui->firmwareFilename->setText("");
ui->loadButton->setEnabled(false);
ui->writeButton->setEnabled(false);
ui->firmwareInfoFrame->hide(); ui->firmwareInfoFrame->hide();
ui->splashFrame->hide(); ui->splashFrame->hide();
} }
QImage image; // add resize event to queue after changes above
switch (imageSource) { QTimer::singleShot(0, [=]() { shrink(); });
case FIRMWARE:
ui->useFirmwareSplash->setChecked(true);
image = firmware.getSplash();
break;
case PROFILE:
ui->useProfileSplash->setChecked(true);
image.load(g.currentProfile().splashFile());
break;
case LIBRARY:
ui->useLibrarySplash->setChecked(true);
image.load(imageFile);
break;
case EXTERNAL:
ui->useExternalSplash->setChecked(true);
image.load(imageFile);
break;
}
if (!image.isNull())
ui->splash->setPixmap(makePixMap(image));
QTimer::singleShot(0, [=]() { adjustSize(); });
} }
void FlashFirmwareDialog::loadClicked() void FlashFirmwareDialog::loadClicked()
@@ -133,6 +152,7 @@ void FlashFirmwareDialog::loadClicked()
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"), QString fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"),
g.flashDir(), g.flashDir(),
getFirmwareFilesFilter()); getFirmwareFilesFilter());
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if (!firmwareFileExtensions().contains(QFileInfo(fileName).suffix().toLower())) { if (!firmwareFileExtensions().contains(QFileInfo(fileName).suffix().toLower())) {
QMessageBox::critical(this, tr("Open Firmware File"), QMessageBox::critical(this, tr("Open Firmware File"),
@@ -141,32 +161,35 @@ void FlashFirmwareDialog::loadClicked()
return; return;
} }
FirmwareInterface fw(fileName); FirmwareInterface newfw(fileName);
if (!fw.isValid()) { if (chkHWComp->isChecked()) {
QMessageBox::critical(this, tr("Open Firmware File"), if (!newfw.isValid()) {
tr("%1 is not a valid firmware file")
.arg(fileName));
return;
}
if (connectionMode == CONNECTION_UF2) {
const Uf2Info uf2(getUf2Info());
if (fw.getFlavour() != uf2.board) {
QMessageBox::critical(this, tr("Open Firmware File"), QMessageBox::critical(this, tr("Open Firmware File"),
tr("%1 \nFirmware file is for %2 radio however connected radio is %3") tr("Error - %1 is not a valid firmware file")
.arg(fileName) .arg(fileName));
.arg(fw.getFlavour())
.arg(uf2.board));
return; return;
} }
if (connectionMode == CONNECTION_UF2) {
const Uf2Info uf2(getUf2Info());
if (newfw.getFlavour() != uf2.board) {
QMessageBox::critical(this, tr("Open Firmware File"),
tr("%1 \nIncompatability - File: '%2' Connected radio: '%3'")
.arg(fileName)
.arg(newfw.getFlavour())
.arg(uf2.board));
return;
}
}
} }
if (fw.getFlavour() != getCurrentFirmware()->getFlavour()) { if (chkProfComp->isChecked() &&
newfw.getFlavour() != getCurrentFirmware()->getFlavour()) {
QMessageBox::critical(this, tr("Open Firmware File"), QMessageBox::critical(this, tr("Open Firmware File"),
tr("%1 \nFirmware file is for %2 radio however profile is for %3 radio") tr("%1 \nIncompatability - File: '%2' Profile: '%3'")
.arg(fileName) .arg(fileName)
.arg(fw.getFlavour()) .arg(newfw.getFlavour())
.arg(getCurrentFirmware()->getFlavour())); .arg(getCurrentFirmware()->getFlavour()));
return; return;
} }
@@ -184,7 +207,7 @@ void FlashFirmwareDialog::useFirmwareSplashClicked()
QMessageBox::warning(this, CPN_STR_TTL_ERROR, tr( "The firmware file is not valid." )); QMessageBox::warning(this, CPN_STR_TTL_ERROR, tr( "The firmware file is not valid." ));
} else if (!firmware.hasSplash()) { } else if (!firmware.hasSplash()) {
QMessageBox::warning(this, CPN_STR_TTL_ERROR, QMessageBox::warning(this, CPN_STR_TTL_ERROR,
tr( "There is no start screen image in the firmware file." )); tr( "The firmware file does not cntain a start screen image." ));
} else { } else {
imageSource = FIRMWARE; imageSource = FIRMWARE;
} }
@@ -261,7 +284,6 @@ void FlashFirmwareDialog::writeButtonClicked()
{ {
g.flashDir(QFileInfo(fwName).dir().absolutePath()); g.flashDir(QFileInfo(fwName).dir().absolutePath());
g.currentProfile().fwName(fwName); g.currentProfile().fwName(fwName);
g.checkHardwareCompatibility(ui->checkHardwareCompatibility->isChecked());
g.backupOnFlash(ui->checkBackup->isChecked()); g.backupOnFlash(ui->checkBackup->isChecked());
if (imageSource != FIRMWARE) { if (imageSource != FIRMWARE) {
@@ -301,35 +323,54 @@ void FlashFirmwareDialog::startWrite(const QString &filename)
CompanionIcon("write_flash.png")); CompanionIcon("write_flash.png"));
auto progress = progressDialog.progress(); auto progress = progressDialog.progress();
bool checkHw = g.checkHardwareCompatibility(); bool checkHw = chkHWComp->isChecked();
bool checkProfile = chkProfComp->isChecked();
bool backup = g.backupOnFlash(); bool backup = g.backupOnFlash();
FirmwareInterface newfw(filename); FirmwareInterface newfw(filename);
if (g.checkHardwareCompatibility() || backup) { if (checkHw || checkProfile || backup) {
progress->updateInfoAndMessages(tr("Reading old firmware...")); progress->updateInfoAndMessages(tr("Reading old firmware..."));
readFirmware( readFirmware(
[this, &newfw, progress, checkHw, backup](const QByteArray &_data) { [this, &newfw, progress, checkHw, checkProfile, backup](const QByteArray &_data) {
FirmwareInterface currfw(_data); FirmwareInterface currfw(_data);
if (!currfw.isValid()) {
QString errMsg(tr("Firmware read from radio invalid"));
progress->addMessage(errMsg, QtFatalMsg);
progress->setInfo(errMsg);
return;
}
if (backup) { qDebug() << "profile:" << getCurrentFirmware()->getFlavour()
progress->addMessage(tr("Backing up old firmware")); << "current:" << currfw.getFlavour()
if (!writeFirmwareToFile(this, _data, progress)) { << "new:" << newfw.getFlavour();
if (checkHw) {
if (!currfw.isValid()) {
QString errMsg(tr("Firmware read from radio invalid"));
progress->addMessage(errMsg, QtFatalMsg);
progress->setInfo(errMsg);
return;
}
progress->addMessage(tr("Performing hardware compatibity check"));
if (!newfw.isHardwareCompatible(currfw)) {
QString errMsg(tr("New firmware is not compatible with current firmware"));
progress->updateInfoAndMessages(errMsg, QtFatalMsg);
return; return;
} }
} }
if (checkHw) { if (checkProfile) {
progress->addMessage(tr("Performing compatibity check")); progress->addMessage(tr("Performing profile compatibity check"));
if (!newfw.isHardwareCompatible(currfw)) { if (currfw.getFlavour() != getCurrentFirmware()->getFlavour()) {
QString errMsg(tr("New firmware is not compatible with old firmware")); QString errMsg(tr("Current firmware is not compatible with profile"));
progress->updateInfoAndMessages(errMsg, QtFatalMsg); progress->updateInfoAndMessages(errMsg, QtFatalMsg);
return; return;
} else if (newfw.getFlavour() != getCurrentFirmware()->getFlavour()) {
QString errMsg(tr("New firmware is not compatible with profile"));
progress->updateInfoAndMessages(errMsg, QtFatalMsg);
return;
}
}
if (backup) {
progress->addMessage(tr("Backing up current firmware"));
if (!writeFirmwareToFile(this, _data, progress)) {
return;
} }
} }
@@ -364,7 +405,7 @@ void FlashFirmwareDialog::detectClicked(bool atLoad)
connectionMsg = tr("Radio connection mode: DFU"); connectionMsg = tr("Radio connection mode: DFU");
} else { } else {
connectionMode = CONNECTION_NONE; connectionMode = CONNECTION_NONE;
connectionMsg = tr("ALERT: No radio connected"); connectionMsg = tr("ALERT: No radio detected");
} }
ui->connectionMode->setText(connectionMsg); ui->connectionMode->setText(connectionMsg);
@@ -376,9 +417,6 @@ void FlashFirmwareDialog::detectClicked(bool atLoad)
tr("Note: USB mode is not suitable for flashing firmware.")); tr("Note: USB mode is not suitable for flashing firmware."));
} }
if (!isFileConnectionCompatible())
fwName.clear();
if (!atLoad) if (!atLoad)
updateUI(); updateUI();
} }
@@ -395,3 +433,9 @@ bool FlashFirmwareDialog::isFileConnectionCompatible()
return false; return false;
} }
void FlashFirmwareDialog::shrink()
{
this->adjustSize();
this->resize(0, 0);
}
+15 -2
View File
@@ -50,13 +50,26 @@ class FlashFirmwareDialog : public QDialog
void startWrite(const QString &filename); void startWrite(const QString &filename);
private: private:
enum ConnectionModes { CONNECTION_NONE, CONNECTION_UF2, CONNECTION_DFU }; enum ConnectionModes {
enum ImageSource {FIRMWARE, PROFILE, LIBRARY, EXTERNAL}; CONNECTION_NONE,
CONNECTION_UF2,
CONNECTION_DFU
};
enum ImageSource {
FIRMWARE,
PROFILE,
LIBRARY,
EXTERNAL
};
Ui::FlashFirmwareDialog *ui; Ui::FlashFirmwareDialog *ui;
QString fwName; QString fwName;
ImageSource imageSource; ImageSource imageSource;
QString imageFile; QString imageFile;
int connectionMode; int connectionMode;
QCheckBox *chkHWComp;
QCheckBox *chkProfComp;
bool isFileConnectionCompatible(); bool isFileConnectionCompatible();
void shrink();
}; };
+13 -18
View File
@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>421</width> <width>421</width>
<height>390</height> <height>396</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@@ -264,32 +264,19 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkHardwareCompatibility">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Checks the new firmware matches the connected radio. If not the process will be aborted.</string>
</property>
<property name="text">
<string>Check hardware compatibility (recommended)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkBackup"> <widget class="QCheckBox" name="checkBackup">
<property name="toolTip"> <property name="toolTip">
<string>Read the connected radio firmware and write to the backup folder.</string> <string>Read the connected radio firmware and write to the backup folder.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Backup radio firmware before flashing</string> <string>Backup current radio firmware before flashing</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="AutoCollapsibleSection" name="advancedWidget" native="true"/>
</item>
<item> <item>
<spacer name="spacer2"> <spacer name="spacer2">
<property name="orientation"> <property name="orientation">
@@ -354,6 +341,14 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>AutoCollapsibleSection</class>
<extends>QWidget</extends>
<header>autocollapsiblesection.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>writeButton</tabstop> <tabstop>writeButton</tabstop>
<tabstop>firmwareFilename</tabstop> <tabstop>firmwareFilename</tabstop>
+1
View File
@@ -6,6 +6,7 @@ set(${PROJECT_NAME}_NAMES
autobitmappedcombobox autobitmappedcombobox
autobitsetcheckbox autobitsetcheckbox
autocheckbox autocheckbox
autocollapsiblesection
autocombobox autocombobox
autodoublespinbox autodoublespinbox
autohexspinbox autohexspinbox
@@ -0,0 +1,139 @@
/*
* 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.
*
* Based on
*
Elypson/qt-collapsible-section
(c) 2016 Michael A. Voelkel - michael.alexander.voelkel@gmail.com
This file is part of Elypson/qt-collapsible section.
Elypson/qt-collapsible-section is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Elypson/qt-collapsible-section 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 Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with Elypson/qt-collapsible-section. If not, see <http://www.gnu.org/licenses/>.
*/
#include "autocollapsiblesection.h"
#include <QPropertyAnimation>
AutoCollapsibleSection::AutoCollapsibleSection(QWidget * parent) :
QWidget(parent)
{
toggleButton = new QToolButton(this);
headerLine = new QFrame(this);
toggleAnimation = new QParallelAnimationGroup(this);
contentArea = new QScrollArea(this);
mainLayout = new QGridLayout(this);
toggleButton->setStyleSheet("QToolButton {border: none;}");
toggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toggleButton->setArrowType(Qt::ArrowType::RightArrow);
toggleButton->setText(title);
toggleButton->setCheckable(true);
toggleButton->setChecked(false);
headerLine->setFrameShape(QFrame::HLine);
headerLine->setFrameShadow(QFrame::Sunken);
headerLine->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
contentArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// start out collapsed
contentArea->setMaximumHeight(0);
contentArea->setMinimumHeight(0);
// let the entire widget grow and shrink with its content
toggleAnimation->addAnimation(new QPropertyAnimation(this, "maximumHeight"));
toggleAnimation->addAnimation(new QPropertyAnimation(this, "minimumHeight"));
toggleAnimation->addAnimation(new QPropertyAnimation(contentArea, "maximumHeight"));
mainLayout->setVerticalSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
int row = 0;
mainLayout->addWidget(toggleButton, row, 0, 1, 1, Qt::AlignLeft);
mainLayout->addWidget(headerLine, row++, 2, 1, 1);
mainLayout->addWidget(contentArea, row, 0, 1, 3);
setLayout(mainLayout);
connect(toggleButton, &QToolButton::toggled, this, &AutoCollapsibleSection::toggle);
connect(toggleAnimation, &QParallelAnimationGroup::finished, [this] () { emit resized(); });
}
void AutoCollapsibleSection::setAnimationDuration(const int duration)
{
animationDuration = duration;
}
void AutoCollapsibleSection::setContentLayout(QLayout & contentLayout)
{
delete contentArea->layout();
contentArea->setLayout(&contentLayout);
collapsedHeight = sizeHint().height() - contentArea->maximumHeight();
updateHeights();
}
void AutoCollapsibleSection::setTitle(const QString & title)
{
toggleButton->setText(title);
}
void AutoCollapsibleSection::toggle(bool expanded)
{
toggleButton->setArrowType(expanded ? Qt::ArrowType::DownArrow :
Qt::ArrowType::RightArrow);
toggleAnimation->setDirection(expanded ? QAbstractAnimation::Forward :
QAbstractAnimation::Backward);
toggleAnimation->start();
isExpanded = expanded;
}
void AutoCollapsibleSection::updateHeights()
{
int contentHeight = contentArea->layout()->sizeHint().height();
for (int i = 0; i < toggleAnimation->animationCount() - 1; ++i) {
QPropertyAnimation* SectionAnimation = static_cast<QPropertyAnimation *>
(toggleAnimation->animationAt(i));
SectionAnimation->setDuration(animationDuration);
SectionAnimation->setStartValue(collapsedHeight);
SectionAnimation->setEndValue(collapsedHeight + contentHeight);
}
QPropertyAnimation* contentAnimation = static_cast<QPropertyAnimation *>
(toggleAnimation->animationAt(toggleAnimation->animationCount() - 1));
contentAnimation->setDuration(animationDuration);
contentAnimation->setStartValue(0);
contentAnimation->setEndValue(contentHeight);
toggleAnimation->setDirection(isExpanded ? QAbstractAnimation::Forward :
QAbstractAnimation::Backward);
toggleAnimation->start();
}
@@ -0,0 +1,87 @@
/*
* 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.
*
* Based on
*
Elypson/qt-collapsible-section
(c) 2016 Michael A. Voelkel - michael.alexander.voelkel@gmail.com
This file is part of Elypson/qt-collapsible section.
Elypson/qt-collapsible-section is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Elypson/qt-collapsible-section 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 Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with Elypson/qt-collapsible-section. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QFrame>
#include <QGridLayout>
#include <QParallelAnimationGroup>
#include <QScrollArea>
#include <QToolButton>
#include <QWidget>
class AutoCollapsibleSection : public QWidget
{
Q_OBJECT
public:
static const int DEFAULT_DURATION = 0;
explicit AutoCollapsibleSection(QWidget * parent = nullptr);
// setters
void setAnimationDuration(const int duration);
void setContentLayout(QLayout & contentLayout);
void setTitle(const QString & title);
// getters
const int getAnimationDuration() { return animationDuration; }
void updateHeights();
signals:
// inform parent that expand/collapse animation finished
void resized();
public slots:
void toggle(bool collapsed);
private:
QGridLayout *mainLayout;
QToolButton *toggleButton;
QFrame *headerLine;
QParallelAnimationGroup *toggleAnimation;
QScrollArea *contentArea;
int animationDuration = DEFAULT_DURATION;
int collapsedHeight;
bool isExpanded = false;
QString title;
};
-1
View File
@@ -776,7 +776,6 @@ class AppData: public CompStoreObj
PROPERTY(bool, enableBackup, false) PROPERTY(bool, enableBackup, false)
PROPERTY(bool, backupOnFlash, true) PROPERTY(bool, backupOnFlash, true)
PROPERTY(bool, outputDisplayDetails, false) PROPERTY(bool, outputDisplayDetails, false)
PROPERTY(bool, checkHardwareCompatibility, true)
PROPERTY(bool, removeModelSlots, true) PROPERTY(bool, removeModelSlots, true)
PROPERTY(bool, maximized, false) PROPERTY(bool, maximized, false)
PROPERTY(bool, tabbedMdi, false) PROPERTY(bool, tabbedMdi, false)