forked from CastroFidel/winehelper
the license agreement has been placed in a separate file
This commit is contained in:
@ -4,6 +4,7 @@ import subprocess
|
||||
import sys
|
||||
import shlex
|
||||
import shutil
|
||||
import html
|
||||
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,QPushButton, QLabel, QTabWidget,
|
||||
QTextEdit, QFileDialog, QMessageBox, QLineEdit, QCheckBox, QStackedWidget, QScrollArea,
|
||||
QGridLayout, QFrame, QDialog, QTextBrowser)
|
||||
@ -20,6 +21,7 @@ class Var:
|
||||
CHANGELOG_FILE = os.environ.get("CHANGELOG_FILE")
|
||||
WH_ICON_PATH = os.environ.get("WH_ICON_PATH")
|
||||
LICENSE_FILE = os.environ.get("LICENSE_FILE")
|
||||
LICENSE_AGREEMENT_FILE = os.environ.get("AGREEMENT")
|
||||
|
||||
class WineHelperGUI(QMainWindow):
|
||||
def __init__(self):
|
||||
@ -604,7 +606,6 @@ class WineHelperGUI(QMainWindow):
|
||||
# Подвкладка "Лицензия"
|
||||
license_tab = QWidget()
|
||||
license_layout = QVBoxLayout(license_tab)
|
||||
import html
|
||||
license_text = QTextBrowser()
|
||||
license_text.setOpenExternalLinks(True)
|
||||
|
||||
@ -1255,38 +1256,29 @@ class WineHelperGUI(QMainWindow):
|
||||
license_page = QWidget()
|
||||
license_layout = QVBoxLayout(license_page)
|
||||
|
||||
license_text = QTextEdit()
|
||||
license_text.setReadOnly(True)
|
||||
license_text = QTextBrowser()
|
||||
|
||||
# Получаем текст лицензии из скрипта winehelper
|
||||
script_path = os.path.join(Var.DATA_PATH, "winehelper")
|
||||
license_content = ""
|
||||
# Получаем текст лицензионного соглашения из файла
|
||||
try:
|
||||
with open(script_path, 'r', encoding='utf-8') as f:
|
||||
capturing = False
|
||||
for line in f:
|
||||
if 'print_warning "Лицензионные соглашения использования сторонних компонентов:' in line:
|
||||
capturing = True
|
||||
continue
|
||||
license_file_path = Var.LICENSE_AGREEMENT_FILE
|
||||
if not license_file_path or not os.path.exists(license_file_path):
|
||||
raise FileNotFoundError
|
||||
|
||||
if capturing:
|
||||
if 'Подтверждая продолжение установки' in line:
|
||||
break
|
||||
# Очищаем строку от лишних символов
|
||||
clean_line = line.strip()
|
||||
clean_line = clean_line.replace('print_warning "', '').replace('\\n', '\n')
|
||||
clean_line = clean_line.rstrip('"')
|
||||
license_content += clean_line + '\n'
|
||||
with open(license_file_path, 'r', encoding='utf-8') as f:
|
||||
license_content = f.read()
|
||||
|
||||
escaped_license_content = html.escape(license_content)
|
||||
|
||||
license_text.setHtml(f"""
|
||||
<h3>Лицензионные соглашения использования сторонних компонентов:</h3>
|
||||
<p>{license_content}</p>
|
||||
<pre style="font-family: sans-serif; font-size: 10pt; white-space: pre-wrap; word-wrap: break-word;">{escaped_license_content}</pre>
|
||||
""")
|
||||
except (FileNotFoundError, TypeError):
|
||||
license_text.setHtml(f'<h3>Лицензионные соглашения</h3><p>Не удалось загрузить файл лицензионного соглашения по пути:<br>{Var.LICENSE_AGREEMENT_FILE}</p>')
|
||||
except Exception as e:
|
||||
print(f"Ошибка чтения файла для извлечения лицензии: {str(e)}")
|
||||
license_text.setHtml("""
|
||||
print(f"Ошибка чтения файла лицензии: {str(e)}")
|
||||
license_text.setHtml(f"""
|
||||
<h3>Лицензионные соглашения</h3>
|
||||
<p>Не удалось загрузить текст лицензионного соглашения.</p>
|
||||
<p>Произошла ошибка при чтении файла лицензии:<br>{str(e)}</p>
|
||||
""")
|
||||
|
||||
license_layout.addWidget(license_text)
|
||||
@ -1385,7 +1377,7 @@ class WineHelperGUI(QMainWindow):
|
||||
self.install_process.start(winehelper_path, args)
|
||||
if not self.install_process.waitForStarted(3000):
|
||||
raise RuntimeError("Не удалось запустить процесс установки")
|
||||
self.append_log("Процесс установки успешно запущен...")
|
||||
self.append_log("Процесс установки запущен...")
|
||||
except Exception as e:
|
||||
self.append_log(f"\n=== ОШИБКА: {str(e)} ===", is_error=True)
|
||||
QMessageBox.critical(self.install_dialog, "Ошибка", f"Не удалось запустить установку:\n{str(e)}")
|
||||
|
Reference in New Issue
Block a user