diff -r c5e8b68e34f8 -r e1d646a4cbd8 src/mainwindow.cpp --- a/src/mainwindow.cpp Sun Apr 09 13:28:36 2023 +0300 +++ b/src/mainwindow.cpp Sun Apr 09 15:59:08 2023 +0300 @@ -4,6 +4,7 @@ #include #include #include +#include "src/settings.h" static constexpr MemberData renderStyleButtons[] = { { offsetof(MainWindow, actionRenderStyleNormal), gl::RenderStyle::Normal }, @@ -26,6 +27,19 @@ }); } this->connect(this->actionAbout, &QAction::triggered, this, &MainWindow::showAboutDialog); + this->connect(this->mdiArea, &QMdiArea::subWindowActivated, this, &MainWindow::updateTitle); + this->gridMatrix->setValue(DEFAULT_GRID_MATRIX); + this->tabifyDockWidget(this->messageLogDock, this->toolOptionsDock); + this->restoreGeometry(setting()); + this->restoreState(setting()); + // If a dock is made floating and the app is closed, the dock becomes invisible + // after the restoreState call. So we make them visible again here. + for (QDockWidget* dock : this->findChildren()) { + dock->setVisible(true); + } + this->actionAbout->setText(this->actionAbout->text().arg(CMAKE_PROJECT_NAME)); + this->updateTitle(); + this->show(); } void MainWindow::setRenderStyle(gl::RenderStyle style) @@ -100,3 +114,28 @@ }); } } + +static QString title(MainWindow* ui) +{ + QMdiSubWindow* subWindow = ui->mdiArea->activeSubWindow(); + QString titlestring; + const QString versionString = fullVersionString(QLocale::ShortFormat); + if (subWindow != nullptr) { + titlestring = QObject::tr("%1 - %2").arg(subWindow->windowTitle(), versionString); + } + else { + titlestring = versionString; + } + if (/* DISABLES CODE */ (true) + and std::strcmp(CMAKE_BUILD_TYPE, "Release") != 0 + and std::strcmp(CMAKE_BUILD_TYPE, "MinSizeRel") != 0 + ) { + titlestring += QObject::tr(" [%1]").arg(CMAKE_BUILD_TYPE); + } + return titlestring; +} + +void MainWindow::updateTitle() +{ + this->setWindowTitle(title(this)); +}