Merge Master

This commit is contained in:
AgCaliva
2023-08-30 16:24:16 -03:00
2458 changed files with 219581 additions and 231989 deletions

View File

@@ -68,6 +68,7 @@
#include "CommandPy.h"
#include "Control.h"
#include "PreferencePages/DlgSettingsCacheDirectory.h"
#include "DlgCheckableMessageBox.h"
#include "DocumentPy.h"
#include "DocumentRecovery.h"
#include "EditorView.h"
@@ -85,7 +86,8 @@
#include "MDIViewPy.h"
#include "SoFCDB.h"
#include "Selection.h"
#include "SoFCOffscreenRenderer.h"
#include "SelectionFilterPy.h"
#include "SoQtOffscreenRendererPy.h"
#include "SplitView3DInventor.h"
#include "TaskView/TaskView.h"
#include "TaskView/TaskDialogPython.h"
@@ -171,11 +173,7 @@ public:
// Pimpl class
struct ApplicationP
{
explicit ApplicationP(bool GUIenabled) :
activeDocument(nullptr),
editDocument(nullptr),
isClosing(false),
startingUp(true)
explicit ApplicationP(bool GUIenabled)
{
// create the macro manager
if (GUIenabled)
@@ -196,14 +194,14 @@ struct ApplicationP
/// list of all handled documents
std::map<const App::Document*, Gui::Document*> documents;
/// Active document
Gui::Document* activeDocument;
Gui::Document* editDocument;
Gui::Document* activeDocument{nullptr};
Gui::Document* editDocument{nullptr};
MacroManager* macroMngr;
PreferencePackManager* prefPackManager;
/// List of all registered views
std::list<Gui::BaseView*> passive;
bool isClosing;
bool startingUp;
bool isClosing{false};
bool startingUp{true};
/// Handles all commands
CommandManager commandManager;
ViewProviderMap viewproviderMap;
@@ -1587,7 +1585,7 @@ QPixmap Application::workbenchIcon(const QString& wb) const
if (!s.isEmpty())
return icon.pixmap(s[0]);
}
return QPixmap();
return {};
}
QString Application::workbenchToolTip(const QString& wb) const
@@ -1611,7 +1609,7 @@ QString Application::workbenchToolTip(const QString& wb) const
}
}
return QString();
return {};
}
QString Application::workbenchMenuText(const QString& wb) const
@@ -1636,7 +1634,7 @@ QString Application::workbenchMenuText(const QString& wb) const
}
}
return QString();
return {};
}
QStringList Application::workbenches() const
@@ -2210,6 +2208,25 @@ void Application::runApplication()
int major = context.format().majorVersion();
int minor = context.format().minorVersion();
#ifdef NDEBUG
// In release mode, issue a warning to users that their version of OpenGL is
// potentially going to cause problems
if (major < 2) {
auto message =
QObject::tr("This system is running OpenGL %1.%2. "
"FreeCAD requires OpenGL 2.0 or above. "
"Please upgrade your graphics driver and/or card as required.")
.arg(major)
.arg(minor)
+ QStringLiteral("\n");
Base::Console().Warning(message.toStdString().c_str());
Dialog::DlgCheckableMessageBox::showMessage(
Gui::GUISingleApplication::applicationName() + QStringLiteral(" - ")
+ QObject::tr("Invalid OpenGL Version"),
message);
}
#endif
const char* glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION));
Base::Console().Log("OpenGL version is: %d.%d (%s)\n", major, minor, glVersion);
}
@@ -2475,11 +2492,9 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
qApp->setPalette(newPal);
}
QString current = mw->property("fc_currentStyleSheet").toString();
mw->setProperty("fc_currentStyleSheet", qssFile);
if (!qssFile.isEmpty() && current != qssFile) {
if (!qssFile.isEmpty()) {
// Search for stylesheet in user-defined search paths.
// For qss they are set-up in runApplication() with the prefix "qss"
QString prefix(QLatin1String("qss:"));
@@ -2495,7 +2510,10 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
if (!f.fileName().isEmpty() && f.open(QFile::ReadOnly | QFile::Text)) {
mdi->setBackground(QBrush(Qt::NoBrush));
QTextStream str(&f);
qApp->setStyleSheet(str.readAll());
QString styleSheetContent = replaceVariablesInQss(str.readAll());
qApp->setStyleSheet(styleSheetContent);
ActionStyleEvent e(ActionStyleEvent::Clear);
qApp->sendEvent(mw, &e);
@@ -2521,8 +2539,7 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
}
}
}
if (qssFile.isEmpty()) {
else {
if (tiledBackground) {
qApp->setStyleSheet(QString());
ActionStyleEvent e(ActionStyleEvent::Restore);
@@ -2547,6 +2564,28 @@ void Application::setStyleSheet(const QString& qssFile, bool tiledBackground)
}
}
QString Application::replaceVariablesInQss(QString qssText)
{
//First we fetch the colors from preferences,
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Themes");
unsigned long longAccentColor1 = hGrp->GetUnsigned("ThemeAccentColor1", 0);
unsigned long longAccentColor2 = hGrp->GetUnsigned("ThemeAccentColor2", 0);
unsigned long longAccentColor3 = hGrp->GetUnsigned("ThemeAccentColor3", 0);
//convert them to hex.
//Note: the ulong contains alpha channels so 8 hex characters when we need 6 here.
QString accentColor1 = QString::fromLatin1("#%1").arg(longAccentColor1, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor2 = QString::fromLatin1("#%1").arg(longAccentColor2, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
QString accentColor3 = QString::fromLatin1("#%1").arg(longAccentColor3, 8, 16, QLatin1Char('0')).toUpper().mid(0, 7);
qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor1"), accentColor1);
qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor2"), accentColor2);
qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor3"), accentColor3);
//Base::Console().Warning("%s\n", qssText.toStdString());
return qssText;
}
void Application::checkForDeprecatedSettings()
{
// From 0.21, `FCBak` will be the intended default backup format