From 96a057d1c8d5e69a8c3856ea60402ebef9114a86 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Jul 2022 18:32:25 +0300 Subject: [PATCH 45/45] Qt: Raise dialogs when they are accessed again Dialogs disappearing behind main window were a problem on MacOS Reported by ddeanbrown See osdn #43943 Signed-off-by: Marko Lindqvist --- client/gui-qt/dialogs.cpp | 8 ++++++++ client/gui-qt/dialogs.h | 1 + client/gui-qt/diplodlg.cpp | 17 ++++++++++++++++- client/gui-qt/diplodlg.h | 1 + client/gui-qt/helpdlg.cpp | 5 ++++- client/gui-qt/optiondlg.cpp | 1 + 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/client/gui-qt/dialogs.cpp b/client/gui-qt/dialogs.cpp index 1a416ea340..f3dad03e0b 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -335,6 +335,14 @@ qfc_dialog::qfc_dialog(QWidget *parent) : QDialog(parent, close_pix = *fc_icons::instance()->get_pixmap("cclose"); } +/***********************************************************************//** + Existing dialog requested again. +***************************************************************************/ +void qfc_dialog::reactivate() +{ + raise(); +} + /***********************************************************************//** Paint event for themed dialog ***************************************************************************/ diff --git a/client/gui-qt/dialogs.h b/client/gui-qt/dialogs.h index 1576bad3f5..a14b861bbb 100644 --- a/client/gui-qt/dialogs.h +++ b/client/gui-qt/dialogs.h @@ -75,6 +75,7 @@ class qfc_dialog : public QDialog Q_OBJECT public: qfc_dialog(QWidget *parent); + void reactivate(); private: int titlebar_height; QPoint point; diff --git a/client/gui-qt/diplodlg.cpp b/client/gui-qt/diplodlg.cpp index 8985aa22f6..e87a1ff08c 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -855,6 +855,14 @@ void diplo_dlg::update_dlg() } } +/************************************************************************//** + Existing dialog requested again. +****************************************************************************/ +void diplo_dlg::reactivate() +{ + raise(); +} + /************************************************************************//** Update a player's acceptance status of a treaty (traditionally shown with the thumbs-up/thumbs-down sprite). @@ -893,6 +901,7 @@ void qtg_init_meeting(struct Treaty *ptreaty, struct player *they, QPixmap *pix, *def_pix, *pix2, *pix3, *def_pix_del; QWidget *w; QWidget *fw; + bool was_open; if (client_is_observer()) { return; @@ -933,7 +942,8 @@ void qtg_init_meeting(struct Treaty *ptreaty, struct player *they, delete def_pix; delete def_pix_del; - if (!gui()->is_repo_dlg_open("DDI")) { + was_open = gui()->is_repo_dlg_open("DDI"); + if (!was_open) { dd = new diplo_dlg(ptreaty, they, initiator); if (!dd->init(false)) { @@ -947,6 +957,11 @@ void qtg_init_meeting(struct Treaty *ptreaty, struct player *they, fc_assert(i != -1); w = gui()->game_tab_widget->widget(i); dd = qobject_cast(w); + + if (was_open) { + dd->reactivate(); + } + fw = dd->find_widget(they); if (fw == NULL) { dd->add_widget(ptreaty, they, initiator); diff --git a/client/gui-qt/diplodlg.h b/client/gui-qt/diplodlg.h index b904234dad..6efebc8ddc 100644 --- a/client/gui-qt/diplodlg.h +++ b/client/gui-qt/diplodlg.h @@ -112,6 +112,7 @@ public: diplo_dlg(struct Treaty *ptreaty, struct player *they, struct player *initiator); ~diplo_dlg(); + void reactivate(); void update_dlg(); bool init(bool raise); diplo_wdg *find_widget(struct player *they); diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index fe601015ff..4578beebbf 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -80,9 +80,12 @@ void popup_help_dialog_typed(const char *item, enum help_page_type htype) int pos; const help_item *topic; - if (!help_dlg) { + if (help_dlg == nullptr) { help_dlg = new help_dialog(); + } else { + help_dlg->reactivate(); } + topic = get_help_item_spec(item, htype, &pos); if (pos >= 0) { help_dlg->set_topic(topic); diff --git a/client/gui-qt/optiondlg.cpp b/client/gui-qt/optiondlg.cpp index 9257f5fa78..04e92dc328 100644 --- a/client/gui-qt/optiondlg.cpp +++ b/client/gui-qt/optiondlg.cpp @@ -779,6 +779,7 @@ void option_dialog_popup(QString name, const struct option_set *poptset, if (::dialog_list.contains(poptset)) { opt_dialog = dialog_list[poptset]; + opt_dialog->reactivate(); opt_dialog->show(); } else { opt_dialog = new option_dialog(name, poptset, client_set, -- 2.35.1