From 15baf36b06545e5c17638c51b5f6f5560760ef89 Mon Sep 17 00:00:00 2001 From: CURTLab Date: Tue, 26 Mar 2024 20:19:05 +0100 Subject: [PATCH] Added support to save corrected tsf file --- BleedThroughCorrection/Correction.h | 2 +- BleedThroughCorrection/MainWindow.cpp | 16 ++++++++++++++++ BleedThroughCorrection/MainWindow.ui | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/BleedThroughCorrection/Correction.h b/BleedThroughCorrection/Correction.h index f4c8a8a..fbf56ab 100644 --- a/BleedThroughCorrection/Correction.h +++ b/BleedThroughCorrection/Correction.h @@ -48,7 +48,7 @@ class Correction : public QObject inline constexpr const QString &fileName() const { return m_fileName; } inline constexpr const Localizations &localizations() const { return m_locs; } - inline constexpr const Localizations &correctedLocalizations() const { return m_corrected; } + inline constexpr Localizations &correctedLocalizations() { return m_corrected; } signals: void localizationsLoaded(); diff --git a/BleedThroughCorrection/MainWindow.cpp b/BleedThroughCorrection/MainWindow.cpp index c7d6966..d8b8719 100644 --- a/BleedThroughCorrection/MainWindow.cpp +++ b/BleedThroughCorrection/MainWindow.cpp @@ -50,6 +50,8 @@ MainWindow::MainWindow(QWidget *parent) m_bar->setVisible(false); m_ui->preview->setColorMap(ColorMap::Hot); + m_ui->buttonSaveCorrection->setEnabled(false); + m_ui->splitter->setSizes({250, width()-250}); connect(m_ui->spinPenWidth, qOverload(&QSpinBox::valueChanged), @@ -197,6 +199,20 @@ MainWindow::MainWindow(QWidget *parent) }); m_ui->preview->setImage(image); m_ui->frame->setEnabled(true); + m_ui->buttonSaveCorrection->setEnabled(true); + }); + + connect(m_ui->buttonSaveCorrection, &QAbstractButton::clicked, this, [this]() { + QFileInfo fi(m_ui->editFile->text()); + QString defaultFile = m_ui->editFile->text().isEmpty() ? "" : fi.absolutePath() + "/" + fi.baseName() + "_bleedCorr.tsf"; + QString fileName = QFileDialog::getSaveFileName(this, tr("Save corrected localization file"), defaultFile, "TSF file (*.tsf)"); + + try { + if (!fileName.isEmpty()) + m_correction.correctedLocalizations().save(fileName.toStdString()); + } catch (std::exception &e) { + QMessageBox::critical(this, tr("Error"), tr("Could not save correct TSF file.\nReason: %1").arg(e.what())); + } }); diff --git a/BleedThroughCorrection/MainWindow.ui b/BleedThroughCorrection/MainWindow.ui index 7e23089..61a05cf 100644 --- a/BleedThroughCorrection/MainWindow.ui +++ b/BleedThroughCorrection/MainWindow.ui @@ -388,6 +388,13 @@ + + + + Save + + +