Skip to content

Commit

Permalink
Made viewing rewrite previews a toggleable option in the Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdwetering committed Jul 10, 2024
1 parent aa66c91 commit fb665b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion zxlive/rewrite_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .common import ET, GraphT, VT, get_data
from .dialogs import show_error_msg
from .rewrite_data import is_rewrite_data, RewriteData, MatchType, MATCHES_VERTICES
from .settings import display_setting

if TYPE_CHECKING:
from .proof_panel import ProofPanel
Expand All @@ -39,7 +40,7 @@ class RewriteAction:

@classmethod
def from_rewrite_data(cls, d: RewriteData) -> RewriteAction:
if 'picture' in d:
if 'picture' in d and display_setting.PREVIEWS_SHOW:
pixmap = QPixmap()
pixmap.load(get_data("tooltips/"+d['picture']))
buffer = QBuffer()
Expand Down
3 changes: 3 additions & 0 deletions zxlive/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ColorScheme(TypedDict):
"tab-bar-location": QTabWidget.TabPosition.North,
"snap-granularity": '4',
"input-circuit-format": 'openqasm',
"previews-show": 'True'
}

tikz_export_defaults: dict[str, str] = {
Expand Down Expand Up @@ -179,6 +180,7 @@ def _get_synonyms(key: str, default: list[str]) -> list[str]:

class DisplaySettings:
SNAP_DIVISION = 4 # Should be an integer dividing SCALE
PREVIEWS_SHOW = True

def __init__(self, scheme_id: str) -> None:
self.colors = color_schemes[scheme_id]
Expand All @@ -190,6 +192,7 @@ def set_color_scheme(self, scheme_id: str) -> None:
def update(self) -> None:
self.SNAP_DIVISION = int(get_settings_value("snap-granularity", str))
self.SNAP = SCALE / self.SNAP_DIVISION
self.PREVIEWS_SHOW = (get_settings_value("previews-show",str) == "True")


# Initialise settings
Expand Down
6 changes: 6 additions & 0 deletions zxlive/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,19 @@ class SettingsData(TypedDict):
'sqasm-no-simplification': "Spider QASM (no simplification)",
}

combo_true_false = {
'True': 'True',
'False': 'False'
}


general_settings: list[SettingsData] = [
{"id": "path/custom-rules", "label": "Custom rules path", "type": FormInputType.Folder},
{"id": "color-scheme", "label": "Color scheme", "type": FormInputType.Combo, "data": color_scheme_data},
{"id": "tab-bar-location", "label": "Tab bar location", "type": FormInputType.Combo, "data": tab_positioning_data},
{"id": "snap-granularity", "label": "Snap-to-grid granularity", "type": FormInputType.Combo, "data": snap_to_grid_data},
{"id": "input-circuit-format", "label": "Input Circuit as", "type": FormInputType.Combo, "data": input_circuit_formats},
{"id": "previews-show", "label": "Show rewrite previews","type": FormInputType.Combo, "data": combo_true_false}
]

tikz_export_settings: list[SettingsData] = [
Expand Down

0 comments on commit fb665b0

Please sign in to comment.