Skip to content

Commit

Permalink
Backup settings when running --reset-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dail8859 committed Nov 29, 2024
1 parent 0aebd26 commit a3278ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/NotepadNext/NotepadNextApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/NotepadNext/dialogs/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/NotepadNext/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit a3278ff

Please sign in to comment.