Browse Source

UI: Use existing path for file dialogs

Warchamp7 1 year ago
parent
commit
16e86f2d49
2 changed files with 15 additions and 8 deletions
  1. 5 1
      UI/context-bar-controls.cpp
  2. 10 7
      UI/properties-view.cpp

+ 5 - 1
UI/context-bar-controls.cpp

@@ -500,7 +500,11 @@ void ImageSourceToolbar::on_browse_clicked()
 	const char *filter = obs_property_path_filter(p);
 	const char *filter = obs_property_path_filter(p);
 	const char *default_path = obs_property_path_default_path(p);
 	const char *default_path = obs_property_path_default_path(p);
 
 
-	QString path = OpenFile(this, desc, default_path, filter);
+	QString startDir = ui->path->text();
+	if (startDir.isEmpty())
+		startDir = default_path;
+
+	QString path = OpenFile(this, desc, startDir, filter);
 	if (path.isEmpty()) {
 	if (path.isEmpty()) {
 		return;
 		return;
 	}
 	}

+ 10 - 7
UI/properties-view.cpp

@@ -1813,17 +1813,21 @@ bool WidgetInfo::PathChanged(const char *setting)
 	obs_path_type type = obs_property_path_type(property);
 	obs_path_type type = obs_property_path_type(property);
 	const char *filter = obs_property_path_filter(property);
 	const char *filter = obs_property_path_filter(property);
 	const char *default_path = obs_property_path_default_path(property);
 	const char *default_path = obs_property_path_default_path(property);
+
+	QLineEdit *edit = static_cast<QLineEdit *>(widget);
+
+	QString startDir = edit->text();
+	if (startDir.isEmpty())
+		startDir = default_path;
+
 	QString path;
 	QString path;
 
 
 	if (type == OBS_PATH_DIRECTORY)
 	if (type == OBS_PATH_DIRECTORY)
-		path = SelectDirectory(view, QT_UTF8(desc),
-				       QT_UTF8(default_path));
+		path = SelectDirectory(view, QT_UTF8(desc), startDir);
 	else if (type == OBS_PATH_FILE)
 	else if (type == OBS_PATH_FILE)
-		path = OpenFile(view, QT_UTF8(desc), QT_UTF8(default_path),
-				QT_UTF8(filter));
+		path = OpenFile(view, QT_UTF8(desc), startDir, QT_UTF8(filter));
 	else if (type == OBS_PATH_FILE_SAVE)
 	else if (type == OBS_PATH_FILE_SAVE)
-		path = SaveFile(view, QT_UTF8(desc), QT_UTF8(default_path),
-				QT_UTF8(filter));
+		path = SaveFile(view, QT_UTF8(desc), startDir, QT_UTF8(filter));
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 	// TODO: Revisit when QTBUG-42661 is fixed
 	// TODO: Revisit when QTBUG-42661 is fixed
@@ -1833,7 +1837,6 @@ bool WidgetInfo::PathChanged(const char *setting)
 	if (path.isEmpty())
 	if (path.isEmpty())
 		return false;
 		return false;
 
 
-	QLineEdit *edit = static_cast<QLineEdit *>(widget);
 	edit->setText(path);
 	edit->setText(path);
 	obs_data_set_string(view->settings, setting, QT_TO_UTF8(path));
 	obs_data_set_string(view->settings, setting, QT_TO_UTF8(path));
 	return true;
 	return true;