From d0fb24a74136bbcccd26242c8d323e52ac609442 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 9 Nov 2025 12:50:48 +0300 Subject: [PATCH] added misterhorse URL handler --- src/mainwindow.py | 37 ++++++++++++++++++++++++++++++++++++- src/utils.py | 9 +++++++++ translations/en_US.py | 4 +++- translations/ru_RU.py | 4 +++- translations/uk_UA.py | 4 +++- 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/mainwindow.py b/src/mainwindow.py index a317f37..46ab2a1 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -13,7 +13,7 @@ from src.killaethread import KillAEThread from src.pluginthread import PluginThread from src.removeaethread import RemoveAEThread 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, 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__() self.ran_from_aep_file = False + self.ran_from_mhtb_link = False self.setWindowTitle(gls('welcome_win_title')) 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.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): self.run_ae_thread.clear_aep_file_arg() 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_button_clicked() + exit(0) def init_installation(self): if check_aegnux_installed(): @@ -107,6 +141,7 @@ class MainWindow(MainWindowUI): self.plugininst_action.setEnabled(True) self.term_action.setEnabled(True) self.try_autoopen_aep() + self.try_autoopen_mhtb() else: self.install_button.show() diff --git a/src/utils.py b/src/utils.py index c8f3b10..a80e752 100644 --- a/src/utils.py +++ b/src/utils.py @@ -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') 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: DEFAULT_ENVS = ["TERMINAL", "TERM_PROGRAM"] TERMINALS = [ diff --git a/translations/en_US.py b/translations/en_US.py index d041fc9..1d35b58 100644 --- a/translations/en_US.py +++ b/translations/en_US.py @@ -38,5 +38,7 @@ STRINGS = { 'plugin_note_text': 'Those plugins are available at https://t.me/Aegnux', 'done_title': 'Done!', '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.' } \ No newline at end of file diff --git a/translations/ru_RU.py b/translations/ru_RU.py index 1a9e507..20a40e1 100644 --- a/translations/ru_RU.py +++ b/translations/ru_RU.py @@ -37,5 +37,7 @@ STRINGS = { 'plugin_note': 'Замечание к приватным плагинам', 'plugin_note_text': 'Эти плагины доступны здесь: https://t.me/Aegnux', 'done_ae': 'AE был установлен.', - 'done_plugins': 'Плагины были установлены.' + 'done_plugins': 'Плагины были установлены.', + 'mhtb_not_found_title': 'Mister Horse Product Manager не найден', + 'mhtb_not_found_text': 'Mister Horse Product Manager не установлен в префиксе Wine. Пожалуйста, сначала установите его.' } \ No newline at end of file diff --git a/translations/uk_UA.py b/translations/uk_UA.py index 399193a..8f86edb 100644 --- a/translations/uk_UA.py +++ b/translations/uk_UA.py @@ -37,5 +37,7 @@ STRINGS = { 'plugin_note': 'Примітка до приватних плагінів', 'plugin_note_text': 'Ці плагіни доступні тут: https://t.me/Aegnux', 'done_ae': 'AE було встановлено.', - 'done_plugins': 'Плагіни було встановлено.' + 'done_plugins': 'Плагіни було встановлено.', + 'mhtb_not_found_title': 'Mister Horse Product Manager не знайдено', + 'mhtb_not_found_text': 'Mister Horse Product Manager не встановлено в префіксі Wine. Будь ласка, спочатку встановіть його.' }