added misterhorse URL handler

This commit is contained in:
Andrew
2025-11-09 12:50:48 +03:00
parent 700a669bc5
commit d0fb24a741
5 changed files with 54 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ from src.killaethread import KillAEThread
from src.pluginthread import PluginThread from src.pluginthread import PluginThread
from src.removeaethread import RemoveAEThread from src.removeaethread import RemoveAEThread
from src.utils import ( from src.utils import (
check_aegnux_tip_marked, get_default_terminal, get_wine_bin_path_env, check_aegnux_tip_marked, get_default_terminal, get_mhtb_install_dir, get_wine_bin_path_env,
get_cep_dir, get_ae_plugins_dir, get_wineprefix_dir, get_cep_dir, get_ae_plugins_dir, get_wineprefix_dir,
check_aegnux_installed, mark_aegnux_tip_as_shown, get_ae_install_dir, get_aegnux_installation_dir check_aegnux_installed, mark_aegnux_tip_as_shown, get_ae_install_dir, get_aegnux_installation_dir
) )
@@ -25,6 +25,7 @@ class MainWindow(MainWindowUI):
super().__init__() super().__init__()
self.ran_from_aep_file = False self.ran_from_aep_file = False
self.ran_from_mhtb_link = False
self.setWindowTitle(gls('welcome_win_title')) self.setWindowTitle(gls('welcome_win_title'))
self.install_button.clicked.connect(self.install_button_clicked) self.install_button.clicked.connect(self.install_button_clicked)
@@ -75,6 +76,38 @@ class MainWindow(MainWindowUI):
self.aeg_action.triggered.connect(self.aegnux_folder_clicked) self.aeg_action.triggered.connect(self.aegnux_folder_clicked)
self.cep_action.triggered.connect(self.cep_folder_clicked) self.cep_action.triggered.connect(self.cep_folder_clicked)
def try_autoopen_mhtb(self):
if self.ran_from_mhtb_link:
return
self.ran_from_mhtb_link = True
mhtb_link = ''
for arg in sys.argv:
if 'misterhorsepm://' in arg:
mhtb_link = arg
break
if mhtb_link == '':
return
mhtb_dir = get_mhtb_install_dir()
if mhtb_dir is None:
QMessageBox.warning(
self,
gls('mhtb_not_found_title'),
gls('mhtb_not_found_text')
)
return
self.run_mhtb_thread = RunExeThread([f'{mhtb_dir.as_posix()}/ProductManager.exe', mhtb_link])
self.run_mhtb_thread.log_signal.connect(self._log)
self.run_mhtb_thread.finished_signal.connect(self._finished)
self.run_mhtb_thread.start()
exit(0)
def try_autoopen_aep(self): def try_autoopen_aep(self):
self.run_ae_thread.clear_aep_file_arg() self.run_ae_thread.clear_aep_file_arg()
if self.ran_from_aep_file: if self.ran_from_aep_file:
@@ -94,6 +127,7 @@ class MainWindow(MainWindowUI):
self.run_ae_thread.add_aep_file_arg(aep_file) self.run_ae_thread.add_aep_file_arg(aep_file)
self.run_ae_button_clicked() self.run_ae_button_clicked()
exit(0)
def init_installation(self): def init_installation(self):
if check_aegnux_installed(): if check_aegnux_installed():
@@ -107,6 +141,7 @@ class MainWindow(MainWindowUI):
self.plugininst_action.setEnabled(True) self.plugininst_action.setEnabled(True)
self.term_action.setEnabled(True) self.term_action.setEnabled(True)
self.try_autoopen_aep() self.try_autoopen_aep()
self.try_autoopen_mhtb()
else: else:
self.install_button.show() self.install_button.show()

View File

@@ -148,6 +148,15 @@ def get_wine_bin_path_env(old_path: str | None):
old_path = old_path if old_path is not None else os.getenv('PATH') old_path = old_path if old_path is not None else os.getenv('PATH')
return f'{get_wine_runner_dir().as_posix()}/bin:{old_path}' return f'{get_wine_runner_dir().as_posix()}/bin:{old_path}'
def get_mhtb_install_dir():
wineprefix_dir = get_wineprefix_dir()
mhtb_dir = wineprefix_dir.joinpath('drive_c/Program Files/Mister Horse Product Manager')
if not os.path.exists(mhtb_dir):
return None
return mhtb_dir
def get_default_terminal() -> str: def get_default_terminal() -> str:
DEFAULT_ENVS = ["TERMINAL", "TERM_PROGRAM"] DEFAULT_ENVS = ["TERMINAL", "TERM_PROGRAM"]
TERMINALS = [ TERMINALS = [

View File

@@ -38,5 +38,7 @@ STRINGS = {
'plugin_note_text': 'Those plugins are available at https://t.me/Aegnux', 'plugin_note_text': 'Those plugins are available at https://t.me/Aegnux',
'done_title': 'Done!', 'done_title': 'Done!',
'done_ae': 'AE has been installed.', 'done_ae': 'AE has been installed.',
'done_plugins': 'The plugins have been installed.' 'done_plugins': 'The plugins have been installed.',
'mhtb_not_found_title': 'Mister Horse Product Manager Not Found',
'mhtb_not_found_text': 'Mister Horse Product Manager is not installed in the Wine prefix. Please install it first.'
} }

View File

@@ -37,5 +37,7 @@ STRINGS = {
'plugin_note': 'Замечание к приватным плагинам', 'plugin_note': 'Замечание к приватным плагинам',
'plugin_note_text': 'Эти плагины доступны здесь: https://t.me/Aegnux', 'plugin_note_text': 'Эти плагины доступны здесь: https://t.me/Aegnux',
'done_ae': 'AE был установлен.', 'done_ae': 'AE был установлен.',
'done_plugins': 'Плагины были установлены.' 'done_plugins': 'Плагины были установлены.',
'mhtb_not_found_title': 'Mister Horse Product Manager не найден',
'mhtb_not_found_text': 'Mister Horse Product Manager не установлен в префиксе Wine. Пожалуйста, сначала установите его.'
} }

View File

@@ -37,5 +37,7 @@ STRINGS = {
'plugin_note': 'Примітка до приватних плагінів', 'plugin_note': 'Примітка до приватних плагінів',
'plugin_note_text': 'Ці плагіни доступні тут: https://t.me/Aegnux', 'plugin_note_text': 'Ці плагіни доступні тут: https://t.me/Aegnux',
'done_ae': 'AE було встановлено.', 'done_ae': 'AE було встановлено.',
'done_plugins': 'Плагіни було встановлено.' 'done_plugins': 'Плагіни було встановлено.',
'mhtb_not_found_title': 'Mister Horse Product Manager не знайдено',
'mhtb_not_found_text': 'Mister Horse Product Manager не встановлено в префіксі Wine. Будь ласка, спочатку встановіть його.'
} }