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

Add the Welcome Wizard #1043

Merged
merged 6 commits into from
May 21, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 8 additions & 82 deletions wingetui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def forceContinue():
self.loadStatus = 1000 # Override loading status

skipButton.clicked.connect(forceContinue)
Thread(target=lambda: (time.sleep(15), self.callInMain.emit(skipButton.show)), daemon=True).start()


self.textEnterAnim = QVariantAnimation(self)
self.textEnterAnim.setStartValue(0)
Expand Down Expand Up @@ -209,94 +209,20 @@ def forceContinue():
def increaseStep():
self.loadStatus += 1
self.finishedPreloadingStep.connect(increaseStep)
if getSettings("AskedAbout3PackageManagers") == False or "--welcomewizard" in sys.argv:
self.askAboutPackageManagers(onclose=lambda: Thread(target=self.loadPreUIComponents, daemon=True).start())
if getSettings("ShownWelcomeWizard") == False or "--welcomewizard" in sys.argv or "--welcome" in sys.argv:
self.askAboutPackageManagers(onclose=lambda: (Thread(target=self.loadPreUIComponents, daemon=True).start(), Thread(target=lambda: (time.sleep(15), self.callInMain.emit(skipButton.show)), daemon=True).start()))
else:
Thread(target=self.loadPreUIComponents, daemon=True).start()
Thread(target=lambda: (time.sleep(15), self.callInMain.emit(skipButton.show)), daemon=True).start()
self.loadingText.setText(_("Checking for other running instances..."))
except Exception as e:
raise e

def askAboutPackageManagers(self, onclose: object):
self.w = NotClosableWidget()
self.w.setObjectName("micawin")
self.w.setWindowFlag(Qt.WindowType.Window)
self.w.setWindowTitle("\x20")
pixmap = QPixmap(4, 4)
pixmap.fill(Qt.GlobalColor.transparent)
self.w.setWindowIcon(pixmap)
self.w.setAutoFillBackground(True)
self.w.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint, False)
self.w.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
self.w.setWindowFlag(Qt.WindowType.WindowCloseButtonHint, False)
self.w.setWindowModality(Qt.WindowModality.WindowModal)

self.w.setMinimumWidth(750)
self.w.setContentsMargins(20, 0, 20, 10)
mainLayout = QVBoxLayout()
label = (QLabel("<p style='font-size: 25pt;font-weight: bold;'>"+_("Welcome to WingetUI")+"</p><p style='font-size: 17pt;font-weight: bold;'>"+_("You may now choose your weapons")+"</p>"))
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
label.setWordWrap(True)
mainLayout.addWidget(label)
label = (QLabel(_("WingetUI is based on package managers. They are the engines used to load, install update and remove software from your computer. Please select the desired package managers and hit \"Apply\" to continue. The default ones are Winget and Chocolatey")))
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
label.setWordWrap(True)
mainLayout.addWidget(label)

winget = WelcomeWizardPackageManager(_("Enable {pm}").format(pm="Winget"), _("Microsoft's official package manager. It contains well known software such as browsers, PDF readers, windows add-ons and other utilities, as well as other less-known but useful software, such as Microsoft Visual C++ Redistributables. Packages from Winget have been carefully validated"), getMedia("winget"))
winget.setChecked(True)
scoop = WelcomeWizardPackageManager(_("Enable {pm}").format(pm="Scoop"), _("From scoop you will be able to download utilities that might not be suitable for everybody. Install CLI utilities such as nano, sudo or nmap for Windows. And with the ability to add custom buckets, you will be able to download unlimited amounts of different utilities, apps, fonts, games, and any other thing you can dream of."), getMedia("scoop"))
scoop.setChecked(False)
if (getSettings("ScoopAlreadySetup") or getSettings("ScoopEnabledByAssistant")) and not getSettings("DisableScoop"):
scoop.setChecked(True)
choco = WelcomeWizardPackageManager(_("Enable {pm}").format(pm="Chocolatey"), _("The package manager for Windows by default. With more than {0} packages on their repositories, you will find anything you want to install. From Firefox to Sysinternals, almost every package is available to download from Chocolatey servers").format("9500"), getMedia("choco"))
choco.setChecked(True)

