From a3278ff3ed454588c22ed07650a7e04db64156ea Mon Sep 17 00:00:00 2001 From: dail8859 Date: Sat, 23 Nov 2024 15:42:17 -0500 Subject: [PATCH] Backup settings when running --reset-settings --- src/NotepadNext/NotepadNextApplication.cpp | 9 +++++++++ src/NotepadNext/dialogs/MainWindow.cpp | 4 ++-- src/NotepadNext/main.cpp | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NotepadNext/NotepadNextApplication.cpp b/src/NotepadNext/NotepadNextApplication.cpp index 3e79b55df..3b6688990 100644 --- a/src/NotepadNext/NotepadNextApplication.cpp +++ b/src/NotepadNext/NotepadNextApplication.cpp @@ -105,6 +105,15 @@ bool NotepadNextApplication::init() settings = new ApplicationSettings(this); if (parser.isSet("reset-settings")) { + QFileInfo original(settings->fileName()); + QString backup = original.canonicalPath() + "/backup." + original.suffix(); + + qInfo("Resetting application settings"); + qInfo("Backuping up %s to %s", qUtf8Printable(settings->fileName()), qUtf8Printable(backup)); + + QFile::remove(backup); + bool renameSuccessfull = QFile::rename(settings->fileName(), backup); + settings->clear(); } diff --git a/src/NotepadNext/dialogs/MainWindow.cpp b/src/NotepadNext/dialogs/MainWindow.cpp index 68ae40884..a36f0a765 100644 --- a/src/NotepadNext/dialogs/MainWindow.cpp +++ b/src/NotepadNext/dialogs/MainWindow.cpp @@ -1638,7 +1638,7 @@ void MainWindow::applyStyleSheet() QString sheet; QFile f(":/stylesheets/npp.css"); - qInfo() << "Loading stylesheet: " << f.fileName(); + qInfo() << "Loading stylesheet:" << f.fileName(); f.open(QFile::ReadOnly); sheet = f.readAll(); @@ -1649,7 +1649,7 @@ void MainWindow::applyStyleSheet() QString fullPath = QDir(directoryPath).filePath("custom.css"); if (QFile::exists(fullPath)) { QFile custom(fullPath); - qInfo() << "Loading stylesheet: " << custom.fileName(); + qInfo() << "Loading stylesheet:" << custom.fileName(); custom.open(QFile::ReadOnly); sheet += custom.readAll(); diff --git a/src/NotepadNext/main.cpp b/src/NotepadNext/main.cpp index 43104ade6..6fab0d899 100644 --- a/src/NotepadNext/main.cpp +++ b/src/NotepadNext/main.cpp @@ -58,6 +58,7 @@ int main(int argc, char *argv[]) qInfo("CPU: %s", qUtf8Printable(QSysInfo::currentCpuArchitecture())); qInfo("File Path: %s", qUtf8Printable(QApplication::applicationFilePath())); qInfo("Arguments: %s", qUtf8Printable(app.arguments().join(' '))); + qInfo("Config File: %s", qUtf8Printable(ApplicationSettings().fileName())); qInfo("============================="); if(app.isPrimary()) {