diff --git a/game/localplayer/CityType.cpp b/game/localplayer/CityType.cpp index b770e76..c3f824d 100644 --- a/game/localplayer/CityType.cpp +++ b/game/localplayer/CityType.cpp @@ -106,6 +106,11 @@ CityTypeDlg::CityTypeDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::CityTy changed = true; smartUpdateContent(); }; + onShow = [this] { + loadType(0); + dragiix = -1; + offscreenPaint(); + }; } CityTypeDlg::~CityTypeDlg() @@ -140,14 +145,6 @@ void CityTypeDlg::saveType() changed = false; } -void CityTypeDlg::showEvent(QShowEvent *event) -{ - FramedDlg::showEvent(event); - loadType(0); - dragiix = -1; - offscreenPaint(); -} - void CityTypeDlg::closeEvent(QCloseEvent *event) { saveType(); diff --git a/game/localplayer/CityType.h b/game/localplayer/CityType.h index 295b10b..c38f2dd 100644 --- a/game/localplayer/CityType.h +++ b/game/localplayer/CityType.h @@ -55,7 +55,6 @@ public: protected: void offscreenPaint() override; void vpaint(Dpi::Canvas &canvas) override; - void showEvent(QShowEvent *event) override; void resizeEvent(QResizeEvent *event) override; void closeEvent(QCloseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; diff --git a/game/localplayer/Diagram.cpp b/game/localplayer/Diagram.cpp index f94b100..704b6be 100644 --- a/game/localplayer/Diagram.cpp +++ b/game/localplayer/Diagram.cpp @@ -164,6 +164,11 @@ DiaDlg::DiaDlg(QWidget *parent) : FramedDlg(parent), ui(new Ui::DiaDlg) ui->closeBtn->onClick = [this] { close(); }; ui->toggleBtn->onClick = [this] { toggleBtnClicked(); }; + onShow = [this] { + if (windowMode() == WindowMode::Modal) + centerToScreen(); + offscreenPaint(); + }; } DiaDlg::~DiaDlg() @@ -281,14 +286,6 @@ void DiaDlg::vpaint(Dpi::Canvas &canvas) loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, 31, s); } -void DiaDlg::showEvent(QShowEvent *event) -{ - FramedDlg::showEvent(event); - if (windowMode() == WindowMode::Modal) - centerToScreen(); - offscreenPaint(); -} - void DiaDlg::resizeEvent(QResizeEvent *event) { FramedDlg::resizeEvent(event); diff --git a/game/localplayer/Diagram.h b/game/localplayer/Diagram.h index 96ad342..a229375 100644 --- a/game/localplayer/Diagram.h +++ b/game/localplayer/Diagram.h @@ -57,7 +57,6 @@ public: protected: void offscreenPaint() override; void vpaint(Dpi::Canvas &canvas) override; - void showEvent(QShowEvent *event) override; void resizeEvent(QResizeEvent *event) override; void keyPressEvent(QKeyEvent *event) override; diff --git a/game/localplayer/Rates.cpp b/game/localplayer/Rates.cpp index 12c3262..6e4f685 100644 --- a/game/localplayer/Rates.cpp +++ b/game/localplayer/Rates.cpp @@ -73,6 +73,13 @@ RatesDlg::RatesDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::RatesD ui->taxDownBtn->onClick = [this] { taxLuxBtnClick(1); }; ui->scienceBtn->onClick = [this] { taxLuxBtnClick(2); }; ui->luxBtn->onClick = [this] { taxLuxBtnClick(3); }; + onShow = [this] { + setWindowTitle(phrase(QStringLiteral("TITLE_RATES"))); + const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me; + ui->scienceBtn->setVisible(!hasLiberty); + ui->luxBtn->setVisible(!hasLiberty); + offscreenPaint(); + }; } RatesDlg::~RatesDlg() @@ -164,16 +171,6 @@ void RatesDlg::resizeEvent(QResizeEvent *event) ui->closeBtn->move(width() - 38, ui->closeBtn->y()); } -void RatesDlg::showEvent(QShowEvent *event) -{ - BufferedDrawDlg::showEvent(event); - setWindowTitle(phrase(QStringLiteral("TITLE_RATES"))); - const bool hasLiberty = ClientTools::myRO->Wonder[woLiberty].EffectiveOwner == ClientTools::me; - ui->scienceBtn->setVisible(!hasLiberty); - ui->luxBtn->setVisible(!hasLiberty); - offscreenPaint(); -} - void RatesDlg::taxLuxBtnClick(int which) { int newTax = ClientTools::myRO->TaxRate / 10; diff --git a/game/localplayer/Rates.h b/game/localplayer/Rates.h index b45634e..566e2c7 100644 --- a/game/localplayer/Rates.h +++ b/game/localplayer/Rates.h @@ -51,7 +51,6 @@ public: protected: void offscreenPaint() override; - void showEvent(QShowEvent *event) override; void resizeEvent(QResizeEvent *event) override; private: diff --git a/game/localplayer/Wonders.cpp b/game/localplayer/Wonders.cpp index 339c8aa..3d561d8 100644 --- a/game/localplayer/Wonders.cpp +++ b/game/localplayer/Wonders.cpp @@ -92,6 +92,11 @@ WondersDlg::WondersDlg(QWidget *parent) : BufferedDrawDlg(parent), ui(new Ui::Wo ui->closeBtn->setButtonIndex(0); ui->closeBtn->onClick = [this] { close(); }; initButtons(); + onShow = [this] { + setWindowTitle(phrase(QStringLiteral("TITLE_WONDERS"))); + selection = -1; + offscreenPaint(); + }; } WondersDlg::~WondersDlg() @@ -281,14 +286,6 @@ void WondersDlg::vpaint(Dpi::Canvas &canvas) loweredTextOut(canvas, -1, *MainTexture, (width() - biColorTextWidth(canvas, s)) / 2, height() - 3 - 36 + 10, s); } -void WondersDlg::showEvent(QShowEvent *event) -{ - BufferedDrawDlg::showEvent(event); - setWindowTitle(phrase(QStringLiteral("TITLE_WONDERS"))); - selection = -1; - offscreenPaint(); -} - void WondersDlg::resizeEvent(QResizeEvent *event) { BufferedDrawDlg::resizeEvent(event); diff --git a/game/localplayer/Wonders.h b/game/localplayer/Wonders.h index 0a4d9fa..77787f3 100644 --- a/game/localplayer/Wonders.h +++ b/game/localplayer/Wonders.h @@ -54,7 +54,6 @@ public: protected: void offscreenPaint() override; void vpaint(Dpi::Canvas &canvas) override; - void showEvent(QShowEvent *event) override; void resizeEvent(QResizeEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;