2020-04-07 13:20:52 +00:00
|
|
|
#include "MapFileDialog.h"
|
|
|
|
#include "ui_MapFileDialog.h"
|
2018-06-20 09:24:28 +00:00
|
|
|
|
2019-01-29 17:37:09 +00:00
|
|
|
#include "common/Configuration.h"
|
|
|
|
|
2018-06-20 09:24:28 +00:00
|
|
|
#include <QFileDialog>
|
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
MapFileDialog::MapFileDialog(QWidget *parent):
|
2018-06-20 09:24:28 +00:00
|
|
|
QDialog(parent),
|
2020-04-07 13:20:52 +00:00
|
|
|
ui(new Ui::MapFileDialog)
|
2018-06-20 09:24:28 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
MapFileDialog::~MapFileDialog() {}
|
2018-06-20 09:24:28 +00:00
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
void MapFileDialog::on_selectFileButton_clicked()
|
2018-06-20 09:24:28 +00:00
|
|
|
{
|
2019-01-29 17:37:09 +00:00
|
|
|
QString currentDir = Config()->getRecentFolder();
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("Select file"), currentDir);
|
2018-06-20 09:24:28 +00:00
|
|
|
|
|
|
|
if (!fileName.isEmpty()) {
|
|
|
|
ui->filenameLineEdit->setText(fileName);
|
2019-01-29 17:37:09 +00:00
|
|
|
Config()->setRecentFolder(QFileInfo(fileName).absolutePath());
|
2018-06-20 09:24:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
void MapFileDialog::on_buttonBox_accepted()
|
2018-06-20 09:24:28 +00:00
|
|
|
{
|
2018-11-02 06:48:17 +00:00
|
|
|
const QString &filePath = QDir::toNativeSeparators(ui->filenameLineEdit->text());
|
2018-06-20 09:24:28 +00:00
|
|
|
RVA mapAddress = RVA_INVALID;
|
|
|
|
QString mapAddressStr = ui->mapAddressLineEdit->text();
|
2018-11-02 06:48:17 +00:00
|
|
|
if (!mapAddressStr.isEmpty()) {
|
2018-06-20 09:24:28 +00:00
|
|
|
mapAddress = Core()->math(mapAddressStr);
|
|
|
|
}
|
2019-02-05 19:35:54 +00:00
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
if (!Core()->mapFile(filePath, mapAddress)) {
|
|
|
|
QMessageBox::critical(this, tr("Map new file file"), tr("Failed to map a new file"));
|
2019-02-05 19:35:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
close();
|
2018-06-20 09:24:28 +00:00
|
|
|
}
|
|
|
|
|
2020-04-07 13:20:52 +00:00
|
|
|
void MapFileDialog::on_buttonBox_rejected()
|
2018-06-20 09:24:28 +00:00
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|