Skip to content

Commit

Permalink
Fix typo and move special popup menu class
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Sep 5, 2023
1 parent b109548 commit 4cc4026
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions novelwriter/gui/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@
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)
Expand Down Expand Up @@ -104,7 +92,7 @@ def __init__(self, mainGui: GuiMain) -> None:
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()
Expand Down Expand Up @@ -171,3 +159,17 @@ def updateTheme(self) -> None:
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
2 changes: 1 addition & 1 deletion tests/test_gui/test_gui_guimain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 4cc4026

Please sign in to comment.