Skip to content

Commit

Permalink
GUI2/Addon License Prompt: simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Feb 20, 2021
1 parent 243bc6d commit 2066750
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 34 deletions.
38 changes: 13 additions & 25 deletions src/gui/dialogs/addon/license_prompt.cpp
@@ -1,42 +1,30 @@
/*
Copyright (C) 2020 by Iris Morelle <shadowm@wesnoth.org>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
Copyright (C) 2020 by Iris Morelle <shadowm@wesnoth.org>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
This program 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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
This program 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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
See the COPYING file for more details.
*/

#define GETTEXT_DOMAIN "wesnoth-lib"

#include "gui/dialogs/addon/license_prompt.hpp"

#include "gettext.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/widgets/button.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"

namespace gui2 {
namespace dialogs {

namespace gui2::dialogs
{
REGISTER_DIALOG(addon_license_prompt)

addon_license_prompt::addon_license_prompt(const std::string& license_terms)
: license_terms_(license_terms)
{
}

void addon_license_prompt::pre_show(window& window)
{
styled_widget& terms = find_widget<styled_widget>(&window, "terms", false);
terms.set_use_markup(true);
terms.set_label(license_terms_);
register_label("terms", true, license_terms, true);
}

}} // end namespace gui2::dialogs
} // end namespace gui2::dialogs
12 changes: 3 additions & 9 deletions src/gui/dialogs/addon/license_prompt.hpp
Expand Up @@ -16,9 +16,8 @@

#include "gui/dialogs/modal_dialog.hpp"

namespace gui2 {
namespace dialogs {

namespace gui2::dialogs
{
class addon_license_prompt : public modal_dialog
{
public:
Expand All @@ -35,11 +34,6 @@ class addon_license_prompt : public modal_dialog
private:
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;

/** Inherited from modal_dialog. */
virtual void pre_show(window& window) override;

std::string license_terms_;
};

}} // end namespace gui2::dialogs
} // end namespace gui2::dialogs

0 comments on commit 2066750

Please sign in to comment.