Пример #1
0
    def __init__(self, parent: QW.QWidget, service_key: bytes,
                 account_identifiers: typing.Collection[
                     HydrusNetwork.AccountIdentifier]):

        QW.QWidget.__init__(self, parent)

        self._service_key = service_key
        self._service = HG.client_controller.services_manager.GetService(
            self._service_key)
        self._account_identifiers = account_identifiers

        self._done_first_fetch = False
        self._accounts_loaded = False
        self._account_keys_to_accounts = {}
        self._account_keys_to_account_info = {}

        self._accounts_box = ClientGUICommon.StaticBox(self, 'accounts')

        self._status_st = ClientGUICommon.BetterStaticText(self._accounts_box)

        self._account_list = ClientGUICommon.BetterCheckBoxList(
            self._accounts_box)
        self._account_list.setSelectionMode(
            QW.QAbstractItemView.SingleSelection)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_list, (74, 6))

        self._account_list.setMinimumSize(min_width, min_height)

        self._account_info_box = QW.QTextEdit(self._accounts_box)
        self._account_info_box.setReadOnly(True)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_info_box, (16, 8))

        self._account_info_box.setMinimumHeight(min_height)

        self._copy_checked_account_keys_button = ClientGUICommon.BetterButton(
            self._accounts_box, 'copy checked account ids',
            self._CopyCheckedAccountKeys)

        #

        self._accounts_box.Add(self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._accounts_box.Add(self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._account_info_box,
                               CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._copy_checked_account_keys_button,
                               CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        #

        self._account_list.itemClicked.connect(self._AccountClicked)
Пример #2
0
        def DoShowHide(self):

            parent = self.parentWidget()

            horizontal_offset = (self.width() - parent.width()) // 2

            if self._direction == 'down':

                pos = parent.mapToGlobal(parent.rect().bottomLeft())

            else:

                pos = parent.mapToGlobal(parent.rect().topLeft() -
                                         self.rect().bottomLeft())

            pos.setX(pos.x() - horizontal_offset)

            self.move(pos)

            over_parent = ClientGUIFunctions.MouseIsOverWidget(parent)
            over_me = ClientGUIFunctions.MouseIsOverWidget(self)

            should_show = over_parent or over_me

            if should_show:

                self.show()

            else:

                self.hide()
Пример #3
0
def SlideOffScreenTLWUpAndLeft(tlw):

    tlw_frame_rect = tlw.frameGeometry()

    tlw_top_left = tlw_frame_rect.topLeft()
    tlw_bottom_right = tlw_frame_rect.bottomRight()

    tlw_right = tlw_bottom_right.x()
    tlw_bottom = tlw_bottom_right.y()

    display_size = ClientGUIFunctions.GetDisplaySize(tlw)
    display_pos = ClientGUIFunctions.GetDisplayPosition(tlw)

    display_right = display_pos.x() + display_size.width(
    ) - CHILD_POSITION_PADDING
    display_bottom = display_pos.y() + display_size.height(
    ) - CHILD_POSITION_PADDING

    move_x = tlw_right > display_right
    move_y = tlw_bottom > display_bottom

    if move_x or move_y:

        delta_x = min(display_right - tlw_right, 0)
        delta_y = min(display_bottom - tlw_bottom, 0)

        delta_point = QC.QPoint(delta_x, delta_y)

        safe_pos = tlw_top_left + delta_point

        tlw.move(safe_pos)
Пример #4
0
def IShouldCatchShortcutEvent(evt_handler,
                              event=None,
                              child_tlw_classes_who_can_pass_up=None):

    do_focus_test = True

    if event is not None and isinstance(event, QG.QWheelEvent):

        do_focus_test = False

    if do_focus_test:

        if not ClientGUIFunctions.TLWIsActive(evt_handler):

            if child_tlw_classes_who_can_pass_up is not None:

                child_tlw_has_focus = ClientGUIFunctions.WidgetOrAnyTLWChildHasFocus(
                    evt_handler) and isinstance(
                        QW.QApplication.activeWindow(),
                        child_tlw_classes_who_can_pass_up)

                if not child_tlw_has_focus:

                    return False

            else:

                return False

    return True
Пример #5
0
 def PausePlay( self ):
     
     self._job_key.PausePlay()
     
     if self._job_key.IsPaused():
         
         ClientGUIFunctions.SetBitmapButtonBitmap( self._pause_button, CC.global_pixmaps().play )
         
     else:
         
         ClientGUIFunctions.SetBitmapButtonBitmap( self._pause_button, CC.global_pixmaps().pause )
Пример #6
0
 def __init__( self, parent, management_controller = None ):
     
     QW.QWidget.__init__( self, parent )
     
     self._management_controller = management_controller
     
     self._sort_type = ( 'system', CC.SORT_FILES_BY_FILESIZE )
     
     self._sort_type_button = ClientGUICommon.BetterButton( self, 'sort', self._SortTypeButtonClick )
     self._sort_order_choice = ClientGUICommon.BetterChoice( self )
     
     type_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._sort_type_button, 14 )
     
     self._sort_type_button.setMinimumWidth( type_width )
     
     asc_width = ClientGUIFunctions.ConvertTextToPixelWidth( self._sort_order_choice, 14 )
     
     self._sort_order_choice.setMinimumWidth( asc_width )
     
     self._sort_order_choice.addItem( '', CC.SORT_ASC )
     
     self._UpdateSortTypeLabel()
     self._UpdateAscLabels()
     
     #
     
     hbox = QP.HBoxLayout( margin = 0 )
     
     QP.AddToLayout( hbox, self._sort_type_button, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._sort_order_choice, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )
     
     HG.client_controller.sub( self, 'ACollectHappened', 'a_collect_happened' )
     HG.client_controller.sub( self, 'BroadcastSort', 'do_page_sort' )
     
     if self._management_controller is not None and self._management_controller.HasVariable( 'media_sort' ):
         
         media_sort = self._management_controller.GetVariable( 'media_sort' )
         
         try:
             
             self.SetSort( media_sort )
             
         except:
             
             default_sort = ClientMedia.MediaSort( ( 'system', CC.SORT_FILES_BY_FILESIZE ), CC.SORT_ASC )
             
             self.SetSort( default_sort )
             
         
     
     self._sort_order_choice.currentIndexChanged.connect( self.EventSortAscChoice )
    def __init__(self, parent, controller, frame_splash_status):

        QW.QWidget.__init__(self, parent)

        self._controller = controller

        self._my_status = frame_splash_status

        self._my_status.SetWindow(self)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(self, 64)

        self.setMinimumWidth(width)

        self.setMaximumWidth(width * 2)

        self._drag_last_pos = None
        self._initial_position = self.parentWidget().pos()

        # this is 124 x 166
        self._hydrus_pixmap = QG.QPixmap(
            os.path.join(HC.STATIC_DIR, 'hydrus_splash.png'))

        self._image_label = QW.QLabel(self)

        self._image_label.setPixmap(self._hydrus_pixmap)

        self._image_label.setAlignment(QC.Qt.AlignCenter)

        self._title_label = ClientGUICommon.BetterStaticText(self, label=' ')
        self._status_label = ClientGUICommon.BetterStaticText(self, label=' ')
        self._status_sub_label = ClientGUICommon.BetterStaticText(self,
                                                                  label=' ')

        self._title_label.setAlignment(QC.Qt.AlignCenter)
        self._status_label.setAlignment(QC.Qt.AlignCenter)
        self._status_sub_label.setAlignment(QC.Qt.AlignCenter)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._image_label, CC.FLAGS_CENTER)
        QP.AddToLayout(vbox, self._title_label, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._status_label, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._status_sub_label,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        margin = ClientGUIFunctions.ConvertTextToPixelWidth(self, 3)

        self._image_label.setMargin(margin)

        self.setLayout(vbox)
    def _OKToAlterUI(self):

        if not QP.isValid(self): return

        main_gui = self.parentWidget()

        # test both because when user uses a shortcut to send gui to a diff monitor, we can't chase it
        # this may need a better test for virtual display dismissal
        not_on_hidden_or_virtual_display = ClientGUIFunctions.MouseIsOnMyDisplay(
            main_gui) or ClientGUIFunctions.MouseIsOnMyDisplay(self)

        main_gui_up = not main_gui.isMinimized()

        return not_on_hidden_or_virtual_display and main_gui_up
    def __init__(self, parent, label):

        ClientGUIScrolledPanels.ResizingScrolledPanel.__init__(self, parent)

        self._commit = ClientGUICommon.BetterButton(self,
                                                    'commit and continue',
                                                    self.parentWidget().done,
                                                    QW.QDialog.Accepted)
        self._commit.setObjectName('HydrusAccept')

        self._back = ClientGUICommon.BetterButton(self, 'go back',
                                                  self.parentWidget().done,
                                                  QW.QDialog.Rejected)

        vbox = QP.VBoxLayout()

        st = ClientGUICommon.BetterStaticText(self, label)

        st.setAlignment(QC.Qt.AlignCenter)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._commit, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        st = ClientGUICommon.BetterStaticText(self, '-or-')

        st.setAlignment(QC.Qt.AlignCenter)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._back, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        ClientGUIFunctions.SetFocusLater(self._commit)
Пример #10
0
 def __init__( self, parent, label ):
     
     ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent )
     
     self._commit = ClientGUICommon.BetterButton( self, 'commit', self.parentWidget().done, QW.QDialog.Accepted )
     self._commit.setObjectName( 'HydrusAccept' )
     
     self._forget = ClientGUICommon.BetterButton( self, 'forget', self.parentWidget().done, QW.QDialog.Rejected )
     self._forget.setObjectName( 'HydrusCancel' )
     
     def cancel_callback( parent ):
         
         parent.SetCancelled( True )
         parent.done( QW.QDialog.Rejected )
         
     
     self._back = ClientGUICommon.BetterButton( self, 'back to filtering', cancel_callback, parent )
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._commit, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._forget, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment( label, self, QC.Qt.AlignVCenter | QC.Qt.AlignHCenter ), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment( '-or-', self, QC.Qt.AlignVCenter | QC.Qt.AlignHCenter ), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._back, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
     
     ClientGUIFunctions.SetFocusLater( self._commit )
    def _HideOtherWindows(self):

        from hydrus.client.gui import ClientGUI

        for tlw in QW.QApplication.topLevelWidgets():

            if isinstance(tlw, ClientGUI.FrameGUI):

                pass

            if tlw == self.window():

                continue

            if not isinstance(tlw, (ClientGUITopLevelWindows.Frame,
                                    ClientGUITopLevelWindows.MainFrame,
                                    ClientGUITopLevelWindows.NewDialog)):

                continue

            if ClientGUIFunctions.IsQtAncestor(self, tlw, through_tlws=True):

                continue

            if isinstance(tlw, ClientGUI.FrameGUI) and not self._hide_main_gui:

                continue

            if not tlw.isVisible() or tlw.isMinimized():

                continue

            tlw.hide()

            self._windows_hidden.append(tlw)
