Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions console_backend/src/common_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ pub enum Keys {
CONSOLE_VERSION,
#[strum(serialize = "CONNECTION_MESSAGE")]
CONNECTION_MESSAGE,
#[strum(serialize = "NOTIFICATION")]
NOTIFICATION,
}

#[derive(Clone, Debug, Display, EnumString, EnumVariantNames, Eq, Hash, PartialEq)]
Expand Down
13 changes: 12 additions & 1 deletion console_backend/src/settings_tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn tick(settings_tab: &SettingsTab, settings_state: SettingsTabState) {
}
if let Some(req) = settings_state.write {
if let Err(e) = settings_tab.write_setting(&req.group, &req.name, &req.value) {
error!("Issue writing setting, {}", e);
settings_tab.send_notification(format!("Issue writing setting {}, {}", &req.name, e));
};
}
if settings_state.reset {
Expand Down Expand Up @@ -316,6 +316,17 @@ impl SettingsTab {
Ok(())
}

fn send_notification(&self, message: String) {
error!("{}", message);
let mut builder = Builder::new_default();
let msg = builder.init_root::<crate::console_backend_capnp::message::Builder>();
let mut status = msg.init_settings_notification();
status.set_message(&message);

self.client_sender
.send_data(serialize_capnproto_builder(builder));
}

fn write_setting(&self, group: &str, name: &str, value: &str) -> Result<()> {
{
let settings = self.settings.lock();
Expand Down
12 changes: 12 additions & 0 deletions resources/SettingsTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ MainTab {
repeat: true
onTriggered: {
settings_tab_model.fill_data(settingsTabData);
if (settingsTabData.notification !== "") {
settingsNotification.text = settingsTabData.notification;
settingsNotification.visible = true;
}
if (settingsTabData.import_status !== "") {
if (settingsTabData.import_status === "success") {
importSuccess.visible = true;
Expand Down Expand Up @@ -129,6 +133,14 @@ MainTab {
id: insSettingsPopup
}

MessageDialog {
id: settingsNotification

title: "Settings Write Notification"
icon: StandardIcon.Warning
standardButtons: StandardButton.Close
}

MessageDialog {
id: importFailure

Expand Down
6 changes: 4 additions & 2 deletions resources/SettingsTabComponents/SettingsPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,10 @@ Rectangle {
textFieldTimer.startTimer(settingGroup, settingName, text);
}
onEditingFinished: {
textFieldTimer.stop();
data_model.settings_write_request(settingGroup, settingName, text);
if (textFieldTimer.running) {
textFieldTimer.stop();
data_model.settings_write_request(settingGroup, settingName, text);
}
}
validator: {
if (settingType === "integer")
Expand Down
39 changes: 39 additions & 0 deletions resources/SettingsTabComponents/SettingsTable.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,45 @@ Rectangle {
return (item[Constants.settingsTable.tableRightColumnHeader] == "");
}

onVisibleChanged: {
if (visible && selectedRowIdx == -1) {
selectedRowIdx = 1;
tableView.focus = true;
}
}
Keys.onUpPressed: {
let cellDecrease = 1;
let new_row = selectedRowIdx - 1;
if (new_row > -1 && isHeaderRow(new_row)) {
cellDecrease += 1;
new_row -= 1;
}
selectedRowIdx = (new_row <= -1) ? (tableView.rows - 1) : new_row;
if (selectedRowIdx == tableView.rows - 1) {
tableView.verticalScrollBar.position = 1 - tableView.verticalScrollBar.size;
} else {
let proposed_position = tableView.verticalScrollBar.position - cellDecrease / tableView.rows;
let min_position = 0;
tableView.verticalScrollBar.position = Math.max(proposed_position, min_position);
}
}
Keys.onDownPressed: {
let cellIncrease = 1;
let new_row = selectedRowIdx + 1;
if (new_row < tableView.rows && isHeaderRow(new_row)) {
cellIncrease += 1;
new_row += 1;
}
selectedRowIdx = (new_row >= (tableView.rows)) ? 1 : new_row;
if (selectedRowIdx == 1) {
tableView.verticalScrollBar.position = 0;
} else {
let proposed_position = tableView.verticalScrollBar.position + cellIncrease / tableView.rows;
let max_position = 1 - tableView.verticalScrollBar.size;
tableView.verticalScrollBar.position = Math.min(proposed_position, max_position);
}
}

SettingsTableEntries {
id: settingsTableEntries
}
Expand Down
5 changes: 5 additions & 0 deletions resources/TableComponents/SwiftTableView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import SwiftConsole 1.0
TableView {
id: tableView

property alias horizontalScrollBar: _horizontalScrollBar
property alias verticalScrollBar: _verticalScrollBar
property variant columnWidths: []
property int selectedRow: -1
property int _currentSelectedIndex: -1
Expand Down Expand Up @@ -38,9 +40,12 @@ TableView {
}

ScrollBar.horizontal: ScrollBar {
id: _horizontalScrollBar
}

ScrollBar.vertical: ScrollBar {
id: _verticalScrollBar

policy: ScrollBar.AlwaysOn
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/base/console_backend.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ struct SettingsResetRequest {
reset @0 :Void = void;
}

struct SettingsNotification {
message @0 :Text;
}

struct Point {
x @0 :Float64;
y @1 :Float64;
Expand Down Expand Up @@ -497,5 +501,6 @@ struct Message {
autoSurveyRequest @50 : AutoSurveyRequest;
loggingBarRecordingStatus @51 : LoggingBarRecordingStatus;
connectionNotification @52 : ConnectionNotification;
settingsNotification @53 : SettingsNotification;
}
}
1 change: 1 addition & 0 deletions swiftnav_console/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class Keys(str, Enum):
RECORDING_FILENAME = "RECORDING_FILENAME"
CONSOLE_VERSION = "CONSOLE_VERSION"
CONNECTION_MESSAGE = "CONNECTION_MESSAGE"
NOTIFICATION = "NOTIFICATION"


class ConnectionState(str, Enum):
Expand Down
2 changes: 2 additions & 0 deletions swiftnav_console/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ def receive_messages(app_, backend, messages):
SETTINGS_TABLE[Keys.ENTRIES][:] = settings_rows_to_json(m.settingsTableStatus.data)
elif m.which == Message.Union.SettingsImportResponse:
SETTINGS_TAB[Keys.IMPORT_STATUS] = m.settingsImportResponse.status
elif m.which == Message.Union.SettingsNotification:
SETTINGS_TAB[Keys.NOTIFICATION] = m.settingsNotification.message
elif m.which == Message.Union.InsSettingsChangeResponse:
SETTINGS_TAB[Keys.RECOMMENDED_INS_SETTINGS][:] = [
[entry.settingName, entry.currentValue, entry.recommendedValue]
Expand Down
12 changes: 12 additions & 0 deletions swiftnav_console/settings_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
Keys.IMPORT_STATUS: None,
Keys.RECOMMENDED_INS_SETTINGS: [],
Keys.NEW_INS_CONFIRMATON: False,
Keys.NOTIFICATION: "",
}


Expand All @@ -25,6 +26,7 @@ class SettingsTabData(QObject):
_import_status: str = ""
_recommended_ins_settings: List[List[Any]] = []
_new_ins_confirmation: bool = False
_notification: str = ""

def get_import_status(self) -> str:
return self._import_status
Expand Down Expand Up @@ -52,13 +54,23 @@ def get_new_ins_confirmation(self) -> bool:

new_ins_confirmation = Property(bool, get_new_ins_confirmation, set_new_ins_confirmation)

def get_notification(self) -> str:
return self._notification

def set_notification(self, notification: str) -> None:
self._notification = notification

notification = Property(str, get_notification, set_notification)


class SettingsTabModel(QObject): # pylint: disable=too-few-public-methods
@Slot(SettingsTabData) # type: ignore
def fill_data(self, cp: SettingsTabData) -> SettingsTabData: # pylint:disable=no-self-use
cp.set_import_status(SETTINGS_TAB[Keys.IMPORT_STATUS])
cp.set_recommended_ins_settings(SETTINGS_TAB[Keys.RECOMMENDED_INS_SETTINGS])
cp.set_new_ins_confirmation(SETTINGS_TAB[Keys.NEW_INS_CONFIRMATON])
cp.set_notification(SETTINGS_TAB[Keys.NOTIFICATION])
SETTINGS_TAB[Keys.NOTIFICATION] = ""
return cp

@Slot(SettingsTabData) # type: ignore
Expand Down