diff --git a/Makefile.toml b/Makefile.toml index 749cd0992..5a65301c7 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -879,11 +879,13 @@ cd console_backend/tests && python ../../utils/bench_runner.py --frontend_mem -- ''' [tasks.newline-terminator] +env = { EXCLUSION_PATTERNS = [".png", "docs", "resources/images"] } private = true script_runner = "python" script_extension = "py" script = ''' import os +import re import sys import subprocess def raises_exc(func): @@ -900,6 +902,9 @@ try_open_text = lambda fn: lambda: (open(fn, "ta"), open(fn, "tr").read(4096)) valid_file = lambda fn: os.path.getsize(fn) > 0 and not raises_exc(try_open_text(fn)) no_trailing_lf = lambda fn: valid_file(fn) and not has_newline(fn) all_files = subprocess.check_output(["git", "ls-files"]).decode('utf8').splitlines() +exclusion_substrings = os.environ.get("EXCLUSION_PATTERNS") +exclusion_substrings = exclusion_substrings.split(";") +all_files = [x for x in all_files if not any([re.match(".*"+y, x) for y in exclusion_substrings])] no_newline = list(map(append_newline, filter(no_trailing_lf, all_files))) footer = "*********************************************\n" err = "ERROR: " if dry_run else "Fixing " diff --git a/console_backend/src/main_tab.rs b/console_backend/src/main_tab.rs index f3879e3cb..0f3b97249 100644 --- a/console_backend/src/main_tab.rs +++ b/console_backend/src/main_tab.rs @@ -4,7 +4,6 @@ use std::{ time::{Duration, Instant}, }; -use capnp::message::Builder; use chrono::Local; use log::error; use sbp::Sbp; @@ -15,7 +14,7 @@ use crate::constants::{ }; use crate::output::{CsvLogging, SbpLogger}; use crate::shared_state::{create_directory, SharedState}; -use crate::utils::{bytes_to_human_readable, refresh_loggingbar, serialize_capnproto_builder}; +use crate::utils::{refresh_loggingbar, refresh_loggingbar_recording}; use crate::{client_sender::BoxedClientSender, shared_state::ConnectionState}; use crate::{common_constants::SbpLogging, shared_state::SbpLoggingStatsState}; @@ -55,32 +54,6 @@ pub fn logging_stats_thread( }) } -pub fn refresh_loggingbar_recording( - client_sender: &BoxedClientSender, - size: u64, - duration: u64, - filename: Option, -) { - let mut builder = Builder::new_default(); - let msg = builder.init_root::(); - - let mut logging_bar_status = msg.init_logging_bar_recording_status(); - logging_bar_status.set_recording_duration_sec(duration); - logging_bar_status.set_recording_size(&bytes_to_human_readable(size as u128)); - if let Some(filename_) = filename { - logging_bar_status - .reborrow() - .get_recording_filename() - .set_filename(&filename_); - } else { - logging_bar_status - .reborrow() - .get_recording_filename() - .set_none(()); - } - client_sender.send_data(serialize_capnproto_builder(builder)); -} - pub struct MainTab { logging_directory: PathBuf, last_csv_logging: CsvLogging, diff --git a/console_backend/src/utils.rs b/console_backend/src/utils.rs index e8fec21cc..fafba0b71 100644 --- a/console_backend/src/utils.rs +++ b/console_backend/src/utils.rs @@ -178,6 +178,32 @@ pub fn refresh_loggingbar(client_sender: &BoxedClientSender, shared_state: &Shar client_sender.send_data(serialize_capnproto_builder(builder)); } +pub fn refresh_loggingbar_recording( + client_sender: &BoxedClientSender, + size: u64, + duration: u64, + filename: Option, +) { + let mut builder = Builder::new_default(); + let msg = builder.init_root::(); + + let mut logging_bar_status = msg.init_logging_bar_recording_status(); + logging_bar_status.set_recording_duration_sec(duration); + logging_bar_status.set_recording_size(size); + if let Some(filename_) = filename { + logging_bar_status + .reborrow() + .get_recording_filename() + .set_filename(&filename_); + } else { + logging_bar_status + .reborrow() + .get_recording_filename() + .set_none(()); + } + client_sender.send_data(serialize_capnproto_builder(builder)); +} + pub fn signal_key_label( key: (SignalCodes, i16), extra: Option<&HashMap>, diff --git a/resources/Constants/Constants.qml b/resources/Constants/Constants.qml index 348257dee..643b8d4dd 100644 --- a/resources/Constants/Constants.qml +++ b/resources/Constants/Constants.qml @@ -461,6 +461,7 @@ QtObject { readonly property int pauseButtonPadding: 0 readonly property string pauseButtonTooltip: "Pause Log Panel" readonly property string playButtonTooltip: "Resume Log Panel" + readonly property string clearButtonTooltip: "Clear Log Panel" readonly property int logLevelMenuHeight: 100 readonly property int dropdownButtonPadding: 0 readonly property int dropdownButtonWidth: 20 @@ -628,6 +629,7 @@ QtObject { readonly property string swiftLogoPath: "qrc:/images/icon.png" readonly property string swiftLogoWidePath: "qrc:/images/swiftLogoWide.svg" readonly property string folderPath: "qrc:/images/fontawesome/folder-regular.svg" + readonly property string xPath: "qrc:/images/iconic/x.svg" } insSettingsPopup: QtObject { diff --git a/resources/LogPanel.qml b/resources/LogPanel.qml index 0c065a6f5..591575cfb 100644 --- a/resources/LogPanel.qml +++ b/resources/LogPanel.qml @@ -1,4 +1,5 @@ -import "./Constants" +import "BaseComponents" +import "Constants" import Qt.labs.qmlmodels 1.0 import QtQuick 2.15 import QtQuick.Controls 2.15 @@ -48,13 +49,43 @@ Item { anchors.rightMargin: Constants.logPanel.pauseButtonRightMargin z: Constants.logPanel.zAboveTable - RoundButton { - id: baselinePauseButton + SwiftButton { + width: Constants.logPanel.pauseButtonWidth + height: Constants.logPanel.pauseButtonWidth + padding: Constants.logPanel.pauseButtonPadding + icon.width: Constants.logPanel.pauseButtonWidth / 3 + icon.height: Constants.logPanel.pauseButtonWidth / 3 + icon.source: Constants.icons.xPath + icon.color: Constants.materialGrey + anchors.right: parent.right + anchors.top: parent.top + ToolTip.visible: hovered + ToolTip.text: Constants.logPanel.clearButtonTooltip + onClicked: { + tableView.model.clear(); + var new_row = { + }; + new_row[Constants.logPanel.timestampHeader] = ""; + new_row[Constants.logPanel.levelHeader] = ""; + new_row[Constants.logPanel.msgHeader] = ""; + logEntries = [new_row]; + tableView.model.setRow(0, new_row); + tableView.forceLayout(); + } + } + } + + Item { + anchors.fill: parent + anchors.topMargin: Constants.genericTable.cellHeight * 2 + anchors.rightMargin: Constants.logPanel.pauseButtonRightMargin + z: Constants.logPanel.zAboveTable + + SwiftButton { visible: !consolePaused width: Constants.logPanel.pauseButtonWidth height: Constants.logPanel.pauseButtonWidth - radius: Constants.logPanel.pauseButtonWidth / 3 padding: Constants.logPanel.pauseButtonPadding icon.width: Constants.logPanel.pauseButtonWidth / 3 icon.height: Constants.logPanel.pauseButtonWidth / 3 @@ -69,13 +100,10 @@ Item { } } - RoundButton { - id: baselinePlayButton - + SwiftButton { visible: consolePaused width: Constants.logPanel.pauseButtonWidth height: Constants.logPanel.pauseButtonWidth - radius: Constants.logPanel.pauseButtonWidth / 3 padding: Constants.logPanel.pauseButtonPadding icon.width: Constants.logPanel.pauseButtonWidth / 3 icon.height: Constants.logPanel.pauseButtonWidth / 3 diff --git a/resources/LoggingBar.qml b/resources/LoggingBar.qml index 10fb2addf..1ba458f86 100644 --- a/resources/LoggingBar.qml +++ b/resources/LoggingBar.qml @@ -19,7 +19,7 @@ Rectangle { let hours = Math.floor(duration / 3600).toFixed(0).padStart(2, 0); let minutes = Math.floor(duration / 60).toFixed(0).padStart(2, 0); let seconds = (duration % 60).toFixed(0).padStart(2, 0); - return hours + ":" + minutes + ":" + seconds + " s"; + return hours + ":" + minutes + ":" + seconds; } color: Constants.swiftControlBackground @@ -275,8 +275,8 @@ Rectangle { mockRecordingSize += 15.15; recordingSize.text = bytesToString(mockRecordingSize); } else { - if (loggingBarData.recording_size.length > 0) - recordingSize.text = loggingBarData.recording_size; + if (loggingBarData.recording_size > 0) + recordingSize.text = bytesToString(loggingBarData.recording_size); else recordingSize.text = "0.00 MiB"; } diff --git a/resources/console_resources.qrc b/resources/console_resources.qrc index ddec744be..f44591293 100644 --- a/resources/console_resources.qrc +++ b/resources/console_resources.qrc @@ -103,6 +103,7 @@ images/fontawesome/file-import.svg images/fontawesome/exclamation-triangle.svg images/fontawesome/folder-regular.svg + images/iconic/x.svg images/icon.png images/icon.ico TableComponents/SortableColumnHeading.qml diff --git a/src/main/resources/base/console_backend.capnp b/src/main/resources/base/console_backend.capnp index 3c835d543..8013b34bd 100644 --- a/src/main/resources/base/console_backend.capnp +++ b/src/main/resources/base/console_backend.capnp @@ -330,7 +330,7 @@ struct LoggingBarStatus { } struct LoggingBarRecordingStatus { recordingDurationSec @0 : UInt64; - recordingSize @1 :Text; + recordingSize @1 :UInt64; recordingFilename :union { filename @2 :Text; none @3 :Void = void; diff --git a/swiftnav_console/logging_bar.py b/swiftnav_console/logging_bar.py index 8cf4eebd0..5256968ed 100644 --- a/swiftnav_console/logging_bar.py +++ b/swiftnav_console/logging_bar.py @@ -14,7 +14,7 @@ Keys.SBP_LOGGING_FORMAT: SbpLogging.SBP_JSON, Keys.SBP_LOGGING_LABELS: [SbpLogging.SBP_JSON, SbpLogging.SBP], Keys.RECORDING_DURATION_SEC: int, - Keys.RECORDING_SIZE: str, + Keys.RECORDING_SIZE: int, Keys.RECORDING_FILENAME: str, } @@ -27,7 +27,7 @@ class LoggingBarData(QObject): # pylint: disable=too-many-instance-attributes _sbp_logging_labels: List[str] = [] _previous_folders: List[str] = [] _recording_duration_sec: int = 0 - _recording_size: str + _recording_size: int = 0 _recording_filename: str = "" def get_csv_logging(self) -> bool: @@ -70,13 +70,13 @@ def set_previous_folders(self, previous_folders: List[str]) -> None: previous_folders = Property(QTKeys.QVARIANTLIST, get_previous_folders, set_previous_folders) # type: ignore - def get_recording_size(self) -> str: + def get_recording_size(self) -> int: return self._recording_size - def set_recording_size(self, recording_size: str) -> None: + def set_recording_size(self, recording_size: int) -> None: self._recording_size = recording_size - recording_size = Property(str, get_recording_size, set_recording_size) + recording_size = Property(int, get_recording_size, set_recording_size) def get_recording_duration_sec(self) -> int: return self._recording_duration_sec