def load_user_infos(cls, data): avatar_url = data['avatar'] request = QNetworkRequest(QUrl(avatar_url)) cls.controller.network_manager.get(request) cls.controller.network_manager.network_queue.put(ViewOp.set_login_label_avatar) ViewOp.ui.MY_LIST_WIDGET.empty_layout() ViewOp.ui.COLLECTION_LIST_WIDGET.empty_layout() 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')
def _show_user_playlist(self): while self.ui.MY_LIST_WIDGET.layout().takeAt(0): item = self.ui.MY_LIST_WIDGET.layout().takeAt(0) del item while self.ui.COLLECTION_LIST_WIDGET.layout().takeAt(0): item = self.ui.MY_LIST_WIDGET.layout().takeAt(0) del item playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): return for playlist in playlists: pid = playlist['id'] w = PlaylistItem(self) w.set_playlist_item(playlist) w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.MY_LIST_WIDGET.layout().addWidget(w) if pid == self.api.favorite_pid: @func_coroutine def load_favorite_playlist(playlist_id): favorite_playlist_detail = self.api.get_playlist_detail(playlist_id, cache=False) self.state["current_pid"] = playlist_id self.ui.WEBVIEW.load_playlist(favorite_playlist_detail) load_favorite_playlist(pid) else: APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.COLLECTION_LIST_WIDGET.layout().addWidget(w)
def load_user_infos(cls, data): avatar_url = data['avatar'] request = QNetworkRequest(QUrl(avatar_url)) ControllerApi.network_manager.get(request) ControllerApi.network_manager.network_queue.put(ViewOp.set_login_label_avatar) ViewOp.ui.MY_LIST_WIDGET.empty_layout() ViewOp.ui.COLLECTION_LIST_WIDGET.empty_layout() playlists = ControllerApi.api.get_user_playlist() if not ControllerApi.api.is_response_ok(playlists): return 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 ControllerApi.api.is_playlist_mine(playlist): ViewOp.ui.MY_LIST_WIDGET.layout().addWidget(w) if pid == ControllerApi.api.favorite_pid: @func_coroutine def load_favorite_playlist(playlist_id): favorite_playlist_detail = ControllerApi.api.get_playlist_detail(playlist_id, cache=False) ControllerApi.state["current_pid"] = playlist_id ViewOp.ui.WEBVIEW.load_playlist(favorite_playlist_detail) load_favorite_playlist(pid) else: app_event_loop = asyncio.get_event_loop() app_event_loop.call_soon(ControllerApi.api.get_playlist_detail, pid) else: ViewOp.ui.COLLECTION_LIST_WIDGET.layout().addWidget(w)
def change_to_simi(self): PlaylistItem.de_active_all() if self.current_mode == 1: FmMode.exit_() elif self.current_mode == 2: ControllerApi.notify_widget.show_message("提示", "你正处于单曲电台模式") return self.current_mode = 2 ControllerApi.player.change_player_mode_to_other() SimiSongsMode.load_()
def change_to_simi(self): PlaylistItem.de_active_all() if self.current_mode == 1: FmMode.exit_() if self.current_mode == 2: ControllerApi.notify_widget.show_message("提示", "你正处于单曲电台模式") return self.current_mode = 2 ControllerApi.player.change_player_mode_to_other() SimiSongsMode.load_()
def new_playlist(cls): playlist = cls.controller.api.new_playlist('default') if playlist is None: cls.controller.notify_widget.show_message('◕◠◔', '新建歌单失败') return False w = PlaylistItem() w.set_playlist_item(playlist) w.signal_text_btn_clicked.connect(cls.on_playlist_btn_clicked) ViewOp.ui.MY_LIST_WIDGET.layout().addWidget(w) w.edit_mode() return True
def search_music(self): text = self.ui.top_widget.search_edit.text() if text != '': self.status.showMessage(u'正在搜索: ' + text) songs = self.api.search(text) if not self.is_response_ok(songs): return PlaylistItem.de_active_all() self.webview.load_search_result(songs) self.state['current_pid'] = 0 length = len(songs) if length != 0: self.status.showMessage(u'搜索到 ' + str(length) + u' 首 ' + text + u' 相关歌曲', 5000) return else: self.ui.status.showMessage(u'很抱歉,没有找到相关歌曲', 5000) return
def show_user_playlist(self): while self.ui.left_widget.central_widget.create_list_widget.layout.takeAt( 0): item = self.ui.left_widget.central_widget.create_list_widget.layout.takeAt( 0) del item while self.ui.left_widget.central_widget.collection_list_widget.layout.takeAt( 0): item = self.ui.left_widget.central_widget.create_list_widget.layout.takeAt( 0) del item playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): self.show_network_error_message() return for playlist in playlists: # self.status.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist['id'] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.left_widget.central_widget.create_list_widget.layout.addWidget( w) if pid == self.api.favorite_pid: @func_coroutine def load_favorite_playlist(): favorite_playlist_detail = self.api.get_playlist_detail( pid) self.webview.load_playlist(favorite_playlist_detail) load_favorite_playlist() else: APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.left_widget.central_widget.collection_list_widget.layout.addWidget( w)
def search_music(self): text = self.ui.top_widget.search_edit.text() if text != "": self.status.showMessage(u"正在搜索: " + text) songs = self.api.search(text) if not self.is_response_ok(songs): return PlaylistItem.de_active_all() self.webview.load_search_result(songs) self.state["current_pid"] = 0 length = len(songs) if length != 0: self.status.showMessage(u"搜索到 " + str(length) + u" 首 " + text + u" 相关歌曲", 5000) return else: self.ui.status.showMessage(u"很抱歉,没有找到相关歌曲", 5000) return
def _search_music(self): text = ViewOp.ui.SEARCH_BOX.text() if text != '': ViewOp.ui.STATUS_BAR.showMessage(u'正在搜索: ' + text) songs = ControllerApi.api.search(text) if not ControllerApi.api.is_response_ok(songs): return PlaylistItem.de_active_all() ViewOp.ui.WEBVIEW.load_search_result(songs) ControllerApi.state['current_pid'] = 0 length = len(songs) if length != 0: ViewOp.ui.STATUS_BAR.showMessage(u'O(∩_∩)O,搜索到 ' + str(length) + u' 首 ' + text + u' 相关歌曲', 5000) return else: ViewOp.ui.STATUS_BAR.showMessage(u'Oops,没有找到相关歌曲', 5000) return
def search_music(self): text = self.ui.SEARCH_BOX.text() if text != "": self.ui.STATUS_BAR.showMessage(u"正在搜索: " + text) songs = self.api.search(text) if not self.is_response_ok(songs): return PlaylistItem.de_active_all() self.ui.WEBVIEW.load_search_result(songs) self.state["current_pid"] = 0 length = len(songs) if length != 0: self.ui.STATUS_BAR.showMessage(u"搜索到 " + str(length) + u" 首 " + text + u" 相关歌曲", 5000) return else: self.ui.STATUS_BAR.showMessage(u"很抱歉,没有找到相关歌曲", 5000) return
def search_music(self): text = self.ui.SEARCH_BOX.text() if text != '': self.ui.STATUS_BAR.showMessage(u'正在搜索: ' + text) songs = self.api.search(text) if not self.is_response_ok(songs): return PlaylistItem.de_active_all() self.ui.WEBVIEW.load_search_result(songs) self.state['current_pid'] = 0 length = len(songs) if length != 0: self.ui.STATUS_BAR.showMessage(u'搜索到 ' + str(length) + u' 首 ' + text + u' 相关歌曲', 5000) return else: self.ui.STATUS_BAR.showMessage(u'很抱歉,没有找到相关歌曲', 5000) return
def search_music(self): text = self.ui.SEARCH_BOX.text() if text != '': self.ui.STATUS_BAR.showMessage(u'正在搜索: ' + text) songs = self.api.search(text) if not self.is_response_ok(songs): return PlaylistItem.de_active_all() self.ui.WEBVIEW.load_search_result(songs) self.state['current_pid'] = 0 length = len(songs) if length != 0: self.ui.STATUS_BAR.showMessage( u'搜索到 ' + str(length) + u' 首 ' + text + u' 相关歌曲', 5000) return else: self.ui.STATUS_BAR.showMessage(u'很抱歉,没有找到相关歌曲', 5000) return
def _search_music(self): text = ViewOp.ui.SEARCH_BOX.text() if text != '': ViewOp.ui.STATUS_BAR.showMessage(u'正在搜索: ' + text) songs = ControllerApi.api.search(text) if not ControllerApi.api.is_response_ok(songs): return PlaylistItem.de_active_all() ViewOp.ui.WEBVIEW.load_search_result(songs) ControllerApi.state['current_pid'] = 0 length = len(songs) if length != 0: ViewOp.ui.STATUS_BAR.showMessage( u'O(∩_∩)O,搜索到 ' + str(length) + u' 首 ' + text + u' 相关歌曲', 5000) return else: ViewOp.ui.STATUS_BAR.showMessage(u'Oops,没有找到相关歌曲', 5000) return
def show_user_playlist(self): playlists = self.api.get_user_playlist() self.status.showMessage(u'正在缓存部分数据,请您等待3-4s', 5000) # self.trayicon.showMessage(u'正在缓存部分数据,请您等待3-4s') for playlist in playlists: # self.status.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist['id'] start_new_thread(self.api.get_playlist_detail, (pid, )) w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.left_widget.central_widget.create_list_widget.layout.addWidget(w) else: self.ui.left_widget.central_widget.collection_list_widget.layout.addWidget(w)
def show_user_playlist(self): playlists = self.api.get_user_playlist() self.status.showMessage(u'正在缓存部分数据,请您等待3-4s', 5000) # self.trayicon.showMessage(u'正在缓存部分数据,请您等待3-4s') for playlist in playlists: # self.status.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist['id'] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.left_widget.central_widget.create_list_widget.layout.addWidget(w) start_new_thread(self.api.get_playlist_detail, (pid, )) else: self.ui.left_widget.central_widget.collection_list_widget.layout.addWidget(w)
def show_user_playlist(self): while self.ui.MY_LIST_WIDGET.layout.takeAt(0): item = self.ui.MY_LIST_WIDGET.layout.takeAt(0) del item while self.ui.COLLECTION_LIST_WIDGET.layout.takeAt(0): item = self.ui.MY_LIST_WIDGET.layout.takeAt(0) del item playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): self.show_network_error_message() return for playlist in playlists: # self.ui.STATUS_BAR.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist['id'] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.MY_LIST_WIDGET.layout.addWidget(w) if pid == self.api.favorite_pid: @func_coroutine def load_favorite_playlist(playlist_id): favorite_playlist_detail = self.api.get_playlist_detail( playlist_id, cache=False) self.state["current_pid"] = playlist_id self.ui.WEBVIEW.load_playlist(favorite_playlist_detail) load_favorite_playlist(pid) else: APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.COLLECTION_LIST_WIDGET.layout.addWidget(w)
def show_user_playlist(self): while self.ui.MY_LIST_WIDGET.layout.takeAt(0): item = self.ui.MY_LIST_WIDGET.layout.takeAt(0) del item while self.ui.COLLECTION_LIST_WIDGET.layout.takeAt(0): item = self.ui.MY_LIST_WIDGET.layout.takeAt(0) del item playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): self.show_network_error_message() return for playlist in playlists: # self.ui.STATUS_BAR.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist["id"] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.MY_LIST_WIDGET.layout.addWidget(w) if pid == self.api.favorite_pid: @func_coroutine def load_favorite_playlist(playlist_id): favorite_playlist_detail = self.api.get_playlist_detail(playlist_id, cache=False) self.state["current_pid"] = playlist_id self.ui.WEBVIEW.load_playlist(favorite_playlist_detail) load_favorite_playlist(pid) else: APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.COLLECTION_LIST_WIDGET.layout.addWidget(w)
def show_user_playlist(self): while self.ui.left_widget.central_widget.create_list_widget.layout.takeAt(0): item = self.ui.left_widget.central_widget.create_list_widget.layout.takeAt(0) del item while self.ui.left_widget.central_widget.collection_list_widget.layout.takeAt(0): item = self.ui.left_widget.central_widget.create_list_widget.layout.takeAt(0) del item playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): self.show_network_error_message() return for playlist in playlists: # self.status.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist["id"] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.left_widget.central_widget.create_list_widget.layout.addWidget(w) if pid == self.api.favorite_pid: @func_coroutine def load_favorite_playlist(): favorite_playlist_detail = self.api.get_playlist_detail(pid) self.webview.load_playlist(favorite_playlist_detail) load_favorite_playlist() else: APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.left_widget.central_widget.collection_list_widget.layout.addWidget(w)
def show_user_playlist(self): playlists = self.api.get_user_playlist() if not self.is_response_ok(playlists): self.show_network_error_message() return for playlist in playlists: # self.status.showMessage(u'正在缓存您的歌单列表', 10000) # 会让程序整体等待10s pid = playlist['id'] w = PlaylistItem(self) w.set_playlist_item(playlist) # 感觉这句话增加了耦合度, 暂时没找到好的解决办法 w.signal_text_btn_clicked.connect(self.on_playlist_btn_clicked) if self.api.is_playlist_mine(playlist): self.ui.left_widget.central_widget.create_list_widget.layout.addWidget(w) APP_EVENT_LOOP = asyncio.get_event_loop() APP_EVENT_LOOP.call_soon(self.api.get_playlist_detail, pid) else: self.ui.left_widget.central_widget.collection_list_widget.layout.addWidget(w)
def load_user_infos(cls, data): avatar_url = data['avatar'] request = QNetworkRequest(QUrl(avatar_url)) cls.controller.network_manager.get(request) cls.controller.network_manager.network_queue.put( ViewOp.set_login_label_avatar) ViewOp.ui.MY_LIST_WIDGET.empty_layout() ViewOp.ui.COLLECTION_LIST_WIDGET.empty_layout() 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)