MeshLib C++ Docs
Loading...
Searching...
No Matches
MRFileDialog.h
Go to the documentation of this file.
1#pragma once
2#include "exports.h"
4#include "MRMesh/MRSignal.h"
5#include <filesystem>
6#include <functional>
7
8namespace MR
9{
12
13
15struct MRVIEWER_CLASS FileDialogSignals
16{
17public:
18 using SelectFileSignal = Signal<void( const std::filesystem::path& path )>;
19 using SelectFilesSignal = Signal<void( const std::vector<std::filesystem::path>& )>;
22
24 MRVIEWER_API static FileDialogSignals& instance();
25
28
30
33
34private:
35 FileDialogSignals() = default;
36 ~FileDialogSignals() = default;
37};
38
39
41{
43 std::string fileName;
46 std::filesystem::path baseFolder{};
48};
49
52MRVIEWER_API std::filesystem::path openFileDialog( const FileParameters& params = {} );
53
56MRVIEWER_API void openFileDialogAsync( std::function<void( const std::filesystem::path& )> callback, const FileParameters& params = {} );
57
60MRVIEWER_API std::vector<std::filesystem::path> openFilesDialog( const FileParameters& params = {} );
61
64MRVIEWER_API void openFilesDialogAsync( std::function<void( const std::vector<std::filesystem::path>& )> callback, const FileParameters& params = {} );
65
68MRVIEWER_API std::filesystem::path openFolderDialog( std::filesystem::path baseFolder = {} );
69
72MRVIEWER_API void openFolderDialogAsync( std::function<void ( const std::filesystem::path& )> callback, std::filesystem::path baseFolder = {} );
73
76MRVIEWER_API std::vector<std::filesystem::path> openFoldersDialog( std::filesystem::path baseFolder = {} );
77
79MRVIEWER_API std::filesystem::path saveFileDialog( const FileParameters& params = {} );
80
83MRVIEWER_API void saveFileDialogAsync( std::function<void( const std::filesystem::path& )> callback, const FileParameters& params = {} );
84
85namespace FileDialog
86{
87
89{
90 bool folderDialog{false};
91 bool multiselect{true};
92 bool saveDialog{false};
93};
94
97MRVIEWER_API std::filesystem::path getLastUsedDir();
98
100MRVIEWER_API void setLastUsedDir( const std::filesystem::path& folder );
101
102}
103
104}
SelectFileSignal onOpenFile
called when one file is selected for opening (openFileDialog and openFileDialogAsync)
Definition MRFileDialog.h:26
MRVIEWER_API std::filesystem::path openFileDialog(const FileParameters &params={})
MRVIEWER_API std::vector< std::filesystem::path > openFoldersDialog(std::filesystem::path baseFolder={})
std::string fileName
Default filename.
Definition MRFileDialog.h:43
static MRVIEWER_API FileDialogSignals & instance()
returns instance of this holder
SelectFilesSignal onOpenFiles
called when several files are selected for opening (openFilesDialog and openFilesDialogAsync)
Definition MRFileDialog.h:27
MRVIEWER_API void openFilesDialogAsync(std::function< void(const std::vector< std::filesystem::path > &)> callback, const FileParameters &params={})
bool multiselect
open dialog only
Definition MRFileDialog.h:91
std::filesystem::path baseFolder
Definition MRFileDialog.h:46
SelectFileSignal onSaveFile
called when file name is selected for saving (saveFileDialog and saveFileDialogAsync)
Definition MRFileDialog.h:29
MRVIEWER_API std::filesystem::path saveFileDialog(const FileParameters &params={})
returns empty path on cancel
bool saveDialog
open dialog only
Definition MRFileDialog.h:92
MRVIEWER_API void openFileDialogAsync(std::function< void(const std::filesystem::path &)> callback, const FileParameters &params={})
MRVIEWER_API std::filesystem::path getLastUsedDir()
SelectFolderSignal onSelectFolder
called when one folder is selected (we do not now differ reason)(openFolderDialog and openFolderDialo...
Definition MRFileDialog.h:31
MRVIEWER_API std::filesystem::path openFolderDialog(std::filesystem::path baseFolder={})
MRVIEWER_API void openFolderDialogAsync(std::function< void(const std::filesystem::path &)> callback, std::filesystem::path baseFolder={})
MRVIEWER_API std::vector< std::filesystem::path > openFilesDialog(const FileParameters &params={})
MRVIEWER_API void saveFileDialogAsync(std::function< void(const std::filesystem::path &)> callback, const FileParameters &params={})
bool folderDialog
Definition MRFileDialog.h:90
SelectFoldersSignal onSelectFolders
called when several folders are selected (we do not now differ reason)(openFoldersDialog)
Definition MRFileDialog.h:32
IOFilters filters
Definition MRFileDialog.h:47
MRVIEWER_API void setLastUsedDir(const std::filesystem::path &folder)
saves in the configuration the path to last used folder (where the files were last saved or open)
std::vector< IOFilter > IOFilters
Definition MRIOFilters.h:32
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
This structure contains global signals for file dialogs, that are called on valid selection of file o...
Definition MRFileDialog.h:16
Definition MRFileDialog.h:89
Definition MRFileDialog.h:41