mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 10:36:24 +00:00
NetworkSettings: Port NetworkSettings to GML compilation
This commit is contained in:
parent
1e11116d65
commit
8118ea764f
|
@ -4,16 +4,13 @@ serenity_component(
|
|||
TARGETS NetworkSettings
|
||||
)
|
||||
|
||||
stringify_gml(NetworkSettings.gml NetworkSettingsGML.h network_settings_gml)
|
||||
compile_gml(NetworkSettings.gml NetworkSettingsGML.cpp)
|
||||
|
||||
set(SOURCES
|
||||
NetworkSettingsWidget.cpp
|
||||
NetworkSettingsGML.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set(GENERATED_SOURCES
|
||||
NetworkSettingsGML.h
|
||||
)
|
||||
|
||||
serenity_app(NetworkSettings ICON network)
|
||||
target_link_libraries(NetworkSettings PRIVATE LibCore LibGfx LibGUI LibMain)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@GUI::Frame {
|
||||
@NetworkSettings::NetworkSettingsWidget {
|
||||
fill_with_background_color: true
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [10]
|
||||
|
@ -24,7 +24,6 @@
|
|||
}
|
||||
|
||||
@GUI::ComboBox {
|
||||
model_only: true
|
||||
name: "adapters_combobox"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/IPv4Address.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonParser.h>
|
||||
#include <Applications/NetworkSettings/NetworkSettingsGML.h>
|
||||
#include <LibCore/Command.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
|
@ -30,17 +29,15 @@ static int netmask_to_cidr(IPv4Address const& address)
|
|||
return 32 - count_trailing_zeroes_safe(address_in_host_representation);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> NetworkSettingsWidget::try_create()
|
||||
ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> NetworkSettingsWidget::create()
|
||||
{
|
||||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) NetworkSettingsWidget()));
|
||||
auto widget = TRY(try_create());
|
||||
TRY(widget->setup());
|
||||
return widget;
|
||||
}
|
||||
|
||||
ErrorOr<void> NetworkSettingsWidget::setup()
|
||||
{
|
||||
TRY(load_from_gml(network_settings_gml));
|
||||
|
||||
m_adapters_combobox = *find_descendant_of_type_named<GUI::ComboBox>("adapters_combobox");
|
||||
m_enabled_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("enabled_checkbox");
|
||||
m_enabled_checkbox->on_checked = [&](bool value) {
|
||||
|
|
|
@ -16,11 +16,14 @@ class NetworkSettingsWidget : public GUI::SettingsWindow::Tab {
|
|||
C_OBJECT_ABSTRACT(NetworkSettingsWidget)
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> try_create();
|
||||
static ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> create();
|
||||
|
||||
virtual void apply_settings() override;
|
||||
void switch_adapter(DeprecatedString const& adapter);
|
||||
|
||||
protected:
|
||||
static ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> try_create();
|
||||
|
||||
private:
|
||||
NetworkSettingsWidget() = default;
|
||||
ErrorOr<void> setup();
|
||||
|
|
|
@ -36,7 +36,9 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
|
||||
auto app_icon = GUI::Icon::default_icon("network"sv);
|
||||
auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No));
|
||||
auto network_settings_widget = TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"_string, "network"sv));
|
||||
|
||||
auto network_settings_widget = TRY(NetworkSettings::NetworkSettingsWidget::create());
|
||||
TRY(window->add_tab(network_settings_widget, "Network"_string, "network"sv));
|
||||
if (!adapter.is_null()) {
|
||||
network_settings_widget->switch_adapter(adapter);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue