소스 검색

AboutDialog: Accept a version string

This allows applications to specify a version string to appear in the
`AboutDialog`.
Mahmoud Mandour 3 년 전
부모
커밋
eb6f9d469a
2개의 변경된 파일8개의 추가작업 그리고 12개의 파일을 삭제
  1. 3 8
      Userland/Libraries/LibGUI/AboutDialog.cpp
  2. 5 4
      Userland/Libraries/LibGUI/AboutDialog.h

+ 3 - 8
Userland/Libraries/LibGUI/AboutDialog.cpp

@@ -5,7 +5,6 @@
  */
 
 #include <AK/StringBuilder.h>
-#include <LibCore/Version.h>
 #include <LibGUI/AboutDialog.h>
 #include <LibGUI/BoxLayout.h>
 #include <LibGUI/Button.h>
@@ -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;
-}
-
 }

+ 5 - 4
Userland/Libraries/LibGUI/AboutDialog.h

@@ -6,6 +6,7 @@
 
 #pragma once
 
+#include <LibCore/Version.h>
 #include <LibGUI/Dialog.h>
 
 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<Gfx::Bitmap> m_icon;
+    String m_version_string;
 };
 }