Skip to content

The only downloader you need. 下载器的集大成者。

refactor(app): 优化右键菜单位置

XiaoYouChR041c1a92446e
diff --git a/app/components/custom_components.py b/app/components/custom_components.py
index b885cfbf..1e5ca837 100644
--- a/app/components/custom_components.py
+++ b/app/components/custom_components.py
@@ -185,6 +185,20 @@ class CustomAcrylicMenu(RoundMenu):
self.view.itemClicked.connect(self._onItemClicked)
self.view.itemEntered.connect(self._onItemEntered)
+ def adjustPosition(self):
+ m = self.hBoxLayout.contentsMargins()
+ rect = getCurrentScreenGeometry()
+ w, h = (
+ self.hBoxLayout.sizeHint().width() + 5,
+ self.hBoxLayout.sizeHint().height(),
+ )
+
+ x = min(self.x() - m.left(), rect.right() - w)
+ y = self.y() - 45
+
+ self.move(x, y)
+
+
def showEvent(self, event, /):
self.windowEffect.addMenuShadowEffect(self.winId())
self.windowEffect.addShadowEffect(self.winId())
@@ -202,8 +216,9 @@ class CustomAcrylicMenu(RoundMenu):
),
)
+ self.adjustPosition()
self.raise_()
self.activateWindow()
self.setFocus()
- super().showEvent(event)
+ super().showEvent(event)
\ No newline at end of file