mainLayout.addSpacing(20)
mainLayout.addWidget(winget)
mainLayout.addWidget(scoop)
mainLayout.addWidget(choco)
mainLayout.addSpacing(20)

mainLayout.addStretch()

blayout = QHBoxLayout()
mainLayout.addLayout(blayout)
blayout.addStretch()

def performSelectionAndContinue():
self.w.close()
setSettings("AskedAbout3PackageManagers", True)
setSettings("DisableWinget", not winget.isChecked())
setSettings("DisableScoop", not scoop.isChecked())
setSettings("ScoopEnabledByAssistant", scoop.isChecked())
setSettings("DisableChocolatey", not choco.isChecked())
if choco.isChecked() and shutil.which("choco") != None:
setSettings("UseSystemChocolatey", True)
if scoop.isChecked() and shutil.which("scoop") == None:
os.startfile(os.path.join(realpath, "resources/install_scoop.cmd"))
else:
onclose()

okbutton = QPushButton(_("Apply and start WingetUI"))
okbutton.setFixedSize(190, 30)
okbutton.setObjectName("AccentButton")
okbutton.clicked.connect(performSelectionAndContinue)
blayout.addWidget(okbutton)

w = QWidget(self.w)
w.setObjectName("mainbg")
w.setLayout(mainLayout)
l = QHBoxLayout()
l.addWidget(w)
self.w.setLayout(l)

r = ApplyMica(self.w.winId(), MICAMODE.DARK if isDark() else MICAMODE.LIGHT)
if r != 0:
self.w.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, False)
self.w.setAttribute(Qt.WidgetAttribute.WA_NoSystemBackground, False)
self.w.setStyleSheet(darkCSS.replace("mainbg", "transparent" if r == 0x0 else "#202020") if isDark() else lightCSS.replace("mainbg", "transparent" if r == 0x0 else "#f5f5f5"))
self.w.show()
import welcome
self.ww = welcome.WelcomeWindow(callback=lambda: (self.popup.show(), onclose()))
self.popup.hide()
self.ww.show()

def loadPreUIComponents(self):
try:
Expand Down
18 changes: 9 additions & 9 deletions wingetui/customWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,22 +534,22 @@ def __init__(self, text, description, image) -> None:
mainw.setContentsMargins(0, 0, 0, 0)
mainw.setObjectName("bgwidget")
mainw.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
self.checkbox = SectionCheckBox(text, mainw, margin=0, bigfont=True)
self.checkbox = QCheckBox(text)
self.checkbox.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, False)
self.checkbox.stateChanged.connect(lambda v: (self.description.setEnabled(v), self.image.setEnabled(v)))
self.checkbox.setFixedHeight(30)
self.description = QLabel(description)
self.checkbox.stateChanged.connect(lambda v: (self.image.setEnabled(v)))
self.checkbox.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
self.description = ClickableLabel(description)
self.description.clicked.connect(self.checkbox.click)
self.description.setWordWrap(True)
self.description.setEnabled(False)
self.image = QLabel()
self.image.setPixmap(QPixmap(image).scaledToHeight(64, Qt.TransformationMode.SmoothTransformation))
self.image.setPixmap(QPixmap(image).scaledToHeight(48, Qt.TransformationMode.SmoothTransformation))
h = QHBoxLayout()
v = QVBoxLayout()
v.addWidget(self.checkbox)
v.addWidget(self.description, stretch=1)
h.addLayout(v, stretch=1)
h.addWidget(self.image)
h.setContentsMargins(16, 16, 16, 16)
h.setContentsMargins(12, 8, 16, 8)
h2 = QHBoxLayout()
h.addStretch()
mainw.setLayout(h)
Expand All @@ -560,9 +560,9 @@ def __init__(self, text, description, image) -> None:
mainw.setFixedWidth(600)
self.setLayout(h2)
if isDark():
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 5%); border: 1px solid #101010; padding: 16px; border-radius: 16px;}""")
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 5%); border: 1px solid #101010; padding: 8px; border-radius: 8px;}""")
else:
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 50%); border: 1px solid #eeeeee; padding: 16px; border-radius: 16px;}""")
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 50%); border: 1px solid #eeeeee; padding: 8px; border-radius: 8px;}""")

