Skip to content

Commit

Permalink
Added support to save corrected tsf file
Browse files Browse the repository at this point in the history
  • Loading branch information
CURTLab committed Mar 26, 2024
1 parent 13d9833 commit 15baf36
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BleedThroughCorrection/Correction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions BleedThroughCorrection/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(&QSpinBox::valueChanged),
Expand Down Expand Up @@ -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()));
}
});


Expand Down
7 changes: 7 additions & 0 deletions BleedThroughCorrection/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="buttonSaveCorrection">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 15baf36

Please sign in to comment.