mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-20 11:33:28 -05:00
Set sensible default paths when browsing using FileSelection
Previously FileSelection would default to the OBS run dir
This commit is contained in:
parent
c16b97e5cd
commit
f99eb6c3c8
|
|
@ -3,6 +3,8 @@
|
|||
#include <obs-module.h>
|
||||
#include <QLayout>
|
||||
#include <QFileDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <filesystem>
|
||||
|
||||
FileSelection::FileSelection(FileSelection::Type type, QWidget *parent)
|
||||
: QWidget(parent), _type(type)
|
||||
|
|
@ -29,12 +31,22 @@ void FileSelection::SetPath(const QString &path)
|
|||
|
||||
void FileSelection::BrowseButtonClicked()
|
||||
{
|
||||
QString defaultPath;
|
||||
if (std::filesystem::exists(
|
||||
std::filesystem::path(_filePath->text().toStdString()))) {
|
||||
defaultPath = _filePath->text();
|
||||
} else {
|
||||
defaultPath = QStandardPaths::writableLocation(
|
||||
QStandardPaths::DesktopLocation);
|
||||
}
|
||||
|
||||
QString path;
|
||||
if (_type == FileSelection::Type::WRITE) {
|
||||
path = QFileDialog::getSaveFileName(this);
|
||||
path = QFileDialog::getSaveFileName(this, "", defaultPath);
|
||||
} else {
|
||||
path = QFileDialog::getOpenFileName(this);
|
||||
path = QFileDialog::getOpenFileName(this, "", defaultPath);
|
||||
}
|
||||
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user