Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make overflowing Add Lora menus scrollable #239

Merged
merged 7 commits into from
Dec 23, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ai_diffusion/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,15 @@ def value(self):
def value(self, v):
self._checkbox.setChecked(v)


class QMenu(QMenu):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sub-class isn't really needed here (and I don't like that it has the same name)
Please just keep the function, name it _menu_width or similar and call it directly

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

class LoraList(QWidget):
class Item(QWidget):
changed = pyqtSignal()
Expand Down Expand Up @@ -353,6 +361,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() > screen.availableSize().width():
menu.setStyleSheet("QMenu{menu-scrollable: 1;}")

return menu

def _select_update(self, text):
Expand Down
Loading