summaryrefslogtreecommitdiff
path: root/src/monitor-gui.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2017-07-22 23:18:26 +0200
committerJoel Klinghed <the_jk@yahoo.com>2017-07-22 23:19:37 +0200
commita3da855cddff3c3c71311af6ce3e7629a459024d (patch)
tree7ed8cad6256f74fb83632f608891ceeb32e1f59a /src/monitor-gui.cc
parentd9e1e04c09a99b2a507e071f434fd394f4781051 (diff)
Add application config for GUI
QT5 stored in .config/org.the_jk/tp.Monitor.conf on Linux GTK stored in dconf
Diffstat (limited to 'src/monitor-gui.cc')
-rw-r--r--src/monitor-gui.cc15
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();