diff --git a/b_asic/scheduler-gui/__init__.py b/b_asic/scheduler-gui/__init__.py index 6d2e933f306b6ea1507787f93c73d859a1e8ae28..87bb8be2b965bc8a508534d1bf7c40469f6096db 100644 --- a/b_asic/scheduler-gui/__init__.py +++ b/b_asic/scheduler-gui/__init__.py @@ -3,11 +3,12 @@ Graphical user interface for B-ASIC scheduler. """ -from logger import * -from main_window import * -from graphics_graph import * -from graphics_axis import * -from component_item import * +from logger import * +from main_window import * +from graphics_graph_item import * +from graphics_graph_event import * +from graphics_axis_item import * +from graphics_component_item import * # __all__ = ['main_window', 'graphics_graph', 'graphics_axis', 'component_item'] __version__ = '0.1' diff --git a/b_asic/scheduler-gui/main_window.py b/b_asic/scheduler-gui/main_window.py index b3dec33a415e14747bb6134ffd1e93d392ad2275..f3e03486d42a05682ef4ab677c85437e31e94a8c 100644 --- a/b_asic/scheduler-gui/main_window.py +++ b/b_asic/scheduler-gui/main_window.py @@ -2,20 +2,15 @@ # -*- coding: utf-8 -*- """B-ASIC Scheduler-gui Module. -Contains the scheduler-gui class for scheduling operations in an SFG. +Contains the scheduler-gui MainWindow class for scheduling operations in an SFG. Start main-window with start_gui(). """ - - - - - import os import sys from pathlib import Path from types import ModuleType -from typing import Any, Iterable, List +from typing import Any, Iterable, List, Sequence, Type from pprint import pprint #from matplotlib.pyplot import bar #from diagram import * @@ -120,6 +115,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): _graph: GraphicsGraphItem _scale: float _debug_rects: QGraphicsItemGroup + _splitter_pos: int + _splitter_min: int def __init__(self): @@ -133,15 +130,17 @@ class MainWindow(QMainWindow, Ui_MainWindow): QIcon.setThemeName('breeze') log.debug('themeName: \'{}\''.format(QIcon.themeName())) log.debug('themeSearchPaths: {}'.format(QIcon.themeSearchPaths())) + self.setupUi(self) + # self._splitter_pos = 0 + self._read_settings() self._init_ui() self._init_graphics() - self._read_settings() + # self._splitter_pos = self.splitter.sizes()[1] def _init_ui(self) -> None: """Initialize the ui""" - self.setupUi(self) # Connect signals to slots self.menu_load_from_file.triggered .connect(self._load_schedule_from_pyfile) @@ -168,6 +167,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.info_table.setItem(i,1,item) # Init central-widget splitter + self._splitter_min = self.splitter.minimumSizeHint().height() self.splitter.setStretchFactor(0, 1) self.splitter.setStretchFactor(1, 0) self.splitter.setCollapsible(0, False) @@ -304,15 +304,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): def toggle_component_info(self, checked: bool) -> None: """This method toggles the right hand side info window.""" # Note: splitter handler index 0 is a hidden splitter handle far most left, use index 1 - settings = QSettings() - range = self.splitter.getRange(1) # tuple(min, max) + # settings = QSettings() + _, max = self.splitter.getRange(1) # tuple(min, max) if checked: - self.splitter.restoreState(settings.value("mainwindow/splitter/last_state")) - # self.splitter.restoreState(settings.value("splitterSizes")) + if self._splitter_pos < self._splitter_min: + self.splitter.moveSplitter(max - self._splitter_min, 1) + else: + self.splitter.moveSplitter(max - self._splitter_pos, 1) else: - settings.setValue("mainwindow/splitter/last_state", self.splitter.saveState()) - self.splitter.moveSplitter(range[1], 1) + self.splitter.moveSplitter(max, 1) @Slot(bool) def toggle_exit_dialog(self, checked: bool) -> None: @@ -323,13 +324,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): def _splitter_moved(self, pos: int, index: int) -> None: """Callback method used to check if the right widget (info window) has collapsed. Update the checkbutton accordingly.""" - # TODO: Custom move handler, save state on click-release? - widths: list[int, int] = list(self.splitter.sizes()) + width = self.splitter.sizes()[1] - if widths[1] == 0: - self.menu_node_info.setChecked(False) + if width == 0: + if self.menu_node_info.isChecked() is True: + self.menu_node_info.setChecked(False) else: - self.menu_node_info.setChecked(True) + if self.menu_node_info.isChecked() is False: + self.menu_node_info.setChecked(True) + self._splitter_pos = width + @Slot('QList<QRectF>') def shrink_scene_to_min_size(self, region: List[QRectF]) -> None: @@ -395,6 +399,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): s.setValue('mainwindow/state', self.saveState()) # toolbars, dockwidgets: pos, size s.setValue('mainwindow/menu/node_info', self.menu_node_info.isChecked()) s.setValue('mainwindow/splitter/state', self.splitter.saveState()) + s.setValue('mainwindow/splitter/pos', self.splitter.sizes()[1]) if s.isWritable(): log.debug('Settings written to \'{}\'.'.format(s.fileName())) @@ -412,6 +417,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.restoreState( s.value('mainwindow/state', QByteArray())) self.menu_node_info.setChecked( s.value('mainwindow/menu/node_info', True, bool)) self.splitter.restoreState( s.value('mainwindow/splitter/state', QByteArray())) + self._splitter_pos = ( s.value('mainwindow/splitter/pos', 200, int)) self.menu_exit_dialog.setChecked( s.value('mainwindow/hide_exit_dialog', False, bool)) log.debug('Settings read from \'{}\'.'.format(s.fileName())) diff --git a/b_asic/scheduler-gui/main_window.ui b/b_asic/scheduler-gui/main_window.ui index 4e8a19b1e47a359d1a283f85d99ed01e74aab417..0b8c564c54f40c33c4e10aaf490aa9a4e98830e7 100644 --- a/b_asic/scheduler-gui/main_window.ui +++ b/b_asic/scheduler-gui/main_window.ui @@ -49,6 +49,9 @@ <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="handleWidth"> + <number>0</number> + </property> <widget class="QGraphicsView" name="view"> <property name="renderHints"> <set>QPainter::HighQualityAntialiasing|QPainter::TextAntialiasing</set>