From e2bb45fd8fd17c21194c2049d8bc138713f0e0bd Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 25 Mar 2019 15:12:55 +0000 Subject: [PATCH] Restore removed LastCaptureExe saving last exe selected. Closes #1318 --- qrenderdoc/Code/Interface/PersistantConfig.h | 6 ++++++ qrenderdoc/Code/QRDUtils.cpp | 4 +++- qrenderdoc/Code/QRDUtils.h | 1 + qrenderdoc/Windows/Dialogs/CaptureDialog.cpp | 7 ++++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index f24f5c12a..6593bc4b6 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -274,6 +274,8 @@ DECLARE_REFLECTION_STRUCT(BugReport); \ CONFIG_SETTING_VAL(public, QString, rdcstr, LastCapturePath, "") \ \ + CONFIG_SETTING_VAL(public, QString, rdcstr, LastCaptureExe, "") \ + \ CONFIG_SETTING(public, QVariantList, rdcarray, RecentCaptureSettings) \ \ CONFIG_SETTING_VAL(public, QString, rdcstr, TemporaryCaptureDirectory, "") \ @@ -459,6 +461,10 @@ For more information about some of these settings that are user-facing see The path containing the last executable that was captured, which is useful as a default location for browsing. +.. data:: LastCaptureExe + + The filename of the last executable that was captured, inside :data:`LastCapturePath`. + .. data:: RecentCaptureSettings A ``list`` of ``str`` with the recently opened capture settings files. diff --git a/qrenderdoc/Code/QRDUtils.cpp b/qrenderdoc/Code/QRDUtils.cpp index bfcf528b2..561931929 100644 --- a/qrenderdoc/Code/QRDUtils.cpp +++ b/qrenderdoc/Code/QRDUtils.cpp @@ -1153,7 +1153,7 @@ QString RDDialog::getOpenFileName(QWidget *parent, const QString &caption, const } QString RDDialog::getExecutableFileName(QWidget *parent, const QString &caption, const QString &dir, - QFileDialog::Options options) + const QString &defaultExe, QFileDialog::Options options) { QString d = dir; if(d.isEmpty()) @@ -1175,6 +1175,8 @@ QString RDDialog::getExecutableFileName(QWidget *parent, const QString &caption, fileProxy->setRequirePermissions(QDir::Executable); fd.setProxyModel(fileProxy); } + if(!defaultExe.isEmpty()) + fd.selectFile(defaultExe); show(&fd); if(fd.result() == QFileDialog::Accepted) diff --git a/qrenderdoc/Code/QRDUtils.h b/qrenderdoc/Code/QRDUtils.h index 7fa9114f5..b7342418b 100644 --- a/qrenderdoc/Code/QRDUtils.h +++ b/qrenderdoc/Code/QRDUtils.h @@ -564,6 +564,7 @@ struct RDDialog static QString getExecutableFileName(QWidget *parent = NULL, const QString &caption = QString(), const QString &dir = QString(), + const QString &defaultExe = QString(), QFileDialog::Options options = QFileDialog::Options()); static QString getSaveFileName(QWidget *parent = NULL, const QString &caption = QString(), diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp index c6fbc489f..be23b3937 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp @@ -633,12 +633,14 @@ bool CaptureDialog::checkAllowClose() void CaptureDialog::on_exePathBrowse_clicked() { QString initDir; + QString initExe; QFileInfo f(ui->exePath->text()); QDir dir = f.dir(); if(f.isAbsolute() && dir.exists()) { initDir = dir.absolutePath(); + initExe = f.fileName(); } else if(m_Ctx.Replay().CurrentRemote()) { @@ -647,6 +649,8 @@ void CaptureDialog::on_exePathBrowse_clicked() else if(!m_Ctx.Config().LastCapturePath.isEmpty()) { initDir = m_Ctx.Config().LastCapturePath; + if(!m_Ctx.Config().LastCaptureExe.isEmpty()) + initExe = m_Ctx.Config().LastCaptureExe; } QString filename; @@ -659,7 +663,7 @@ void CaptureDialog::on_exePathBrowse_clicked() } else { - filename = RDDialog::getExecutableFileName(this, tr("Choose executable"), initDir); + filename = RDDialog::getExecutableFileName(this, tr("Choose executable"), initDir, initExe); } if(!filename.isEmpty()) @@ -1038,6 +1042,7 @@ void CaptureDialog::SetExecutableFilename(const rdcstr &filename) else { m_Ctx.Config().LastCapturePath = QFileInfo(fn).absolutePath(); + m_Ctx.Config().LastCaptureExe = QFileInfo(fn).fileName(); } m_Ctx.Config().Save();