8000 更换三态按钮的图标为 svg 格式 · ag-python-qt/Groove@ec481b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ec481b4

Browse files
committed
更换三态按钮的图标为 svg 格式
1 parent 90328ce commit ec481b4

File tree

109 files changed

+86586
-83251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+86586
-83251
lines changed

app/View/navigation_interface/navigation_button.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ def paintEvent(self, e):
277277
elif self.pressedPos in [Position.BOTTOM_LEFT, Position.TOP_RIGHT, Position.BOTTOM]:
278278
self.drawIcon(painter, 0.05, 0)
279279
elif self.pressedPos in [Position.LEFT, Position.RIGHT, Position.CENTER]:
280-
self.drawIcon(painter, 0, 0, 0, 0, 1)
280+
self.drawIcon(painter, 0, 0, 0, 0, 2)
281281

282282
def drawIcon(self, painter, shearX=0, shearY=0, x=0, y=0, ds=0):
283283
""" draw icon """
284284
ds = y/2 if not ds else ds
285285
painter.shear(shearX, shearY)
286-
iw, ih = self.iconSize().width()-y/2, self.iconSize().height()-y/2
286+
iw, ih = self.iconSize().width()-ds, self.iconSize().height()-ds
287287
rect = QRectF((60-iw)/2+x, (self.height()-ih)/2+y, iw, ih)
288288
drawSvgIcon(self.iconPath, painter, rect)

app/View/playlist_card_interface/playlist_card_interface.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def __createWidgets(self):
4343
c = getIconColor()
4444
self.createPlaylistButton = ThreeStatePushButton(
4545
{
46-
"normal": f":/images/playlist_card_interface/Add_{c}_normal.png",
47-
"hover": f":/images/playlist_card_interface/Add_{c}_hover.png",
48-
"pressed": f":/images/playlist_card_interface/Add_{c}_pressed.png",
46+
"normal": f":/images/playlist_card_interface/Add_{c}_normal.svg",
47+
"hover": f":/images/playlist_card_interface/Add_{c}_hover.svg",
48+
"pressed": f":/images/playlist_card_interface/Add_{c}_pressed.svg",
4949
},
5050
self.tr(" New playlist"),
5151
(19, 19),
@@ -82,7 +82,7 @@ def __initLayout(self):
8282
self.playlistLabel.move(30, 54)
8383
self.createPlaylistButton.move(30, 131)
8484
self.sortModeLabel.move(
85-
self.createPlaylistButton.geometry().right()+30, 136)
85+
self.createPlaylistButton.geometry().right()+30, 135)
8686
self.sortModeButton.move(self.sortModeLabel.geometry().right()+7, 132)
8787

8888
def __setQss(self):

app/View/playlist_interface/playlist_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def __init__(self, library: Library, playlist: Playlist = None, parent=None):
5353
c = getIconColor()
5454
self.addMusicButton = ThreeStatePushButton(
5555
{
56-
"normal": f":/images/playlist_interface/album_{c}_normal.png",
57-
"hover": f":/images/playlist_interface/album_{c}_hover.png",
58-
"pressed": f":/images/playlist_interface/album_{c}_pressed.png",
56+
"normal": f":/images/playlist_interface/album_{c}_normal.svg",
57+
"hover": f":/images/playlist_interface/album_{c}_hover.svg",
58+
"pressed": f":/images/playlist_interface/album_{c}_pressed.svg",
5959
},
6060
self.tr(" Add songs from my collection"),
6161
(29, 29),

app/View/search_result_interface/group_box.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# coding:utf-8
2-
from common.icon import Icon, getIconColor
3-
from common.config import config, Theme
2+
from common.icon import getIconColor, drawSvgIcon
43
from common.library import Library
54
from common.style_sheet import setStyleSheet
65
from components.buttons.three_state_button import ThreeStatePushButton
76
from PyQt5.QtCore import (QEasingCurve, QParallelAnimationGroup, QPropertyAnimation,
8-
QSize, Qt, pyqtSignal, pyqtProperty, QEvent)
7+
Qt, pyqtSignal, pyqtProperty, QEvent, QRect)
98
from PyQt5.QtGui import QColor, QPixmap, QPainter
10-
from PyQt5.QtWidgets import (QGraphicsOpacityEffect, QPushButton, QScrollArea,
11-
QToolButton, QWidget)
9+
from PyQt5.QtWidgets import QPushButton, QScrollArea, QToolButton, QWidget
1210

1311

1412
class ToolButton(QToolButton):
@@ -19,7 +17,7 @@ def __init__(self, iconPath: str, parent=None):
1917
self.__opacity = 1
2018
self.isEnter = False
2119
self.isPressed = False
22-
self.iconPixmap = QPixmap(iconPath)
20+
self.iconPath = iconPath
2321
self.setFixedSize(25, 301)
2422
self.installEventFilter(self)
2523

@@ -43,7 +41,7 @@ def paintEvent(self, e):
4341
painter.drawRect(self.rect())
4442

4543
# draw icon
46-
painter.drawPixmap(5, 143, self.iconPixmap)
44+
drawSvgIcon(self.iconPath, painter, QRect(5, 143, 15, 15))
4745

