diff --git a/app/main_window.py b/app/main_window.py index 3323c14..b08c6ae 100644 --- a/app/main_window.py +++ b/app/main_window.py @@ -264,6 +264,9 @@ class MainWindow(QMainWindow): help_menu = menubar.addMenu("Aide") self._add_action(help_menu, "Rechercher une mise a jour...", None, self._do_check_update) help_menu.addSeparator() + self._add_action(help_menu, "Integrer a Windows (menu contextuel + association PDF)", None, self._do_register_windows) + self._add_action(help_menu, "Retirer l'integration Windows", None, self._do_unregister_windows) + help_menu.addSeparator() self._add_action(help_menu, "A propos de CopyDev Imposing Tool", None, self._show_about) def _add_action(self, menu, text, shortcut, callback): @@ -1281,6 +1284,61 @@ class MainWindow(QMainWindow): self._open_pdf(output) self._status_label.setText(f"Document test de {num} pages cree") + def _do_register_windows(self): + if sys.platform != "win32": + QMessageBox.information(self, "Windows uniquement", "Cette fonction est reservee a Windows.") + return + import subprocess + exe = sys.executable if getattr(sys, 'frozen', False) else os.path.abspath("main.py") + try: + cmds = [ + # Association PDF + f'reg add "HKCU\\Software\\Classes\\.pdf\\OpenWithProgids" /v "CopyDevImpose" /t REG_SZ /d "" /f', + f'reg add "HKCU\\Software\\Classes\\CopyDevImpose" /ve /d "CopyDev Imposing Tool" /f', + f'reg add "HKCU\\Software\\Classes\\CopyDevImpose\\shell\\open\\command" /ve /d "\\"{exe}\\" \\"%1\\"" /f', + f'reg add "HKCU\\Software\\Classes\\CopyDevImpose\\DefaultIcon" /ve /d "{exe},0" /f', + # Menu contextuel + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose" /ve /d "CopyDev Impose" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose" /v "SubCommands" /t REG_SZ /d "" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose" /v "Icon" /t REG_SZ /d "{exe},0" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\open" /ve /d "Ouvrir avec CopyDev" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\open\\command" /ve /d "\\"{exe}\\" \\"%1\\"" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\bookletA4" /ve /d "Livret A4" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\bookletA4\\command" /ve /d "\\"{exe}\\" --action booklet_a4 \\"%1\\"" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\bookletA3" /ve /d "Livret A3" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\bookletA3\\command" /ve /d "\\"{exe}\\" --action booklet_a3 \\"%1\\"" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\nup2x2" /ve /d "2x2 par feuille" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\nup2x2\\command" /ve /d "\\"{exe}\\" --action nup_2x2 \\"%1\\"" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\unbooklet" /ve /d "Delivretiser" /f', + f'reg add "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose\\shell\\unbooklet\\command" /ve /d "\\"{exe}\\" --action unbooklet \\"%1\\"" /f', + ] + for cmd in cmds: + subprocess.run(cmd, shell=True, capture_output=True) + QMessageBox.information(self, "Integration Windows", + "CopyDev Imposing Tool est maintenant integre a Windows !\n\n" + "- Clic droit sur un PDF > CopyDev Impose\n" + "- Ouvrir avec > CopyDev Imposing Tool") + self._status_label.setText("Integration Windows effectuee") + except Exception as e: + QMessageBox.critical(self, "Erreur", f"Echec de l'integration :\n{e}") + + def _do_unregister_windows(self): + if sys.platform != "win32": + return + import subprocess + try: + cmds = [ + 'reg delete "HKCU\\Software\\Classes\\CopyDevImpose" /f', + 'reg delete "HKCU\\Software\\Classes\\.pdf\\OpenWithProgids" /v "CopyDevImpose" /f', + 'reg delete "HKCU\\Software\\Classes\\SystemFileAssociations\\.pdf\\shell\\CopyDevImpose" /f', + ] + for cmd in cmds: + subprocess.run(cmd, shell=True, capture_output=True) + QMessageBox.information(self, "Integration Windows", "Integration Windows retiree.") + self._status_label.setText("Integration Windows retiree") + except Exception as e: + QMessageBox.critical(self, "Erreur", str(e)) + def _do_check_update(self): from app.updater import check_for_update, do_update, VERSION self._status_label.setText("Recherche de mises a jour...") diff --git a/app/updater.py b/app/updater.py index 1ca5cd5..bc88bb8 100644 --- a/app/updater.py +++ b/app/updater.py @@ -14,7 +14,7 @@ REPO = "jules/copydev-imposing-tool" BRANCH = "master" # Version actuelle (incrementee a chaque release) -VERSION = "3.4.0" +VERSION = "3.4.1" def get_remote_version(): diff --git a/version.txt b/version.txt index 1809198..47b322c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.4.0 +3.4.1