Skip to content

Commit

Permalink
Merge pull request #315 from zxcalc/expand-rewrite-action
Browse files Browse the repository at this point in the history
Toggle rewrite panel expansion with click + auto expand 1st row + fix height
  • Loading branch information
boldar99 authored Jul 10, 2024
2 parents 8c5e107 + a611cbc commit d90c793
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zxlive/proof_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ def init_rewrites_bar(self) -> None:
def reset_rewrite_panel_style(self) -> None:
self.rewrites_panel.setUniformRowHeights(True)
self.rewrites_panel.setSelectionMode(QAbstractItemView.SelectionMode.NoSelection)
fi = QFontInfo(display_setting.font)
self.rewrites_panel.setStyleSheet(
f'''
QTreeView::Item:hover {{
background-color: #e2f4ff;
}}
QTreeView::Item{{
height:{fi.pixelSize() * 2.2}px;
height:{display_setting.font.pointSizeF() * 2.2}px;
}}
QTreeView::Item:!enabled {{
color: #c0c0c0;
Expand Down Expand Up @@ -431,5 +430,6 @@ def _refresh_rewrites_model(self) -> None:
refresh_custom_rules()
model = RewriteActionTreeModel.from_dict(action_groups, self)
self.rewrites_panel.setModel(model)
self.rewrites_panel.expand(model.index(0,0))
self.rewrites_panel.clicked.connect(model.do_rewrite)
self.graph_scene.selection_changed_custom.connect(lambda: model.executor.submit(model.update_on_selection))
4 changes: 4 additions & 0 deletions zxlive/rewrite_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def do_rewrite(self, index: QModelIndex) -> None:
node = cast(RewriteActionTree, index.internalPointer())
if node.is_rewrite:
node.rewrite_action.do_rewrite(self.proof_panel)
else:
self.proof_panel.rewrites_panel.setExpanded(
index, not self.proof_panel.rewrites_panel.isExpanded(index)
)

def update_on_selection(self) -> None:
selection, edges = self.proof_panel.parse_selection()
Expand Down

0 comments on commit d90c793

Please sign in to comment.