Add "Safe mode" which temporarily disables configs and addons (#16858)

* Add safe-mode which starts freecad in a clean environment

* Integrate safe-mode

* Show "(Safe Mode)" in main window title

* Show safe mode info when safe mode is started

* Created Safe Mode Icon

* Use new icon

* Add PreCompiled.h

* Add exports for windows

---------

Co-authored-by: Gabriel <gaz082@gmail.com>
This commit is contained in:
Benjamin Nauck
2024-10-21 18:08:52 +02:00
committed by GitHub
parent 06cf87d097
commit f4860bf981
9 changed files with 394 additions and 1 deletions

View File

@@ -70,6 +70,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/DocumentObjectGroup.h>
#include <App/SafeMode.h>
#include <Base/ConsoleObserver.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
@@ -1654,6 +1655,22 @@ void MainWindow::delayedStartup()
if (hGrp->GetBool("RecoveryEnabled", true)) {
Application::Instance->checkForPreviousCrashes();
}
if (SafeMode::SafeModeEnabled()) {
auto safeModePopup = QMessageBox(
QMessageBox::Information,
tr("Safe mode enabled"),
tr("FreeCAD is now running in safe mode."),
QMessageBox::Ok
);
safeModePopup.setInformativeText(
tr(
"Safe mode temporarily disables your configurations and addons."
" Restart the application to exit safe mode."
)
);
safeModePopup.exec();
}
}
void MainWindow::appendRecentFile(const QString& filename)
@@ -2610,6 +2627,10 @@ void MainWindow::setWindowTitle(const QString& string)
title = appname;
}
if (SafeMode::SafeModeEnabled()) {
title = QString::fromUtf8("%1 (%2)").arg(title, tr("Safe Mode"));
}
if (!string.isEmpty()) {
title = QString::fromUtf8("[*] %1 - %2").arg(string, title);
}