Skip to content

Commit 0c08240

Browse files
authored
Merge pull request #1043 from marticliment/welcome-wizard
Add the Welcome Wizard
2 parents 31608a3 + eccea5b commit 0c08240

32 files changed

+1290
-99
lines changed

wingetui/__init__.py

Lines changed: 8 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def forceContinue():
126126
self.loadStatus = 1000 # Override loading status
127127

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

131131
self.textEnterAnim = QVariantAnimation(self)
132132
self.textEnterAnim.setStartValue(0)
@@ -209,94 +209,20 @@ def forceContinue():
209209
def increaseStep():
210210
self.loadStatus += 1
211211
self.finishedPreloadingStep.connect(increaseStep)
212-
if getSettings("AskedAbout3PackageManagers") == False or "--welcomewizard" in sys.argv:
213-
self.askAboutPackageManagers(onclose=lambda: Thread(target=self.loadPreUIComponents, daemon=True).start())
212+
if getSettings("ShownWelcomeWizard") == False or "--welcomewizard" in sys.argv or "--welcome" in sys.argv:
213+
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()))
214214
else:
215215
Thread(target=self.loadPreUIComponents, daemon=True).start()
216+
Thread(target=lambda: (time.sleep(15), self.callInMain.emit(skipButton.show)), daemon=True).start()
216217
self.loadingText.setText(_("Checking for other running instances..."))
217218
except Exception as e:
218219
raise e
219220

220221
def askAboutPackageManagers(self, onclose: object):
221-
self.w = NotClosableWidget()
222-
self.w.setObjectName("micawin")
223-
self.w.setWindowFlag(Qt.WindowType.Window)
224-
self.w.setWindowTitle("\x20")
225-
pixmap = QPixmap(4, 4)
226-
pixmap.fill(Qt.GlobalColor.transparent)
227-
self.w.setWindowIcon(pixmap)
228-
self.w.setAutoFillBackground(True)
229-
self.w.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint, False)
230-
self.w.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint, False)
231-
self.w.setWindowFlag(Qt.WindowType.WindowCloseButtonHint, False)
232-
self.w.setWindowModality(Qt.WindowModality.WindowModal)
233-
234-
self.w.setMinimumWidth(750)
235-
self.w.setContentsMargins(20, 0, 20, 10)
236-
mainLayout = QVBoxLayout()
237-
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>"))
238-
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
239-
label.setWordWrap(True)
240-
mainLayout.addWidget(label)
241-
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")))
242-
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
243-
label.setWordWrap(True)
244-
mainLayout.addWidget(label)
245-
246-
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"))
247-
winget.setChecked(True)
248-
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"))
249-
scoop.setChecked(False)
250-
if (getSettings("ScoopAlreadySetup") or getSettings("ScoopEnabledByAssistant")) and not getSettings("DisableScoop"):
251-
scoop.setChecked(True)
252-
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"))
253-
choco.setChecked(True)
254-
255-
mainLayout.addSpacing(20)
256-
mainLayout.addWidget(winget)
257-
mainLayout.addWidget(scoop)
258-
mainLayout.addWidget(choco)
259-
mainLayout.addSpacing(20)
260-
261-
mainLayout.addStretch()
262-
263-
blayout = QHBoxLayout()
264-
mainLayout.addLayout(blayout)
265-
blayout.addStretch()
266-
267-
def performSelectionAndContinue():
268-
self.w.close()
269-
setSettings("AskedAbout3PackageManagers", True)
270-
setSettings("DisableWinget", not winget.isChecked())
271-
setSettings("DisableScoop", not scoop.isChecked())
272-
setSettings("ScoopEnabledByAssistant", scoop.isChecked())
273-
setSettings("DisableChocolatey", not choco.isChecked())
274-
if choco.isChecked() and shutil.which("choco") != None:
275-
setSettings("UseSystemChocolatey", True)
276-
if scoop.isChecked() and shutil.which("scoop") == None:
277-
os.startfile(os.path.join(realpath, "resources/install_scoop.cmd"))
278-
else:
279-
onclose()
280-
281-
okbutton = QPushButton(_("Apply and start WingetUI"))
282-
okbutton.setFixedSize(190, 30)
283-
okbutton.setObjectName("AccentButton")
284-
okbutton.clicked.connect(performSelectionAndContinue)
285-
blayout.addWidget(okbutton)
286-
287-
w = QWidget(self.w)
288-
w.setObjectName("mainbg")
289-
w.setLayout(mainLayout)
290-
l = QHBoxLayout()
291-
l.addWidget(w)
292-
self.w.setLayout(l)
293-
294-
r = ApplyMica(self.w.winId(), MICAMODE.DARK if isDark() else MICAMODE.LIGHT)
295-
if r != 0:
296-
self.w.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, False)
297-
self.w.setAttribute(Qt.WidgetAttribute.WA_NoSystemBackground, False)
298-
self.w.setStyleSheet(darkCSS.replace("mainbg", "transparent" if r == 0x0 else "#202020") if isDark() else lightCSS.replace("mainbg", "transparent" if r == 0x0 else "#f5f5f5"))
299-
self.w.show()
222+
import welcome
223+
self.ww = welcome.WelcomeWindow(callback=lambda: (self.popup.show(), onclose()))
224+
self.popup.hide()
225+
self.ww.show()
300226

