diff --git a/cmake/license.h.in b/cmake/license.h.in new file mode 100644 index 0000000..f0d7856 --- /dev/null +++ b/cmake/license.h.in @@ -0,0 +1,3 @@ +#pragma once + +const QString license = QStringLiteral("@LICENSE_TXT@"); \ No newline at end of file diff --git a/mdlviewer/CMakeLists.txt b/mdlviewer/CMakeLists.txt index a38f1f5..4ca825b 100644 --- a/mdlviewer/CMakeLists.txt +++ b/mdlviewer/CMakeLists.txt @@ -13,10 +13,13 @@ add_executable(mdlviewer src/boneeditor.cpp src/cmpeditor.cpp src/gearlistwidget.cpp - src/gearlistmodel.cpp) + src/gearlistmodel.cpp + src/aboutwindow.cpp) target_include_directories(mdlviewer PUBLIC - include) + include + PRIVATE + ${CMAKE_BINARY_DIR}) target_link_libraries(mdlviewer PUBLIC ${LIBRARIES} Qt5::Core @@ -43,3 +46,11 @@ if(WIN32) 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) diff --git a/mdlviewer/include/aboutwindow.h b/mdlviewer/include/aboutwindow.h new file mode 100644 index 0000000..553c17a --- /dev/null +++ b/mdlviewer/include/aboutwindow.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +class AboutWindow : public QDialog { +public: + explicit AboutWindow(QWidget* widget = nullptr); +}; \ No newline at end of file diff --git a/mdlviewer/src/aboutwindow.cpp b/mdlviewer/src/aboutwindow.cpp new file mode 100644 index 0000000..9223d05 --- /dev/null +++ b/mdlviewer/src/aboutwindow.cpp @@ -0,0 +1,78 @@ +#include "aboutwindow.h" + +#include +#include +#include +#include +#include + +#include "license.h" + +AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { + setWindowTitle("About"); + setWindowModality(Qt::WindowModality::ApplicationModal); + + auto mainLayout = new QVBoxLayout(); + setLayout(mainLayout); + + auto mainLabel = new QLabel(); + mainLabel->setText(QString("

%1

").arg(QCoreApplication::applicationName())); + mainLayout->addWidget(mainLabel); + + auto aboutWidget = new QWidget(); + auto aboutLayout = new QVBoxLayout(); + aboutWidget->setLayout(aboutLayout); + + auto aboutLabel = new QLabel(); + aboutLabel->setText("Part of the Novus modding tool environment."); + aboutLayout->addWidget(aboutLabel); + + auto websiteLabel = new QLabel(); + websiteLabel->setText("https://xiv.zone/novus"); + websiteLabel->setOpenExternalLinks(true); + aboutLayout->addWidget(websiteLabel); + + auto licenseLabel = new QLabel(); + licenseLabel->setText("License: GNU General Public License Version 3"); + connect(licenseLabel, &QLabel::linkActivated, [this] { + auto licenseDialog = new QDialog(this); + licenseDialog->setWindowTitle("License Agreement"); + + auto layout = new QVBoxLayout(); + licenseDialog->setLayout(layout); + + auto licenseEdit = new QPlainTextEdit(); + licenseEdit->setPlainText(license); + licenseEdit->setReadOnly(true); + layout->addWidget(licenseEdit); + + licenseDialog->show(); + }); + aboutLayout->addWidget(licenseLabel); + + aboutLayout->addStretch(); + + auto authorsWidget = new QWidget(); + auto authorsLayout = new QVBoxLayout(); + authorsWidget->setLayout(authorsLayout); + + auto authorNameLabel = new QLabel(); + authorNameLabel->setText("Joshua Goins"); + + QFont boldFont = authorNameLabel->font(); + boldFont.setBold(true); + authorNameLabel->setFont(boldFont); + + authorsLayout->addWidget(authorNameLabel); + + auto authorRoleLabel = new QLabel(); + authorRoleLabel->setText("Maintainer"); + authorsLayout->addWidget(authorRoleLabel); + + authorsLayout->addStretch(); + + auto tabWidget = new QTabWidget(); + tabWidget->addTab(aboutWidget, "About"); + tabWidget->addTab(authorsWidget, "Authors"); + mainLayout->addWidget(tabWidget); +} \ No newline at end of file diff --git a/mdlviewer/src/mainwindow.cpp b/mdlviewer/src/mainwindow.cpp index ced0538..1f28fa2 100644 --- a/mdlviewer/src/mainwindow.cpp +++ b/mdlviewer/src/mainwindow.cpp @@ -14,7 +14,9 @@ #include #include #include +#include +#include "aboutwindow.h" #include "cmpeditor.h" #include "gearlistwidget.h" @@ -47,6 +49,24 @@ MainWindow::MainWindow(GameData* in_data) : data(*in_data) { cmpEditor->show(); }); + auto helpMenu = menuBar()->addMenu("Help"); + + auto donateAction = helpMenu->addAction("Donate"); + donateAction->setIcon(QIcon::fromTheme("help-donate")); + + helpMenu->addSeparator(); + + auto aboutNovusAction = helpMenu->addAction("About mdlviewer"); + 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);