Store file path between load dialog invocations
MODIFY
src/loaddialog.cpp
src/loaddialog.cpp
namespace Ripes {
LoadDialog::TypeButtonID LoadDialog::s_typeIndex = TypeButtonID::Assembly;
+QString LoadDialog::s_filePath = QString();
LoadDialog::LoadDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::LoadDialog) {
m_ui->setupUi(this);
@@ -52,8 +53,8 @@ LoadDialog::LoadDialog(QWidget* parent) : QDialog(parent), m_ui(new Ui::LoadDial
m_ui->currentISA->setText(ProcessorHandler::get()->currentISA()->name());
// default selection
+ m_ui->filePath->setText(s_filePath);
m_fileTypeButtons->button(s_typeIndex)->toggle();
- validateCurrentFile();
}
void LoadDialog::inputTypeChanged() {
@@ -100,8 +101,10 @@ void LoadDialog::openFileButtonTriggered() {
}
const auto filename = QFileDialog::getOpenFileName(this, title, "", filter);
+ if (!filename.isEmpty()) {
m_ui->filePath->setText(filename);
}
+}
void LoadDialog::paletteValidate(QWidget* w, bool valid) {
QPalette palette = this->palette();
@@ -215,6 +218,7 @@ bool LoadDialog::fileTypeValidate(const QFile& file) {
void LoadDialog::validateCurrentFile() {
const QString& filename = m_ui->filePath->text();
+ s_filePath = filename;
QFile file(filename);
const bool filePathValid = file.exists();
bool fileTypeValid = false;

MODIFY
src/loaddialog.h
src/loaddialog.h
@@ -47,6 +47,7 @@ private slots:
private:
enum TypeButtonID { Assembly, FlatBinary, ELF };
static TypeButtonID s_typeIndex;
+ static QString s_filePath;
void setElfInfo(const ELFInfo& info);
bool fileTypeValidate(const QFile& file);

Store file path between load dialog invocations