From c243be2b14ff5701f90e7494b97b0ade7d88b240 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 10 Jul 2023 21:59:33 -0600 Subject: [PATCH] lightpreview: open dialog: start in directory of current file --- lightpreview/mainwindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lightpreview/mainwindow.cpp b/lightpreview/mainwindow.cpp index 97e2b966..040eb803 100644 --- a/lightpreview/mainwindow.cpp +++ b/lightpreview/mainwindow.cpp @@ -409,7 +409,13 @@ void MainWindow::showEvent(QShowEvent *event) void MainWindow::fileOpen() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Map (*.map);; BSP (*.bsp)")); + // open the file browser in the directory containing the currently open file, if there is one + QString currentDir; + if (!m_mapFile.isEmpty()) { + currentDir = QFileInfo(m_mapFile).absolutePath(); + } + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), currentDir, tr("Map (*.map);; BSP (*.bsp)")); if (!fileName.isEmpty()) loadFile(fileName); @@ -693,7 +699,7 @@ void MainWindow::compileThreadExited() delete m_compileThread; m_compileThread = nullptr; - + if (!std::holds_alternative(m_bspdata.bsp)) { return; }