From cded63cd57e91c6c023c1286aeb08306d805efcc Mon Sep 17 00:00:00 2001 From: Johannes Pohl Date: Sun, 5 Feb 2017 16:16:37 +0100 Subject: [PATCH] add default value to read settings for backward compatibility --- src/urh/controller/SignalTabController.py | 10 +++++----- src/urh/signalprocessing/Message.py | 5 ++--- src/urh/ui/views/SelectableGraphicView.py | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/urh/controller/SignalTabController.py b/src/urh/controller/SignalTabController.py index 80562688..2b9fa21b 100644 --- a/src/urh/controller/SignalTabController.py +++ b/src/urh/controller/SignalTabController.py @@ -104,11 +104,11 @@ class SignalTabController(QWidget): @pyqtSlot(bool) def set_shift_statuslabel(self, shift_pressed): - if shift_pressed and constants.SETTINGS.value('hold_shift_to_drag', type=bool): + if shift_pressed and constants.SETTINGS.value('hold_shift_to_drag', False, type=bool): self.ui.lShiftStatus.setText("[SHIFT] Use Mouse to scroll signal.") self.ui.lCtrlStatus.clear() - elif shift_pressed and not constants.SETTINGS.value('hold_shift_to_drag', type=bool): + elif shift_pressed and not constants.SETTINGS.value('hold_shift_to_drag', False, type=bool): self.ui.lShiftStatus.setText("[SHIFT] Use mouse to create a selection.") self.ui.lCtrlStatus.clear() else: @@ -135,7 +135,7 @@ class SignalTabController(QWidget): # Neues Signal aus "Create Signal from Selection" sig_frame.ui.btnSaveSignal.show() - sig_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', type=bool) + sig_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', False, type=bool) sig_frame.closed.connect(self.close_frame) sig_frame.signal_created.connect(self.signal_created.emit) sig_frame.drag_started.connect(self.frame_dragged) @@ -182,7 +182,7 @@ class SignalTabController(QWidget): sig_frame.files_dropped.connect(self.handle_files_dropped) sig_frame.setMinimumHeight(sig_frame.height()) sig_frame.closed.connect(self.close_frame) - sig_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', type=bool) + sig_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', False, type=bool) sig_frame.set_empty_frame_visibilities() @@ -282,4 +282,4 @@ class SignalTabController(QWidget): def refresh_participant_information(self): for sframe in self.signal_frames: - sframe.on_participant_changed() \ No newline at end of file + sframe.on_participant_changed() diff --git a/src/urh/signalprocessing/Message.py b/src/urh/signalprocessing/Message.py index f688064a..c32b812e 100644 --- a/src/urh/signalprocessing/Message.py +++ b/src/urh/signalprocessing/Message.py @@ -320,7 +320,7 @@ class Message(object): @property def decoded_bits_buffer(self) -> bytes: - bits = [b if isinstance(b, bool) else True if b.pulsetype == 1 else False for b in self.decoded_bits] + bits = [int(b) if isinstance(b, bool) else 1 if b.pulsetype == 1 else 0 for b in self.decoded_bits] return np.packbits(bits).tobytes() @property @@ -328,7 +328,6 @@ class Message(object): padded_bitchains = self.split(decode=False) return self.__bitchains_to_hex(padded_bitchains) - @property def plain_ascii_str(self) -> str: padded_bitchains = self.split(decode=False) @@ -578,4 +577,4 @@ class Message(object): def get_label_range(self, lbl: ProtocolLabel, view: int, decode: bool): start = self.convert_index(index=lbl.start, from_view=0, to_view=view, decoded=decode)[0] end = self.convert_index(index=lbl.end, from_view=0, to_view=view, decoded=decode)[1] - return int(start), int(end) \ No newline at end of file + return int(start), int(end) diff --git a/src/urh/ui/views/SelectableGraphicView.py b/src/urh/ui/views/SelectableGraphicView.py index ed204880..f31bf676 100644 --- a/src/urh/ui/views/SelectableGraphicView.py +++ b/src/urh/ui/views/SelectableGraphicView.py @@ -49,7 +49,7 @@ class SelectableGraphicView(QGraphicsView): @property def hold_shift_to_drag(self) -> bool: - return constants.SETTINGS.value('hold_shift_to_drag', type=bool) + return constants.SETTINGS.value('hold_shift_to_drag', False, type=bool) def is_pos_in_separea(self, pos: QPoint): """ @@ -253,4 +253,4 @@ class SelectableGraphicView(QGraphicsView): """ topLeft = self.mapToScene(0, 0) bottomRight = self.mapToScene(self.viewport().width() - 1, self.viewport().height() - 1 ) - return QRectF(topLeft, bottomRight) \ No newline at end of file + return QRectF(topLeft, bottomRight)