Skip to content

Commit

Permalink
fixes working sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
w4ffl35 committed Jan 11, 2024
1 parent d0be5e8 commit 60d2b6c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
3 changes: 2 additions & 1 deletion src/airunner/aihandler/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def controlnet(self):
return self._controlnet

@property
def self.options.get("allow_online_mode", False)
def allow_online_mode(self):
return self.options.get("allow_online_mode", False)

@property
def vae_path(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class ActiveGridSettingsWidget(BaseWidget):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.ui.width_slider_widget.setProperty("current_value", self.app.settings_manager.settings.working_width)
self.ui.height_slider_widget.setProperty("current_value", self.app.settings_manager.settings.working_height)
self.ui.width_slider_widget.setProperty("current_value", self.app.working_width)
self.ui.height_slider_widget.setProperty("current_value", self.app.working_height)
self.ui.width_slider_widget.initialize()
self.ui.height_slider_widget.initialize()
self.ui.border_opacity_slider_widget.setProperty("current_value", self.app.settings_manager.active_grid_settings.border_opacity)
Expand Down
30 changes: 14 additions & 16 deletions src/airunner/widgets/canvas_plus/canvas_plus_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def active_grid_area_rect(self):
return QRect(
self.app.settings_manager.active_grid_settings.pos_x,
self.app.settings_manager.active_grid_settings.pos_y,
self.app.settings_manager.settings.working_width,
self.app.settings_manager.settings.working_height
self.app.working_width,
self.app.working_height
)

def update_settings(self):
Expand Down Expand Up @@ -154,8 +154,6 @@ def handle_changed_signal(self, key, value):
self.redraw()
elif key in [
"active_grid_settings.enabled",
"settings.working_width",
"settings.working_height",
]:
self.redraw()

Expand Down Expand Up @@ -404,31 +402,31 @@ def cell_size(self):
return self.app.cell_size

def increase_active_grid_height(self, amount):
height = self.app.settings_manager.settings.working_height + self.cell_size * amount
height = self.app.working_height + self.cell_size * amount
if height > 4096:
height = 4096
self.app.settings_manager.settings.set_value("working_height", height)
self.app.working_height = height
self.do_draw()

def decrease_active_grid_height(self, amount):
height = self.app.settings_manager.settings.working_height - self.cell_size * amount
height = self.app.working_height - self.cell_size * amount
if height < 512:
height = 512
self.app.settings_manager.settings.set_value("working_height", height)
self.app.working_height = height
self.do_draw()

def increase_active_grid_width(self, amount):
width = self.app.settings_manager.settings.working_width + self.cell_size * amount
width = self.app.working_width + self.cell_size * amount
if width > 4096:
width = 4096
self.app.settings_manager.settings.set_value("working_width", width)
self.app.working_width = width
self.do_draw()

def decrease_active_grid_width(self, amount):
width = self.app.settings_manager.settings.working_width - self.cell_size * amount
width = self.app.working_width - self.cell_size * amount
if width < 512:
width = 512
self.app.settings_manager.settings.set_value("working_width", width)
self.app.working_width = width
self.do_draw()

def wheelEvent(self, event):
Expand Down Expand Up @@ -739,8 +737,8 @@ def load_image_from_object(self, image, is_outpaint=False, image_root_point=None
def load_image(self, image_path):
image = Image.open(image_path)
if self.app.resize_on_paste:
image.thumbnail((self.app.settings_manager.settings.working_width,
self.app.settings_manager.settings.working_height), Image.ANTIALIAS)
image.thumbnail((self.app.working_width,
self.app.working_height), Image.ANTIALIAS)
self.add_image_to_scene(image)

def current_draggable_pixmap(self):
Expand Down Expand Up @@ -818,8 +816,8 @@ def create_image(self, image):
def resize_image(self, image):
image.thumbnail(
(
self.app.settings_manager.settings.working_width,
self.app.settings_manager.settings.working_height
self.app.working_width,
self.app.working_height
),
Image.ANTIALIAS
)
Expand Down
4 changes: 2 additions & 2 deletions src/airunner/widgets/generator_form/generator_form_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ def do_generate(self, extra_options=None, seed=None, latents_seed=None, do_deter
enable_controlnet = bool(override_data.get("enable_controlnet", self.app.settings_manager.generator.enable_controlnet))
controlnet = override_data.get("controlnet", self.app.settings_manager.generator.controlnet)
controlnet_conditioning_scale = float(override_data.get("controlnet_conditioning_scale", self.app.settings_manager.generator.controlnet_guidance_scale))
width = int(override_data.get("width", self.app.settings_manager.settings.working_width))
height = int(override_data.get("height", self.app.settings_manager.settings.working_height))
width = int(override_data.get("width", self.app.working_width))
height = int(override_data.get("height", self.app.working_height))
clip_skip = int(override_data.get("clip_skip", self.app.settings_manager.generator.clip_skip))
batch_size = int(override_data.get("batch_size", 1))

Expand Down
34 changes: 24 additions & 10 deletions src/airunner/windows/main/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from PyQt6 import uic, QtCore
from PyQt6.QtCore import pyqtSlot, Qt, pyqtSignal, QTimer, QObject, QThread
from PyQt6.QtGui import QGuiApplication
from PyQt6.QtWidgets import QApplication, QFileDialog, QMainWindow, QWidget
from PyQt6.QtWidgets import QApplication, QFileDialog, QMainWindow
from PyQt6 import QtGui
from PyQt6.QtCore import QSettings

from airunner.resources_light_rc import *
from airunner.resources_dark_rc import *
from airunner.aihandler.enums import GeneratorSection, MessageCode, Mode
from airunner.aihandler.enums import MessageCode, Mode
from airunner.aihandler.logger import Logger as logger
from airunner.aihandler.pyqt_client import OfflineClient
from airunner.aihandler.qtvar import MessageHandlerVar
Expand All @@ -25,7 +25,6 @@
from airunner.data.models import Prompt, LLMGenerator
from airunner.filters.windows.filter_base import FilterBase
from airunner.input_event_manager import InputEventManager
from airunner.mixins.history_mixin import HistoryMixin
from airunner.settings import BASE_PATH
from airunner.utils import get_version, auto_export_image, \
create_airunner_paths, default_hf_cache_dir
Expand Down Expand Up @@ -102,8 +101,7 @@ def process_image_data(self, message):


class MainWindow(
QMainWindow,
HistoryMixin
QMainWindow
):
# signals
ai_mode_toggled = pyqtSignal(bool)
Expand Down Expand Up @@ -254,6 +252,22 @@ def nsfw_filter(self):
@nsfw_filter.setter
def nsfw_filter(self, val):
self.application_settings.setValue("nsfw_filter", val)

@property
def working_height(self):
return self.application_settings.value("working_height", 512, type=int)

@working_height.setter
def working_height(self, val):
self.application_settings.setValue("working_height", val)

@property
def working_width(self):
return self.application_settings.value("working_width", 512, type=int)

@working_width.setter
def working_width(self, val):
self.application_settings.setValue("working_width", val)

@property
def current_llm_generator(self):
Expand Down Expand Up @@ -361,7 +375,7 @@ def latest_version_check(self, val):

@property
def dark_mode_enabled(self):
return self.application_settings.value("dark_mode_enabled", False, type=bool)
return self.application_settings.value("dark_mode_enabled", True, type=bool)

@dark_mode_enabled.setter
def dark_mode_enabled(self, val):
Expand Down Expand Up @@ -913,7 +927,7 @@ def restore_state(self):
self.ui.standard_image_widget.ui.tabWidget.setCurrentIndex(generator_tab_index)

self.ui.ai_button.setChecked(self.ai_mode)
self.set_button_checked("toggle_grid", self.show_gird, False)
self.set_button_checked("toggle_grid", self.show_grid, False)
##### End window properties #####
#################################

Expand Down Expand Up @@ -1091,8 +1105,8 @@ def toggle_tool(self, tool):
self.settings_manager.set_value("settings.current_tool", tool)

def initialize_mixins(self):
HistoryMixin.initialize(self)
#self.canvas = Canvas()
pass

def connect_signals(self):
logger.info("Connecting signals")
Expand Down Expand Up @@ -1215,7 +1229,7 @@ def handle_wheel_event(self, event):
if QtCore.Qt.KeyboardModifier.ShiftModifier in event.modifiers():
delta = event.angleDelta().y()
increment = grid_size if delta > 0 else -grid_size
val = self.settings_manager.settings.working_width + increment
val = self.working_width + increment
self.settings_manager.set_value("settings.working_width", val)
except TypeError:
pass
Expand All @@ -1225,7 +1239,7 @@ def handle_wheel_event(self, event):
if QtCore.Qt.KeyboardModifier.ControlModifier in event.modifiers():
delta = event.angleDelta().y()
increment = grid_size if delta > 0 else -grid_size
val = self.settings_manager.settings.working_height + increment
val = self.working_height + increment
self.settings_manager.set_value("settings.working_height", val)
except TypeError:
pass
Expand Down

0 comments on commit 60d2b6c

Please sign in to comment.