Allow using relative units for cover rounding

This commit is contained in:
Kovid Goyal 2024-05-23 21:35:23 +05:30
parent 075fbe767b
commit 1ba634a1ad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 167 additions and 157 deletions

View File

@ -429,6 +429,7 @@ def create_defs():
defs['cover_grid_show_title'] = False
defs['cover_grid_texture'] = None
defs['cover_corner_radius'] = 0
defs['cover_corner_radius_unit'] = 'px'
defs['show_vl_tabs'] = False
defs['vl_tabs_closable'] = True
defs['show_highlight_toggle_button'] = False
@ -1766,7 +1767,7 @@ def clip_border_radius(painter, rect):
r = gprefs['cover_corner_radius']
if r > 0:
pp = QPainterPath()
pp.addRoundedRect(QRectF(rect), r, r)
pp.addRoundedRect(QRectF(rect), r, r, Qt.SizeMode.RelativeSize if gprefs['cover_corner_radius_unit'] == '%' else Qt.SizeMode.AbsoluteSize)
painter.setClipPath(pp)
try:
yield

View File

@ -626,6 +626,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('bd_show_cover', gprefs)
r('bd_overlay_cover_size', gprefs)
r('cover_corner_radius', gprefs)
r('cover_corner_radius_unit', gprefs, choices=[(_('Pixels'), 'px'), (_('Percentage'), '%')])
r('cover_grid_width', gprefs)
r('cover_grid_height', gprefs)
r('cover_grid_cache_size_multiple', gprefs)

View File