4846
def eventFilter(self, obj, e):
4947
if obj is self:
@@ -85,9 +83,9 @@ def __init__(self, library: Library, view, parent=None):
8583
self.library = library
8684
self.titleButton = QPushButton('Title', self)
8785
self.scrollLeftButton = ToolButton(
88-
':/images/search_result_interface/ChevronLeft.png', self)
86+
':/images/search_result_interface/ChevronLeft.svg', self)
8987
self.scrollRightButton = ToolButton(
90-
':/images/search_result_interface/ChevronRight.png', self)
88+
':/images/search_result_interface/ChevronRight.svg', self)
9189
self.opacityAniGroup = QParallelAnimationGroup(self)
9290
self.leftOpacityAni = QPropertyAnimation(
9391
self.scrollLeftButton, b'opacity', self)
@@ -99,9 +97,9 @@ def __init__(self, library: Library, view, parent=None):
9997
c = getIconColor()
10098
self.showAllButton = ThreeStatePushButton(
10199
{
102-
"normal": f":/images/search_result_interface/ShowAll_normal_{c}.png",
103-
"hover": f":/images/search_result_interface/ShowAll_hover_{c}.png",
104-
"pressed": f":/images/search_result_interface/ShowAll_pressed_{c}.png",
100+
"normal": f":/images/search_result_interface/ShowAll_normal_{c}.svg",
101+
"hover": f":/images/search_result_interface/ShowAll_hover_{c}.svg",
102+
"pressed": f":/images/search_result_interface/ShowAll_pressed_{c}.svg",
105103
},
106104
self.tr(' Show All'),
107105
(14, 14),

app/View/search_result_interface/search_result_interface.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
from components.widgets.label import PixmapLabel
1313
from components.widgets.scroll_area import ScrollArea
1414
from components.widgets.tooltip import DownloadStateTooltip
15-
from PyQt5.QtCore import Qt, pyqtSignal
15+
from PyQt5.QtCore import pyqtSignal
10000 1616
from PyQt5.QtGui import QPixmap
1717
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget
18+
from PyQt5.QtSvg import QSvgWidget
1819

1920
from .album_group_box import AlbumGroupBox
2021
from .playlist_group_box import PlaylistGroupBox
@@ -48,7 +49,7 @@ def __init__(self, library: Library, parent=None):
4849
self.onlineSongInfos = [] # matched online information
4950

5051
self.titleLabel = QLabel(self)
51-
self.searchLabel = PixmapLabel(self)
52+
self.searchLabel = QSvgWidget(self)
5253
self.scrollWidget = QWidget(self)
5354
self.vBox = QVBoxLayout(self.scrollWidget)
5455
self.albumGroupBox = AlbumGroupBox(library, self.scrollWidget)
@@ -84,8 +85,9 @@ def __initWidget(self):
8485
self.setWidget(self.scrollWidget)
8586
self.setViewportMargins(0, 115, 0, 0)
8687
self.__setQss()
87-
self.searchLabel.setPixmap(
88-
QPixmap(f":/images/search_result_interface/Search_{getIconColor()}.png"))
88+
self.searchLabel.setFixedSize(50, 50)
89+
self.searchLabel.load(
90+
f":/images/search_result_interface/Search_{getIconColor()}.svg")
8991
self.__setHintsLabelVisible(False)
9092
self.titleLabel.move(30, 55)
9193
self.titleLabel.raise_()

app/View/search_result_interface/song_group_box.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def __init__(self, song_type: str, parent=None):
4949
c = getIconColor()
5050
self.showAllButton = ThreeStatePushButton(
5151
{
52-
"normal": f":/images/search_result_interface/ShowAll_normal_{c}.png",
53-
"hover": f":/images/search_result_interface/ShowAll_hover_{c}.png",
54-
"pressed": f":/images/search_result_interface/ShowAll_pressed_{c}.png",
52+
"normal": f":/images/search_result_interface/ShowAll_normal_{c}.svg",
53+
"hover": f":/images/search_result_interface/ShowAll_hover_{c}.svg",
54+
"pressed": f":/images/search_result_interface/ShowAll_pressed_{c}.svg",
5555
},
5656
self.tr(' Show All'),
5757
(14, 14),

app/View/singer_interface/singer_interface.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ def __init__(self, library: Library, singerInfo: SingerInfo = None, parent=None)
5757
c = getIconColor()
5858
self.playButton = ThreeStateButton(
5959
{
60-
"normal": f":/images/singer_interface/Play_{c}_normal.png",
61-
"hover": f":/images/singer_interface/Play_{c}_hover.png",
62-
"pressed": f":/images/singer_interface/Play_{c}_pressed.png",
60+
"normal": f":/images/singer_interface/Play_{c}_normal.svg",
61+
"hover": f":/images/singer_interface/Play_{c}_hover.svg",
62+
"pressed": f":/images/singer_interface/Play_{c}_pressed.svg",
6363
},
6464
self.scrollWidget,
65-
(20, 20)
65+
(20, 20),
66+
(18, 18)
6667
)
6768
self.albumCards = self.albumCardView.albumCards
6869

0 commit comments

Comments
 (0)
0