Skip to content

Commit

Permalink
add aspect ratio (#587)
Browse files Browse the repository at this point in the history
Co-authored-by: dl1com <1631996+dl1com@users.noreply.github.com>
  • Loading branch information
t0mpr1c3 and dl1com authored Oct 17, 2023
1 parent 66f3411 commit 52c8a2c
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 @@ -112,8 +112,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 @@ -122,6 +121,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 __quit(self):
logging.debug("Quitting")
QCoreApplication.instance().quit()
Expand Down
2 changes: 2 additions & 0 deletions src/main/python/ayab/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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 +63,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,
'disable_hardware_beep': bool,
Expand Down
12 changes: 11 additions & 1 deletion src/main/python/ayab/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# https://github.com/AllYarnsAreBeautiful/ayab-desktop

import logging
from enum import Enum

from PyQt5.QtCore import QRect
from PyQt5.QtGui import QImage, QPixmap, QBrush, QColor
Expand All @@ -29,6 +30,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 +122,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 52c8a2c

Please sign in to comment.