@ -27,7 +27,34 @@
<attribute name="title">
<string>&amp;Main interface</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_widget_style">
<property name="text">
<string>User interface style (&amp;needs restart):</string>
</property>
<property name="buddy">
<cstring>opt_ui_style</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="opt_ui_style"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="icon_theme">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="icon_theme_button">
<property name="text">
<string>Change &amp;icon theme</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="opt_color_palette_label">
<property name="text">
@ -38,78 +65,13 @@
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QCheckBox" name="opt_show_splash_screen">
<property name="text">
<string>Show the &amp;splash screen at startup</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable s&amp;ystem tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="opt_row_numbers_in_book_list">
<property name="text">
<string>Show &amp;row numbers in the book list</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Choose &amp;language (needs restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="2" column="1">
<widget class="QPushButton" name="button_adjust_colors">
<property name="text">
<string>Adjust &amp;colors</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QCheckBox" name="opt_disable_animations">
<property name="toolTip">
<string>Disable all animations. Useful if you have a slow/old computer.</string>
</property>
<property name="text">
<string>Disable &amp;animations</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="3">
<widget class="QCheckBox" name="opt_booklist_grid">
<property name="text">
<string>Draw a &amp;grid in the book list</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="icon_theme">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
@ -120,7 +82,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="3" column="1">
<widget class="QComboBox" name="opt_gui_layout">
<property name="maximumSize">
<size>
@ -136,17 +98,102 @@
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QCheckBox" name="opt_show_layout_buttons">
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Show &amp;layout buttons in the status bar</string>
<string>Choose &amp;language (needs restart):</string>
</property>
<property name="buddy">
<cstring>opt_language</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="icon_theme_button">
<item row="4" column="1">
<widget class="QComboBox" name="opt_language">
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
<property name="minimumContentsLength">
<number>20</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Change &amp;icon theme</string>
<string>&amp;Round the corners of covers:</string>
</property>
<property name="buddy">
<cstring>opt_cover_corner_radius</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSpinBox" name="opt_cover_corner_radius">
<property name="toolTip">
<string>Round the corners of covers in many places they are displayed such as the Cover grid, Book details panel, etc. Adjust the amount of rounding with this setting. A value of between 5 and 10 looks good with most covers sizes. Zero disables rounding and is the default.</string>
</property>
<property name="specialValueText">
<string>no rounding</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="opt_cover_corner_radius_unit">
<property name="toolTip">
<string>The unit for the cover corner rounding. Either pixel values or as a percetage of the cover size.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="opt_systray_icon">
<property name="text">
<string>Enable s&amp;ystem tray icon (needs restart)</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="opt_disable_animations">
<property name="toolTip">
<string>Disable all animations. Useful if you have a slow/old computer.</string>
</property>
<property name="text">
<string>Disable &amp;animations</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_disable_tray_notification">
<property name="toolTip">
<string>Disable popup notifications when calibre completes jobs such a conversion, sending to device etc. The notifications are sent via the operating system notification facility, if available. Note that on Windows, you have to enable the system tray icon for notifications to work.</string>
</property>
<property name="text">
<string>Disable n&amp;otifications on job completion</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="opt_show_splash_screen">
<property name="text">
<string>Show the &amp;splash screen at startup</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="opt_book_list_tooltips">
<property name="text">
<string>Show &amp;tooltips in the book list</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="opt_show_layout_buttons">
<property name="text">
<string>Show &amp;layout buttons in the status bar</string>
</property>
</widget>
</item>
@ -171,17 +218,14 @@
</item>
</layout>
</item>
<item row="9" column="2">
<item row="9" column="1">
<widget class="QPushButton" name="change_font_button">
<property name="text">
<string>Change &amp;font (needs restart)</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="opt_ui_style"/>
</item>
<item row="10" column="0" colspan="3">
<item row="10" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Toolbar</string>
@ -223,6 +267,47 @@
</layout>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>E&amp;xtra spacing to add between rows in the book list (can be negative):</string>
</property>
<property name="buddy">
<cstring>opt_book_list_extra_row_spacing</cstring>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QSpinBox" name="opt_book_list_extra_row_spacing">
<property name="suffix">
<string> px</string>
</property>
<property name="minimum">
<number>-20</number>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QCheckBox" name="opt_row_numbers_in_book_list">
<property name="text">
<string>Show &amp;row numbers in the book list</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QCheckBox" name="opt_booklist_grid">
<property name="text">
<string>Draw a &amp;grid in the book list</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="opt_dnd_merge">
<property name="text">
<string>Allow using &amp;drag and drop to merge books</string>
</property>
</widget>
</item>
<item row="15" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
@ -236,83 +321,6 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_widget_style">
<property name="text">
<string>User interface style (&amp;needs restart):</string>
</property>
<property name="buddy">
<cstring>opt_ui_style</cstring>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QSpinBox" name="opt_book_list_extra_row_spacing">
<property name="suffix">
<string> px</string>
</property>
<property name="minimum">
<number>-20</number>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="opt_dnd_merge">
<property name="text">
<string>Allow using &amp;drag and drop to merge books</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_disable_tray_notification">
<property name="toolTip">
<string>Disable popup notifications when calibre completes jobs such a conversion, sending to device etc. The notifications are sent via the operating system notification facility, if available. Note that on Windows, you have to enable the system tray icon for notifications to work.</string>
</property>
<property name="text">
<string>Disable n&amp;otifications on job completion</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="opt_book_list_tooltips">
<property name="text">
<string>Show &amp;tooltips in the book list</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>E&amp;xtra spacing to add between rows in the book list (can be negative):</string>
</property>
<property name="buddy">
<cstring>opt_book_list_extra_row_spacing</cstring>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Round the corners of covers:</string>
</property>
<property name="buddy">
<cstring>opt_cover_corner_radius</cstring>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QSpinBox" name="opt_cover_corner_radius">
<property name="toolTip">
<string>Round the corners of covers in many places they are displayed such as the Cover grid, Book details panel, etc. Adjust the amount of rounding with this setting. A value of between 5 and 10 looks good with most covers sizes. Zero disables rounding and is the default.</string>
</property>
<property name="specialValueText">
<string>no rounding</string>
</property>
<property name="suffix">
<string> px</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QTabWidget" name="cover_grid_tab">