kopia lustrzana https://github.com/NanoVNA-Saver/nanovna-saver
Added Dark Mode Gui and Color Mode for value fields
rodzic
47b0bd3649
commit
fbb89db6e4
|
@ -40,6 +40,7 @@ class Marker(QtCore.QObject):
|
|||
if frequency.isnumeric():
|
||||
self.frequency = int(frequency)
|
||||
self.frequencyInput = QtWidgets.QLineEdit(frequency)
|
||||
self.frequencyInput.setProperty("cssClass", "marker_label")
|
||||
self.frequencyInput.setAlignment(QtCore.Qt.AlignRight)
|
||||
self.frequencyInput.textEdited.connect(lambda: self.setFrequency(self.frequencyInput.text()))
|
||||
|
||||
|
@ -49,19 +50,31 @@ class Marker(QtCore.QObject):
|
|||
|
||||
self.frequency_label = QtWidgets.QLabel("")
|
||||
self.frequency_label.setMinimumWidth(100)
|
||||
self.frequency_label.setProperty("cssClass", "frequency_label")
|
||||
self.impedance_label = QtWidgets.QLabel("")
|
||||
self.impedance_label.setProperty("cssClass", "impedance_label")
|
||||
# self.admittance_label = QtWidgets.QLabel("")
|
||||
self.parallel_r_label = QtWidgets.QLabel("")
|
||||
self.parallel_r_label.setProperty("cssClass", "parallel_r_label")
|
||||
self.parallel_x_label = QtWidgets.QLabel("")
|
||||
self.parallel_x_label.setProperty("cssClass", "parallel_x_label")
|
||||
self.returnloss_label = QtWidgets.QLabel("")
|
||||
self.returnloss_label.setProperty("cssClass", "returnloss_label")
|
||||
self.returnloss_label.setMinimumWidth(80)
|
||||
self.vswr_label = QtWidgets.QLabel("")
|
||||
self.vswr_label.setProperty("cssClass", "vswr_label")
|
||||
self.inductance_label = QtWidgets.QLabel("")
|
||||
self.inductance_label.setProperty("cssClass", "inductance_label")
|
||||
self.capacitance_label = QtWidgets.QLabel("")
|
||||
self.capacitance_label.setProperty("cssClass", "capacitance_label")
|
||||
self.gain_label = QtWidgets.QLabel("")
|
||||
self.gain_label.setProperty("cssClass", "gain_label")
|
||||
self.s11_phase_label = QtWidgets.QLabel("")
|
||||
self.s11_phase_label.setProperty("cssClass", "s11_phase_label")
|
||||
self.s21_phase_label = QtWidgets.QLabel("")
|
||||
self.s21_phase_label.setProperty("cssClass", "s21_phase_label")
|
||||
self.quality_factor_label = QtWidgets.QLabel("")
|
||||
self.quality_factor_label.setProperty("cssClass", "quality_factor_label")
|
||||
|
||||
################################################################################################################
|
||||
# Marker control layout
|
||||
|
@ -83,6 +96,7 @@ class Marker(QtCore.QObject):
|
|||
################################################################################################################
|
||||
|
||||
self.group_box = QtWidgets.QGroupBox(self.name)
|
||||
self.group_box.setProperty("cssClass", self.name.replace(" ", "-"))
|
||||
box_layout = QtWidgets.QHBoxLayout(self.group_box)
|
||||
|
||||
line = QtWidgets.QFrame()
|
||||
|
|
|
@ -36,6 +36,20 @@ from .SweepWorker import SweepWorker
|
|||
from .Touchstone import Touchstone
|
||||
from .Analysis import Analysis, LowPassAnalysis, HighPassAnalysis, BandPassAnalysis
|
||||
from .about import version as ver
|
||||
from PyQt5.QtWidgets import QApplication, QPushButton, QDesktopWidget
|
||||
|
||||
##*****************************************************
|
||||
#
|
||||
# Modif Carl
|
||||
#
|
||||
##*****************************************************
|
||||
import os
|
||||
import qtmodern.styles
|
||||
import qtmodern.windows
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
##*****************************************************
|
||||
##*****************************************************
|
||||
|
||||
|
||||
Datapoint = collections.namedtuple('Datapoint', 'freq re im')
|
||||
|
||||
|
@ -89,6 +103,8 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
logger.debug("Building user interface")
|
||||
|
||||
self.baseTitle = "NanoVNA Saver " + NanoVNASaver.version
|
||||
|
||||
self.setProperty("cssClass", "mainWindow")
|
||||
self.updateTitle()
|
||||
layout = QtWidgets.QGridLayout()
|
||||
scrollarea = QtWidgets.QScrollArea()
|
||||
|
@ -247,6 +263,9 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
marker1.updated.connect(self.dataUpdated)
|
||||
label, layout = marker1.getRow()
|
||||
marker_control_layout.addRow(label, layout)
|
||||
|
||||
|
||||
|
||||
self.markers.append(marker1)
|
||||
marker1.isMouseControlledRadioButton.setChecked(True)
|
||||
|
||||
|
@ -262,7 +281,6 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
marker3.updated.connect(self.dataUpdated)
|
||||
label, layout = marker3.getRow()
|
||||
marker_control_layout.addRow(label, layout)
|
||||
|
||||
self.markers.append(marker3)
|
||||
|
||||
self.showMarkerButton = QtWidgets.QPushButton()
|
||||
|
@ -290,10 +308,12 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
s11_control_box.setTitle("S11")
|
||||
s11_control_layout = QtWidgets.QFormLayout()
|
||||
s11_control_box.setLayout(s11_control_layout)
|
||||
|
||||
s11_control_box.setProperty("cssClass", "s11_control_box")
|
||||
self.s11_min_swr_label = QtWidgets.QLabel()
|
||||
self.s11_min_swr_label.setProperty("cssClass", "s11_min_swr_label")
|
||||
s11_control_layout.addRow("Min VSWR:", self.s11_min_swr_label)
|
||||
self.s11_min_rl_label = QtWidgets.QLabel()
|
||||
self.s11_min_rl_label.setProperty("cssClass", "s11_min_rl_label")
|
||||
s11_control_layout.addRow("Return loss:", self.s11_min_rl_label)
|
||||
|
||||
marker_column.addWidget(s11_control_box)
|
||||
|
@ -302,11 +322,13 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
s21_control_box.setTitle("S21")
|
||||
s21_control_layout = QtWidgets.QFormLayout()
|
||||
s21_control_box.setLayout(s21_control_layout)
|
||||
|
||||
s21_control_box.setProperty("cssClass", "s21_control_box")
|
||||
self.s21_min_gain_label = QtWidgets.QLabel()
|
||||
self.s21_min_gain_label.setProperty("cssClass", "s21_min_gain_label")
|
||||
s21_control_layout.addRow("Min gain:", self.s21_min_gain_label)
|
||||
|
||||
self.s21_max_gain_label = QtWidgets.QLabel()
|
||||
self.s21_max_gain_label.setProperty("cssClass", "s21_max_gain_label")
|
||||
s21_control_layout.addRow("Max gain:", self.s21_max_gain_label)
|
||||
|
||||
marker_column.addWidget(s21_control_box)
|
||||
|
@ -333,6 +355,7 @@ class NanoVNASaver(QtWidgets.QWidget):
|
|||
tdr_control_box.setMaximumWidth(250)
|
||||
|
||||
self.tdr_result_label = QtWidgets.QLabel()
|
||||
self.tdr_result_label.setProperty("cssClass", "tdr_result_label")
|
||||
tdr_control_layout.addRow("Estimated cable length:", self.tdr_result_label)
|
||||
|
||||
self.tdr_button = QtWidgets.QPushButton("Time Domain Reflectometry ...")
|
||||
|
@ -1132,9 +1155,13 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
|||
display_options_layout.addRow(self.show_lines_option, show_lines_label)
|
||||
|
||||
self.dark_mode_option = QtWidgets.QCheckBox("Dark mode")
|
||||
self.color_mode_option = QtWidgets.QCheckBox("Color mode")
|
||||
dark_mode_label = QtWidgets.QLabel("Black background with white text")
|
||||
color_mode_label = QtWidgets.QLabel("Values and menus colored (May need restart)")
|
||||
self.dark_mode_option.stateChanged.connect(self.changeDarkMode)
|
||||
self.color_mode_option.stateChanged.connect(self.changeColorMode)
|
||||
display_options_layout.addRow(self.dark_mode_option, dark_mode_label)
|
||||
display_options_layout.addRow(self.color_mode_option, color_mode_label)
|
||||
|
||||
self.btnColorPicker = QtWidgets.QPushButton("█")
|
||||
self.btnColorPicker.setFixedWidth(20)
|
||||
|
@ -1299,6 +1326,7 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
|||
|
||||
layout.addWidget(charts_box)
|
||||
self.dark_mode_option.setChecked(self.app.settings.value("DarkMode", False, bool))
|
||||
self.color_mode_option.setChecked(self.app.settings.value("ColorMode", False, bool))
|
||||
self.show_lines_option.setChecked(self.app.settings.value("ShowLines", False, bool))
|
||||
|
||||
self.backgroundColor = self.app.settings.value("BackgroundColor", defaultValue=QtGui.QColor("white"),
|
||||
|
@ -1373,17 +1401,58 @@ class DisplaySettingsWindow(QtWidgets.QWidget):
|
|||
def changeDarkMode(self):
|
||||
state = self.dark_mode_option.isChecked()
|
||||
self.app.settings.setValue("DarkMode", state)
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
if state:
|
||||
qtmodern.styles.dark(app)
|
||||
if self.color_mode_option.isChecked():
|
||||
app.setStyleSheet( "file:///" + os.path.join(path, 'dark-colored.css'))
|
||||
else:
|
||||
app.setStyleSheet( "")
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.black))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.white))
|
||||
else:
|
||||
qtmodern.styles.light(app)
|
||||
if self.color_mode_option.isChecked():
|
||||
app.setStyleSheet( "file:///" + os.path.join(path, 'light-colored.css'))
|
||||
else:
|
||||
app.setStyleSheet( "")
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.white))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.black))
|
||||
|
||||
def changeColorMode(self):
|
||||
state = self.color_mode_option.isChecked()
|
||||
self.app.settings.setValue("ColorMode", state)
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
if state:
|
||||
if self.dark_mode_option.isChecked():
|
||||
app.setStyleSheet( "file:///" + os.path.join(path, 'dark-colored.css'))
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.black))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.white))
|
||||
else:
|
||||
app.setStyleSheet( "file:///" + os.path.join(path, 'light-colored.css'))
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.white))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.black))
|
||||
else:
|
||||
app.setStyleSheet( "")
|
||||
if self.dark_mode_option.isChecked():
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.black))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.white))
|
||||
else:
|
||||
for c in self.app.charts:
|
||||
c.setBackgroundColor(QtGui.QColor(QtCore.Qt.white))
|
||||
c.setForegroundColor(QtGui.QColor(QtCore.Qt.lightGray))
|
||||
c.setTextColor(QtGui.QColor(QtCore.Qt.black))
|
||||
|
||||
def changeCustomColors(self):
|
||||
self.app.settings.setValue("UseCustomColors", self.use_custom_colors.isChecked())
|
||||
if self.use_custom_colors.isChecked():
|
||||
|
@ -1549,6 +1618,7 @@ class TDRWindow(QtWidgets.QWidget):
|
|||
layout.addRow("Velocity factor", self.tdr_velocity_input)
|
||||
|
||||
self.tdr_result_label = QtWidgets.QLabel()
|
||||
self.tdr_result_label.setProperty("cssClass", "tdr_result_label")
|
||||
layout.addRow("Estimated cable length:", self.tdr_result_label)
|
||||
|
||||
layout.addRow(self.app.tdr_chart)
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -18,12 +18,21 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
|
||||
from PyQt5 import QtWidgets, QtCore
|
||||
|
||||
from .NanoVNASaver import NanoVNASaver
|
||||
from .about import debug
|
||||
|
||||
|
||||
##*****************************************************
|
||||
#
|
||||
# Modif Carl
|
||||
#
|
||||
##*****************************************************
|
||||
import os
|
||||
import qtmodern.styles
|
||||
import qtmodern.windows
|
||||
##*****************************************************
|
||||
##*****************************************************
|
||||
def main():
|
||||
print("NanoVNASaver " + NanoVNASaver.version)
|
||||
print("Copyright (C) 2019 Rune B. Broberg")
|
||||
|
@ -70,10 +79,20 @@ def main():
|
|||
|
||||
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
|
||||
##*****************************************************
|
||||
#
|
||||
# Modif Carl For Styling
|
||||
#
|
||||
##*****************************************************
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
qtmodern.styles.light(app)
|
||||
# app.setStyleSheet( "file:///" + os.path.join(path, 'light-colored.css'))
|
||||
window = NanoVNASaver()
|
||||
window.show()
|
||||
app.exec_()
|
||||
|
||||
##*****************************************************
|
||||
##*****************************************************
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Ładowanie…
Reference in New Issue