diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py
index 167aac5187..ceca0a6680 100644
--- a/resources/default_tweaks.py
+++ b/resources/default_tweaks.py
@@ -428,26 +428,6 @@ vertical_scrolling_per_row = False
# Example: locale_for_sorting = 'nb' -- sort using Norwegian rules.
locale_for_sorting = ''
-#: Number of columns for custom metadata in the edit metadata dialog
-# Set whether to use one or two columns for custom metadata when editing
-# metadata one book at a time. If True, then the fields are laid out using two
-# columns. If False, one column is used.
-metadata_single_use_2_cols_for_custom_fields = True
-
-#: Edit metadata custom column label width and elision point
-# Set the width of custom column labels shown in the edit metadata dialogs.
-# If metadata_edit_elide_labels is True then labels wider than the width
-# will be elided, otherwise they will be word wrapped. The maximum width is
-# computed by multiplying the average width of characters in the font by the
-# appropriate number.
-# Set the elision point to 'middle' to put the ellipsis (…) in the middle of
-# the label, 'right' to put it at the right end of the label, and 'left' to
-# put it at the left end.
-metadata_edit_elide_labels = True
-metadata_edit_bulk_cc_label_length = 25
-metadata_edit_single_cc_label_length = 12
-metadata_edit_elision_point = 'right'
-
#: The number of seconds to wait before sending emails
# The number of seconds to wait before sending emails when using a
# public email server like GMX/Hotmail/Gmail. Default is: 5 minutes
diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py
index 4bcf3db57a..6094b6c5c0 100644
--- a/src/calibre/gui2/__init__.py
+++ b/src/calibre/gui2/__init__.py
@@ -31,6 +31,7 @@ from calibre.gui2.linux_file_dialogs import (
)
from calibre.gui2.qt_file_dialogs import FileDialog
from calibre.ptempfile import base_dir
+from calibre.utils.config_base import tweaks
from calibre.utils.config import Config, ConfigProxy, JSONConfig, dynamic
from calibre.utils.date import UNDEFINED_DATE
from calibre.utils.file_type_icons import EXT_MAP
@@ -204,6 +205,28 @@ def create_defs():
defs['browse_annots_use_stemmer'] = True
defs['annots_export_format'] = 'txt'
defs['books_autoscroll_time'] = 2.0
+ defs['edit_metadata_single_use_2_cols_for_custom_fields'] = True
+ defs['edit_metadata_elide_labels'] = True
+ defs['edit_metadata_elision_point'] = "right"
+ defs['edit_metadata_bulk_cc_label_length'] = 25
+ defs['edit_metadata_single_cc_label_length'] = 12
+
+ def migrate_tweak(tweak_name, pref_name):
+ # If the tweak has been changed then leave the tweak in the file so
+ # that the user can bounce between versions with and without the
+ # migration. For versions before the migration the tweak wins. For
+ # versions after the migration any changes win.
+ v = tweaks.get(tweak_name, None)
+ migrated_tweak_name = pref_name + '_tweak_migrated'
+ m = gprefs.get(migrated_tweak_name, None)
+ if m is None and v is not None:
+ gprefs[pref_name] = v
+ gprefs[migrated_tweak_name] = True
+ migrate_tweak('metadata_edit_elide_labels', 'edit_metadata_elide_labels')
+ migrate_tweak('metadata_edit_elision_point', 'edit_metadata_elision_point')
+ migrate_tweak('metadata_edit_bulk_cc_label_length', 'edit_metadata_bulk_cc_label_length')
+ migrate_tweak('metadata_edit_single_cc_label_length', 'edit_metadata_single_cc_label_length')
+ migrate_tweak('metadata_single_use_2_cols_for_custom_fields', 'edit_metadata_single_use_2_cols_for_custom_fields')
create_defs()
diff --git a/src/calibre/gui2/custom_column_widgets.py b/src/calibre/gui2/custom_column_widgets.py
index 273a6c5973..df0adbae45 100644
--- a/src/calibre/gui2/custom_column_widgets.py
+++ b/src/calibre/gui2/custom_column_widgets.py
@@ -17,7 +17,7 @@ from qt.core import (Qt, QComboBox, QLabel, QSpinBox, QDoubleSpinBox,
from calibre.utils.date import qt_to_dt, now, as_local_time, as_utc, internal_iso_format_string
from calibre.gui2.complete2 import EditWithComplete as EWC
from calibre.gui2.comments_editor import Editor as CommentsEditor
-from calibre.gui2 import UNDEFINED_QDATETIME, error_dialog, elided_text
+from calibre.gui2 import UNDEFINED_QDATETIME, error_dialog, elided_text, gprefs
from calibre.gui2.dialogs.tag_editor import TagEditor
from calibre.utils.config import tweaks
from calibre.utils.icu import sort_key
@@ -809,8 +809,8 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
ans = []
column = row = base_row = max_row = 0
label_width = 0
- do_elision = tweaks['metadata_edit_elide_labels']
- elide_pos = tweaks['metadata_edit_elision_point']
+ do_elision = gprefs['edit_metadata_elide_labels']
+ elide_pos = gprefs['edit_metadata_elision_point']
elide_pos = elide_pos if elide_pos in {'left', 'middle', 'right'} else 'right'
# make room on the right side for the scrollbar
sb_width = QApplication.instance().style().pixelMetric(QStyle.PixelMetric.PM_ScrollBarExtent)
@@ -857,10 +857,10 @@ def populate_metadata_page(layout, db, book_id, bulk=False, two_column=False, pa
colon_width = font_metrics.width(':')
if bulk:
label_width = (font_metrics.averageCharWidth() *
- tweaks['metadata_edit_bulk_cc_label_length']) - colon_width
+ gprefs['edit_metadata_bulk_cc_label_length']) - colon_width
else:
label_width = (font_metrics.averageCharWidth() *
- tweaks['metadata_edit_single_cc_label_length']) - colon_width
+ gprefs['edit_metadata_single_cc_label_length']) - colon_width
wij.setMaximumWidth(label_width)
if c == 0:
wij.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Preferred)
diff --git a/src/calibre/gui2/metadata/single.py b/src/calibre/gui2/metadata/single.py
index f18d1eada1..fbcab264d6 100644
--- a/src/calibre/gui2/metadata/single.py
+++ b/src/calibre/gui2/metadata/single.py
@@ -56,7 +56,6 @@ class MetadataSingleDialogBase(QDialog):
view_format = pyqtSignal(object, object)
edit_format = pyqtSignal(object, object)
- cc_two_column = tweaks['metadata_single_use_2_cols_for_custom_fields']
one_line_comments_toolbar = False
use_toolbutton_for_config_metadata = True
@@ -309,13 +308,16 @@ class MetadataSingleDialogBase(QDialog):
gprefs['paste_isbn_prefixes'] = list(filter(None, (x.strip() for x in prefixes.splitlines()))) or gprefs.defaults['paste_isbn_prefixes']
self.update_paste_identifiers_menu()
+ def use_two_columns_for_custom_metadata(self):
+ raise NotImplementedError
+
def create_custom_metadata_widgets(self): # {{{
self.custom_metadata_widgets_parent = w = QWidget(self)
layout = QGridLayout()
w.setLayout(layout)
self.custom_metadata_widgets, self.__cc_spacers = \
populate_metadata_page(layout, self.db, None, parent=w, bulk=False,
- two_column=self.cc_two_column)
+ two_column=self.use_two_columns_for_custom_metadata())
self.__custom_col_layouts = [layout]
for widget in self.custom_metadata_widgets:
widget.connect_data_changed(self.data_changed)
@@ -745,6 +747,9 @@ class Splitter(QSplitter):
class MetadataSingleDialog(MetadataSingleDialogBase): # {{{
+ def use_two_columns_for_custom_metadata(self):
+ return gprefs['edit_metadata_single_use_2_cols_for_custom_fields']
+
def do_layout(self):
if len(self.db.custom_column_label_map) == 0:
self.central_widget.tabBar().setVisible(False)
@@ -896,15 +901,16 @@ class DragTrackingWidget(QWidget): # {{{
class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{
- cc_two_column = False
one_line_comments_toolbar = True
use_toolbutton_for_config_metadata = False
-
on_drag_enter = pyqtSignal()
def handle_drag_enter(self):
self.central_widget.setCurrentIndex(1)
+ def use_two_columns_for_custom_metadata(self):
+ return False
+
def do_layout(self):
self.central_widget.clear()
self.tabs = []
@@ -1051,10 +1057,12 @@ class MetadataSingleDialogAlt1(MetadataSingleDialogBase): # {{{
class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{
- cc_two_column = False
one_line_comments_toolbar = True
use_toolbutton_for_config_metadata = False
+ def use_two_columns_for_custom_metadata(self):
+ return False
+
def do_layout(self):
self.central_widget.clear()
self.labels = []
diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py
index 99c571253b..13ba0a04c0 100644
--- a/src/calibre/gui2/preferences/look_feel.py
+++ b/src/calibre/gui2/preferences/look_feel.py
@@ -539,6 +539,13 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
choices=[(_('Default'), 'default'), (_('Compact Metadata'), 'alt1'),
(_('All on 1 tab'), 'alt2')])
r('edit_metadata_ignore_display_order', db.prefs)
+ r('edit_metadata_elision_point', gprefs,
+ choices=[(_('Left'), 'left'), (_('Middle'), 'middle'),
+ (_('Right'), 'right')])
+ r('edit_metadata_elide_labels', gprefs)
+ r('edit_metadata_single_use_2_cols_for_custom_fields', gprefs)
+ r('edit_metadata_bulk_cc_label_length', gprefs)
+ r('edit_metadata_single_cc_label_length', gprefs)
self.current_font = self.initial_font = None
self.change_font_button.clicked.connect(self.change_font)
diff --git a/src/calibre/gui2/preferences/look_feel.ui b/src/calibre/gui2/preferences/look_feel.ui
index da900433b6..34d2b52c65 100644
--- a/src/calibre/gui2/preferences/look_feel.ui
+++ b/src/calibre/gui2/preferences/look_feel.ui
@@ -908,10 +908,10 @@ A value of zero means calculate automatically.
Edit &metadata
-
- -
-
-
-
+
+
-
+
+
-
Edit metadata (single) &layout:
@@ -921,29 +921,16 @@ A value of zero means calculate automatically.
- -
+
-
Choose a different layout for the Edit metadata dialog. The compact metadata layout favors editing custom metadata over changing covers and formats.
- -
-
-
- Qt::Horizontal
-
-
-
- 20
- 40
-
-
-
-
- -
+
-
Select the custom columns (for this library) to display in the edit metadata dialogs and their order
@@ -994,18 +981,103 @@ A value of zero means calculate automatically.
- -
-
-
- Show all columns in default order when editing metadata
-
-
- <p>Check this box to make the edit metadata dialogs ignore the
+
-
+
+
-
+
+
-
+
+
+ Show all columns in default order when editing metadata
+
+
+ <p>Check this box to make the edit metadata dialogs ignore the
above specifications, showing all the columns in the default order. This is
useful for temporarily seeing all your columns in the dialogs without losing
the display and order specifications.</p>
-
-
+
+
+
+ -
+
+
+ Elide labels when editing custom columns
+
+
+ If checked then labels wider than the label width
+will be elided, otherwise they will be word wrapped.
+
+
+
+ -
+
+
+ Elision point
+
+
+ opt_edit_metadata_elision_point
+
+
+
+ -
+
+
+ Choose where in the label to put the ...
+
+
+
+
+
+ -
+
+
-
+
+
+ Use two columns for custom columns in the Default layout
+
+
+
+ -
+
+
+ Bulk edit custom column label length
+
+
+ opt_edit_metadata_bulk_cc_label_length
+
+
+
+ -
+
+
+ The maximum width of a custom column label in bulk metadata
+edit. It is computed by multiplying the average width of characters
+in the font by this number.
+
+
+
+ -
+
+
+ Single edit Custom column label length
+
+
+ opt_edit_metadata_single_cc_label_length
+
+
+
+ -
+
+
+ The maximum width of a custom column label in single
+metadata edit. It is computed by multiplying the average width of characters
+in the font by this number.
+
+
+
+
+
+