From 5a34349465556f1ac7b9f10374a673c9e3742cc7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Jul 2022 18:37:18 +0300 Subject: [PATCH 30/30] 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 2098d357f1..a244774f16 100644 --- a/client/gui-qt/dialogs.cpp +++ b/client/gui-qt/dialogs.cpp @@ -315,6 +315,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 dd6a15c849..0ff481f34f 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 7c3f7cae40..62b800844c 100644 --- a/client/gui-qt/diplodlg.cpp +++ b/client/gui-qt/diplodlg.cpp @@ -848,6 +848,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). @@ -887,6 +895,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; @@ -928,7 +937,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)) { @@ -942,6 +952,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 041f0a9c58..757818c438 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 8ddcec336c..fcd16ccc78 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