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