mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-08-14 16:19:44 +02:00
fix(ui): remove blank action on suggest boxes
This commit is contained in:
@@ -5,9 +5,10 @@ from typing import override
|
||||
|
||||
import structlog
|
||||
from PySide6 import QtCore, QtGui
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtCore import QPoint, Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QMenu,
|
||||
QWidget,
|
||||
)
|
||||
|
||||
@@ -72,3 +73,12 @@ class AutofillLineEdit(QLineEdit):
|
||||
if arg__1.key() == QtCore.Qt.Key.Key_Shift:
|
||||
self.holding_shift.emit(False) # noqa: FBT003
|
||||
return super().keyReleaseEvent(arg__1)
|
||||
|
||||
def show_action_menu(self, pos: QPoint) -> None:
|
||||
"""Show a context menu of actions."""
|
||||
menu = QMenu(self)
|
||||
for action in self.actions():
|
||||
# Filter out icon action(s)
|
||||
if action.text():
|
||||
menu.addAction(action)
|
||||
menu.exec(self.mapToGlobal(pos)) # pyright: ignore[reportArgumentType]
|
||||
|
||||
@@ -72,7 +72,8 @@ class SuggestBoxView(QVBoxLayout):
|
||||
QPixmap(), AutofillLineEdit.ActionPosition.TrailingPosition
|
||||
)
|
||||
self.scroll_area.setFocusProxy(self.search_field)
|
||||
self.search_field.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu)
|
||||
self.search_field.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
self.search_field.customContextMenuRequested.connect(self.search_field.show_action_menu)
|
||||
|
||||
# Finalize Layout
|
||||
self.addWidget(scroll_area_container)
|
||||
|
||||
Reference in New Issue
Block a user