def setChecked(self, v: bool) -> None:
self.checkbox.setChecked(v)
Expand Down
26 changes: 19 additions & 7 deletions wingetui/genericCustomWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,11 @@ def calculateSize(self) -> None:
"""
Recalculates minimum height
"""
if self.getFullHeight() >= self.maxHeight:
self.setFixedHeight(self.maxHeight)
else:
self.setFixedHeight(self.getFullHeight() if self.getFullHeight() > 20 else 4)
if self.resizeBar:
if self.getFullHeight() >= self.maxHeight:
self.setFixedHeight(self.maxHeight)
else:
self.setFixedHeight(self.getFullHeight() if self.getFullHeight() > 20 else 4)

def getFullHeight(self) -> int:
"""
Expand All @@ -325,15 +326,16 @@ def removeItem(self, item: QWidget):
self.vlayout.removeWidget(item)
self.rss()
self.itemCount = self.vlayout.count()
if self.itemCount <= 0:
if self.itemCount <= 0 and self.resizeBar:
globals.trayIcon.setIcon(QIcon(getMedia("greyicon")))
self.resizeBar.hide()

def addItem(self, item: QWidget):
self.vlayout.addWidget(item)
self.itemCount = self.vlayout.count()
self.resizeBar.show()
globals.trayIcon.setIcon(QIcon(getMedia("icon")))
if self.resizeBar:
self.resizeBar.show()
globals.trayIcon.setIcon(QIcon(getMedia("icon")))

class TreeWidgetItemWithQAction(QTreeWidgetItem):
itemAction: QAction = QAction
Expand Down Expand Up @@ -1191,6 +1193,16 @@ def closeEvent(self, event: QCloseEvent) -> None:
globals.app.restoreOverrideCursor()
return super().closeEvent(event)

class ClickableLabel(QLabel):
clicked = Signal()

def __init__(self, text: str = "", parent: QWidget = None):
super().__init__(text, parent)
self.setMouseTracking(True)

def mousePressEvent(self, ev: QMouseEvent) -> None:
self.clicked.emit()
return super().mousePressEvent(ev)

if __name__ == "__main__":
import __init__
Binary file added wingetui/resources/admin_color.png
Loading
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/agreement.png
Loading
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/choco_color.png
Loading
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/coffee.png
Loading
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/console_color.png
Loading
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/empty.png
Loading
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/finish.png
Loading
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/github.png
Loading
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/hacker.png
Loading
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/kofi.png
Loading
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/next_black.png
Loading
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/next_white.png
Loading
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/node_color.png
Loading
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/pip_color.png
Loading
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/previous_black.png
Loading
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/previous_white.png
Loading
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/rocket.png
Loading
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/scoop_color.png
Loading
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/shield_green.png
Loading
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/shield_question.png
Loading
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/shield_red.png
Loading
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/shield_reload.png
Loading
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/shield_yellow.png
Loading
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/simple_user.png
Loading
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/update_pc_color.png
Loading
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/winget_color.png
Binary file added wingetui/resources/youtube.png
1 change: 0 additions & 1 deletion wingetui/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def isDark() -> bool:
return False
return SYSTEM_THEME_ON_LAUNCH == 0


def queueProgram(id: str):
globals.pending_programs.append(id)

Expand Down
Loading