From 50e558d85621d4e50487700dfd0ac667ba0cea7d Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Sat, 17 Apr 2021 11:25:07 +0100 Subject: [PATCH] Bug #1924674: Column icon rules: no error if no column is selected --- src/calibre/gui2/dialogs/template_dialog.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py index 5f8a046680..84520b0680 100644 --- a/src/calibre/gui2/dialogs/template_dialog.py +++ b/src/calibre/gui2/dialogs/template_dialog.py @@ -710,19 +710,22 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): def accept(self): txt = unicode_type(self.textbox.toPlainText()).rstrip() + if (self.coloring or self.iconing or self.embleming) and not txt: + error_dialog(self, _('No template provided'), + _('The template box cannot be empty'), show=True) + return if self.coloring: if self.colored_field.currentIndex() == -1: error_dialog(self, _('No column chosen'), _('You must specify a column to be colored'), show=True) return - if not txt: - error_dialog(self, _('No template provided'), - _('The template box cannot be empty'), show=True) - return - self.rule = (unicode_type(self.colored_field.itemData( self.colored_field.currentIndex()) or ''), txt) elif self.iconing: + if self.icon_field.currentIndex() == -1: + error_dialog(self, _('No column chosen'), + _('You must specify the column where the icons are applied'), show=True) + return rt = unicode_type(self.icon_kind.itemData(self.icon_kind.currentIndex()) or '') self.rule = (rt, unicode_type(self.icon_field.itemData(