From 74eceb72149f5c6149d9b3f7dcd6746ae1f0fff6 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Fri, 19 Apr 2024 17:18:35 +0100 Subject: [PATCH] Remove "view column definition" --- src/calibre/gui2/library/views.py | 10 ++---- .../gui2/preferences/create_custom_column.py | 33 +++++++------------ 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index c67176e3fa..b985aea213 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -569,9 +569,6 @@ class BooksView(QTableView): # {{{ view.apply_state(view.get_default_state()) elif action == 'addcustcol': self.add_column_signal.emit() - elif action == 'viewcustcol': - col_manager = CreateNewCustomColumn(self.gui) - col_manager.view_existing_column(column) elif action == 'editcustcol': def show_restart_dialog(): from calibre.gui2.preferences.main import must_restart_message @@ -651,13 +648,10 @@ class BooksView(QTableView): # {{{ if not isinstance(view, DeviceBooksView): col_manager = CreateNewCustomColumn(self.gui) if self.can_add_columns and self.model().is_custom_column(col): - actv = ans.addAction(QIcon.ic('view-image.png'), _('View column definition for %s') % name, - partial(handler, action='viewcustcol')) - acte = ans.addAction(QIcon.ic('edit_input.png'), _('Edit column definition for %s') % name, + act = ans.addAction(QIcon.ic('edit_input.png'), _('Edit column definition for %s') % name, partial(handler, action='editcustcol')) if col_manager.must_restart(): - actv.setEnabled(False) - acte.setEnabled(False) + act.setEnabled(False) if self.is_library_view: if self._model.db.field_metadata[col]['is_category']: act = ans.addAction(QIcon.ic('quickview.png'), _('Quickview column %s') % name, diff --git a/src/calibre/gui2/preferences/create_custom_column.py b/src/calibre/gui2/preferences/create_custom_column.py index 24d16be6b2..981f2e01c8 100644 --- a/src/calibre/gui2/preferences/create_custom_column.py +++ b/src/calibre/gui2/preferences/create_custom_column.py @@ -106,11 +106,10 @@ class CreateCustomColumn(QDialog): ))) column_types_map = {k['datatype']:idx for idx, k in iteritems(column_types)} - def __init__(self, gui, caller, current_key, standard_colheads, freeze_lookup_name=False, view_only=False): + def __init__(self, gui, caller, current_key, standard_colheads, freeze_lookup_name=False): QDialog.__init__(self, gui) self.orig_column_number = -1 self.gui = gui - self.view_only = view_only self.setup_ui() self.setWindowTitle(_('Create a custom column')) self.heading_label.setText('' + _('Create a custom column')) @@ -139,12 +138,8 @@ class CreateCustomColumn(QDialog): self.exec() return - if view_only: - self.setWindowTitle(_('View custom column')) - self.heading_label.setText('' + _('View custom column definition. Changes will be ignored')) - else: - self.setWindowTitle(_('Edit custom column')) - self.heading_label.setText('' + _('Edit custom column definition')) + self.setWindowTitle(_('Edit custom column')) + self.heading_label.setText('' + _('Edit custom column')) self.shortcuts.setVisible(False) col = current_key if col not in caller.custcols: @@ -297,13 +292,15 @@ class CreateCustomColumn(QDialog): self.g = g = QGridLayout() l.addLayout(g) l.addStretch(10) - if self.view_only: - self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, self) - else: - self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | - QDialogButtonBox.StandardButton.Cancel, self) + bbl = QHBoxLayout() + txt = QLabel(_('Pressing OK will require restarting calibre even if nothing was changed')) + txt.setWordWrap(True) + bbl.addWidget(txt) + bbl.addStretch(1) + self.button_box = bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel, self) bb.accepted.connect(self.accept), bb.rejected.connect(self.reject) - l.addWidget(bb) + bbl.addWidget(bb) + l.addLayout(bbl) def add_row(text, widget): if text is None: @@ -1010,17 +1007,11 @@ class CreateNewCustomColumn: return self.Result.INVALID_KEY return self._create_or_edit_column(lookup_name, freeze_lookup_name=False, operation='edit') - def view_existing_column(self, lookup_name): - if lookup_name not in self.custcols: - return self.Result.INVALID_KEY - return self._create_or_edit_column(lookup_name, freeze_lookup_name=True, operation='view') - def _create_or_edit_column(self, lookup_name, freeze_lookup_name, operation=None): try: dialog = CreateCustomColumn(self.gui, self, lookup_name, self.gui.library_view.model().orig_headers, - freeze_lookup_name=freeze_lookup_name, - view_only=operation=='view') + freeze_lookup_name=freeze_lookup_name) if dialog.result() == QDialog.DialogCode.Accepted and self.cc_column_key is not None: cc = self.custcols[lookup_name] if operation == 'create':