Ejemplo n.º 1
0
    def __init__(self, app, parent=None):
        super().__init__(parent)
        self._app = app

        self.library_header = QLabel('音乐提供方', self)
        self.collections_header = QLabel('本地收藏', self)
        self.collections_header.setToolTip(
            '我们可以在本地建立『收藏集』来收藏自己喜欢的音乐资源\n\n'
            '每个收藏集都以一个独立 .fuo 文件的存在,'
            '将鼠标悬浮在收藏集上,可以查看文件所在路径。\n'
            '新建 fuo 文件,则可以新建收藏集,文件名即是收藏集的名字。\n\n'
            '手动编辑 fuo 文件即可编辑收藏集中的音乐资源,也可以在界面上拖拽来增删歌曲。')
        self.playlists_header = QLabel('歌单列表', self)
        self.my_music_header = QLabel('我的音乐', self)

        self.playlists_view = PlaylistsView(self)
        self.providers_view = ProvidersView(self)
        self.my_music_view = MyMusicView(self)
        self.collections_view = CollectionsView(self)

        self.providers_con = ListViewContainer(self.library_header,
                                               self.providers_view)
        self.collections_con = ListViewContainer(self.collections_header,
                                                 self.collections_view)
        self.playlists_con = ListViewContainer(self.playlists_header,
                                               self.playlists_view)
        self.my_music_con = ListViewContainer(self.my_music_header,
                                              self.my_music_view)

        self.providers_view.setModel(self._app.pvd_uimgr.model)
        self.playlists_view.setModel(self._app.pl_uimgr.model)
        self.my_music_view.setModel(self._app.mymusic_uimgr.model)
        self.collections_view.setModel(self._app.coll_uimgr.model)

        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.playlists_con)
        self._layout.addStretch(0)

        self.providers_view.setFrameShape(QFrame.NoFrame)
        self.playlists_view.setFrameShape(QFrame.NoFrame)
        self.my_music_view.setFrameShape(QFrame.NoFrame)
        self.collections_view.setFrameShape(QFrame.NoFrame)
        self.setFrameShape(QFrame.NoFrame)
        # 让各个音乐库来决定是否显示这些组件
        self.playlists_con.hide()
        self.my_music_con.hide()

        self.playlists_view.show_playlist.connect(
            lambda pl: self._app.browser.goto(model=pl))
        self.collections_view.show_collection.connect(self.show_coll)
Ejemplo n.º 2
0
    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.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.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.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.pvd_uimgr.model)
        self.playlists_view.setModel(self._app.pl_uimgr.model)
        self.my_music_view.setModel(self._app.mymusic_uimgr.model)
        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.playlists_con)
        self._layout.addStretch(0)

        self.providers_view.setFrameShape(QFrame.NoFrame)
        self.playlists_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.collections_view.show_collection.connect(
            lambda collection: self._app.ui.table_container.show_collection(
                collection))

        # 让各个音乐库来决定是否显示这些组件
        self.playlists_con.hide()
        self.my_music_con.hide()
Ejemplo n.º 3
0
class _LeftPanel(QFrame):
    def __init__(self, app, parent=None):
        super().__init__(parent)
        self._app = app

        self.library_header = QLabel('音乐提供方', self)
        self.collections_header = QLabel('本地收藏', self)
        self.collections_header.setToolTip(
            '我们可以在本地建立『收藏集』来收藏自己喜欢的音乐资源\n\n'
            '每个收藏集都以一个独立 .fuo 文件的存在,'
            '将鼠标悬浮在收藏集上,可以查看文件所在路径。\n'
            '新建 fuo 文件,则可以新建收藏集,文件名即是收藏集的名字。\n\n'
            '手动编辑 fuo 文件即可编辑收藏集中的音乐资源,也可以在界面上拖拽来增删歌曲。')
        self.playlists_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.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.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.pvd_uimgr.model)
        self.playlists_view.setModel(self._app.pl_uimgr.model)
        self.my_music_view.setModel(self._app.mymusic_uimgr.model)
        self.collections_view.setModel(self._app.coll_uimgr.model)

        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.playlists_con)
        self._layout.addStretch(0)

        self.providers_view.setFrameShape(QFrame.NoFrame)
        self.playlists_view.setFrameShape(QFrame.NoFrame)
        self.my_music_view.setFrameShape(QFrame.NoFrame)
        self.collections_view.setFrameShape(QFrame.NoFrame)
        self.setFrameShape(QFrame.NoFrame)
        # 让各个音乐库来决定是否显示这些组件
        self.playlists_con.hide()
        self.my_music_con.hide()

        self.playlists_view.show_playlist.connect(
            lambda pl: self._app.browser.goto(model=pl))
        self.collections_view.show_collection.connect(self.show_coll)

    def sizeHint(self):
        size = super().sizeHint()
        return QSize(230, size.height())

    def show_coll(self, coll):
        coll_id = self._app.coll_uimgr.get_coll_id(coll)
        self._app.browser.goto(uri='/colls/{}'.format(coll_id))