mirror of
https://github.com/isledecomp/SIEdit.git
synced 2024-11-23 07:38:09 -05:00
app: implement export option
This commit is contained in:
parent
7968e70031
commit
ea3bee369d
2 changed files with 24 additions and 0 deletions
|
@ -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_;
|
||||
|
|
|
@ -52,6 +52,8 @@ private slots:
|
|||
//bool SaveFile();
|
||||
//bool SaveFileAs();
|
||||
|
||||
void ExportFile();
|
||||
|
||||
void SelectionChanged(const QModelIndex &index);
|
||||
|
||||
void ShowContextMenu(const QPoint &p);
|
||||
|
|
Loading…
Reference in a new issue