From fc70d52e58a57509177f3f241c34fc9e704e312a Mon Sep 17 00:00:00 2001 From: zhiyiYo <1319158137@qq.com> Date: Mon, 13 Feb 2023 19:44:35 +0800 Subject: [PATCH] fixes #10 --- qfluentwidgets/__init__.py | 2 +- qfluentwidgets/components/widgets/combo_box.py | 3 +++ qfluentwidgets/components/widgets/menu.py | 8 ++++---- setup.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/qfluentwidgets/__init__.py b/qfluentwidgets/__init__.py index 3818319..1ab6c16 100644 --- a/qfluentwidgets/__init__.py +++ b/qfluentwidgets/__init__.py @@ -10,7 +10,7 @@ online at https://pyqt-fluent-widgets.readthedocs.io. :license: MIT, see LICENSE for more details. """ -__version__ = "0.2.4" +__version__ = "0.2.5" from .components import * from .common import * diff --git a/qfluentwidgets/components/widgets/combo_box.py b/qfluentwidgets/components/widgets/combo_box.py index 34a1d9a..52ae8bb 100644 --- a/qfluentwidgets/components/widgets/combo_box.py +++ b/qfluentwidgets/components/widgets/combo_box.py @@ -122,6 +122,9 @@ class ComboBox(QPushButton): self._showComboMenu() def _showComboMenu(self): + if not self.items: + return + menu = ComboBoxMenu(self) for i, item in enumerate(self.items): menu.addAction( diff --git a/qfluentwidgets/components/widgets/menu.py b/qfluentwidgets/components/widgets/menu.py index 5475ace..67d1a9b 100644 --- a/qfluentwidgets/components/widgets/menu.py +++ b/qfluentwidgets/components/widgets/menu.py @@ -554,10 +554,10 @@ class RoundMenu(QWidget): if self.isVisible(): return - desktop = QApplication.desktop().availableGeometry() - w, h = self.width() + 20, self.height() + 20 - pos.setX(max(10, min(pos.x() - self.layout().contentsMargins().left(), desktop.width() - w))) - pos.setY(max(10, min(pos.y() - 4, desktop.height() - h))) + rect = QApplication.screenAt(QCursor.pos()).availableGeometry() + w, h = self.width() + 5, self.height() + 5 + pos.setX(max(10, min(pos.x() - self.layout().contentsMargins().left(), rect.right() - w))) + pos.setY(max(10, min(pos.y() - 4, rect.bottom() - h))) if ani: self.ani.setStartValue(pos-QPoint(0, h/2)) diff --git a/setup.py b/setup.py index e724eee..44e17d3 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f: setuptools.setup( name="PyQt-Fluent-Widgets", - version="0.2.4", + version="0.2.5", keywords="pyqt fluent widgets", author="zhiyiYo", author_email="shokokawaii@outlook.com", -- GitLab