Bookshelf: add option to write the texts up to down

This commit is contained in:
un-pogaz 2026-01-02 20:31:48 +01:00
parent f0ec227141
commit 69b01f5962
4 changed files with 15 additions and 3 deletions

View File

@ -497,6 +497,7 @@ def create_defs():
defs['bookshelf_variable_height'] = True
defs['bookshelf_fade_time'] = 400
defs['bookshelf_hover'] = 'shift'
defs['bookshelf_up_to_down'] = False
# Migrate beta bookshelf_thumbnail
if isinstance(btv := gprefs.get('bookshelf_thumbnail'), bool):

View File

@ -1726,6 +1726,9 @@ class BookshelfView(MomentumScrollMixin, QAbstractScrollArea):
painter.save()
rotate()
if gprefs['bookshelf_up_to_down']:
painter.rotate(180)
text_rect.adjust(max(0, line_rect.width() - 6), 0, 0, 0)
painter.setFont(font)
painter.drawText(text_rect, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter, elided_text)
painter.restore()
@ -1798,7 +1801,7 @@ class BookshelfView(MomentumScrollMixin, QAbstractScrollArea):
return
painter.save()
painter.translate(rect.left() + rect.width() // 2, rect.top() + rect.height() // 2)
painter.rotate(-90)
painter.rotate(90 if gprefs['bookshelf_up_to_down'] else -90)
# Determine text color based on spine background brightness
text_color = self.get_contrasting_text_color(spine_color)

View File

@ -31,6 +31,7 @@ class BookshelfTab(QTabWidget, LazyConfigWidgetBase, Ui_Form):
r('bookshelf_shadow', gprefs)
r('bookshelf_variable_height', gprefs)
r('bookshelf_fade_time', gprefs)
r('bookshelf_up_to_down', gprefs)
r('bookshelf_thumbnail', gprefs, choices=[
(_('Full'), 'full'),

View File

@ -51,7 +51,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_bookshelf_thumbnail">
<property name="text">
<string>Cover &amp;thumbnail on the spines:</string>
@ -61,7 +61,7 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="10" column="1">
<widget class="QComboBox" name="opt_bookshelf_thumbnail"/>
</item>
<item row="0" column="1">
@ -78,6 +78,13 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="opt_bookshelf_up_to_down">
<property name="text">
<string>&amp;Write the texts up to down</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="label_fade_time">
<property name="text">