mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 13:15:43 -05:00
Add ValidPathOrDesktop() helper function
This commit is contained in:
@@ -29,17 +29,19 @@ void FileSelection::SetPath(const QString &path)
|
||||
_filePath->setText(path);
|
||||
}
|
||||
|
||||
QString FileSelection::ValidPathOrDesktop(const QString &path)
|
||||
{
|
||||
if (std::filesystem::exists(
|
||||
std::filesystem::path(path.toStdString()))) {
|
||||
return path;
|
||||
}
|
||||
return QStandardPaths::writableLocation(
|
||||
QStandardPaths::DesktopLocation);
|
||||
}
|
||||
|
||||
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 defaultPath = ValidPathOrDesktop(_filePath->text());
|
||||
QString path;
|
||||
if (_type == FileSelection::Type::WRITE) {
|
||||
path = QFileDialog::getSaveFileName(this, "", defaultPath);
|
||||
|
||||
Reference in New Issue
Block a user