How to use the feeluown.view_api.ViewOp.ui function in feeluown

To help you get started, we’ve selected a few feeluown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feeluown / FeelUOwn / feeluown / controllers / focus_manager.py View on Github external
def change_focus(cls):

        # TODO: other widget can add themselves to focusable_widgets
        focusable_widgets = [
            ViewOp.ui.WEBVIEW.tracks_table_widget,
            _BaseItem.items[2]]

        current_focus_widget = QApplication.focusWidget()
        if current_focus_widget in focusable_widgets:
            index = focusable_widgets.index(current_focus_widget)
            next_index = index + 1 if index < (len(focusable_widgets) - 1)\
                else 0
            focusable_widgets[next_index].setFocus()
        else:
            focusable_widgets[0].setFocus()
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
playlists = cls.controller.api.get_user_playlist()
        if not cls.controller.api.is_response_ok(playlists):
            return

        playlist_num = len(playlists)

        for playlist in playlists:
            pid = playlist['id']

            w = PlaylistItem()
            w.set_playlist_item(playlist)
            w.signal_text_btn_clicked.connect(cls.on_playlist_btn_clicked)

            if cls.controller.api.is_playlist_mine(playlist):
                ViewOp.ui.MY_LIST_WIDGET.layout().addWidget(w)
                if pid == cls.controller.api.favorite_pid:
                    favorite_playlist_detail = cls.controller.api.get_playlist_detail(pid)
                    cls.controller.state["current_pid"] = pid
                    ViewOp.ui.WEBVIEW.load_playlist(favorite_playlist_detail)
                else:
                    if playlist_num <= 50:
                        app_event_loop = asyncio.get_event_loop()
                        app_event_loop.call_soon(cls.controller.api.get_playlist_detail, pid)
            else:
                ViewOp.ui.COLLECTION_LIST_WIDGET.layout().addWidget(w)
        LOG.info('load user infos finished')
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
playlist_num = len(playlists)

        for playlist in playlists:
            pid = playlist['id']

            w = PlaylistItem()
            w.set_playlist_item(playlist)
            w.signal_text_btn_clicked.connect(cls.on_playlist_btn_clicked)

            if cls.controller.api.is_playlist_mine(playlist):
                ViewOp.ui.MY_LIST_WIDGET.layout().addWidget(w)
                if pid == cls.controller.api.favorite_pid:
                    favorite_playlist_detail = cls.controller.api.get_playlist_detail(pid)
                    cls.controller.state["current_pid"] = pid
                    ViewOp.ui.WEBVIEW.load_playlist(favorite_playlist_detail)
                else:
                    if playlist_num <= 50:
                        app_event_loop = asyncio.get_event_loop()
                        app_event_loop.call_soon(cls.controller.api.get_playlist_detail, pid)
            else:
                ViewOp.ui.COLLECTION_LIST_WIDGET.layout().addWidget(w)
        LOG.info('load user infos finished')
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
def on_player_media_changed(cls, music_model):
        artists = music_model['artists']
        artists_name = ''
        for artist in artists:
            artists_name += artist['name']
        title = music_model['name'] + ' - ' + artists_name
        cls.controller.desktop_mini.content.set_song_name(music_model['name'])
        cls.controller.desktop_mini.content.set_song_singer(artists_name)

        metrics = QFontMetrics(ViewOp.ui.TOP_WIDGET.font())
        title = metrics.elidedText(title, Qt.ElideRight, 300 - 40)
        ViewOp.ui.SONG_NAME_LABEL.setText(title)
        cls.controller.lyric_widget.reset_lyric()

        ViewOp.ui.SONG_COUNTDOWN_LABEL.setText('00:00')
        ViewOp.ui.SONG_PROGRESS_SLIDER.setRange(0, cls.controller.player.duration() / 1000)
        cls.controller.desktop_mini.content.set_duration(cls.controller.player.duration() / 1000)

        cls.controller.network_manager.get(QNetworkRequest(QUrl(music_model['album']['picUrl'] + "?param=200y200")))
        cls.controller.network_manager.network_queue.put(ViewOp.set_music_cover_img)

        cls.controller.current_playlist_widget.add_item_from_model(music_model)
        cls.controller.current_playlist_widget.focus_cell_by_mid(music_model['id'])

        cls.controller.state['current_mid'] = music_model['id']
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
def on_set_favorite_btn_clicked(cls, checked=True):
        if not cls.controller.state["current_mid"]:
            return False
        data = cls.controller.api.set_music_to_favorite(cls.controller.state['current_mid'], checked)
        cls.controller.desktop_mini.content.is_song_like = checked
        if not cls.controller.api.is_response_ok(data):
            ViewOp.ui.LOVE_SONG_BTN.setChecked(not checked)
            cls.controller.desktop_mini.content.is_song_like = not checked
            return False
        playlist_detail = cls.controller.api.get_playlist_detail(cls.controller.api.favorite_pid, cache=False)
        if not cls.controller.api.is_response_ok(playlist_detail):
            ViewOp.ui.STATUS_BAR.showMessage("刷新 -喜欢列表- 失败")
            return False
        if cls.controller.state['current_pid'] == cls.controller.api.favorite_pid:
            LOG.info("喜欢列表的歌曲发生变化")
            ViewOp.ui.WEBVIEW.load_playlist(playlist_detail)
        return True
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
def on_player_media_changed(cls, music_model):
        artists = music_model['artists']
        artists_name = ''
        for artist in artists:
            artists_name += artist['name']
        title = music_model['name'] + ' - ' + artists_name
        cls.controller.desktop_mini.content.set_song_name(music_model['name'])
        cls.controller.desktop_mini.content.set_song_singer(artists_name)

        metrics = QFontMetrics(ViewOp.ui.TOP_WIDGET.font())
        title = metrics.elidedText(title, Qt.ElideRight, 300 - 40)
        ViewOp.ui.SONG_NAME_LABEL.setText(title)
        cls.controller.lyric_widget.reset_lyric()

        ViewOp.ui.SONG_COUNTDOWN_LABEL.setText('00:00')
        ViewOp.ui.SONG_PROGRESS_SLIDER.setRange(0, cls.controller.player.duration() / 1000)
        cls.controller.desktop_mini.content.set_duration(cls.controller.player.duration() / 1000)

        cls.controller.network_manager.get(QNetworkRequest(QUrl(music_model['album']['picUrl'] + "?param=200y200")))
        cls.controller.network_manager.network_queue.put(ViewOp.set_music_cover_img)

        cls.controller.current_playlist_widget.add_item_from_model(music_model)
        cls.controller.current_playlist_widget.focus_cell_by_mid(music_model['id'])

        cls.controller.state['current_mid'] = music_model['id']

        if MusicModel.mv_available(music_model):
            ViewOp.ui.PLAY_MV_BTN.show()
        else:
            ViewOp.ui.PLAY_MV_BTN.close()
        if cls.controller.state['is_login']:
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
ViewOp.ui.SONG_COUNTDOWN_LABEL.setText('00:00')
        ViewOp.ui.SONG_PROGRESS_SLIDER.setRange(0, cls.controller.player.duration() / 1000)
        cls.controller.desktop_mini.content.set_duration(cls.controller.player.duration() / 1000)

        cls.controller.network_manager.get(QNetworkRequest(QUrl(music_model['album']['picUrl'] + "?param=200y200")))
        cls.controller.network_manager.network_queue.put(ViewOp.set_music_cover_img)

        cls.controller.current_playlist_widget.add_item_from_model(music_model)
        cls.controller.current_playlist_widget.focus_cell_by_mid(music_model['id'])

        cls.controller.state['current_mid'] = music_model['id']

        if MusicModel.mv_available(music_model):
            ViewOp.ui.PLAY_MV_BTN.show()
        else:
            ViewOp.ui.PLAY_MV_BTN.close()
        if cls.controller.state['is_login']:
            if cls.controller.api.is_favorite_music(music_model['id']):
                ViewOp.ui.LOVE_SONG_BTN.setChecked(True)
                cls.controller.desktop_mini.content.is_song_like = True
            else:
                ViewOp.ui.LOVE_SONG_BTN.setChecked(False)
                cls.controller.desktop_mini.content.is_song_like = False
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
cls.controller.network_manager.get(QNetworkRequest(QUrl(music_model['album']['picUrl'] + "?param=200y200")))
        cls.controller.network_manager.network_queue.put(ViewOp.set_music_cover_img)

        cls.controller.current_playlist_widget.add_item_from_model(music_model)
        cls.controller.current_playlist_widget.focus_cell_by_mid(music_model['id'])

        cls.controller.state['current_mid'] = music_model['id']

        if MusicModel.mv_available(music_model):
            ViewOp.ui.PLAY_MV_BTN.show()
        else:
            ViewOp.ui.PLAY_MV_BTN.close()
        if cls.controller.state['is_login']:
            if cls.controller.api.is_favorite_music(music_model['id']):
                ViewOp.ui.LOVE_SONG_BTN.setChecked(True)
                cls.controller.desktop_mini.content.is_song_like = True
            else:
                ViewOp.ui.LOVE_SONG_BTN.setChecked(False)
                cls.controller.desktop_mini.content.is_song_like = False
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
def on_player_media_changed(cls, music_model):
        artists = music_model['artists']
        artists_name = ''
        for artist in artists:
            artists_name += artist['name']
        title = music_model['name'] + ' - ' + artists_name
        cls.controller.desktop_mini.content.set_song_name(music_model['name'])
        cls.controller.desktop_mini.content.set_song_singer(artists_name)

        metrics = QFontMetrics(ViewOp.ui.TOP_WIDGET.font())
        title = metrics.elidedText(title, Qt.ElideRight, 300 - 40)
        ViewOp.ui.SONG_NAME_LABEL.setText(title)
        cls.controller.lyric_widget.reset_lyric()

        ViewOp.ui.SONG_COUNTDOWN_LABEL.setText('00:00')
        ViewOp.ui.SONG_PROGRESS_SLIDER.setRange(0, cls.controller.player.duration() / 1000)
        cls.controller.desktop_mini.content.set_duration(cls.controller.player.duration() / 1000)

        cls.controller.network_manager.get(QNetworkRequest(QUrl(music_model['album']['picUrl'] + "?param=200y200")))
        cls.controller.network_manager.network_queue.put(ViewOp.set_music_cover_img)

        cls.controller.current_playlist_widget.add_item_from_model(music_model)
        cls.controller.current_playlist_widget.focus_cell_by_mid(music_model['id'])

        cls.controller.state['current_mid'] = music_model['id']

        if MusicModel.mv_available(music_model):
            ViewOp.ui.PLAY_MV_BTN.show()
github feeluown / FeelUOwn / feeluown / view_api.py View on Github external
def on_play_or_pause_clicked(cls):
        if cls.controller.player.mediaStatus() == QMediaPlayer.NoMedia or \
                cls.controller.player.mediaStatus() == QMediaPlayer.UnknownMediaStatus:
            ViewOp.ui.PLAY_OR_PAUSE.setChecked(True)     # 暂停状态
            return
        cls.controller.player.play_or_pause()