Browse Source

Less obvious fixes for PySide2.

pyside
Ben Niemann 3 years ago
parent
commit
83ab01c293
  1. 8
      noisicaa/ui/graph/canvas_test.py
  2. 8
      noisicaa/ui/property_connector.py
  3. 2
      noisicaa/ui/settings_dialog.py
  4. 3
      noisicaa/ui/stat_monitor.py
  5. 17
      noisidev/qttest.py

8
noisicaa/ui/graph/canvas_test.py

@ -49,8 +49,8 @@ class CanvasTest(uitest.ProjectMixin, uitest.UITestCase):
self.canvas.zoomStarted.connect(sig)
evt = QtGui.QWheelEvent(
QtCore.QPointF(200, 100),
QtCore.QPointF(500, 300),
QtCore.QPoint(200, 100),
QtCore.QPoint(500, 300),
QtCore.QPoint(0, 10),
QtCore.QPoint(0, 120),
10, Qt.Vertical,
@ -69,8 +69,8 @@ class CanvasTest(uitest.ProjectMixin, uitest.UITestCase):
self.canvas.zoomStarted.connect(sig)
evt = QtGui.QWheelEvent(
QtCore.QPointF(200, 100),
QtCore.QPointF(500, 300),
QtCore.QPoint(200, 100),
QtCore.QPoint(500, 300),
QtCore.QPoint(0, -10),
QtCore.QPoint(0, -120),
10, Qt.Vertical,

8
noisicaa/ui/property_connector.py

@ -89,8 +89,8 @@ class QComboBoxConnector(Generic[V], PropertyConnector[V, QtWidgets.QComboBox]):
idx = self._widget.findData(self.value())
if idx >= 0:
self._widget.setCurrentIndex(idx)
connection = self._widget.currentIndexChanged.connect(self._widgetChanged)
self.add_cleanup_function(lambda: self._widget.currentIndexChanged.disconnect(connection))
self._widget.currentIndexChanged.connect(self._widgetChanged)
self.add_cleanup_function(lambda: self._widget.currentIndexChanged.disconnect(self._widgetChanged))
def _widgetChanged(self) -> None:
self.setValue(self._widget.currentData())
@ -141,8 +141,8 @@ class QDoubleSpinBoxConnector(PropertyConnector[float, QtWidgets.QDoubleSpinBox]
def _connectToWidget(self) -> None:
self._widget.setValue(self.value())
connection = self._widget.valueChanged.connect(self.__valueChanged)
self.add_cleanup_function(lambda: self._widget.valueChanged.disconnect(connection))
self._widget.valueChanged.connect(self.__valueChanged)
self.add_cleanup_function(lambda: self._widget.valueChanged.disconnect(self.__valueChanged))
def __valueChanged(self, value: float) -> None:
if self.__ignore_change:

2
noisicaa/ui/settings_dialog.py

@ -59,7 +59,7 @@ class SettingsDialog(ui_base.CommonMixin, QtWidgets.QDialog):
# TODO: somehow always ends up being shown...
#self.setVisible(bool(self.app.settings.value('dialog/settings/visible', False)))
self.restoreGeometry(self.app.settings.value('dialog/settings/geometry', b''))
self.tabs.setCurrentIndex(int(self.app.settings.value('dialog/settings/page', 0)))
self.tabs.setCurrentIndex(int(self.app.settings.value('dialog/settings/page') or 0))
def storeState(self) -> None:
s = self.app.settings

3
noisicaa/ui/stat_monitor.py

@ -223,8 +223,7 @@ class StatMonitor(ui_base.AbstractStatMonitor):
self.setCentralWidget(main_widget)
self.setVisible(
int(self.app.settings.value(
'dialog/stat_monitor/visible', False)))
bool(self.app.settings.value('dialog/stat_monitor/visible') or False))
self.restoreGeometry(
self.app.settings.value(
'dialog/stat_monitor/geometry', b''))

17
noisidev/qttest.py

@ -33,24 +33,33 @@ from . import unittest
logger = logging.getLogger(__name__)
qt_app = None
class QtTestCase(unittest.AsyncTestCase):
use_default_loop = True
qt_app = None # type: QtWidgets.QApplication
qt_app = None
@classmethod
def setUpClass(cls):
if not constants.TEST_OPTS.ALLOW_UI:
return
if cls.qt_app is None:
cls.qt_app = QtWidgets.QApplication(['unittest'])
cls.qt_app.setQuitOnLastWindowClosed(False)
global qt_app
if qt_app is None:
qt_app = QtWidgets.QApplication(['unittest'])
qt_app.setQuitOnLastWindowClosed(False)
cls.qt_app = qt_app
event_loop = quamash.QEventLoop(cls.qt_app)
asyncio.set_event_loop(event_loop)
executor = concurrent.futures.ThreadPoolExecutor(max_workers=10)
event_loop.set_default_executor(executor)
@classmethod
def tearDownClass(cls):
cls.qt_app = None
def setup_testcase(self):
if not constants.TEST_OPTS.ALLOW_UI:
raise unittest.SkipTest("QT tests disabled")

Loading…
Cancel
Save