def __init__(self, parent): super(NetEaseSearchResultFrame, self).__init__() self.parent = parent # self.singsFrame = QFrame() self.singsFrameLayout = VBoxLayout(self) self.noSingsContentsLabel = QLabel(self) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.parent.width()) self.singsResultTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.parent.width() / 3 * 1.25, self.parent.width() / 3 * 1.25, self.parent.width() / 3 * 0.5 ]) }) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop | Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout)
def __init__(self, parent): super(CurrentMusicDetail, self).__init__() # with open('QSS/currentMusic.qss', 'r', encoding='utf-8') as f: # self.setStyleSheet(f.read()) self.setObjectName('detail') self.hide() self.mainLayout = VBoxLayout(self.frame) self.topLayout = HBoxLayout() self.topMainLayout = VBoxLayout() self.topHeaderLayout = HBoxLayout() # 为歌词创建索引方便删除。 self.allLyrics = [] # self.detailText = QTextEdit() # self.detailText.setObjectName('detailText') # self.detailText.setReadOnly(True) self.titleLabel = QLabel("✧✧✧") self.titleLabel.setObjectName('titleLabel') self.recoveryButton = QPushButton() self.recoveryButton.setObjectName('recoveryButton') self.recoveryButton.setMinimumSize(24, 24) self.recoveryButton.setMaximumSize(36, 36) self.setLayouts()
def __init__(self, parent): super(CurrentMusicDetail, self).__init__() self.setObjectName('detail') self.hide() self.mainLayout = VBoxLayout(self.frame) self.topLayout = HBoxLayout() self.topMainLayout = VBoxLayout() self.topHeaderLayout = HBoxLayout() self.lyricFrames = ScrollArea() self.lyricFrames.setObjectName('lyricScroll') self.lyricFrames.frame.setObjectName('lyricFrame') self.lyricFramesLayout = VBoxLayout(self.lyricFrames.frame) # self.lyricFrames.setMaximumHeight(500) # 为歌词创建索引方便删除。 self.allLyrics = [] # self.detailText = QTextEdit() # self.detailText.setObjectName('detailText') # self.detailText.setReadOnly(True) self.titleLabel = QLabel("✧✧✧") self.titleLabel.setObjectName('titleLabel') self.recoveryButton = QPushButton() self.recoveryButton.setObjectName('recoveryButton') self.recoveryButton.setMinimumSize(24, 24) self.recoveryButton.setMaximumSize(36, 36) self.setLayouts()
def setSingsFrame(self): # 单曲界面。 self.singsFrame = QFrame() self.singsFrameLayout = VBoxLayout(self.singsFrame) self.noSingsContentsLabel = QLabel(self.singsFrame) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.width()) self.singsResultTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.width() / 3 * 1.25, self.width() / 3 * 1.25, self.width() / 3 * 0.5 ]) }) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop | Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout) self.contentsTab.addTab(self.singsFrame, "单曲")
def __init__(self, title: str, parent=None): super(Header, self).__init__() self.parent = None self.setStyleSheet(self.myStyle) self.mainLayout = HBoxLayout(self) self.title = QLabel(title) self.mainLayout.addWidget(self.title) self.mainLayout.addStretch(1) self.closeButton = QPushButton('×') self.mainLayout.addWidget(self.closeButton)
def __init__(self, parent): super(SingsSearchResultFrameBase, self).__init__() self.parent = parent self.singsFrameLayout = VBoxLayout(self) self.noSingsContentsLabel = QLabel(self) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.parent.width()) self.singsResultTable.setColumnWidths({i:j for i,j in zip(range(3), [self.parent.width()/3*1.25,self.parent.width()/3*1.25,self.parent.width()/3*0.5])}) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop|Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout)
def __init__(self, title:str, parent=None): super(Header, self).__init__() self.parent = None self.setStyleSheet(self.myStyle) self.mainLayout = HBoxLayout(self) self.title = QLabel(title) self.mainLayout.addWidget(self.title) self.mainLayout.addStretch(1) self.closeButton = QPushButton('×') self.mainLayout.addWidget(self.closeButton)
def setLayouts(self): self.mainLayout = VBoxLayout() self.topLayout = HBoxLayout() self.descriptionLayout = VBoxLayout() self.titleLayout = HBoxLayout() self.titleLayout.addWidget(self.showButton) self.titleLayout.addSpacing(5) self.titleLayout.addWidget(self.titleLabel) self.authorLayout = HBoxLayout() self.authorLayout.addWidget(self.authorPic) self.authorLayout.addWidget(self.authorName) self.authorLayout.addStretch(1) self.descriptLayout = HBoxLayout() self.descriptLayout.addWidget(self.descriptionButton) self.descriptLayout.addWidget(self.descriptionText) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addLayout(self.titleLayout) self.descriptionLayout.addLayout(self.authorLayout) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addWidget(self.playAllButton) self.descriptionLayout.addSpacing(10) self.descriptionLayout.addLayout(self.descriptLayout) self.topLayout.addWidget(self.picLabel) self.topLayout.addSpacing(18) self.topLayout.addLayout(self.descriptionLayout) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addWidget(self.contentsTab) self.frame.setLayout(self.mainLayout)
def setLayouts(self): self.mainLayout = VBoxLayout() self.topLayout = HBoxLayout() self.descriptionLayout = VBoxLayout() self.titleLayout = HBoxLayout() self.titleLayout.addWidget(self.showButton) self.titleLayout.addSpacing(5) self.titleLayout.addWidget(self.titleLabel) self.authorLayout = HBoxLayout() self.authorLayout.addWidget(self.authorPic) self.authorLayout.addWidget(self.authorName) self.authorLayout.addStretch(1) self.descriptLayout = HBoxLayout() self.descriptLayout.addWidget(self.descriptionButton) self.descriptLayout.addWidget(self.descriptionText) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addLayout(self.titleLayout) self.descriptionLayout.addLayout(self.authorLayout) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addWidget(self.playAllButton) self.descriptionLayout.addSpacing(10) self.descriptionLayout.addLayout(self.descriptLayout) # self.descriptionLayout.setSpacing(0) self.topLayout.addWidget(self.picLabel) self.topLayout.addSpacing(18) self.topLayout.addLayout(self.descriptionLayout) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addWidget(self.contentsTab) self.frame.setLayout(self.mainLayout)
class Header(QFrame): myStyle = """ QFrame {background: #2D2D2D;} QLabel { margin-left: 8px; color: white; font-weight: bold; font-size: 15px; } QPushButton { border: none; font: bold; font-size: 13px; color: #7C7C7C; margin-right: 8px; } QPushButton:hover{ color: #DCDDE4; } """ def __init__(self, title:str, parent=None): super(Header, self).__init__() self.parent = None self.setStyleSheet(self.myStyle) self.mainLayout = HBoxLayout(self) self.title = QLabel(title) self.mainLayout.addWidget(self.title) self.mainLayout.addStretch(1) self.closeButton = QPushButton('×') self.mainLayout.addWidget(self.closeButton) def connectCloseButton(self, functionName): self.closeButton.clicked.connect(functionName)
class Header(QFrame): myStyle = """ QFrame {background: #2D2D2D;} QLabel { margin-left: 8px; color: white; font-weight: bold; font-size: 15px; } QPushButton { border: none; font: bold; font-size: 13px; color: #7C7C7C; margin-right: 8px; } QPushButton:hover{ color: #DCDDE4; } """ def __init__(self, title: str, parent=None): super(Header, self).__init__() self.parent = None self.setStyleSheet(self.myStyle) self.mainLayout = HBoxLayout(self) self.title = QLabel(title) self.mainLayout.addWidget(self.title) self.mainLayout.addStretch(1) self.closeButton = QPushButton('×') self.mainLayout.addWidget(self.closeButton) def connectCloseButton(self, functionName): self.closeButton.clicked.connect(functionName)
class CurrentMusicDetail(ScrollArea): """ showPic | MusicDetails --------------------- comments. MusicDetails title| recovery T E X T """ def __init__(self, parent): super(CurrentMusicDetail, self).__init__() # with open('QSS/currentMusic.qss', 'r', encoding='utf-8') as f: # self.setStyleSheet(f.read()) self.setObjectName('detail') self.hide() self.mainLayout = VBoxLayout(self.frame) self.topLayout = HBoxLayout() self.topMainLayout = VBoxLayout() self.topHeaderLayout = HBoxLayout() # 为歌词创建索引方便删除。 self.allLyrics = [] # self.detailText = QTextEdit() # self.detailText.setObjectName('detailText') # self.detailText.setReadOnly(True) self.titleLabel = QLabel("✧✧✧") self.titleLabel.setObjectName('titleLabel') self.recoveryButton = QPushButton() self.recoveryButton.setObjectName('recoveryButton') self.recoveryButton.setMinimumSize(24, 24) self.recoveryButton.setMaximumSize(36, 36) self.setLayouts() def setLayouts(self): self.mainLayout.addLayout(self.topLayout) # 为showPic预留。 # self.topLayout.addStretch(1) self.topLayout.addLayout(self.topMainLayout) self.topMainLayout.addSpacing(25) self.topMainLayout.addLayout(self.topHeaderLayout) self.topHeaderLayout.addStretch(1) self.topHeaderLayout.addSpacing(100) self.topHeaderLayout.addWidget(self.titleLabel) self.topHeaderLayout.addStretch(1) self.topHeaderLayout.addSpacing(20) self.topHeaderLayout.addWidget(self.recoveryButton) self.topHeaderLayout.addSpacing(50) self.topMainLayout.addSpacing(30) def addLyricLabel(self, label): HStretchBox(self.topMainLayout, label) self.allLyrics.append(label) def removeAllLyricLabels(self): for i in self.allLyrics: i.deleteLater() self.allLyrics = [] for i in range(3, self.topMainLayout.count()): self.topMainLayout.takeAt(i)
class DetailSings(ScrollArea): def __init__(self, parent=None): super(DetailSings, self).__init__(self) # self.hide() self.parent = parent self.setObjectName('detailSings') with open('QSS/detailSings.qss', 'r', encoding='utf-8') as f: self.setStyleSheet(f.read()) self.setLabels() self.setButtons() self.setTabs() self.setLayouts() # self.config = ConfigDetailSings(self) # 布局。 def setLabels(self): self.picLabel = PicLabel(width=200, height=200) self.picLabel.setObjectName('picLabel') self.titleLabel = QLabel(self.frame) self.titleLabel.setObjectName('titleLabel') self.titleLabel.setWordWrap(True) self.titleLabel.setMaximumHeight(40) self.authorPic = QLabel(self.frame) self.authorName = QLabel(self.frame) self.authorName.setObjectName('authorName') self.authorName.setMaximumHeight(28) # self.descriptionLabel = QLabel(self.frame) self.descriptionText = QTextEdit(self.frame) self.descriptionText.setReadOnly(True) self.descriptionText.setObjectName('descriptionText') self.descriptionText.setMaximumWidth(450) self.descriptionText.setMaximumHeight(100) self.descriptionText.setMinimumHeight(100) # self.descriptionLabel.setWordWrap(True) def setButtons(self): self.showButton = QPushButton("歌单") self.showButton.setObjectName('showButton') self.showButton.setMaximumSize(36, 20) self.descriptionButton = QPushButton(" 简介 :") self.descriptionButton.setObjectName('descriptionButton') self.descriptionButton.setMaximumSize(36, 36) self.playAllButton = QPushButton("全部播放") self.playAllButton.setIcon(QIcon('resource/playAll.png')) self.playAllButton.setObjectName('playAllButton') self.playAllButton.setMaximumSize(90, 24) # self.playAllButton.clicked.connect(self.addAllMusicToPlayer) def setTabs(self): self.contentsTab = QTabWidget(self.frame) self.singsTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsTable.setObjectName('singsTable') self.singsTable.setMinimumWidth(self.width()) self.singsTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.width() / 3 * 1.25, self.width() / 3 * 1.25, self.width() / 3 * 0.5 ]) }) # self.singsTable.itemDoubleClicked.connect(self.itemDoubleClickedEvent) self.contentsTab.addTab(self.singsTable, "歌曲列表") def setLayouts(self): self.mainLayout = VBoxLayout() self.topLayout = HBoxLayout() self.descriptionLayout = VBoxLayout() self.titleLayout = HBoxLayout() self.titleLayout.addWidget(self.showButton) self.titleLayout.addSpacing(5) self.titleLayout.addWidget(self.titleLabel) self.authorLayout = HBoxLayout() self.authorLayout.addWidget(self.authorPic) self.authorLayout.addWidget(self.authorName) self.authorLayout.addStretch(1) self.descriptLayout = HBoxLayout() self.descriptLayout.addWidget(self.descriptionButton) self.descriptLayout.addWidget(self.descriptionText) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addLayout(self.titleLayout) self.descriptionLayout.addLayout(self.authorLayout) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addWidget(self.playAllButton) self.descriptionLayout.addSpacing(10) self.descriptionLayout.addLayout(self.descriptLayout) # self.descriptionLayout.setSpacing(0) self.topLayout.addWidget(self.picLabel) self.topLayout.addSpacing(18) self.topLayout.addLayout(self.descriptionLayout) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addWidget(self.contentsTab) self.frame.setLayout(self.mainLayout)
class DetailSings(ScrollArea): def __init__(self, parent=None): super(DetailSings, self).__init__(self) # self.hide() self.parent = parent self.setObjectName('detailSings') with open('QSS/detailSings.qss', 'r', encoding='utf-8') as f: self.setStyleSheet(f.read()) self.setLabels() self.setButtons() self.setTabs() self.setLayouts() # 布局。 def setLabels(self): self.picLabel = PicLabel(width=200, height=200) self.picLabel.setObjectName('picLabel') self.titleLabel = QLabel(self.frame) self.titleLabel.setObjectName('titleLabel') self.titleLabel.setWordWrap(True) self.titleLabel.setMaximumHeight(40) self.authorPic = QLabel(self.frame) self.authorName = QLabel(self.frame) self.authorName.setObjectName('authorName') self.authorName.setMaximumHeight(28) self.descriptionText = QTextEdit(self.frame) self.descriptionText.setReadOnly(True) self.descriptionText.setObjectName('descriptionText') self.descriptionText.setMaximumWidth(450) self.descriptionText.setMaximumHeight(100) self.descriptionText.setMinimumHeight(100) def setButtons(self): self.showButton = QPushButton("歌单") self.showButton.setObjectName('showButton') self.showButton.setMaximumSize(36, 20) self.descriptionButton = QPushButton(" 简介 :") self.descriptionButton.setObjectName('descriptionButton') self.descriptionButton.setMaximumSize(36, 36) self.playAllButton = QPushButton("全部播放") self.playAllButton.setIcon(QIcon('resource/playAll.png')) self.playAllButton.setObjectName('playAllButton') self.playAllButton.setMaximumSize(90, 24) def setTabs(self): self.contentsTab = QTabWidget(self.frame) self.singsTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsTable.setObjectName('singsTable') self.singsTable.setMinimumWidth(self.width()) self.singsTable.setColumnWidths({i:j for i,j in zip(range(3), [self.width()/3*1.25,self.width()/3*1.25,self.width()/3*0.5])}) self.contentsTab.addTab(self.singsTable, "歌曲列表") def setLayouts(self): self.mainLayout = VBoxLayout() self.topLayout = HBoxLayout() self.descriptionLayout = VBoxLayout() self.titleLayout = HBoxLayout() self.titleLayout.addWidget(self.showButton) self.titleLayout.addSpacing(5) self.titleLayout.addWidget(self.titleLabel) self.authorLayout = HBoxLayout() self.authorLayout.addWidget(self.authorPic) self.authorLayout.addWidget(self.authorName) self.authorLayout.addStretch(1) self.descriptLayout = HBoxLayout() self.descriptLayout.addWidget(self.descriptionButton) self.descriptLayout.addWidget(self.descriptionText) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addLayout(self.titleLayout) self.descriptionLayout.addLayout(self.authorLayout) self.descriptionLayout.addSpacing(5) self.descriptionLayout.addWidget(self.playAllButton) self.descriptionLayout.addSpacing(10) self.descriptionLayout.addLayout(self.descriptLayout) self.topLayout.addWidget(self.picLabel) self.topLayout.addSpacing(18) self.topLayout.addLayout(self.descriptionLayout) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addWidget(self.contentsTab) self.frame.setLayout(self.mainLayout)
class SearchArea(ScrollArea): def __init__(self, parent=None): super(SearchArea, self).__init__(self) self.parent = parent self.setObjectName("searchArea") with open('QSS/searchArea.qss', 'r', encoding='utf-8') as f: self.setStyleSheet(f.read()) self.mainLayout = QVBoxLayout(self.frame) self.titleLabel = QLabel(self.frame) # 搜索结果的tab。 self.contentsTab = QTabWidget(self.frame) # 加入布局。 self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.contentsTab) self.setSingsFrame() # 布局。 def setSingsFrame(self): # 单曲界面。 self.singsFrame = QFrame() self.singsFrameLayout = VBoxLayout(self.singsFrame) self.noSingsContentsLabel = QLabel(self.singsFrame) self.noSingsContentsLabel.setMaximumHeight(60) self.noSingsContentsLabel.setObjectName("noSingsLable") self.noSingsContentsLabel.hide() self.singsResultTable = TableWidget(3, ['音乐标题', '歌手', '时长']) self.singsResultTable.setObjectName('singsTable') self.singsResultTable.setMinimumWidth(self.width()) self.singsResultTable.setColumnWidths({ i: j for i, j in zip(range(3), [ self.width() / 3 * 1.25, self.width() / 3 * 1.25, self.width() / 3 * 0.5 ]) }) self.singsFrameLayout.addWidget(self.singsResultTable, Qt.AlignTop | Qt.AlignCenter) self.centerLabelLayout = HBoxLayout() self.centerLabelLayout.addStretch(1) self.centerLabelLayout.addWidget(self.noSingsContentsLabel) self.centerLabelLayout.addStretch(1) self.singsFrameLayout.addLayout(self.centerLabelLayout) self.contentsTab.addTab(self.singsFrame, "单曲") # 功能。 def setText(self, text): self.text = text self.titleLabel.setText( "搜索<font color='#23518F'>“{0}”</font><br>".format(self.text))