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

调整图标路径

上级 3ccf79f9
# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QWidget, QAction, QHBoxLayout, QLabel
from qfluentwidgets import RoundMenu
from qfluentwidgets import MenuIconFactory as MIF
from qfluentwidgets import FluentIconFactory as FIF
class Demo(QWidget):
......@@ -23,16 +22,16 @@ class Demo(QWidget):
menu = RoundMenu(parent=self)
# add actions
menu.addAction(QAction(MIF.create(MIF.COPY), 'Copy'))
menu.addAction(QAction(MIF.create(MIF.CUT), 'Cut'))
menu.addAction(QAction(FIF.icon(FIF.COPY), 'Copy'))
menu.addAction(QAction(FIF.icon(FIF.CUT), 'Cut'))
submenu = RoundMenu("Add To", self)
submenu.setIcon(MIF.create(MIF.ADD))
submenu.setIcon(FIF.icon(FIF.ADD))
menu.addMenu(submenu)
# add actions
menu.addAction(QAction(MIF.create(MIF.PASTE), 'Paste'))
menu.addAction(QAction(MIF.create(MIF.CANCEL), 'Undo'))
menu.addAction(QAction(FIF.icon(FIF.PASTE), 'Paste'))
menu.addAction(QAction(FIF.icon(FIF.CANCEL), 'Undo'))
# add separator
menu.addSeparator()
......
......@@ -342,7 +342,7 @@
</message>
<message>
<source>Configuration takes effect after restart</source>
<translation>配置在重啓 Groove 後生效</translation>
<translation>配置在重啓軟件後生效</translation>
</message>
</context>
</TS>
\ No newline at end of file
......@@ -342,7 +342,7 @@
</message>
<message>
<source>Configuration takes effect after restart</source>
<translation>配置在重启 Groove 后生效</translation>
<translation>配置在重启软件后生效</translation>
</message>
</context>
</TS>
\ No newline at end of file
......@@ -4,7 +4,7 @@ from qfluentwidgets import (SettingCardGroup, SwitchSettingCard, FolderListSetti
OptionsSettingCard, RangeSettingCard, PushSettingCard,
ColorSettingCard, HyperlinkCard, PrimaryPushSettingCard, ScrollArea,
ExpandLayout, setStyleSheet, ToastToolTip)
from qfluentwidgets import SettingIconFactory as SIF
from qfluentwidgets import FluentIconFactory as FIF
from PyQt5.QtCore import Qt, pyqtSignal, QUrl
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QWidget, QLabel, QFontDialog, QFileDialog
......@@ -37,7 +37,7 @@ class SettingInterface(ScrollArea):
)
self.downloadFolderCard = PushSettingCard(
self.tr('Choose folder'),
SIF.create(SIF.DOWNLOAD),
FIF.path(FIF.DOWNLOAD),
self.tr("Download directory"),
cfg.get(cfg.downloadFolder),
self.musicInThisPCGroup
......@@ -46,7 +46,7 @@ class SettingInterface(ScrollArea):
# personalization
self.personalGroup = SettingCardGroup(self.tr('Personalization'), self.scrollWidget)
self.enableAcrylicCard = SwitchSettingCard(
SIF.create(SIF.TRANSPARENT),
FIF.path(FIF.TRANSPARENT),
self.tr("Use Acrylic effect"),
self.tr("Acrylic effect has better visual experience, but it may cause the window to become stuck"),
configItem=cfg.enableAcrylicBackground,
......@@ -54,7 +54,7 @@ class SettingInterface(ScrollArea):
)
self.themeCard = OptionsSettingCard(
cfg.themeMode,
SIF.create(SIF.BRUSH),
FIF.path(FIF.BRUSH),
self.tr('Application theme'),
self.tr("Change the appearance of your application"),
texts=[
......@@ -65,7 +65,7 @@ class SettingInterface(ScrollArea):
)
self.zoomCard = OptionsSettingCard(
cfg.dpiScale,
SIF.create(SIF.ZOOM),
FIF.path(FIF.ZOOM),
self.tr("Interface zoom"),
self.tr("Change the size of widgets and fonts"),
texts=[
......@@ -76,7 +76,7 @@ class SettingInterface(ScrollArea):
)
self.languageCard = OptionsSettingCard(
cfg.language,
SIF.create(SIF.LANGUAGE),
FIF.path(FIF.LANGUAGE),
self.tr('Language'),
self.tr('Set your preferred language for UI'),
texts=['简体中文', '繁體中文', 'English', self.tr('Use system setting')],
......@@ -87,13 +87,13 @@ class SettingInterface(ScrollArea):
self.onlineMusicGroup = SettingCardGroup(self.tr('Online Music'), self.scrollWidget)
self.onlinePageSizeCard = RangeSettingCard(
cfg.onlinePageSize,
SIF.create(SIF.SEARCH),
FIF.path(FIF.SEARCH),
self.tr("Number of online music displayed on each page"),
parent=self.onlineMusicGroup
)
self.onlineMusicQualityCard = OptionsSettingCard(
cfg.onlineSongQuality,
SIF.create(SIF.MUSIC),
FIF.path(FIF.MUSIC),
self.tr('Online music quality'),
texts=[
self.tr('Standard quality'), self.tr('High quality'),
......@@ -103,7 +103,7 @@ class SettingInterface(ScrollArea):
)
self.onlineMvQualityCard = OptionsSettingCard(
cfg.onlineMvQuality,
SIF.create(SIF.VIDEO),
FIF.path(FIF.VIDEO),
self.tr('Online MV quality'),
texts=[
self.tr('Full HD'), self.tr('HD'),
......@@ -116,31 +116,31 @@ class SettingInterface(ScrollArea):
self.deskLyricGroup = SettingCardGroup(self.tr('Desktop Lyric'), self.scrollWidget)
self.deskLyricFontCard = PushSettingCard(
self.tr('Choose font'),
SIF.create(SIF.FONT),
FIF.path(FIF.FONT),
self.tr('Font'),
parent=self.deskLyricGroup
)
self.deskLyricHighlightColorCard = ColorSettingCard(
cfg.deskLyricHighlightColor,
SIF.create(SIF.PALETTE),
FIF.path(FIF.PALETTE),
self.tr('Foreground color'),
parent=self.deskLyricGroup
)
self.deskLyricStrokeColorCard = ColorSettingCard(
cfg.deskLyricStrokeColor,
SIF.create(SIF.PENCIL_INK),
FIF.path(FIF.PENCIL_INK),
self.tr('Stroke color'),
parent=self.deskLyricGroup
)
self.deskLyricStrokeSizeCard = RangeSettingCard(
cfg.deskLyricStrokeSize,
SIF.create(SIF.FLUORESCENT_PEN),
FIF.path(FIF.FLUORESCENT_PEN),
self.tr('Stroke size'),
parent=self.deskLyricGroup
)
self.deskLyricAlignmentCard = OptionsSettingCard(
cfg.deskLyricAlignment,
SIF.create(SIF.ALIGNMENT),
FIF.path(FIF.ALIGNMENT),
self.tr('Alignment'),
texts=[
self.tr('Center aligned'), self.tr('Left aligned'),
......@@ -152,7 +152,7 @@ class SettingInterface(ScrollArea):
# main panel
self.mainPanelGroup = SettingCardGroup(self.tr('Main Panel'), self.scrollWidget)
self.minimizeToTrayCard = SwitchSettingCard(
SIF.create(SIF.MINIMIZE),
FIF.path(FIF.MINIMIZE),
self.tr('Minimize to tray after closing'),
self.tr('PyQt-Fluent-Widgets will continue to run in the background'),
configItem=cfg.minimizeToTray,
......@@ -162,7 +162,7 @@ class SettingInterface(ScrollArea):
# update software
self.updateSoftwareGroup = SettingCardGroup(self.tr("Software update"), self.scrollWidget)
self.updateOnStartUpCard = SwitchSettingCard(
SIF.create(SIF.UPDATE),
FIF.path(FIF.UPDATE),
self.tr('Check for updates when the application starts'),
self.tr('The new version will be more stable and have more features'),
configItem=cfg.checkUpdateAtStartUp,
......@@ -174,21 +174,21 @@ class SettingInterface(ScrollArea):
self.helpCard = HyperlinkCard(
HELP_URL,
self.tr('Open help page'),
SIF.create(SIF.HELP),
FIF.path(FIF.HELP),
self.tr('Help'),
self.tr('Discover new features and learn useful tips about PyQt-Fluent-Widgets'),
self.aboutGroup
)
self.feedbackCard = PrimaryPushSettingCard(
self.tr('Provide feedback'),
SIF.create(SIF.FEEDBACK),
FIF.path(FIF.FEEDBACK),
self.tr('Provide feedback'),
self.tr('Help us improve PyQt-Fluent-Widgets by providing feedback'),
self.aboutGroup
)
self.aboutCard = PrimaryPushSettingCard(
self.tr('Check update'),
SIF.create(SIF.INFO),
FIF.path(FIF.INFO),
self.tr('About'),
'© ' + self.tr('Copyright') + f" {YEAR}, {AUTHOR}. " +
self.tr('Version') + f" {VERSION[1:]}",
......
<?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.5) scale(0.03125,0.03125) " fill="#000000" d="M261,128L229,149.25 220.781234741211,153.953140258789 212.124984741211,157.3125 203.031234741211,159.328125 193.5,160 32,160 32,416 32.625,422.53125 34.5,428.625 37.4375,434.09375 41.25,438.75 45.90625,442.5625 51.375,445.5 57.46875,447.375 64,448 448,448 454.5,447.375 460.5,445.5 465.90625,442.53125 470.625,438.625 474.53125,433.90625 477.5,428.5 479.374969482422,422.5 480,416 480,160 479.374969482422,153.656265258789 477.5,147.625 474.53125,142.125015258789 470.625,137.375 465.875,133.468765258789 460.375,130.5 454.34375,128.625 448,128 261,128z M64,64L57.5,64.625 51.5,66.5 46.09375,69.4687652587891 41.375,73.375 37.46875,78.0937652587891 34.5,83.5 32.625,89.5 32,96 32,128 193.5,128 199.125,127.5 204.5,126 209.65625,123.750007629395 214.625,121 224,114.5 233,108 209.5,76.75 204.4375,71.40625 198.25,67.375 194.828125,65.8984375 191.3125,64.84375 187.703125,64.2109375 184,64 64,64z M64,32L184,32 191.601547241211,32.4218902587891 198.906234741211,33.6875228881836 205.914047241211,35.7968902587891 212.625,38.75 218.960922241211,42.4531402587891 224.843734741211,46.8125228881836 230.2734375,51.8281402587891 235.25,57.5 249.75,76.75 264,96 448,96 454.5234375,96.3125 460.843719482422,97.2500076293945 466.960906982422,98.8125076293945 472.875,101 478.507781982422,103.734382629395 483.781219482422,106.937515258789 488.695281982422,110.609382629395 493.25,114.75 497.390625,119.304710388184 501.0625,124.218780517578 504.265625,129.492202758789 507,135.125 509.1875,141.0390625 510.75,147.15625 511.6875,153.476577758789 512,160 512,416 511.6875,422.5234375 510.75,428.84375 509.1875,434.9609375 507,440.875 504.265625,446.5078125 501.0625,451.78125 497.390625,456.6953125 493.25,461.25 488.695281982422,465.390625 483.781219482422,469.0625 478.507781982422,472.265625 472.875,475 466.960906982422,477.1875 460.843719482422,478.75 454.5234375,479.6875 448,480 64,480 57.4765625,479.6875 51.15625,478.75 45.0390625,477.1875 39.125,475 33.4921875,472.265625 28.21875,469.0625 23.3046875,465.390625 18.75,461.25 14.609375,456.6953125 10.9375,451.78125 7.734375,446.5078125 5,440.875 2.8125,434.9609375 1.25,428.84375 0.3125,422.5234375 0,416 0,96 0.3125,89.4765701293945 1.25,83.1562576293945 2.8125,77.0390625 5,71.125 7.734375,65.4921875 10.9375,60.2187538146973 14.609375,55.3046913146973 18.75,50.75 23.3046875,46.6093864440918 28.21875,42.9375114440918 33.4921875,39.7343826293945 39.125,37 45.0390625,34.8125114440918 51.15625,33.2500190734863 57.4765625,32.3125152587891 64,32z" />
</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.5) scale(0.03125,0.03125) " fill="#FFFFFF" d="M261,128L229,149.25 220.781234741211,153.953140258789 212.124984741211,157.3125 203.031234741211,159.328125 193.5,160 32,160 32,416 32.625,422.53125 34.5,428.625 37.4375,434.09375 41.25,438.75 45.90625,442.5625 51.375,445.5 57.46875,447.375 64,448 448,448 454.5,447.375 460.5,445.5 465.90625,442.53125 470.625,438.625 474.53125,433.90625 477.5,428.5 479.374969482422,422.5 480,416 480,160 479.374969482422,153.656265258789 477.5,147.625 474.53125,142.125015258789 470.625,137.375 465.875,133.468765258789 460.375,130.5 454.34375,128.625 448,128 261,128z M64,64L57.5,64.625 51.5,66.5 46.09375,69.4687652587891 41.375,73.375 37.46875,78.0937652587891 34.5,83.5 32.625,89.5 32,96 32,128 193.5,128 199.125,127.5 204.5,126 209.65625,123.750007629395 214.625,121 224,114.5 233,108 209.5,76.75 204.4375,71.40625 198.25,67.375 194.828125,65.8984375 191.3125,64.84375 187.703125,64.2109375 184,64 64,64z M64,32L184,32 191.601547241211,32.4218902587891 198.906234741211,33.6875228881836 205.914047241211,35.7968902587891 212.625,38.75 218.960922241211,42.4531402587891 224.843734741211,46.8125228881836 230.2734375,51.8281402587891 235.25,57.5 249.75,76.75 264,96 448,96 454.5234375,96.3125 460.843719482422,97.2500076293945 466.960906982422,98.8125076293945 472.875,101 478.507781982422,103.734382629395 483.781219482422,106.937515258789 488.695281982422,110.609382629395 493.25,114.75 497.390625,119.304710388184 501.0625,124.218780517578 504.265625,129.492202758789 507,135.125 509.1875,141.0390625 510.75,147.15625 511.6875,153.476577758789 512,160 512,416 511.6875,422.5234375 510.75,428.84375 509.1875,434.9609375 507,440.875 504.265625,446.5078125 501.0625,451.78125 497.390625,456.6953125 493.25,461.25 488.695281982422,465.390625 483.781219482422,469.0625 478.507781982422,472.265625 472.875,475 466.960906982422,477.1875 460.843719482422,478.75 454.5234375,479.6875 448,480 64,480 57.4765625,479.6875 51.15625,478.75 45.0390625,477.1875 39.125,475 33.4921875,472.265625 28.21875,469.0625 23.3046875,465.390625 18.75,461.25 14.609375,456.6953125 10.9375,451.78125 7.734375,446.5078125 5,440.875 2.8125,434.9609375 1.25,428.84375 0.3125,422.5234375 0,416 0,96 0.3125,89.4765701293945 1.25,83.1562576293945 2.8125,77.0390625 5,71.125 7.734375,65.4921875 10.9375,60.2187538146973 14.609375,55.3046913146973 18.75,50.75 23.3046875,46.6093864440918 28.21875,42.9375114440918 33.4921875,39.7343826293945 39.125,37 45.0390625,34.8125114440918 51.15625,33.2500190734863 57.4765625,32.3125152587891 64,32z" />
</g>
</svg>
此差异已折叠。
......@@ -3,80 +3,78 @@
<file>images/color_dialog/Clear_black.svg</file>
<file>images/color_dialog/Clear_white.svg</file>
<file>images/color_dialog/HuePanel.png</file>
<file>images/menu/Cancel_black.svg</file>
<file>images/menu/Cancel_white.svg</file>
<file>images/menu/ChevronRight_black.svg</file>
<file>images/menu/ChevronRight_white.svg</file>
<file>images/menu/Copy_black.svg</file>
<file>images/menu/Copy_white.svg</file>
<file>images/menu/Cut_black.svg</file>
<file>images/menu/Cut_white.svg</file>
<file>images/menu/Paste_black.svg</file>
<file>images/menu/Paste_white.svg</file>
<file>images/menu/Add_black.svg</file>
<file>images/menu/Add_white.svg</file>
<file>images/menu/Folder_black.svg</file>
<file>images/menu/Folder_white.svg</file>
<file>images/menu/Setting_black.svg</file>
<file>images/menu/Setting_white.svg</file>
<file>images/setting_card/Alignment_black.svg</file>
<file>images/setting_card/Alignment_white.svg</file>
<file>images/setting_card/BackgroundColor_black.svg</file>
<file>images/setting_card/BackgroundColor_white.svg</file>
<file>images/setting_card/Brush_black.svg</file>
<file>images/setting_card/Brush_white.svg</file>
<file>images/setting_card/ChevronDown_black.svg</file>
<file>images/setting_card/ChevronDown_white.svg</file>
<file>images/setting_card/Close_black.svg</file>
<file>images/setting_card/Close_white.svg</file>
<file>images/setting_card/Download_black.svg</file>
<file>images/setting_card/Download_white.svg</file>
<file>images/setting_card/Embed_black.svg</file>
<file>images/setting_card/Embed_white.svg</file>
<file>images/setting_card/Feedback_black.svg</file>
<file>images/setting_card/Feedback_white.svg</file>
<file>images/setting_card/FluorescentPen_black.svg</file>
<file>images/setting_card/FluorescentPen_white.svg</file>
<file>images/setting_card/FolderAdd_black.svg</file>
<file>images/setting_card/FolderAdd_white.svg</file>
<file>images/setting_card/Folder_black.svg</file>
<file>images/setting_card/Folder_white.svg</file>
<file>images/setting_card/Font_black.svg</file>
<file>images/setting_card/Font_white.svg</file>
<file>images/setting_card/Help_black.svg</file>
<file>images/setting_card/Help_white.svg</file>
<file>images/setting_card/Info_black.svg</file>
<file>images/setting_card/Info_white.svg</file>
<file>images/setting_card/Link_black.svg</file>
<file>images/setting_card/Link_white.svg</file>
<file>images/setting_card/Minimize_black.svg</file>
<file>images/setting_card/Minimize_white.svg</file>
<file>images/setting_card/Movie_black.svg</file>
<file>images/setting_card/Movie_white.svg</file>
<file>images/setting_card/MusicFolder_black.svg</file>
<file>images/setting_card/MusicFolder_white.svg</file>
<file>images/setting_card/Music_black.svg</file>
<file>images/setting_card/Music_white.svg</file>
<file>images/setting_card/Palette_black.svg</file>
<file>images/setting_card/Palette_white.svg</file>
<file>images/setting_card/PencilInk_black.svg</file>
<file>images/setting_card/PencilInk_white.svg</file>
<file>images/setting_card/Question_black.svg</file>
<file>images/setting_card/Question_white.svg</file>
<file>images/setting_card/Search_black.svg</file>
<file>images/setting_card/Search_white.svg</file>
<file>images/setting_card/Transparent_black.svg</file>
<file>images/setting_card/Transparent_white.svg</file>
<file>images/setting_card/Update_black.svg</file>
<file>images/setting_card/Update_white.svg</file>
<file>images/setting_card/Video_black.svg</file>
<file>images/setting_card/Video_white.svg</file>
<file>images/setting_card/Web_black.svg</file>
<file>images/setting_card/Web_white.svg</file>
<file>images/setting_card/Zoom_black.svg</file>
<file>images/setting_card/Zoom_white.svg</file>
<file>images/setting_card/Language_black.svg</file>
<file>images/setting_card/Language_white.svg</file>
<file>images/icons/Cancel_black.svg</file>
<file>images/icons/Cancel_white.svg</file>
<file>images/icons/ChevronRight_black.svg</file>
<file>images/icons/ChevronRight_white.svg</file>
<file>images/icons/Copy_black.svg</file>
<file>images/icons/Copy_white.svg</file>
<file>images/icons/Cut_black.svg</file>
<file>images/icons/Cut_white.svg</file>
<file>images/icons/Paste_black.svg</file>
<file>images/icons/Paste_white.svg</file>
<file>images/icons/Add_black.svg</file>
<file>images/icons/Add_white.svg</file>
<file>images/icons/Folder_black.svg</file>
<file>images/icons/Folder_white.svg</file>
<file>images/icons/Setting_black.svg</file>
<file>images/icons/Setting_white.svg</file>
<file>images/icons/Alignment_black.svg</file>
<file>images/icons/Alignment_white.svg</file>
<file>images/icons/BackgroundColor_black.svg</file>
<file>images/icons/BackgroundColor_white.svg</file>
<file>images/icons/Brush_black.svg</file>
<file>images/icons/Brush_white.svg</file>
<file>images/icons/ChevronDown_black.svg</file>
<file>images/icons/ChevronDown_white.svg</file>
<file>images/icons/Close_black.svg</file>
<file>images/icons/Close_white.svg</file>
<file>images/icons/Download_black.svg</file>
<file>images/icons/Download_white.svg</file>
<file>images/icons/Embed_black.svg</file>
<file>images/icons/Embed_white.svg</file>
<file>images/icons/Feedback_black.svg</file>
<file>images/icons/Feedback_white.svg</file>
<file>images/icons/FluorescentPen_black.svg</file>
<file>images/icons/FluorescentPen_white.svg</file>
<file>images/icons/FolderAdd_black.svg</file>
<file>images/icons/FolderAdd_white.svg</file>
<file>images/icons/Font_black.svg</file>
<file>images/icons/Font_white.svg</file>
<file>images/icons/Help_black.svg</file>
<file>images/icons/Help_white.svg</file>
<file>images/icons/Info_black.svg</file>
<file>images/icons/Info_white.svg</file>
<file>images/icons/Link_black.svg</file>
<file>images/icons/Link_white.svg</file>
<file>images/icons/Minimize_black.svg</file>
<file>images/icons/Minimize_white.svg</file>
<file>images/icons/Movie_black.svg</file>
<file>images/icons/Movie_white.svg</file>
<file>images/icons/MusicFolder_black.svg</file>
<file>images/icons/MusicFolder_white.svg</file>
<file>images/icons/Music_black.svg</file>
<file>images/icons/Music_white.svg</file>
<file>images/icons/Palette_black.svg</file>
<file>images/icons/Palette_white.svg</file>
<file>images/icons/PencilInk_black.svg</file>
<file>images/icons/PencilInk_white.svg</file>
<file>images/icons/Question_black.svg</file>
<file>images/icons/Question_white.svg</file>
<file>images/icons/Search_black.svg</file>
<file>images/icons/Search_white.svg</file>
<file>images/icons/Transparent_black.svg</file>
<file>images/icons/Transparent_white.svg</file>
<file>images/icons/Update_black.svg</file>
<file>images/icons/Update_white.svg</file>
<file>images/icons/Video_black.svg</file>
<file>images/icons/Video_white.svg</file>
<file>images/icons/Web_black.svg</file>
<file>images/icons/Web_white.svg</file>
<file>images/icons/Zoom_black.svg</file>
<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/completed.svg</file>
......
from .config import *
from .auto_wrap import TextWrap
from .icon import Icon, getIconColor
from .icon import Icon, getIconColor, drawSvgIcon, FluentIconFactory
from .style_sheet import setStyleSheet, getStyleSheet
from .smooth_scroll import SmoothScroll, SmoothMode
\ No newline at end of file
# coding:utf-8
from PyQt5.QtCore import QPoint, QRect, QRectF, QSize, Qt
from PyQt5.QtCore import QPoint, QRect, QRectF, Qt
from PyQt5.QtGui import QIcon, QIconEngine, QImage, QPainter, QPixmap
from PyQt5.QtSvg import QSvgRenderer
......@@ -13,16 +13,15 @@ class PixmapIconEngine(QIconEngine):
self.iconPath = iconPath
super().__init__()
def paint(self, painter: QPainter, rect, mode, state):
def paint(self, painter, rect, mode, state):
painter.setRenderHints(QPainter.Antialiasing |
QPainter.SmoothPixmapTransform)
if not self.iconPath.lower().endswith('svg'):
painter.drawImage(rect, QImage(self.iconPath))
else:
renderer = QSvgRenderer(self.iconPath)
renderer.render(painter, QRectF(rect))
drawSvgIcon(self.iconPath, painter, rect)
def pixmap(self, size: QSize, mode: QIcon.Mode, state):
def pixmap(self, size, mode, state):
pixmap = QPixmap(size)
pixmap.fill(Qt.transparent)
self.paint(QPainter(pixmap), QRect(QPoint(0, 0), size), mode, state)
......@@ -39,3 +38,89 @@ class Icon(QIcon):
def getIconColor():
""" get the color of icon based on theme """
return "white" if qconfig.theme == 'dark' else 'black'
def drawSvgIcon(iconPath, painter, rect):
""" draw svg icon
Parameters
----------
iconPath: str
the path of svg icon
painter: QPainter
painter
rect: QRect | QRectF
the rect to render icon
"""
renderer = QSvgRenderer(iconPath)
renderer.render(painter, QRectF(rect))
class FluentIconFactory:
""" Fluent icon factory """
WEB = "Web"
CUT = "Cut"
ADD = "Add"
COPY = "Copy"
LINK = "Link"
HELP = "Help"
FONT = "Font"
INFO = "Info"
ZOOM = "Zoom"
CLOSE = "Close"
MOVIE = "Movie"
BRUSH = "Brush"
MUSIC = "Music"
VIDEO = "Video"
EMBED = "Embed"
PASTE = "Paste"
CANCEL = "Cancel"
FOLDER = "Folder"
SEARCH = "Search"
UPDATE = "Update"
SETTING = "Setting"
PALETTE = "Palette"
FEEDBACK = "Feedback"
MINIMIZE = "Minimize"
LANGUAGE = "Language"
DOWNLOAD = "Download"
QUESTION = "Question"
ALIGNMENT = "Alignment"
PENCIL_INK = "PencilInk"
FOLDER_ADD = "FolderAdd"
ARROW_DOWN = "ChevronDown"
TRANSPARENT = "Transparent"
MUSIC_FOLDER = "MusicFolder"
CHEVRON_RIGHT = "ChevronRight"
BACKGROUND_FILL = "BackgroundColor"
FLUORESCENT_PEN = "FluorescentPen"
@staticmethod
def path(iconType):
""" get the path of icon """
return f':/qfluentwidgets/images/icons/{iconType}_{getIconColor()}.svg'
@classmethod
def icon(cls, iconType):
""" create an fluent icon """
return QIcon(cls.path(iconType))
@classmethod
def render(cls, iconType, painter, rect):
""" draw svg icon
Parameters
----------
iconType: str
fluent icon type
painter: QPainter
painter
rect: QRect | QRectF
the rect to render icon
"""
drawSvgIcon(cls.path(iconType), painter, rect)
\ No newline at end of file
from .setting_card import (SettingCard, SwitchSettingCard, SettingIconFactory,
RangeSettingCard, PushSettingCard, ColorSettingCard,
HyperlinkCard, PrimaryPushSettingCard, ColorPickerButton)
from .setting_card import (SettingCard, SwitchSettingCard, RangeSettingCard,
PushSettingCard, ColorSettingCard, HyperlinkCard,
PrimaryPushSettingCard, ColorPickerButton)
from .expand_setting_card import ExpandSettingCard
from .folder_list_setting_card import FolderListSettingCard
from .options_setting_card import OptionsSettingCard
......
# coding:utf-8
from PyQt5.QtCore import (QEvent, Qt, QPropertyAnimation, pyqtProperty, QEasingCurve,
QParallelAnimationGroup, QRect, QSize, QPoint, QRectF)
from PyQt5.QtGui import QColor, QPixmap, QPainter
from PyQt5.QtGui import QColor, QPainter
from PyQt5.QtWidgets import QFrame, QWidget, QAbstractButton, QApplication
from PyQt5.QtSvg import QSvgRenderer
from ...common.config import qconfig
from ...common.icon import FluentIconFactory as FIF
from ...common.style_sheet import setStyleSheet
from .setting_card import SettingCard
from .setting_card import SettingIconFactory as SIF
from ..layout.v_box_layout import VBoxLayout
......@@ -21,7 +20,6 @@ class ExpandButton(QAbstractButton):
self.__angle = 0
self.isHover = False
self.isPressed = False
self.iconPath = SIF.create(SIF.ARROW_DOWN)
self.rotateAni = QPropertyAnimation(self, b'angle', self)
self.clicked.connect(self.__onClicked)
......@@ -46,8 +44,7 @@ class ExpandButton(QAbstractButton):
# draw icon
painter.translate(self.width()//2, self.height()//2)
painter.rotate(self.__angle)
renderer = QSvgRenderer(self.iconPath, self)
renderer.render(painter, QRectF(-6, -6, 9.6, 9.6))
FIF.render(FIF.ARROW_DOWN, painter, QRectF(-6, -6, 9.6, 9.6))
def enterEvent(self, e):
self.setHover(True)
......
......@@ -6,12 +6,12 @@ from PyQt5.QtCore import Qt, pyqtSignal, QRectF
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import (QPushButton, QFileDialog, QWidget, QLabel,
QHBoxLayout, QToolButton)
from PyQt5.QtSvg import QSvgRenderer
from ...common.config import ConfigItem, qconfig
from ...common.icon import drawSvgIcon
from ...common.icon import FluentIconFactory as FIF
from ..dialog_box.dialog import Dialog
from .expand_setting_card import ExpandSettingCard
from .setting_card import SettingIconFactory as SIF
class ToolButton(QToolButton):
......@@ -38,9 +38,8 @@ class ToolButton(QToolButton):
painter.setRenderHints(QPainter.Antialiasing |
QPainter.SmoothPixmapTransform)
painter.setOpacity(0.63 if self.isPressed else 1)
renderer = QSvgRenderer(self.iconPath, self)
w, h = self._iconSize
renderer.render(painter, QRectF(
drawSvgIcon(self.iconPath, painter, QRectF(
(self.width()-w)//2, (self.height()-h)//2, w, h))
......@@ -66,8 +65,7 @@ class PushButton(QPushButton):
painter = QPainter(self)
painter.setRenderHints(QPainter.Antialiasing)
painter.setOpacity(0.63 if self.isPressed else 1)
renderer = QSvgRenderer(self.iconPath, self)
renderer.render(painter, QRectF(12, 8, 16, 16))
drawSvgIcon(self.iconPath, painter, QRectF(12, 8, 16, 16))
class FolderItem(QWidget):
......@@ -80,7 +78,7 @@ class FolderItem(QWidget):
self.folder = folder
self.hBoxLayout = QHBoxLayout(self)
self.folderLabel = QLabel(folder, self)
self.removeButton = ToolButton(SIF.create(SIF.CLOSE), (39, 29), (12, 12), self)
self.removeButton = ToolButton(FIF.path(FIF.CLOSE), (39, 29), (12, 12), self)
self.setFixedHeight(53)
self.hBoxLayout.setContentsMargins(48, 0, 60, 0)
......@@ -115,10 +113,10 @@ class FolderListSettingCard(ExpandSettingCard):
parent: QWidget
parent widget
"""
super().__init__(SIF.create(SIF.FOLDER), title, content, parent)
super().__init__(FIF.path(FIF.FOLDER), title, content, parent)
self.configItem = configItem
self.addFolderButton = PushButton(
SIF.create(SIF.FOLDER_ADD), self.tr('Add folder'), self)
FIF.path(FIF.FOLDER_ADD), self.tr('Add folder'), self)
self.folders = qconfig.get(configItem).copy() # type:List[str]
self.__initWidget()
......
from .menu import DWMMenu, LineEditMenu, RoundMenu, MenuIconFactory
from .menu import DWMMenu, LineEditMenu, RoundMenu
from .slider import Slider, HollowHandleStyle
from .stacked_widget import PopUpAniStackedWidget, OpacityAniStackedWidget
from .switch_button import SwitchButton, IndicatorPosition
......
......@@ -5,39 +5,13 @@ from PyQt5.QtGui import QIcon, QColor, QPainter, QPen, QPixmap
from PyQt5.QtWidgets import (QAction, QApplication, QMenu, QProxyStyle, QStyle,
QGraphicsDropShadowEffect, QListWidget, QWidget, QHBoxLayout,
QListWidgetItem, QStyleOptionViewItem)
from PyQt5.QtSvg import QSvgRenderer
from ...common.smooth_scroll import SmoothScroll
from ...common.icon import Icon, getIconColor
from ...common.icon import FluentIconFactory as FIF
from ...common.style_sheet import setStyleSheet
from ...common.config import qconfig
class MenuIconFactory:
""" Menu icon factory """
CUT = "Cut"
ADD = "Add"
COPY = "Copy"
PASTE = "Paste"
CANCEL = "Cancel"
FOLDER = "Folder"
SETTING = "Setting"
CHEVRON_RIGHT = "ChevronRight"
@classmethod
def create(cls, iconType: str):
""" create icon """
return QIcon(cls.path(iconType))
@classmethod
def path(cls, iconType: str):
return f":/qfluentwidgets/images/menu/{iconType}_{getIconColor()}.svg"
MIF = MenuIconFactory
class CustomMenuStyle(QProxyStyle):
""" Custom menu style """
......@@ -89,28 +63,28 @@ class LineEditMenu(DWMMenu):
def createActions(self):
self.cutAct = QAction(
MIF.create(MIF.CUT),
FIF.icon(FIF.CUT),
self.tr("Cut"),
self,
shortcut="Ctrl+X",
triggered=self.parent().cut,
)
self.copyAct = QAction(
MIF.create(MIF.COPY),
FIF.icon(FIF.COPY),
self.tr("Copy"),
self,
shortcut="Ctrl+C",
triggered=self.parent().copy,
)
self.pasteAct = QAction(
MIF.create(MIF.PASTE),
FIF.icon(FIF.PASTE),
self.tr("Paste"),
self,
shortcut="Ctrl+V",
triggered=self.parent().paste,
)
self.cancelAct = QAction(
MIF.create(MIF.CANCEL),
FIF.icon(FIF.CANCEL),
self.tr("Cancel"),
self,
shortcut="Ctrl+Z",
......@@ -201,9 +175,8 @@ class SubMenuItemWidget(QWidget):
self.style().drawPrimitive(QStyle.PE_PanelItemViewRow, option, painter)
# draw right arrow
s = 9
renderer = QSvgRenderer(MIF.path(MIF.CHEVRON_RIGHT))
renderer.render(painter, QRectF(self.width()-10, self.height()/2-s/2, s, s))
FIF.render(FIF.CHEVRON_RIGHT, painter, QRectF(
self.width()-10, self.height()/2-9/2, 9, 9))
class MenuActionListWidget(QListWidget):
......@@ -298,7 +271,7 @@ class RoundMenu(QWidget):
self._actions.append(action)
hasIcon = any(not i.icon().isNull() for i in self._actions)
# create empty icon
# icon empty icon
icon = action.icon()
if hasIcon and icon.isNull():
pixmap = QPixmap(self.view.iconSize())
......@@ -356,7 +329,7 @@ class RoundMenu(QWidget):
""" add sub menu """
hasIcon = any(not self.view.item(i).icon().isNull() for i in range(self.view.count()))
# create empty icon
# icon empty icon
icon = menu.icon()
if hasIcon and icon.isNull():
pixmap = QPixmap(self.view.iconSize())
......@@ -381,7 +354,7 @@ class RoundMenu(QWidget):
m = self.view.viewportMargins()
w = self.view.width()-m.left()-m.right()
# create separator
# icon separator
separator = MenuSeparator(self.view)
separator.resize(w, separator.height())
......
......@@ -2,9 +2,9 @@
from PyQt5.QtCore import QEasingCurve, QPropertyAnimation, Qt, QTimer, pyqtSignal, QSize, QPoint, QRectF
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QLabel, QWidget, QToolButton, QGraphicsOpacityEffect
from PyQt5.QtSvg import QSvgRenderer, QSvgWidget
from PyQt5.QtSvg import QSvgWidget
from ...common import setStyleSheet
from ...common import setStyleSheet, drawSvgIcon
class StateToolTip(QWidget):
......@@ -129,11 +129,9 @@ class StateToolTip(QWidget):
if not self.isDone:
painter.translate(19, 18)
painter.rotate(self.rotateAngle)
render = QSvgRenderer(self.busyIconPath, self)
render.render(painter, QRectF(-8, -8, 16, 16))
drawSvgIcon(self.busyIconPath, painter, QRectF(-8, -8, 16, 16))
else:
render = QSvgRenderer(self.doneIconPath, self)
render.render(painter, QRectF(11, 10, 16, 16))
drawSvgIcon(self.doneIconPath, painter, QRectF(11, 10, 16, 16))
class ToastToolTip(QWidget):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册