From 31f7e5733e90ec042f9d2af1807344560efc4d5f Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 8 Jul 2023 10:33:12 -0400 Subject: [PATCH] Add about window to exdviewer and explorer as well --- CMakeLists.txt | 3 +- common/CMakeLists.txt | 17 +++++++++++ {mdlviewer => common}/include/aboutwindow.h | 0 {mdlviewer => common}/src/aboutwindow.cpp | 0 exdviewer/CMakeLists.txt | 2 +- exdviewer/src/mainwindow.cpp | 27 +++++++++++++++++ explorer/CMakeLists.txt | 2 +- explorer/src/mainwindow.cpp | 32 +++++++++++++++++++-- mdlviewer/CMakeLists.txt | 16 +++-------- 9 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 common/CMakeLists.txt rename {mdlviewer => common}/include/aboutwindow.h (100%) rename {mdlviewer => common}/src/aboutwindow.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c89178..0107a25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,4 +42,5 @@ add_subdirectory(mdlviewer) add_subdirectory(argcracker) add_subdirectory(explorer) add_subdirectory(bonedecomp) -add_subdirectory(parts) \ No newline at end of file +add_subdirectory(parts) +add_subdirectory(common) \ No newline at end of file diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 0000000..572e21f --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(NovusCommon STATIC) +target_sources(NovusCommon PRIVATE + include/aboutwindow.h + src/aboutwindow.cpp) +target_include_directories(NovusCommon PUBLIC + include + PRIVATE + ${CMAKE_BINARY_DIR}) +target_link_libraries(NovusCommon PUBLIC Qt5::Core Qt5::Widgets) + +# meant for including the license text +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE LICENSE_TXT) +STRING(REPLACE "\n" " \\n" LICENSE_TXT ${LICENSE_TXT}) +STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT}) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/license.h.in + ${CMAKE_BINARY_DIR}/license.h) diff --git a/mdlviewer/include/aboutwindow.h b/common/include/aboutwindow.h similarity index 100% rename from mdlviewer/include/aboutwindow.h rename to common/include/aboutwindow.h diff --git a/mdlviewer/src/aboutwindow.cpp b/common/src/aboutwindow.cpp similarity index 100% rename from mdlviewer/src/aboutwindow.cpp rename to common/src/aboutwindow.cpp diff --git a/exdviewer/CMakeLists.txt b/exdviewer/CMakeLists.txt index 8cb848b..898d2d3 100644 --- a/exdviewer/CMakeLists.txt +++ b/exdviewer/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(exdviewer target_include_directories(exdviewer PUBLIC include) -target_link_libraries(exdviewer PUBLIC physis z ${LIBRARIES} Qt5::Core Qt5::Widgets exdpart) +target_link_libraries(exdviewer PUBLIC physis z ${LIBRARIES} Qt5::Core Qt5::Widgets exdpart NovusCommon) install(TARGETS exdviewer DESTINATION "${INSTALL_BIN_PATH}") diff --git a/exdviewer/src/mainwindow.cpp b/exdviewer/src/mainwindow.cpp index baf1390..72a42c1 100644 --- a/exdviewer/src/mainwindow.cpp +++ b/exdviewer/src/mainwindow.cpp @@ -5,12 +5,39 @@ #include #include #include +#include +#include +#include +#include +#include #include "exdpart.h" +#include "aboutwindow.h" MainWindow::MainWindow(GameData* data) : data(data) { setWindowTitle("exdviewer"); + auto helpMenu = menuBar()->addMenu("Help"); + + auto donateAction = helpMenu->addAction("Donate"); + connect(donateAction, &QAction::triggered, this, [] { + QDesktopServices::openUrl(QUrl("https://redstrate.com/fund")); + }); + donateAction->setIcon(QIcon::fromTheme("help-donate")); + + helpMenu->addSeparator(); + + auto aboutNovusAction = helpMenu->addAction("About exdviewer"); + aboutNovusAction->setIcon(QIcon::fromTheme("help-about")); + connect(aboutNovusAction, &QAction::triggered, this, [this] { + auto window = new AboutWindow(this); + window->show(); + }); + + auto aboutQtAction = helpMenu->addAction("About Qt"); + aboutQtAction->setIcon(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png")); + connect(aboutQtAction, &QAction::triggered, QApplication::instance(), &QApplication::aboutQt); + auto dummyWidget = new QWidget(); setCentralWidget(dummyWidget); diff --git a/explorer/CMakeLists.txt b/explorer/CMakeLists.txt index b64d5d5..dada3b5 100644 --- a/explorer/CMakeLists.txt +++ b/explorer/CMakeLists.txt @@ -8,7 +8,7 @@ add_executable(explorer target_include_directories(explorer PUBLIC include) -target_link_libraries(explorer PUBLIC physis z ${LIBRARIES} Qt5::Core Qt5::Widgets) +target_link_libraries(explorer PUBLIC physis z ${LIBRARIES} Qt5::Core Qt5::Widgets NovusCommon) install(TARGETS explorer DESTINATION "${INSTALL_BIN_PATH}") diff --git a/explorer/src/mainwindow.cpp b/explorer/src/mainwindow.cpp index 6a4d507..5072a4e 100644 --- a/explorer/src/mainwindow.cpp +++ b/explorer/src/mainwindow.cpp @@ -1,15 +1,43 @@ #include "mainwindow.h" -#include "filetreewindow.h" -#include "filepropertieswindow.h" +#include +#include +#include +#include +#include #include #include #include #include +#include "filetreewindow.h" +#include "filepropertieswindow.h" +#include "aboutwindow.h" + MainWindow::MainWindow(GameData* data) : data(data) { setWindowTitle("explorer"); + auto helpMenu = menuBar()->addMenu("Help"); + + auto donateAction = helpMenu->addAction("Donate"); + connect(donateAction, &QAction::triggered, this, [] { + QDesktopServices::openUrl(QUrl("https://redstrate.com/fund")); + }); + donateAction->setIcon(QIcon::fromTheme("help-donate")); + + helpMenu->addSeparator(); + + auto aboutNovusAction = helpMenu->addAction("About explorer"); + aboutNovusAction->setIcon(QIcon::fromTheme("help-about")); + connect(aboutNovusAction, &QAction::triggered, this, [this] { + auto window = new AboutWindow(this); + window->show(); + }); + + auto aboutQtAction = helpMenu->addAction("About Qt"); + aboutQtAction->setIcon(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png")); + connect(aboutQtAction, &QAction::triggered, QApplication::instance(), &QApplication::aboutQt); + mdiArea = new QMdiArea(); setCentralWidget(mdiArea); diff --git a/mdlviewer/CMakeLists.txt b/mdlviewer/CMakeLists.txt index 4ca825b..c6c5436 100644 --- a/mdlviewer/CMakeLists.txt +++ b/mdlviewer/CMakeLists.txt @@ -13,8 +13,7 @@ add_executable(mdlviewer src/boneeditor.cpp src/cmpeditor.cpp src/gearlistwidget.cpp - src/gearlistmodel.cpp - src/aboutwindow.cpp) + src/gearlistmodel.cpp) target_include_directories(mdlviewer PUBLIC include @@ -28,7 +27,8 @@ target_link_libraries(mdlviewer PUBLIC assimp::assimp magic_enum physis z - mdlpart) + mdlpart + NovusCommon) install(TARGETS mdlviewer DESTINATION "${INSTALL_BIN_PATH}") @@ -45,12 +45,4 @@ if(WIN32) POST_BUILD COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$\" ) -endif() - -# meant for including the license text -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE LICENSE_TXT) -STRING(REPLACE "\n" " \\n" LICENSE_TXT ${LICENSE_TXT}) -STRING(REPLACE "\"" "\"\"" LICENSE_TXT ${LICENSE_TXT}) - -configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/license.h.in - ${CMAKE_BINARY_DIR}/license.h) +endif() \ No newline at end of file