Пример #12
0
    def minimumSizeHint(self):

        width = 0

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        width += self._min_last_section_size

        width += self.frameWidth() * 2

        if self._forced_height_num_chars is None:

            min_num_rows = 4

        else:

            min_num_rows = self._forced_height_num_chars

        # + 2 for header and * 1.25 for magic
        (width_gumpf, height) = ClientGUIFunctions.ConvertTextToPixels(
            self, (20, int((min_num_rows + 2) * 1.25)))

        min_size_hint = QC.QSize(width, height)

        return min_size_hint
    def _DoDebugHide(self):

        if not QP.isValid(self): return

        parent = self.parentWidget()

        possibly_on_hidden_virtual_desktop = not ClientGUIFunctions.MouseIsOnMyDisplay(
            parent)

        going_to_bug_out_at_hide_or_show = possibly_on_hidden_virtual_desktop

        new_options = HG.client_controller.new_options

        if new_options.GetBoolean('hide_message_manager_on_gui_iconise'
                                  ) and not self._DisplayingError():

            if parent.isMinimized():

                self.hide()

                return

        current_focus_tlw = QW.QApplication.activeWindow()

        main_gui_is_active = current_focus_tlw in (self, parent)

        if new_options.GetBoolean('hide_message_manager_on_gui_deactive'
                                  ) and not self._DisplayingError():

            if not main_gui_is_active:

                if not going_to_bug_out_at_hide_or_show:

                    self.hide()
