Skip to content

Commit d0fb24a

Browse files
added misterhorse URL handler
1 parent 700a669 commit d0fb24a

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

src/mainwindow.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from src.pluginthread import PluginThread
1414
from src.removeaethread import RemoveAEThread
1515
from src.utils import (
16-
check_aegnux_tip_marked, get_default_terminal, get_wine_bin_path_env,
16+
check_aegnux_tip_marked, get_default_terminal, get_mhtb_install_dir, get_wine_bin_path_env,
1717
get_cep_dir, get_ae_plugins_dir, get_wineprefix_dir,
1818
check_aegnux_installed, mark_aegnux_tip_as_shown, get_ae_install_dir, get_aegnux_installation_dir
1919
)
@@ -25,6 +25,7 @@ def __init__(self):
2525
super().__init__()
2626

2727
self.ran_from_aep_file = False
28+
self.ran_from_mhtb_link = False
2829

2930
self.setWindowTitle(gls('welcome_win_title'))
3031
self.install_button.clicked.connect(self.install_button_clicked)
@@ -75,6 +76,38 @@ def __init__(self):
7576
self.aeg_action.triggered.connect(self.aegnux_folder_clicked)
7677
self.cep_action.triggered.connect(self.cep_folder_clicked)
7778

79+
def try_autoopen_mhtb(self):
80+
if self.ran_from_mhtb_link:
81+
return
82+
83+
self.ran_from_mhtb_link = True
84+
85+
mhtb_link = ''
86+
87+
for arg in sys.argv:
88+
if 'misterhorsepm://' in arg:
89+
mhtb_link = arg
90+
break
91+
92+
if mhtb_link == '':
93+
return
94+
95+
mhtb_dir = get_mhtb_install_dir()
96+
if mhtb_dir is None:
97+
QMessageBox.warning(
98+
self,
99+
gls('mhtb_not_found_title'),
100+
gls('mhtb_not_found_text')
101+
)
102+
return
103+
104+
self.run_mhtb_thread = RunExeThread([f'{mhtb_dir.as_posix()}/ProductManager.exe', mhtb_link])
105+
self.run_mhtb_thread.log_signal.connect(self._log)
106+
self.run_mhtb_thread.finished_signal.connect(self._finished)
107+
108+
self.run_mhtb_thread.start()
109+
exit(0)
110+
78111
def try_autoopen_aep(self):
79112
self.run_ae_thread.clear_aep_file_arg()
80113
if self.ran_from_aep_file:
@@ -94,6 +127,7 @@ def try_autoopen_aep(self):
94127

95128
self.run_ae_thread.add_aep_file_arg(aep_file)
96129
self.run_ae_button_clicked()
130+
exit(0)
97131

98132
def init_installation(self):
99133
if check_aegnux_installed():
@@ -107,6 +141,7 @@ def init_installation(self):
107141
self.plugininst_action.setEnabled(True)
108142
self.term_action.setEnabled(True)
109143
self.try_autoopen_aep()
144+
self.try_autoopen_mhtb()
110145

111146
else:
112147
self.install_button.show()

src/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ def get_wine_bin_path_env(old_path: str | None):
148148
old_path = old_path if old_path is not None else os.getenv('PATH')
149149
return f'{get_wine_runner_dir().as_posix()}/bin:{old_path}'
150150

151+
def get_mhtb_install_dir():
152+
wineprefix_dir = get_wineprefix_dir()
153+
mhtb_dir = wineprefix_dir.joinpath('drive_c/Program Files/Mister Horse Product Manager')
154+
155+
if not os.path.exists(mhtb_dir):
156+
return None
157+
158+
return mhtb_dir
159+
151160
def get_default_terminal() -> str:
152161
DEFAULT_ENVS = ["TERMINAL", "TERM_PROGRAM"]
153162
TERMINALS = [

translations/en_US.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@
3838
'plugin_note_text': 'Those plugins are available at https://t.me/Aegnux',
3939
'done_title': 'Done!',
4040
'done_ae': 'AE has been installed.',
41-
'done_plugins': 'The plugins have been installed.'
41+
'done_plugins': 'The plugins have been installed.',
42+
'mhtb_not_found_title': 'Mister Horse Product Manager Not Found',
43+
'mhtb_not_found_text': 'Mister Horse Product Manager is not installed in the Wine prefix. Please install it first.'
4244
}

translations/ru_RU.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@
3737
'plugin_note': 'Замечание к приватным плагинам',
3838
'plugin_note_text': 'Эти плагины доступны здесь: https://t.me/Aegnux',
3939
'done_ae': 'AE был установлен.',
40-
'done_plugins': 'Плагины были установлены.'
40+
'done_plugins': 'Плагины были установлены.',
41+
'mhtb_not_found_title': 'Mister Horse Product Manager не найден',
42+
'mhtb_not_found_text': 'Mister Horse Product Manager не установлен в префиксе Wine. Пожалуйста, сначала установите его.'
4143
}

translations/uk_UA.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@
3737
'plugin_note': 'Примітка до приватних плагінів',
3838
'plugin_note_text': 'Ці плагіни доступні тут: https://t.me/Aegnux',
3939
'done_ae': 'AE було встановлено.',
40-
'done_plugins': 'Плагіни було встановлено.'
40+
'done_plugins': 'Плагіни було встановлено.',
41+
'mhtb_not_found_title': 'Mister Horse Product Manager не знайдено',
42+
'mhtb_not_found_text': 'Mister Horse Product Manager не встановлено в префіксі Wine. Будь ласка, спочатку встановіть його.'
4143
}

0 commit comments

Comments
 (0)