diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py index cb1d06be02..30fb8c1e43 100644 --- a/src/calibre/gui2/dialogs/tag_categories.py +++ b/src/calibre/gui2/dialogs/tag_categories.py @@ -4,7 +4,7 @@ __license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' 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 = [] diff --git a/src/calibre/gui2/dialogs/tag_categories.ui b/src/calibre/gui2/dialogs/tag_categories.ui index d878c94e0c..a6a88500a4 100644 --- a/src/calibre/gui2/dialogs/tag_categories.ui +++ b/src/calibre/gui2/dialogs/tag_categories.ui @@ -21,7 +21,7 @@ - + @@ -38,7 +38,7 @@ - Select a category to edit + Copy category name to clipboard false @@ -51,6 +51,17 @@ + + + + Copy the category name to the clipboard + + + + :/images/edit-copy.png:/images/edit-copy.png + + + diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 715adae45f..397eb07611 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -180,6 +180,7 @@ class TagsView(QTreeView): # {{{ def __init__(self, parent=None): QTreeView.__init__(self, parent=None) + self.possible_drag_start = None self.setProperty('frame_for_focus', True) self.setMouseTracking(True) self.alter_tb = None @@ -384,7 +385,12 @@ class TagsView(QTreeView): # {{{ def mousePressEvent(self, event): if event.buttons() & Qt.MouseButton.LeftButton: - self.possible_drag_start = event.pos() + # Only remember a possible drag start if the item is drag enabled + dex = self.indexAt(event.pos()) + if self._model.flags(dex) & Qt.ItemFlag.ItemIsDragEnabled: + self.possible_drag_start = event.pos() + else: + self.possible_drag_start = None return QTreeView.mousePressEvent(self, event) def mouseMoveEvent(self, event): @@ -399,7 +405,8 @@ class TagsView(QTreeView): # {{{ QTreeView.mouseMoveEvent(self, event) return # don't start drag/drop until the mouse has moved a bit. - if ((event.pos() - self.possible_drag_start).manhattanLength() < + if (self.possible_drag_start is None or + (event.pos() - self.possible_drag_start).manhattanLength() < QApplication.startDragDistance()): QTreeView.mouseMoveEvent(self, event) return