Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/framework/uicomponents/qml/Muse/UiComponents/FilePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Item {
enum PickerType {
File,
Directory,
MultipleDirectories
MultipleDirectories,
Any
}
property int pickerType: FilePicker.PickerType.File

Expand Down Expand Up @@ -120,6 +121,14 @@ Item {
root.pathEdited(selectedDirectories)
break
}
case FilePicker.PickerType.Any:{
var selectedAny = filePickerModel.selectAny()
if (Boolean(selectedAny)) {
root.pathEdited(selectedAny)
}

break
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/framework/uicomponents/view/filepickermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ QString FilePickerModel::selectMultipleDirectories(const QString& selectedDirect
return result.join(";");
}

QString FilePickerModel::selectAny()
{
std::vector<std::string> filter;
for (const QString& nameFilter : m_filter) {
filter.push_back(nameFilter.toStdString());
}

io::path_t file = interactive()->selectSavingFileSync(m_title.toStdString(), m_dir, filter);

if (!file.empty()) {
m_dir = io::dirpath(file).toQString();
}

return file.toQString();
}

void FilePickerModel::setTitle(const QString& title)
{
if (title == m_title) {
Expand Down
1 change: 1 addition & 0 deletions src/framework/uicomponents/view/filepickermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FilePickerModel : public QObject, public muse::Injectable
Q_INVOKABLE QString selectFile();
Q_INVOKABLE QString selectDirectory();
Q_INVOKABLE QString selectMultipleDirectories(const QString& selectedDirectoriesStr);
Q_INVOKABLE QString selectAny();

public slots:
void setTitle(const QString& title);
Expand Down
Loading