--- a/src/main.cpp Mon Jun 27 02:01:52 2022 +0300 +++ b/src/main.cpp Mon Jun 27 15:46:12 2022 +0300 @@ -6,6 +6,7 @@ #include <QScrollBar> #include <QStackedWidget> #include <QTranslator> +#include <ui_about.h> #include <ui_mainwindow.h> #include "src/gl/partrenderer.h" #include "src/layers/axeslayer.h" @@ -69,7 +70,7 @@ static void doQtRegistrations() { - QCoreApplication::setApplicationName(::appName); + QCoreApplication::setApplicationName(QStringLiteral(APPNAME)); QCoreApplication::setOrganizationName("hecknology.net"); QCoreApplication::setOrganizationDomain("hecknology.net"); qRegisterMetaType<Message>(); @@ -213,16 +214,9 @@ } } -/** - * @brief Updates the title of the main window so to contain the app's name - * and version as well as the open document name. - */ static QString title() { - QString title = ::appName; - title += " "; - title += fullVersionString(); - return title; + return fullVersionString(); } static ColorTable loadColors(const LibrariesModel* libraries) @@ -364,6 +358,23 @@ return result; } +static void about(QWidget* parent) +{ + QDialog dialog{parent}; + Ui_About ui; + ui.setupUi(&dialog); + ui.textBrowser->setHtml( + ui.textBrowser->toHtml() + .replace("%APPNAME%", APPNAME) + .replace("%COPYRIGHT%", COPYRIGHT) + .replace("%VERSION%", detailedVersionString()) + .replace("%REVDATE%", revisionDateString()) + .replace("%QTVERSION%", qVersion()) + ); + dialog.setWindowTitle(QObject::tr("About %1").arg(APPNAME)); + dialog.exec(); +} + int main(int argc, char *argv[]) { doQtRegistrations(); @@ -584,7 +595,7 @@ addRecentlyOpenedFile(*pathPtr); } } - }; + };; const auto actionSaveAs = [&]{ const std::optional<ModelId> modelId = findCurrentModelId(&ui); if (modelId.has_value()) @@ -709,6 +720,11 @@ } } }); + QObject::connect( + ui.actionAbout, + &QAction::triggered, + [&mainWindow]{about(&mainWindow);} + ); mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); mainWindow.restoreState(setting<Setting::MainWindowState>()); @@ -720,6 +736,7 @@ restoreSettings(); updateRenderPreferences(&ui, &renderPreferences, &documents); mainWindow.setWindowTitle(title()); + ui.actionAbout->setText(ui.actionAbout->text().arg(APPNAME)); mainWindow.show(); const int result = app.exec(); saveSettings();