def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.library_header = QLabel('音乐库', self) self.playlists_header = QLabel('歌单列表', self) self.history_header = QLabel('浏览历史记录', self) self.my_music_header = QLabel('我的音乐', self) class Container(QFrame): def __init__(self, label, view, parent=None): super().__init__(parent) self._layout = QVBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) label.setFixedHeight(25) self._layout.addWidget(label) self._layout.addWidget(view) self._layout.addStretch(0) # XXX: 本意是让 Container 下方不要出现多余的空间 self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) self.playlists_view = PlaylistsView(self) self.providers_view = ProvidersView(self) self.histories_view = HistoriesView(self) self.my_music_view = MyMusicView(self) self.providers_con = Container(self.library_header, self.providers_view) self.histories_con = Container(self.history_header, self.histories_view) self.playlists_con = Container(self.playlists_header, self.playlists_view) self.my_music_con = Container(self.my_music_header, self.my_music_view) self.providers_view.setModel(self._app.providers) self.histories_view.setModel(self._app.histories) self.playlists_view.setModel(self._app.playlists) self.my_music_view.setModel(self._app.my_music) self._layout = QVBoxLayout(self) if use_mac_theme(): self._layout.setSpacing(0) self._layout.setContentsMargins(6, 4, 0, 0) self._layout.addWidget(self.providers_con) self._layout.addWidget(self.my_music_con) self._layout.addWidget(self.histories_con) self._layout.addWidget(self.playlists_con) self._layout.addStretch(0) self.providers_view.setFrameShape(QFrame.NoFrame) self.playlists_view.setFrameShape(QFrame.NoFrame) self.histories_view.setFrameShape(QFrame.NoFrame) self.my_music_view.setFrameShape(QFrame.NoFrame) self.setMinimumWidth(180) self.setMaximumWidth(250) self.playlists_view.show_playlist.connect( lambda pl: asyncio.ensure_future(self.show_model(pl))) self.histories_view.show_model.connect( lambda model: asyncio.ensure_future(self.show_model(model))) # 让各个音乐库来决定是否显示这些组件 self.playlists_con.hide() self.my_music_con.hide() # 历史记录暂时隐藏 self.histories_con.hide()
def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.library_header = QLabel('音乐库', self) self.collections_header = QLabel('本地收藏 (Beta)', self) self.collections_header.setToolTip( '我们可以在本地建立『收藏集』来收藏自己喜欢的音乐资源\n\n' '每个收藏集都以一个独立 .fuo 文件的存在,' '将鼠标悬浮在收藏集上,可以查看文件所在路径。\n' '新建 fuo 文件,则可以新建收藏集,文件名即是收藏集的名字。\n\n' '手动编辑 fuo 文件即可编辑收藏集中的音乐资源,也可以在界面上拖拽来增删歌曲。') self.playlists_header = QLabel('歌单列表', self) self.history_header = QLabel('浏览历史记录', self) self.my_music_header = QLabel('我的音乐', self) class Container(QFrame): def __init__(self, label, view, parent=None): super().__init__(parent) self._layout = QVBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) label.setFixedHeight(25) self._layout.addWidget(label) self._layout.addWidget(view) self._layout.addStretch(0) # XXX: 本意是让 Container 下方不要出现多余的空间 self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) self.playlists_view = PlaylistsView(self) self.providers_view = ProvidersView(self) self.histories_view = HistoriesView(self) self.my_music_view = MyMusicView(self) self.collections_view = CollectionsView(self) self.providers_con = Container(self.library_header, self.providers_view) self.collections_con = Container(self.collections_header, self.collections_view) self.histories_con = Container(self.history_header, self.histories_view) self.playlists_con = Container(self.playlists_header, self.playlists_view) self.my_music_con = Container(self.my_music_header, self.my_music_view) self.providers_view.setModel(self._app.providers) self.histories_view.setModel(self._app.histories) self.playlists_view.setModel(self._app.playlists) self.my_music_view.setModel(self._app.my_music) self.collections_view.setModel(self._app.collections) self._layout = QVBoxLayout(self) if use_mac_theme(): self._layout.setSpacing(0) self._layout.setContentsMargins(6, 4, 0, 0) self._layout.addWidget(self.providers_con) self._layout.addWidget(self.collections_con) self._layout.addWidget(self.my_music_con) self._layout.addWidget(self.histories_con) self._layout.addWidget(self.playlists_con) self._layout.addStretch(0) self.providers_view.setFrameShape(QFrame.NoFrame) self.playlists_view.setFrameShape(QFrame.NoFrame) self.histories_view.setFrameShape(QFrame.NoFrame) self.my_music_view.setFrameShape(QFrame.NoFrame) self.collections_view.setFrameShape(QFrame.NoFrame) self.setFrameShape(QFrame.NoFrame) self.setMinimumWidth(180) self.setMaximumWidth(250) self.playlists_view.show_playlist.connect( lambda pl: asyncio.ensure_future(self.show_model(pl))) self.histories_view.show_model.connect( lambda model: asyncio.ensure_future(self.show_model(model))) self.collections_view.show_collection.connect( lambda collection: self._app.ui.table_container.show_collection( collection)) # 让各个音乐库来决定是否显示这些组件 self.playlists_con.hide() self.my_music_con.hide() # 历史记录暂时隐藏 self.histories_con.hide()
class LeftPanel(QFrame): def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.library_header = QLabel('音乐库', self) self.playlists_header = QLabel('歌单列表', self) self.history_header = QLabel('浏览历史记录', self) self.my_music_header = QLabel('我的音乐', self) class Container(QWidget): def __init__(self, label, view, parent=None): super().__init__(parent) self._layout = QVBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) label.setFixedHeight(25) self._layout.addWidget(label) self._layout.addWidget(view) self._layout.addStretch(0) self.playlists_view = PlaylistsView(self) self.providers_view = ProvidersView(self) self.histories_view = HistoriesView(self) self.my_music_view = MyMusicView(self) self.providers_con = Container(self.library_header, self.providers_view) self.histories_con = Container(self.history_header, self.histories_view) self.playlists_con = Container(self.playlists_header, self.playlists_view) self.my_music_con = Container(self.my_music_header, self.my_music_view) self._splitter = QSplitter(Qt.Vertical, self) self.providers_view.setModel(self._app.providers) self.histories_view.setModel(self._app.histories) self.playlists_view.setModel(self._app.playlists) self.my_music_view.setModel(self._app.my_music) self._layout = QVBoxLayout(self) if use_mac_theme(): self._layout.setSpacing(0) self._layout.setContentsMargins(6, 4, 0, 0) self._splitter.addWidget(self.providers_con) self._splitter.addWidget(self.my_music_con) self._splitter.addWidget(self.histories_con) self._splitter.addWidget(self.playlists_con) self._layout.addWidget(self._splitter) self._layout.addStretch(0) self.providers_view.setFrameShape(QFrame.NoFrame) self.playlists_view.setFrameShape(QFrame.NoFrame) self.histories_view.setFrameShape(QFrame.NoFrame) self.my_music_view.setFrameShape(QFrame.NoFrame) self.setMinimumWidth(180) self.setMaximumWidth(250) self.playlists_view.show_playlist.connect( lambda pl: asyncio.ensure_future(self.show_model(pl))) self.histories_view.show_model.connect( lambda model: asyncio.ensure_future(self.show_model(model))) # 让各个音乐库来决定是否显示这些组件 self.playlists_con.hide() self.my_music_con.hide() # 历史记录暂时隐藏 self.histories_con.hide() async def show_model(self, playlist): await self._app.ui.table_container.show_model(playlist)
def __init__(self, app, parent=None): super().__init__(parent) self._app = app self.library_header = QLabel('音乐库', self) self.collections_header = QLabel('本地收藏 (Alpha)', self) self.playlists_header = QLabel('歌单列表', self) self.history_header = QLabel('浏览历史记录', self) self.my_music_header = QLabel('我的音乐', self) class Container(QFrame): def __init__(self, label, view, parent=None): super().__init__(parent) self._layout = QVBoxLayout(self) self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) label.setFixedHeight(25) self._layout.addWidget(label) self._layout.addWidget(view) self._layout.addStretch(0) # XXX: 本意是让 Container 下方不要出现多余的空间 self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) self.playlists_view = PlaylistsView(self) self.providers_view = ProvidersView(self) self.histories_view = HistoriesView(self) self.my_music_view = MyMusicView(self) self.collections_view = CollectionsView(self) self.providers_con = Container(self.library_header, self.providers_view) self.collections_con = Container(self.collections_header, self.collections_view) self.histories_con = Container(self.history_header, self.histories_view) self.playlists_con = Container(self.playlists_header, self.playlists_view) self.my_music_con = Container(self.my_music_header, self.my_music_view) self.providers_view.setModel(self._app.providers) self.histories_view.setModel(self._app.histories) self.playlists_view.setModel(self._app.playlists) self.my_music_view.setModel(self._app.my_music) self.collections_view.setModel(self._app.collections) self._layout = QVBoxLayout(self) if use_mac_theme(): self._layout.setSpacing(0) self._layout.setContentsMargins(6, 4, 0, 0) self._layout.addWidget(self.providers_con) self._layout.addWidget(self.collections_con) self._layout.addWidget(self.my_music_con) self._layout.addWidget(self.histories_con) self._layout.addWidget(self.playlists_con) self._layout.addStretch(0) self.providers_view.setFrameShape(QFrame.NoFrame) self.playlists_view.setFrameShape(QFrame.NoFrame) self.histories_view.setFrameShape(QFrame.NoFrame) self.my_music_view.setFrameShape(QFrame.NoFrame) self.collections_view.setFrameShape(QFrame.NoFrame) self.setMinimumWidth(180) self.setMaximumWidth(250) self.playlists_view.show_playlist.connect( lambda pl: asyncio.ensure_future(self.show_model(pl))) self.histories_view.show_model.connect( lambda model: asyncio.ensure_future(self.show_model(model))) self.collections_view.show_collection.connect( lambda collection: self._app.ui.table_container.show_collection(collection)) # 让各个音乐库来决定是否显示这些组件 self.playlists_con.hide() self.my_music_con.hide() # 历史记录暂时隐藏 self.histories_con.hide()