301227
def loadPreUIComponents(self):
302228
try:

wingetui/customWidgets.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,22 +534,22 @@ def __init__(self, text, description, image) -> None:
534534
mainw.setContentsMargins(0, 0, 0, 0)
535535
mainw.setObjectName("bgwidget")
536536
mainw.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
537-
self.checkbox = SectionCheckBox(text, mainw, margin=0, bigfont=True)
537+
self.checkbox = QCheckBox(text)
538538
self.checkbox.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, False)
539-
self.checkbox.stateChanged.connect(lambda v: (self.description.setEnabled(v), self.image.setEnabled(v)))
540-
self.checkbox.setFixedHeight(30)
541-
self.description = QLabel(description)
539+
self.checkbox.stateChanged.connect(lambda v: (self.image.setEnabled(v)))
540+
self.checkbox.setSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum)
541+
self.description = ClickableLabel(description)
542+
self.description.clicked.connect(self.checkbox.click)
542543
self.description.setWordWrap(True)
543-
self.description.setEnabled(False)
544544
self.image = QLabel()
545-
self.image.setPixmap(QPixmap(image).scaledToHeight(64, Qt.TransformationMode.SmoothTransformation))
545+
self.image.setPixmap(QPixmap(image).scaledToHeight(48, Qt.TransformationMode.SmoothTransformation))
546546
h = QHBoxLayout()
547547
v = QVBoxLayout()
548548
v.addWidget(self.checkbox)
549549
v.addWidget(self.description, stretch=1)
550550
h.addLayout(v, stretch=1)
551551
h.addWidget(self.image)
552-
h.setContentsMargins(16, 16, 16, 16)
552+
h.setContentsMargins(12, 8, 16, 8)
553553
h2 = QHBoxLayout()
554554
h.addStretch()
555555
mainw.setLayout(h)
@@ -560,9 +560,9 @@ def __init__(self, text, description, image) -> None:
560560
mainw.setFixedWidth(600)
561561
self.setLayout(h2)
562562
if isDark():
563-
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 5%); border: 1px solid #101010; padding: 16px; border-radius: 16px;}""")
563+
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 5%); border: 1px solid #101010; padding: 8px; border-radius: 8px;}""")
564564
else:
565-
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 50%); border: 1px solid #eeeeee; padding: 16px; border-radius: 16px;}""")
565+
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 50%); border: 1px solid #eeeeee; padding: 8px; border-radius: 8px;}""")
566566

567567
def setChecked(self, v: bool) -> None:
568568
self.checkbox.setChecked(v)

