Skip to content

Commit

Permalink
Add an About dialog with build info (#2138)
Browse files Browse the repository at this point in the history
add About dialog
  • Loading branch information
nadiaholmquist authored Oct 24, 2024
1 parent a97463b commit 287f664
Show file tree
Hide file tree
Showing 12 changed files with 470 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
branches:
- master

env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions

jobs:
build-macos:
strategy:
Expand All @@ -34,6 +39,7 @@ jobs:
with:
configurePreset: release-mac-${{ matrix.arch }}
buildPreset: release-mac-${{ matrix.arch }}
configurePresetAdditionalArgs: "['-DMELONDS_EMBED_BUILD_INFO=ON']"
- name: Compress app bundle
shell: bash
run: |
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
branches:
- master

env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions

jobs:
build-x86_64:
name: x86_64
Expand All @@ -23,7 +28,7 @@ jobs:
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
- 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
run: |
cmake --build build
Expand Down Expand Up @@ -74,7 +79,8 @@ jobs:
-DPKG_CONFIG_EXECUTABLE=/usr/bin/aarch64-linux-gnu-pkg-config \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-12 \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++-12 \
-DUSE_QT6=ON
-DUSE_QT6=ON \
-DMELONDS_EMBED_BUILD_INFO=ON
- name: Build
shell: bash
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
branches:
- master

env:
MELONDS_GIT_BRANCH: ${{ github.ref }}
MELONDS_GIT_HASH: ${{ github.sha }}
MELONDS_BUILD_PROVIDER: GitHub Actions

jobs:
build:
runs-on: windows-latest
Expand All @@ -29,7 +34,7 @@ jobs:
with:
vcpkgGitCommitId: 10b7a178346f3f0abef60cecd5130e295afd8da4
- name: Configure
run: cmake --preset=release-mingw-x86_64
run: cmake --preset=release-mingw-x86_64 -DMELONDS_EMBED_BUILD_INFO=ON
- name: Build
run: cmake --build --preset=release-mingw-x86_64
- uses: actions/upload-artifact@v4
Expand Down
12 changes: 10 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
inherit (pkgs.lib) cmakeBool optionals makeLibraryPath;
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
else sourceInfo.shortRev;

melonDS = pkgs.qt6.qtbase.stdenv.mkDerivation {
pname = "melonDS";
version = "0.9.5-${versionSuffix}";
version = "0.9.5-${shortRevision}";
src = ./.;

nativeBuildInputs = with pkgs; [
Expand Down Expand Up @@ -46,8 +49,13 @@
cmakeFlags = [
(cmakeBool "USE_QT6" 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 [
"--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ pkgs.libpcap pkgs.wayland ]}"
] ++ optionals isDarwin [
Expand Down
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ if (ENABLE_JIT)
endif()

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")
target_sources(core PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/version.h")
Expand Down
58 changes: 58 additions & 0 deletions src/frontend/qt_sdl/AboutDialog.cpp
Original file line number Diff line number Diff line change
@@ -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"));;
}
50 changes: 50 additions & 0 deletions src/frontend/qt_sdl/AboutDialog.h
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 287f664

Please sign in to comment.