2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2023-02-02 17:09:27 +00:00
|
|
|
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-05-24 14:26:33 +00:00
|
|
|
#include <AK/StringBuilder.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/AboutDialog.h>
|
2023-02-02 17:09:27 +00:00
|
|
|
#include <LibGUI/AboutDialogGML.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
|
#include <LibGUI/Button.h>
|
2020-07-22 15:29:51 +02:00
|
|
|
#include <LibGUI/ImageWidget.h>
|
2020-09-18 09:49:51 +02:00
|
|
|
#include <LibGUI/Label.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Widget.h>
|
2022-04-09 09:28:38 +02:00
|
|
|
#include <LibGfx/Font/Font.h>
|
|
|
|
|
#include <LibGfx/Font/FontDatabase.h>
|
2019-09-02 19:45:55 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
|
2022-08-30 12:49:08 +02:00
|
|
|
AboutDialog::AboutDialog(StringView name, StringView version, Gfx::Bitmap const* icon, Window* parent_window)
|
2020-03-04 20:53:51 +01:00
|
|
|
: Dialog(parent_window)
|
2019-09-02 19:45:55 +02:00
|
|
|
, m_name(name)
|
|
|
|
|
, m_icon(icon)
|
2021-08-29 12:00:50 +02:00
|
|
|
, m_version_string(version)
|
2019-09-02 19:45:55 +02:00
|
|
|
{
|
2021-07-27 20:13:13 +02:00
|
|
|
resize(413, 204);
|
2022-12-04 18:02:33 +00:00
|
|
|
set_title(DeprecatedString::formatted("About {}", m_name));
|
2019-09-02 19:45:55 +02:00
|
|
|
set_resizable(false);
|
|
|
|
|
|
2020-03-30 09:01:02 +02:00
|
|
|
if (parent_window)
|
|
|
|
|
set_icon(parent_window->icon());
|
|
|
|
|
|
2023-01-06 16:48:37 +00:00
|
|
|
auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
|
2023-02-02 17:09:27 +00:00
|
|
|
widget->load_from_gml(about_dialog_gml).release_value_but_fixme_should_propagate_errors();
|
2020-05-24 14:26:33 +00:00
|
|
|
|
2023-02-02 17:09:27 +00:00
|
|
|
auto icon_wrapper = find_descendant_of_type_named<Widget>("icon_wrapper");
|
2020-05-24 14:26:33 +00:00
|
|
|
if (icon) {
|
2023-02-02 17:09:27 +00:00
|
|
|
icon_wrapper->set_visible(true);
|
|
|
|
|
auto icon_image = find_descendant_of_type_named<ImageWidget>("icon");
|
|
|
|
|
icon_image->set_bitmap(m_icon);
|
|
|
|
|
} else {
|
|
|
|
|
icon_wrapper->set_visible(false);
|
2020-05-24 14:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-02 17:09:27 +00:00
|
|
|
find_descendant_of_type_named<GUI::Label>("name")->set_text(m_name);
|
2020-05-24 14:26:33 +00:00
|
|
|
// If we are displaying a dialog for an application, insert 'SerenityOS' below the application name
|
2023-02-02 17:09:27 +00:00
|
|
|
find_descendant_of_type_named<GUI::Label>("serenity_os")->set_visible(m_name != "SerenityOS");
|
|
|
|
|
find_descendant_of_type_named<GUI::Label>("version")->set_text(m_version_string);
|
2019-09-02 19:45:55 +02:00
|
|
|
|
2023-02-02 17:09:27 +00:00
|
|
|
auto ok_button = find_descendant_of_type_named<DialogButton>("ok_button");
|
|
|
|
|
ok_button->on_click = [this](auto) {
|
2022-05-13 13:10:27 +01:00
|
|
|
done(ExecResult::OK);
|
2019-09-02 19:45:55 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
}
|