From cffda26dd8cc98dc2cc3fa27d91ad8ef42b1d56d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 10 Dec 2022 12:54:54 +0200 Subject: [PATCH 48/48] Qt: Add action confirmation dialog See osdn #46194 Signed-off-by: Marko Lindqvist --- client/gui-qt/dialogs.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index 91e625be04..6d0d669e8b 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -4909,12 +4909,42 @@ void qtg_popup_combat_info(int attacker_unit_id, int defender_unit_id, } } +/**********************************************************************//** + Open dialog confirming that user wants to do the action. +**************************************************************************/ +static void popup_act_confirmation_dialog(QString hdr, QString body, + struct act_confirmation_data *data) +{ + hud_message_box *ask = new hud_message_box(gui()->central_wdg); + + ask->setStandardButtons(QMessageBox::Cancel | QMessageBox::Ok); + ask->setDefaultButton(QMessageBox::Cancel); + ask->set_text_title(body, hdr); + ask->setAttribute(Qt::WA_DeleteOnClose); + QObject::connect(ask, &hud_message_box::accepted, [=]() { + action_confirmation(data, TRUE); + }); + QObject::connect(ask, &hud_message_box::rejected, [=]() { + action_confirmation(data, FALSE); + }); + + ask->show(); +} + /***********************************************************************//** Common code wants confirmation for an action. ***************************************************************************/ void qtg_request_action_confirmation(const char *expl, struct act_confirmation_data *data) { - // TODO: Implement. Currently just pass everything as confirmed. - action_confirmation(data, TRUE); + QString hdr, body_text; + + hdr = QString(_("Are you sure you want to do %1?")). + arg(QString(action_id_name_translation(data->act))); + + if (expl != NULL) { + body_text += QString(expl); + } + + popup_act_confirmation_dialog(hdr, body_text, data); } -- 2.35.1