From 216cb02a0d0f8352f2c97940ceaa8d681242e15a Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Jul 2022 18:41:30 +0300 Subject: [PATCH 23/23] 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 6960a7a2d3..4b07994bbb 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -233,6 +233,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 51bb86364d..6952644711 100644 --- a/client/gui-qt/dialogs.h +++ b/client/gui-qt/dialogs.h @@ -76,6 +76,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 5d55bf8bd1..d07040fab0 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -862,6 +862,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). @@ -901,6 +909,7 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from) QPixmap *pix, *def_pix, *pix2, *pix3, *def_pix_del; QWidget *w; QWidget *fw; + bool was_open; if (client_is_observer()) { return; @@ -942,7 +951,8 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from) 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(counterpart, initiated_from); if (!dd->init(false)) { @@ -956,6 +966,11 @@ void handle_diplomacy_init_meeting(int counterpart, int initiated_from) fc_assert(i != -1); w = gui()->game_tab_widget->widget(i); dd = qobject_cast(w); + + if (was_open) { + dd->reactivate(); + } + fw = dd->find_widget(counterpart); if (fw == NULL) { dd->add_widget(counterpart, initiated_from); diff --git a/client/gui-qt/diplodlg.h b/client/gui-qt/diplodlg.h index 128dd67582..e8a99a1acb 100644 --- a/client/gui-qt/diplodlg.h +++ b/client/gui-qt/diplodlg.h @@ -110,6 +110,7 @@ class diplo_dlg: public QTabWidget public: diplo_dlg(int counterpart, int initiated_from); ~diplo_dlg(); + void reactivate(); void update_dlg(); bool init(bool raise); diplo_wdg *find_widget(int counterpart); diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp index f7164a80d4..3542229e42 100644 --- a/client/gui-qt/helpdlg.cpp +++ b/client/gui-qt/helpdlg.cpp @@ -79,9 +79,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 33a4ebcba9..b7abe9db40 100644 --- a/client/gui-qt/optiondlg.cpp +++ b/client/gui-qt/optiondlg.cpp @@ -779,6 +779,7 @@ void option_dialog_popup(const char *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, gui()->central_wdg); -- 2.35.1