提交 d654dc35 编写于 作者: 之一Yo's avatar 之一Yo

修复导航窗口展开时仍然显示工具提示的问题,fixes #165

上级 1b7d725c
...@@ -171,7 +171,8 @@ class MainWindow(FramelessWindow): ...@@ -171,7 +171,8 @@ class MainWindow(FramelessWindow):
icon=icon, icon=icon,
text=text, text=text,
onClick=lambda t: self.switchTo(interface, t), onClick=lambda t: self.switchTo(interface, t),
position=position position=position,
tooltip=text
) )
def initWindow(self): def initWindow(self):
......
...@@ -26,11 +26,6 @@ QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) ...@@ -26,11 +26,6 @@ QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings) app.setAttribute(Qt.AA_DontCreateNativeWidgetSiblings)
# font anti aliasing
font = app.font()
font.setHintingPreference(QFont.PreferNoHinting)
app.setFont(font)
# internationalization # internationalization
locale = cfg.get(cfg.language).value locale = cfg.get(cfg.language).value
translator = FluentTranslator(locale) translator = FluentTranslator(locale)
......
...@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma ...@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details. :license: GPLv3, see LICENSE for more details.
""" """
__version__ = "0.8.3" __version__ = "0.8.4"
from .components import * from .components import *
from .common import * from .common import *
......
...@@ -55,6 +55,21 @@ ...@@ -55,6 +55,21 @@
<translation>取消</translation> <translation>取消</translation>
</message> </message>
</context> </context>
<context>
<name>NavigationPanel</name>
<message>
<source>Open Navigation</source>
<translation>打开导航</translation>
</message>
<message>
<source>Close Navigation</source>
<translation>关闭导航</translation>
</message>
<message>
<source>Back</source>
<translation>返回</translation>
</message>
</context>
<context> <context>
<name>Dialog</name> <name>Dialog</name>
<message> <message>
......
...@@ -55,6 +55,21 @@ ...@@ -55,6 +55,21 @@
<translation>取消</translation> <translation>取消</translation>
</message> </message>
</context> </context>
<context>
<name>NavigationPanel</name>
<message>
<source>Open Navigation</source>
<translation>打開導航</translation>
</message>
<message>
<source>Close Navigation</source>
<translation>關閉導航</translation>
</message>
<message>
<source>Back</source>
<translation>返回</translation>
</message>
</context>
<context> <context>
<name>Dialog</name> <name>Dialog</name>
<message> <message>
......
...@@ -55,6 +55,21 @@ ...@@ -55,6 +55,21 @@
<translation>取消</translation> <translation>取消</translation>
</message> </message>
</context> </context>
<context>
<name>NavigationPanel</name>
<message>
<source>Open Navigation</source>
<translation>打開導航</translation>
</message>
<message>
<source>Close Navigation</source>
<translation>關閉導航</translation>
</message>
<message>
<source>Back</source>
<translation>返回</translation>
</message>
</context>
<context> <context>
<name>Dialog</name> <name>Dialog</name>
<message> <message>
......
...@@ -10,8 +10,8 @@ QTreeView { ...@@ -10,8 +10,8 @@ QTreeView {
QTreeView::item { QTreeView::item {
padding: 4px; padding: 4px;
margin-top: 3px; margin-top: 2px;
margin-bottom: 3px; margin-bottom: 2px;
padding-left: 20px; padding-left: 20px;
border-radius: 5px; border-radius: 5px;
color: white; color: white;
......
此差异已折叠。
...@@ -29,6 +29,15 @@ class NavigationItemPosition(Enum): ...@@ -29,6 +29,15 @@ class NavigationItemPosition(Enum):
BOTTOM = 2 BOTTOM = 2
class NavigationToolTipFilter(ToolTipFilter):
""" Navigation tool tip filter """
def _canShowToolTip(self) -> bool:
isVisible = super()._canShowToolTip()
parent = self.parent() # type: NavigationWidget
return isVisible and parent.isCompacted
class NavigationPanel(QFrame): class NavigationPanel(QFrame):
""" Navigation panel """ """ Navigation panel """
...@@ -189,7 +198,7 @@ class NavigationPanel(QFrame): ...@@ -189,7 +198,7 @@ class NavigationPanel(QFrame):
if tooltip: if tooltip:
widget.setToolTip(tooltip) widget.setToolTip(tooltip)
widget.installEventFilter(ToolTipFilter(widget, 1000)) widget.installEventFilter(NavigationToolTipFilter(widget, 1000))
self._addWidgetToLayout(widget, position) self._addWidgetToLayout(widget, position)
......
...@@ -153,7 +153,7 @@ class TextEdit(QTextEdit): ...@@ -153,7 +153,7 @@ class TextEdit(QTextEdit):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
self.installEventFilter(SmoothScrollDelegate(self)) self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self) FluentStyleSheet.LINE_EDIT.apply(self)
def contextMenuEvent(self, e): def contextMenuEvent(self, e):
...@@ -166,7 +166,7 @@ class PlainTextEdit(QPlainTextEdit): ...@@ -166,7 +166,7 @@ class PlainTextEdit(QPlainTextEdit):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent=parent) super().__init__(parent=parent)
self.installEventFilter(SmoothScrollDelegate(self)) self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self) FluentStyleSheet.LINE_EDIT.apply(self)
def contextMenuEvent(self, e): def contextMenuEvent(self, e):
......
...@@ -334,7 +334,7 @@ class ScrollBar(QWidget): ...@@ -334,7 +334,7 @@ class ScrollBar(QWidget):
def _adjustHandleSize(self): def _adjustHandleSize(self):
total = self.maximum() - self.minimum() + self.parent().height() total = self.maximum() - self.minimum() + self.parent().height()
if total != 0: if total != 0:
s = self._grooveLength() * self.parent().height() / total s = int(self._grooveLength() * self.parent().height() / total)
else: else:
s = 1 s = 1
...@@ -345,7 +345,7 @@ class ScrollBar(QWidget): ...@@ -345,7 +345,7 @@ class ScrollBar(QWidget):
def _adjustHandlePos(self): def _adjustHandlePos(self):
total = max(self.maximum() - self.minimum(), 1) total = max(self.maximum() - self.minimum(), 1)
delta = self.value() / total * self._slideLength() delta = int(self.value() / total * self._slideLength())
if self.orientation() == Qt.Vertical: if self.orientation() == Qt.Vertical:
x = self.width() - self.handle.width() - 3 x = self.width() - self.handle.width() - 3
......
...@@ -264,6 +264,8 @@ class ToolTipFilter(QObject): ...@@ -264,6 +264,8 @@ class ToolTipFilter(QObject):
self._tooltipDelay = showDelay self._tooltipDelay = showDelay
self.position = position self.position = position
self.timer = QTimer(self) self.timer = QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.showToolTip)
def eventFilter(self, obj: QObject, e: QEvent) -> bool: def eventFilter(self, obj: QObject, e: QEvent) -> bool:
if e.type() == QEvent.ToolTip: if e.type() == QEvent.ToolTip:
...@@ -273,7 +275,7 @@ class ToolTipFilter(QObject): ...@@ -273,7 +275,7 @@ class ToolTipFilter(QObject):
elif e.type() == QEvent.Enter: elif e.type() == QEvent.Enter:
self.isEnter = True self.isEnter = True
parent = self.parent() # type: QWidget parent = self.parent() # type: QWidget
if parent.isWidgetType() and parent.toolTip() and parent.isEnabled(): if self._canShowToolTip():
if self._tooltip is None: if self._tooltip is None:
self._tooltip = ToolTip(parent.toolTip(), parent.window()) self._tooltip = ToolTip(parent.toolTip(), parent.window())
...@@ -281,13 +283,16 @@ class ToolTipFilter(QObject): ...@@ -281,13 +283,16 @@ class ToolTipFilter(QObject):
self._tooltip.setDuration(t) self._tooltip.setDuration(t)
# show the tool tip after delay # show the tool tip after delay
QTimer.singleShot(self._tooltipDelay, self.showToolTip) self.timer.start(self._tooltipDelay)
elif e.type() == QEvent.MouseButtonPress:
self.hideToolTip()
return super().eventFilter(obj, e) return super().eventFilter(obj, e)
def hideToolTip(self): def hideToolTip(self):
""" hide tool tip """ """ hide tool tip """
self.isEnter = False self.isEnter = False
self.timer.stop()
if self._tooltip: if self._tooltip:
self._tooltip.hide() self._tooltip.hide()
...@@ -304,3 +309,7 @@ class ToolTipFilter(QObject): ...@@ -304,3 +309,7 @@ class ToolTipFilter(QObject):
def setToolTipDelay(self, delay: int): def setToolTipDelay(self, delay: int):
""" set the delay of tool tip """ """ set the delay of tool tip """
self._tooltipDelay = delay self._tooltipDelay = delay
def _canShowToolTip(self) -> bool:
parent = self.parent() # type: QWidget
return parent.isWidgetType() and parent.toolTip() and parent.isEnabled()
...@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f: ...@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup( setuptools.setup(
name="PyQt-Fluent-Widgets", name="PyQt-Fluent-Widgets",
version="0.8.3", version="0.8.4",
keywords="pyqt fluent widgets", keywords="pyqt fluent widgets",
author="zhiyiYo", author="zhiyiYo",
author_email="shokokawaii@outlook.com", author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册