def show_main_window(app: QApplication, args): options = Options.with_default_data_dir() options.load_from_disk() from randovania.gui.main_window import MainWindow main_window = MainWindow(options, getattr(args, "preview", False)) app.main_window = main_window main_window.show()
async def show_main_window(app: QtWidgets.QApplication, options, is_preview: bool): from randovania.interface_common.preset_manager import PresetManager from randovania.interface_common.options import Options options = typing.cast(Options, options) preset_manager = PresetManager(options.presets_path) logger.info("Loading user presets...") await preset_manager.load_user_presets() logger.info("Finished loading presets!") from randovania.gui.lib.qt_network_client import QtNetworkClient network_client: QtNetworkClient = app.network_client async def attempt_login(): from randovania.network_client.network_client import UnableToConnect from randovania.gui.lib import async_dialog try: from randovania.gui import main_online_interaction if not await main_online_interaction.ensure_logged_in(None, network_client): await async_dialog.warning(None, "Login required", "Logging in is required to use dev builds.") return False except UnableToConnect as e: s = e.reason.replace('\n', '<br />') await async_dialog.warning( None, "Connection Error", f"<b>Unable to connect to the server:</b><br /><br />{s}<br /><br />" f"Logging in is required to use dev builds.") return False return True if randovania.is_frozen() and randovania.is_dev_version(): try: logger.info("Disabling quit on last window closed") app.setQuitOnLastWindowClosed(False) if not await attempt_login(): app.quit() return finally: def reset_last_window_quit(): logger.info("Re-enabling quit on last window closed") app.setQuitOnLastWindowClosed(True) QtCore.QTimer.singleShot(1000, reset_last_window_quit) from randovania.gui.main_window import MainWindow logger.info("Preparing main window...") main_window = MainWindow(options, preset_manager, network_client, is_preview) app.main_window = main_window logger.info("Displaying main window") main_window.show() await main_window.request_new_data()
async def show_main_window(app: QApplication, options, is_preview: bool): from randovania.interface_common.preset_manager import PresetManager preset_manager = PresetManager(options.data_dir) await preset_manager.load_user_presets() from randovania.gui.main_window import MainWindow main_window = MainWindow(options, preset_manager, app.network_client, is_preview) app.main_window = main_window main_window.show() await main_window.request_new_data()
def test_dragEnterEvent(default_main_window: MainWindow, url, should_accept): mock_url = MagicMock() mock_url.toLocalFile.return_value = url event = MagicMock() event.mimeData.return_value.urls.return_value = [mock_url] # Run default_main_window.dragEnterEvent(event) # Assert if should_accept: event.acceptProposedAction.assert_called_once_with() else: event.acceptProposedAction.assert_not_called()
def test_drop_random_event(mock_load_game: MagicMock, default_main_window: MainWindow, qtbot, ): # Setup event = MagicMock() urls = [MagicMock(), MagicMock()] urls[0].toLocalFile.return_value = "directory/games/seed.json" urls[1].toLocalFile.return_value = "directory/games/game.png" event.mimeData.return_value.urls.return_value = [] # Run default_main_window.dropEvent(event) # Assert mock_load_game.assert_not_called()
def test_drop_iso_event(mock_load_game: MagicMock, default_main_window: MainWindow, qtbot, ): # Setup event = MagicMock() urls = [MagicMock(), MagicMock()] urls[0].toLocalFile.return_value = "directory/games/seed.json" urls[1].toLocalFile.return_value = "directory/games/game.iso" event.mimeData.return_value.urls.return_value = urls # Run default_main_window.dropEvent(event) # Assert mock_load_game.assert_called_once_with(default_main_window.windows[0], Path("directory/games/game.iso"))
async def show_main_window(app: QtWidgets.QApplication, options, is_preview: bool): from randovania.interface_common.preset_manager import PresetManager preset_manager = PresetManager(options.data_dir) logger.info("Loading user presets...") await preset_manager.load_user_presets() logger.info("Finished loading presets!") from randovania.gui.main_window import MainWindow logger.info("Preparing main window...") main_window = MainWindow(options, preset_manager, app.network_client, is_preview) app.main_window = main_window logger.info("Displaying main window") main_window.show() await main_window.request_new_data()
def show_main_window(app: QApplication, args): options = Options.with_default_data_dir() if not load_options_from_disk(options): raise SystemExit(1) from randovania.gui.main_window import MainWindow main_window = MainWindow(options, getattr(args, "preview", False)) app.main_window = main_window main_window.show() main_window.request_new_data()
def show_main_window(app: QApplication, is_preview: bool): options = Options.with_default_data_dir() preset_manager = PresetManager(options.data_dir) for old_preset in options.data_dir.joinpath("presets").glob( "*.randovania_preset"): old_preset.rename( old_preset.with_name( f"{old_preset.stem}.{Preset.file_extension()}")) if not load_options_from_disk(options): raise SystemExit(1) if not load_user_presets(preset_manager): raise SystemExit(2) from randovania.gui.main_window import MainWindow main_window = MainWindow(options, preset_manager, is_preview) app.main_window = main_window main_window.show() main_window.request_new_data()
def create_window(options: Union[Options, MagicMock], preset_manager: PresetManager) -> MainWindow: return MainWindow(options, preset_manager, MagicMock(), False)
def create_window(options: Union[Options, MagicMock]) -> MainWindow: return MainWindow(options, False)