| 1 | // Aseprite | 
|---|---|
| 2 | // Copyright (C) 2018 David Capello | 
| 3 | // | 
| 4 | // This program is distributed under the terms of | 
| 5 | // the End-User License Agreement for Aseprite. | 
| 6 | |
| 7 | #ifdef HAVE_CONFIG_H | 
| 8 | #include "config.h" | 
| 9 | #endif | 
| 10 | |
| 11 | #include "app/ui/optional_alert.h" | 
| 12 | |
| 13 | #include "app/i18n/strings.h" | 
| 14 | #include "ui/alert.h" | 
| 15 | #include "ui/button.h" | 
| 16 | |
| 17 | namespace app { | 
| 18 | |
| 19 | // static | 
| 20 | int OptionalAlert::show(Option<bool>& option, | 
| 21 | const int optionWhenDisabled, | 
| 22 | const std::string& msg) | 
| 23 | { | 
| 24 | if (!option()) | 
| 25 | return optionWhenDisabled; | 
| 26 | |
| 27 | ui::AlertPtr alert(ui::Alert::create(msg)); | 
| 28 | ui::CheckBox* cb = alert->addCheckBox(Strings::general_dont_show()); | 
| 29 | const int ret = alert->show(); | 
| 30 | if (ret == optionWhenDisabled) | 
| 31 | option(!cb->isSelected()); | 
| 32 | return ret; | 
| 33 | } | 
| 34 | |
| 35 | } // namespace app | 
| 36 | 
