#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：SlideButtonOperation.py
@Description：
@Author：XSH
@Time：2025/12/23 13:21
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from abc                                    import abstractmethod                       #
from PyQt5                                  import Qt                                   #
from AppInterfaces.UiInterface              import UiInterface                          #
from AppInterfaces.globalSlot               import globalSlot, AppSlot                  #
from AppCore.Contexts                       import *                                    #
from AppCore.DBModels                       import *                                    #
from AppCore.Levels                         import *                                    #
from AppUtils.utils                         import *                                    #
from AppSettings.Settings                   import *                                    #

class SlideButtonOperation(Qt.QWidget, UiInterface):
    LastButton      : Qt.QPushButton            #
    BeginButton     : Qt.QPushButton            #
    EndButton       : Qt.QPushButton            #
    NextButton      : Qt.QPushButton            #
    DoneButton      : Qt.QPushButton            #

    def __init__(self, parent: Qt.QWidget = None):
        super(SlideButtonOperation, self).__init__(parent)
        self.Initialization('SlideButtonOperation', self, parent)


    def initValue(self):
        super(SlideButtonOperation, self).initValue()
        self.initLastButton      ()
        self.initBeginButton     ()
        self.initEndButton       ()
        self.initNextButton      ()
        self.initDoneButton      ()



    def initProperty(self):
        super(SlideButtonOperation, self).initProperty()
        self.LastButton  .setFixedHeight(35)
        self.BeginButton .setFixedHeight(35)
        self.EndButton   .setFixedHeight(35)
        self.NextButton  .setFixedHeight(35)
        self.DoneButton  .setFixedHeight(35)
        self.LastButton      .setText('上一张　')
        self.BeginButton     .setText('开始位置')
        self.EndButton       .setText('结束位置')
        self.NextButton      .setText('下一张　')
        self.DoneButton      .setText('　保存　')


    def initLayouts(self):
        if self.hasWindowLayouts:
            return
        main_layout: Qt.QGridLayout = Qt.QGridLayout()
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(5, 5, 5, 5)

        main_layout.addWidget(self.LastButton  , 0, 0  , 1, 2)
        main_layout.addWidget(self.BeginButton , 0, 0  , 1, 2)
        main_layout.addWidget(self.EndButton   , 0, 2  , 1, 2)
        main_layout.addWidget(self.NextButton  , 0, 4  , 1, 2)
        main_layout.addWidget(self.DoneButton  , 0, 6  , 1, 4)
        self.setLayout(main_layout)

    def initLastButton  (self):
        if not self.hasLastButton  :
            self.LastButton   = Qt.QPushButton()
    def initBeginButton (self):
        if not self.hasBeginButton :
            self.BeginButton  = Qt.QPushButton()
    def initEndButton   (self):
        if not self.hasEndButton   :
            self.EndButton    = Qt.QPushButton()
    def initNextButton  (self):
        if not self.hasNextButton  :
            self.NextButton   = Qt.QPushButton()
    def initDoneButton  (self):
        if not self.hasDoneButton  :
            self.DoneButton   = Qt.QPushButton()






    @property
    def hasLastButton  (self) -> bool:
        return self.has_field('LastButton'  , Qt.QPushButton)

    @property
    def hasBeginButton (self) -> bool:
        return self.has_field('BeginButton' , Qt.QPushButton)

    @property
    def hasEndButton   (self) -> bool:
        return self.has_field('EndButton'   , Qt.QPushButton)

    @property
    def hasNextButton  (self) -> bool:
        return self.has_field('NextButton'  , Qt.QPushButton)

    @property
    def hasDoneButton  (self) -> bool:
        return self.has_field('DoneButton'  , Qt.QPushButton)
