1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00
serenity/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30

56 lines
1.4 KiB
C++

/*
* Copyright (c) 2022, Maciej <sppmacd@pm.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/SettingsWindow.h>
#include <AK/HashMap.h>
namespace NetworkSettings {
class NetworkSettingsWidget : public GUI::SettingsWindow::Tab {
C_OBJECT_ABSTRACT(NetworkSettingsWidget)
public:
static ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> create();
virtual void apply_settings() override;
void switch_adapter(ByteString const& adapter);
protected:
static ErrorOr<NonnullRefPtr<NetworkSettingsWidget>> try_create();
private:
NetworkSettingsWidget() = default;
ErrorOr<void> setup();
struct NetworkAdapterData {
bool enabled = false;
bool dhcp = false;
ByteString ip_address;
int cidr = 0;
ByteString default_gateway;
};
void on_switch_adapter(ByteString const& adapter);
void on_switch_enabled_or_dhcp();
ErrorOr<void> apply_settings_impl();
ErrorOr<Optional<JsonObject>> create_settings_object();
HashMap<ByteString, NetworkAdapterData> m_network_adapters;
Vector<ByteString> m_adapter_names;
NetworkAdapterData* m_current_adapter_data = nullptr;
RefPtr<GUI::CheckBox> m_enabled_checkbox;
RefPtr<GUI::CheckBox> m_dhcp_checkbox;
RefPtr<GUI::ComboBox> m_adapters_combobox;
RefPtr<GUI::TextBox> m_ip_address_textbox;
RefPtr<GUI::SpinBox> m_cidr_spinbox;
RefPtr<GUI::TextBox> m_default_gateway_textbox;
};
}