Feature: Added clear command to clear settings

Signed-off-by: LorenEteval <loren.eteval@proton.me>
This commit is contained in:
LorenEteval
2026-06-21 15:56:17 +08:00
committed by Loren Eteval
parent 5125dac85c
commit e1762b7456
2 changed files with 21 additions and 1 deletions
+1
View File
@@ -29,6 +29,7 @@ __all__ = [
class AppBuiltinCommand(Enum):
Empty = 'empty'
RunAs = 'runas'
Clear = 'clear'
class AppBuiltinRouting(Enum):
+20 -1
View File
@@ -38,6 +38,22 @@ __all__ = ['main']
logger = logging.getLogger(__name__)
def runClearSettings():
app = QtCore.QCoreApplication(sys.argv)
app.setApplicationName(APPLICATION_NAME)
app.setApplicationVersion(APPLICATION_VERSION)
app.setOrganizationName(ORGANIZATION_NAME)
app.setOrganizationDomain(ORGANIZATION_DOMAIN)
settings = QtCore.QSettings()
settings.clear()
settings.sync()
logger.info('application settings have been cleared')
sys.exit(0)
def runAppMain():
process = AppMainProcess(functools.partial(Application, sys.argv))
@@ -142,7 +158,10 @@ def runAppMain():
def main():
try:
runAppMain()
if len(sys.argv) > 1 and sys.argv[1] == AppBuiltinCommand.Clear.value:
runClearSettings()
else:
runAppMain()
except Exception:
# Any non-exit exceptions