From 5d9671af9f0ea869947b207a8ea2035610bbadf9 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 10 Apr 2022 19:56:14 -0400 Subject: [PATCH] Improve about window Now it looks much, much nicer and will eventually include more fields, such as a place to report bugs etc. --- CMakeLists.txt | 14 ++++++-- cmake/license.h.in | 3 ++ include/aboutwindow.h | 8 +++++ src/aboutwindow.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++ src/launcherwindow.cpp | 8 ++--- 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 cmake/license.h.in create mode 100644 include/aboutwindow.h create mode 100644 src/aboutwindow.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 99595a7..afdbbec 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,9 @@ set(SRC include/config.h include/gameinstaller.h src/gameinstaller.cpp - src/encryptedarg.cpp) + src/encryptedarg.cpp + src/aboutwindow.cpp + include/aboutwindow.h) include(FetchContent) @@ -146,12 +148,20 @@ add_executable(astra ${SRC}) target_link_libraries(astra PUBLIC ${LIBRARIES} libxiv) +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) + target_include_directories(astra PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${KEYCHAIN_INCLUDE_DIRS} - ${QUAZIP_INCLUDE_DIRS}) + ${QUAZIP_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}) if(ENABLE_WATCHDOG) target_include_directories(astra PRIVATE ${TESSERACT_INCLUDE_DIRS} ${LEPTONICA_INCLUDE_DIRS}) 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/include/aboutwindow.h b/include/aboutwindow.h new file mode 100644 index 0000000..737e5a7 --- /dev/null +++ b/include/aboutwindow.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +class AboutWindow : public QDialog { +public: + AboutWindow(QWidget* widget = nullptr); +}; \ No newline at end of file diff --git a/src/aboutwindow.cpp b/src/aboutwindow.cpp new file mode 100644 index 0000000..0f7217f --- /dev/null +++ b/src/aboutwindow.cpp @@ -0,0 +1,78 @@ +#include "aboutwindow.h" + +#include +#include +#include +#include + +#include "license.h" +#include "config.h" + +AboutWindow::AboutWindow(QWidget* widget) : QDialog(widget) { + setWindowTitle("About"); + setWindowModality(Qt::WindowModality::ApplicationModal); + + auto mainLayout = new QVBoxLayout(this); + setLayout(mainLayout); + + auto mainLabel = new QLabel(); + mainLabel->setText(QString("

Astra

\nVersion %1").arg(version)); + mainLayout->addWidget(mainLabel); + + auto aboutWidget = new QWidget(); + auto aboutLayout = new QVBoxLayout(); + aboutWidget->setLayout(aboutLayout); + + auto aboutLabel = new QLabel(); + aboutLabel->setText("Cross-platform FFXIV launcher"); + aboutLayout->addWidget(aboutLabel); + + auto websiteLabel = new QLabel(); + websiteLabel->setText("https://xiv.zone/astra"); + websiteLabel->setOpenExternalLinks(true); + aboutLayout->addWidget(websiteLabel); + + auto licenseLabel = new QLabel(); + licenseLabel->setText("License: GNU General Public License Version 3"); + connect(licenseLabel, &QLabel::linkActivated, [this] { + QDialog* licenseDialog = new QDialog(this); + licenseDialog->setWindowTitle("License Agreement"); + + QVBoxLayout* layout = new QVBoxLayout(); + licenseDialog->setLayout(layout); + + QPlainTextEdit* 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/src/launcherwindow.cpp b/src/launcherwindow.cpp index c219fe4..8a4e073 100644 --- a/src/launcherwindow.cpp +++ b/src/launcherwindow.cpp @@ -16,6 +16,7 @@ #include "assetupdater.h" #include "headline.h" #include "config.h" +#include "aboutwindow.h" LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindow(parent), core(core) { setWindowTitle("Astra"); @@ -84,11 +85,8 @@ LauncherWindow::LauncherWindow(LauncherCore& core, QWidget* parent) : QMainWindo QAction* showAbout = helpMenu->addAction("About Astra"); showAbout->setIcon(QIcon::fromTheme("help-about")); connect(showAbout, &QAction::triggered, [=] { - QString aboutText; - aboutText.append(QString("Version: %1\n").arg(version)); - aboutText.append("The source code is available at https://sr.ht/~redstrate/astra."); - - QMessageBox::about(this, "About Astra", aboutText); + auto window = new AboutWindow(this); + window->show(); }); QAction* showAboutQt = helpMenu->addAction("About Qt");