Skip to content

Commit 307d601

Browse files
Add popup on setting write failure[CPP-478]
1 parent 7cfcee6 commit 307d601

File tree

7 files changed

+46
-1
lines changed

7 files changed

+46
-1
lines changed

console_backend/src/common_constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ pub enum Keys {
289289
CONSOLE_VERSION,
290290
#[strum(serialize = "CONNECTION_MESSAGE")]
291291
CONNECTION_MESSAGE,
292+
#[strum(serialize = "NOTIFICATION")]
293+
NOTIFICATION,
292294
}
293295

294296
#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]

console_backend/src/settings_tab.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn tick(settings_tab: &SettingsTab, settings_state: SettingsTabState) {
6363
}
6464
if let Some(req) = settings_state.write {
6565
if let Err(e) = settings_tab.write_setting(&req.group, &req.name, &req.value) {
66-
error!("Issue writing setting, {}", e);
66+
settings_tab.send_notification(format!("Issue writing setting, {}", e));
6767
};
6868
}
6969
if settings_state.reset {
@@ -316,6 +316,17 @@ impl SettingsTab {
316316
Ok(())
317317
}
318318

319+
fn send_notification(&self, message: String) {
320+
error!("{}", message);
321+
let mut builder = Builder::new_default();
322+
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();
323+
let mut status = msg.init_settings_notification();
324+
status.set_message(&message);
325+
326+
self.client_sender
327+
.send_data(serialize_capnproto_builder(builder));
328+
}
329+
319330
fn write_setting(&self, group: &str, name: &str, value: &str) -> Result<()> {
320331
{
321332
let settings = self.settings.lock();

resources/SettingsTab.qml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ MainTab {
4949
repeat: true
5050
onTriggered: {
5151
settings_tab_model.fill_data(settingsTabData);
52+
if (settingsTabData.notification !== "") {
53+
settingsNotification.text = settingsTabData.notification;
54+
settingsNotification.visible = true;
55+
}
5256
if (settingsTabData.import_status !== "") {
5357
if (settingsTabData.import_status === "success") {
5458
importSuccess.visible = true;
@@ -129,6 +133,14 @@ MainTab {
129133
id: insSettingsPopup
130134
}
131135

136+
MessageDialog {
137+
id: settingsNotification
138+
139+
title: "Settings Write Notification"
140+
icon: StandardIcon.Warning
141+
standardButtons: StandardButton.Close
142+
}
143+
132144
MessageDialog {
133145
id: importFailure
134146

src/main/resources/base/console_backend.capnp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ struct SettingsResetRequest {
142142
reset @0 :Void = void;
143143
}
144144

145+
struct SettingsNotification {
146+
message @0 :Text;
147+
}
148+
145149
struct Point {
146150
x @0 :Float64;
147151
y @1 :Float64;
@@ -497,5 +501,6 @@ struct Message {
497501
autoSurveyRequest @50 : AutoSurveyRequest;
498502
loggingBarRecordingStatus @51 : LoggingBarRecordingStatus;
499503
connectionNotification @52 : ConnectionNotification;
504+
settingsNotification @53 : SettingsNotification;
500505
}
501506
}

swiftnav_console/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class Keys(str, Enum):
137137
RECORDING_FILENAME = "RECORDING_FILENAME"
138138
CONSOLE_VERSION = "CONSOLE_VERSION"
139139
CONNECTION_MESSAGE = "CONNECTION_MESSAGE"
140+
NOTIFICATION = "NOTIFICATION"
140141

141142

142143
class ConnectionState(str, Enum):

swiftnav_console/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ def receive_messages(app_, backend, messages):
421421
SETTINGS_TABLE[Keys.ENTRIES][:] = settings_rows_to_json(m.settingsTableStatus.data)
422422
elif m.which == Message.Union.SettingsImportResponse:
423423
SETTINGS_TAB[Keys.IMPORT_STATUS] = m.settingsImportResponse.status
424+
elif m.which == Message.Union.SettingsNotification:
425+
SETTINGS_TAB[Keys.NOTIFICATION] = m.settingsNotification.message
424426
elif m.which == Message.Union.InsSettingsChangeResponse:
425427
SETTINGS_TAB[Keys.RECOMMENDED_INS_SETTINGS][:] = [
426428
[entry.settingName, entry.currentValue, entry.recommendedValue]

swiftnav_console/settings_tab.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Keys.IMPORT_STATUS: None,
1313
Keys.RECOMMENDED_INS_SETTINGS: [],
1414
Keys.NEW_INS_CONFIRMATON: False,
15+
Keys.NOTIFICATION: "",
1516
}
1617

1718

@@ -25,6 +26,7 @@ class SettingsTabData(QObject):
2526
_import_status: str = ""
2627
_recommended_ins_settings: List[List[Any]] = []
2728
_new_ins_confirmation: bool = False
29+
_notification: str = ""
2830

2931
def get_import_status(self) -> str:
3032
return self._import_status
@@ -52,13 +54,23 @@ def get_new_ins_confirmation(self) -> bool:
5254

5355
new_ins_confirmation = Property(bool, get_new_ins_confirmation, set_new_ins_confirmation)
5456

57+
def get_notification(self) -> str:
58+
return self._notification
59+
60+
def set_notification(self, notification: str) -> None:
61+
self._notification = notification
62+
63+
notification = Property(str, get_notification, set_notification)
64+
5565

5666
class SettingsTabModel(QObject): # pylint: disable=too-few-public-methods
5767
@Slot(SettingsTabData) # type: ignore
5868
def fill_data(self, cp: SettingsTabData) -> SettingsTabData: # pylint:disable=no-self-use
5969
cp.set_import_status(SETTINGS_TAB[Keys.IMPORT_STATUS])
6070
cp.set_recommended_ins_settings(SETTINGS_TAB[Keys.RECOMMENDED_INS_SETTINGS])
6171
cp.set_new_ins_confirmation(SETTINGS_TAB[Keys.NEW_INS_CONFIRMATON])
72+
cp.set_notification(SETTINGS_TAB[Keys.NOTIFICATION])
73+
SETTINGS_TAB[Keys.NOTIFICATION] = ""
6274
return cp
6375

6476
@Slot(SettingsTabData) # type: ignore

0 commit comments

Comments
 (0)