Fix typo and move special popup menu class

This commit is contained in:
Veronica Berglyd Olsen
2023-09-05 22:20:04 +02:00
parent b1095481ef
commit 4cc402679f
2 changed files with 16 additions and 14 deletions
+15 -13
View File
@@ -40,18 +40,6 @@ if TYPE_CHECKING: # pragma: no cover
logger = logging.getLogger(__name__)
class PopRightMenu(QMenu):
def event(self, event: QEvent):
"""Overload the show event and move the menu popup location."""
if event.type() == QEvent.Show:
parent = self.parent()
if isinstance(parent, QWidget):
offset = QPoint(parent.width(), parent.height() - self.height())
self.move(parent.mapToGlobal(offset))
return super(PopRightMenu, self).event(event)
class GuiSideBar(QWidget):
viewChangeRequested = pyqtSignal(nwView)
@@ -104,7 +92,7 @@ class GuiSideBar(QWidget):
self.tbSettings.setIconSize(iconSize)
self.tbSettings.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
self.mSettings = PopRightMenu(self.tbSettings)
self.mSettings = _PopRightMenu(self.tbSettings)
self.mSettings.addAction(self.mainGui.mainMenu.aEditWordList)
self.mSettings.addAction(self.mainGui.mainMenu.aProjectSettings)
self.mSettings.addSeparator()
@@ -171,3 +159,17 @@ class GuiSideBar(QWidget):
return
# END Class GuiSideBar
class _PopRightMenu(QMenu):
def event(self, event: QEvent):
"""Overload the show event and move the menu popup location."""
if event.type() == QEvent.Show:
parent = self.parent()
if isinstance(parent, QWidget):
offset = QPoint(parent.width(), parent.height() - self.height())
self.move(parent.mapToGlobal(offset))
return super(_PopRightMenu, self).event(event)
# END Class _PopRightMenu
+1 -1
View File
@@ -595,7 +595,7 @@ def testGuiMain_Features(qtbot, nwGUI, projPath, mockRnd):
# SideBar Menu
# ============
# Just make sure the custom event handler executes and don't fail
# Just make sure the custom event handler executes and doesn't fail
nwGUI.sideBar.mSettings.show()
nwGUI.sideBar.mSettings.hide()