Debian Codegraph @

android/app/jni/extern/pfd-fixed/examples/kill.cpp

raw
1 //
2 // Portable File Dialogs
3 //
4 // Copyright © 2018—2020 Sam Hocevar <[email protected]>
5 //
6 // This program is free software. It comes without any warranty, to
7 // the extent permitted by applicable law. You can redistribute it
8 // and/or modify it under the terms of the Do What the Fuck You Want
9 // to Public License, Version 2, as published by the WTFPL Task Force.
10 // See http://www.wtfpl.net/ for more details.
11 //
12
13 #include "portable-file-dialogs.h"
14
15 #include <cstdio>
16
17 int main()
18 {
19 // Set verbosity to true
20 pfd::settings::verbose(true);
21
22 // Message box with nice message
23 auto m = pfd::message("Upgrade software?",
24 "Press OK to upgrade this software.\n"
25 "\n"
26 "By default, the software will update itself\n"
27 "automatically in 10 seconds.",
28 pfd::choice::ok_cancel,
29 pfd::icon::warning);
30
31 // Wait for an answer for up to 10 seconds
32 for (int i = 0; i < 10 && !m.ready(1000); ++i)
33 ;
34
35 // Upgrade software if user clicked OK, or if user didn’t interact
36 bool upgrade = m.ready() ? m.result() == pfd::button::ok : m.kill();
37 if (upgrade)
38 std::cout << "Upgrading software!\n";
39 else
40 std::cout << "Not upgrading software.\n";
41 }
42