Пример #14
0
        def __init__(self, parent, predicate_panel_class, predicate):

            QW.QWidget.__init__(self, parent)

            self._defaults_button = ClientGUICommon.BetterBitmapButton(
                self,
                CC.global_pixmaps().star, self._DefaultsMenu)
            self._defaults_button.setToolTip('Set a new default.')

            self._predicate_panel = predicate_panel_class(self, predicate)
            self._parent = parent

            self._ok = QW.QPushButton('ok', self)
            self._ok.clicked.connect(self._DoOK)
            self._ok.setObjectName('HydrusAccept')

            hbox = QP.HBoxLayout()

            QP.AddToLayout(hbox, self._defaults_button,
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox, self._predicate_panel,
                           CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
            QP.AddToLayout(hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)

            self.setLayout(hbox)

            ClientGUIFunctions.SetFocusLater(self._ok)
Пример #15
0
    def sizeHint(self):

        width = 0

        width += self.frameWidth() * 2

        # all but last column

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        #

        # ok, we are going full slippery dippery doo now
        # the issue is: when we first boot up, we want to give a 'hey, it would be nice' size of the last actual recorded final column
        # HOWEVER, after that: we want to use the current size of the last column
        # so, if it is the first couple of seconds, lmao. after that, oaml
        # I later updated this to use the columnWidth, rather than hickery dickery text-to-pixel-width, since it was juddering resize around text width phase

        last_column_type = self._column_list_status.GetColumnTypes()[-1]

        if HydrusData.TimeHasPassed(self._creation_time + 2):

            width += self.columnWidth(self.columnCount() - 1)

            # this is a hack to stop the thing suddenly growing to screen width in a weird resize loop
            # I couldn't reproduce this error, so I assume it is a QSS or whatever font/style/scrollbar on some systems that caused inaccurate columnWidth result
            width = min(width, self.width())

        else:

            last_column_chars = self._original_column_list_status.GetColumnWidth(
                last_column_type)

            main_tlw = HG.client_controller.GetMainTLW()

            width += ClientGUIFunctions.ConvertTextToPixelWidth(
                main_tlw, last_column_chars)

        #

        if self._forced_height_num_chars is None:

            num_rows = self._initial_height_num_chars

        else:

            num_rows = self._forced_height_num_chars

        header_size = self.header().sizeHint()

        data_area_height = self._GetRowHeightEstimate() * num_rows

        PADDING = 10

        size_hint = QC.QSize(width,
                             header_size.height() + data_area_height + PADDING)

        return size_hint
Пример #16
0
 def __init__( self, parent, message, yes_label = 'yes', no_label = 'no' ):
     
     ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent )
     
     self._yes = ClientGUICommon.BetterButton( self, yes_label, self.parentWidget().done, QW.QDialog.Accepted )
     self._yes.setObjectName( 'HydrusAccept' )
     self._yes.setText( yes_label )
     
     self._no = ClientGUICommon.BetterButton( self, no_label, self.parentWidget().done, QW.QDialog.Rejected )
     self._no.setObjectName( 'HydrusCancel' )
     self._no.setText( no_label )
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._yes )
     QP.AddToLayout( hbox, self._no )
     
     vbox = QP.VBoxLayout()
     
     text = ClientGUICommon.BetterStaticText( self, message )
     text.setWordWrap( True )
     
     QP.AddToLayout( vbox, text )
     QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT )
     
     self.widget().setLayout( vbox )
     
     ClientGUIFunctions.SetFocusLater( self._yes )
