diff --git a/src/calibre/gui2/dialogs/template_dialog.py b/src/calibre/gui2/dialogs/template_dialog.py index 9b31c3c929..f02678363b 100644 --- a/src/calibre/gui2/dialogs/template_dialog.py +++ b/src/calibre/gui2/dialogs/template_dialog.py @@ -207,10 +207,15 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): cols = sorted([k for k in displayable_columns(fm)]) self.colored_field.addItems(cols) self.colored_field.setCurrentIndex(self.colored_field.findText(color_field)) + colors = QColor.colorNames() + colors.sort() + self.color_name.addItems(colors) else: self.colored_field.setVisible(False) self.colored_field_label.setVisible(False) - + self.color_chooser_label.setVisible(False) + self.color_name.setVisible(False) + self.color_copy_button.setVisible(False) if mi: self.mi = mi else: @@ -235,6 +240,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): self.textbox.setPlainText(text) self.buttonBox.button(QDialogButtonBox.Ok).setText(_('&OK')) self.buttonBox.button(QDialogButtonBox.Cancel).setText(_('&Cancel')) + self.color_copy_button.clicked.connect(self.color_to_clipboard) try: with open(P('template-functions.json'), 'rb') as f: @@ -263,6 +269,11 @@ class TemplateDialog(QDialog, Ui_TemplateDialog): '' '%s'%tt) + def color_to_clipboard(self): + app = QApplication.instance() + c = app.clipboard() + c.setText(unicode(self.color_name.currentText())) + def textbox_changed(self): cur_text = unicode(self.textbox.toPlainText()) if self.last_text != cur_text: diff --git a/src/calibre/gui2/dialogs/template_dialog.ui b/src/calibre/gui2/dialogs/template_dialog.ui index 674100fe04..9037e70b94 100644 --- a/src/calibre/gui2/dialogs/template_dialog.ui +++ b/src/calibre/gui2/dialogs/template_dialog.ui @@ -21,8 +21,8 @@ - - + + Set the color of the column: @@ -32,10 +32,35 @@ - + + + + + Copy a color name to the clipboard: + + + color_name + + + + + + + + + + + + :/images/edit-copy.png:/images/edit-copy.png + + + Copy the selected color name to the clipboard + + +