creatumlibre.ui.menu.zoom
1from PyQt6.QtGui import QAction, QKeySequence 2 3 4class ZoomMenu: 5 """Zoom funcitons to scale the image""" 6 7 def __init__(self, parent): 8 self.parent = parent 9 zoom_menu = parent.menu_bar.addMenu("Zoom") 10 11 zoom_actions = { 12 "Zoom In": ("Ctrl++", parent.tab_manager.zoom_in), 13 "Zoom Out": ("Ctrl+-", parent.tab_manager.zoom_out), 14 "Fit to Frame": ("Ctrl+#", parent.tab_manager.fit_to_container), 15 "Reset": ("Ctrl+.", parent.tab_manager.reset_zoom), 16 } 17 18 for name, (shortcut, function) in zoom_actions.items(): 19 action = QAction(name, parent) 20 action.setShortcut(QKeySequence(shortcut)) 21 action.triggered.connect(function) 22 zoom_menu.addAction(action) 23 24 def zoom_in(self): 25 """Increase the zoom level of the active image.""" 26 active_tab = self.parent.tab_manager.get_active_tab() 27 if active_tab: 28 active_tab.apply_zoom(1.2) # Scale up by 20% 29 30 def zoom_out(self): 31 """Decrease the zoom level of the active image.""" 32 active_tab = self.parent.tab_manager.get_active_tab() 33 if active_tab: 34 active_tab.apply_zoom(0.8) # Scale down by 20% 35 36 def fit_to_frame(self): 37 """Resize image to fit within the tab without stretching.""" 38 print("Fitting image to frame") 39 active_tab = self.parent.tab_manager.get_active_tab() 40 if active_tab: 41 active_tab.fit_to_container(self.parent.tab_manager) 42 43 def reset_zoom(self): 44 """Reset zoom level to default.""" 45 active_tab = self.parent.tab_manager.get_active_tab() 46 if active_tab: 47 active_tab.reset_zoom()
class
ZoomMenu:
5class ZoomMenu: 6 """Zoom funcitons to scale the image""" 7 8 def __init__(self, parent): 9 self.parent = parent 10 zoom_menu = parent.menu_bar.addMenu("Zoom") 11 12 zoom_actions = { 13 "Zoom In": ("Ctrl++", parent.tab_manager.zoom_in), 14 "Zoom Out": ("Ctrl+-", parent.tab_manager.zoom_out), 15 "Fit to Frame": ("Ctrl+#", parent.tab_manager.fit_to_container), 16 "Reset": ("Ctrl+.", parent.tab_manager.reset_zoom), 17 } 18 19 for name, (shortcut, function) in zoom_actions.items(): 20 action = QAction(name, parent) 21 action.setShortcut(QKeySequence(shortcut)) 22 action.triggered.connect(function) 23 zoom_menu.addAction(action) 24 25 def zoom_in(self): 26 """Increase the zoom level of the active image.""" 27 active_tab = self.parent.tab_manager.get_active_tab() 28 if active_tab: 29 active_tab.apply_zoom(1.2) # Scale up by 20% 30 31 def zoom_out(self): 32 """Decrease the zoom level of the active image.""" 33 active_tab = self.parent.tab_manager.get_active_tab() 34 if active_tab: 35 active_tab.apply_zoom(0.8) # Scale down by 20% 36 37 def fit_to_frame(self): 38 """Resize image to fit within the tab without stretching.""" 39 print("Fitting image to frame") 40 active_tab = self.parent.tab_manager.get_active_tab() 41 if active_tab: 42 active_tab.fit_to_container(self.parent.tab_manager) 43 44 def reset_zoom(self): 45 """Reset zoom level to default.""" 46 active_tab = self.parent.tab_manager.get_active_tab() 47 if active_tab: 48 active_tab.reset_zoom()
Zoom funcitons to scale the image
ZoomMenu(parent)
8 def __init__(self, parent): 9 self.parent = parent 10 zoom_menu = parent.menu_bar.addMenu("Zoom") 11 12 zoom_actions = { 13 "Zoom In": ("Ctrl++", parent.tab_manager.zoom_in), 14 "Zoom Out": ("Ctrl+-", parent.tab_manager.zoom_out), 15 "Fit to Frame": ("Ctrl+#", parent.tab_manager.fit_to_container), 16 "Reset": ("Ctrl+.", parent.tab_manager.reset_zoom), 17 } 18 19 for name, (shortcut, function) in zoom_actions.items(): 20 action = QAction(name, parent) 21 action.setShortcut(QKeySequence(shortcut)) 22 action.triggered.connect(function) 23 zoom_menu.addAction(action)
def
zoom_in(self):
25 def zoom_in(self): 26 """Increase the zoom level of the active image.""" 27 active_tab = self.parent.tab_manager.get_active_tab() 28 if active_tab: 29 active_tab.apply_zoom(1.2) # Scale up by 20%
Increase the zoom level of the active image.
def
zoom_out(self):
31 def zoom_out(self): 32 """Decrease the zoom level of the active image.""" 33 active_tab = self.parent.tab_manager.get_active_tab() 34 if active_tab: 35 active_tab.apply_zoom(0.8) # Scale down by 20%
Decrease the zoom level of the active image.
def
fit_to_frame(self):
37 def fit_to_frame(self): 38 """Resize image to fit within the tab without stretching.""" 39 print("Fitting image to frame") 40 active_tab = self.parent.tab_manager.get_active_tab() 41 if active_tab: 42 active_tab.fit_to_container(self.parent.tab_manager)
Resize image to fit within the tab without stretching.