Skip to content

Commit

Permalink
add aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mpr1c3 committed Oct 17, 2023
1 parent 6072855 commit 5e1a797
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/python/ayab/ayab.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def __activate_menu(self):
self.menu.ui.action_load_AYAB_firmware.triggered.connect(
self.flash.open)
self.menu.ui.action_cancel.triggered.connect(self.engine.cancel)
self.menu.ui.action_set_preferences.triggered.connect(
self.prefs.open_dialog)
self.menu.ui.action_set_preferences.triggered.connect(self.__set_prefs)
self.menu.ui.action_about.triggered.connect(self.about.show)
# get names of image actions from Transform methods
transforms = filter(lambda x: x[0] != "_", Transform.__dict__.keys())
Expand All @@ -123,6 +122,10 @@ def __activate_menu(self):
slot = getattr(self.scene.ayabimage, t)
action.triggered.connect(slot)

def __set_prefs(self):
self.prefs.open_dialog()
self.scene.refresh()

def start_knitting(self):
"""Start the knitting process."""
self.start_operation()
Expand Down
3 changes: 3 additions & 0 deletions src/main/python/ayab/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import re
from enum import Enum

from PyQt5.QtCore import Qt, QSettings, QCoreApplication
from PyQt5.QtWidgets import QDialog, QFormLayout, QLabel, QCheckBox, QComboBox
Expand All @@ -34,6 +35,7 @@
from .engine.mode import Mode
from .machine import Machine
from .language import Language
from .scene import AspectRatio


def str2bool(qvariant):
Expand Down Expand Up @@ -62,6 +64,7 @@ class Preferences(SignalSender):
'default_infinite_repeat': bool,
'default_alignment': Alignment,
'default_knit_side_image': bool,
'aspect_ratio': AspectRatio,
# 'default_continuous_reporting': bool,
'quiet_mode': bool,
'language': Language,
Expand Down
11 changes: 10 additions & 1 deletion src/main/python/ayab/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
from .machine import Machine


class AspectRatio(Enum):
DEFAULT = 0
FAIRISLE = 1

def add_items(box):
box.addItem("1:1")
box.addItem("4:5")


class Scene(QGraphicsView):
"""Graphics scene object for UI.
Expand Down Expand Up @@ -112,7 +121,7 @@ def refresh(self):
self.LIMIT_BAR_WIDTH))

self.resetTransform()
self.scale(self.zoom, self.zoom)
self.scale(self.zoom, self.zoom * (1.0 - 0.2 * self.__prefs.value("aspect_ratio")))
self.setScene(qscene)

@property
Expand Down

0 comments on commit 5e1a797

Please sign in to comment.