mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a color chooser (copy color name to clipboard) to the advanced coloring template editor
This commit is contained in:
parent
6c8b994534
commit
98309d2b02
@ -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):
|
||||
'<a href="http://manual.calibre-ebook.com/template_ref.html">'
|
||||
'%s</a>'%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:
|
||||
|
@ -21,8 +21,8 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="colored_field_label">
|
||||
<property name="text">
|
||||
<string>Set the color of the column:</string>
|
||||
@ -32,10 +32,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="colored_field">
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="color_chooser_label">
|
||||
<property name="text">
|
||||
<string>Copy a color name to the clipboard:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>color_name</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="color_name">
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="color_copy_button">
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../resources/images.qrc">
|
||||
<normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Copy the selected color name to the clipboard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user