示例#1
0
 def OnDrop( self, x, y ):
     
     screen_position = ClientGUIFunctions.ClientToScreen( self._parent, QC.QPoint( x, y ) )
     
     drop_tlw = QW.QApplication.topLevelAt( screen_position )
     my_tlw = self._parent.window()
     
     if drop_tlw == my_tlw:
         
         return True
         
     else:
         
         return False
    def _SizeAndPositionAndShow(self):

        try:

            gui_frame = self.parentWidget()

            possibly_on_hidden_virtual_desktop = not ClientGUIFunctions.MouseIsOnMyDisplay(
                gui_frame)

            gui_is_hidden = not gui_frame.isVisible()

            going_to_bug_out_at_hide_or_show = possibly_on_hidden_virtual_desktop or gui_is_hidden

            current_focus_tlw = QW.QApplication.activeWindow()

            self_is_active = current_focus_tlw == self

            main_gui_or_child_window_is_active = ClientGUIFunctions.TLWOrChildIsActive(
                gui_frame)

            num_messages_displayed = self._message_vbox.count()

            there_is_stuff_to_display = num_messages_displayed > 0

            if there_is_stuff_to_display:

                parent_size = gui_frame.size()

                my_size = self.size()

                my_x = (parent_size.width() - my_size.width()) - 20
                my_y = (parent_size.height() - my_size.height()) - 25

                if gui_frame.isVisible():

                    my_position = ClientGUIFunctions.ClientToScreen(
                        gui_frame, QC.QPoint(my_x, my_y))

                    if my_position != self.pos():

                        self.move(my_position)

                # Unhiding tends to raise the main gui tlw in some window managers, which is annoying if a media viewer window has focus
                show_is_not_annoying = main_gui_or_child_window_is_active or self._DisplayingError(
                )

                ok_to_show = show_is_not_annoying and not going_to_bug_out_at_hide_or_show

                if ok_to_show:

                    self.show()

            else:

                if not going_to_bug_out_at_hide_or_show:

                    self.hide()

        except:

            text = 'The popup message manager experienced a fatal error and will now stop working! Please restart the client as soon as possible! If this keeps happening, please email the details and your client.log to the hydrus developer.'

            HydrusData.Print(text)

            HydrusData.Print(traceback.format_exc())

            QW.QMessageBox.critical(gui_frame, 'Error', text)

            self._update_job.Cancel()

            self.CleanBeforeDestroy()

            self.deleteLater()