Skip to content

Commit

Permalink
Added "Info to Clipboard" to context menu and optional toggle for con…
Browse files Browse the repository at this point in the history
…cise _job_info()
  • Loading branch information
mmuellerdm committed Nov 13, 2024
1 parent 0629d24 commit 3947b3f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ai_diffusion/ui/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def add(self, job: Job):
"seed": _("Seed"),
}

def _job_info(self, params: JobParams):
def _job_info(self, params: JobParams, tooltip_header: bool = True):
title = params.name if params.name != "" else "<no prompt>"
if len(title) > 70:
title = title[:66] + "..."
Expand All @@ -163,7 +163,7 @@ def _job_info(self, params: JobParams):
title + "\n",
_("Click to toggle preview, double-click to apply."),
"",
]
] if tooltip_header else []
for key, value in params.metadata.items():
if key == "style" and style:
value = style.name
Expand Down Expand Up @@ -340,6 +340,7 @@ def _show_context_menu(self, pos: QPoint):
if job is None or Styles.list().find(job.params.style) is None:
style_action.setEnabled(False)
menu.addAction(_("Copy Seed"), self._copy_seed)
menu.addAction(_("Info to Clipboard"), self._info_to_clipboard)
menu.addSeparator()
save_action = ensure(menu.addAction(_("Save Image"), self._save_image))
if self._model.document.filename == "":
Expand Down Expand Up @@ -381,6 +382,10 @@ def _copy_seed(self):
self._model.fixed_seed = True
self._model.seed = job.params.seed

def _info_to_clipboard(self):
if (job := self.selected_job) and (clipboard := QGuiApplication.clipboard()):
clipboard.setText(self._job_info(job.params, tooltip_header=False))

def _save_image(self):
items = self.selectedItems()
for item in items:
Expand Down

0 comments on commit 3947b3f

Please sign in to comment.