Exemple #1
0
def _load_options():
    logger.info("Loading up user preferences code...")
    from randovania.interface_common.options import Options
    from randovania.gui.lib import startup_tools, theme

    logger.info("Restoring saved user preferences...")
    options = Options.with_default_data_dir()
    if not startup_tools.load_options_from_disk(options):
        raise SystemExit(1)

    logger.info("Creating user preferences folder")
    import dulwich.repo
    import dulwich.errors
    try:
        dulwich.repo.Repo(options.user_dir)
    except dulwich.errors.NotGitRepository:
        options.user_dir.mkdir(parents=True, exist_ok=True)
        dulwich.repo.Repo.init(options.user_dir)

    theme.set_dark_theme(options.dark_mode)

    from randovania.layout.preset_migration import VersionedPreset
    for old_preset in options.data_dir.joinpath("presets").glob(
            "*.randovania_preset"):
        old_preset.rename(
            old_preset.with_name(
                f"{old_preset.stem}.{VersionedPreset.file_extension()}"))

    logger.info("Loaded user preferences")

    return options
    def on_options_changed(self):
        self.menu_action_validate_seed_after.setChecked(
            self._options.advanced_validate_seed_after)
        self.menu_action_timeout_generation_after_a_time_limit.setChecked(
            self._options.advanced_timeout_during_generation)
        self.menu_action_dark_mode.setChecked(self._options.dark_mode)

        self.generate_seed_tab.on_options_changed(self._options)
        theme.set_dark_theme(self._options.dark_mode)
Exemple #3
0
def test_set_dark_theme_change(skip_qtbot, active, mocker):
    mock_load_stylesheet: MagicMock = mocker.patch(
        "qdarktheme.load_stylesheet", return_value="")

    app = MagicMock()
    app.palette.return_value = QtGui.QPalette()

    theme._current_dark_theme = not active
    theme.set_dark_theme(active, app=app)

    mock_load_stylesheet.assert_called_once_with(
        theme="dark" if active else "light")
    app.setStyleSheet.assert_called_once()
    app.setPalette.assert_called_once()
Exemple #4
0
def _load_options():
    from randovania.interface_common.options import Options
    from randovania.gui.lib import startup_tools, theme

    options = Options.with_default_data_dir()
    if not startup_tools.load_options_from_disk(options):
        raise SystemExit(1)

    theme.set_dark_theme(options.dark_mode)

    from randovania.layout.preset_migration import VersionedPreset
    for old_preset in options.data_dir.joinpath("presets").glob("*.randovania_preset"):
        old_preset.rename(old_preset.with_name(f"{old_preset.stem}.{VersionedPreset.file_extension()}"))

    return options
Exemple #5
0
def test_set_dark_theme_no_change(skip_qtbot):
    theme._current_dark_theme = False
    theme.set_dark_theme(False)
Exemple #6
0
def test_set_dark_theme(skip_qtbot, active):
    theme.set_dark_theme(active)