mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Fix restart app in Windows
This commit is contained in:
+19
-9
@@ -2815,6 +2815,23 @@ class abogen(QWidget):
|
|||||||
self.config["replace_single_newlines"] = enabled
|
self.config["replace_single_newlines"] = enabled
|
||||||
save_config(self.config)
|
save_config(self.config)
|
||||||
|
|
||||||
|
def restart_app(self):
|
||||||
|
from PyQt5.QtCore import QProcess
|
||||||
|
import sys
|
||||||
|
exe = sys.executable
|
||||||
|
args = sys.argv
|
||||||
|
|
||||||
|
# On Windows, use .exe if available
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
script_path = args[0]
|
||||||
|
if not script_path.lower().endswith('.exe'):
|
||||||
|
exe_path = os.path.splitext(script_path)[0] + '.exe'
|
||||||
|
if os.path.exists(exe_path):
|
||||||
|
args[0] = exe_path
|
||||||
|
|
||||||
|
QProcess.startDetached(exe, args)
|
||||||
|
QApplication.quit()
|
||||||
|
|
||||||
def toggle_kokoro_internet_access(self, disabled):
|
def toggle_kokoro_internet_access(self, disabled):
|
||||||
if disabled:
|
if disabled:
|
||||||
message = (
|
message = (
|
||||||
@@ -2838,11 +2855,7 @@ class abogen(QWidget):
|
|||||||
self.config["disable_kokoro_internet"] = disabled
|
self.config["disable_kokoro_internet"] = disabled
|
||||||
save_config(self.config)
|
save_config(self.config)
|
||||||
try:
|
try:
|
||||||
from PyQt5.QtCore import QProcess
|
self.restart_app()
|
||||||
import sys
|
|
||||||
|
|
||||||
QProcess.startDetached(sys.executable, sys.argv)
|
|
||||||
QApplication.quit()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
self, "Restart Failed", f"Failed to restart the application:\n{e}"
|
self, "Restart Failed", f"Failed to restart the application:\n{e}"
|
||||||
@@ -2864,10 +2877,7 @@ class abogen(QWidget):
|
|||||||
try:
|
try:
|
||||||
if os.path.exists(config_path):
|
if os.path.exists(config_path):
|
||||||
os.remove(config_path)
|
os.remove(config_path)
|
||||||
from PyQt5.QtCore import QProcess
|
self.restart_app()
|
||||||
|
|
||||||
QProcess.startDetached(sys.executable, sys.argv)
|
|
||||||
QApplication.quit()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
self, "Reset Error", f"Could not reset settings:\n{e}"
|
self, "Reset Error", f"Could not reset settings:\n{e}"
|
||||||
|
|||||||
Reference in New Issue
Block a user