Пример #17
0
 def __init__( self, parent: QW.QWidget, service_key: bytes, accounts: typing.Collection[ HydrusNetwork.Account ] ):
     
     ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )
     
     self._service_key = service_key
     self._service = HG.client_controller.services_manager.GetService( self._service_key )
     self._accounts = accounts
     
     self._accounts_box = ClientGUICommon.StaticBox( self, 'accounts' )
     
     self._account_list = ClientGUIListBoxes.BetterQListWidget( self._accounts_box )
     self._account_list.setSelectionMode( QW.QListWidget.ExtendedSelection )
     
     ( min_width, min_height ) = ClientGUIFunctions.ConvertTextToPixels( self._account_list, ( 74, 16 ) )
     
     self._account_list.setMinimumSize( min_width, min_height )
     
     modify_button = ClientGUICommon.BetterButton( self._accounts_box, 'modify selected', self._ModifyAccounts )
     
     #
     
     my_admin_account_key = self._service.GetAccount().GetAccountKey()
     
     accounts.sort( key = lambda a: ( a.GetAccountType().GetTitle(), a.GetAccountKey().hex() ) )
     
     for account in accounts:
         
         item = QW.QListWidgetItem()
         
         account_key = account.GetAccountKey()
         
         text = account.GetSingleLineTitle()
         
         if account_key == my_admin_account_key:
             
             text = 'THIS IS YOU: {}'.format( text )
             
         
         item.setText( text )
         
         item.setData( QC.Qt.UserRole, account )
         
         self._account_list.addItem( item )
         
     
     #
     
     self._accounts_box.Add( self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, modify_button, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
     
     #
     
     self._account_list.itemDoubleClicked.connect( self._ModifyAccounts )
Пример #18
0
def LoadFromQtImage( qt_image: QG.QImage ):
    
    # assume this for now
    depth = 3
    
    numpy_image = ClientGUIFunctions.ConvertQtImageToNumPy( qt_image )
    
    return LoadFromNumPyImage( numpy_image )
Пример #19
0
    def sizeHint(self):

        # still have an issue here where if the list gets populated with a bunch of stuff and hence gets a vertical scrollbar, it doesn't account for that
        # something like change this to viewportSizehint and/or doing updateGeometry on add data, if that isn't already done when scrollbars added?

        width = 0

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        #

        # we use the last value saved to options for this column. not what it currently is, but what user saw last
        # this might be from a few milliseconds ago, or last time dialog was open. main thing is this is a _sensible_ value for this column, to inform panels and so on

        last_column_type = self._column_list_status.GetColumnTypes()[-1]

        last_column_chars = self._column_list_status.GetColumnWidth(
            last_column_type)

        main_tlw = HG.client_controller.GetMainTLW()

        width += ClientGUIFunctions.ConvertTextToPixelWidth(
            main_tlw, last_column_chars)

        #

        width += self.frameWidth() * 2

        if self._forced_height_num_chars is None:

            num_rows = self._initial_height_num_chars

        else:

            num_rows = self._forced_height_num_chars

        # + 2 for header and * 1.25 for magic
        (width_gumpf, height) = ClientGUIFunctions.ConvertTextToPixels(
            self, (20, int((num_rows + 2) * 1.25)))

        size_hint = QC.QSize(width, height)

        return size_hint
Пример #20
0
 def GrowShrinkColumnsHeight( self, ideal_rows ):
     
     # +2 for the header row and * 1.25 for magic rough text-to-rowheight conversion
     
     existing_min_width = self.minimumWidth()
     
     ( width_gumpf, ideal_client_height ) = ClientGUIFunctions.ConvertTextToPixels( self, ( 20, int( ( ideal_rows + 2 ) * 1.25 ) ) )
     
     QP.SetMinClientSize( self, ( existing_min_width, ideal_client_height ) )
Пример #21
0
    def __init__(self,
                 parent,
                 message,
                 title='Are you sure?',
                 yes_tuples=None,
                 no_label='no'):

        if yes_tuples is None:

            yes_tuples = [('yes', 'yes')]

        Dialog.__init__(self, parent, title, position='center')

        self._value = None

        yes_buttons = []

        for (label, data) in yes_tuples:

            yes_button = ClientGUICommon.BetterButton(self, label, self._DoYes,
                                                      data)
            yes_button.setObjectName('HydrusAccept')

            yes_buttons.append(yes_button)

        self._no = ClientGUICommon.BetterButton(self, no_label, self.done,
                                                QW.QDialog.Rejected)
        self._no.setObjectName('HydrusCancel')

        #

        hbox = QP.HBoxLayout()

        for yes_button in yes_buttons:

            QP.AddToLayout(hbox, yes_button, CC.FLAGS_CENTER_PERPENDICULAR)

        QP.AddToLayout(hbox, self._no, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        text = ClientGUICommon.BetterStaticText(self, message)
        text.setWordWrap(True)

        QP.AddToLayout(vbox, text, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 250))

        QP.SetInitialSize(self, size_hint)

        ClientGUIFunctions.SetFocusLater(yes_buttons[0])
    def sizeHint(self):

        width = 0

        # all but last column

        for i in range(self.columnCount() - 1):

            width += self.columnWidth(i)

        #

        # ok, we are going full slippery dippery doo now
        # the issue is: when we first boot up, we want to give a 'hey, it would be nice' size of the last actual recorded final column
        # HOWEVER, after that: we want to use the current size of the last column
        # so, if it is the first couple of seconds, lmao. after that, oaml

        last_column_type = self._column_list_status.GetColumnTypes()[-1]

        if HydrusData.TimeHasPassed(self._creation_time + 2):

            last_column_chars = self._column_list_status.GetColumnWidth(
                last_column_type)

        else:

            last_column_chars = self._original_column_list_status.GetColumnWidth(
                last_column_type)

        main_tlw = HG.client_controller.GetMainTLW()

        width += ClientGUIFunctions.ConvertTextToPixelWidth(
            main_tlw, last_column_chars)

        #

        width += self.frameWidth() * 2

        if self._forced_height_num_chars is None:

            num_rows = self._initial_height_num_chars

        else:

            num_rows = self._forced_height_num_chars

        header_size = self.header().sizeHint()

        data_area_height = self._GetRowHeightEstimate() * num_rows

        PADDING = 10

        size_hint = QC.QSize(width,
                             header_size.height() + data_area_height + PADDING)

        return size_hint
Пример #23
0
    def _GenerateCurrentStatus(self) -> ClientGUIListStatus.ColumnListStatus:

        status = ClientGUIListStatus.ColumnListStatus()

        status.SetColumnListType(self._column_list_type)

        main_tlw = HG.client_controller.GetMainTLW()

        columns = []

        header = self.header()

        num_columns = header.count()

        last_column_index = num_columns - 1

        # ok, the big pain in the ass situation here is getting a precise last column size that is reproduced on next dialog launch
        # ultimately, with fuzzy sizing, style padding, scrollbars appearing, and other weirdness, the more precisely we try to define it, the more we will get dialogs that grow/shrink by a pixel each time
        # *therefore*, the actual solution here is to move to snapping with a decent snap distance. the user loses size setting precision, but we'll snap back to a decent size every time, compensating for fuzz

        LAST_COLUMN_SNAP_DISTANCE_CHARS = 5

        for visual_index in range(num_columns):

            logical_index = header.logicalIndex(visual_index)

            column_type = self.headerItem().data(logical_index, QC.Qt.UserRole)
            width_pixels = header.sectionSize(logical_index)
            shown = not header.isSectionHidden(logical_index)

            if visual_index == last_column_index:

                if self.verticalScrollBar().isVisible():

                    width_pixels += max(
                        0, min(self.verticalScrollBar().width(), 20))

            width_chars = ClientGUIFunctions.ConvertPixelsToTextWidth(
                main_tlw, width_pixels)

            if visual_index == last_column_index:

                # here's the snap magic
                width_chars = round(
                    width_chars // LAST_COLUMN_SNAP_DISTANCE_CHARS
                ) * LAST_COLUMN_SNAP_DISTANCE_CHARS

            columns.append((column_type, width_chars, shown))

        status.SetColumns(columns)

        status.SetSort(self._sort_column_type, self._sort_asc)

        return status
Пример #24
0
    def _GetRowHeightEstimate(self):

        if self.topLevelItemCount() > 0:

            height = self.rowHeight(self.indexFromItem(self.topLevelItem(0)))

        else:

            (width_gumpf,
             height) = ClientGUIFunctions.ConvertTextToPixels(self, (20, 1))

        return height
    def SetInitialSize(self, size: QC.QSize):

        display_size = ClientGUIFunctions.GetDisplaySize(self)

        width = min(display_size.width(), size.width())
        height = min(display_size.height(), size.height())

        self.resize(QC.QSize(width, height))

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

        self.setMinimumSize(QC.QSize(min_width, min_height))
Пример #26
0
 def __init__( self, parent, management_controller = None, silent = False ):
     
     QW.QWidget.__init__( self, parent )
     
     # this is trash, rewrite it to deal with the media_collect object, not the management controller
     
     self._management_controller = management_controller
     
     if self._management_controller is not None and self._management_controller.HasVariable( 'media_collect' ):
         
         self._media_collect = self._management_controller.GetVariable( 'media_collect' )
         
     else:
         
         self._media_collect = HG.client_controller.new_options.GetDefaultCollect()
         
     
     self._silent = silent
     
     self._collect_comboctrl = QP.CollectComboCtrl( self, self._media_collect )
     
     self._collect_unmatched = ClientGUICommon.BetterChoice( self )
     
     width = ClientGUIFunctions.ConvertTextToPixelWidth( self._collect_unmatched, 19 )
     
     self._collect_unmatched.setMinimumWidth( width )
     
     self._collect_unmatched.addItem( 'collect unmatched', True )
     self._collect_unmatched.addItem( 'leave unmatched', False )
     
     #
     
     self._collect_unmatched.SetValue( self._media_collect.collect_unmatched )
     
     #
     
     hbox = QP.HBoxLayout( margin = 0 )
     
     QP.AddToLayout( hbox, self._collect_comboctrl, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._collect_unmatched, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )
     
     #
     
     self._UpdateLabel()
     
     self._collect_unmatched.currentIndexChanged.connect( self.CollectValuesChanged )
     self._collect_comboctrl.itemChanged.connect( self.CollectValuesChanged )
     
     HG.client_controller.sub( self, 'SetCollectFromPage', 'set_page_collect' )
Пример #27
0
    def __init__(self, parent: QW.QWidget, predicate: ClientSearch.Predicate):

        QW.QWidget.__init__(self, parent)

        from hydrus.client.gui.search import ClientGUIACDropdown

        if predicate.GetType() != ClientSearch.PREDICATE_TYPE_OR_CONTAINER:

            raise Exception(
                'Launched an ORPredicateControl without an OR Pred!')

        predicates = predicate.GetValue()

        page_key = HydrusData.GenerateKey()

        location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext(
        )

        file_search_context = ClientSearch.FileSearchContext(
            location_context=location_context, predicates=predicates)

        self._search_control = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self,
            page_key,
            file_search_context,
            hide_favourites_edit_actions=True)

        self._search_control.setMinimumWidth(
            ClientGUIFunctions.ConvertTextToPixelWidth(self._search_control,
                                                       64))

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._search_control, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        ClientGUIFunctions.SetFocusLater(self._search_control)
Пример #28
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
Пример #29
0
    def _OKToAlterUI( self ):

        if not QP.isValid( self ): return
        
        main_gui = self.parentWidget()
        
        gui_is_hidden = not main_gui.isVisible()
        
        if gui_is_hidden:
            
            return False
            
        
        if HG.client_controller.new_options.GetBoolean( 'freeze_message_manager_when_mouse_on_other_monitor' ):
            
            # test both because when user uses a shortcut to send gui to a diff monitor, we can't chase it
            # this may need a better test for virtual display dismissal
            # this is also a proxy for hidden/virtual displays, which is really what it is going on about
            on_my_monitor = ClientGUIFunctions.MouseIsOnMyDisplay( main_gui ) or ClientGUIFunctions.MouseIsOnMyDisplay( self )
            
            if not on_my_monitor:
                
                return False
                
            
        
        if HG.client_controller.new_options.GetBoolean( 'freeze_message_manager_when_main_gui_minimised' ):
            
            main_gui_up = not main_gui.isMinimized()
            
            if not main_gui_up:
                
                return False
                
            
        
        return True
 def keyPressEvent( self, event ):
     
     ( modifier, key ) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple( event )
     
     current_focus = QW.QApplication.focusWidget()
     
     event_from_us = current_focus is not None and ClientGUIFunctions.IsQtAncestor( current_focus, self )
     
     if event_from_us and key == QC.Qt.Key_Escape:
         
         self._TryEndModal( QW.QDialog.Rejected )
         
     else:
         
         QP.Dialog.keyPressEvent( self, event )