Skip to content

Commit

Permalink
add preferences widget to prferences window
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ffl35 committed May 1, 2023
1 parent ef42551 commit ee0bfaf
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 1 deletion.
20 changes: 19 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QScrollArea
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QScrollArea, QLineEdit, QPushButton, QHBoxLayout
from PyQt6.QtCore import pyqtSignal
from airunner.extensions import BaseExtension
from aihandler.qtvar import Var, StringVar, FloatVar, BooleanVar
Expand Down Expand Up @@ -250,3 +250,21 @@ def load_lora(self, pipeline, checkpoint_path, multiplier=1.0, device="cuda", dt
curr_layer.weight.data += multiplier * alpha * torch.mm(weight_up, weight_down)

return pipeline

def preferences_injection(self, window):
preferences_widget = self.load_template("preferences")
preferences_widget.lora_path.textChanged.connect(
lambda val: self.settings_manager.settings.lora_path.set(val))
preferences_widget.lora_browse_button.clicked.connect(
lambda: self.browse_for_lora_path(self.template.lora_path))
preferences_widget.lora_path.setText(
self.settings_manager.settings.lora_path.get())
layout = window.template.frame.layout()
if layout is not None:
layout.addWidget(preferences_widget)
window.show()
else:
print("Layout is not set up")



88 changes: 88 additions & 0 deletions templates/preferences.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>100</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>2</x>
<y>12</y>
<width>341</width>
<height>75</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Folder that contains LoRA files</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>LoRA Path</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lora_path"/>
</item>
<item>
<widget class="QPushButton" name="lora_browse_button">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit ee0bfaf

Please sign in to comment.