Debian Codegraph @

android/app/jni/extern/pfd-fixed/doc/pfd.md

raw
1 ## Portable File Dialogs documentation
2
3 The library can be used either as a [header-only library](https://en.wikipedia.org/wiki/Header-only),
4 or as a [single file library](https://github.com/nothings/single_file_libs).
5
6 ### Use as header-only library
7
8 Just include the main header file wherever needed:
9
10 ```cpp
11 #include "portable-file-dialogs.h"
12
13 /* ... */
14
15 pfd::message::message("Hello", "This is a test");
16
17 /* ... */
18 ```
19
20 ### Use as a single-file library
21
22 Defining the `PFD_SKIP_IMPLEMENTATION` macro before including `portable-file-dialogs.h` will
23 skip all the implementation code and reduce compilation times. You still need to include the
24 header without the macro at least once, typically in a `pfd-impl.cpp` file.
25
26 ```cpp
27 // In pfd-impl.cpp
28 #include "portable-file-dialogs.h"
29 ```
30
31 ```cpp
32 // In all other files
33 #define PFD_SKIP_IMPLEMENTATION 1
34 #include "portable-file-dialogs.h"
35 ```
36
37 ### General concepts
38
39 Dialogs inherit from `pfd::dialog` and are created by calling their class constructor. Their
40 destructor will block until the window is closed by user interaction. So for instance this
41 will block until the end of the line:
42
43 ```cpp
44 pfd::message::message("Hi", "there");
45 ```
46
47 Whereas this will only block until the end of the scope, allowing the program to perform
48 additional operations while the dialog is open:
49
50 ```cpp
51 {
52 auto m = pfd::message::message("Hi", "there");
53
54 // ... perform asynchronous operations here
55 }
56 ```
57
58 It is possible to call `bool pfd::dialog::ready(timeout)` on the dialog in order to query its
59 status and perform asynchronous operations as long as the user has not interacted:
60
61 ```cpp
62 {
63 auto m = pfd::message::message("Hi", "there");
64
65 while (!m.ready())
66 {
67 // ... perform asynchronous operations here
68 }
69 }
70 ```
71
72 If necessary, a dialog can be forcibly closed using `bool pfd::dialog::kill()`. Note that this
73 may be confusing to the user and should only be used in very specific situations. It is also not
74 possible to close a Windows message box that provides no _Cancel_ button.
75
76 ```cpp
77 {
78 auto m = pfd::message::message("Hi", "there");
79
80 while (!m.ready())
81 {
82 // ... perform asynchronous operations here
83
84 if (too_much_time_has_passed())
85 m.kill();
86 }
87 }
88 ```
89
90 Finally, the user response can be retrieved using `pfd::dialog::result()`. The return value of
91 this function depends on which dialog is being used. See their respective documentation for more
92 information:
93
94 * [`pfd::message`](message.md) (message box)
95 * [`pfd::notify`](notify.md) (notification)
96 * [`pfd::open_file`](open_file.md) (file open)
97 * [`pfd::save_file`](save_file.md) (file save)
98 * [`pfd::select_folder`](select_folder.md) (folder selection)
99
100 ### Settings
101
102 The library can be queried and configured through the `pfd::settings` class.
103
104 ```cpp
105 bool pfd::settings::available();
106 void pfd::settings::verbose(bool value);
107 void pfd::settings::rescan();
108 ```
109
110 The return value of `pfd::settings::available()` indicates whether a suitable dialog backend (such
111 as Zenity or KDialog on Linux) has been found. If not, the library will not work and all dialog
112 invocations will be no-ops. The program will not crash but you should account for this situation
113 and add a fallback mechanism or exit gracefully.
114
115 Calling `pfd::settings::rescan()` will force a rescan of available backends. This may change the
116 result of `pfd::settings::available()` if a backend was installed on the system in the meantime.
117 This is probably only useful for debugging purposes.
118
119 Calling `pfd::settings::verbose(true)` may help debug the library. It will output debug information
120 to `std::cout` about some operations being performed.