33#include < qdialog.h>
44#include < qgridlayout.h>
55#include < qlogging.h>
6+ #include < qmainwindow.h>
67#include < qmessagebox.h>
78#include < qobject.h>
89#include < qpushbutton.h>
@@ -15,8 +16,16 @@ using Lazyboard::front_end::AboutWindow;
1516using std::make_unique;
1617using Self = AboutWindow;
1718
19+ #if defined(LAZY_DEBUG)
20+ #include < string>
21+
22+ #include " ../front_end_utils/include/utils.hxx"
23+ using Lazyboard::front_end_utils::debug_info;
24+ using Lazyboard::front_end_utils::dump_ptr_address;
25+ using std::string;
26+ #endif
27+
1828AboutWindow::AboutWindow () {
19- about_window = make_unique<QDialog>();
2029 grid_layout = make_unique<QGridLayout>();
2130 github_button = make_unique<QPushButton>();
2231 github_issue_button = make_unique<QPushButton>();
@@ -31,8 +40,7 @@ void Self::is_open_browser_ok(ResultContext &status) {
3140 break ;
3241
3342 case R::FAILED:
34- QMessageBox::critical (about_window.get (), " Error" ,
35- " Could not open your browser" );
43+ QMessageBox::critical (this , " Error" , " Could not open your browser" );
3644 }
3745}
3846
@@ -66,14 +74,48 @@ void Self::setup_buttons() {
6674}
6775
6876void Self::setup_front_end () {
69- about_window ->setLayout (this ->grid_layout .get ());
77+ this ->setLayout (this ->grid_layout .get ());
7078 this ->setup_buttons ();
7179}
7280
7381void Self::show_window () {
74- about_window ->setMinimumSize (MIN_WIDTH, MIN_HEIGHT);
75- about_window ->setWindowTitle (" Lazyboard About" );
82+ this ->setMinimumSize (MIN_WIDTH, MIN_HEIGHT);
83+ this ->setWindowTitle (" Lazyboard About" );
7684
7785 this ->setup_front_end ();
78- about_window->exec ();
86+ this ->exec ();
87+ }
88+
89+ void Self::on_closed (QMainWindow *main_window) {
90+ using O = QObject;
91+ const auto fn = [this , main_window] {
92+ main_window->show ();
93+
94+ // clang-format off
95+ #if defined (LAZY_DEBUG)
96+ debug_info (" About window is closed" );
97+ #endif // clang-format on
98+ };
99+
100+ O::connect (this , &QDialog::rejected, fn);
101+ }
102+
103+ void Self::showEvent (QShowEvent *event) {
104+ QDialog::showEvent (event);
105+ this ->_main_window ->setHidden (true );
106+
107+ // clang-format off
108+ #if defined (LAZY_DEBUG)
109+ debug_info (" About Dialog is open" );
110+ #endif // clang-format on
111+ }
112+
113+ void Self::on_about_window_event (QMainWindow *main_window) {
114+ this ->_main_window = main_window;
115+ this ->on_closed (this ->_main_window );
116+
117+ // clang-format off
118+ #if defined (LAZY_DEBUG)
119+ dump_ptr_address (main_window);
120+ #endif // clang-format on
79121}
0 commit comments