Skip to content

Commit

Permalink
make overflowing Add Lora menus scrollable (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtvrv authored Dec 23, 2023
1 parent 8774699 commit 6b64ebc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ai_diffusion/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def value(self, v):
self._update_text()


def _menu_width(menu: QMenu) -> int:
if not menu.isEmpty():
last_action = menu.actions()[-1]
action_rect = menu.actionGeometry(last_action)
return action_rect.right()
else:
return 0


class LoraList(QWidget):
class Item(QWidget):
changed = pyqtSignal()
Expand Down Expand Up @@ -368,6 +377,10 @@ def _build_menu(self, values, title="", path="") -> QMenu:
else:
menu.addMenu(self._build_menu(v, k, os.path.join(path, k)))

if screen := QGuiApplication.screenAt(QCursor.pos()):
if _menu_width(menu) > screen.availableSize().width():
menu.setStyleSheet("QMenu{menu-scrollable: 1;}")

return menu

def _select_update(self, text):
Expand Down

0 comments on commit 6b64ebc

Please sign in to comment.