From 5b0c5bb4bb27489c623b0bb6ee58d98d75c99f81 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 15 Jan 2023 16:33:32 +0100 Subject: [PATCH] removed symbols from shift/scale, combobox in fitparameter respects sizehint --- src/gui_qt/data/shift_graphs.py | 2 +- src/gui_qt/fit/fitwindow.py | 2 +- src/gui_qt/io/asciireader.py | 7 ++++++- src/gui_qt/lib/styles.py | 12 ++++++++++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gui_qt/data/shift_graphs.py b/src/gui_qt/data/shift_graphs.py index 3e0edb2..61dc918 100644 --- a/src/gui_qt/data/shift_graphs.py +++ b/src/gui_qt/data/shift_graphs.py @@ -46,7 +46,7 @@ class QShift(QtWidgets.QDialog, Ui_shift_dialog): pl = [PlotItem(x=x, y=y.real, name=name, pen=mkPen(color=color)), PlotItem(x=x, y=y.imag, name=name, pen=mkPen(color=color))] else: - pl = [PlotItem(x=x, y=y, name=name, symbol='t', pen=mkPen(color=color))] + pl = [PlotItem(x=x, y=y, name=name, pen=mkPen(color=color))] self.data[idx] = (pl, x, y) diff --git a/src/gui_qt/fit/fitwindow.py b/src/gui_qt/fit/fitwindow.py index bc5b650..099dd1c 100644 --- a/src/gui_qt/fit/fitwindow.py +++ b/src/gui_qt/fit/fitwindow.py @@ -107,7 +107,7 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog): if function is None: return - dialog = QFitParameterWidget() + dialog = QFitParameterWidget(self.stackedWidget) data_names = self.data_table.data_list(include_name=True) dialog.set_function(function, function_idx) diff --git a/src/gui_qt/io/asciireader.py b/src/gui_qt/io/asciireader.py index 543654a..7bf5a06 100644 --- a/src/gui_qt/io/asciireader.py +++ b/src/gui_qt/io/asciireader.py @@ -183,7 +183,12 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader): col_header = None if self.column_checkBox.isChecked(): - col_header = [self.ascii_table.horizontalHeaderItem(i).text() for i in range(self.ascii_table.columnCount())] + col_header = [] + for i in range(self.ascii_table.columnCount()): + if self.ascii_table.horizontalHeaderItem(i) is not None: + col_header.append(self.ascii_table.horizontalHeaderItem(i).text()) + else: + col_header.append(i) if y is not None and col_header is not None: col_header = [col_header[i] for i in range(len(col_header)) if i in y] diff --git a/src/gui_qt/lib/styles.py b/src/gui_qt/lib/styles.py index d453f50..21290d6 100644 --- a/src/gui_qt/lib/styles.py +++ b/src/gui_qt/lib/styles.py @@ -1,5 +1,5 @@ from . import HAS_IMPORTLIB_RESOURCE -from ..Qt import QtGui, QtWidgets +from ..Qt import QtGui, QtWidgets, QtCore class DarkPalette(QtGui.QPalette): @@ -97,6 +97,14 @@ class MyProxyStyle(QtWidgets.QProxyStyle): from pkg_resources import resource_filename with open(resource_filename('resources.icons', 'style.qss'), 'r') as f: obj.setStyleSheet(f.read()) - else: return super().polish(obj) + + def drawComplexControl(self, control: QtWidgets.QStyle.ComplexControl, + opts: QtWidgets.QStyleOptionComplex, painter: QtGui.QPainter, widget=None): + if control == QtWidgets.QStyle.CC_ComboBox: + textrect = self.baseStyle().subControlRect(QtWidgets.QStyle.CC_ComboBox, opts, QtWidgets.QStyle.SC_ComboBoxEditField, widget) + opts.currentText = painter.fontMetrics().elidedText(opts.currentText, QtCore.Qt.ElideRight, textrect.width()) + super().drawComplexControl(control, opts, painter, widget=widget) + else: + super().drawComplexControl(control, opts, painter, widget=widget)