4 #include <QMdiSubWindow> |
4 #include <QMdiSubWindow> |
5 #include <QMessageBox> |
5 #include <QMessageBox> |
6 #include <QScrollBar> |
6 #include <QScrollBar> |
7 #include <QStackedWidget> |
7 #include <QStackedWidget> |
8 #include <QTranslator> |
8 #include <QTranslator> |
|
9 #include <ui_about.h> |
9 #include <ui_mainwindow.h> |
10 #include <ui_mainwindow.h> |
10 #include "src/gl/partrenderer.h" |
11 #include "src/gl/partrenderer.h" |
11 #include "src/layers/axeslayer.h" |
12 #include "src/layers/axeslayer.h" |
12 #include "src/layers/edittools.h" |
13 #include "src/layers/edittools.h" |
13 #include "src/layers/gridlayer.h" |
14 #include "src/layers/gridlayer.h" |
67 }; |
68 }; |
68 #include <main.moc> |
69 #include <main.moc> |
69 |
70 |
70 static void doQtRegistrations() |
71 static void doQtRegistrations() |
71 { |
72 { |
72 QCoreApplication::setApplicationName(::appName); |
73 QCoreApplication::setApplicationName(QStringLiteral(APPNAME)); |
73 QCoreApplication::setOrganizationName("hecknology.net"); |
74 QCoreApplication::setOrganizationName("hecknology.net"); |
74 QCoreApplication::setOrganizationDomain("hecknology.net"); |
75 QCoreApplication::setOrganizationDomain("hecknology.net"); |
75 qRegisterMetaType<Message>(); |
76 qRegisterMetaType<Message>(); |
76 qRegisterMetaType<Library>(); |
77 qRegisterMetaType<Library>(); |
77 qRegisterMetaType<QList<Library>>(); |
78 qRegisterMetaType<QList<Library>>(); |
360 for (const QModelIndex& index : indexList) |
354 for (const QModelIndex& index : indexList) |
361 { |
355 { |
362 result.push_back(index.row()); |
356 result.push_back(index.row()); |
363 } |
357 } |
364 return result; |
358 return result; |
|
359 } |
|
360 |
|
361 static void about(QWidget* parent) |
|
362 { |
|
363 QDialog dialog{parent}; |
|
364 Ui_About ui; |
|
365 ui.setupUi(&dialog); |
|
366 ui.textBrowser->setHtml( |
|
367 ui.textBrowser->toHtml() |
|
368 .replace("%APPNAME%", APPNAME) |
|
369 .replace("%COPYRIGHT%", COPYRIGHT) |
|
370 .replace("%VERSION%", detailedVersionString()) |
|
371 .replace("%REVDATE%", revisionDateString()) |
|
372 .replace("%QTVERSION%", qVersion()) |
|
373 ); |
|
374 dialog.setWindowTitle(QObject::tr("About %1").arg(APPNAME)); |
|
375 dialog.exec(); |
365 } |
376 } |
366 |
377 |
367 int main(int argc, char *argv[]) |
378 int main(int argc, char *argv[]) |
368 { |
379 { |
369 doQtRegistrations(); |
380 doQtRegistrations(); |
582 const QString* pathPtr = documents.modelPath(modelId); |
593 const QString* pathPtr = documents.modelPath(modelId); |
583 if (pathPtr != nullptr) { |
594 if (pathPtr != nullptr) { |
584 addRecentlyOpenedFile(*pathPtr); |
595 addRecentlyOpenedFile(*pathPtr); |
585 } |
596 } |
586 } |
597 } |
587 }; |
598 };; |
588 const auto actionSaveAs = [&]{ |
599 const auto actionSaveAs = [&]{ |
589 const std::optional<ModelId> modelId = findCurrentModelId(&ui); |
600 const std::optional<ModelId> modelId = findCurrentModelId(&ui); |
590 if (modelId.has_value()) |
601 if (modelId.has_value()) |
591 { |
602 { |
592 const QString* pathPtr = documents.modelPath(*modelId); |
603 const QString* pathPtr = documents.modelPath(*modelId); |
707 for (const ModelAction& action : ldraw::makeUnofficial(model)) { |
718 for (const ModelAction& action : ldraw::makeUnofficial(model)) { |
708 executeAction(model, action); |
719 executeAction(model, action); |
709 } |
720 } |
710 } |
721 } |
711 }); |
722 }); |
|
723 QObject::connect( |
|
724 ui.actionAbout, |
|
725 &QAction::triggered, |
|
726 [&mainWindow]{about(&mainWindow);} |
|
727 ); |
712 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); |
728 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); |
713 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
729 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
714 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
730 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
715 // If a dock is made floating and the app is closed, the dock becomes invisible |
731 // If a dock is made floating and the app is closed, the dock becomes invisible |
716 // after the restoreState call. So we make them visible again here. |
732 // after the restoreState call. So we make them visible again here. |
718 dock->setVisible(true); |
734 dock->setVisible(true); |
719 } |
735 } |
720 restoreSettings(); |
736 restoreSettings(); |
721 updateRenderPreferences(&ui, &renderPreferences, &documents); |
737 updateRenderPreferences(&ui, &renderPreferences, &documents); |
722 mainWindow.setWindowTitle(title()); |
738 mainWindow.setWindowTitle(title()); |
|
739 ui.actionAbout->setText(ui.actionAbout->text().arg(APPNAME)); |
723 mainWindow.show(); |
740 mainWindow.show(); |
724 const int result = app.exec(); |
741 const int result = app.exec(); |
725 saveSettings(); |
742 saveSettings(); |
726 return result; |
743 return result; |
727 } |
744 } |