Skip to content

Commit

Permalink
UID copy on click
Browse files Browse the repository at this point in the history
  • Loading branch information
ronpandolfi committed Apr 18, 2023
1 parent 02687c8 commit c7f487f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions xicam/gui/widgets/metadataview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from pyqtgraph.parametertree.parameterTypes import GroupParameter
from collections import deque, OrderedDict, defaultdict
from queue import Queue
from qtpy.QtGui import QStandardItem, QStandardItemModel
from qtpy.QtWidgets import QProgressBar, QWidget, QVBoxLayout
from qtpy.QtGui import QStandardItem, QStandardItemModel, QGuiApplication
from qtpy.QtWidgets import QProgressBar, QWidget, QVBoxLayout, QTreeWidgetItem
from qtpy.QtCore import QItemSelectionModel, Signal, Qt, QTimer
import sys
import uuid
Expand All @@ -30,6 +30,7 @@ def __init__(self, *args, **kwargs):
super(MetadataWidgetBase, self).__init__(*args, **kwargs)
LazyGroupParameter.itemClass.initialize_treewidget(self)
self.kwargs = kwargs
self.itemClicked.connect(self.onItemClicked)

def insert(self, doctype: str, child, groups: dict):
group = groups[doctype]
Expand Down Expand Up @@ -71,6 +72,12 @@ def _lookup_name_for_group(doctype, document):
else:
raise KeyError(f"Cannot find document type '{doctype}' in supported header parameters")

def onItemClicked(self, item: QTreeWidgetItem, column):
clipboard = QGuiApplication.instance().clipboard()
if not item.parent():# and item.text(0) != clipboard.text():
clipboard.setText(item.text(0))
msg.showMessage(f'UID copied to clipboard: {item.text(0)}', timeout=3)


class MetadataWidget(QWidget):
def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit c7f487f

Please sign in to comment.