def AppendMenuCheckItem(menu, label, description, initial_value, callable, *args, **kwargs): label = SanitiseLabel(label) menu_item = QW.QAction(menu) if HC.PLATFORM_MACOS: menu_item.setMenuRole(QW.QAction.ApplicationSpecificRole) menu_item.setText(HydrusText.ElideText(label, 128, elide_center=True)) menu_item.setStatusTip(description) menu_item.setToolTip(description) menu_item.setWhatsThis(description) menu_item.setCheckable(True) menu_item.setChecked(initial_value) menu.addAction(menu_item) BindMenuItem(menu_item, callable, *args, **kwargs) return menu_item
def AppendMenuItem(menu, label, description, callable, *args, **kwargs): label = SanitiseLabel(label) menu_item = QW.QAction(menu) if HC.PLATFORM_MACOS: menu_item.setMenuRole(QW.QAction.ApplicationSpecificRole) elided_label = HydrusText.ElideText(label, 128, elide_center=True) menu_item.setText(elided_label) if elided_label != label: menu_item.setToolTip(label) else: menu_item.setToolTip(description) menu_item.setStatusTip(description) menu_item.setWhatsThis(description) menu.addAction(menu_item) BindMenuItem(menu_item, callable, *args, **kwargs) return menu_item
def AppendMenuLabel(menu, label, description=''): original_label_text = label label = SanitiseLabel(label) if description is None: description = '' menu_item = QW.QAction(menu) if HC.PLATFORM_MACOS: menu_item.setMenuRole(QW.QAction.ApplicationSpecificRole) menu_item.setText(HydrusText.ElideText(label, 128, elide_center=True)) menu_item.setStatusTip(description) menu_item.setToolTip(description) menu_item.setWhatsThis(description) menu.addAction(menu_item) BindMenuItem(menu_item, HG.client_controller.pub, 'clipboard', 'text', original_label_text) return menu_item
def GetTextSizeFromPainter(painter: QG.QPainter, text: str): try: text_size = painter.fontMetrics().size(QC.Qt.TextSingleLine, text) except ValueError: from hydrus.client.metadata import ClientTags if not ClientTags.have_shown_invalid_tag_warning: from hydrus.core import HydrusData HydrusData.ShowText( 'Hey, I think hydrus stumbled across an invalid tag! Please run _database->check and repair->fix invalid tags_ immediately, or you may get errors!' ) bad_text = repr(text) bad_text = HydrusText.ElideText(bad_text, 24) HydrusData.ShowText('The bad text was: {}'.format(bad_text)) ClientTags.have_shown_invalid_tag_warning = True text = '*****INVALID, UNDISPLAYABLE TAG, RUN DATABASE REPAIR NOW*****' text_size = painter.fontMetrics().size(QC.Qt.TextSingleLine, text) return (text_size, text)
def _UpdateLabel( self ): label = self._string_converter.ToString() self.setToolTip( label ) elided_label = HydrusText.ElideText( label, 64 ) self.setText( elided_label )
def _UpdateLabel( self ): statements = self._string_processor.GetProcessingStrings() if len( statements ) == 0: label = self._string_processor.ToString() else: statements = [ HydrusText.ElideText( statement, 64 ) for statement in statements ] label = os.linesep.join( statements ) self.setText( label )
def AppendMenuBitmapItem(menu, label, description, bitmap, callable, *args, **kwargs): label = SanitiseLabel(label) menu_item = QW.QAction(menu) if HC.PLATFORM_MACOS: menu_item.setMenuRole(QW.QAction.ApplicationSpecificRole) menu_item.setText(HydrusText.ElideText(label, 64, elide_center=True)) menu_item.setStatusTip(description) menu_item.setToolTip(description) menu_item.setWhatsThis(description) menu_item.setIcon(QG.QIcon(bitmap)) menu.addAction(menu_item) BindMenuItem(menu_item, callable, *args, **kwargs) return menu_item