mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
allow multiple tendies files
This commit is contained in:
@@ -19,7 +19,7 @@ from tweaks.custom_gestalt_tweaks import CustomGestaltTweaks, ValueTypeStrings
|
||||
from tweaks.daemons_tweak import Daemon
|
||||
|
||||
App_Version = "5.0"
|
||||
App_Build = 4
|
||||
App_Build = 5
|
||||
|
||||
class Page(Enum):
|
||||
Home = 0
|
||||
@@ -160,7 +160,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
## POSTERBOARD PAGE ACTIONS
|
||||
self.ui.modifyPosterboardsChk.toggled.connect(self.on_modifyPosterboardsChk_clicked)
|
||||
self.ui.selectPosterboardBtn.clicked.connect(self.on_selectPosterboardBtn_clicked)
|
||||
self.ui.importTendiesBtn.clicked.connect(self.on_importTendiesBtn_clicked)
|
||||
self.ui.resetPRBExtBtn.clicked.connect(self.on_resetPRBExtBtn_clicked)
|
||||
self.ui.deleteAllDescriptorsBtn.clicked.connect(self.on_deleteAllDescriptorsBtn_clicked)
|
||||
|
||||
@@ -219,6 +219,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.ui.resChangerContent.hide()
|
||||
self.ui.resHeightWarningLbl.hide()
|
||||
self.ui.resWidthWarningLbl.hide()
|
||||
self.ui.pbActionLbl.hide()
|
||||
|
||||
|
||||
## GENERAL INTERFACE FUNCTIONS
|
||||
@@ -834,38 +835,125 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
tweaks["Daemons"].set_multiple_values(Daemon.VoiceControl.value, value=checked)
|
||||
|
||||
## PosterBoard Page
|
||||
def delete_pb_file(self, file):
|
||||
if file in tweaks["PosterBoard"].zip_paths:
|
||||
tweaks["PosterBoard"].zip_paths.remove(file)
|
||||
#self.load_posterboard()
|
||||
|
||||
def load_posterboard(self):
|
||||
# Clear the layout
|
||||
layout = self.ui.pbFilesList.layout()
|
||||
if layout:
|
||||
while layout.count():
|
||||
child = layout.takeAt(0)
|
||||
widget = child.widget()
|
||||
if widget:
|
||||
widget.deleteLater()
|
||||
del child
|
||||
del layout
|
||||
self.ui.pbFilesList.setLayout(None)
|
||||
|
||||
# Clear the widget contents
|
||||
for child in self.ui.pbFilesList.children():
|
||||
child.deleteLater()
|
||||
|
||||
if len(tweaks["PosterBoard"].zip_paths) == 0:
|
||||
return
|
||||
|
||||
# Create scroll layout
|
||||
mainLayout = QtWidgets.QVBoxLayout()
|
||||
mainLayout.setContentsMargins(0, 0, 0, 0)
|
||||
mainLayout.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
||||
|
||||
# Iterate through the files
|
||||
for tendie in tweaks["PosterBoard"].zip_paths:
|
||||
widget = QtWidgets.QWidget()
|
||||
|
||||
# create the icon/label
|
||||
titleBtn = QtWidgets.QToolButton(widget)
|
||||
titleBtn.setIcon(QtGui.QIcon(":/icon/photo-stack.svg"))
|
||||
titleBtn.setIconSize(QtCore.QSize(20, 20))
|
||||
titleBtn.setText(f" {tendie}")
|
||||
titleBtn.setStyleSheet("QToolButton {\n background-color: transparent;\n icon-size: 20px;\n}")
|
||||
titleBtn.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
titleBtn.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||
|
||||
delBtn = QtWidgets.QToolButton(widget)
|
||||
delBtn.setIcon(QtGui.QIcon(":/icon/trash.svg"))
|
||||
delBtn.clicked.connect(lambda _, file=tendie: self.delete_pb_file(file))
|
||||
|
||||
spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
|
||||
# main layout
|
||||
layout = QtWidgets.QHBoxLayout(widget)
|
||||
layout.setContentsMargins(0, 0, 0, 9)
|
||||
layout.addWidget(titleBtn)
|
||||
layout.addItem(spacer)
|
||||
layout.addWidget(delBtn)
|
||||
# Add the widget to the mainLayout
|
||||
widget.setLayout(layout)
|
||||
mainLayout.addWidget(widget)
|
||||
|
||||
# Create a QWidget to act as the container for the scroll area
|
||||
scrollWidget = QtWidgets.QWidget()
|
||||
|
||||
# Set the main layout (containing all the widgets) on the scroll widget
|
||||
scrollWidget.setLayout(mainLayout)
|
||||
|
||||
# Create a QScrollArea to hold the content widget (scrollWidget)
|
||||
scrollArea = QtWidgets.QScrollArea()
|
||||
scrollArea.setWidgetResizable(True) # Allow the content widget to resize within the scroll area
|
||||
scrollArea.setFrameStyle(QtWidgets.QScrollArea.NoFrame) # Remove the outline from the scroll area
|
||||
|
||||
# Set the scrollWidget as the content widget of the scroll area
|
||||
scrollArea.setWidget(scrollWidget)
|
||||
|
||||
# Set the size policy of the scroll area to expand in both directions
|
||||
scrollArea.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
|
||||
|
||||
# Set the scroll area as the central widget of the main window
|
||||
scrollLayout = QtWidgets.QVBoxLayout()
|
||||
scrollLayout.setContentsMargins(0, 0, 0, 0)
|
||||
scrollLayout.addWidget(scrollArea)
|
||||
self.ui.pbFilesList.setLayout(scrollLayout)
|
||||
|
||||
def on_modifyPosterboardsChk_clicked(self, checked: bool):
|
||||
tweaks["PosterBoard"].set_enabled(checked)
|
||||
self.ui.posterboardPageContent.setDisabled(not checked)
|
||||
def on_selectPosterboardBtn_clicked(self):
|
||||
selected_file, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Select PosterBoard File", "", "Zip Files (*.tendies)", options=QtWidgets.QFileDialog.ReadOnly)
|
||||
def on_importTendiesBtn_clicked(self):
|
||||
selected_files, _ = QtWidgets.QFileDialog.getOpenFileNames(self, "Select PosterBoard Files", "", "Zip Files (*.tendies)", options=QtWidgets.QFileDialog.ReadOnly)
|
||||
tweaks["PosterBoard"].resetting = False
|
||||
if selected_file == "" or selected_file == None:
|
||||
tweaks["PosterBoard"].zip_path = None
|
||||
self.ui.currentPosterboardLbl.setText("None")
|
||||
else:
|
||||
# user selected zip, set it
|
||||
tweaks["PosterBoard"].zip_path = selected_file
|
||||
self.ui.currentPosterboardLbl.setText(selected_file)
|
||||
if selected_files != None and len(selected_files) > 0:
|
||||
# user selected files, add them
|
||||
# but limit to 15
|
||||
if len(selected_files) + len(tweaks["PosterBoard"].zip_paths) > 15:
|
||||
# alert that there are too many
|
||||
detailsBox = QtWidgets.QMessageBox()
|
||||
detailsBox.setIcon(QtWidgets.QMessageBox.Critical)
|
||||
detailsBox.setWindowTitle("Error!")
|
||||
detailsBox.setText("You selected too many descriptors! The limit is 15.")
|
||||
detailsBox.exec()
|
||||
else:
|
||||
tweaks["PosterBoard"].zip_paths.extend(selected_files)
|
||||
self.load_posterboard()
|
||||
|
||||
def on_deleteAllDescriptorsBtn_clicked(self):
|
||||
if tweaks["PosterBoard"].resetting and tweaks["PosterBoard"].resetType == 0:
|
||||
tweaks["PosterBoard"].resetting = False
|
||||
self.ui.currentPosterboardLbl.setText("None")
|
||||
self.ui.pbActionLbl.hide()
|
||||
else:
|
||||
tweaks["PosterBoard"].resetting = True
|
||||
tweaks["PosterBoard"].zip_path = None
|
||||
tweaks["PosterBoard"].resetType = 0
|
||||
self.ui.currentPosterboardLbl.setText("Clearing Collections Wallpapers")
|
||||
self.ui.pbActionLbl.setText("! Clearing Collections Wallpapers")
|
||||
self.ui.pbActionLbl.show()
|
||||
def on_resetPRBExtBtn_clicked(self):
|
||||
if tweaks["PosterBoard"].resetting and tweaks["PosterBoard"].resetType == 1:
|
||||
tweaks["PosterBoard"].resetting = False
|
||||
self.ui.currentPosterboardLbl.setText("None")
|
||||
self.ui.pbActionLbl.hide()
|
||||
else:
|
||||
tweaks["PosterBoard"].resetting = True
|
||||
tweaks["PosterBoard"].zip_path = None
|
||||
tweaks["PosterBoard"].resetType = 1
|
||||
self.ui.currentPosterboardLbl.setText("Resetting PRB Extension")
|
||||
self.ui.pbActionLbl.setText("! Resetting PRB Extension")
|
||||
self.ui.pbActionLbl.show()
|
||||
|
||||
## Risky Options Page
|
||||
def on_disableOTAChk_clicked(self, checked: bool):
|
||||
|
||||
Reference in New Issue
Block a user