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

添加单向滚动区域示例

上级 5fed9e02
......@@ -737,6 +737,16 @@
<source>Chitanda Eru is so hot 🥵🥵</source>
<translation>春寒赐浴华清池温泉水滑洗凝脂 🥵🥵</translation>
</message>
<message>
<location filename="../../view/scroll_interface.py" line="67"/>
<source>Single direction scroll scroll area</source>
<translation>单方向平滑滚动区域</translation>
</message>
<message>
<location filename="../../view/scroll_interface.py" line="73"/>
<source>Chitanda Eru is so hot 🥵🥵🥵</source>
<translation>春宵苦短日高起从此君王不早朝🥵🥵🥵</translation>
</message>
</context>
<context>
<name>SettingInterface</name>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_HK" sourcelanguage="en_US">
<TS version="2.1" language="zh_CN" sourcelanguage="en_US">
<context>
<name>BasicInputInterface</name>
<message>
......@@ -737,6 +737,16 @@
<source>Chitanda Eru is so hot 🥵🥵</source>
<translation>春寒賜浴華清池温泉水滑洗凝脂 🥵🥵</translation>
</message>
<message>
<location filename="../../view/scroll_interface.py" line="67"/>
<source>Single direction scroll scroll area</source>
<translation>單方向平滑滾動區域</translation>
</message>
<message>
<location filename="../../view/scroll_interface.py" line="73"/>
<source>Chitanda Eru is so hot 🥵🥵🥵</source>
<translation>春宵苦短日高起從此君王不早朝🥵🥵🥵</translation>
</message>
</context>
<context>
<name>SettingInterface</name>
......
......@@ -109,6 +109,7 @@
<file>images/chidanta.jpg</file>
<file>images/chidanta2.jpg</file>
<file>images/chidanta3.jpg</file>
<file>images/chidanta4.jpg</file>
<file>images/header.png</file>
<file>images/header1.png</file>
<file>images/kunkun.png</file>
......
......@@ -2,7 +2,7 @@
from PyQt5.QtCore import Qt, QEasingCurve
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QWidget
from qfluentwidgets import SingleDirectionScrollArea, SmoothScrollArea, ToolTipFilter, PixmapLabel
from qfluentwidgets import SingleDirectionScrollArea, SmoothScrollArea, ToolTipFilter, PixmapLabel, ScrollArea
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -19,7 +19,8 @@ class ScrollInterface(GalleryInterface):
parent=parent
)
w = SingleDirectionScrollArea()
# scroll area
w = ScrollArea()
label = PixmapLabel(self)
label.setPixmap(QPixmap(":/gallery/images/chidanta2.jpg").scaled(
775, 1229, Qt.KeepAspectRatio, Qt.SmoothTransformation
......@@ -28,7 +29,6 @@ class ScrollInterface(GalleryInterface):
w.horizontalScrollBar().setValue(0)
w.setWidget(label)
w.setFixedSize(775, 430)
w.setObjectName('imageViewer')
card = self.addExampleCard(
self.tr('Smooth scroll area'),
......@@ -39,13 +39,13 @@ class ScrollInterface(GalleryInterface):
card.card.setToolTip(self.tr('Chitanda Eru is too hot 🥵'))
card.card.setToolTipDuration(2000)
# smooth scroll area
w = SmoothScrollArea()
label = PixmapLabel(self)
label.setPixmap(QPixmap(":/gallery/images/chidanta3.jpg"))
w.setWidget(label)
w.setFixedSize(660, 540)
w.setObjectName('imageViewer')
card = self.addExampleCard(
self.tr('Smooth scroll area implemented by animation'),
......@@ -55,3 +55,20 @@ class ScrollInterface(GalleryInterface):
card.card.installEventFilter(ToolTipFilter(card.card, showDelay=500))
card.card.setToolTip(self.tr('Chitanda Eru is so hot 🥵🥵'))
card.card.setToolTipDuration(2000)
# single direction scroll area
w = SingleDirectionScrollArea(self, Qt.Horizontal)
label = PixmapLabel(self)
label.setPixmap(QPixmap(":/gallery/images/chidanta4.jpg"))
w.setWidget(label)
w.setFixedSize(660, 498)
card = self.addExampleCard(
self.tr('Single direction scroll scroll area'),
w,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/scroll_area/demo.py',
)
card.card.installEventFilter(ToolTipFilter(card.card, showDelay=500))
card.card.setToolTip(self.tr('Chitanda Eru is so hot 🥵🥵🥵'))
card.card.setToolTipDuration(2000)
......@@ -333,15 +333,14 @@ class ScrollBar(QWidget):
self.move(1, size.height() - 13)
def _adjustHandleSize(self):
total = self.maximum() - self.minimum() + self.parent().height()
if total != 0:
s = int(self._grooveLength() * self.parent().height() / total)
else:
s = 1
p = self.parent()
if self.orientation() == Qt.Vertical:
total = self.maximum() - self.minimum() + p.height()
s = int(self._grooveLength() * p.height() / max(total, 1))
self.handle.setFixedHeight(max(40, s))
else:
total = self.maximum() - self.minimum() + p.width()
s = int(self._grooveLength() * p.width() / max(total, 1))
self.handle.setFixedWidth(max(40, s))
def _adjustHandlePos(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册