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

fixes #67

上级 35d14c98
......@@ -2,15 +2,15 @@
import sys
from PyQt5.QtCore import QEasingCurve, Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel
from qfluentwidgets import SmoothScrollArea
from PyQt5.QtWidgets import QApplication
from qfluentwidgets import SmoothScrollArea, PixmapLabel
class Demo(SmoothScrollArea):
def __init__(self):
super().__init__()
self.label = QLabel(self)
self.label = PixmapLabel(self)
self.label.setPixmap(QPixmap("resource/shoko.jpg"))
# customize scroll animation
......
QScrollBar {
QScrollBar:vertical {
background: transparent;
width: 5px;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 5px;
padding-bottom: 2px;
}
/*隐藏上箭头*/
QScrollBar::sub-line {
background: transparent;
......@@ -18,9 +24,16 @@ QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 40px;
}
QScrollBar::handle:horizontal {
min-width: 40px;
}
QScrollBar::add-page,
QScrollBar::sub-page {
background: none;
......
......@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__ = "0.5.3"
__version__ = "0.5.4"
from .components import *
from .common import *
......
......@@ -34,6 +34,7 @@ class ScrollArea(QScrollArea):
def wheelEvent(self, e):
self.smoothScroll.wheelEvent(e)
class SmoothScrollBar(QScrollBar):
""" Smooth scroll bar """
......@@ -46,9 +47,11 @@ class SmoothScrollBar(QScrollBar):
self.ani.setPropertyName(b"value")
self.ani.setEasingCurve(QEasingCurve.OutCubic)
self.ani.setDuration(500)
self.__value = self.value()
self.ani.finished.connect(self.scrollFinished)
def setValue(self, value: int):
def setValue(self, value):
if value == self.value():
return
......@@ -60,27 +63,37 @@ class SmoothScrollBar(QScrollBar):
self.ani.setEndValue(value)
self.ani.start()
def scrollValue(self, value: int):
def scrollValue(self, value):
""" scroll the specified distance """
value += self.value()
self.scrollTo(value)
self.__value += value
self.__value = max(self.minimum(), self.__value)
self.__value = min(self.maximum(), self.__value)
self.setValue(self.__value)
def scrollTo(self, value: int):
def scrollTo(self, value):
""" scroll to the specified position """
value = min(self.maximum(), max(self.minimum(), value))
self.setValue(value)
self.__value = value
self.__value = max(self.minimum(), self.__value)
self.__value = min(self.maximum(), self.__value)
self.setValue(self.__value)
def resetValue(self, value):
self.__value = value
def mousePressEvent(self, e):
self.ani.stop()
super().mousePressEvent(e)
self.__value = self.value()
def mouseReleaseEvent(self, e):
self.ani.stop()
super().mouseReleaseEvent(e)
self.__value = self.value()
def mouseMoveEvent(self, e):
self.ani.stop()
super().mouseMoveEvent(e)
self.__value = self.value()
class SmoothScrollArea(QScrollArea):
......
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.5.3",
version="0.5.4",
keywords="pyqt fluent widgets",
author="zhiyiYo",
author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册