Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle need restart after installation for winget #626

Merged
merged 4 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3,367 changes: 1,701 additions & 1,666 deletions media/customcolor_icon.ai

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions wingetui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self):
titlewidget = QHBoxLayout()
titlewidget.addStretch()
icon = QLabel()
icon.setPixmap(QPixmap(realpath+"/resources/icon.png").scaledToWidth(128, Qt.TransformationMode.SmoothTransformation))
icon.setPixmap(QPixmap(getMedia("icon", autoIconMode = False)).scaledToWidth(128, Qt.TransformationMode.SmoothTransformation))
text = QLabel("WingetUI")
text.setStyleSheet(f"font-family: \"{globals.dispfont}\";font-weight: bold; color: {'white' if isDark() else 'black'};font-size: 50pt;")
titlewidget.addWidget(icon)
Expand Down Expand Up @@ -285,7 +285,7 @@ def loadMainUI(self):
globals.trayIcon = QSystemTrayIcon()
self.trayIcon = globals.trayIcon
globals.app = self
self.trayIcon.setIcon(QIcon(realpath+"/resources/icon.png"))
self.trayIcon.setIcon(QIcon(getMedia("icon", autoIconMode = False)))
self.trayIcon.setToolTip("WingetUI")
self.trayIcon.setVisible(True)

Expand Down
4 changes: 3 additions & 1 deletion wingetui/chocoHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ def uninstallAssistant(p: subprocess.Popen, closeAndInform: Signal, infoSignal:
p.wait()
cprint(output)
outputCode = p.returncode
if outputCode in (1605, 1614, 1641, 3010):
if outputCode in (1605, 1614, 1641):
outputCode = 0
elif outputCode == 3010:
outputCode = 3
closeAndInform.emit(outputCode, output)


Expand Down
2 changes: 1 addition & 1 deletion wingetui/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self):
self.setWindowTitle("WingetUI")
self.setMinimumSize(700, 560)
self.setObjectName("micawin")
self.setWindowIcon(QIcon(realpath+"/resources/icon.png"))
self.setWindowIcon(QIcon(getMedia("icon", autoIconMode = False)))
self.resize(QSize(1100, 700))
try:
rs = getSettingsValue("OldWindowGeometry").split(",")
Expand Down
Binary file added wingetui/resources/notif_restart.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wingetui/resources/restart_color.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
227 changes: 112 additions & 115 deletions wingetui/storeEngine.py

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions wingetui/tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from ast import Attribute
import shutil
import winreg
import io
Expand All @@ -7,11 +6,11 @@
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
from win32mica import ApplyMica, MICAMODE
from urllib.request import urlopen
from versions import *
from languages import *
from external.blurwindow import GlobalBlur
from pathlib import Path

import globals

Expand Down Expand Up @@ -241,16 +240,18 @@ def ApplyMenuBlur(hwnd: int, window: QWidget, smallCorners: bool = False, avoidO
#QtWin.extendFrameIntoClientArea(window, -1, -1, -1, -1)


def getPath(s):
return os.path.join(os.path.join(realpath, "resources"), s).replace("\\", "/")
def getPath(s: str) -> str:
return str(Path(f"{realpath}/resources/{s}").resolve()).replace("\\", "/")

def getIconMode() -> str:
return "white" if isDark() else "black"

def getMedia(m: str) -> str:
filename = getPath(m+"_"+getIconMode()+".png")
if not os.path.exists(filename):
filename = getPath(m+".png")
def getMedia(m: str, autoIconMode = True) -> str:
filename = ""
if autoIconMode == True:
filename = getPath(f"{m}_{getIconMode()}.png")
if not filename or not os.path.exists(filename):
filename = getPath(f"{m}.png")
return filename

def getint(s: str, fallback: int) -> int:
Expand Down
18 changes: 10 additions & 8 deletions wingetui/wingetHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def searchForUpdates(signal: Signal, finishSignal: Signal, noretry: bool = False
verSeparator = len(l.split("Version")[0])
newVerSeparator = len(l.split("Available")[0])
counter += 1

if p.returncode != 0 and not noretry:
time.sleep(1)
print(p.returncode)
Expand Down Expand Up @@ -354,10 +354,9 @@ def getInfo(signal: Signal, title: str, id: str, useId: bool) -> None:
signal.emit(appInfo)
except Exception as e:
report(e)

def installAssistant(p: subprocess.Popen, closeAndInform: Signal, infoSignal: Signal, counterSignal: Signal) -> None:
print(f"🟢 winget installer assistant thread started for process {p}")
outputCode = 0
counter = 0
output = ""
while p.poll() is None:
Expand All @@ -370,14 +369,17 @@ def installAssistant(p: subprocess.Popen, closeAndInform: Signal, infoSignal: Si
counterSignal.emit(counter)
output += line+"\n"
p.wait()
outputCode = p.returncode
if outputCode == 0x8A150011:
outputCode = 2
match p.returncode:
case 0x8A150011:
outputCode = 2
case 0x8A150109: # need restart
outputCode = 3
case other:
outputCode = p.returncode
closeAndInform.emit(outputCode, output)

def uninstallAssistant(p: subprocess.Popen, closeAndInform: Signal, infoSignal: Signal, counterSignal: Signal) -> None:
print(f"🟢 winget installer assistant thread started for process {p}")
outputCode = 0
counter = 0
output = ""
while p.poll() is None:
Expand Down