# Path: src/controllers/utils.py
# def registerContext(func):
#     @functools.wraps(func)
#     def wrapper(*args, **kwargs):
#         self = args[0]
#         if hasattr(self, '__contextName__'):
#             contexts.update({self.__contextName__: self})
#         func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: src/controllers/signalmanager.py
# class SignalManager(QObject):
#     def __init__(self, parent=None):


import os
import re
import requests
from PyQt5.QtCore import (QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl)
from PyQt5.QtGui import QCursor, QDesktopServices
from .utils import registerContext
from config.constants import LRCPath
from log import logger
from dwidgets.coverlrc.lrc_download import TTPlayer, DUOMI, SOSO, TTPod
from dwidgets.coverlrc.cover_query import poster
from dwidgets.coverlrc.lrc_parser import LrcParser
from dwidgets.dthreadutil import dthread
from .signalmanager import signalManager
            elif self._lineMode == 2:
                texts = []
                if lyric_id % 2 == 0:
                    texts.append((text, percentage, lyric_id))
                    text = self.getLyricTextById(lyric_id + 1)
                    texts.append((text, 0, lyric_id + 1))
                else:
                    texts.append((text, percentage, lyric_id))
                    text = self.getLyricTextById(lyric_id - 1)
                    texts.insert(0, (text, 1, lyric_id - 1))
                signalManager.douleTextInfoChanged.emit(texts)
            self.currentText = text

    @pyqtProperty('QString', notify=currentTextChanged)
    def currentText(self):
        return self._currentText

    @currentText.setter
    def currentText(self, text):
        self._currentText = text
        self.currentTextChanged.emit(text)

    @pyqtSlot(int, result='QString')
    def getLyricTextById(self, lyric_id):
        return self.lrcParser.get_item_lyric(lyric_id)

    def isLrcExisted(self, artist, title):
        path = self.getLrcPath(artist, title)
        if path:
            if os.path.exists(path):

# Path: src/controllers/utils.py
# def registerContext(func):
#     @functools.wraps(func)
#     def wrapper(*args, **kwargs):
#         self = args[0]
#         if hasattr(self, '__contextName__'):
#             contexts.update({self.__contextName__: self})
#         func(*args, **kwargs)
# 
#     return wrapper
# 
# Path: src/controllers/signalmanager.py
# class SignalManager(QObject):
#     def __init__(self, parent=None):


# Path: src/controllers/lrcworker.py
import os
import re
import requests
from PyQt5.QtCore import (QObject, pyqtSignal, pyqtSlot, pyqtProperty, QUrl)
from PyQt5.QtGui import QCursor, QDesktopServices
from .utils import registerContext
from config.constants import LRCPath
from log import logger
from dwidgets.coverlrc.lrc_download import TTPlayer, DUOMI, SOSO, TTPod
from dwidgets.coverlrc.cover_query import poster
from dwidgets.coverlrc.lrc_parser import LrcParser
from dwidgets.dthreadutil import dthread
from .signalmanager import signalManager

            elif self._lineMode == 2:
                texts = []
                if lyric_id % 2 == 0:
                    texts.append((text, percentage, lyric_id))
                    text = self.getLyricTextById(lyric_id + 1)
                    texts.append((text, 0, lyric_id + 1))
                else:
                    texts.append((text, percentage, lyric_id))
                    text = self.getLyricTextById(lyric_id - 1)
                    texts.insert(0, (text, 1, lyric_id - 1))
                signalManager.douleTextInfoChanged.emit(texts)
            self.currentText = text

    @pyqtProperty('QString', notify=currentTextChanged)
    def currentText(self):
        return self._currentText

    @currentText.setter
    def currentText(self, text):
        self._currentText = text
        self.currentTextChanged.emit(text)

    @pyqtSlot(int, result='QString')
    def getLyricTextById(self, lyric_id):
        return self.lrcParser.get_item_lyric(lyric_id)

    def isLrcExisted(self, artist, title):
        path = self.getLrcPath(artist, title)
        if path:
            if os.path.exists(path):

                return True