Skip to content

Commit 041c1a9

Browse files
committed
refactor(app): 优化右键菜单位置
1 parent b7cafb5 commit 041c1a9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

app/components/custom_components.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ def __initWidgets(self):
185185
self.view.itemClicked.connect(self._onItemClicked)
186186
self.view.itemEntered.connect(self._onItemEntered)
187187

188+
def adjustPosition(self):
189+
m = self.hBoxLayout.contentsMargins()
190+
rect = getCurrentScreenGeometry()
191+
w, h = (
192+
self.hBoxLayout.sizeHint().width() + 5,
193+
self.hBoxLayout.sizeHint().height(),
194+
)
195+
196+
x = min(self.x() - m.left(), rect.right() - w)
197+
y = self.y() - 45
198+
199+
self.move(x, y)
200+
201+
188202
def showEvent(self, event, /):
189203
self.windowEffect.addMenuShadowEffect(self.winId())
190204
self.windowEffect.addShadowEffect(self.winId())
@@ -202,8 +216,9 @@ def showEvent(self, event, /):
202216
),
203217
)
204218

219+
self.adjustPosition()
205220
self.raise_()
206221
self.activateWindow()
207222
self.setFocus()
208223

209-
super().showEvent(event)
224+
super().showEvent(event)

0 commit comments

Comments
 (0)