mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Persist a default browse directory for file dialogs, if none is provided
* This provides a slightly more sensible default than the application working directory. * The default is shared across all dialogs and open/save.
This commit is contained in:
@@ -287,6 +287,8 @@ bool PersistantConfig::Load(const rdcstr &filename)
|
||||
|
||||
RENDERDOC_SetConfigSetting("Disassembly_FriendlyNaming", ShaderViewer_FriendlyNaming ? "1" : "0");
|
||||
|
||||
RDDialog::DefaultBrowsePath = LastFileBrowsePath;
|
||||
|
||||
// localhost should always be available as a remote host
|
||||
bool foundLocalhost = false;
|
||||
|
||||
@@ -396,6 +398,8 @@ bool PersistantConfig::Save()
|
||||
|
||||
RENDERDOC_SetConfigSetting("Disassembly_FriendlyNaming", ShaderViewer_FriendlyNaming ? "1" : "0");
|
||||
|
||||
LastFileBrowsePath = RDDialog::DefaultBrowsePath;
|
||||
|
||||
return Serialize(m_Filename);
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,8 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, LastCaptureFilePath, "") \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, LastFileBrowsePath, "") \
|
||||
\
|
||||
CONFIG_SETTING(public, QVariantList, rdcarray<rdcstr>, RecentCaptureFiles) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, LastCapturePath, "") \
|
||||
@@ -332,6 +334,12 @@ For more information about some of these settings that are user-facing see
|
||||
|
||||
The path to the last capture to be opened, which is useful as a default location for browsing.
|
||||
|
||||
.. data:: LastFileBrowsePath
|
||||
|
||||
The path to the last file browsed to in any dialog. Used as a default location for all file
|
||||
browsers without another explicit default directory (such as opening capture files - see
|
||||
:data:`LastCaptureFilePath`).
|
||||
|
||||
.. data:: RecentCaptureFiles
|
||||
|
||||
A ``list`` of ``str`` with the recently opened capture files.
|
||||
|
||||
@@ -859,6 +859,8 @@ bool GUIInvoke::onUIThread()
|
||||
return qApp->thread() == QThread::currentThread();
|
||||
}
|
||||
|
||||
QString RDDialog::DefaultBrowsePath;
|
||||
|
||||
const QMessageBox::StandardButtons RDDialog::YesNoCancel =
|
||||
QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
|
||||
@@ -978,7 +980,11 @@ QString RDDialog::getOpenFileName(QWidget *parent, const QString &caption, const
|
||||
const QString &filter, QString *selectedFilter,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QFileDialog fd(parent, caption, dir, filter);
|
||||
QString d = dir;
|
||||
if(d.isEmpty())
|
||||
d = DefaultBrowsePath;
|
||||
|
||||
QFileDialog fd(parent, caption, d, filter);
|
||||
fd.setFileMode(QFileDialog::ExistingFile);
|
||||
fd.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fd.setOptions(options);
|
||||
@@ -991,7 +997,10 @@ QString RDDialog::getOpenFileName(QWidget *parent, const QString &caption, const
|
||||
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
{
|
||||
DefaultBrowsePath = QFileInfo(files[0]).dir().absolutePath();
|
||||
return files[0];
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
@@ -1000,6 +1009,10 @@ QString RDDialog::getOpenFileName(QWidget *parent, const QString &caption, const
|
||||
QString RDDialog::getExecutableFileName(QWidget *parent, const QString &caption, const QString &dir,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QString d = dir;
|
||||
if(d.isEmpty())
|
||||
d = DefaultBrowsePath;
|
||||
|
||||
QString filter;
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
@@ -1007,7 +1020,7 @@ QString RDDialog::getExecutableFileName(QWidget *parent, const QString &caption,
|
||||
filter = QApplication::translate("RDDialog", "Executables (*.exe);;All Files (*)");
|
||||
#endif
|
||||
|
||||
QFileDialog fd(parent, caption, dir, filter);
|
||||
QFileDialog fd(parent, caption, d, filter);
|
||||
fd.setOptions(options);
|
||||
fd.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
fd.setFileMode(QFileDialog::ExistingFile);
|
||||
@@ -1022,7 +1035,10 @@ QString RDDialog::getExecutableFileName(QWidget *parent, const QString &caption,
|
||||
{
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
{
|
||||
DefaultBrowsePath = QFileInfo(files[0]).dir().absolutePath();
|
||||
return files[0];
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
@@ -1045,7 +1061,11 @@ QString RDDialog::getSaveFileName(QWidget *parent, const QString &caption, const
|
||||
const QString &filter, QString *selectedFilter,
|
||||
QFileDialog::Options options)
|
||||
{
|
||||
QFileDialog fd(parent, caption, dir, filter);
|
||||
QString d = dir;
|
||||
if(d.isEmpty())
|
||||
d = DefaultBrowsePath;
|
||||
|
||||
QFileDialog fd(parent, caption, d, filter);
|
||||
fd.setAcceptMode(QFileDialog::AcceptSave);
|
||||
fd.setOptions(options);
|
||||
const QStringList &defaultSuffixes = getDefaultSuffixesFromFilter(filter);
|
||||
@@ -1064,7 +1084,10 @@ QString RDDialog::getSaveFileName(QWidget *parent, const QString &caption, const
|
||||
|
||||
QStringList files = fd.selectedFiles();
|
||||
if(!files.isEmpty())
|
||||
{
|
||||
DefaultBrowsePath = QFileInfo(files[0]).dir().absolutePath();
|
||||
return files[0];
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
||||
@@ -442,6 +442,8 @@ struct RDDialog
|
||||
{
|
||||
static const QMessageBox::StandardButtons YesNoCancel;
|
||||
|
||||
static QString DefaultBrowsePath;
|
||||
|
||||
static void show(QMenu *menu, QPoint pos);
|
||||
static int show(QDialog *dialog);
|
||||
static QMessageBox::StandardButton messageBox(
|
||||
|
||||
Reference in New Issue
Block a user