wingetui/genericCustomWidgets.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,11 @@ def calculateSize(self) -> None:
310310
"""
311311
Recalculates minimum height
312312
"""
313-
if self.getFullHeight() >= self.maxHeight:
314-
self.setFixedHeight(self.maxHeight)
315-
else:
316-
self.setFixedHeight(self.getFullHeight() if self.getFullHeight() > 20 else 4)
313+
if self.resizeBar:
314+
if self.getFullHeight() >= self.maxHeight:
315+
self.setFixedHeight(self.maxHeight)
316+
else:
317+
self.setFixedHeight(self.getFullHeight() if self.getFullHeight() > 20 else 4)
317318

318319
def getFullHeight(self) -> int:
319320
"""
@@ -325,15 +326,16 @@ def removeItem(self, item: QWidget):
325326
self.vlayout.removeWidget(item)
326327
self.rss()
327328
self.itemCount = self.vlayout.count()
328-
if self.itemCount <= 0:
329+
if self.itemCount <= 0 and self.resizeBar:
329330
globals.trayIcon.setIcon(QIcon(getMedia("greyicon")))
330331
self.resizeBar.hide()
331332

332333
def addItem(self, item: QWidget):
333334
self.vlayout.addWidget(item)
334335
self.itemCount = self.vlayout.count()
335-
self.resizeBar.show()
336-
globals.trayIcon.setIcon(QIcon(getMedia("icon")))
336+
if self.resizeBar:
337+
self.resizeBar.show()
338+
globals.trayIcon.setIcon(QIcon(getMedia("icon")))
337339

338340
class TreeWidgetItemWithQAction(QTreeWidgetItem):
339341
itemAction: QAction = QAction
@@ -1191,6 +1193,16 @@ def closeEvent(self, event: QCloseEvent) -> None:
11911193
globals.app.restoreOverrideCursor()
11921194
return super().closeEvent(event)
11931195

1196+
class ClickableLabel(QLabel):
1197+
clicked = Signal()
1198+
1199+
def __init__(self, text: str = "", parent: QWidget = None):
1200+
super().__init__(text, parent)
1201+
self.setMouseTracking(True)
1202+
1203+
def mousePressEvent(self, ev: QMouseEvent) -> None:
1204+
self.clicked.emit()
1205+
return super().mousePressEvent(ev)
11941206

11951207
if __name__ == "__main__":
11961208
import __init__

wingetui/resources/admin_color.png

5.65 KB
Loading

wingetui/resources/agreement.png

4.97 KB
Loading

wingetui/resources/choco_color.png

16.8 KB
Loading

wingetui/resources/coffee.png

2.46 KB
Loading

wingetui/resources/console_color.png

2.61 KB
Loading

wingetui/resources/empty.png

102 Bytes
Loading

wingetui/resources/finish.png

3.79 KB
Loading

wingetui/resources/github.png

7.34 KB
Loading

wingetui/resources/hacker.png

81.9 KB
Loading

wingetui/resources/kofi.png

10.3 KB
Loading

wingetui/resources/next_black.png

1.09 KB
Loading

wingetui/resources/next_white.png

1.09 KB
Loading

wingetui/resources/node_color.png

4.44 KB
Loading

wingetui/resources/pip_color.png

2.36 KB
Loading

wingetui/resources/previous_black.png

285 Bytes
Loading

wingetui/resources/previous_white.png

285 Bytes
Loading

wingetui/resources/rocket.png

5.98 KB
Loading

wingetui/resources/scoop_color.png

2.95 KB
Loading

wingetui/resources/shield_green.png

3.41 KB
Loading
6.49 KB
Loading

wingetui/resources/shield_red.png

7.15 KB
Loading

wingetui/resources/shield_reload.png

6.33 KB
Loading

wingetui/resources/shield_yellow.png

5.02 KB
Loading

wingetui/resources/simple_user.png

4.86 KB
Loading
6.28 KB
Loading

wingetui/resources/winget_color.png

766 Bytes
Loading

wingetui/resources/youtube.png

1.75 KB
Loading

wingetui/tools.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def isDark() -> bool:
181181
return False
182182
return SYSTEM_THEME_ON_LAUNCH == 0
183183

184-
185184
def queueProgram(id: str):
186185
globals.pending_programs.append(id)
187186

0 commit comments

Comments
 (0)