diff options
Diffstat (limited to 'src/monitor-gui.cc')
| -rw-r--r-- | src/monitor-gui.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/monitor-gui.cc b/src/monitor-gui.cc index dacc318..fbbcfb9 100644 --- a/src/monitor-gui.cc +++ b/src/monitor-gui.cc @@ -7,6 +7,7 @@ #include <unordered_map> #include <vector> +#include "config.hh" #include "gui_about.hh" #include "gui_formapply.hh" #include "gui_hexdump.hh" @@ -242,23 +243,26 @@ private: class ConnectFormDelegate : public GuiFormApply::Delegate { public: - ConnectFormDelegate(Monitor* monitor) - : monitor_(monitor) { + ConnectFormDelegate(Monitor* monitor, Config* config) + : monitor_(monitor), config_(config) { } void apply(GuiFormApply* form) override { std::string host; uint16_t port; - if (!parse_address(form->get_string("address"), &host, &port)) { + auto const& addr = form->get_string("address"); + if (!parse_address(addr, &host, &port)) { form->set_error("Invalid address, expects HOST[:PORT]"); form->applied(false); return; } + config_->set("connect", addr); monitor_->connect(host, port); } private: Monitor* monitor_; + Config* config_; }; public: @@ -317,7 +321,7 @@ public: } else if (id == ACTION_CONNECT) { setup_monitor(); auto dlg = std::unique_ptr<GuiFormApply::Delegate>( - new ConnectFormDelegate(monitor_.get())); + new ConnectFormDelegate(monitor_.get(), main_->config())); auto lst = std::unique_ptr<GuiFormApply::Listener>( new ConnectFormListener()); connect_.reset( @@ -325,7 +329,8 @@ public: "Enter address for monitor to connect to", "Connect", dlg.get())); - connect_->add_string("address", "Address", ""); + connect_->add_string("address", "Address", + main_->config()->get("connect", "")); connect_->add_listener(lst.get()); if (connect_->show(main_.get())) { monitor_->attach(); |
