Compare commits

..
Author SHA1 Message Date
Boria138 4dce7c9683 chore(settings): move download options from appearance
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2026-05-14 20:40:38 +05:00
Boria138 cdeb74fd10 feat: added disable runtime download settings
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
2026-05-14 18:39:53 +05:00
28 changed files with 473 additions and 345 deletions

No files matched your search

-3
View File
@@ -30,7 +30,6 @@
- В настройки добавлена загрузка Wine/Proton в Steam `compatibilitytools.d`
### Changed
- Бейджи источников (Steam и PortProton) теперь отображаются при любом фильтре библиотеки
- Обложки к играм из Steam теперь полностью локальные
- Улучшен механизм кеширования данных
- Тип геймпада `Xbox` `PS` теперь выбирается автоматически
@@ -49,7 +48,6 @@
- Автоустановки теперь можно остановить
- Префиксы `DEFAULT`, `DOTNET` и `PROGRAMS` теперь всегда отображаются вверху списков префиксов
- Из лога удалена версия скриптов, так как скрипты теперь внутри PortProtonQt
- Из downloader удалена отдельная проверка сети через Yandex и Google
### Fixed
- Исправлено определение `PW_USE_RUNTIME` в debug-логе
@@ -67,7 +65,6 @@
- Исправлено управление геймпадом в диалоге выбора файла для загрузки PPDB
- Исправлен повторный вывод одинаковых Vulkan GPU в `vk_gpu_info`
- Исправлена работа клавиатурного управления при раскладке, отличной от английской
- Исправлена загрузка данных HowLongToBeat
### Contributors
- @Dervart
+1 -1
View File
@@ -57,7 +57,7 @@ PortProtonQt использует код и зависимости от след
- [Icoextract](https://github.com/jlu5/icoextract) — библиотека для извлечения иконок, лицензия [MIT](https://github.com/jlu5/icoextract/blob/master/LICENSE).
- [HowLongToBeat Python API](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI) — библиотека для взаимодействия с HowLongToBeat, лицензия [MIT](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI/blob/master/LICENSE.md).
- [iat](https://sourceforge.net/projects/iat.berlios) — библиотека для конвертации mdf в iso, лицензия GPLv3
- [mdf2iso](https://github.com/ScrappyCocco/HowLongToBeat-PythonAPI) — библиотека для конвертации mdf в iso, лицензия [GPLv2](https://salsa.debian.org/debian/mdf2iso/-/blob/master/gpl.txt).
Полный текст лицензий см. в файле [LICENSE](LICENSE).
> [!WARNING]
+1 -1
View File
@@ -88,7 +88,7 @@ EOM
# Disable locale noextract
sed -i -E 's@[[:space:]]*usr/share/locale/\*@@g; s@[[:space:]]+@ @g; s@[[:space:]]+$@@' /etc/pacman.conf
pacman -Syyu --noconfirm --disable-download-timeout
pacman -Syy
echo "Building PortProtonQt from PKGBUILD..."
echo "---------------------------------------------------------------"
+1 -2
View File
@@ -11,7 +11,6 @@ export DESKTOP=/usr/share/applications/ru.linux_gaming.PortProtonQt.desktop
export ICON=/usr/share/icons/hicolor/scalable/apps/ru.linux_gaming.PortProtonQt.svg
export OUTNAME=PortProtonQt-"$VERSION"-anylinux-"$ARCH".AppImage
export DEPLOY_OPENGL=1
export DEPLOY_SDL=1
export DEPLOY_SYS_PYTHON=1
export OPTIMIZE_LAUNCH=1
@@ -41,7 +40,7 @@ fi
/usr/lib/libQt6Core.so* \
/usr/lib/libQt6Gui.so* \
/usr/lib/libQt6Network.so* \
/usr/lib/qt6/plugins/imageformats/libqwebp.so
/usr/lib/libudev.so*
# Turn AppDir into AppImage
./quick-sharun --make-appimage
+1 -1
View File
@@ -6,7 +6,7 @@ arch=('any')
url="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt"
license=('GPL-3.0')
depends=('python-requests' 'python-babel' 'python-evdev' 'python-pygame' 'python-orjson'
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'jq' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' 'squashfs-tools' '7zip' 'python-dbus-fast')
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-beautifulsoup4' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'jq' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' 'squashfs-tools' '7zip' 'python-dbus-fast')
depends_aarch64=('muvm')
makedepends=('meson' 'ninja' 'vulkan-headers' 'gettext')
source=("git+https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt#tag=v$pkgver")
+2 -2
View File
@@ -6,7 +6,7 @@ arch=('any')
url="https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt"
license=('GPL-3.0')
depends=('python-requests' 'python-babel' 'python-evdev' 'python-pygame' 'python-orjson'
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'jq' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'qt6-imageformats' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' 'squashfs-tools' '7zip' 'python-dbus-fast')
'python-psutil' 'python-tqdm' 'python-vdf' 'python-libarchive-c' 'pyside6' 'python-rapidfuzz' 'python-pefile' 'python-pillow' 'perl-image-exiftool' 'python-beautifulsoup4' 'python-websocket-client' 'cabextract' 'unzip' 'curl' 'jq' 'file' 'findutils' 'gawk' 'grep' 'tar' 'xz' 'zstd' 'gzip' 'unrar' 'qt6-svg' 'pciutils' 'mesa-utils' 'vulkan-icd-loader' 'procps-ng' 'psmisc' 'squashfs-tools' '7zip' 'python-dbus-fast')
depends_aarch64=('muvm')
makedepends=('meson' 'ninja' 'vulkan-headers' 'gettext')
source=("git+https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt.git")
@@ -18,7 +18,7 @@ pkgver() {
}
build() {
arch-meson PortProtonQt build -Dnightly=true
arch-meson PortProtonQt build
meson compile -C build
}
+1 -4
View File
@@ -39,11 +39,11 @@ Requires: python3-tqdm
Requires: python3-vdf
Requires: python3-pefile
Requires: python3-pillow
Requires: python3-beautifulsoup4
Requires: python3-rapidfuzz
Requires: python3-libarchive-c
Requires: perl-Image-ExifTool
Requires: qt6-qtsvg
Requires: qt6-qtimageformats
Requires: cabextract
Requires: gzip
Requires: unzip
@@ -97,7 +97,6 @@ git clone https://git.linux-gaming.ru/Linux-Gaming/PortProtonQt.git
%build
cd %{oname}
%meson \
-Dnightly=true \
-Dpython_purelibdir=%{python3_sitelib} \
-Dudev_rulesdir=%{_udevrulesdir}
%meson_build
@@ -121,8 +120,6 @@ install -Dpm 0644 ./completions/_portprotonqt -t %{buildroot}%{zsh_completions_d
%{_datadir}/polkit-1/rules.d/ru.linux_gaming.PortProtonQt.rules
%{_datadir}/applications/ru.linux_gaming.PortProtonQt.desktop
%{_datadir}/portproton/scripts/
%{_datadir}/portproton/conf/
%{_datadir}/portproton/img/
%{bash_completions_dir}/portprotonqt
%{fish_completions_dir}/portprotonqt.fish
%{zsh_completions_dir}/_portprotonqt
+1 -3
View File
@@ -36,11 +36,11 @@ Requires: python3-tqdm
Requires: python3-vdf
Requires: python3-pefile
Requires: python3-pillow
Requires: python3-beautifulsoup4
Requires: python3-rapidfuzz
Requires: python3-libarchive-c
Requires: perl-Image-ExifTool
Requires: qt6-qtsvg
Requires: qt6-qtimageformats
Requires: cabextract
Requires: gzip
Requires: unzip
@@ -119,8 +119,6 @@ install -Dpm 0644 ./completions/_portprotonqt -t %{buildroot}%{zsh_completions_d
%{_datadir}/polkit-1/rules.d/ru.linux_gaming.PortProtonQt.rules
%{_datadir}/applications/ru.linux_gaming.PortProtonQt.desktop
%{_datadir}/portproton/scripts/
%{_datadir}/portproton/conf/
%{_datadir}/portproton/img/
%{bash_completions_dir}/portprotonqt
%{fish_completions_dir}/portprotonqt.fish
%{zsh_completions_dir}/_portprotonqt
@@ -1282,7 +1282,11 @@ init_wine_ver () {
}
pw_init_runtime () {
check_flatpak && export PW_USE_RUNTIME="0"
if [[ ! -f "${PW_WINELIB}/runtime/files/bin/vkcube" ]] \
|| [[ ! -f "${PW_WINELIB}/pressure-vessel/bin/pressure-vessel-wrap" ]]
then
export PW_USE_RUNTIME="0"
fi
if [[ "$PW_USE_RUNTIME" != "1" ]] \
|| [[ "$PW_WINE_USE" == "USE_SYSTEM_WINE" ]]
then
@@ -2515,7 +2519,7 @@ pw_enable_gamemode_basic () {
start_portproton () {
pw_check_and_download_plugins
if check_flatpak ; then
if [[ "${PW_DISABLE_RUNTIME_DOWNLOAD}" == "1" ]] ; then
try_remove_dir "${PORT_WINE_TMP_PATH}/libs${PW_LIBS_VER}"
else
pw_check_and_download_runtime
@@ -4103,7 +4107,12 @@ gui_edit_db () {
if [[ $PW_WINE_USE =~ (PROTON_LG|WINE_LG) ]] || [[ $PW_VULKAN_USE == "0" ]] ; then
DISABLE_EDIT_DB_LIST+=" PW_USE_SUPPLIED_DXVK_VKD3D"
fi
check_flatpak && DISABLE_EDIT_DB_LIST+=" PW_USE_RUNTIME"
if [[ ! -f "${PW_WINELIB}/runtime/files/bin/vkcube" ]] \
|| [[ ! -f "${PW_WINELIB}/pressure-vessel/bin/pressure-vessel-wrap" ]]
then
DISABLE_EDIT_DB_LIST+=" PW_USE_RUNTIME"
fi
# GALLIUM NINE
[[ ! -f "${PW_TMPFS_PATH}/gallium_nine.tmp" ]] && DISABLE_EDIT_DB_LIST+=" PW_USE_GALLIUM_NINE"
@@ -37,6 +37,11 @@ if [[ -z "$PORT_DATA_PATH" ]] ; then
fi
fi
if [[ -f "$HOME/.config/PortProtonQt.conf" ]] \
&& grep "disable_runtime_download = True" "$HOME/.config/PortProtonQt.conf" ; then
export PW_DISABLE_RUNTIME_DOWNLOAD=1
fi
export PORT_SCRIPTS_PATH PORT_IMG_PATH PORT_DATA_PATH PORT_CONF_PATH
export PW_LOG_FILE="${PORT_DATA_PATH}/PortProton.log"
+2 -2
View File
@@ -87,12 +87,12 @@ def bump_meson(path: Path, old: str, new: str) -> bool:
def bump_app_py(path: Path, old: str, new: str) -> bool:
"""
Update APP_VERSION fallback in app.py
Update __app_version__ in app.py
"""
if not path.exists():
return False
text = path.read_text(encoding='utf-8')
pattern = re.compile(r"(?m)^(\s*APP_VERSION\s*=\s*)\"" + re.escape(old) + r"\"$")
pattern = re.compile(r"(?m)^(\s*__app_version__\s*=\s*)\"" + re.escape(old) + r"\"$")
new_text, count = pattern.subn(lambda m: m.group(1) + f'"{new}"', text)
if count:
path.write_text(new_text, encoding='utf-8')
+1 -2
View File
@@ -679,8 +679,7 @@ def get_files_from_meson_build(meson_file_path):
'install_headers', # Header files installation
'install_man', # Manual pages installation
'install_symlink', # Symlinks installation
'install_emptydir', # Empty directories installation
'configure_file', # Files generated and potentially installed
'install_emptydir' # Empty directories installation
]
# Process each install function
-25
View File
@@ -12,20 +12,6 @@ python3 = import('python').find_installation('python3')
conf = configuration_data()
conf.set('PYTHON', python3.full_path())
version_conf = configuration_data()
version_conf.set_quoted('APP_VERSION', meson.project_version())
version_conf.set_quoted('APP_COMMIT', '')
if get_option('nightly')
git = find_program('git', required: false)
if git.found()
git_commit = run_command(git, 'rev-parse', '--short', 'HEAD', check: false)
if git_commit.returncode() == 0
version_conf.set_quoted('APP_COMMIT', git_commit.stdout().strip())
endif
endif
endif
# Directories
prefix = get_option('prefix')
datadir = prefix / get_option('datadir')
@@ -39,17 +25,6 @@ pkgdatadir = pythondir / meson.project_name()
# C compiler for vk_gpu_info
cc = meson.get_compiler('c')
configured_version = configure_file(
input: 'portprotonqt/_version.py.in',
output: '_version.py',
configuration: version_conf,
)
install_data(
configured_version,
install_dir: pythondir / meson.project_name(),
)
# Install Python package
subdir('portprotonqt')
-1
View File
@@ -2,4 +2,3 @@
option('python_purelibdir', type: 'string', value: '', description: 'Python pure library installation directory (overrides purelib)')
option('udev_rulesdir', type: 'string', value: '', description: 'Udev rules installation directory (overrides default)')
option('nightly', type: 'boolean', value: false, description: 'Include git commit in application version')
-2
View File
@@ -1,2 +0,0 @@
APP_VERSION = @APP_VERSION@
APP_COMMIT = @APP_COMMIT@
+2 -14
View File
@@ -1,22 +1,12 @@
import sys
import os
import importlib
import subprocess
import shutil
from logging import Logger
__app_id__ = "ru.linux_gaming.PortProtonQt"
__app_name__ = "PortProtonQt"
try:
version_module = importlib.import_module("portprotonqt._version")
APP_COMMIT = version_module.APP_COMMIT
APP_VERSION = version_module.APP_VERSION
except ImportError:
APP_COMMIT = ""
APP_VERSION = "0.1.12"
__app_version__ = APP_VERSION
__app_version__ = "0.1.12"
from PySide6.QtCore import QTimer
from PySide6.QtWidgets import QApplication, QMenu, QSystemTrayIcon
@@ -46,9 +36,6 @@ from portprotonqt.cli import (
from portprotonqt.localization import _, get_steam_language
def get_version():
if APP_COMMIT:
return f"{__app_version__} ({APP_COMMIT})"
try:
commit = subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"],
@@ -169,6 +156,7 @@ def main():
portproton_location = get_portproton_location()
if portproton_location:
os.environ["PORT_DATA_PATH"] = portproton_location
ui_config.get_disable_runtime_download()
# Check if running as Steam compatibility tool (STEAM_COMPAT=1).
is_steam_compat = os.environ.get("STEAM_COMPAT") == "1"
+48 -4
View File
@@ -11,6 +11,7 @@ from portprotonqt.logger import get_logger
logger = get_logger(__name__)
THEME_VARIANTS = ("dark", "light", "auto")
DOWNLOADS_SECTION = "Downloads"
def _get_theme_base_name(theme_name: str) -> str:
@@ -244,21 +245,64 @@ class UIConfig(BaseConfig):
def get_economy_mode(self) -> bool:
"""Get economy mode setting."""
return self._get_bool("economy_mode", False)
return self._get_download_bool("economy_mode", False)
def set_economy_mode(self, enabled: bool):
"""Set economy mode setting."""
validate_bool(enabled, "economy_mode")
self._save_value("economy_mode", enabled, "bool")
self._save_download_value("economy_mode", enabled)
def _get_download_bool(self, option: str, default: bool) -> bool:
cp = self._read_config()
if cp is None:
return self._save_download_value(option, default)
try:
if cp.has_option(DOWNLOADS_SECTION, option):
return cp.getboolean(DOWNLOADS_SECTION, option, fallback=default)
if cp.has_option(self._section, option):
return cp.getboolean(self._section, option, fallback=default)
except ValueError as e:
logger.warning("Error reading %s: %s", option, e)
return self._save_download_value(option, default)
except configparser.Error as e:
logger.warning("Error reading %s: %s", option, e)
return self._save_download_value(option, default)
return self._save_download_value(option, default)
def _save_download_value(self, option: str, value: bool) -> bool:
validate_bool(value, option)
cp = self._read_config() or configparser.ConfigParser()
if DOWNLOADS_SECTION not in cp:
cp[DOWNLOADS_SECTION] = {}
cp[DOWNLOADS_SECTION][option] = str(value)
if cp.has_section(self._section):
cp.remove_option(self._section, option)
self._save_config(cp)
return value
def get_download_wine_to_steam(self) -> bool:
"""Get Steam compatibility tools download setting."""
return self._get_bool("download_wine_to_steam", False)
return self._get_download_bool("download_wine_to_steam", False)
def set_download_wine_to_steam(self, enabled: bool) -> None:
"""Set Steam compatibility tools download setting."""
validate_bool(enabled, "download_wine_to_steam")
self._save_value("download_wine_to_steam", enabled, "bool")
self._save_download_value("download_wine_to_steam", enabled)
def get_disable_runtime_download(self) -> bool:
"""Get PortProton runtime download setting."""
default = bool(os.getenv("FLATPAK_ID"))
return self._get_download_bool("disable_runtime_download", default)
def set_disable_runtime_download(self, enabled: bool) -> None:
"""Set PortProton runtime download setting."""
if os.getenv("FLATPAK_ID"):
enabled = True
validate_bool(enabled, "disable_runtime_download")
self._save_download_value("disable_runtime_download", enabled)
def load_theme_metainfo(theme_name: str) -> dict:
+4 -16
View File
@@ -21,7 +21,6 @@ from portprotonqt.detail_pages.widgets import (
create_back_button,
create_content_frame,
setup_adaptive_layout,
apply_adaptive_layout,
create_cover_frame,
create_protondb_badge,
create_steam_badge,
@@ -196,17 +195,19 @@ class DetailPageManager:
return size, size
def _create_game_badges(self, parent: QWidget, game_data: dict) -> list:
from portprotonqt.config import game_config
if self._is_compact_detail_layout():
return []
display_filter = game_config.get_display_filter()
game_source = str(game_data.get("game_source", "")).lower()
appid = game_data.get("appid", "")
name = game_data.get("name", "")
exec_line = game_data.get("exec_line", "")
steam_visible = game_source == "steam"
portproton_visible = game_source == "portproton"
steam_visible = game_source == "steam" and display_filter in ("all", "favorites")
portproton_visible = game_source == "portproton" and display_filter in ("all", "favorites")
badges = []
protondb_badge = self._create_protondb_badge(parent, game_data)
@@ -322,19 +323,6 @@ class DetailPageManager:
if has_data:
game_info_layout.addLayout(hltb_layout)
QTimer.singleShot(0, self._refresh_current_detail_page_layout)
def _refresh_current_detail_page_layout(self) -> None:
"""Refresh layout after asynchronous detail content changes."""
if not self._detail_page_active or not self._current_detail_page:
return
content_frame_layout = self._get_content_frame_layout(self._current_detail_page)
if content_frame_layout:
content_frame_layout.invalidate()
apply_adaptive_layout(self._current_detail_page, content_frame_layout)
self._current_detail_page.updateGeometry()
def _add_hltb_times(
self, game: GameEntry, hltb: HowLongToBeat, hltb_layout: QHBoxLayout
+19 -22
View File
@@ -107,33 +107,30 @@ def setup_adaptive_layout(
"""Setup adaptive layout switching on resize."""
def on_detail_page_resize(event) -> None:
apply_adaptive_layout(detail_page, content_frame_layout)
if detail_page.property("force_compact_detail_layout"):
content_frame_layout.setDirection(QBoxLayout.Direction.TopToBottom)
content_frame_layout.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
)
QWidget.resizeEvent(detail_page, event)
return
required_width = _get_required_horizontal_width(content_frame_layout)
if detail_page.width() < required_width:
if content_frame_layout.direction() != QBoxLayout.Direction.TopToBottom:
content_frame_layout.setDirection(QBoxLayout.Direction.TopToBottom)
content_frame_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
else:
if content_frame_layout.direction() != QBoxLayout.Direction.LeftToRight:
content_frame_layout.setDirection(QBoxLayout.Direction.LeftToRight)
content_frame_layout.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
)
QWidget.resizeEvent(detail_page, event)
detail_page.resizeEvent = on_detail_page_resize
def apply_adaptive_layout(detail_page: QWidget, content_frame_layout: QBoxLayout) -> None:
"""Apply detail page adaptive layout for current size hints."""
if detail_page.property("force_compact_detail_layout"):
content_frame_layout.setDirection(QBoxLayout.Direction.TopToBottom)
content_frame_layout.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
)
return
required_width = _get_required_horizontal_width(content_frame_layout)
if detail_page.width() < required_width:
if content_frame_layout.direction() != QBoxLayout.Direction.TopToBottom:
content_frame_layout.setDirection(QBoxLayout.Direction.TopToBottom)
content_frame_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
elif content_frame_layout.direction() != QBoxLayout.Direction.LeftToRight:
content_frame_layout.setDirection(QBoxLayout.Direction.LeftToRight)
content_frame_layout.setAlignment(
Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop
)
def _get_required_horizontal_width(content_frame_layout: QBoxLayout) -> int:
"""Calculate minimal width for horizontal content layout."""
item_count = content_frame_layout.count()
+5 -5
View File
@@ -94,15 +94,15 @@ class WinetricksDialog(DraggableDialog):
def update_winetricks(self):
"""Update the winetricks script."""
if not self.downloader.has_internet():
logger.warning("No internet connection, skipping winetricks update")
return
url = "https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks"
temp_path = os.path.join(self.tmp_path, "winetricks_temp")
try:
if not self.downloader.download(url, temp_path):
logger.warning("Failed to download external winetricks version")
if os.path.exists(temp_path):
os.remove(temp_path)
return
self.downloader.download(url, temp_path)
with open(temp_path) as f:
ext_content = f.read()
ext_ver_match = re.search(r'WINETRICKS_VERSION\s*=\s*[\'"]?([^\'"\s]+)', ext_content)
+46 -123
View File
@@ -5,7 +5,6 @@ import stat
import subprocess
import tempfile
import shlex
from typing import BinaryIO
from portprotonqt.logger import get_logger
logger = get_logger(__name__)
@@ -13,14 +12,6 @@ logger = get_logger(__name__)
SYNC_HEADER = b'\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00'
SYNC_HEADER_MDF = b'\x80\xc0\x80\x80\x80\x80\x80\xc0\x80\x80\x80\x80'
ISO_9660_SIG = b'\x01\x43\x44\x30\x30\x31\x01\x00'
DISC_BLOCK_SIZES = (2048, 2336, 2352, 2368, 2448)
SVCD_SUB_HEADERS = (
b"\x00\x00\x08\x00\x00\x00\x08\x00",
b"\x00\x00\x09\x00\x00\x00\x09\x00",
b"\x00\x00\x88\x00\x00\x00\x88\x00",
b"\x00\x00\x89\x00\x00\x00\x89\x00",
)
UDF_SIGNATURES = (b"BEA01", b"BOOT2", b"CD001", b"CDW02", b"NSR02", b"NSR03", b"TEA01")
class DiscImageManager:
@@ -61,126 +52,58 @@ class DiscImageManager:
logger.error("Failed to read ISO 9660 signature for %s: %s", file_path, e)
return False
def _is_svcd_sub_header(self, header: bytes) -> bool:
"""Return True if header matches known SVCD subheader bytes."""
return header[:8] in SVCD_SUB_HEADERS
def _calculate_disc_layout(self, source: BinaryIO) -> tuple[int, int]:
"""Return pregap and block size using the iat detection rules."""
source.seek(0, os.SEEK_END)
image_size = source.tell()
cd_id_start = -1
cd_id_end = 0
header_size = 0
for offset in range(32768, image_size):
source.seek(offset)
header = source.read(12)
if header == SYNC_HEADER:
header_size = self._add_header_size(header_size, 16)
continue
if self._is_svcd_sub_header(header):
header_size = self._add_header_size(header_size, 8)
continue
if header[:5] in UDF_SIGNATURES:
if cd_id_start < 0:
cd_id_start = offset
else:
cd_id_end = offset
break
if cd_id_start < 0 or cd_id_end <= cd_id_start:
return self._detect_sector_layout(source)
block_size = self._calculate_block_size(cd_id_end - cd_id_start)
pregap = cd_id_start - (block_size * 16) - header_size - 1
return max(pregap, 0), block_size
def _add_header_size(self, header_size: int, value: int) -> int:
"""Add a detected header size once, matching iat's mixed header logic."""
if header_size in (value, 24):
return header_size
return header_size + value
def _calculate_block_size(self, block_delta: int) -> int:
"""Return closest iat-supported block size for descriptor spacing."""
for block_size in DISC_BLOCK_SIZES[:-1]:
if block_delta % block_size == 0:
return block_size
return DISC_BLOCK_SIZES[-1]
def _detect_sector_layout(self, source: BinaryIO) -> tuple[int, int]:
"""Fallback sector layout detection for images without two descriptors."""
source.seek(0)
h0 = source.read(12)
source.seek(2352)
h2352 = source.read(12)
if h0 == SYNC_HEADER and h2352 == SYNC_HEADER_MDF:
return 0, 2448
if h0 == SYNC_HEADER:
return 0, 2352
return 0, 2352
def _write_sync_sector_data(self, target: BinaryIO, sector: bytes) -> None:
"""Write ISO user data from a sector with a sync header."""
mode = sector[15]
if mode == 0:
target.write(sector[16:2352])
elif mode == 1:
target.write(sector[16:2064])
elif mode == 2:
self._write_mode_two_sector_data(target, sector)
else:
raise ValueError(f"Unknown MDF sector mode {mode}")
def _write_mode_two_sector_data(self, target: BinaryIO, sector: bytes) -> None:
"""Write ISO user data from a Mode 2 sector."""
sub_header = sector[16:24]
if sub_header[:4] != sub_header[4:8]:
target.write(sector[16:2352])
return
if sub_header[2] & 0x20:
target.write(sector[24:2348])
return
target.write(sector[24:2072])
def _write_headerless_sector_data(self, target: BinaryIO, sector: bytes) -> bool:
"""Write ISO user data from a 2336-byte headerless sector."""
sub_header = sector[:8]
if sub_header[:4] != sub_header[4:8]:
return False
if self._is_svcd_sub_header(sub_header):
target.write(sector[8:2332])
else:
target.write(sector[8:2056])
return True
def _write_iso_from_mdf(self, mdf_path: str, iso_path: str) -> None:
"""Convert MDF to ISO using iat-compatible sector extraction."""
"""Convert MDF to ISO using logic from test.py or legacy fallback."""
with open(mdf_path, "rb") as source:
source.seek(0)
h0 = source.read(12)
source.seek(2352)
h2352 = source.read(12)
if h0 == SYNC_HEADER:
if h2352 == SYNC_HEADER_MDF:
sector_size = 2448
elif h2352 == SYNC_HEADER:
sector_size = 2352
else:
raise ValueError(f"Unknown SYNC format for {mdf_path}")
source.seek(0, os.SEEK_END)
num_sectors = source.tell() // sector_size
source.seek(0)
with open(iso_path, "wb") as target:
for _ in range(num_sectors):
sector_start = source.tell()
header = source.read(16)
if len(header) < 16:
break
mode = header[15]
data_offset = 24 if mode == 2 else 16
source.seek(sector_start + data_offset)
data = source.read(2048)
if len(data) < 2048:
break
target.write(data)
source.seek(sector_start + sector_size)
return
# Legacy fallback
with open(mdf_path, "rb") as source, open(iso_path, "wb") as target:
pregap, block_size = self._calculate_disc_layout(source)
image_size = os.path.getsize(mdf_path)
source.seek(pregap)
sector_index = pregap
while sector_index < image_size:
sector = source.read(block_size)
sector_index = 0
while True:
sector = source.read(2352)
if not sector:
return
if len(sector) != block_size:
if len(sector) != 2352:
raise ValueError(f"Truncated MDF sector at {sector_index}")
if sector.startswith(SYNC_HEADER):
self._write_sync_sector_data(target, sector)
elif block_size == 2336 and not self._write_headerless_sector_data(target, sector):
sector_index += 1
source.seek(sector_index)
continue
elif block_size == 2048:
target.write(sector)
mode = sector[15]
if mode == 1:
target.write(sector[16:2064])
elif mode == 2:
target.write(sector[24:2072])
else:
sector_index += 1
source.seek(sector_index)
continue
sector_index += block_size
raise ValueError(f"Unknown MDF sector mode {mode} at {sector_index}")
sector_index += 1
def _convert_mdf_to_iso(self, mdf_path: str) -> str | None:
"""Convert raw 2352-byte sector MDF to temporary ISO."""
+54
View File
@@ -2,6 +2,7 @@ from PySide6.QtCore import QObject, Signal, QThread
import threading
import os
import requests
import socket
from pathlib import Path
from tqdm import tqdm
from collections.abc import Callable
@@ -64,12 +65,54 @@ class Downloader(QObject):
self._locks = {}
self._active_threads: list[QThread] = []
self._global_lock = threading.Lock()
self._has_internet = None
self.callback_requested.connect(self._run_callback)
def _run_callback(self, callback, result):
if callback:
callback(result)
def has_internet(self, timeout=3):
if self._has_internet is None:
errors = []
# Primary: Yandex
try:
socket.create_connection(("77.88.8.8", 53), timeout=timeout)
except Exception as e:
errors.append(f"Yandex DNS (77.88.8.8): {e}")
try:
socket.create_connection(("77.88.8.1", 53), timeout=timeout)
except Exception as e:
errors.append(f"Yandex DNS (77.88.8.1): {e}")
try:
requests.get("https://ya.ru", timeout=timeout)
except Exception as e:
errors.append(f"ya.ru: {e}")
# Fallback: Google (if Yandex failed)
if errors:
logger.debug("Yandex check failed, trying Google fallback")
try:
socket.create_connection(("8.8.8.8", 53), timeout=timeout)
except Exception as e:
errors.append(f"Google DNS (8.8.8.8): {e}")
try:
socket.create_connection(("8.8.4.4", 53), timeout=timeout)
except Exception as e:
errors.append(f"Google DNS (8.8.4.4): {e}")
try:
requests.get("https://www.google.com", timeout=timeout)
except Exception as e:
errors.append(f"google.com: {e}")
if errors:
logger.warning("Internet unavailable:\n" + "\n".join(errors))
self._has_internet = False
else:
self._has_internet = True
return self._has_internet
def _get_url_lock(self, url):
with self._global_lock:
if url not in self._locks:
@@ -176,6 +219,9 @@ class Downloader(QObject):
return results
def download(self, url, local_path, timeout=5):
if not self.has_internet():
logger.warning(f"No internet, skipping download {url}")
return None
with self._global_lock:
if url in self._last_error:
logger.warning(f"Previous download error for {url}, skipping")
@@ -213,6 +259,14 @@ class Downloader(QObject):
max_workers=None,
on_result: Callable[[str, str | None], None] | None = None,
):
if not self.has_internet():
logger.warning("No internet, skipping parallel download")
results = dict.fromkeys(urls)
if on_result:
for url, result in results.items():
on_result(url, result)
return results
filtered_urls = []
filtered_paths = []
emitted_urls = set()
+4 -4
View File
@@ -89,8 +89,8 @@ class GameCard(QFrame):
self.portproton_api = PortProtonAPI(self.downloader)
self.missing_executable_path = self._get_missing_executable_path()
self.steam_visible = (str(game_source).lower() == "steam" and not self.economy_mode)
self.portproton_visible = (str(game_source).lower() == "portproton" and not self.economy_mode)
self.steam_visible = (str(game_source).lower() == "steam" and self.display_filter in ("all", "favorites") and not self.economy_mode)
self.portproton_visible = (str(game_source).lower() == "portproton" and self.display_filter in ("all", "favorites") and not self.economy_mode)
self.base_extra_margin = 8 if self.list_layout else 20
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
@@ -486,8 +486,8 @@ class GameCard(QFrame):
self.display_filter = display_filter
self.economy_mode = ui_config.get_economy_mode()
self.steam_visible = (str(self.game_source).lower() == "steam" and not self.economy_mode)
self.portproton_visible = (str(self.game_source).lower() == "portproton" and not self.economy_mode)
self.steam_visible = (str(self.game_source).lower() == "steam" and self.display_filter in ("all", "favorites") and not self.economy_mode)
self.portproton_visible = (str(self.game_source).lower() == "portproton" and self.display_filter in ("all", "favorites") and not self.economy_mode)
protondb_visible = bool(self.getProtonDBText(self.protondb_tier)) and not self.economy_mode
anticheat_visible = bool(self.getAntiCheatText(self.anticheat_status)) and not self.economy_mode
+181 -56
View File
@@ -1,9 +1,11 @@
import orjson
import time
from dataclasses import dataclass
import re
from dataclasses import dataclass, field
from typing import Any
from difflib import SequenceMatcher
from threading import Thread
import requests
from bs4 import BeautifulSoup, Tag
from portprotonqt.config import proxy_config
from portprotonqt.time_utils import format_playtime
from portprotonqt.logger import get_logger
@@ -15,22 +17,66 @@ logger = get_logger(__name__)
@dataclass
class GameEntry:
"""Game information from HowLongToBeat."""
game_id: int = -1
game_name: str | None = None
main_story: float | None = None
main_extra: float | None = None
completionist: float | None = None
similarity: float = -1.0
raw_data: dict[str, Any] = field(default_factory=dict)
@dataclass
class SearchConfig:
"""Search configuration."""
token: str
hp_key: str
hp_val: str
api_key: str | None = None
search_url: str | None = None
class APIKeyExtractor:
"""Extract API key and search URL from site scripts."""
@staticmethod
def extract_from_script(script_content: str) -> SearchConfig:
config = SearchConfig()
config.api_key = APIKeyExtractor._extract_api_key(script_content)
config.search_url = APIKeyExtractor._extract_search_url(script_content, config.api_key)
return config
@staticmethod
def _extract_api_key(script_content: str) -> str | None:
user_id_pattern = r'users\s*:\s*{\s*id\s*:\s*"([^"]+)"'
matches = re.findall(user_id_pattern, script_content)
if matches:
return ''.join(matches)
concat_pattern = r'\/api\/\w+\/"(?:\.concat\("[^"]*"\))+'
matches = re.findall(concat_pattern, script_content)
if matches:
parts = str(matches).split('.concat')
cleaned_parts = [re.sub(r'["\(\)\[\]\']', '', part) for part in parts[1:]]
return ''.join(cleaned_parts)
return None
@staticmethod
def _extract_search_url(script_content: str, api_key: str | None) -> str | None:
if not api_key:
return None
pattern = re.compile(
r'fetch\(\s*["\'](\/api\/[^"\']*)["\']'
r'((?:\s*\.concat\(\s*["\']([^"\']*)["\']\s*\))+)'
r'\s*,',
re.DOTALL
)
for match in pattern.finditer(script_content):
endpoint = match.group(1)
concat_calls = match.group(2)
concat_strings = re.findall(r'\.concat\(\s*["\']([^"\']*)["\']\s*\)', concat_calls)
concatenated_str = ''.join(concat_strings)
if concatenated_str == api_key:
return endpoint
return None
class HTTPClient:
"""HTTP client for HowLongToBeat API."""
BASE_URL = 'https://howlongtobeat.com/'
AUTH_URL = BASE_URL + "api/bleed/init"
SEARCH_URL = BASE_URL + "api/bleed"
SEARCH_URL = BASE_URL + "api/s/"
def __init__(self, timeout: int = 60):
self.timeout = timeout
@@ -43,55 +89,67 @@ class HTTPClient:
if proxy_settings:
self.session.proxies.update(proxy_settings)
def get_search_config(self) -> SearchConfig | None:
def get_search_config(self, parse_all_scripts: bool = False) -> SearchConfig | None:
try:
response = self.session.get(
self.AUTH_URL,
params={"t": int(time.time() * 1000)},
timeout=self.timeout
)
response = self.session.get(self.BASE_URL, timeout=self.timeout)
response.raise_for_status()
data = response.json()
except (requests.RequestException, ValueError):
return None
if not data.get("token") or not data.get("hpKey") or not data.get("hpVal"):
return None
return SearchConfig(
token=data["token"],
hp_key=data["hpKey"],
hp_val=data["hpVal"]
)
soup = BeautifulSoup(response.text, 'html.parser')
scripts = soup.find_all('script', src=True)
script_urls = []
for script in scripts:
if isinstance(script, Tag):
src = script.get('src')
if src is not None and isinstance(src, str):
if parse_all_scripts or '_app-' in src:
script_urls.append(src)
for script_url in script_urls:
full_url = self.BASE_URL + script_url
script_response = self.session.get(full_url, timeout=self.timeout)
if script_response.status_code == 200:
config = APIKeyExtractor.extract_from_script(script_response.text)
if config.api_key:
return config
except requests.RequestException:
pass
return None
def search_games(self, game_name: str, page: int = 1, config: SearchConfig | None = None) -> str | None:
if not config:
config = self.get_search_config()
if not config:
if not config:
config = self.get_search_config(parse_all_scripts=True)
if not config or not config.api_key:
return None
for retry in range(2):
payload = self._build_search_payload(game_name, page, config)
headers = {
'content-type': 'application/json',
'accept': '*/*',
'x-auth-token': config.token,
'x-hp-key': config.hp_key,
'x-hp-val': config.hp_val
}
try:
response = self.session.post(
self.SEARCH_URL,
headers=headers,
data=orjson.dumps(payload),
timeout=self.timeout
)
except requests.RequestException:
return None
search_url = self.SEARCH_URL
if config.search_url:
search_url = self.BASE_URL + config.search_url.lstrip('/')
payload = self._build_search_payload(game_name, page, config)
headers = {
'content-type': 'application/json',
'accept': '*/*'
}
try:
response = self.session.post(
search_url + config.api_key,
headers=headers,
data=orjson.dumps(payload),
timeout=self.timeout
)
if response.status_code == 200:
return response.text
if response.status_code != 403 or retry:
return None
config = self.get_search_config()
if not config:
return None
except requests.RequestException:
pass
try:
response = self.session.post(
search_url,
headers=headers,
data=orjson.dumps(payload),
timeout=self.timeout
)
if response.status_code == 200:
return response.text
except requests.RequestException:
pass
return None
def _build_search_payload(self, game_name: str, page: int, config: SearchConfig) -> dict[str, Any]:
@@ -113,7 +171,8 @@ class HTTPClient:
'genre': "",
"difficulty": ""
},
'rangeYear': {'max': "", 'min': ""}
'rangeYear': {'max': "", 'min': ""},
'modifier': "" # Hardcoded to empty string for SearchModifiers.NONE
},
'users': {'sortCategory': "postcount"},
'lists': {'sortCategory': "follows"},
@@ -122,26 +181,42 @@ class HTTPClient:
'randomizer': 0
},
'useCache': True,
'fields': ["comp_main", "comp_plus", "comp_100"]
'fields': ["game_id", "game_name", "comp_main", "comp_plus", "comp_100"] # Request only needed fields
}
payload[config.hp_key] = config.hp_val
if config.api_key:
payload['searchOptions']['users']['id'] = config.api_key
return payload
class ResultParser:
"""Search results parser."""
def parse_results(self, json_response: str) -> list[GameEntry]:
def __init__(self, search_query: str, minimum_similarity: float = 0.4, case_sensitive: bool = True):
self.search_query = search_query
self.minimum_similarity = minimum_similarity
self.case_sensitive = case_sensitive
self.search_numbers = self._extract_numbers(search_query)
def parse_results(self, json_response: str, target_game_id: int | None = None) -> list[GameEntry]:
try:
data = orjson.loads(json_response)
games = []
# Only process the first result
if data.get("data"):
game_data = data["data"][0]
games.append(self._parse_game_entry(game_data))
game = self._parse_game_entry(game_data)
if target_game_id is not None:
if game.game_id == target_game_id:
games.append(game)
elif self.minimum_similarity == 0.0 or game.similarity >= self.minimum_similarity:
games.append(game)
return games
except (orjson.JSONDecodeError, KeyError, IndexError):
return []
def _parse_game_entry(self, game_data: dict[str, Any]) -> GameEntry:
game = GameEntry()
game.game_id = game_data.get("game_id", -1)
game.game_name = game_data.get("game_name")
game.raw_data = game_data
time_fields = [
("comp_main", "main_story"),
("comp_plus", "main_extra"),
@@ -153,8 +228,35 @@ class ResultParser:
time_seconds = game_data[json_field]
time_hours = None if all_zero else round(time_seconds / 3600, 2)
setattr(game, attr_name, time_hours)
game.similarity = self._calculate_similarity(game)
return game
def _calculate_similarity(self, game: GameEntry) -> float:
return self._compare_strings(self.search_query, game.game_name)
def _compare_strings(self, a: str | None, b: str | None) -> float:
if not a or not b:
return 0.0
if self.case_sensitive:
similarity = SequenceMatcher(None, a, b).ratio()
else:
similarity = SequenceMatcher(None, a.lower(), b.lower()).ratio()
if self.search_numbers and not self._contains_numbers(b, self.search_numbers):
similarity -= 0.1
return max(0.0, similarity)
@staticmethod
def _extract_numbers(text: str) -> list[str]:
return [word for word in text.split() if word.isdigit()]
@staticmethod
def _contains_numbers(text: str, numbers: list[str]) -> bool:
if not numbers:
return True
cleaned_text = re.sub(r'([^\s\w]|_)+', '', text)
text_numbers = [word for word in cleaned_text.split() if word.isdigit()]
return any(num in text_numbers for num in numbers)
class HowLongToBeat(QObject):
"""Main class for HowLongToBeat API."""
@@ -171,13 +273,15 @@ class HowLongToBeat(QObject):
return self.cache_manager.load_text(f"hltb_{game_name}")
def _save_to_cache(self, game_name: str, json_response: str):
"""Save data to cache, storing only first game times."""
"""Save data to cache, storing only first game and required fields."""
try:
data = orjson.loads(json_response)
if data.get("data"):
first_game = data["data"][0]
simplified_data = {
"data": [{
"game_id": first_game.get("game_id", -1),
"game_name": first_game.get("game_name"),
"comp_main": first_game.get("comp_main", 0),
"comp_plus": first_game.get("comp_plus", 0),
"comp_100": first_game.get("comp_100", 0)
@@ -194,8 +298,25 @@ class HowLongToBeat(QObject):
cached_response = self._load_from_cache(game_name)
if cached_response:
try:
parser = ResultParser()
return parser.parse_results(cached_response)
cached_data = orjson.loads(cached_response)
full_json = {
"data": [
{
"game_id": game["game_id"],
"game_name": game["game_name"],
"comp_main": game["comp_main"],
"comp_plus": game["comp_plus"],
"comp_100": game["comp_100"]
}
for game in cached_data.get("data", [])
]
}
parser = ResultParser(
game_name,
self.minimum_similarity,
case_sensitive
)
return parser.parse_results(orjson.dumps(full_json).decode('utf-8'))
except orjson.JSONDecodeError:
pass
# If not in cache, make request
@@ -204,7 +325,11 @@ class HowLongToBeat(QObject):
return None
# Save only first game to cache
self._save_to_cache(game_name, json_response)
parser = ResultParser()
parser = ResultParser(
game_name,
self.minimum_similarity,
case_sensitive
)
return parser.parse_results(json_response)
def format_game_time(self, game_entry: GameEntry, time_field: str = "main_story") -> str | None:
+38 -5
View File
@@ -2364,6 +2364,23 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
hide_autoinstall_layout.addStretch()
uiForm.addRow(hide_autoinstall_layout)
disable_runtime_download_layout = None
if not os.getenv("FLATPAK_ID"):
self.disableRuntimeDownloadCheckBox = QCheckBox()
self.disableRuntimeDownloadCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
self.disableRuntimeDownloadCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
self.disableRuntimeDownloadTitle = QLabel(_("Disable PortProton runtime download"))
self.disableRuntimeDownloadTitle.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
self.disableRuntimeDownloadTitle.setStyleSheet(self.theme.SETTINGS_TITLE_CHECKBOX_STYLE)
self.disableRuntimeDownloadTitle.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.disableRuntimeDownloadCheckBox.setChecked(ui_config.get_disable_runtime_download())
disable_runtime_download_layout = QHBoxLayout()
disable_runtime_download_layout.setContentsMargins(0, 0, 0, 0)
disable_runtime_download_layout.addWidget(self.disableRuntimeDownloadCheckBox)
disable_runtime_download_layout.addWidget(self.disableRuntimeDownloadTitle)
disable_runtime_download_layout.addStretch()
download_wine_to_steam_layout = None
self.steamCompatCheckBox = QCheckBox()
self.steamCompatCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
self.steamCompatCheckBox.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
@@ -2394,7 +2411,6 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
download_wine_to_steam_layout.addWidget(self.downloadWineToSteamCheckBox)
download_wine_to_steam_layout.addWidget(self.downloadWineToSteamTitle)
download_wine_to_steam_layout.addStretch()
uiForm.addRow(download_wine_to_steam_layout)
self.economyModeCheckBox = QCheckBox()
self.economyModeCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
@@ -2418,7 +2434,6 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
economy_mode_layout.addWidget(self.economyModeCheckBox)
economy_mode_layout.addWidget(self.economyModeTitle)
economy_mode_layout.addStretch()
uiForm.addRow(economy_mode_layout)
self.forceSystemDpiCheckBox = QCheckBox()
self.forceSystemDpiCheckBox.setStyleSheet(self.theme.CHECKBOX_STYLE)
@@ -2436,7 +2451,20 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
force_system_dpi_layout.addStretch()
uiForm.addRow(force_system_dpi_layout)
# 3. Gamepad Settings Section
# 3. Download Settings Section
downloadFrame, downloadForm = create_section(_("Download Settings"), self.theme)
downloadForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
scrollLayout.addWidget(downloadFrame)
if disable_runtime_download_layout is not None:
downloadForm.addRow(disable_runtime_download_layout)
if download_wine_to_steam_layout is not None:
downloadForm.addRow(download_wine_to_steam_layout)
downloadForm.addRow(economy_mode_layout)
# 4. Gamepad Settings Section
padFrame, padForm = create_section(_("Gamepad Settings"), self.theme)
padForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
scrollLayout.addWidget(padFrame)
@@ -2457,7 +2485,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
auto_fullscreen_layout.addStretch()
padForm.addRow(auto_fullscreen_layout)
# 4. Hardware Settings Section
# 5. Hardware Settings Section
hwFrame, hwForm = create_section(_("Hardware Settings"), self.theme)
hwForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
scrollLayout.addWidget(hwFrame)
@@ -2492,7 +2520,7 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
else:
hwForm.addRow(QLabel(_("No GPUs found")), QLabel(""))
# 5. Proxy Settings Section
# 6. Proxy Settings Section
proxyFrame, proxyForm = create_section(_("Proxy Settings"), self.theme)
proxyForm.setRowWrapPolicy(QFormLayout.RowWrapPolicy.DontWrapRows)
scrollLayout.addWidget(proxyFrame)
@@ -2680,6 +2708,11 @@ class MainWindow(MainWindowControlHintsMixin, MainWindowSystemTabMixin, MainWind
if hasattr(self, 'downloadWineToSteamCheckBox'):
ui_config.set_download_wine_to_steam(self.downloadWineToSteamCheckBox.isChecked())
if hasattr(self, 'disableRuntimeDownloadCheckBox'):
ui_config.set_disable_runtime_download(self.disableRuntimeDownloadCheckBox.isChecked())
else:
ui_config.get_disable_runtime_download()
# Save GPU selection to user.conf (only if the combo box exists)
if hasattr(self, 'gpuCombo'):
selected_gpu = self.gpuCombo.currentText()
+7 -41
View File
@@ -31,8 +31,6 @@ logger = get_logger(__name__)
AUTOINSTALL_CACHE_DURATION = 3600 # 1 hour for autoinstall cache
HEAD_FAILURE_RETRY_DELAY = 60 # 1 minute cooldown for failed HEAD checks
HEAD_CACHE_DURATION = 24 * 60 * 60
HEAD_CACHE_NAME = "head_cache"
HEAD_CACHE_OLD_PATTERN = "head_*.json"
def _create_bootstrap_file_explorer_parent() -> tuple[QObject | None, Any]:
@@ -118,7 +116,6 @@ class PortProtonAPI:
self._head_positive_cache: set[str] = set()
self._head_negative_cache: set[str] = set()
self._head_failure_cache: dict[str, float] = {}
self._head_disk_cache_cleaned = False
self._pending_asset_notifier: QObject | None = None
self._pending_asset_batch_thread: QThread | None = None
@@ -127,38 +124,6 @@ class PortProtonAPI:
os.makedirs(game_dir, exist_ok=True)
return game_dir
def _load_head_cache_entry(self, cache_manager: CacheManager, cache_key: str) -> bool | None:
cached = cache_manager.load_json(HEAD_CACHE_NAME)
if not isinstance(cached, dict):
return None
entry = cached.get(cache_key)
if not isinstance(entry, dict):
return None
timestamp = entry.get("timestamp")
if not isinstance(timestamp, int | float):
return None
if time.time() - timestamp > HEAD_CACHE_DURATION:
return None
return entry.get("exists") is True
def _save_head_cache_entry(self, cache_manager: CacheManager, cache_key: str, exists: bool) -> None:
cached = cache_manager.load_json(HEAD_CACHE_NAME)
if not isinstance(cached, dict):
cached = {}
cached[cache_key] = {"exists": exists, "timestamp": time.time()}
cache_manager.save_json(HEAD_CACHE_NAME, cached)
self._remove_old_head_cache_files(cache_manager)
def _remove_old_head_cache_files(self, cache_manager: CacheManager) -> None:
if self._head_disk_cache_cleaned:
return
for cache_file in cache_manager.cache_dir.glob(HEAD_CACHE_OLD_PATTERN):
try:
cache_file.unlink()
except OSError as e:
logger.debug("Failed to remove old HEAD cache %s: %s", cache_file, e)
self._head_disk_cache_cleaned = True
def _check_file_exists(self, url: str, timeout: int = 5) -> bool:
if url in self._head_negative_cache:
return False
@@ -169,10 +134,11 @@ class PortProtonAPI:
return False
cache_manager = CacheManager()
cache_key = hashlib.sha256(url.encode('utf-8')).hexdigest()
cached_exists = self._load_head_cache_entry(cache_manager, cache_key)
if cached_exists is not None:
return cached_exists
cache_key = f"head_{hashlib.sha256(url.encode('utf-8')).hexdigest()}"
if cache_manager.is_fresh(cache_key, HEAD_CACHE_DURATION):
cached = cache_manager.load_json(cache_key)
if isinstance(cached, dict):
return cached.get("exists") is True
try:
session = get_requests_session()
@@ -181,13 +147,13 @@ class PortProtonAPI:
self._head_negative_cache.add(url)
self._head_positive_cache.discard(url)
self._head_failure_cache.pop(url, None)
self._save_head_cache_entry(cache_manager, cache_key, False)
cache_manager.save_json(cache_key, {"exists": False})
return False
response.raise_for_status()
if response.status_code == 200:
self._head_positive_cache.add(url)
self._head_failure_cache.pop(url, None)
self._save_head_cache_entry(cache_manager, cache_key, True)
cache_manager.save_json(cache_key, {"exists": True})
return True
return False
except requests.RequestException as e:
+2 -1
View File
@@ -24,7 +24,9 @@ classifiers = [
]
dependencies = [
"babel>=2.18.0",
"beautifulsoup4>=4.14.3",
"evdev>=1.9.3",
"icoextract>=0.2.0",
"libarchive-c>=5.3",
"orjson>=3.11.8",
"pillow>=12.2.0",
@@ -38,7 +40,6 @@ dependencies = [
"websocket-client>=1.9.0",
"dbus-fast>=4.0.4",
"pygame>=2.6.1",
"pefile>=2024.8.26",
]
[project.scripts]
Generated
+35 -2
View File
@@ -15,6 +15,19 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/77/f5/21d2de20e8b8b0408f0681956ca2c69f1320a3848ac50e6e7f39c6159675/babel-2.18.0-py3-none-any.whl", hash = "sha256:e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35", size = 10196845, upload-time = "2026-02-01T12:30:53.445Z" },
]
[[package]]
name = "beautifulsoup4"
version = "4.14.3"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "soupsieve" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/c3/b0/1c6a16426d389813b48d95e26898aff79abbde42ad353958ad95cc8c9b21/beautifulsoup4-4.14.3.tar.gz", hash = "sha256:6292b1c5186d356bba669ef9f7f051757099565ad9ada5dd630bd9de5fa7fb86", size = 627737, upload-time = "2025-11-30T15:08:26.084Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/1a/39/47f9197bdd44df24d67ac8893641e16f386c984a0619ef2ee4c51fbbc019/beautifulsoup4-4.14.3-py3-none-any.whl", hash = "sha256:0918bfe44902e6ad8d57732ba310582e98da931428d231a5ecb9e7c703a735bb", size = 107721, upload-time = "2025-11-30T15:08:24.087Z" },
]
[[package]]
name = "certifi"
version = "2025.11.12"
@@ -194,6 +207,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/e3/7f/a1a97644e39e7316d850784c642093c99df1290a460df4ede27659056834/filelock-3.20.1-py3-none-any.whl", hash = "sha256:15d9e9a67306188a44baa72f569d2bfd803076269365fdea0934385da4dc361a", size = 16666, upload-time = "2025-12-15T23:54:26.874Z" },
]
[[package]]
name = "icoextract"
version = "0.2.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pefile" },
]
sdist = { url = "https://files.pythonhosted.org/packages/cc/a9/4653791ae2356f981ea3597a1ace0d04fef622071209a4613bf56abd0264/icoextract-0.2.0.tar.gz", hash = "sha256:e7b4770c9a927a48ecfccc4ecd35afe477c2565a71449f92a95bdc92a0d10043", size = 10949, upload-time = "2025-06-03T04:17:37.464Z" }
[[package]]
name = "identify"
version = "2.6.15"
@@ -433,11 +455,12 @@ version = "0.1.12"
source = { editable = "." }
dependencies = [
{ name = "babel" },
{ name = "beautifulsoup4" },
{ name = "dbus-fast" },
{ name = "evdev" },
{ name = "icoextract" },
{ name = "libarchive-c" },
{ name = "orjson" },
{ name = "pefile" },
{ name = "pillow" },
{ name = "psutil" },
{ name = "pygame" },
@@ -460,11 +483,12 @@ dev = [
[package.metadata]
requires-dist = [
{ name = "babel", specifier = ">=2.18.0" },
{ name = "beautifulsoup4", specifier = ">=4.14.3" },
{ name = "dbus-fast", specifier = ">=4.0.4" },
{ name = "evdev", specifier = ">=1.9.3" },
{ name = "icoextract", specifier = ">=0.2.0" },
{ name = "libarchive-c", specifier = ">=5.3" },
{ name = "orjson", specifier = ">=3.11.8" },
{ name = "pefile", specifier = ">=2024.8.26" },
{ name = "pillow", specifier = ">=12.2.0" },
{ name = "psutil", specifier = ">=7.2.2" },
{ name = "pygame", specifier = ">=2.6.1" },
@@ -830,6 +854,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/fb/99/6e5ee21db2d6af84bbbd7d871d441dafeb069c6de5667b1aa49891a77c66/shiboken6-6.11.0-cp310-abi3-win_arm64.whl", hash = "sha256:3bd76cf56105ab2d62ecaff630366f11264f69b88d488f10f048da9a065781f4", size = 1783186, upload-time = "2026-03-23T12:47:11.832Z" },
]
[[package]]
name = "soupsieve"
version = "2.8.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/89/23/adf3796d740536d63a6fbda113d07e60c734b6ed5d3058d1e47fc0495e47/soupsieve-2.8.1.tar.gz", hash = "sha256:4cf733bc50fa805f5df4b8ef4740fc0e0fa6218cf3006269afd3f9d6d80fd350", size = 117856, upload-time = "2025-12-18T13:50:34.655Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/48/f3/b67d6ea49ca9154453b6d70b34ea22f3996b9fa55da105a79d8732227adc/soupsieve-2.8.1-py3-none-any.whl", hash = "sha256:a11fe2a6f3d76ab3cf2de04eb339c1be5b506a8a47f2ceb6d139803177f85434", size = 36710, upload-time = "2025-12-18T13:50:33.267Z" },
]
[[package]]
name = "tqdm"
version = "4.67.3"