18 #include "src/settingseditor/settingseditor.h" |
18 #include "src/settingseditor/settingseditor.h" |
19 #include "src/ui/circletooloptionswidget.h" |
19 #include "src/ui/circletooloptionswidget.h" |
20 #include "src/ui/objecteditor.h" |
20 #include "src/ui/objecteditor.h" |
21 #include "src/version.h" |
21 #include "src/version.h" |
22 #include "src/widgets/colorselectdialog.h" |
22 #include "src/widgets/colorselectdialog.h" |
|
23 #include <GL/glew.h> |
23 |
24 |
24 static const QDir LOCALE_DIR {":/locale"}; |
25 static const QDir LOCALE_DIR {":/locale"}; |
25 |
26 |
26 class ModelSubWindow : public QMdiSubWindow |
27 class ModelSubWindow : public QMdiSubWindow |
27 { |
28 { |
378 static void about(QWidget* parent) |
379 static void about(QWidget* parent) |
379 { |
380 { |
380 QDialog dialog{parent}; |
381 QDialog dialog{parent}; |
381 Ui_About ui; |
382 Ui_About ui; |
382 ui.setupUi(&dialog); |
383 ui.setupUi(&dialog); |
|
384 const char* glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION)); |
|
385 const QString extensions = []{ |
|
386 GLint numExtensions; |
|
387 glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); |
|
388 QStringList extensionsList; |
|
389 for (GLint i = 0; i < numExtensions; i++) { |
|
390 const GLubyte* ext = glGetStringi(GL_EXTENSIONS, i); |
|
391 extensionsList.push_back(reinterpret_cast<const char*>(ext)); |
|
392 } |
|
393 return extensionsList.join(" "); |
|
394 }(); |
383 for (QTextBrowser* browser : dialog.findChildren<QTextBrowser*>()) { |
395 for (QTextBrowser* browser : dialog.findChildren<QTextBrowser*>()) { |
384 browser->setHtml( |
396 browser->setHtml( |
385 browser->toHtml() |
397 browser->toHtml() |
386 .replace("%APPNAME%", CMAKE_PROJECT_NAME) |
398 .replace("%APPNAME%", CMAKE_PROJECT_NAME) |
387 .replace("%COPYRIGHT%", COPYRIGHT) |
399 .replace("%COPYRIGHT%", COPYRIGHT) |
393 .replace("%COMPILER_VERSION%", CMAKE_CXX_COMPILER_VERSION) |
405 .replace("%COMPILER_VERSION%", CMAKE_CXX_COMPILER_VERSION) |
394 .replace("%COMPILER_FLAGS%", CMAKE_CXX_FLAGS) |
406 .replace("%COMPILER_FLAGS%", CMAKE_CXX_FLAGS) |
395 .replace("%COMPILER_CPU%", CMAKE_SYSTEM_PROCESSOR) |
407 .replace("%COMPILER_CPU%", CMAKE_SYSTEM_PROCESSOR) |
396 .replace("%COMPILER_SYSTEM%", CMAKE_SYSTEM) |
408 .replace("%COMPILER_SYSTEM%", CMAKE_SYSTEM) |
397 .replace("%GLMVERSIONSTRING%", GLM_VERSION_MESSAGE) |
409 .replace("%GLMVERSIONSTRING%", GLM_VERSION_MESSAGE) |
|
410 .replace("%GL_VERSION%", glVersion) |
|
411 .replace("%GL_EXTENSIONS%", extensions) |
398 ); |
412 ); |
399 } |
413 } |
400 dialog.setWindowTitle(QObject::tr("About %1").arg(CMAKE_PROJECT_NAME)); |
414 dialog.setWindowTitle(QObject::tr("About %1").arg(CMAKE_PROJECT_NAME)); |
401 dialog.exec(); |
415 dialog.exec(); |
402 } |
416 } |
773 } |
787 } |
774 }); |
788 }); |
775 QObject::connect( |
789 QObject::connect( |
776 ui.actionAbout, |
790 ui.actionAbout, |
777 &QAction::triggered, |
791 &QAction::triggered, |
778 [&mainWindow]{about(&mainWindow);} |
792 [&mainWindow, &ui]{ |
|
793 // Make sure that there's an OpenGL context active, otherwise |
|
794 // we cannot obtain OpenGL information |
|
795 if (ui.mdiArea->findChildren<ModelSubWindow*>().empty()) { |
|
796 ui.actionNew->trigger(); |
|
797 } |
|
798 about(&mainWindow); |
|
799 } |
779 ); |
800 ); |
780 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); |
801 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); |
781 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
802 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
782 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
803 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
783 // If a dock is made floating and the app is closed, the dock becomes invisible |
804 // If a dock is made floating and the app is closed, the dock becomes invisible |