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

调整提示气泡的样式为圆角

上级 949e71a1
......@@ -5,7 +5,7 @@ from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSetti
ColorSettingCard, HyperlinkCard, PrimaryPushSettingCard, ScrollArea,
ComboBoxSettingCard, ExpandLayout, setStyleSheet, ToastToolTip)
from qfluentwidgets import FluentIconFactory as FIF
from PyQt5.QtCore import Qt, pyqtSignal, QUrl
from PyQt5.QtCore import Qt, pyqtSignal, QUrl, QStandardPaths
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QWidget, QLabel, QFontDialog, QFileDialog
......@@ -33,6 +33,7 @@ class SettingInterface(ScrollArea):
self.musicFolderCard = FolderListSettingCard(
cfg.musicFolders,
self.tr("Local music library"),
directory=QStandardPaths.writableLocation(QStandardPaths.MusicLocation),
parent=self.musicInThisPCGroup
)
self.downloadFolderCard = PushSettingCard(
......
......@@ -10,7 +10,7 @@ online at https://pyqt-fluent-widgets.readthedocs.io.
:license: MIT, see LICENSE for more details.
"""
__version__ = "0.2.5"
__version__ = "0.2.6"
from .components import *
from .common import *
......
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 16 16">
<g>
<path id="path1" transform="rotate(0,8,8) translate(0,0) scale(0.205128205128205,0.205128205128205) " fill="#000000" d="M15,12L16.13671875,12.22265625 17.109375,12.890625 45,40.78125 72.890625,12.890625 73.86328125,12.22265625 75,12 76.13671875,12.22265625 77.109375,12.890625 77.77734375,13.86328125 78,15 77.77734375,16.13671875 77.109375,17.109375 49.21875,45 77.109375,72.890625 77.77734375,73.86328125 78,75 77.77734375,76.13671875 77.109375,77.109375 76.13671875,77.77734375 75,78 73.86328125,77.77734375 72.890625,77.109375 45,49.21875 17.109375,77.109375 16.13671875,77.77734375 15,78 13.8632802963257,77.77734375 12.890625,77.109375 12.22265625,76.13671875 12,75 12.22265625,73.86328125 12.890625,72.890625 40.78125,45 12.890625,17.109375 12.22265625,16.13671875 12,15 12.22265625,13.86328125 12.890625,12.890625 13.8632802963257,12.22265625 15,12z" />
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 16 16">
<g>
<path id="path1" transform="rotate(0,8,8) translate(-1,-1) scale(0.0345572354211663,0.0345572354211663) " fill="#CCEAF1" d="M79,49L256,225.75 433,49 463,79 286.25,256 463,433 433,463 256,286.25 79,463 49,433 225.75,256 49,79 79,49z" />
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 16 16">
<g>
<path id="path1" transform="rotate(0,8,8) translate(-1,-1) scale(0.0345572354211663,0.0345572354211663) " fill="#FFFFFF" d="M79,49L256,225.75 433,49 463,79 286.25,256 463,433 433,463 256,286.25 79,463 49,433 225.75,256 49,79 79,49z" />
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 16 16">
<g>
<path id="path1" transform="rotate(0,8,8) translate(-1,-1) scale(0.0345572354211663,0.0345572354211663) " fill="#99D6E4" d="M79,49L256,225.75 433,49 463,79 286.25,256 463,433 433,463 256,286.25 79,463 49,433 225.75,256 49,79 79,49z" />
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 16 16">
<g>
<path id="path1" transform="rotate(0,8,8) translate(0,0) scale(0.205128205128205,0.205128205128205) " fill="#FFFFFF" d="M15,12L16.13671875,12.22265625 17.109375,12.890625 45,40.78125 72.890625,12.890625 73.86328125,12.22265625 75,12 76.13671875,12.22265625 77.109375,12.890625 77.77734375,13.86328125 78,15 77.77734375,16.13671875 77.109375,17.109375 49.21875,45 77.109375,72.890625 77.77734375,73.86328125 78,75 77.77734375,76.13671875 77.109375,77.109375 76.13671875,77.77734375 75,78 73.86328125,77.77734375 72.890625,77.109375 45,49.21875 17.109375,77.109375 16.13671875,77.77734375 15,78 13.8632802963257,77.77734375 12.890625,77.109375 12.22265625,76.13671875 12,75 12.22265625,73.86328125 12.890625,72.890625 40.78125,45 12.890625,17.109375 12.22265625,16.13671875 12,15 12.22265625,13.86328125 12.890625,12.890625 13.8632802963257,12.22265625 15,12z" />
</g>
</svg>
QWidget {
StateToolTip,
ToastToolTip {
background-color: rgb(0, 107, 131);
border: none;
border-radius: 7px;
}
QLabel#titleLabel {
color: white;
background-color: transparent;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
QLabel#contentLabel {
color: white;
background-color: transparent;
font: 13px 'Segoe UI', 'Microsoft YaHei';
}
QToolButton {
border: none;
margin: 0px;
width: 11px;
height: 11px;
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_white.svg) top center no-repeat;
}
QToolButton:hover {
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_black.svg) top center no-repeat;
}
QToolButton:pressed {
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_black.svg) top center no-repeat;
}
\ No newline at end of file
QWidget {
StateToolTip,
ToastToolTip {
background-color: rgb(0, 107, 131);
border: none;
border-radius: 7px;
}
QLabel#titleLabel {
color: white;
background-color: transparent;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
QLabel#contentLabel {
color: white;
background-color: transparent;
font: 13px 'Segoe UI', 'Microsoft YaHei';
}
QToolButton {
border: none;
margin: 0px;
width: 11px;
height: 11px;
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_white.svg) top center no-repeat;
}
QToolButton:hover {
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_black.svg) top center no-repeat;
}
QToolButton:pressed {
border-image: url(:/qfluentwidgets/images/state_tool_tip/close_black.svg) top center no-repeat;
}
\ No newline at end of file
此差异已折叠。
......@@ -75,8 +75,9 @@
<file>images/icons/Zoom_white.svg</file>
<file>images/icons/Language_black.svg</file>
<file>images/icons/Language_white.svg</file>
<file>images/state_tool_tip/close_white.svg</file>
<file>images/state_tool_tip/close_black.svg</file>
<file>images/state_tool_tip/close_normal.svg</file>
<file>images/state_tool_tip/close_hover.svg</file>
<file>images/state_tool_tip/close_pressed.svg</file>
<file>images/state_tool_tip/completed.svg</file>
<file>images/state_tool_tip/info.svg</file>
<file>images/state_tool_tip/running.svg</file>
......
......@@ -97,7 +97,7 @@ class FolderListSettingCard(ExpandSettingCard):
folderChanged = pyqtSignal(list)
def __init__(self, configItem: ConfigItem, title: str, content: str = None, parent=None):
def __init__(self, configItem: ConfigItem, title: str, content: str = None, directory="./", parent=None):
"""
Parameters
----------
......@@ -110,11 +110,15 @@ class FolderListSettingCard(ExpandSettingCard):
content: str
the content of card
directory: str
working directory of file dialog
parent: QWidget
parent widget
"""
super().__init__(FIF.path(FIF.FOLDER), title, content, parent)
self.configItem = configItem
self._dialogDirectory = directory
self.addFolderButton = PushButton(
FIF.path(FIF.FOLDER_ADD), self.tr('Add folder'), self)
......@@ -136,7 +140,7 @@ class FolderListSettingCard(ExpandSettingCard):
def __showFolderDialog(self):
""" show folder dialog """
folder = QFileDialog.getExistingDirectory(
self, self.tr("Choose folder"), "./")
self, self.tr("Choose folder"), self._dialogDirectory)
if not folder or folder in self.folders:
return
......
......@@ -5,6 +5,7 @@ from PyQt5.QtWidgets import QLabel, QWidget, QToolButton, QGraphicsOpacityEffect
from PyQt5.QtSvg import QSvgWidget
from ...common import setStyleSheet, drawSvgIcon
from ...components.widgets.three_state_button import ThreeStateButton, ButtonState
class StateToolTip(QWidget):
......@@ -36,7 +37,15 @@ class StateToolTip(QWidget):
self.animation = QPropertyAnimation(self, b"windowOpacity")
self.busyIconPath = ":/qfluentwidgets/images/state_tool_tip/running.svg"
self.doneIconPath = ":/qfluentwidgets/images/state_tool_tip/completed.svg"
self.closeButton = QToolButton(self)
self.closeButton = ThreeStateButton(
{
ButtonState.NORMAL: ':/qfluentwidgets/images/state_tool_tip/close_normal.svg',
ButtonState.HOVER: ':/qfluentwidgets/images/state_tool_tip/close_hover.svg',
ButtonState.PRESSED: ':/qfluentwidgets/images/state_tool_tip/close_pressed.svg',
},
parent=self,
buttonSize=(12, 12)
)
self.isDone = False
self.rotateAngle = 0
......@@ -67,7 +76,7 @@ class StateToolTip(QWidget):
self.contentLabel.width()) + 56, 51)
self.titleLabel.move(32, 9)
self.contentLabel.move(12, 27)
self.closeButton.move(self.width() - 24, 18)
self.closeButton.move(self.width() - 24, 19)
def __setQss(self):
""" set style sheet """
......@@ -124,7 +133,7 @@ class StateToolTip(QWidget):
""" paint state tooltip """
super().paintEvent(e)
painter = QPainter(self)
painter.setRenderHints(QPainter.SmoothPixmapTransform)
painter.setRenderHints(QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
if not self.isDone:
painter.translate(19, 18)
......@@ -161,11 +170,19 @@ class ToastToolTip(QWidget):
self.titleLabel = QLabel(self.title, self)
self.contentLabel = QLabel(self.content, self)
self.iconLabel = QSvgWidget(self.icon, self)
self.closeButton = QToolButton(self)
self.closeTimer = QTimer(self)
self.opacityEffect = QGraphicsOpacityEffect(self)
self.opacityAni = QPropertyAnimation(self.opacityEffect, b"opacity")
self.slideAni = QPropertyAnimation(self, b'pos')
self.closeButton = ThreeStateButton(
{
ButtonState.NORMAL: ':/qfluentwidgets/images/state_tool_tip/close_normal.svg',
ButtonState.HOVER: ':/qfluentwidgets/images/state_tool_tip/close_hover.svg',
ButtonState.PRESSED: ':/qfluentwidgets/images/state_tool_tip/close_pressed.svg',
},
parent=self,
buttonSize=(12, 12)
)
self.__initWidget()
......@@ -175,7 +192,7 @@ class ToastToolTip(QWidget):
self.closeButton.setFixedSize(QSize(11, 11))
self.closeButton.setIconSize(QSize(11, 11))
self.closeTimer.setInterval(2000)
self.contentLabel.setMinimumWidth(250)
self.contentLabel.setMinimumWidth(180)
self.iconLabel.resize(16, 16)
self.iconLabel.move(12, 10)
......@@ -196,7 +213,7 @@ class ToastToolTip(QWidget):
self.contentLabel.width()) + 72, 51)
self.titleLabel.move(32, 9)
self.contentLabel.move(12, 27)
self.closeButton.move(self.width() - 24, 18)
self.closeButton.move(self.width() - 24, 19)
def __setQss(self):
""" set style sheet """
......
# coding:utf-8
from enum import Enum
from PyQt5.QtCore import QEvent, QSize, Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QToolButton
class ButtonState(Enum):
""" Button state """
NORMAL = 0
HOVER = 1
PRESSED = 2
class ThreeStateButton(QToolButton):
""" Three state tool button class """
def __init__(self, iconPaths, parent=None, buttonSize=(40, 40), iconSize=None):
"""
Parameters
----------
iconPaths: Dict[ButtonState, str]
icon path dict
parent:
parent window
button: tuple
button size
iconSize: tuple
icon size
"""
super().__init__(parent)
self.iconPaths = iconPaths
self.resize(*buttonSize)
self.setIconSize(self.size() if not iconSize else QSize(*iconSize))
self.setCursor(Qt.ArrowCursor)
self.setStyleSheet('border: none; margin: 0px; background: transparent')
self.setState(ButtonState.NORMAL)
self.installEventFilter(self)
def eventFilter(self, obj, e):
if obj is self:
if e.type() == QEvent.Enter:
self.setState(ButtonState.HOVER)
if e.type() in [QEvent.Leave, QEvent.MouseButtonRelease]:
self.setState(ButtonState.NORMAL)
if e.type() == QEvent.MouseButtonPress:
self.setState(ButtonState.PRESSED)
return super().eventFilter(obj, e)
def setState(self, state):
""" set the state of button """
self.setIcon(QIcon(self.iconPaths[state]))
\ No newline at end of file
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.2.5",
version="0.2.6",
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.
先完成此消息的编辑!
想要评论请 注册