1
0
Fork 0
mirror of synced 2024-06-26 10:11:19 +12:00

Add some checks, if no wine prefixes exist and update prefixes, when changing in linux settings

This commit is contained in:
Dummerle 2022-01-19 20:10:10 +01:00
parent 3239e3ec7a
commit b13daed37a
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1
4 changed files with 40 additions and 14 deletions

View file

@ -301,7 +301,7 @@ class GameSettings(QWidget, Ui_GameSettings):
text = os.path.expanduser("~/.proton")
return True, text, ""
parent = os.path.dirname(text)
return os.path.exists(parent), text
return os.path.exists(parent), text, PathEdit.reasons.dir_not_exist
def proton_prefix_save(self, text: str):
self.core.lgd.config.set(

View file

@ -15,15 +15,18 @@ logger = getLogger("EOS")
def get_wine_prefixes() -> List[str]:
prefixes = [os.path.expanduser("~/.wine")]
if os.path.exists(p := os.path.expanduser("~/.wine")):
prefixes = [p]
else:
prefixes = []
for i in shared.core.get_installed_list():
# get prefix from environment
env = shared.core.get_app_environment(i.app_name)
if pfx := env.get("WINEPREFIX"):
if pfx not in prefixes:
if pfx not in prefixes and os.path.exists(os.path.join(pfx, "user.reg")):
prefixes.append(pfx)
if steam_pfx := env.get("STEAM_COMPAT_DATA_PATH"):
if steam_pfx not in prefixes:
if steam_pfx not in prefixes and os.path.exists(os.path.join(steam_pfx, "user.reg")):
prefixes.append(os.path.join(steam_pfx, "pfx"))
return prefixes
@ -62,6 +65,7 @@ class EosWidget(QGroupBox, Ui_EosWidget):
self.overlay = self.core.lgd.get_overlay_install_info()
shared.signals.overlay_installation_finished.connect(self.overlay_installation_finished)
shared.signals.wine_prefix_updated.connect(self.update_prefixes)
self.update_check_button.clicked.connect(self.check_for_update)
self.install_button.clicked.connect(self.install_overlay)
@ -78,22 +82,37 @@ class EosWidget(QGroupBox, Ui_EosWidget):
self.current_prefix = None
self.select_pfx_combo.setVisible(False)
else:
self.current_prefix = os.path.expanduser("~/.wine")
for pfx in get_wine_prefixes():
self.current_prefix = os.path.expanduser("~/.wine") \
if os.path.exists(os.path.expanduser("~/.wine")) \
else None
pfxs = get_wine_prefixes()
for pfx in pfxs:
self.select_pfx_combo.addItem(pfx.replace(os.path.expanduser("~/"), "~/"))
if not pfxs:
self.enable_gb.setDisabled(True)
else:
self.select_pfx_combo.setCurrentIndex(0)
self.select_pfx_combo.currentIndexChanged.connect(self.update_select_combo)
self.update_select_combo(None)
if pfxs:
self.update_select_combo(None)
reg_paths = eos.query_registry_entries(self.current_prefix)
enabled = False
if reg_paths['overlay_path'] and self.core.is_overlay_install(reg_paths['overlay_path']):
enabled = True
self.enabled_cb.setChecked(enabled)
self.enabled_info_label.setText("")
self.threadpool = QThreadPool.globalInstance()
def update_prefixes(self):
logger.debug("Updated prefixes")
pfxs = get_wine_prefixes() # returns /home/whatever
self.select_pfx_combo.clear()
for pfx in pfxs:
self.select_pfx_combo.addItem(pfx.replace(os.path.expanduser("~/"), "~/"))
if self.current_prefix in pfxs:
self.select_pfx_combo.setCurrentIndex(
self.select_pfx_combo.findText(self.current_prefix.replace(os.path.expanduser("~/"), "~/")))
def check_for_update(self):
def worker_finished(update_available):
self.update_button.setVisible(update_available)
@ -127,7 +146,9 @@ class EosWidget(QGroupBox, Ui_EosWidget):
def update_select_combo(self, i: None):
if i is None:
i = self.select_pfx_combo.currentIndex()
prefix = self.select_pfx_combo.itemText(i).replace("~/", os.path.expanduser("~/"))
prefix = os.path.expanduser(self.select_pfx_combo.itemText(i))
if platform.system() != "Windows" and not os.path.exists(prefix):
return
self.current_prefix = prefix
reg_paths = eos.query_registry_entries(self.current_prefix)

View file

@ -1,3 +1,4 @@
import os
from logging import getLogger
from PyQt5.QtWidgets import QFileDialog, QWidget
@ -21,6 +22,7 @@ class LinuxSettings(QWidget, Ui_LinuxSettings):
self.wine_prefix = PathEdit(
self.load_prefix(),
file_type=QFileDialog.DirectoryOnly,
edit_func=lambda path: (os.path.isdir(path), path, PathEdit.reasons.dir_not_exist),
save_func=self.save_prefix,
)
self.prefix_layout.addWidget(self.wine_prefix)
@ -50,6 +52,7 @@ class LinuxSettings(QWidget, Ui_LinuxSettings):
def save_prefix(self, text: str):
self.save_setting(text, f"{self.name}.env", "WINEPREFIX")
self.save_setting(text, self.name, "wine_prefix")
shared.signals.wine_prefix_updated.emit()
@staticmethod
def load_setting(section: str, setting: str, fallback: str = str()):

View file

@ -141,3 +141,5 @@ class Signals(QObject):
game_uninstalled = pyqtSignal(str)
set_discord_rpc = pyqtSignal(str) # app_name of running game
wine_prefix_updated = pyqtSignal()