Add a "copy category name to clipboard" button to the user category editor.

This commit is contained in:
Charles Haley 2021-06-09 14:19:48 +01:00
parent 3499f03ae5
commit c122784bc0
2 changed files with 19 additions and 3 deletions

View File

@ -4,7 +4,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
from qt.core import (
Qt, QDialog, QIcon, QListWidgetItem)
Qt, QApplication, QDialog, QIcon, QListWidgetItem)
from calibre.gui2.dialogs.tag_categories_ui import Ui_TagCategories
from calibre.gui2.dialogs.confirm_delete import confirm
@ -103,6 +103,7 @@ class TagCategories(QDialog, Ui_TagCategories):
self.category_filter_box.addItem(v)
self.current_cat_name = None
self.copy_category_name_to_clipboard.clicked.connect(self.copy_category_name_to_clipboard_clicked)
self.apply_button.clicked.connect(self.apply_button_clicked)
self.unapply_button.clicked.connect(self.unapply_button_clicked)
self.add_category_button.clicked.connect(self.add_category)
@ -128,6 +129,10 @@ class TagCategories(QDialog, Ui_TagCategories):
self.category_box.setCurrentIndex(0)
self.select_category(0)
def copy_category_name_to_clipboard_clicked(self):
t = self.category_box.itemText(self.category_box.currentIndex())
QApplication.clipboard().setText(t)
def initialize_category_lists(self, book_ids):
self.db_categories = self.db.new_api.get_categories(book_ids=book_ids)
self.all_items = []

View File

@ -21,7 +21,7 @@
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<layout class="QGridLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
@ -38,7 +38,7 @@
<item row="0" column="1">
<widget class="QComboBox" name="category_box">
<property name="toolTip">
<string>Select a category to edit</string>
<string>Copy category name to clipboard</string>
</property>
<property name="editable">
<bool>false</bool>
@ -51,6 +51,17 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="copy_category_name_to_clipboard">
<property name="toolTip">
<string>Copy the category name to the clipboard</string>
</property>
<property name="icon">
<iconset resource="../../../../resources/images.qrc">
<normaloff>:/images/edit-copy.png</normaloff>:/images/edit-copy.png</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">