Skip to content

Commit

Permalink
add reload buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Dec 6, 2024
1 parent 9b6dd02 commit 3dc1fb9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
30 changes: 30 additions & 0 deletions data/resources/ui/settings_view.ui
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,48 @@
<object class="AdwEntryRow" id="camera_ip_addr_row">
<property name="title">Camera IP Address</property>
<property name="show-apply-button">True</property>
<child type="suffix">
<object class="GtkButton">
<property name="action-name">settings-view.reload-camera</property>
<property name="icon-name">update-symbolic</property>
<property name="valign">center</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwEntryRow" id="aux_camera_ip_addrs_row">
<property name="title">Auxiliary Cameras IP Addresses</property>
<property name="show-apply-button">True</property>
<child type="suffix">
<object class="GtkButton">
<property name="action-name">settings-view.reload-aux-cameras</property>
<property name="icon-name">update-symbolic</property>
<property name="valign">center</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwEntryRow" id="rfid_reader_ip_addr_row">
<property name="title">RFID Reader IP Address</property>
<property name="show-apply-button">True</property>
<child type="suffix">
<object class="GtkButton">
<property name="action-name">settings-view.reload-rfid-reader</property>
<property name="icon-name">update-symbolic</property>
<property name="valign">center</property>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
<child>
Expand Down
19 changes: 19 additions & 0 deletions src/ui/settings_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ mod imp {
fn class_init(klass: &mut Self::Class) {
klass.bind_template();

klass.install_action("settings-view.reload-camera", None, move |_, _, _| {
let app = Application::get();
if let Err(err) = app.camera().restart() {
tracing::error!("Failed to restart camera: {:?}", err);
app.add_message_toast("Failed to restart camera");
}
});
klass.install_action("settings-view.reload-aux-cameras", None, move |_, _, _| {
let app = Application::get();
for camera in app.detector().aux_cameras() {
if let Err(err) = camera.restart() {
tracing::error!("Failed to restart aux camera: {:?}", err);
app.add_message_toast("Failed to restart aux camera");
}
}
});
klass.install_action("settings-view.reload-rfid-reader", None, move |_, _, _| {
Application::get().rfid_reader().reconnect();
});
klass.install_action(
"settings-view.reload-remote-status",
None,
Expand Down

0 comments on commit 3dc1fb9

Please sign in to comment.