Use averageCharWidth instead of 'n's

This commit is contained in:
Charles Haley 2020-10-17 09:48:27 +01:00
parent 638a017fb1
commit 8ada8a8e6b
2 changed files with 11 additions and 10 deletions

View File

@ -404,6 +404,13 @@ metadata_single_use_2_cols_for_custom_fields = True
# metadata_edit_custom_column_order = ['#genre', '#mytags', '#etc'] # metadata_edit_custom_column_order = ['#genre', '#mytags', '#etc']
metadata_edit_custom_column_order = [] metadata_edit_custom_column_order = []
#: Edit metadata custom column label width
# Set the width of custom column labels shown in the edit metadata dialogs.
# Labels longer than this length will be elided. The width is computed by
# multiplying the average width of characters in the font by the number provided.
metadata_edit_bulk_cc_label_width = 25
metadata_edit_single_cc_label_width = 12
#: The number of seconds to wait before sending emails #: The number of seconds to wait before sending emails
# The number of seconds to wait before sending emails when using a # The number of seconds to wait before sending emails when using a
# public email server like GMX/Hotmail/Gmail. Default is: 5 minutes # public email server like GMX/Hotmail/Gmail. Default is: 5 minutes
@ -543,9 +550,3 @@ exclude_fields_on_paste = []
# Useful if for some reason your operating systems network checking # Useful if for some reason your operating systems network checking
# facilities are not reliable (for example NetworkManager on Linux). # facilities are not reliable (for example NetworkManager on Linux).
skip_network_check = False skip_network_check = False
#: Edit metadata custom column label width
# Set the width of custom column labels shown in the edit metadata dialogs.
# Labels longer than this length will be elided. The length is in 'n'self
metadata_edit_bulk_cc_label_length = 25
metadata_edit_single_cc_label_length = 10

View File

@ -788,11 +788,11 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
if label_width == 0: if label_width == 0:
font_metrics = wij.fontMetrics() font_metrics = wij.fontMetrics()
if bulk: if bulk:
label_width = font_metrics.width('n' * label_width = (font_metrics.averageCharWidth() *
tweaks['metadata_edit_bulk_cc_label_length']) tweaks['metadata_edit_bulk_cc_label_length'])
else: else:
label_width = font_metrics.width('n' * label_width = (font_metrics.averageCharWidth() *
tweaks['metadata_edit_single_cc_label_length']) tweaks['metadata_edit_single_cc_label_length'])
wij.setMaximumWidth(label_width) wij.setMaximumWidth(label_width)
if c == 0: if c == 0:
wij.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) wij.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)