mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 09:59:41 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43cbfe056c | |||
| 12df32f72a | |||
| 9e0ee2a36d | |||
| 5b9bdd2a2a |
@@ -68,3 +68,4 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
|
|||||||
|
|
||||||
[Run]
|
[Run]
|
||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||||
|
Filename: "{app}\{#MyAppExeName}"; Flags: nowait skipifnotsilent
|
||||||
|
|||||||
@@ -134,27 +134,13 @@ SVG_PAUSE = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x
|
|||||||
SVG_FOLDER = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 6c0-1.1.9-2 2-2h5l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6z" fill="{color}"/></svg>'
|
SVG_FOLDER = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 6c0-1.1.9-2 2-2h5l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6z" fill="{color}"/></svg>'
|
||||||
|
|
||||||
|
|
||||||
def _find_install_path():
|
|
||||||
uninstall_key = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
|
|
||||||
for hive in (winreg.HKEY_CURRENT_USER, winreg.HKEY_LOCAL_MACHINE):
|
|
||||||
try:
|
|
||||||
with winreg.OpenKey(hive, uninstall_key) as key:
|
|
||||||
for i in range(winreg.QueryInfoKey(key)[0]):
|
|
||||||
with winreg.OpenKey(key, winreg.EnumKey(key, i)) as subkey:
|
|
||||||
try:
|
|
||||||
name = winreg.QueryValueEx(subkey, "DisplayName")[0]
|
|
||||||
if "SoftwareManager" in name:
|
|
||||||
return winreg.QueryValueEx(subkey, "InstallLocation")[0]
|
|
||||||
except OSError:
|
|
||||||
continue
|
|
||||||
except OSError:
|
|
||||||
continue
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def download_update(latest_version):
|
def download_update(latest_version):
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||||
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||||
|
installer_path = os.path.join(tempfile.gettempdir(), new_filename)
|
||||||
|
|
||||||
progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0)
|
progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0)
|
||||||
progress.setWindowTitle("Updating")
|
progress.setWindowTitle("Updating")
|
||||||
@@ -179,11 +165,11 @@ def download_update(latest_version):
|
|||||||
progress.setValue(int(downloaded * 100 / total))
|
progress.setValue(int(downloaded * 100 / total))
|
||||||
QtWidgets.QApplication.processEvents()
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
with open(new_filename, "wb") as f:
|
with open(installer_path, "wb") as f:
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
|
|
||||||
if not os.path.exists(new_filename):
|
if not os.path.exists(installer_path):
|
||||||
progress.close()
|
progress.close()
|
||||||
raise FileNotFoundError("Executable not found")
|
raise FileNotFoundError("Executable not found")
|
||||||
|
|
||||||
@@ -191,24 +177,8 @@ def download_update(latest_version):
|
|||||||
progress.setValue(100)
|
progress.setValue(100)
|
||||||
QtWidgets.QApplication.processEvents()
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
proc = subprocess.Popen([new_filename, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS", "/NORESTART"])
|
subprocess.Popen([installer_path, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS"])
|
||||||
while proc.poll() is None:
|
time.sleep(1)
|
||||||
QtWidgets.QApplication.processEvents()
|
|
||||||
import time
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
progress.close()
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove(new_filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
install_path = _find_install_path()
|
|
||||||
if not install_path:
|
|
||||||
raise FileNotFoundError("Could not find SoftwareManager install location in registry")
|
|
||||||
subprocess.Popen([os.path.join(install_path, "SoftwareManager.exe")])
|
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
@@ -275,15 +245,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.searchbar.setMinimumHeight(30)
|
self.searchbar.setMinimumHeight(30)
|
||||||
self.searchbar.returnPressed.connect(self._start_search)
|
self.searchbar.returnPressed.connect(self._start_search)
|
||||||
|
|
||||||
self._spinner_label = QLabel()
|
|
||||||
self._spinner_label.setFixedSize(20, 20)
|
|
||||||
self._spinner_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
||||||
self._spinner_label.hide()
|
|
||||||
self._spinner_angle = 0
|
|
||||||
self._spinner_timer = QTimer()
|
|
||||||
self._spinner_timer.setInterval(80)
|
|
||||||
self._spinner_timer.timeout.connect(self._update_spinner)
|
|
||||||
|
|
||||||
self.dlbutton = QtWidgets.QPushButton("Download")
|
self.dlbutton = QtWidgets.QPushButton("Download")
|
||||||
self.dlbutton.setCursor(Qt.CursorShape.PointingHandCursor)
|
self.dlbutton.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||||
self.libraryList = QListWidget()
|
self.libraryList = QListWidget()
|
||||||
@@ -368,7 +329,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
|
|
||||||
search_row = QHBoxLayout()
|
search_row = QHBoxLayout()
|
||||||
search_row.addWidget(self.searchbar)
|
search_row.addWidget(self.searchbar)
|
||||||
search_row.addWidget(self._spinner_label)
|
|
||||||
containerLayout.addLayout(search_row)
|
containerLayout.addLayout(search_row)
|
||||||
containerLayout.addWidget(state.tracker_list[state.tracker])
|
containerLayout.addWidget(state.tracker_list[state.tracker])
|
||||||
|
|
||||||
@@ -733,10 +693,6 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.context_menu.addAction("Delete File", self.deleteFileAction)
|
self.context_menu.addAction("Delete File", self.deleteFileAction)
|
||||||
|
|
||||||
def _start_search(self):
|
def _start_search(self):
|
||||||
self._spinner_label.show()
|
|
||||||
self._spinner_angle = 0
|
|
||||||
self._spinner_timer.start()
|
|
||||||
self._update_spinner()
|
|
||||||
self.searchbar.setEnabled(False)
|
self.searchbar.setEnabled(False)
|
||||||
def _search_thread():
|
def _search_thread():
|
||||||
try:
|
try:
|
||||||
@@ -746,18 +702,9 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
run_thread(threading.Thread(target=_search_thread))
|
run_thread(threading.Thread(target=_search_thread))
|
||||||
|
|
||||||
def _on_search_finished(self):
|
def _on_search_finished(self):
|
||||||
self._spinner_timer.stop()
|
|
||||||
self._spinner_label.hide()
|
|
||||||
self.searchbar.setEnabled(True)
|
self.searchbar.setEnabled(True)
|
||||||
self.searchbar.setFocus()
|
self.searchbar.setFocus()
|
||||||
|
|
||||||
def _update_spinner(self):
|
|
||||||
frames = ["◐", "◓", "◑", "◒"]
|
|
||||||
idx = (self._spinner_angle // 1) % len(frames)
|
|
||||||
self._spinner_label.setText(frames[idx])
|
|
||||||
self._spinner_label.setStyleSheet("font-size: 16px; color: gray;")
|
|
||||||
self._spinner_angle += 1
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_log(text):
|
def add_log(text):
|
||||||
if MainWindow._instance:
|
if MainWindow._instance:
|
||||||
|
|||||||
Reference in New Issue
Block a user