Qt: Add forwarder building from a specific base file

This commit is contained in:
Vicki Pfau 2022-11-06 22:26:41 -08:00
parent 8770200874
commit c4384d1d1e
4 changed files with 32 additions and 4 deletions

View File

@ -65,7 +65,11 @@ void ForwarderController::startBuild(const QString& outFilename) {
return; return;
} }
} }
downloadManifest(); if (m_baseFilename.isEmpty()) {
downloadManifest();
} else {
m_generator->rebuild(m_baseFilename, m_outFilename);
}
} }
void ForwarderController::downloadForwarderKit() { void ForwarderController::downloadForwarderKit() {
@ -201,7 +205,9 @@ void ForwarderController::gotBuild(QNetworkReply* reply) {
} }
void ForwarderController::cleanup() { void ForwarderController::cleanup() {
m_sourceFile.remove(); if (m_sourceFile.exists()) {
m_sourceFile.remove();
}
m_inProgress = false; m_inProgress = false;
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #if defined(Q_OS_WIN) || defined(Q_OS_MAC)

View File

@ -30,6 +30,10 @@ public:
void setGenerator(std::unique_ptr<ForwarderGenerator>&& generator); void setGenerator(std::unique_ptr<ForwarderGenerator>&& generator);
ForwarderGenerator* generator() { return m_generator.get(); } ForwarderGenerator* generator() { return m_generator.get(); }
void setBaseFilename(const QString& path) { m_baseFilename = path; }
void clearBaseFilename() { m_baseFilename = QString(); }
QString baseFilename() const { return m_baseFilename; }
QString channel() const { return m_channel; } QString channel() const { return m_channel; }
bool inProgress() const { return m_inProgress; } bool inProgress() const { return m_inProgress; }
@ -62,6 +66,7 @@ private:
QString m_outFilename; QString m_outFilename;
std::unique_ptr<ForwarderGenerator> m_generator; std::unique_ptr<ForwarderGenerator> m_generator;
QFile m_sourceFile; QFile m_sourceFile;
QString m_baseFilename;
bool m_inProgress = false; bool m_inProgress = false;
QByteArray m_originalPath; QByteArray m_originalPath;
}; };

View File

@ -94,6 +94,11 @@ void ForwarderView::build() {
} }
m_controller.generator()->setTitle(m_ui.title->text()); m_controller.generator()->setTitle(m_ui.title->text());
m_controller.generator()->setRom(m_ui.romFilename->text()); m_controller.generator()->setRom(m_ui.romFilename->text());
if (m_ui.baseType->currentIndex() == 2) {
m_controller.setBaseFilename(m_ui.baseFilename->text());
} else {
m_controller.clearBaseFilename();
}
m_controller.startBuild(m_ui.outputFilename->text()); m_controller.startBuild(m_ui.outputFilename->text());
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_ui.progressBar->setEnabled(true); m_ui.progressBar->setEnabled(true);
@ -120,9 +125,21 @@ void ForwarderView::validate() {
if (!m_ui.system->checkedButton()) { if (!m_ui.system->checkedButton()) {
valid = false; valid = false;
} }
if (m_ui.baseType->currentIndex() != 1) { if (m_ui.baseType->currentIndex() < 1) {
valid = false; valid = false;
} }
if (m_ui.baseType->currentIndex() == 2) {
m_ui.baseFilename->setEnabled(true);
m_ui.baseLabel->setEnabled(true);
m_ui.baseBrowse->setEnabled(true);
if (m_ui.baseFilename->text().isEmpty()) {
valid = false;
}
} else {
m_ui.baseFilename->setEnabled(true);
m_ui.baseLabel->setEnabled(true);
m_ui.baseBrowse->setEnabled(true);
}
if (m_controller.inProgress()) { if (m_controller.inProgress()) {
valid = false; valid = false;
} }

View File

@ -87,7 +87,7 @@
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="baseLabel">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>