def __init__(self): super(Window, self).__init__() self.setObjectName('MainWindow') self.setWindowFlags(Qt.FramelessWindowHint) self.setWindowIcon(QIcon('resource/format.ico')) self.setWindowTitle("Music") with open('QSS/window.qss', 'r') as f: self.setStyleSheet(f.read()) self.resize(1022, 670) self.header = Header(self) self.navigation = Navigation(self) self.playWidgets = PlayWidgets(self) self.detailSings = DetailSings(self) self.mainContent = MainContent(self) self.nativeMusic = NativeMusic(self) self.searchArea = SearchArea(self) self.mainContents = QTabWidget() self.mainContents.tabBar().setObjectName("mainTab") self.systemTray = SystemTray('resource/logo.png', self) # 加载tab设置。 self.setContents() # 添加各类网站的歌单。 self.addAllPlaylist() # 设置布局小细线。 self.setLines() # 设置布局。 self.setLayouts() # 注册功能。 self.configFeatures()
class MainContent(ScrollArea): # 定义一个滑到了最低部的信号。 # 方便子控件得知已经滑到了最底部,要做些加载的动作。 def __init__(self, parent=None): """主内容区,包括推荐歌单等。""" super(MainContent, self).__init__() self.parent = parent self.setObjectName("MainContent") # 连接导航栏的按钮。 # self.parent.navigation.navigationListFunction = self.navigationListFunction with open("QSS/mainContent.qss", 'r', encoding='utf-8') as f: self.style = f.read() self.setStyleSheet(self.style) self.tab = QTabWidget() self.tab.setObjectName("contentsTab") self.mainLayout = QVBoxLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(self.tab) self.frame.setLayout(self.mainLayout) def addTab(self, widget, name=''): self.tab.addTab(widget, name)
class MainContent(ScrollArea): # 定义一个滑到了最低部的信号。 # 方便子控件得知已经滑到了最底部,要做些加载的动作。 def __init__(self, parent=None): """主内容区,包括推荐歌单等。""" super(MainContent, self).__init__() self.parent = parent self.setObjectName("MainContent") # 连接导航栏的按钮。 # self.parent.navigation.navigationListFunction = self.navigationListFunction with open("QSS/mainContent.qss", 'r', encoding='utf-8') as f: self.style = f.read() self.setStyleSheet(self.style) self.tab = QTabWidget() self.tab.setObjectName("contentsTab") # self.setWidget(self.tab) # self.indexNetEaseSings = NetEaseSingsArea(self) # self.tab.addTab(self.indexNetEaseSings, "网易云歌单") self.mainLayout = QVBoxLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(self.tab) self.frame.setLayout(self.mainLayout) def addTab(self, widget, name=''): self.tab.addTab(widget, name)
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 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 __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 __init__(self, parent=None): """主内容区,包括推荐歌单等。""" super(MainContent, self).__init__() self.parent = parent self.setObjectName("MainContent") # 连接导航栏的按钮。 # self.parent.navigation.navigationListFunction = self.navigationListFunction with open("QSS/mainContent.qss", 'r', encoding='utf-8') as f: self.style = f.read() self.setStyleSheet(self.style) self.tab = QTabWidget() self.tab.setObjectName("contentsTab") self.mainLayout = QVBoxLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(self.tab) self.frame.setLayout(self.mainLayout)
def __init__(self): super(Window, self).__init__() self.setObjectName('MainWindow') self.setWindowFlags(Qt.FramelessWindowHint) self.setWindowIcon(QIcon('resource/format.ico')) self.setWindowTitle("Music") self.resize(1022, 670) self.header = Header(self) self.navigation = Navigation(self) self.playWidgets = PlayWidgets(self) self.detailSings = DetailSings(self) self.mainContent = MainContent(self) self.nativeMusic = NativeMusic(self) self.downloadFrame = DownloadFrame(self) self.searchArea = SearchArea(self) self.recommendFrame = RecommendFrame(self) self.mainContents = QTabWidget() self.mainContents.tabBar().setObjectName("mainTab") self.systemTray = SystemTray('resource/logo.png', self) # 加载tab设置。 self.setContents() # 添加各类网站的歌单。 self.addAllPlaylist() # 设置布局小细线。 self.setLines() # 设置布局。 self.setLayouts() # 注册功能。 self.configFeatures() with open('QSS/window.qss', 'r') as f: self.setStyleSheet(f.read())
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.neteaseSearchFrame = NetEaseSearchResultFrame(self) self.contentsTab.addTab(self.neteaseSearchFrame, "网易云") self.xiamiSearchFrame = XiamiSearchResultFrame(self) self.contentsTab.addTab(self.xiamiSearchFrame, "虾米") self.qqSearchFrame = QQSearchResultFrame(self) self.contentsTab.addTab(self.qqSearchFrame, 'QQ') # 功能。 def setText(self, text): self.text = text self.titleLabel.setText( "搜索<font color='#23518F'>“{0}”</font><br>".format(self.text))
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.neteaseSearchFrame = NetEaseSearchResultFrame(self) self.contentsTab.addTab(self.neteaseSearchFrame, "网易云") self.xiamiSearchFrame = XiamiSearchResultFrame(self) self.contentsTab.addTab(self.xiamiSearchFrame, "虾米") self.qqSearchFrame = QQSearchResultFrame(self) self.contentsTab.addTab(self.qqSearchFrame, 'QQ') # 功能。 def setText(self, text): self.text = text self.titleLabel.setText("搜索<font color='#23518F'>“{0}”</font><br>".format(self.text))
class Window(QWidget): """Window 承载整个界面。""" def __init__(self): super(Window, self).__init__() self.setObjectName('MainWindow') self.setWindowFlags(Qt.FramelessWindowHint) self.setWindowIcon(QIcon('resource/format.ico')) self.setWindowTitle("Music") with open('QSS/window.qss', 'r') as f: self.setStyleSheet(f.read()) self.resize(1022, 670) self.header = Header(self) self.navigation = Navigation(self) self.playWidgets = PlayWidgets(self) self.detailSings = DetailSings(self) self.mainContent = MainContent(self) self.nativeMusic = NativeMusic(self) self.searchArea = SearchArea(self) self.mainContents = QTabWidget() self.mainContents.tabBar().setObjectName("mainTab") self.systemTray = SystemTray('resource/logo.png', self) # 加载tab设置。 self.setContents() # 添加各类网站的歌单。 self.addAllPlaylist() # 设置布局小细线。 self.setLines() # 设置布局。 self.setLayouts() # 注册功能。 self.configFeatures() def addAllPlaylist(self): self.indexNetEaseSings = NetEaseSingsArea(self.mainContent) self.indexXiamiSings = XiamiSingsArea(self.mainContent) self.indexQQSings = QQSingsArea(self.mainContent) self.mainContent.addTab(self.indexNetEaseSings, "网易云歌单") self.mainContent.addTab(self.indexXiamiSings, "虾米歌单") self.mainContent.addTab(self.indexQQSings, "QQ歌单") # 布局。 def setContents(self): """设置tab界面。""" # 将需要切换的窗口做成Tab,并隐藏tabBar,这样方便切换,并且可以做前进后退功能。 self.mainContents.addTab(self.mainContent, '') self.mainContents.addTab(self.detailSings, '') self.mainContents.addTab(self.nativeMusic, '') self.mainContents.addTab(self.searchArea, '') self.mainContents.setCurrentIndex(0) def setLines(self): """设置布局小细线。""" self.line1 = QFrame(self) self.line1.setObjectName("line1") self.line1.setFrameShape(QFrame.HLine) self.line1.setFrameShadow(QFrame.Plain) self.line1.setLineWidth(2) def setLayouts(self): self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.header) self.mainLayout.addWidget(self.line1) self.contentLayout = QHBoxLayout() self.contentLayout.setStretch(0, 70) self.contentLayout.setStretch(1, 570) self.contentLayout.addWidget(self.navigation) self.contentLayout.addWidget(self.mainContents) self.contentLayout.setSpacing(0) self.contentLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addLayout(self.contentLayout) self.mainLayout.addWidget(self.playWidgets) self.mainLayout.setStretch(0, 43) self.mainLayout.setStretch(1, 0) self.mainLayout.setStretch(2, 576) self.mainLayout.setStretch(3, 50) self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.mainLayout) # 注册所有功能。 def configFeatures(self): self.config = ConfigWindow(self) self.header.config = ConfigHeader(self.header) self.searchArea.config = ConfigSearchArea(self.searchArea) self.navigation.config = ConfigNavigation(self.navigation) self.nativeMusic.config = ConfigNative(self.nativeMusic) self.mainContent.config = ConfigMainContent(self.mainContent) self.detailSings.config = ConfigDetailSings(self.detailSings) self.indexNetEaseSings.config = ConfigNetEase(self.indexNetEaseSings) self.indexXiamiSings.config = ConfigXiami(self.indexXiamiSings) self.indexQQSings.config = ConfigQQ(self.indexQQSings) self.systemTray.config = ConfigSystemTray(self.systemTray) self.indexNetEaseSings.config.initThread() self.indexXiamiSings.config.initThread() self.indexQQSings.config.initThread() def closeEvent(self, event): # 主要是保存cookies. self.header.config.saveCookies() self.playWidgets.saveCookies() # 系统托盘需要先隐藏,否则退出后会残留在任务栏。 self.systemTray.hide()
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))
class Window(QWidget): """Window 承载整个界面。""" def __init__(self): super(Window, self).__init__() self.setObjectName('MainWindow') self.setWindowFlags(Qt.FramelessWindowHint) self.setWindowIcon(QIcon('resource/format.ico')) self.setWindowTitle("Music") self.resize(1022, 670) self.header = Header(self) self.navigation = Navigation(self) self.playWidgets = PlayWidgets(self) self.detailSings = DetailSings(self) self.mainContent = MainContent(self) self.nativeMusic = NativeMusic(self) self.downloadFrame = DownloadFrame(self) self.searchArea = SearchArea(self) self.recommendFrame = RecommendFrame(self) self.mainContents = QTabWidget() self.mainContents.tabBar().setObjectName("mainTab") self.systemTray = SystemTray('resource/logo.png', self) # 加载tab设置。 self.setContents() # 添加各类网站的歌单。 self.addAllPlaylist() # 设置布局小细线。 self.setLines() # 设置布局。 self.setLayouts() # 注册功能。 self.configFeatures() with open('QSS/window.qss', 'r') as f: self.setStyleSheet(f.read()) def addAllPlaylist(self): self.indexNetEaseSings = NetEaseSingsArea(self.mainContent) self.indexXiamiSings = XiamiSingsArea(self.mainContent) self.indexQQSings = QQSingsArea(self.mainContent) self.mainContent.addTab(self.indexNetEaseSings, "网易云歌单") self.mainContent.addTab(self.indexXiamiSings, "虾米歌单") self.mainContent.addTab(self.indexQQSings, "QQ歌单") # 布局。 def setContents(self): """设置tab界面。""" # 将需要切换的窗口做成Tab,并隐藏tabBar,这样方便切换,并且可以做前进后退功能。 self.mainContents.addTab(self.mainContent, '') self.mainContents.addTab(self.detailSings, '') self.mainContents.addTab(self.nativeMusic, '') self.mainContents.addTab(self.downloadFrame, '') self.mainContents.addTab(self.recommendFrame, '') self.mainContents.addTab(self.searchArea, '') self.mainContents.setCurrentIndex(0) def setLines(self): """设置布局小细线。""" self.line1 = QFrame(self) self.line1.setObjectName("line1") self.line1.setFrameShape(QFrame.HLine) self.line1.setFrameShadow(QFrame.Plain) self.line1.setLineWidth(2) def setLayouts(self): self.mainLayout = QVBoxLayout() self.mainLayout.addWidget(self.header) self.mainLayout.addWidget(self.line1) self.contentLayout = QHBoxLayout() self.contentLayout.setStretch(0, 70) self.contentLayout.setStretch(1, 570) self.contentLayout.addWidget(self.navigation) self.contentLayout.addWidget(self.mainContents) self.contentLayout.setSpacing(0) self.contentLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addLayout(self.contentLayout) self.mainLayout.addWidget(self.playWidgets) self.mainLayout.setStretch(0, 43) self.mainLayout.setStretch(1, 0) self.mainLayout.setStretch(2, 576) self.mainLayout.setStretch(3, 50) self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.mainLayout) # 注册所有功能。 def configFeatures(self): self.config = ConfigWindow(self) self.header.config = ConfigHeader(self.header) self.downloadFrame.config = ConfigDownloadFrame(self.downloadFrame) self.searchArea.config = ConfigSearchArea(self.searchArea) self.navigation.config = ConfigNavigation(self.navigation) self.nativeMusic.config = ConfigNative(self.nativeMusic) self.mainContent.config = ConfigMainContent(self.mainContent) self.detailSings.config = ConfigDetailSings(self.detailSings) self.indexNetEaseSings.config = ConfigNetEase(self.indexNetEaseSings) self.indexXiamiSings.config = ConfigXiami(self.indexXiamiSings) self.indexQQSings.config = ConfigQQ(self.indexQQSings) self.systemTray.config = ConfigSystemTray(self.systemTray) self.recommendFrame.config = ConfigRecommendFrame(self.recommendFrame) self.indexNetEaseSings.config.initThread() self.indexXiamiSings.config.initThread() self.indexQQSings.config.initThread() # 当前耦合度过高。 self.downloadFrame.config.getDownloadSignal() self.config.pullRecommendSong() # move to center. screen = QApplication.desktop().availableGeometry() self.playWidgets.desktopLyric.resize(screen.width(), 50) self.playWidgets.desktopLyric.move(0, screen.height() - 100) def closeEvent(self, event): # 主要是保存cookies. self.header.config.saveCookies() self.playWidgets.saveCookies() self.downloadFrame.config.saveCookies() # 关闭并保存数据库 self.db.commitAndClose() # 系统托盘需要先隐藏,否则退出后会残留在任务栏。 self.systemTray.hide() def resizeEvent(self, event): self. playWidgets.currentMusic.move(0, self.height()-64-self.playWidgets.height())