mirror of
https://github.com/leminlimez/Nugget.git
synced 2025-04-08 04:23:05 +08:00
deleting custom gestalt tweaks
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from PySide6 import QtCore, QtWidgets
|
from PySide6 import QtCore, QtWidgets, QtGui
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import plistlib
|
import plistlib
|
||||||
@@ -423,6 +423,11 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
# update the value
|
# update the value
|
||||||
valueField.setText(new_str)
|
valueField.setText(new_str)
|
||||||
|
|
||||||
|
def delete_custom_gestalt_key(self, id: int, widget: QtWidgets.QWidget):
|
||||||
|
CustomGestaltTweaks.deactivate_tweak(id)
|
||||||
|
self.ui.customKeysLayout.removeWidget(widget)
|
||||||
|
widget.setParent(None)
|
||||||
|
|
||||||
def on_addGestaltKeyBtn_clicked(self):
|
def on_addGestaltKeyBtn_clicked(self):
|
||||||
# create a blank gestalt value with default value of 1
|
# create a blank gestalt value with default value of 1
|
||||||
key_identifier = CustomGestaltTweaks.create_tweak()
|
key_identifier = CustomGestaltTweaks.create_tweak()
|
||||||
@@ -439,10 +444,17 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
keyField.setPlaceholderText("Key")
|
keyField.setPlaceholderText("Key")
|
||||||
keyField.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft)
|
keyField.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft)
|
||||||
keyField.setTextMargins(5, 0, 5, 0)
|
keyField.setTextMargins(5, 0, 5, 0)
|
||||||
keyField.setContentsMargins(0, 0, 50, 0)
|
|
||||||
keyField.textEdited.connect(lambda txt, id=key_identifier: CustomGestaltTweaks.set_tweak_key(id, txt))
|
keyField.textEdited.connect(lambda txt, id=key_identifier: CustomGestaltTweaks.set_tweak_key(id, txt))
|
||||||
hlayout.addWidget(keyField)
|
hlayout.addWidget(keyField)
|
||||||
|
|
||||||
|
# create the delete button
|
||||||
|
delBtn = QtWidgets.QToolButton(widget)
|
||||||
|
delBtn.setIcon(QtGui.QIcon(":/icon/trash.svg"))
|
||||||
|
delBtn.setStyleSheet("QToolButton { margin-right: 8px; background: none; border: none; }\nQToolButton:pressed { background: none; color: #FFFFFF; }")
|
||||||
|
delBtn.setContentsMargins(0, 0, 50, 0)
|
||||||
|
delBtn.clicked.connect(lambda _, id=key_identifier, w=widget: self.delete_custom_gestalt_key(id, w))
|
||||||
|
hlayout.addWidget(delBtn)
|
||||||
|
|
||||||
# create the type dropdown
|
# create the type dropdown
|
||||||
valueTypeDrp = QtWidgets.QComboBox(widget)
|
valueTypeDrp = QtWidgets.QComboBox(widget)
|
||||||
valueTypeDrp.setStyleSheet("QComboBox {\n background-color: #3b3b3b;\n border: none;\n color: #e8e8e8;\n font-size: 14px;\n padding-left: 8px;\n border-radius: 8px;\n}\n\nQComboBox::drop-down {\n image: url(:/icon/caret-down-fill.svg);\n icon-size: 16px;\n subcontrol-position: right center;\n margin-right: 8px;\n}\n\nQComboBox QAbstractItemView {\n background-color: #3b3b3b;\n outline: none;\n margin-top: 1px;\n}\n\nQComboBox QAbstractItemView::item {\n background-color: #3b3b3b;\n color: #e8e8e8;\n padding-left: 8px;\n}\n\nQComboBox QAbstractItemView::item:hover {\n background-color: #535353;\n color: #ffffff;\n}")
|
valueTypeDrp.setStyleSheet("QComboBox {\n background-color: #3b3b3b;\n border: none;\n color: #e8e8e8;\n font-size: 14px;\n padding-left: 8px;\n border-radius: 8px;\n}\n\nQComboBox::drop-down {\n image: url(:/icon/caret-down-fill.svg);\n icon-size: 16px;\n subcontrol-position: right center;\n margin-right: 8px;\n}\n\nQComboBox QAbstractItemView {\n background-color: #3b3b3b;\n outline: none;\n margin-top: 1px;\n}\n\nQComboBox QAbstractItemView::item {\n background-color: #3b3b3b;\n color: #e8e8e8;\n padding-left: 8px;\n}\n\nQComboBox QAbstractItemView::item:hover {\n background-color: #535353;\n color: #ffffff;\n}")
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ class CustomGestaltTweak:
|
|||||||
def __init__(self, tweak: MobileGestaltTweak, value_type: ValueType):
|
def __init__(self, tweak: MobileGestaltTweak, value_type: ValueType):
|
||||||
self.tweak = tweak
|
self.tweak = tweak
|
||||||
self.value_type = value_type
|
self.value_type = value_type
|
||||||
|
self.deactivated = False
|
||||||
|
|
||||||
# TODO: change everything to not return the dict since it is passed by reference
|
# TODO: change everything to not return the dict since it is passed by reference
|
||||||
def apply_tweak(self, plist: dict) -> dict:
|
def apply_tweak(self, plist: dict) -> dict:
|
||||||
if self.tweak.key == "":
|
if self.deactivated or self.tweak.key == "":
|
||||||
# key was not set, don't apply (maybe user added it by accident)
|
# key was not set, don't apply (maybe user added it by accident)
|
||||||
return plist
|
return plist
|
||||||
self.tweak.enabled = True
|
self.tweak.enabled = True
|
||||||
@@ -83,6 +84,10 @@ class CustomGestaltTweaks:
|
|||||||
CustomGestaltTweaks.custom_tweaks[id].tweak.value = new_value
|
CustomGestaltTweaks.custom_tweaks[id].tweak.value = new_value
|
||||||
return new_str
|
return new_str
|
||||||
|
|
||||||
|
def deactivate_tweak(id: int):
|
||||||
|
CustomGestaltTweaks.custom_tweaks[id].deactivated = True
|
||||||
|
CustomGestaltTweaks.custom_tweaks[id].tweak = None
|
||||||
|
|
||||||
def apply_tweaks(plist: dict):
|
def apply_tweaks(plist: dict):
|
||||||
for tweak in CustomGestaltTweaks.custom_tweaks:
|
for tweak in CustomGestaltTweaks.custom_tweaks:
|
||||||
plist = tweak.apply_tweak(plist)
|
plist = tweak.apply_tweak(plist)
|
||||||
|
|||||||
Reference in New Issue
Block a user