Molybden API
Loading...
Searching...
No Matches
dialogs.hpp
1// Copyright (c) 2000-2024 TeamDev. All rights reserved.
2// TeamDev PROPRIETARY and CONFIDENTIAL.
3// Use is subject to license terms.
4
5#ifndef MOLYBDEN_DIALOGS_HPP
6#define MOLYBDEN_DIALOGS_HPP
7
8#include <memory>
9#include <string>
10#include <vector>
11
12namespace molybden {
13
14class App;
15class Browser;
16
20enum class MessageDialogType { kNone, kQuestion, kInfo, kWarning, kError };
21
25enum class MessageDialogButtonType { kNone, kDefault, kCancel };
26
32 MessageDialogButton(const std::string& label);
33 MessageDialogButton(const std::string& label, MessageDialogButtonType type);
34
38 std::string label;
39
43 MessageDialogButtonType type = MessageDialogButtonType::kNone;
44};
45
53 std::string label;
54
58 bool checked = false;
59};
60
68 std::string message;
69
73 std::string informative_text;
74
78 MessageDialogType type = MessageDialogType::kNone;
79
85 std::string title;
86
93 std::vector<MessageDialogButton> buttons;
94
100};
101
116
124 std::string name;
125
129 std::vector<std::string> extensions;
130};
131
135enum class OpenDialogSelectionPolicy {
139 kFiles,
140
144 kDirectories,
145
149 kFilesAndDirectories
150};
151
163
168
172 bool show_hidden_files = false;
173
177 bool resolves_symlinks = false;
178
184};
185
193 std::string title;
194
198 std::string button_label;
199
203 std::string default_path;
204
208 std::string message;
209
213 std::vector<FileFilter> filters;
214
221 OpenDialogSelectionPolicy selection_policy =
222 OpenDialogSelectionPolicy::kFiles;
223
228};
229
237 std::vector<std::string> paths;
238
242 bool canceled = false;
243};
244
252 bool show_hidden_files = false;
253
258
264};
265
273 std::string title;
274
278 std::string default_path;
279
283 std::string button_label;
284
288 std::string message;
289
293 std::vector<FileFilter> filters;
294
299};
300
308 std::string path;
309
313 bool canceled = false;
314};
315
320 public:
327 static void show(const std::shared_ptr<App>& app,
328 const MessageDialogOptions& options);
329
337 static void show(const std::shared_ptr<App>& app,
338 const MessageDialogOptions& options,
339 const std::function<void(MessageDialogResult)>& callback);
340
347 static void show(const std::shared_ptr<Browser>& browser,
348 const MessageDialogOptions& options);
349
357 static void show(const std::shared_ptr<Browser>& browser,
358 const MessageDialogOptions& options,
359 const std::function<void(MessageDialogResult)>& callback);
360};
361
366 public:
374 static void show(const std::shared_ptr<App>& app,
375 const OpenDialogOptions& options,
376 const std::function<void(OpenDialogResult)>& callback);
377
385 static void show(const std::shared_ptr<Browser>& browser,
386 const OpenDialogOptions& options,
387 const std::function<void(OpenDialogResult)>& callback);
388};
389
394 public:
402 static void show(const std::shared_ptr<App>& app,
403 const SaveDialogOptions& options,
404 const std::function<void(SaveDialogResult)>& callback);
405
413 static void show(const std::shared_ptr<Browser>& browser,
414 const SaveDialogOptions& options,
415 const std::function<void(SaveDialogResult)>& callback);
416};
417
418} // namespace molybden
419
420#endif // MOLYBDEN_DIALOGS_HPP
Allow displaying the native message dialogs.
Definition dialogs.hpp:319
static void show(const std::shared_ptr< Browser > &browser, const MessageDialogOptions &options, const std::function< void(MessageDialogResult)> &callback)
Shows a browser modal message dialog with the given options.
static void show(const std::shared_ptr< App > &app, const MessageDialogOptions &options, const std::function< void(MessageDialogResult)> &callback)
Shows an application message dialog with the given options.
static void show(const std::shared_ptr< Browser > &browser, const MessageDialogOptions &options)
Shows a browser modal message dialog with the given options.
static void show(const std::shared_ptr< App > &app, const MessageDialogOptions &options)
Shows an application message dialog with the given options.
Allow displaying the native open file/files/folder dialogs.
Definition dialogs.hpp:365
static void show(const std::shared_ptr< Browser > &browser, const OpenDialogOptions &options, const std::function< void(OpenDialogResult)> &callback)
Shows a browser modal open dialog with the given options.
static void show(const std::shared_ptr< App > &app, const OpenDialogOptions &options, const std::function< void(OpenDialogResult)> &callback)
Shows an application open dialog with the given options.
Allow displaying the native save file/folder dialogs.
Definition dialogs.hpp:393
static void show(const std::shared_ptr< App > &app, const SaveDialogOptions &options, const std::function< void(SaveDialogResult)> &callback)
Shows an application save dialog with the given options.
static void show(const std::shared_ptr< Browser > &browser, const SaveDialogOptions &options, const std::function< void(SaveDialogResult)> &callback)
Shows a browser modal save dialog with the given options.
The file filter.
Definition dialogs.hpp:120
std::string name
The name of the filter.
Definition dialogs.hpp:124
std::vector< std::string > extensions
The file extensions to filter by.
Definition dialogs.hpp:129
The message dialog button.
Definition dialogs.hpp:30
MessageDialogButtonType type
The type of the button.
Definition dialogs.hpp:43
std::string label
The label of the button.
Definition dialogs.hpp:38
The message dialog checkbox.
Definition dialogs.hpp:49
std::string label
The label of the checkbox.
Definition dialogs.hpp:53
bool checked
The initial state of the checkbox.
Definition dialogs.hpp:58
The options of a message dialog.
Definition dialogs.hpp:64
MessageDialogType type
The type of the dialog.
Definition dialogs.hpp:78
MessageDialogCheckbox checkbox
The checkbox of the dialog to get additional user input.
Definition dialogs.hpp:99
std::string message
The message text of the dialog.
Definition dialogs.hpp:68
std::string informative_text
The informative text of the dialog.
Definition dialogs.hpp:73
std::vector< MessageDialogButton > buttons
The buttons of the dialog.
Definition dialogs.hpp:93
std::string title
The title of the dialog.
Definition dialogs.hpp:85
The result of a message dialog.
Definition dialogs.hpp:105
bool checkbox_checked
The checkbox state if the dialog had a checkbox.
Definition dialogs.hpp:114
MessageDialogButton button
The button that was clicked.
Definition dialogs.hpp:109
The features of an open dialog.
Definition dialogs.hpp:158
bool treat_packages_as_directories
Whether the dialog treats packages, such as .app folders, as directories instead of a file (macOS).
Definition dialogs.hpp:183
bool show_hidden_files
Whether the dialog shows and allows selecting hidden files.
Definition dialogs.hpp:172
bool can_create_directories
Whether the dialog allows creating new directories (macOS).
Definition dialogs.hpp:167
bool allow_multiple_selections
Whether the dialog allows multiple file selection.
Definition dialogs.hpp:162
bool resolves_symlinks
Whether the dialog resolves symlinks (macOS).
Definition dialogs.hpp:177
The options of an open dialog.
Definition dialogs.hpp:189
OpenDialogFeatures features
The features of the dialog.
Definition dialogs.hpp:227
OpenDialogSelectionPolicy selection_policy
The selection policy of the dialog.
Definition dialogs.hpp:221
std::string message
The message to display above input boxes on macOS.
Definition dialogs.hpp:208
std::string button_label
The custom label of the dialog confirmation button.
Definition dialogs.hpp:198
std::string title
The title of the dialog.
Definition dialogs.hpp:193
std::vector< FileFilter > filters
The filters of the dialog.
Definition dialogs.hpp:213
std::string default_path
The path to the default directory or file to select in the dialog.
Definition dialogs.hpp:203
The result of an open dialog.
Definition dialogs.hpp:233
std::vector< std::string > paths
The paths that were selected.
Definition dialogs.hpp:237
bool canceled
Whether the dialog was canceled.
Definition dialogs.hpp:242
The features of a save dialog.
Definition dialogs.hpp:248
bool treat_packages_as_directories
Whether the dialog treats packages, such as .app folders, as directories instead of a file (macOS).
Definition dialogs.hpp:263
bool show_hidden_files
Whether the dialog shows and allows selecting hidden files.
Definition dialogs.hpp:252
bool can_create_directories
Whether the dialog allows creating new directories (macOS).
Definition dialogs.hpp:257
The options of a save dialog.
Definition dialogs.hpp:269
SaveDialogFeatures features
The features of the dialog.
Definition dialogs.hpp:298
std::vector< FileFilter > filters
The filters of the dialog.
Definition dialogs.hpp:293
std::string title
The title of the dialog.
Definition dialogs.hpp:273
std::string message
The message to display above input boxes on macOS.
Definition dialogs.hpp:288
std::string default_path
The path to the default directory or file to use by default.
Definition dialogs.hpp:278
std::string button_label
The custom label of the dialog confirmation button.
Definition dialogs.hpp:283
The result of a save dialog.
Definition dialogs.hpp:304
std::string path
The path that was selected.
Definition dialogs.hpp:308
bool canceled
Whether the dialog was canceled.
Definition dialogs.hpp:313