damn it
This commit is contained in:
parent
2ba0185701
commit
0874d58fb8
23 changed files with 2661 additions and 11 deletions
97
extern/pfd-fixed/doc/message.md
vendored
Normal file
97
extern/pfd-fixed/doc/message.md
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
## Message Box API
|
||||
|
||||
Displaying a message box is done using the `pfd::message` class. It can be provided a title, a
|
||||
message text, a `choice` representing which buttons need to be rendered, and an `icon` for the
|
||||
message:
|
||||
|
||||
```cpp
|
||||
pfd::message::message(std::string const &title,
|
||||
std::string const &text,
|
||||
pfd::choice choice = pfd::choice::ok_cancel,
|
||||
pfd::icon icon = pfd::icon::info);
|
||||
|
||||
enum class pfd::choice { ok, ok_cancel, yes_no, yes_no_cancel };
|
||||
|
||||
enum class pfd::icon { info, warning, error, question };
|
||||
```
|
||||
|
||||
The pressed button is queried using `pfd::message::result()`. If the dialog box is closed by any
|
||||
other means, the `pfd::button::cancel` is assumed:
|
||||
|
||||
```cpp
|
||||
pfd::button pfd::message::result();
|
||||
|
||||
enum class pfd::button { ok, cancel, yes, no };
|
||||
```
|
||||
|
||||
It is possible to ask the dialog box whether the user took action using the `pfd::message::ready()`
|
||||
method, with an optional `timeout` argument. If the user did not press a button within `timeout`
|
||||
milliseconds, the function will return `false`:
|
||||
|
||||
```cpp
|
||||
bool pfd::message::ready(int timeout = pfd::default_wait_timeout);
|
||||
```
|
||||
|
||||
## Example 1: simple notification
|
||||
|
||||
The `pfd::message` destructor waits for user action, so this operation will block until the user
|
||||
closes the message box:
|
||||
|
||||
```cpp
|
||||
pfd::message("Problem", "An error occurred while doing things",
|
||||
pfd::choice::ok, pfd::icon::error);
|
||||
```
|
||||
|
||||
## Example 2: retrieving the pressed button
|
||||
|
||||
Using `pfd::message::result()` will also wait for user action before returning. This operation will block and return the user choice:
|
||||
|
||||
```cpp
|
||||
// Ask for user opinion
|
||||
auto button = pfd::message("Action requested", "Do you want to proceed with things?",
|
||||
pfd::choice::yes_no, pfd::icon::question).result();
|
||||
// Do something with button…
|
||||
```
|
||||
|
||||
## Example 3: asynchronous message box
|
||||
|
||||
Using `pfd::message::ready()` allows the application to perform other tasks while waiting for
|
||||
user input:
|
||||
|
||||
```cpp
|
||||
// Message box with nice message
|
||||
auto box = pfd::message("Unsaved Files", "Do you want to save the current "
|
||||
"document before closing the application?",
|
||||
pfd::choice::yes_no_cancel,
|
||||
pfd::icon::warning);
|
||||
|
||||
// Do something while waiting for user input
|
||||
while (!box.ready(1000))
|
||||
std::cout << "Waited 1 second for user input...\n";
|
||||
|
||||
// Act depending on the selected button
|
||||
switch (box.result())
|
||||
{
|
||||
case pfd::button::yes: std::cout << "User agreed.\n"; break;
|
||||
case pfd::button::no: std::cout << "User disagreed.\n"; break;
|
||||
case pfd::button::cancel: std::cout << "User freaked out.\n"; break;
|
||||
}
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
|
||||
#### Windows 10
|
||||
|
||||

|
||||
|
||||
#### Mac OS X
|
||||
|
||||
 
|
||||
|
||||
#### Linux (GNOME desktop)
|
||||
|
||||

|
||||
|
||||
#### Linux (KDE desktop)
|
||||
|
||||

|
||||
40
extern/pfd-fixed/doc/notify.md
vendored
Normal file
40
extern/pfd-fixed/doc/notify.md
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
## Notification API
|
||||
|
||||
Displaying a desktop notification is done using the `pfd::notify` class. It can be provided a
|
||||
title, a message text, and an `icon` for the notification style:
|
||||
|
||||
```cpp
|
||||
pfd::notify::notify(std::string const &title,
|
||||
std::string const &text,
|
||||
pfd::icon icon = pfd::icon::info);
|
||||
|
||||
enum class pfd::icon { info, warning, error };
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
Displaying a notification is straightforward. Emoji are supported:
|
||||
|
||||
```cpp
|
||||
pfd::notify("System event", "Something might be on fire 🔥",
|
||||
pfd::icon::warning);
|
||||
```
|
||||
|
||||
The `pfd::notify` object needs not be kept around, letting the object clean up itself is enough.
|
||||
|
||||
## Screenshots
|
||||
|
||||
Windows 10:
|
||||

