app: implement export option

This commit is contained in:
itsmattkc 2022-07-11 14:20:05 -07:00
parent 7968e70031
commit ea3bee369d
2 changed files with 24 additions and 0 deletions

View file

@ -96,6 +96,7 @@ void MainWindow::InitializeMenuBar()
file_menu->addSeparator();
auto export_action = file_menu->addAction(tr("&Export"));
connect(export_action, &QAction::triggered, this, &MainWindow::ExportFile);
file_menu->addSeparator();
@ -123,6 +124,12 @@ void MainWindow::ExtractObject(si::Object *obj)
if (filename.isEmpty()) {
filename = QString::fromStdString(obj->name());
filename.append(QStringLiteral(".bin"));
} else {
// Strip off directory
int index = filename.lastIndexOf('\\');
if (index != -1) {
filename = filename.mid(index+1);
}
}
QString s = QFileDialog::getSaveFileName(this, tr("Export Object"), filename);
@ -146,6 +153,21 @@ void MainWindow::OpenFile()
}
}
void MainWindow::ExportFile()
{
Chunk *c = interleaf_.Export();
SIViewDialog d(SIViewDialog::Export, c, this);
if (d.exec() == QDialog::Accepted) {
QString s = QFileDialog::getSaveFileName(this);
if (!s.isEmpty()) {
if (!c->Write(s.toStdString())) {
QMessageBox::critical(this, QString(), tr("Failed to write SI file."));
}
}
}
delete c;
}
void MainWindow::SelectionChanged(const QModelIndex &index)
{
Panel *p = panel_blank_;

View file

@ -52,6 +52,8 @@ private slots:
//bool SaveFile();
//bool SaveFileAs();
void ExportFile();
void SelectionChanged(const QModelIndex &index);
void ShowContextMenu(const QPoint &p);