Add an About dialog with build info (#2138)

add About dialog
This commit is contained in:
Nadia Holmquist Pedersen 2024-10-24 22:05:30 +02:00 committed by GitHub
parent a97463b0ac
commit 287f6642fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 470 additions and 5 deletions

View File

@ -9,6 +9,11 @@ on:
branches: branches:
- master - master
env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions
jobs: jobs:
build-macos: build-macos:
strategy: strategy:
@ -34,6 +39,7 @@ jobs:
with: with:
configurePreset: release-mac-${{ matrix.arch }} configurePreset: release-mac-${{ matrix.arch }}
buildPreset: release-mac-${{ matrix.arch }} buildPreset: release-mac-${{ matrix.arch }}
configurePresetAdditionalArgs: "['-DMELONDS_EMBED_BUILD_INFO=ON']"
- name: Compress app bundle - name: Compress app bundle
shell: bash shell: bash
run: | run: |

View File

@ -8,6 +8,11 @@ on:
branches: branches:
- master - master
env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions
jobs: jobs:
build-x86_64: build-x86_64:
name: x86_64 name: x86_64
@ -23,7 +28,7 @@ jobs:
sudo apt install --allow-downgrades cmake ninja-build extra-cmake-modules libpcap0.8-dev libsdl2-dev libenet-dev \ sudo apt install --allow-downgrades cmake ninja-build extra-cmake-modules libpcap0.8-dev libsdl2-dev libenet-dev \
qt6-{base,base-private,multimedia}-dev libqt6svg6-dev libarchive-dev libzstd-dev libfuse2 qt6-{base,base-private,multimedia}-dev libqt6svg6-dev libarchive-dev libzstd-dev libfuse2
- name: Configure - name: Configure
run: cmake -B build -G Ninja -DUSE_QT6=ON -DCMAKE_INSTALL_PREFIX=/usr run: cmake -B build -G Ninja -DUSE_QT6=ON -DCMAKE_INSTALL_PREFIX=/usr -DMELONDS_EMBED_BUILD_INFO=ON
- name: Build - name: Build
run: | run: |
cmake --build build cmake --build build
@ -74,7 +79,8 @@ jobs:
-DPKG_CONFIG_EXECUTABLE=/usr/bin/aarch64-linux-gnu-pkg-config \ -DPKG_CONFIG_EXECUTABLE=/usr/bin/aarch64-linux-gnu-pkg-config \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-12 \ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-12 \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++-12 \ -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++-12 \
-DUSE_QT6=ON -DUSE_QT6=ON \
-DMELONDS_EMBED_BUILD_INFO=ON
- name: Build - name: Build
shell: bash shell: bash
run: | run: |

View File

@ -9,6 +9,11 @@ on:
branches: branches:
- master - master
env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions
jobs: jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
@ -29,7 +34,7 @@ jobs:
with: with:
vcpkgGitCommitId: 10b7a178346f3f0abef60cecd5130e295afd8da4 vcpkgGitCommitId: 10b7a178346f3f0abef60cecd5130e295afd8da4
- name: Configure - name: Configure
run: cmake --preset=release-mingw-x86_64 run: cmake --preset=release-mingw-x86_64 -DMELONDS_EMBED_BUILD_INFO=ON
- name: Build - name: Build
run: cmake --build --preset=release-mingw-x86_64 run: cmake --build --preset=release-mingw-x86_64
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4

View File

@ -12,13 +12,16 @@
inherit (pkgs.lib) cmakeBool optionals makeLibraryPath; inherit (pkgs.lib) cmakeBool optionals makeLibraryPath;
inherit (pkgs.stdenv) isLinux isDarwin; inherit (pkgs.stdenv) isLinux isDarwin;
versionSuffix = with self; if sourceInfo?dirtyShortRev revision = with self; if sourceInfo?dirtyRev
then sourceInfo.dirtyRev
else sourceInfo.rev;
shortRevision = with self; if sourceInfo?dirtyShortRev
then sourceInfo.dirtyShortRev then sourceInfo.dirtyShortRev
else sourceInfo.shortRev; else sourceInfo.shortRev;
melonDS = pkgs.qt6.qtbase.stdenv.mkDerivation { melonDS = pkgs.qt6.qtbase.stdenv.mkDerivation {
pname = "melonDS"; pname = "melonDS";
version = "0.9.5-${versionSuffix}"; version = "0.9.5-${shortRevision}";
src = ./.; src = ./.;
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
@ -46,8 +49,13 @@
cmakeFlags = [ cmakeFlags = [
(cmakeBool "USE_QT6" true) (cmakeBool "USE_QT6" true)
(cmakeBool "USE_SYSTEM_LIBSLIRP" true) (cmakeBool "USE_SYSTEM_LIBSLIRP" true)
(cmakeBool "MELONDS_EMBED_BUILD_INFO" true)
]; ];
env.MELONDS_GIT_HASH = revision;
env.MELONDS_GIT_BRANCH = "(unknown)";
env.MELONDS_BUILD_PROVIDER = "Nix";
qtWrapperArgs = optionals isLinux [ qtWrapperArgs = optionals isLinux [
"--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ pkgs.libpcap pkgs.wayland ]}" "--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ pkgs.libpcap pkgs.wayland ]}"
] ++ optionals isDarwin [ ] ++ optionals isDarwin [

View File

@ -128,6 +128,17 @@ if (ENABLE_JIT)
endif() endif()
set(MELONDS_VERSION_SUFFIX "$ENV{MELONDS_VERSION_SUFFIX}" CACHE STRING "Suffix to add to displayed melonDS version") set(MELONDS_VERSION_SUFFIX "$ENV{MELONDS_VERSION_SUFFIX}" CACHE STRING "Suffix to add to displayed melonDS version")
option(MELONDS_EMBED_BUILD_INFO "Embed detailed build info into the binary" OFF)
set(MELONDS_GIT_BRANCH "$ENV{MELONDS_GIT_BRANCH}" CACHE STRING "The Git branch used for this build")
set(MELONDS_GIT_HASH "$ENV{MELONDS_GIT_HASH}" CACHE STRING "The hash of the Git commit")
set(MELONDS_BUILD_PROVIDER "$ENV{MELONDS_BUILD_PROVIDER}" CACHE STRING "The name of the provider of this build")
if (MELONDS_EMBED_BUILD_INFO)
target_compile_definitions(core PUBLIC MELONDS_EMBED_BUILD_INFO)
if (NOT MELONDS_GIT_BRANCH OR NOT MELONDS_GIT_HASH OR NOT MELONDS_BUILD_PROVIDER)
message(FATAL_ERROR "When embedding build information, all fields must be filled out. See src/CMakeLists.txt.")
endif()
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
target_sources(core PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/version.h") target_sources(core PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/version.h")

View File

@ -0,0 +1,58 @@
/*
Copyright 2016-2023 melonDS team
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#include "AboutDialog.h"
#include <QDesktopServices>
#include "ui_AboutDialog.h"
#include "version.h"
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::AboutDialog)
{
ui->setupUi(this);
ui->lblVersionInfo->setText("Version " MELONDS_VERSION);
#ifdef MELONDS_EMBED_BUILD_INFO
ui->lblBuildInfo->setText(
"Branch: " MELONDS_GIT_BRANCH "\n"
"Commit: " MELONDS_GIT_HASH "\n"
"Built by: " MELONDS_BUILD_PROVIDER
);
#else
ui->lblBuildInfo->hide();
#endif
adjustSize();
}
AboutDialog::~AboutDialog()
{
delete ui;
}
void AboutDialog::openWebsite()
{
QDesktopServices::openUrl(QUrl(MELONDS_URL));
}
void AboutDialog::openGitHub()
{
QDesktopServices::openUrl(QUrl("https://github.com/melonDS-emu/melonDS"));;
}

View File

@ -0,0 +1,50 @@
/*
Copyright 2016-2023 melonDS team
This file is part of melonDS.
melonDS is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with melonDS. If not, see http://www.gnu.org/licenses/.
*/
#ifndef MELONDS_ABOUTDIALOG_H
#define MELONDS_ABOUTDIALOG_H
#include <QDialog>
QT_BEGIN_NAMESPACE
namespace Ui
{
class AboutDialog;
}
QT_END_NAMESPACE
class AboutDialog : public QDialog
{
Q_OBJECT
public:
explicit AboutDialog(QWidget *parent = nullptr);
~AboutDialog() override;
private slots:
static void openWebsite();
static void openGitHub();
private:
Ui::AboutDialog *ui;
};
#endif //MELONDS_ABOUTDIALOG_H

View File

@ -0,0 +1,300 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>304</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>About melonDS</string>
</property>
<property name="modal">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetFixedSize</enum>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1">
<property name="spacing">
<number>24</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QLabel" name="lblLogo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="baseSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::PlainText</enum>
</property>
<property name="pixmap">
<pixmap resource="../../../res/melon.qrc">:/melon-icon</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0,0,1">
<property name="spacing">
<number>12</number>
</property>
<item alignment="Qt::AlignmentFlag::AlignTop">
<widget class="QLabel" name="label_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="font">
<font>
<pointsize>32</pointsize>
</font>
</property>
<property name="text">
<string>melonDS</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblVersionInfo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>[VERSION INFO PLACEHOLDER]</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::MarkdownText</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>By Arisotura, the melonDS team &lt;a href=&quot;https://github.com/melonDS-emu/melonDS/graphs/contributors&quot;&gt;and contributors&lt;/a&gt;.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblBuildInfo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>[EMBEDDED BUILD INFO PLACEHOLDER]</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignmentFlag::AlignBottom">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Licensed under the GNU General Public License v3 or any newer version.&lt;/p&gt;&lt;p&gt;melonDS is intended only for use with software that you own.&lt;/p&gt;&lt;p&gt;The Nintendo DS and Nintendo DSi systems are the property of Nintendo.&lt;br /&gt;melonDS and the melonDS team are not affiliated with or endorsed by Nintendo.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::TextFormat::RichText</enum>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="enabled">
<bool>true</bool>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnOpenWebsite">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Visit the &amp;website</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOpenGitHub">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>View on &amp;GitHub</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Close</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../../res/melon.qrc"/>
</resources>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>586</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>294</x>
<y>154</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnOpenGitHub</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>openGitHub()</slot>
<hints>
<hint type="sourcelabel">
<x>449</x>
<y>243</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>139</y>
</hint>
</hints>
</connection>
<connection>
<sender>btnOpenWebsite</sender>
<signal>clicked()</signal>
<receiver>AboutDialog</receiver>
<slot>openWebsite()</slot>
<hints>
<hint type="sourcelabel">
<x>345</x>
<y>245</y>
</hint>
<hint type="destinationlabel">
<x>96</x>
<y>275</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>openWebsite()</slot>
<slot>openGitHub()</slot>
</slots>
</ui>

View File

@ -37,6 +37,9 @@ set(SOURCES_QT_SDL
QPathInput.h QPathInput.h
SaveManager.cpp SaveManager.cpp
CameraManager.cpp CameraManager.cpp
AboutDialog.cpp
AboutDialog.h
AboutDialog.ui
ArchiveUtil.h ArchiveUtil.h
ArchiveUtil.cpp ArchiveUtil.cpp

View File

@ -82,6 +82,7 @@
#include "ArchiveUtil.h" #include "ArchiveUtil.h"
#include "CameraManager.h" #include "CameraManager.h"
#include "Window.h" #include "Window.h"
#include "AboutDialog.h"
using namespace melonDS; using namespace melonDS;
@ -645,6 +646,15 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
actAudioSync->setCheckable(true); actAudioSync->setCheckable(true);
connect(actAudioSync, &QAction::triggered, this, &MainWindow::onChangeAudioSync); connect(actAudioSync, &QAction::triggered, this, &MainWindow::onChangeAudioSync);
} }
{
QMenu* menu = menubar->addMenu("Help");
actAbout = menu->addAction("About...");
connect(actAbout, &QAction::triggered, this, [&]{
auto dialog = AboutDialog(this);
dialog.exec();
});
}
setMenuBar(menubar); setMenuBar(menubar);
if (localCfg.GetString("Firmware.Username") == "Arisotura") if (localCfg.GetString("Firmware.Username") == "Arisotura")

View File

@ -329,6 +329,8 @@ public:
QAction* actShowOSD; QAction* actShowOSD;
QAction* actLimitFramerate; QAction* actLimitFramerate;
QAction* actAudioSync; QAction* actAudioSync;
QAction* actAbout;
}; };
void ToggleFullscreen(MainWindow* mainWindow); void ToggleFullscreen(MainWindow* mainWindow);

View File

@ -25,5 +25,11 @@
#define MELONDS_VERSION_SUFFIX "${MELONDS_VERSION_SUFFIX}" #define MELONDS_VERSION_SUFFIX "${MELONDS_VERSION_SUFFIX}"
#define MELONDS_VERSION MELONDS_VERSION_BASE MELONDS_VERSION_SUFFIX #define MELONDS_VERSION MELONDS_VERSION_BASE MELONDS_VERSION_SUFFIX
#ifdef MELONDS_EMBED_BUILD_INFO
#define MELONDS_GIT_BRANCH "${MELONDS_GIT_BRANCH}"
#define MELONDS_GIT_HASH "${MELONDS_GIT_HASH}"
#define MELONDS_BUILD_PROVIDER "${MELONDS_BUILD_PROVIDER}"
#endif
#endif // VERSION_H #endif // VERSION_H