class LP_LibraryPanel(FFrame): def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.header = LP_GroupHeader(self._app, '我的音乐') self.current_playlist_item = LP_GroupItem(self._app, '当前播放列表') self.current_playlist_item.set_img_text('❂') self._layout = QVBoxLayout(self) self.setObjectName('lp_library_panel') self.set_theme_style() self.setup_ui() def set_theme_style(self): theme = self._app.theme_manager.current_theme style_str = ''' #{0} {{ background: transparent; }} '''.format(self.objectName(), theme.color3.name()) self.setStyleSheet(style_str) def setup_ui(self): self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._layout.addSpacing(3) self._layout.addWidget(self.header) self._layout.addWidget(self.current_playlist_item) def add_item(self, item): self._layout.addWidget(item)
class Ui(object): def __init__(self, app): super().__init__() self._app = app self.login_dialog = LoginDialog(self._app, self._app) self.login_btn = LoginButton(self._app) self._lb_container = FFrame() self.songs_table_container = SongsTable_Container(self._app) self.fm_item = LP_GroupItem(self._app, '私人FM') self.fm_item.set_img_text('Ω') self.recommend_item = LP_GroupItem(self._app, '每日推荐') self.recommend_item.set_img_text('✦') self.simi_item = LP_GroupItem(self._app, '相似歌曲') self.simi_item.set_img_text('∾') self._lbc_layout = QHBoxLayout(self._lb_container) self.setup() def setup(self): self._lbc_layout.setContentsMargins(0, 0, 0, 0) self._lbc_layout.setSpacing(0) self._lbc_layout.addWidget(self.login_btn) self.login_btn.setFixedSize(30, 30) self._lbc_layout.addSpacing(10) tp_layout = self._app.ui.top_panel.layout() tp_layout.addWidget(self._lb_container) def on_login_in(self): self.login_btn.setToolTip('点击可刷新歌单列表') if self.login_dialog.isVisible(): self.login_dialog.hide() library_panel = self._app.ui.central_panel.left_panel.library_panel library_panel.add_item(self.fm_item) library_panel.add_item(self.simi_item) self.hide_simi_item() library_panel.add_item(self.recommend_item) def show_simi_item(self): self.simi_item.show() def hide_simi_item(self): self.simi_item.hide()