Skip to content

Commit

Permalink
Modifies embedding buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ffl35 committed Jan 2, 2024
1 parent 7d5059c commit f56522d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 27 deletions.
6 changes: 6 additions & 0 deletions src/airunner/widgets/embeddings/embedding_widget.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from airunner.utils import save_session
from airunner.widgets.base_widget import BaseWidget
from airunner.widgets.embeddings.templates.embedding_ui import Ui_embedding
from PyQt6.QtWidgets import QApplication


class EmbeddingWidget(BaseWidget):
Expand Down Expand Up @@ -29,3 +30,8 @@ def action_clicked_button_to_negative_prompt(self):
def action_toggled_embedding(self, val):
self.embedding.active = val
save_session()

def action_clicked_copy(self):
# copy embedding name to clipboard
clipboard = QApplication.clipboard()
clipboard.setText(self.embedding.name)
76 changes: 59 additions & 17 deletions src/airunner/widgets/embeddings/templates/embedding.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="to_negative_prompt_button">
<item row="1" column="0">
<widget class="QPushButton" name="to_prompt_button">
<property name="minimumSize">
<size>
<width>90</width>
Expand All @@ -54,23 +54,22 @@
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Neg Prompt</string>
<string>Prompt</string>
</property>
<property name="icon">
<iconset theme="edit-paste"/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="tags">
<property name="text">
<string>Tags</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="to_prompt_button">
<item row="1" column="1">
<widget class="QPushButton" name="to_negative_prompt_button">
<property name="minimumSize">
<size>
<width>90</width>
Expand All @@ -82,14 +81,40 @@
<pointsize>10</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Prompt</string>
<string>Negative</string>
</property>
<property name="icon">
<iconset theme="edit-paste"/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="tags">
<property name="text">
<string>Tags</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="copy_button">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="edit-copy"/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand All @@ -104,8 +129,8 @@
<slot>action_clicked_button_to_prompt()</slot>
<hints>
<hint type="sourcelabel">
<x>85</x>
<y>129</y>
<x>97</x>
<y>77</y>
</hint>
<hint type="destinationlabel">
<x>43</x>
Expand All @@ -120,8 +145,8 @@
<slot>action_clicked_button_to_negative_prompt()</slot>
<hints>
<hint type="sourcelabel">
<x>255</x>
<y>129</y>
<x>240</x>
<y>77</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
Expand All @@ -145,10 +170,27 @@
</hint>
</hints>
</connection>
<connection>
<sender>copy_button</sender>
<signal>clicked()</signal>
<receiver>embedding</receiver>
<slot>action_clicked_copy()</slot>
<hints>
<hint type="sourcelabel">
<x>298</x>
<y>61</y>
</hint>
<hint type="destinationlabel">
<x>278</x>
<y>-9</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>action_clicked_button_to_prompt()</slot>
<slot>action_clicked_button_to_negative_prompt()</slot>
<slot>action_toggled_embedding(bool)</slot>
<slot>action_clicked_copy()</slot>
</slots>
</ui>
34 changes: 24 additions & 10 deletions src/airunner/widgets/embeddings/templates/embedding_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,51 @@ def setupUi(self, embedding):
self.enabledCheckbox.setObjectName("enabledCheckbox")
self.gridLayout = QtWidgets.QGridLayout(self.enabledCheckbox)
self.gridLayout.setObjectName("gridLayout")
self.to_prompt_button = QtWidgets.QPushButton(parent=self.enabledCheckbox)
self.to_prompt_button.setMinimumSize(QtCore.QSize(90, 0))
font = QtGui.QFont()
font.setPointSize(10)
self.to_prompt_button.setFont(font)
self.to_prompt_button.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
icon = QtGui.QIcon.fromTheme("edit-paste")
self.to_prompt_button.setIcon(icon)
self.to_prompt_button.setFlat(False)
self.to_prompt_button.setObjectName("to_prompt_button")
self.gridLayout.addWidget(self.to_prompt_button, 1, 0, 1, 1)
self.to_negative_prompt_button = QtWidgets.QPushButton(parent=self.enabledCheckbox)
self.to_negative_prompt_button.setMinimumSize(QtCore.QSize(90, 0))
font = QtGui.QFont()
font.setPointSize(10)
self.to_negative_prompt_button.setFont(font)
self.to_negative_prompt_button.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
icon = QtGui.QIcon.fromTheme("edit-paste")
self.to_negative_prompt_button.setIcon(icon)
self.to_negative_prompt_button.setFlat(False)
self.to_negative_prompt_button.setObjectName("to_negative_prompt_button")
self.gridLayout.addWidget(self.to_negative_prompt_button, 1, 1, 1, 1)
self.tags = QtWidgets.QLabel(parent=self.enabledCheckbox)
self.tags.setObjectName("tags")
self.gridLayout.addWidget(self.tags, 0, 0, 1, 2)
self.to_prompt_button = QtWidgets.QPushButton(parent=self.enabledCheckbox)
self.to_prompt_button.setMinimumSize(QtCore.QSize(90, 0))
font = QtGui.QFont()
font.setPointSize(10)
self.to_prompt_button.setFont(font)
self.to_prompt_button.setFlat(False)
self.to_prompt_button.setObjectName("to_prompt_button")
self.gridLayout.addWidget(self.to_prompt_button, 1, 0, 1, 1)
self.copy_button = QtWidgets.QPushButton(parent=self.enabledCheckbox)
self.copy_button.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
self.copy_button.setText("")
icon = QtGui.QIcon.fromTheme("edit-copy")
self.copy_button.setIcon(icon)
self.copy_button.setObjectName("copy_button")
self.gridLayout.addWidget(self.copy_button, 1, 2, 1, 1)
self.gridLayout_2.addWidget(self.enabledCheckbox, 0, 0, 1, 2)

self.retranslateUi(embedding)
self.to_prompt_button.clicked.connect(embedding.action_clicked_button_to_prompt) # type: ignore
self.to_negative_prompt_button.clicked.connect(embedding.action_clicked_button_to_negative_prompt) # type: ignore
self.enabledCheckbox.toggled['bool'].connect(embedding.action_toggled_embedding) # type: ignore
self.copy_button.clicked.connect(embedding.action_clicked_copy) # type: ignore
QtCore.QMetaObject.connectSlotsByName(embedding)

def retranslateUi(self, embedding):
_translate = QtCore.QCoreApplication.translate
embedding.setWindowTitle(_translate("embedding", "Form"))
self.enabledCheckbox.setTitle(_translate("embedding", "Embedding name here"))
self.to_negative_prompt_button.setText(_translate("embedding", "Neg Prompt"))
self.tags.setText(_translate("embedding", "Tags"))
self.to_prompt_button.setText(_translate("embedding", "Prompt"))
self.to_negative_prompt_button.setText(_translate("embedding", "Negative"))
self.tags.setText(_translate("embedding", "Tags"))

0 comments on commit f56522d

Please sign in to comment.