|
||||
|
||||
Mac OS X (dark theme):
|
||||

|
||||
|
||||
Mac OS X (light theme):
|
||||

|
||||
|
||||
Linux (GNOME desktop):
|
||||

|
||||
|
||||
Linux (KDE desktop):
|
||||

|
||||
90
extern/pfd-fixed/doc/open_file.md
vendored
Normal file
90
extern/pfd-fixed/doc/open_file.md
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
## File Open API
|
||||
|
||||
The `pfd::open_file` class handles file opening dialogs. It can be provided a title, a starting
|
||||
directory and/or pre-selected file, an optional filter for recognised file types, and an optional
|
||||
flag to allow multiple selection:
|
||||
|
||||
```cpp
|
||||
pfd::open_file::open_file(std::string const &title,
|
||||
std::string const &initial_path,
|
||||
std::vector<std::string> filters = { "All Files", "*" },
|
||||
pfd::opt option = pfd::opt::none);
|
||||
```
|
||||
|
||||
The `option` parameter can be `pfd::opt::multiselect` to allow selecting multiple files.
|
||||
|
||||
The selected files are queried using `pfd::open_file::result()`. If the user canceled the
|
||||
operation, the returned list is empty:
|
||||
|
||||
```cpp
|
||||
std::vector<std::string> pfd::open_file::result();
|
||||
```
|
||||
|
||||
It is possible to ask the file open dialog whether the user took action using the
|
||||
`pfd::message::ready()` method, with an optional `timeout` argument. If the user did not validate
|
||||
the dialog within `timeout` milliseconds, the function will return `false`:
|
||||
|
||||
```cpp
|
||||
bool pfd::open_file::ready(int timeout = pfd::default_wait_timeout);
|
||||
```
|
||||
|
||||
## Example 1: simple file selection
|
||||
|
||||
Using `pfd::open_file::result()` will wait for user action before returning. This operation will
|
||||
block and return the user choice:
|
||||
|
||||
```cpp
|
||||
auto selection = pfd::open_file("Select a file").result();
|
||||
if (!selection.empty())
|
||||
std::cout << "User selected file " << selection[0] << "\n";
|
||||
```
|
||||
|
||||
## Example 2: filters
|
||||
|
||||
The filter list enumerates filter names and corresponded space-separated wildcard lists. It
|
||||
defaults to `{ "All Files", "*" }`, but here is how to use other options:
|
||||
|
||||
```cpp
|
||||
auto selection = pfd::open_file("Select a file", ".",
|
||||
{ "Image Files", "*.png *.jpg *.jpeg *.bmp",
|
||||
"Audio Files", "*.wav *.mp3",
|
||||
"All Files", "*" },
|
||||
pfd::opt::multiselect).result();
|
||||
// Do something with selection
|
||||
for (auto const &filename : dialog.result())
|
||||
std::cout << "Selected file: " << filename << "\n";
|
||||
```
|
||||
|
||||
## Example 3: asynchronous file open
|
||||
|
||||
Using `pfd::open_file::ready()` allows the application to perform other tasks while waiting for
|
||||
user input:
|
||||
|
||||
```cpp
|
||||
// File open dialog
|
||||
auto dialog = pfd::open_file("Select file to open");
|
||||
|
||||
// Do something while waiting for user input
|
||||
while (!dialog.ready(1000))
|
||||
std::cout << "Waited 1 second for user input...\n";
|
||||
|
||||
// Act depending on the user choice
|
||||
std::cout << "Number of selected files: " << dialog.result().size() << "\n";
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
|
||||
Windows 10:
|
||||

|
||||
|
||||
Mac OS X (dark theme):
|
||||

|
||||
|
||||
Mac OS X (light theme):
|
||||

|
||||
|
||||
Linux (GNOME desktop):
|
||||

|
||||
|
||||
Linux (KDE desktop):
|
||||

|
||||
120
extern/pfd-fixed/doc/pfd.md
vendored
Normal file
120
extern/pfd-fixed/doc/pfd.md
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
## Portable File Dialogs documentation
|
||||
|
||||
The library can be used either as a [header-only library](https://en.wikipedia.org/wiki/Header-only),
|
||||
or as a [single file library](https://github.com/nothings/single_file_libs).
|
||||
|
||||
### Use as header-only library
|
||||
|
||||
Just include the main header file wherever needed:
|
||||
|
||||
```cpp
|
||||
#include "portable-file-dialogs.h"
|
||||
|
||||
/* ... */
|
||||
|
||||
pfd::message::message("Hello", "This is a test");
|
||||
|
||||
/* ... */
|
||||
```
|
||||
|
||||
### Use as a single-file library
|
||||
|
||||
Defining the `PFD_SKIP_IMPLEMENTATION` macro before including `portable-file-dialogs.h` will
|
||||
skip all the implementation code and reduce compilation times. You still need to include the
|
||||
header without the macro at least once, typically in a `pfd-impl.cpp` file.
|
||||
|
||||
```cpp
|
||||
// In pfd-impl.cpp
|
||||
#include "portable-file-dialogs.h"
|
||||
```
|
||||
|
||||
```cpp
|
||||
// In all other files
|
||||
#define PFD_SKIP_IMPLEMENTATION 1
|
||||
#include "portable-file-dialogs.h"
|
||||
```
|
||||
|
||||
### General concepts
|
||||
|
||||
Dialogs inherit from `pfd::dialog` and are created by calling their class constructor. Their
|
||||
destructor will block until the window is closed by user interaction. So for instance this
|
||||
will block until the end of the line:
|
||||
|
||||
```cpp
|
||||
pfd::message::message("Hi", "there");
|
||||
```
|
||||
|
||||
Whereas this will only block until the end of the scope, allowing the program to perform
|
||||
additional operations while the dialog is open:
|
||||
|
||||
```cpp
|
||||
{
|
||||
auto m = pfd::message::message("Hi", "there");
|
||||
|
||||
// ... perform asynchronous operations here
|
||||
}
|
||||
```
|
||||
|
||||
It is possible to call `bool pfd::dialog::ready(timeout)` on the dialog in order to query its
|
||||
status and perform asynchronous operations as long as the user has not interacted:
|
||||
|
||||
```cpp
|
||||
{
|
||||
auto m = pfd::message::message("Hi", "there");
|
||||
|
||||
while (!m.ready())
|
||||
{
|
||||
// ... perform asynchronous operations here
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If necessary, a dialog can be forcibly closed using `bool pfd::dialog::kill()`. Note that this
|
||||
may be confusing to the user and should only be used in very specific situations. It is also not
|
||||
possible to close a Windows message box that provides no _Cancel_ button.
|
||||
|
||||
```cpp
|
||||
{
|
||||
auto m = pfd::message::message("Hi", "there");
|
||||
|
||||
while (!m.ready())
|
||||
{
|
||||
// ... perform asynchronous operations here
|
||||
|
||||
if (too_much_time_has_passed())
|
||||
m.kill();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Finally, the user response can be retrieved using `pfd::dialog::result()`. The return value of
|
||||
this function depends on which dialog is being used. See their respective documentation for more
|
||||
information:
|
||||
|
||||
* [`pfd::message`](message.md) (message box)
|
||||
* [`pfd::notify`](notify.md) (notification)
|
||||
* [`pfd::open_file`](open_file.md) (file open)
|
||||
* [`pfd::save_file`](save_file.md) (file save)
|
||||
* [`pfd::select_folder`](select_folder.md) (folder selection)
|
||||
|
||||
### Settings
|
||||
|
||||
The library can be queried and configured through the `pfd::settings` class.
|
||||
|
||||
```cpp
|
||||
bool pfd::settings::available();
|
||||
void pfd::settings::verbose(bool value);
|
||||
void pfd::settings::rescan();
|
||||
```
|
||||
|
||||
The return value of `pfd::settings::available()` indicates whether a suitable dialog backend (such
|
||||
as Zenity or KDialog on Linux) has been found. If not, the library will not work and all dialog
|
||||
invocations will be no-ops. The program will not crash but you should account for this situation
|
||||
and add a fallback mechanism or exit gracefully.
|
||||
|
||||
Calling `pfd::settings::rescan()` will force a rescan of available backends. This may change the
|
||||
result of `pfd::settings::available()` if a backend was installed on the system in the meantime.
|
||||
This is probably only useful for debugging purposes.
|
||||
|
||||
Calling `pfd::settings::verbose(true)` may help debug the library. It will output debug information
|
||||
to `std::cout` about some operations being performed.
|
||||
73
extern/pfd-fixed/doc/save_file.md
vendored
Normal file
73
extern/pfd-fixed/doc/save_file.md
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
## File Open API
|
||||
|
||||
The `pfd::save_file` class handles file saving dialogs. It can be provided a title, a starting
|
||||
directory and/or pre-selected file, an optional filter for recognised file types, and an optional
|
||||
flag to allow multiple selection:
|
||||
|
||||
```cpp
|
||||
pfd::save_file::save_file(std::string const &title,
|
||||
std::string const &initial_path,
|
||||
std::vector<std::string> filters = { "All Files", "*" },
|
||||
pfd::opt option = pfd::opt::none);
|
||||
```
|
||||
|
||||
The `option` parameter can be `pfd::opt::force_overwrite` to disable a potential warning when
|
||||
saving to an existing file.
|
||||
|
||||
The selected file is queried using `pfd::save_file::result()`. If the user canceled the
|
||||
operation, the returned file name is empty:
|
||||
|
||||
```cpp
|
||||
std::string pfd::save_file::result();
|
||||
```
|
||||
|
||||
It is possible to ask the file save dialog whether the user took action using the
|
||||
`pfd::message::ready()` method, with an optional `timeout` argument. If the user did not validate
|
||||
the dialog within `timeout` milliseconds, the function will return `false`:
|
||||
|
||||
```cpp
|
||||
bool pfd::save_file::ready(int timeout = pfd::default_wait_timeout);
|
||||
```
|
||||
|
||||
## Example 1: simple file selection
|
||||
|
||||
Using `pfd::save_file::result()` will wait for user action before returning. This operation will
|
||||
block and return the user choice:
|
||||
|
||||
```cpp
|
||||
auto destination = pfd::save_file("Select a file").result();
|
||||
if (!destination.empty())
|
||||
std::cout << "User selected file " << destination << "\n";
|
||||
```
|
||||
|
||||
## Example 2: filters
|
||||
|
||||
The filter list enumerates filter names and corresponded space-separated wildcard lists. It
|
||||
defaults to `{ "All Files", "*" }`, but here is how to use other options:
|
||||
|
||||
```cpp
|
||||
auto destination = pfd::save_file("Select a file", ".",
|
||||
{ "Image Files", "*.png *.jpg *.jpeg *.bmp",
|
||||
"Audio Files", "*.wav *.mp3",
|
||||
"All Files", "*" },
|
||||
pfd::opt::force_overwrite).result();
|
||||
// Do something with destination
|
||||
std::cout << "Selected file: " << destination << "\n";
|
||||
```
|
||||
|
||||
## Example 3: asynchronous file save
|
||||
|
||||
Using `pfd::save_file::ready()` allows the application to perform other tasks while waiting for
|
||||
user input:
|
||||
|
||||
```cpp
|
||||
// File save dialog
|
||||
auto dialog = pfd::save_file("Select file to save");
|
||||
|
||||
// Do something while waiting for user input
|
||||
while (!dialog.ready(1000))
|
||||
std::cout << "Waited 1 second for user input...\n";
|
||||
|
||||
// Act depending on the user choice
|
||||
std::cout << "User selected file: " << dialog.result() << "\n";
|
||||
```
|
||||
55
extern/pfd-fixed/doc/select_folder.md
vendored
Normal file
55
extern/pfd-fixed/doc/select_folder.md
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
## Folder Selection API
|
||||
|
||||
The `pfd::select_folder` class handles folder opening dialogs. It can be provided a title, and an
|
||||
optional starting directory:
|
||||
|
||||
```cpp
|
||||
pfd::select_folder::select_folder(std::string const &title,
|
||||
std::string const &default_path = "",
|
||||
pfd::opt option = pfd::opt::none);
|
||||
```
|
||||
|
||||
The `option` parameter can be `pfd::opt::force_path` to force the operating system to use the
|
||||
provided path. Some systems default to the most recently used path, if applicable.
|
||||
|
||||
The selected folder is queried using `pfd::select_folder::result()`. If the user canceled the
|
||||
operation, the returned string is empty:
|
||||
|
||||
```cpp
|
||||
std::string pfd::select_folder::result();
|
||||
```
|
||||
|
||||
It is possible to ask the folder selection dialog whether the user took action using the
|
||||
`pfd::message::ready()` method, with an optional `timeout` argument. If the user did not validate
|
||||
the dialog within `timeout` milliseconds, the function will return `false`:
|
||||
|
||||
```cpp
|
||||
bool pfd::select_folder::ready(int timeout = pfd::default_wait_timeout);
|
||||
```
|
||||
|
||||
## Example 1: simple folder selection
|
||||
|
||||
Using `pfd::select_folder::result()` will wait for user action before returning. This operation
|
||||
will block and return the user choice:
|
||||
|
||||
```cpp
|
||||
auto selection = pfd::select_folder("Select a folder").result();
|
||||
if (!selection.empty())
|
||||
std::cout << "User selected folder " << selection << "\n";
|
||||
```
|
||||
|
||||
## Example 2: asynchronous folder open
|
||||
|
||||
Using `pfd::select_folder::ready()` allows the application to perform other tasks while waiting for user input:
|
||||
|
||||
```cpp
|
||||
// Folder selection dialog
|
||||
auto dialog = pfd::select_folder("Select folder to open");
|
||||
|
||||
// Do something while waiting for user input
|
||||
while (!dialog.ready(1000))
|
||||
std::cout << "Waited 1 second for user input...\n";
|
||||
|
||||
// Act depending on the user choice
|
||||
std::cout << "Selected folder: " << dialog.result() << "\n";
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue