2023-08-04 18:27:03 +00:00
|
|
|
import time
|
|
|
|
from collections import namedtuple
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
|
|
|
import driver.mouse
|
|
|
|
from gui.components.base_popup import BasePopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.slider import Slider
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
shift_image = namedtuple('Shift', ['left', 'right', 'top', 'bottom'])
|
|
|
|
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
class PictureEditPopup(BasePopup):
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2023-08-29 14:43:00 +00:00
|
|
|
super(PictureEditPopup, self).__init__()
|
2024-02-13 09:04:24 +00:00
|
|
|
self._zoom_slider = Slider(names.o_StatusSlider)
|
|
|
|
self._view = QObject(names.cropSpaceItem_Item)
|
|
|
|
self._make_picture_button = Button(names.make_picture_StatusButton)
|
|
|
|
self._slider_handler = QObject(names.o_DropShadow)
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
@allure.step('Make picture')
|
2024-02-15 10:37:40 +00:00
|
|
|
def set_zoom_shift_for_picture(
|
2023-08-04 18:27:03 +00:00
|
|
|
self,
|
|
|
|
zoom: int = None,
|
|
|
|
shift: shift_image = None
|
|
|
|
):
|
|
|
|
if zoom is not None:
|
|
|
|
self._zoom_slider.value = zoom
|
|
|
|
# The slider changed value, but image updates only after click on slider
|
|
|
|
self._slider_handler.click()
|
|
|
|
time.sleep(1)
|
|
|
|
if shift is not None:
|
|
|
|
if shift.left:
|
|
|
|
driver.mouse.press_and_move(self._view.object, 1, 1, shift.left, 1)
|
|
|
|
time.sleep(1)
|
|
|
|
if shift.right:
|
|
|
|
driver.mouse.press_and_move(
|
|
|
|
self._view.object, self._view.width, 1, self._view.width - shift.right, 1)
|
|
|
|
time.sleep(1)
|
|
|
|
if shift.top:
|
|
|
|
driver.mouse.press_and_move(self._view.object, 1, 1, 1, shift.top, step=1)
|
|
|
|
time.sleep(1)
|
|
|
|
if shift.bottom:
|
|
|
|
driver.mouse.press_and_move(
|
|
|
|
self._view.object, 1, self._view.height, 1, self._view.height - shift.bottom, step=1)
|
|
|
|
time.sleep(1)
|
|
|
|
|
2023-08-29 14:43:00 +00:00
|
|
|
self._make_picture_button.click()
|
2024-04-11 08:33:19 +00:00
|
|
|
self._make_picture_button.wait_until_hidden()
|