2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/AboutDialog.h>
|
|
|
|
#include <LibGUI/BoxLayout.h>
|
|
|
|
#include <LibGUI/Button.h>
|
|
|
|
#include <LibGUI/Label.h>
|
|
|
|
#include <LibGUI/Widget.h>
|
2020-02-14 23:53:11 +01:00
|
|
|
#include <LibGfx/Font.h>
|
2019-09-02 19:45:55 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
|
|
|
|
2020-02-06 11:56:38 +01:00
|
|
|
AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::Object* parent)
|
2020-02-02 15:07:41 +01:00
|
|
|
: Dialog(parent)
|
2019-09-02 19:45:55 +02:00
|
|
|
, m_name(name)
|
|
|
|
, m_icon(icon)
|
|
|
|
{
|
|
|
|
resize(230, 120);
|
|
|
|
set_title(String::format("About %s", m_name.characters()));
|
|
|
|
set_resizable(false);
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
auto widget = Widget::construct();
|
2019-09-02 19:45:55 +02:00
|
|
|
set_main_widget(widget);
|
|
|
|
widget->set_fill_with_background_color(true);
|
2020-02-06 14:44:13 +01:00
|
|
|
widget->set_layout(make<HorizontalBoxLayout>());
|
2019-09-02 19:45:55 +02:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
auto left_container = Widget::construct(widget.ptr());
|
2019-09-02 19:45:55 +02:00
|
|
|
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
|
|
|
left_container->set_preferred_size(48, 0);
|
2020-02-06 14:44:13 +01:00
|
|
|
left_container->set_layout(make<VerticalBoxLayout>());
|
2020-02-02 15:07:41 +01:00
|
|
|
auto icon_label = Label::construct(left_container);
|
2019-09-02 19:45:55 +02:00
|
|
|
icon_label->set_icon(m_icon);
|
|
|
|
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
|
|
|
icon_label->set_preferred_size(40, 40);
|
|
|
|
left_container->layout()->add_spacer();
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
auto right_container = Widget::construct(widget.ptr());
|
2020-02-06 14:44:13 +01:00
|
|
|
right_container->set_layout(make<VerticalBoxLayout>());
|
2019-09-02 19:45:55 +02:00
|
|
|
right_container->layout()->set_margins({ 0, 4, 4, 4 });
|
|
|
|
|
|
|
|
auto make_label = [&](const StringView& text, bool bold = false) {
|
2020-02-02 15:07:41 +01:00
|
|
|
auto label = Label::construct(text, right_container);
|
2020-02-06 11:56:38 +01:00
|
|
|
label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
2019-09-02 19:45:55 +02:00
|
|
|
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
|
label->set_preferred_size(0, 14);
|
|
|
|
if (bold)
|
2020-02-06 11:56:38 +01:00
|
|
|
label->set_font(Gfx::Font::default_bold_font());
|
2019-09-02 19:45:55 +02:00
|
|
|
};
|
|
|
|
make_label(m_name, true);
|
2020-01-02 02:55:10 +01:00
|
|
|
make_label("SerenityOS");
|
|
|
|
make_label("(C) The SerenityOS developers");
|
2019-09-02 19:45:55 +02:00
|
|
|
|
|
|
|
right_container->layout()->add_spacer();
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
auto button_container = Widget::construct(right_container.ptr());
|
2019-09-02 19:45:55 +02:00
|
|
|
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
|
|
|
button_container->set_preferred_size(0, 20);
|
2020-02-06 14:44:13 +01:00
|
|
|
button_container->set_layout(make<HorizontalBoxLayout>());
|
2019-09-02 19:45:55 +02:00
|
|
|
button_container->layout()->add_spacer();
|
2020-02-02 15:07:41 +01:00
|
|
|
auto ok_button = Button::construct("OK", button_container);
|
2019-09-02 19:45:55 +02:00
|
|
|
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
|
|
|
ok_button->set_preferred_size(80, 20);
|
|
|
|
ok_button->on_click = [this](auto&) {
|
2020-02-02 15:07:41 +01:00
|
|
|
done(Dialog::ExecOK);
|
2019-09-02 19:45:55 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
AboutDialog::~AboutDialog()
|
2019-09-02 19:45:55 +02:00
|
|
|
{
|
|
|
|
}
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
}
|