From eb6f9d469a61894fbaaeff3564e3c6b60fc3ad47 Mon Sep 17 00:00:00 2001 From: Mahmoud Mandour Date: Sun, 29 Aug 2021 12:00:50 +0200 Subject: [PATCH] AboutDialog: Accept a version string This allows applications to specify a version string to appear in the `AboutDialog`. --- Userland/Libraries/LibGUI/AboutDialog.cpp | 11 +++-------- Userland/Libraries/LibGUI/AboutDialog.h | 9 +++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index cae0fb8861..8685463717 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include @@ -17,10 +16,11 @@ namespace GUI { -AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window* parent_window) +AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window* parent_window, const StringView& version) : Dialog(parent_window) , m_name(name) , m_icon(icon) + , m_version_string(version) { resize(413, 204); set_title(String::formatted("About {}", m_name)); @@ -70,7 +70,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name if (m_name != "SerenityOS") make_label("SerenityOS"); - make_label(version_string()); + make_label(m_version_string); make_label("Copyright \xC2\xA9 the SerenityOS developers, 2018-2021"); right_container.layout()->add_spacer(); @@ -90,9 +90,4 @@ AboutDialog::~AboutDialog() { } -String AboutDialog::version_string() const -{ - return Core::Version::SERENITY_VERSION; -} - } diff --git a/Userland/Libraries/LibGUI/AboutDialog.h b/Userland/Libraries/LibGUI/AboutDialog.h index 01b0f8bf2c..3d41704498 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.h +++ b/Userland/Libraries/LibGUI/AboutDialog.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace GUI { @@ -15,19 +16,19 @@ class AboutDialog final : public Dialog { public: virtual ~AboutDialog() override; - static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const Gfx::Bitmap* window_icon = nullptr) + static void show(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const Gfx::Bitmap* window_icon = nullptr, const StringView& version = Core::Version::SERENITY_VERSION) { - auto dialog = AboutDialog::construct(name, icon, parent_window); + auto dialog = AboutDialog::construct(name, icon, parent_window, version); if (window_icon) dialog->set_icon(window_icon); dialog->exec(); } private: - AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr); - String version_string() const; + AboutDialog(const StringView& name, const Gfx::Bitmap* icon = nullptr, Window* parent_window = nullptr, const StringView& version = Core::Version::SERENITY_VERSION); String m_name; RefPtr m_icon; + String m_version_string; }; }