def get_file_name(fp) -> Tuple[str, RText]: name = os.path.basename(fp) name_text = RText(name) if source.has_permission( PermissionLevel.PHYSICAL_SERVER_CONTROL_LEVEL): name_text.h(fp) return name, name_text
def get_suggestion_text(value: str): text = RText(value, VALUE_COLOR).c( RAction.suggest_command, '{} preference {} set {}'.format(self.control_command_prefix, pref_name, value)) hover_text = RTextList( self.tr('mcdr_command.preference.item.set_suggestion_hint', RText(pref_name, PREF_COLOR), RText(value, VALUE_COLOR))) styles: List[RStyle] = [] extra_descriptions: List[RTextBase] = [] if value == current_value: styles.append(RStyle.underlined) extra_descriptions.append( self.tr('mcdr_command.preference.item.current').set_color( RColor.gray)) if value == default_value: styles.append(RStyle.bold) extra_descriptions.append( self.tr('mcdr_command.preference.item.default').set_color( RColor.gray)) if len(extra_descriptions) > 0: hover_text.append( RTextList( '\n', RText.join(RText(', ', RColor.dark_gray), extra_descriptions))) text.set_styles(styles) return text.h(hover_text)