def attach_attrs(app): """初始化 app 属性""" loop = asyncio.get_event_loop() app.library = Library(app.config.PROVIDERS_STANDBY) app.live_lyric = LiveLyric(app) player_kwargs = dict( audio_device=bytes(app.config.MPV_AUDIO_DEVICE, 'utf-8')) app.playlist = Playlist(app, audio_select_policy=app.config.AUDIO_SELECT_POLICY) app.player = Player(app.playlist, **(player_kwargs or {})) app.plugin_mgr = PluginsManager(app) app.request = Request() app.task_mgr = TaskManager(app, loop) app.fm = FM(app) if app.mode & (app.DaemonMode | app.GuiMode): app.version_mgr = VersionManager(app) if app.mode & app.DaemonMode: app.server = FuoServer(app) app.pubsub_gateway = PubsubGateway() app._ll_publisher = LiveLyricPublisher(app.pubsub_gateway) if app.mode & app.GuiMode: from feeluown.uimodels.provider import ProviderUiManager from feeluown.uimodels.playlist import PlaylistUiManager from feeluown.uimodels.my_music import MyMusicUiManager from feeluown.uimodels.collection import CollectionUiManager from feeluown.collection import CollectionManager from .gui.browser import Browser from .gui.hotkey import HotkeyManager from .gui.image import ImgManager from .gui.theme import ThemeManager from .gui.tips import TipsManager from .gui.ui import Ui from .gui.tray import Tray # GUI 的一些辅助管理模块 app.coll_mgr = CollectionManager(app) app.theme_mgr = ThemeManager(app) app.tips_mgr = TipsManager(app) app.hotkey_mgr = HotkeyManager(app) app.img_mgr = ImgManager(app) # GUI 组件的数据管理模块 app.pvd_uimgr = ProviderUiManager(app) app.pl_uimgr = PlaylistUiManager(app) app.mymusic_uimgr = MyMusicUiManager(app) app.coll_uimgr = CollectionUiManager(app) app.browser = Browser(app) app.ui = Ui(app) if app.config.ENABLE_TRAY: app.tray = Tray(app) app.show_msg = app.ui.toolbar.status_line.get_item( 'notify').widget.show_msg
def attach_attrs(app): """初始化 app 属性""" loop = asyncio.get_event_loop() app.library = Library() app.live_lyric = LiveLyric() player_kwargs = dict( audio_device=bytes(app.config.MPV_AUDIO_DEVICE, 'utf-8')) app.player = Player(app=app, **(player_kwargs or {})) app.playlist = app.player.playlist app.plugin_mgr = PluginsManager(app) app.request = Request() app.task_mgr = TaskManager(app, loop) app.fm = FM(app) if app.mode & (app.DaemonMode | app.GuiMode): app.version_mgr = VersionManager(app) if app.mode & app.DaemonMode: app.server = FuoServer(app) app.pubsub_gateway, app.pubsub_server = create_pubsub( app.get_listen_addr()) app._ll_publisher = LiveLyricPublisher(app.pubsub_gateway) if app.mode & app.GuiMode: from feeluown.uimodels.provider import ProviderUiManager from feeluown.uimodels.playlist import PlaylistUiManager from feeluown.uimodels.my_music import MyMusicUiManager from feeluown.uimodels.collection import CollectionUiManager from feeluown.collection import CollectionManager from .browser import Browser from .hotkey import HotkeyManager from .image import ImgManager from .theme import ThemeManager from .tips import TipsManager from .ui import Ui # GUI 的一些辅助管理模块 app.coll_mgr = CollectionManager(app) app.theme_mgr = ThemeManager(app) app.tips_mgr = TipsManager(app) app.hotkey_mgr = HotkeyManager(app) app.img_mgr = ImgManager(app) # GUI 组件的数据管理模块 app.pvd_uimgr = ProviderUiManager(app) app.pl_uimgr = PlaylistUiManager(app) app.mymusic_uimgr = MyMusicUiManager(app) app.coll_uimgr = CollectionUiManager(app) app.browser = Browser(app) app.ui = Ui(app) app.show_msg = app.ui.magicbox.show_msg
def test_coll_mgr_generate_library_coll(app_mock, tmp_path): coll_mgr = CollectionManager(app_mock) directory = tmp_path / 'sub' directory.mkdir() coll_mgr.default_dir = str(directory) # Simulate a fake Album.fuo file. album = 'fuo://fake/albums/0' f = directory / 'Albums.fuo' f.touch() f.write_text(f'{album}\n') # Check if the library collection file is generated. coll_mgr.generate_library_coll_if_needed([str(f)]) library_coll_file = directory / 'library.fuo' assert library_coll_file.exists() # Check if the album is copied to library collection. with library_coll_file.open() as f: content = f.read() assert album in content
def attach_attrs(app): """初始化 app 属性""" app.library = Library() app.live_lyric = LiveLyric() player_kwargs = dict( audio_device=bytes(app.config.MPV_AUDIO_DEVICE, 'utf-8') ) app.player = Player(app=app, **(player_kwargs or {})) app.playlist = app.player.playlist app.plugin_mgr = PluginsManager(app) app.request = Request() app._g = {} if app.mode & (app.DaemonMode | app.GuiMode): app.version_mgr = VersionManager(app) if app.mode & app.GuiMode: from feeluown.widgets.collections import CollectionsModel from feeluown.uimodels.provider import ProviderUiManager from feeluown.uimodels.playlist import PlaylistUiManager from feeluown.uimodels.my_music import MyMusicUiManager from feeluown.collection import CollectionManager from .browser import Browser from .hotkey import HotkeyManager from .image import ImgManager from .theme import ThemeManager from .tips import TipsManager from .ui import Ui # GUI 的一些辅助管理模块 app.coll_mgr = CollectionManager(app) app.theme_mgr = ThemeManager(app) app.tips_mgr = TipsManager(app) app.hotkey_mgr = HotkeyManager(app) app.img_mgr = ImgManager(app) # GUI 组件的数据管理模块 app.pvd_uimgr = ProviderUiManager(app) app.pl_uimgr = PlaylistUiManager(app) app.mymusic_uimgr = MyMusicUiManager(app) app.collections = CollectionsModel(parent=app) app.browser = Browser(app) app.ui = Ui(app) app.show_msg = app.ui.magicbox.show_msg
def __init__(self, *args, **kwargs): config = args[1] pkg_root_dir = os.path.join(os.path.dirname(__file__), '..') icons_dir = os.path.join(pkg_root_dir, 'gui/assets/icons') QDir.addSearchPath('icons', icons_dir) QGuiApplication.setWindowIcon(QIcon(QPixmap('icons:feeluown.png'))) # Set desktopFileName so that the window icon is properly shown under wayland. # I don't know if this setting brings other benefits or not. # https://github.com/pyfa-org/Pyfa/issues/1607#issuecomment-392099878 QApplication.setDesktopFileName('FeelUOwn') QApplication.instance().setQuitOnLastWindowClosed( not config.ENABLE_TRAY) QApplication.instance().setApplicationName('FeelUOwn') QWidget.__init__(self) App.__init__(self, *args, **kwargs) GuiApp.__q_app = QApplication.instance() self.setObjectName('app') # GUI 的一些辅助管理模块 self.coll_mgr = CollectionManager(self) self.theme_mgr = ThemeManager(self) self.tips_mgr = TipsManager(self) self.hotkey_mgr = HotkeyManager(self) self.img_mgr = ImgManager(self) # GUI 组件的数据管理模块 self.pvd_uimgr = ProviderUiManager(self) self.pl_uimgr = PlaylistUiManager(self) self.mymusic_uimgr = MyMusicUiManager(self) self.coll_uimgr = CollectionUiManager(self) self.browser = Browser(self) self.ui = Ui(self) if self.config.ENABLE_TRAY: self.tray = Tray(self) self.show_msg = self.ui.toolbar.status_line.get_item( 'notify').widget.show_msg