| 12 | JoinRequestDialog::JoinRequestDialog() : m_confirmed(false) {} |
| 13 | |
| 14 | void JoinRequestDialog::displayRequest(String const& userName, function<void(P2PJoinRequestReply)> callback) { |
| 15 | auto assets = Root::singleton().assets(); |
| 16 | |
| 17 | removeAllChildren(); |
| 18 | |
| 19 | GuiReader reader; |
| 20 | |
| 21 | m_callback = std::move(callback); |
| 22 | |
| 23 | reader.registerCallback("yes", [this](Widget*){ reply(P2PJoinRequestReply::Yes); }); |
| 24 | reader.registerCallback("no", [this](Widget*){ reply(P2PJoinRequestReply::No); }); |
| 25 | reader.registerCallback("ignore", [this](Widget*){ reply(P2PJoinRequestReply::Ignore); }); |
| 26 | |
| 27 | m_confirmed = false; |
| 28 | |
| 29 | Json config = assets->json("/interface/windowconfig/joinrequest.config"); |
| 30 | |
| 31 | reader.construct(config.get("paneLayout"), this); |
| 32 | |
| 33 | String message = config.getString("joinMessage").replaceTags(StringMap<String>{{"username", userName}}); |
| 34 | fetchChild<LabelWidget>("message")->setText(message); |
| 35 | |
| 36 | show(); |
| 37 | } |
| 38 | |
| 39 | void JoinRequestDialog::reply(P2PJoinRequestReply reply) { |
| 40 | m_confirmed = true; |
no test coverage detected