def __init__(self, controller, title,
                 frame_splash_status: FrameSplashStatus):

        self._controller = controller

        QW.QWidget.__init__(self, None)

        self.setWindowFlag(QC.Qt.CustomizeWindowHint)
        self.setWindowFlag(QC.Qt.WindowContextHelpButtonHint, on=False)
        self.setWindowFlag(QC.Qt.WindowCloseButtonHint, on=False)
        self.setWindowFlag(QC.Qt.WindowMaximizeButtonHint, on=False)
        self.setAttribute(QC.Qt.WA_DeleteOnClose)

        self.setWindowTitle(title)

        self.setWindowIcon(QG.QIcon(self._controller.frame_icon_pixmap))

        self._my_panel = FrameSplashPanel(self, self._controller,
                                          frame_splash_status)

        self._cancel_shutdown_maintenance = ClientGUICommon.BetterButton(
            self, 'stop shutdown maintenance', self.CancelShutdownMaintenance)

        self._cancel_shutdown_maintenance.hide()

        #

        self._vbox = QP.VBoxLayout()

        QP.AddToLayout(self._vbox, self._cancel_shutdown_maintenance,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(self._vbox, self._my_panel,
                       CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

        self.setLayout(self._vbox)

        screen = ClientGUIFunctions.GetMouseScreen()

        if screen is not None:

            self.move(screen.availableGeometry().center() -
                      self.rect().center())

        self.show()

        self.raise_()
Esempio n. 2
0
def SetInitialTLWSizeAndPosition(tlw: QW.QWidget, frame_key):

    new_options = HG.client_controller.new_options

    (remember_size, remember_position, last_size, last_position,
     default_gravity, default_position, maximised,
     fullscreen) = new_options.GetFrameLocation(frame_key)

    parent = tlw.parentWidget()

    if parent is None:

        parent_window = None

    else:

        parent_window = parent.window()

    if remember_size and last_size is not None:

        (width, height) = last_size

        new_size = QC.QSize(width, height)

    else:

        new_size = GetSafeSize(tlw, tlw.sizeHint(), default_gravity)

    tlw.resize(new_size)

    min_width = min(240, new_size.width())
    min_height = min(240, new_size.height())

    tlw.setMinimumSize(QC.QSize(min_width, min_height))

    #

    child_position_point = QC.QPoint(CHILD_POSITION_PADDING,
                                     CHILD_POSITION_PADDING)

    desired_position = child_position_point

    we_care_about_off_screen_messages = True
    slide_up_and_left = False

    if remember_position and last_position is not None:

        (x, y) = last_position

        desired_position = QC.QPoint(x, y)

    elif default_position == 'topleft':

        if parent_window is None:

            we_care_about_off_screen_messages = False

            screen = ClientGUIFunctions.GetMouseScreen()

            if screen is not None:

                desired_position = screen.availableGeometry().topLeft(
                ) + QC.QPoint(CHILD_POSITION_PADDING, CHILD_POSITION_PADDING)

        else:

            parent_tlw = parent_window.window()

            desired_position = parent_tlw.pos() + QC.QPoint(
                CHILD_POSITION_PADDING, CHILD_POSITION_PADDING)

        slide_up_and_left = True

    elif default_position == 'center':

        if parent_window is None:

            we_care_about_off_screen_messages = False

            screen = ClientGUIFunctions.GetMouseScreen()

            if screen is not None:

                desired_position = screen.availableGeometry().center()

        else:

            desired_position = parent_window.frameGeometry().center(
            ) - tlw.rect().center()

    (safe_position, position_message) = GetSafePosition(desired_position)

    if we_care_about_off_screen_messages and position_message is not None:

        HydrusData.ShowText(position_message)

    if safe_position is not None:

        tlw.move(safe_position)

    if slide_up_and_left:

        SlideOffScreenTLWUpAndLeft(tlw)

    # Comment from before the Qt port: if these aren't callafter, the size and pos calls don't stick if a restore event happens

    if maximised:

        tlw.showMaximized()

    if fullscreen and not HC.PLATFORM_MACOS:

        tlw.showFullScreen()