Small fixes and bigger library
This commit is contained in:
@@ -17,7 +17,7 @@ from bedit_gui.views.main_window import MainWindow
|
||||
from bedit_gui.views.models.document_tree_model import DocumentTreeModel
|
||||
from bedit_gui.utils.icon import render_fitted_icon
|
||||
|
||||
ICON_SIZE = QSize(32, 32)
|
||||
ICON_SIZE = QSize(16, 16)
|
||||
|
||||
class InterfaceEditorLike(Protocol):
|
||||
def exec(self) -> int: ...
|
||||
@@ -84,11 +84,11 @@ class DocumentTreeController(QObject):
|
||||
window.ui.documentTree.setHeaderHidden(True)
|
||||
window.ui.documentTree.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
window.ui.documentTree.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
window.ui.documentTree.setIconSize(QSize(48, 48))
|
||||
window.ui.documentTree.setIconSize(QSize(24, 24))
|
||||
window.ui.documentTree.header().setStretchLastSection(False)
|
||||
window.ui.documentTree.header().setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
||||
window.ui.documentTree.header().setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
|
||||
window.ui.documentTree.setColumnWidth(1, 56)
|
||||
window.ui.documentTree.setColumnWidth(1, 28)
|
||||
self._tree_viewport = window.ui.documentTree.viewport()
|
||||
self._tree_viewport.installEventFilter(self)
|
||||
|
||||
@@ -175,11 +175,22 @@ class DocumentTreeController(QObject):
|
||||
|
||||
def _show_context_menu(self, position: QPoint) -> None:
|
||||
index = self.window.ui.documentTree.indexAt(position)
|
||||
component = self.model.value(index)
|
||||
if not isinstance(component, Component):
|
||||
return
|
||||
value = self.model.value(index)
|
||||
global_position = self.window.ui.documentTree.viewport().mapToGlobal(position)
|
||||
if isinstance(value, CoreDocument):
|
||||
self._show_root_context_menu(global_position)
|
||||
elif isinstance(value, Component):
|
||||
self._show_component_context_menu(value, global_position)
|
||||
|
||||
self._show_component_context_menu(component, self.window.ui.documentTree.viewport().mapToGlobal(position))
|
||||
def _show_root_context_menu(self, global_position: QPoint) -> None:
|
||||
menu = QMenu(self.window.ui.documentTree)
|
||||
add_graph_component = menu.addAction("Add Graph Component")
|
||||
add_equation_component = menu.addAction("Add Equation Component")
|
||||
selected = menu.exec(global_position)
|
||||
if selected is add_graph_component:
|
||||
self.document.add_empty_root_graph_component()
|
||||
elif selected is add_equation_component:
|
||||
self.document.add_empty_root_equation_component()
|
||||
|
||||
def _show_graph_component_context_menu(self, component_id: ComponentID, global_position: QPoint) -> None:
|
||||
component = self._components.get(component_id)
|
||||
|
||||
Reference in New Issue
Block a user