Refactoring Controls

pull/421/head
Holger Müller 2021-07-05 17:32:37 +02:00
rodzic 5e46722955
commit 371a1a16ed
4 zmienionych plików z 24 dodań i 93 usunięć

Wyświetl plik

@ -19,67 +19,15 @@
import logging
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QCheckBox
from NanoVNASaver.Marker import Marker
logger = logging.getLogger(__name__)
class MarkerControl(QtWidgets.QGroupBox):
updated = pyqtSignal(object)
class Control(QtWidgets.QGroupBox):
updated = QtCore.pyqtSignal(object)
def __init__(self, app: QtWidgets.QWidget, title: str = "Markers"):
def __init__(self, app: QtWidgets.QWidget, title: str = ""):
super().__init__()
self.app = app
self.setMaximumWidth(240)
self.setTitle(title)
self.layout = QtWidgets.QFormLayout(self)
marker_count = max(self.app.settings.value("MarkerCount", 3, int), 1)
for i in range(marker_count):
marker = Marker("", self.app.settings)
#marker.setFixedHeight(20)
marker.updated.connect(self.app.markerUpdated)
label, layout = marker.getRow()
self.layout.addRow(label, layout)
self.app.markers.append(marker)
if i == 0:
marker.isMouseControlledRadioButton.setChecked(True)
self.check_delta = QCheckBox("Enable Delta Marker")
self.check_delta.toggled.connect(self.toggle_delta)
self.layout.addRow(self.check_delta)
self.showMarkerButton = QtWidgets.QPushButton()
self.showMarkerButton.setFixedHeight(20)
if self.app.marker_frame.isHidden():
self.showMarkerButton.setText("Show data")
else:
self.showMarkerButton.setText("Hide data")
self.showMarkerButton.clicked.connect(self.toggle_frame)
lock_radiobutton = QtWidgets.QRadioButton("Locked")
lock_radiobutton.setLayoutDirection(QtCore.Qt.RightToLeft)
lock_radiobutton.setSizePolicy(
QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(self.showMarkerButton)
hbox.addWidget(lock_radiobutton)
self.layout.addRow(hbox)
def toggle_frame(self):
if self.app.marker_frame.isHidden():
self.app.marker_frame.setHidden(False)
self.app.settings.setValue("MarkersVisible", True)
self.showMarkerButton.setText("Hide data")
self.showMarkerButton.repaint()
else:
self.app.marker_frame.setHidden(True)
self.app.settings.setValue("MarkersVisible", False)
self.showMarkerButton.setText("Show data")
self.showMarkerButton.repaint()
def toggle_delta(self):
self.app.delta_marker_layout.setVisible(self.check_delta.isChecked())

Wyświetl plik

@ -19,22 +19,18 @@
import logging
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QCheckBox
from NanoVNASaver.Marker import Marker
from NanoVNASaver.Controls.Control import Control
logger = logging.getLogger(__name__)
class MarkerControl(QtWidgets.QGroupBox):
updated = pyqtSignal(object)
class MarkerControl(Control):
def __init__(self, app: QtWidgets.QWidget, title: str = "Markers"):
super().__init__()
self.app = app
self.setMaximumWidth(240)
self.setTitle(title)
self.layout = QtWidgets.QFormLayout(self)
def __init__(self, app: QtWidgets.QWidget):
super().__init__(app, "Markers")
marker_count = max(self.app.settings.value("MarkerCount", 3, int), 1)
for i in range(marker_count):
@ -70,16 +66,13 @@ class MarkerControl(QtWidgets.QGroupBox):
self.layout.addRow(hbox)
def toggle_frame(self):
if self.app.marker_frame.isHidden():
self.app.marker_frame.setHidden(False)
self.app.settings.setValue("MarkersVisible", True)
self.showMarkerButton.setText("Hide data")
self.showMarkerButton.repaint()
else:
self.app.marker_frame.setHidden(True)
self.app.settings.setValue("MarkersVisible", False)
self.showMarkerButton.setText("Show data")
def settings(hidden: bool):
self.app.marker_frame.setHidden(not hidden)
self.app.settings.setValue("MarkersVisible", hidden)
self.showMarkerButton.setText(
"Hide data" if hidden else "Show data")
self.showMarkerButton.repaint()
settings(self.app.marker_frame.isHidden())
def toggle_delta(self):
self.app.delta_marker_layout.setVisible(self.check_delta.isChecked())

Wyświetl plik

@ -19,23 +19,19 @@
import logging
from time import sleep
from PyQt5 import QtWidgets, QtCore
from PyQt5 import QtWidgets
from NanoVNASaver.Hardware.Hardware import Interface, get_interfaces, get_VNA
from NanoVNASaver.Controls.Control import Control
logger = logging.getLogger(__name__)
class SerialControl(QtWidgets.QGroupBox):
updated = QtCore.pyqtSignal(object)
class SerialControl(Control):
def __init__(self, app: QtWidgets.QWidget):
super().__init__(app, "Serial port control")
def __init__(self, app: QtWidgets.QWidget, title: str="Serial port control"):
super().__init__()
self.app = app
self.interface = Interface("serial", "none")
self.setTitle(title)
self.setMaximumWidth(240)
self.layout = QtWidgets.QFormLayout(self)
self.inp_port = QtWidgets.QComboBox()
self.inp_port.setMinimumHeight(20)
self.rescanSerialPort()

Wyświetl plik

@ -19,26 +19,20 @@
import logging
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import pyqtSignal
from NanoVNASaver.Formatting import (
format_frequency_sweep, format_frequency_short,
parse_frequency)
from NanoVNASaver.Inputs import FrequencyInputWidget
from NanoVNASaver.Controls.Control import Control
logger = logging.getLogger(__name__)
class SweepControl(QtWidgets.QGroupBox):
updated = pyqtSignal(object)
class SweepControl(Control):
def __init__(self, app: QtWidgets.QWidget, title: str = "Sweep control"):
super().__init__()
self.app = app
self.setMaximumWidth(240)
self.setTitle(title)
self.layout = QtWidgets.QFormLayout(self)
def __init__(self, app: QtWidgets.QWidget):
super().__init__(app, "Sweep control")
line = QtWidgets.QFrame()
line.setFrameShape(QtWidgets.QFrame.VLine)