Skip to content
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
66 changes: 64 additions & 2 deletions wingetui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,73 @@ def __init__(self):
os.chdir(os.path.expanduser("~"))
self.kill.connect(lambda: (self.popup.hide(), sys.exit(0)))
self.callInMain.connect(lambda f: f())
Thread(target=self.loadStuffThread, daemon=True).start()
self.loadingText.setText(_("Checking for other running instances..."))
if getSettings("AskedAbout3PackageManagers") == False:
self.askAboutPackageManagers(onclose=lambda: Thread(target=self.loadStuffThread, daemon=True).start())
else:
Thread(target=self.loadStuffThread, 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.setWindowFlag(Qt.WindowType.Window)
self.w.setWindowTitle(_("\x20"))
pixmap = QPixmap(4, 4)
pixmap.fill(Qt.GlobalColor.transparent)
self.w.setWindowIcon(pixmap)
self.w.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
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 = PackageManager(_("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 = PackageManager(_("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") and not getSettings("DisableScoop"):
scoop.setChecked(True)
choco = PackageManager(_("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()

okbutton = QPushButton(_("Apply and start WingetUI"))
okbutton.setFixedSize(190, 30)
okbutton.setObjectName("AccentButton")
okbutton.clicked.connect(lambda: (self.w.close(), onclose(), setSettings("AskedAbout3PackageManagers", True), setSettings("DisableWinget", not winget.isChecked()), setSettings("DisableScoop", not scoop.isChecked()), setSettings("DisableChocolatey", not choco.isChecked())))
blayout.addWidget(okbutton)

self.w.setLayout(mainLayout)
self.setStyleSheet(darkCSS if isDark() else lightCSS)
self.w.show()
ApplyMica(self.w.winId(), MICAMODE.DARK if isDark() else MICAMODE.LIGHT)

def loadStuffThread(self):
try:
self.loadStatus = 0 # There are 9 items (preparation threads)
Expand Down
70 changes: 62 additions & 8 deletions wingetui/customWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,19 +998,21 @@ def text(self) -> str:

class QSettingsCheckBox(QWidget):
stateChanged = Signal(bool)
def __init__(self, text="", parent=None):
def __init__(self, text="", parent=None, margin=70, bigfont = False):
self.margin = margin
super().__init__(parent)
self.setAttribute(Qt.WA_StyledBackground)
self.setObjectName("stChkBg")
self.checkbox = QCheckBox(text, self)
if lang["locale"] == "zh_TW":
self.checkbox.setStyleSheet("font-size: 11pt;background: none;font-family: \"Microsoft JhengHei UI\";font-weight: 450;")
self.checkbox.setStyleSheet(f"font-size: {14 if bigfont else 11}pt;background: none;font-family: \"Microsoft JhengHei UI\";font-weight: {700 if bigfont else 450};")
elif lang["locale"] == "zh_CN":
self.checkbox.setStyleSheet("font-size: 11pt;background: none;font-family: \"Microsoft YaHei UI\";font-weight: 450;")
self.checkbox.setStyleSheet(f"font-size: {14 if bigfont else 11}pt;background: none;font-family: \"Microsoft YaHei UI\";font-weight: {700 if bigfont else 450};")
else:
self.checkbox.setStyleSheet("font-size: 9pt;background: none;font-family: \"Segoe UI Variable Text\";font-weight: 450;")
self.checkbox.setStyleSheet(f"font-size: {14 if bigfont else 9}pt;background: none;font-family: \"Segoe UI Variable {'Display' if bigfont else 'Text'}\";font-weight: {700 if bigfont else 450};")
self.checkbox.setObjectName("stChk")
self.checkbox.stateChanged.connect(self.stateChanged.emit)
self.setFixedHeight(50)

def setChecked(self, checked: bool) -> None:
self.checkbox.setChecked(checked)
Expand All @@ -1022,10 +1024,12 @@ def get6px(self, i: int) -> int:
return round(i*self.screen().devicePixelRatio())

def resizeEvent(self, event: QResizeEvent) -> None:
self.checkbox.move((70), 10)
if self.height() != 30:
self.checkbox.move((self.margin), 10)
else:
self.checkbox.move((self.margin), 0)
self.checkbox.setFixedHeight(30)
self.checkbox.setFixedWidth(self.width()-(70))
self.setFixedHeight(50)
self.checkbox.setFixedWidth(self.width()-(self.margin))
return super().resizeEvent(event)

def text(self) -> str:
Expand Down Expand Up @@ -1110,7 +1114,57 @@ def setText(self, text: str) -> None:
def setIcon(self, icon: QIcon) -> None:
self.image.setPixmap(icon.pixmap(QSize(self.image.size())))


class NotClosableWidget(QWidget):
def closeEvent(self, event: QCloseEvent) -> None:
if event.spontaneous():
event.ignore()
return False
else:
event.accept()
return super().closeEvent(event)

class PackageManager(QWidget):
def __init__(self, text, description, image) -> None:
super().__init__()
mainw = QWidget(self)
mainw.setContentsMargins(0, 0, 0, 0)
mainw.setObjectName("bgwidget")
mainw.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
self.checkbox = QSettingsCheckBox(text, mainw, margin=0, bigfont=True)
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.description.setWordWrap(True)
self.description.setEnabled(False)
self.image = QLabel()
self.image.setPixmap(QPixmap(image).scaledToHeight(64, 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)
h2 = QHBoxLayout()
h.addStretch()
mainw.setLayout(h)
h2.addStretch()
h2.addWidget(mainw)
h2.setContentsMargins(0, 0, 0, 0)
h2.addStretch()
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;}""")
else:
self.setStyleSheet("""#bgwidget{background-color: rgba(255, 255, 255, 50%); border: 1px solid #eeeeee; padding: 16px; border-radius: 16px;}""")

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

def isChecked(self) -> bool:
return self.checkbox.isChecked()

if __name__ == "__main__":
import __init__
2 changes: 0 additions & 2 deletions wingetui/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ def resetSelectionIndex():
sct = QShortcut(QKeySequence("Ctrl+Shift+Tab"), self)
sct.activated.connect(lambda: (self.mainWidget.setCurrentIndex((self.mainWidget.currentIndex() - 1) if self.mainWidget.currentIndex() > 0 else 3), self.buttonBox.buttons()[self.mainWidget.currentIndex()].setChecked(True)))



def addTab(self, widget: QWidget, label: str, addToMenu: bool = False, actionIcon: str = "") -> QPushButton:
i = self.mainWidget.addWidget(widget)
btn = PushButtonWithAction(label)
Expand Down