All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -146,7 +146,7 @@
|
||||
#include <Base/ServiceProvider.h>
|
||||
|
||||
#ifdef BUILD_TRACY_FRAME_PROFILER
|
||||
#include <tracy/Tracy.hpp>
|
||||
# include <tracy/Tracy.hpp>
|
||||
#endif
|
||||
|
||||
using namespace Gui;
|
||||
@@ -168,16 +168,14 @@ class ViewProviderMap
|
||||
public:
|
||||
void newObject(const ViewProvider& vp)
|
||||
{
|
||||
auto vpd =
|
||||
freecad_cast<ViewProviderDocumentObject*>(const_cast<ViewProvider*>(&vp));
|
||||
auto vpd = freecad_cast<ViewProviderDocumentObject*>(const_cast<ViewProvider*>(&vp));
|
||||
if (vpd && vpd->getObject()) {
|
||||
map[vpd->getObject()] = vpd;
|
||||
}
|
||||
}
|
||||
void deleteObject(const ViewProvider& vp)
|
||||
{
|
||||
auto vpd =
|
||||
freecad_cast<ViewProviderDocumentObject*>(const_cast<ViewProvider*>(&vp));
|
||||
auto vpd = freecad_cast<ViewProviderDocumentObject*>(const_cast<ViewProvider*>(&vp));
|
||||
if (vpd && vpd->getObject()) {
|
||||
map.erase(vpd->getObject());
|
||||
}
|
||||
@@ -253,11 +251,11 @@ static PyObject* FreeCADGui_subgraphFromObject(PyObject* /*self*/, PyObject* arg
|
||||
std::string vp = obj->getViewProviderName();
|
||||
SoNode* node = nullptr;
|
||||
try {
|
||||
auto base =
|
||||
static_cast<Base::BaseClass*>(Base::Type::createInstanceByName(vp.c_str(), true));
|
||||
auto base = static_cast<Base::BaseClass*>(Base::Type::createInstanceByName(vp.c_str(), true));
|
||||
if (base && base->isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
|
||||
std::unique_ptr<Gui::ViewProviderDocumentObject> vp(
|
||||
static_cast<Gui::ViewProviderDocumentObject*>(base));
|
||||
static_cast<Gui::ViewProviderDocumentObject*>(base)
|
||||
);
|
||||
std::map<std::string, App::Property*> Map;
|
||||
obj->getPropertyMap(Map);
|
||||
vp->attach(obj);
|
||||
@@ -290,10 +288,8 @@ static PyObject* FreeCADGui_subgraphFromObject(PyObject* /*self*/, PyObject* arg
|
||||
|
||||
type += " *";
|
||||
PyObject* proxy = nullptr;
|
||||
proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin",
|
||||
type.c_str(),
|
||||
static_cast<void*>(node),
|
||||
1);
|
||||
proxy = Base::Interpreter()
|
||||
.createSWIGPointerObj("pivy.coin", type.c_str(), static_cast<void*>(node), 1);
|
||||
return Py::new_reference_to(Py::Object(proxy, true));
|
||||
}
|
||||
}
|
||||
@@ -387,7 +383,9 @@ void Application::initStyleParameterManager()
|
||||
static ParamHandlers handlers;
|
||||
|
||||
const auto deduceParametersFilePath = []() -> std::string {
|
||||
const auto hMainWindowGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow");
|
||||
const auto hMainWindowGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
);
|
||||
|
||||
if (const std::string& path = hMainWindowGrp->GetASCII("ThemeStyleParametersFile");
|
||||
!path.empty()) {
|
||||
@@ -400,7 +398,8 @@ void Application::initStyleParameterManager()
|
||||
auto themeParametersSource = new StyleParameters::YamlParameterSource(
|
||||
deduceParametersFilePath(),
|
||||
{.name = QT_TR_NOOP("Theme Parameters"),
|
||||
.options = StyleParameters::ParameterSourceOption::UserEditable});
|
||||
.options = StyleParameters::ParameterSourceOption::UserEditable}
|
||||
);
|
||||
|
||||
auto reloadStylesheetHandler = handlers.addDelayedHandler(
|
||||
"BaseApp/Preferences/MainWindow",
|
||||
@@ -413,31 +412,41 @@ void Application::initStyleParameterManager()
|
||||
bool tiledBG = hGrp->GetBool("TiledBackground", false);
|
||||
|
||||
setStyleSheet(QString::fromStdString(sheet), tiledBG);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
handlers.addHandler("BaseApp/Preferences/Themes",
|
||||
{"ThemeAccentColor1", "ThemeAccentColor2", "ThemeAccentColor2"},
|
||||
reloadStylesheetHandler);
|
||||
handlers.addHandler(
|
||||
"BaseApp/Preferences/Themes",
|
||||
{"ThemeAccentColor1", "ThemeAccentColor2", "ThemeAccentColor2"},
|
||||
reloadStylesheetHandler
|
||||
);
|
||||
|
||||
Base::registerServiceImplementation<StyleParameters::ParameterSource>(
|
||||
new StyleParameters::BuiltInParameterSource({.name = QT_TR_NOOP("Built-in Parameters")}));
|
||||
new StyleParameters::BuiltInParameterSource({.name = QT_TR_NOOP("Built-in Parameters")})
|
||||
);
|
||||
|
||||
// todo: left for compatibility with older theme versions, to be removed before release
|
||||
Base::registerServiceImplementation<StyleParameters::ParameterSource>(
|
||||
new StyleParameters::UserParameterSource(
|
||||
App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Themes/UserTokens"),
|
||||
"User parameter:BaseApp/Preferences/Themes/UserTokens"
|
||||
),
|
||||
{.name = QT_TR_NOOP("Theme Parameters - Fallback"),
|
||||
.options = StyleParameters::ParameterSourceOption::ReadOnly}));
|
||||
.options = StyleParameters::ParameterSourceOption::ReadOnly}
|
||||
)
|
||||
);
|
||||
|
||||
Base::registerServiceImplementation<StyleParameters::ParameterSource>(themeParametersSource);
|
||||
|
||||
Base::registerServiceImplementation<StyleParameters::ParameterSource>(
|
||||
new StyleParameters::UserParameterSource(
|
||||
App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Themes/UserParameters"),
|
||||
"User parameter:BaseApp/Preferences/Themes/UserParameters"
|
||||
),
|
||||
{.name = QT_TR_NOOP("User Parameters"),
|
||||
.options = StyleParameters::ParameterSource::UserEditable}));
|
||||
.options = StyleParameters::ParameterSource::UserEditable}
|
||||
)
|
||||
);
|
||||
|
||||
const auto sources = Base::provideServiceImplementations<StyleParameters::ParameterSource>();
|
||||
for (auto* source : std::views::all(sources) | std::views::reverse) {
|
||||
@@ -666,7 +675,8 @@ Application::Application(bool GUIenabled)
|
||||
|
||||
#ifdef USE_3DCONNEXION_NAVLIB
|
||||
ParameterGrp::handle hViewGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View");
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
if (!hViewGrp->GetBool("LegacySpaceMouseDevices", false)) {
|
||||
// Instantiate the 3Dconnexion controller
|
||||
pNavlibInterface = new NavlibInterface();
|
||||
@@ -751,22 +761,25 @@ void Application::open(const char* FileName, const char* Module)
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
Command::doCommand(Command::App,
|
||||
"FreeCAD.openDocument('%s')",
|
||||
unicodepath.c_str());
|
||||
Command::doCommand(Command::App, "FreeCAD.openDocument('%s')", unicodepath.c_str());
|
||||
Gui::Application::checkForRecomputes();
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string code = fmt::format("from freecad import module_io\n"
|
||||
"module_io.OpenInsertObject(\"{}\", \"{}\", \"{}\")\n",
|
||||
Module, unicodepath, "open");
|
||||
std::string code = fmt::format(
|
||||
"from freecad import module_io\n"
|
||||
"module_io.OpenInsertObject(\"{}\", \"{}\", \"{}\")\n",
|
||||
Module,
|
||||
unicodepath,
|
||||
"open"
|
||||
);
|
||||
Gui::Command::runCommand(Gui::Command::App, code.c_str());
|
||||
|
||||
// ViewFit
|
||||
if (sendHasMsgToActiveView("ViewFit")) {
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View");
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
if (hGrp->GetBool("AutoFitToView", true)) {
|
||||
Command::doCommand(Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
@@ -788,7 +801,8 @@ void Application::open(const char* FileName, const char* Module)
|
||||
QMessageBox::warning(
|
||||
getMainWindow(),
|
||||
QObject::tr("Unknown filetype"),
|
||||
QObject::tr("Cannot open unknown filetype: %1").arg(QLatin1String(te.c_str())));
|
||||
QObject::tr("Cannot open unknown filetype: %1").arg(QLatin1String(te.c_str()))
|
||||
);
|
||||
wc.setWaitCursor();
|
||||
return;
|
||||
}
|
||||
@@ -831,9 +845,14 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
|
||||
}
|
||||
}
|
||||
|
||||
std::string code = fmt::format("from freecad import module_io\n"
|
||||
"module_io.OpenInsertObject(\"{}\", \"{}\", \"{}\", \"{}\")\n",
|
||||
Module, unicodepath, "insert", DocName);
|
||||
std::string code = fmt::format(
|
||||
"from freecad import module_io\n"
|
||||
"module_io.OpenInsertObject(\"{}\", \"{}\", \"{}\", \"{}\")\n",
|
||||
Module,
|
||||
unicodepath,
|
||||
"insert",
|
||||
DocName
|
||||
);
|
||||
Gui::Command::runCommand(Gui::Command::App, code.c_str());
|
||||
|
||||
// Commit the transaction
|
||||
@@ -852,7 +871,8 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
|
||||
doc->setModified(true);
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/View");
|
||||
"User parameter:BaseApp/Preferences/View"
|
||||
);
|
||||
if (hGrp->GetBool("AutoFitToView", true)) {
|
||||
MDIView* view = doc->getActiveView();
|
||||
if (view) {
|
||||
@@ -868,10 +888,13 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
|
||||
// the original file name is required
|
||||
QString filename = QString::fromUtf8(File.filePath().c_str());
|
||||
auto parameterGroup = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/General");
|
||||
"User parameter:BaseApp/Preferences/General"
|
||||
);
|
||||
bool addToRecent = parameterGroup->GetBool("RecentIncludesImported", true);
|
||||
parameterGroup->SetBool("RecentIncludesImported",
|
||||
addToRecent); // Make sure it gets added to the parameter list
|
||||
parameterGroup->SetBool(
|
||||
"RecentIncludesImported",
|
||||
addToRecent
|
||||
); // Make sure it gets added to the parameter list
|
||||
if (addToRecent) {
|
||||
getMainWindow()->appendRecentFile(filename);
|
||||
}
|
||||
@@ -887,7 +910,8 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
|
||||
QMessageBox::warning(
|
||||
getMainWindow(),
|
||||
QObject::tr("Unknown filetype"),
|
||||
QObject::tr("Cannot open unknown filetype: %1").arg(QLatin1String(te.c_str())));
|
||||
QObject::tr("Cannot open unknown filetype: %1").arg(QLatin1String(te.c_str()))
|
||||
);
|
||||
wc.setWaitCursor();
|
||||
}
|
||||
}
|
||||
@@ -907,8 +931,8 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
|
||||
|
||||
if (Module) {
|
||||
try {
|
||||
std::vector<App::DocumentObject*> sel =
|
||||
Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), DocName);
|
||||
std::vector<App::DocumentObject*> sel
|
||||
= Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(), DocName);
|
||||
if (sel.empty()) {
|
||||
App::Document* doc = App::GetApplication().getDocument(DocName);
|
||||
sel = doc->getObjectsOfType(App::DocumentObject::getClassTypeId());
|
||||
@@ -937,15 +961,18 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
|
||||
Gui::Command::runCommand(Gui::Command::App, code.c_str());
|
||||
|
||||
auto parameterGroup = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/General");
|
||||
"User parameter:BaseApp/Preferences/General"
|
||||
);
|
||||
bool addToRecent = parameterGroup->GetBool("RecentIncludesExported", false);
|
||||
parameterGroup->SetBool("RecentIncludesExported",
|
||||
addToRecent); // Make sure it gets added to the parameter list
|
||||
parameterGroup->SetBool(
|
||||
"RecentIncludesExported",
|
||||
addToRecent
|
||||
); // Make sure it gets added to the parameter list
|
||||
if (addToRecent) {
|
||||
// search for a module that is able to open the exported file because otherwise
|
||||
// it doesn't need to be added to the recent files list (#0002047)
|
||||
std::map<std::string, std::string> importMap =
|
||||
App::GetApplication().getImportFilters(te.c_str());
|
||||
std::map<std::string, std::string> importMap
|
||||
= App::GetApplication().getImportFilters(te.c_str());
|
||||
if (!importMap.empty()) {
|
||||
getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str()));
|
||||
}
|
||||
@@ -957,9 +984,11 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
|
||||
// Usually thrown if the file is invalid somehow
|
||||
e.reportException();
|
||||
wc.restoreCursor();
|
||||
QMessageBox::critical(getMainWindow(),
|
||||
QObject::tr("Export failed"),
|
||||
QString::fromUtf8(e.what()));
|
||||
QMessageBox::critical(
|
||||
getMainWindow(),
|
||||
QObject::tr("Export failed"),
|
||||
QString::fromUtf8(e.what())
|
||||
);
|
||||
wc.setWaitCursor();
|
||||
}
|
||||
}
|
||||
@@ -968,7 +997,8 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
|
||||
QMessageBox::warning(
|
||||
getMainWindow(),
|
||||
QObject::tr("Unknown filetype"),
|
||||
QObject::tr("Cannot save to unknown filetype: %1").arg(QLatin1String(te.c_str())));
|
||||
QObject::tr("Cannot save to unknown filetype: %1").arg(QLatin1String(te.c_str()))
|
||||
);
|
||||
wc.setWaitCursor();
|
||||
}
|
||||
}
|
||||
@@ -998,14 +1028,14 @@ void Application::slotNewDocument(const App::Document& Doc, bool isMainDoc)
|
||||
// NOLINTBEGIN
|
||||
// connect the signals to the application for the new document
|
||||
pDoc->signalNewObject.connect(std::bind(&Gui::Application::slotNewObject, this, sp::_1));
|
||||
pDoc->signalDeletedObject.connect(
|
||||
std::bind(&Gui::Application::slotDeletedObject, this, sp::_1));
|
||||
pDoc->signalDeletedObject.connect(std::bind(&Gui::Application::slotDeletedObject, this, sp::_1));
|
||||
pDoc->signalChangedObject.connect(
|
||||
std::bind(&Gui::Application::slotChangedObject, this, sp::_1, sp::_2));
|
||||
pDoc->signalRelabelObject.connect(
|
||||
std::bind(&Gui::Application::slotRelabelObject, this, sp::_1));
|
||||
std::bind(&Gui::Application::slotChangedObject, this, sp::_1, sp::_2)
|
||||
);
|
||||
pDoc->signalRelabelObject.connect(std::bind(&Gui::Application::slotRelabelObject, this, sp::_1));
|
||||
pDoc->signalActivatedObject.connect(
|
||||
std::bind(&Gui::Application::slotActivatedObject, this, sp::_1));
|
||||
std::bind(&Gui::Application::slotActivatedObject, this, sp::_1)
|
||||
);
|
||||
pDoc->signalInEdit.connect(std::bind(&Gui::Application::slotInEdit, this, sp::_1));
|
||||
pDoc->signalResetEdit.connect(std::bind(&Gui::Application::slotResetEdit, this, sp::_1));
|
||||
// NOLINTEND
|
||||
@@ -1080,44 +1110,60 @@ void Application::slotShowHidden(const App::Document& Doc)
|
||||
signalShowHidden(*doc->second);
|
||||
}
|
||||
|
||||
void Application::checkForRecomputes() {
|
||||
std::vector<App::Document *> docs;
|
||||
for (auto doc: App::GetApplication().getDocuments()) {
|
||||
void Application::checkForRecomputes()
|
||||
{
|
||||
std::vector<App::Document*> docs;
|
||||
for (auto doc : App::GetApplication().getDocuments()) {
|
||||
if (doc->testStatus(App::Document::RecomputeOnRestore)) {
|
||||
docs.push_back(doc);
|
||||
doc->setStatus(App::Document::RecomputeOnRestore, false);
|
||||
}
|
||||
}
|
||||
// Certain tests want to use very old .FCStd files. We should not prompt during those tests, so this
|
||||
// allows them to 'FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True")`
|
||||
// Certain tests want to use very old .FCStd files. We should not prompt during those tests, so
|
||||
// this allows them to 'FreeCAD.ConfigSet("SuppressRecomputeRequiredDialog", "True")`
|
||||
const std::map<std::string, std::string>& Map = App::Application::Config();
|
||||
auto value = Map.find("SuppressRecomputeRequiredDialog");
|
||||
bool skip = value != Map.end() && ! value->second.empty(); // Any non empty string is true.
|
||||
if (docs.empty() || skip )
|
||||
bool skip = value != Map.end() && !value->second.empty(); // Any non empty string is true.
|
||||
if (docs.empty() || skip) {
|
||||
return;
|
||||
}
|
||||
WaitCursor wc;
|
||||
wc.restoreCursor();
|
||||
auto res = QMessageBox::warning(getMainWindow(), QObject::tr("Recomputation required"),
|
||||
QObject::tr("Some documents require recomputation for migration purposes. "
|
||||
"It is highly recommended to perform a recomputation before "
|
||||
"any modification to avoid compatibility problems.\n\n"
|
||||
"Recompute now?"),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (res != QMessageBox::Yes)
|
||||
auto res = QMessageBox::warning(
|
||||
getMainWindow(),
|
||||
QObject::tr("Recomputation required"),
|
||||
QObject::tr(
|
||||
"Some documents require recomputation for migration purposes. "
|
||||
"It is highly recommended to perform a recomputation before "
|
||||
"any modification to avoid compatibility problems.\n\n"
|
||||
"Recompute now?"
|
||||
),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::Yes
|
||||
);
|
||||
if (res != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
bool hasError = false;
|
||||
for (auto doc: App::Document::getDependentDocuments(docs, true)) {
|
||||
for (auto doc : App::Document::getDependentDocuments(docs, true)) {
|
||||
try {
|
||||
doc->recompute({}, false, &hasError);
|
||||
} catch (Base::Exception &e) {
|
||||
}
|
||||
catch (Base::Exception& e) {
|
||||
e.reportException();
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
if (hasError)
|
||||
QMessageBox::critical(getMainWindow(), QObject::tr("Recompute error"),
|
||||
QObject::tr("Failed to recompute some documents.\n"
|
||||
"Check the report view for more details."));
|
||||
if (hasError) {
|
||||
QMessageBox::critical(
|
||||
getMainWindow(),
|
||||
QObject::tr("Recompute error"),
|
||||
QObject::tr(
|
||||
"Failed to recompute some documents.\n"
|
||||
"Check the report view for more details."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::checkPartialRestore(App::Document* doc)
|
||||
@@ -1126,9 +1172,12 @@ void Application::checkPartialRestore(App::Document* doc)
|
||||
QMessageBox::critical(
|
||||
getMainWindow(),
|
||||
QObject::tr("Error"),
|
||||
QObject::tr("There were errors while loading the file. Some data might have been "
|
||||
"modified or not recovered at all. Look in the report view for more "
|
||||
"specific information about the objects involved."));
|
||||
QObject::tr(
|
||||
"There were errors while loading the file. Some data might have been "
|
||||
"modified or not recovered at all. Look in the report view for more "
|
||||
"specific information about the objects involved."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,9 +1187,12 @@ void Application::checkRestoreError(App::Document* doc)
|
||||
QMessageBox::critical(
|
||||
getMainWindow(),
|
||||
QObject::tr("Error"),
|
||||
QObject::tr("There were serious errors while loading the file. Some data might have "
|
||||
"been modified or not recovered at all. Saving the project will most "
|
||||
"likely result in loss of data."));
|
||||
QObject::tr(
|
||||
"There were serious errors while loading the file. Some data might have "
|
||||
"been modified or not recovered at all. Saving the project will most "
|
||||
"likely result in loss of data."
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1172,7 +1224,8 @@ void Application::slotActiveDocument(const App::Document& Doc)
|
||||
|
||||
// Update the application to show the unit change
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Units");
|
||||
"User parameter:BaseApp/Preferences/Units"
|
||||
);
|
||||
if (!hGrp->GetBool("IgnoreProjectSchema")) {
|
||||
int userSchema = Doc.UnitSystem.getValue();
|
||||
Base::UnitsApi::setSchema(userSchema);
|
||||
@@ -1233,9 +1286,11 @@ void Application::onLastWindowClosed(Gui::Document* pcDoc)
|
||||
if (!d->isClosing && pcDoc) {
|
||||
// Call the closing mechanism from Python. This also checks whether pcDoc is the last
|
||||
// open document.
|
||||
Command::doCommand(Command::Doc,
|
||||
"App.closeDocument(\"%s\")",
|
||||
pcDoc->getDocument()->getName());
|
||||
Command::doCommand(
|
||||
Command::Doc,
|
||||
"App.closeDocument(\"%s\")",
|
||||
pcDoc->getDocument()->getName()
|
||||
);
|
||||
if (!d->activeDocument && !d->documents.empty()) {
|
||||
Document* gdoc = nullptr;
|
||||
for (auto& v : d->documents) {
|
||||
@@ -1272,11 +1327,13 @@ void Application::onLastWindowClosed(Gui::Document* pcDoc)
|
||||
Base::Console().error(
|
||||
"Unhandled std::exception caught in Application::onLastWindowClosed.\n"
|
||||
"The error message is: %s\n",
|
||||
e.what());
|
||||
e.what()
|
||||
);
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().error(
|
||||
"Unhandled unknown exception caught in Application::onLastWindowClosed.\n");
|
||||
"Unhandled unknown exception caught in Application::onLastWindowClosed.\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1382,7 +1439,8 @@ void Application::setEditDocument(Gui::Document* doc)
|
||||
{
|
||||
if (!doc) {
|
||||
d->editDocument = nullptr;
|
||||
} else if (doc == d->editDocument) {
|
||||
}
|
||||
else if (doc == d->editDocument) {
|
||||
return;
|
||||
}
|
||||
for (auto& v : d->documents) {
|
||||
@@ -1449,9 +1507,7 @@ void Application::setActiveDocument(Gui::Document* pcDocument)
|
||||
// May be useful for error detection
|
||||
if (d->activeDocument) {
|
||||
App::Document* doc = d->activeDocument->getDocument();
|
||||
Base::Console().log("Active document is %s (at %p)\n",
|
||||
doc->getName(),
|
||||
static_cast<void*>(doc));
|
||||
Base::Console().log("Active document is %s (at %p)\n", doc->getName(), static_cast<void*>(doc));
|
||||
}
|
||||
else {
|
||||
Base::Console().log("No active document\n");
|
||||
@@ -1537,9 +1593,11 @@ void Application::viewActivated(MDIView* pcView)
|
||||
{
|
||||
#ifdef FC_DEBUG
|
||||
// May be useful for error detection
|
||||
Base::Console().log("Active view is %s (at %p)\n",
|
||||
(const char*)pcView->windowTitle().toUtf8(),
|
||||
static_cast<void*>(pcView));
|
||||
Base::Console().log(
|
||||
"Active view is %s (at %p)\n",
|
||||
(const char*)pcView->windowTitle().toUtf8(),
|
||||
static_cast<void*>(pcView)
|
||||
);
|
||||
#endif
|
||||
|
||||
signalActivateView(pcView);
|
||||
@@ -1580,8 +1638,7 @@ void Application::tryClose(QCloseEvent* e)
|
||||
}
|
||||
|
||||
// ask all passive views if closable
|
||||
for (std::list<Gui::BaseView*>::iterator It = d->passive.begin(); It != d->passive.end();
|
||||
++It) {
|
||||
for (std::list<Gui::BaseView*>::iterator It = d->passive.begin(); It != d->passive.end(); ++It) {
|
||||
e->setAccepted((*It)->canClose());
|
||||
if (!e->isAccepted()) {
|
||||
return;
|
||||
@@ -1795,9 +1852,11 @@ bool Application::activateWorkbench(const char* name)
|
||||
|
||||
if (!d->startingUp) {
|
||||
wc.restoreCursor();
|
||||
QMessageBox::critical(getMainWindow(),
|
||||
QObject::tr("Workbench failure"),
|
||||
QObject::tr("%1").arg(msg));
|
||||
QMessageBox::critical(
|
||||
getMainWindow(),
|
||||
QObject::tr("Workbench failure"),
|
||||
QObject::tr("%1").arg(msg)
|
||||
);
|
||||
wc.setWaitCursor();
|
||||
}
|
||||
}
|
||||
@@ -2126,11 +2185,11 @@ void messageHandlerCoin(const SoError* error, void* /*userdata*/)
|
||||
Base::Console().error("%s\n", msg);
|
||||
break;
|
||||
}
|
||||
#ifdef FC_OS_WIN32
|
||||
# ifdef FC_OS_WIN32
|
||||
if (old_qtmsg_handler) {
|
||||
(*old_qtmsg_handler)(QtDebugMsg, QMessageLogContext(), QString::fromLatin1(msg));
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
else if (error) {
|
||||
const char* msg = error->getDebugString().getString();
|
||||
@@ -2306,23 +2365,20 @@ void setAppNameAndIcon()
|
||||
QApplication::setApplicationName(QString::fromUtf8(it->second.c_str()));
|
||||
}
|
||||
else {
|
||||
QApplication::setApplicationName(
|
||||
QString::fromStdString(App::Application::getExecutableName()));
|
||||
QApplication::setApplicationName(QString::fromStdString(App::Application::getExecutableName()));
|
||||
}
|
||||
#ifndef Q_OS_MACOS
|
||||
QApplication::setWindowIcon(
|
||||
Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str()));
|
||||
Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str())
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tryRunEventLoop(GUISingleApplication& mainApp)
|
||||
{
|
||||
std::stringstream out;
|
||||
out << App::Application::getUserCachePath()
|
||||
<< App::Application::getExecutableName()
|
||||
<< "_"
|
||||
<< App::Application::applicationPid()
|
||||
<< ".lock";
|
||||
out << App::Application::getUserCachePath() << App::Application::getExecutableName() << "_"
|
||||
<< App::Application::applicationPid() << ".lock";
|
||||
|
||||
// open a lock file with the PID
|
||||
Base::FileInfo fi(out.str());
|
||||
@@ -2353,14 +2409,18 @@ void tryRunEventLoop(GUISingleApplication& mainApp)
|
||||
fi.deleteFile();
|
||||
}
|
||||
else {
|
||||
Base::Console().warning("Failed to create a file lock for the IPC.\n"
|
||||
"The application will be terminated\n");
|
||||
Base::Console().warning(
|
||||
"Failed to create a file lock for the IPC.\n"
|
||||
"The application will be terminated\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (const boost::interprocess::interprocess_exception& e) {
|
||||
QString msg = QString::fromLocal8Bit(e.what());
|
||||
Base::Console().warning("Failed to create a file lock for the IPC: %s\n",
|
||||
msg.toUtf8().constData());
|
||||
Base::Console().warning(
|
||||
"Failed to create a file lock for the IPC: %s\n",
|
||||
msg.toUtf8().constData()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2423,7 +2483,8 @@ void Application::runApplication()
|
||||
int argc = App::Application::GetARGC();
|
||||
GUISingleApplication mainApp(argc, App::Application::GetARGV());
|
||||
|
||||
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 406) && (defined(FC_OS_LINUX) || defined(FC_OS_BSD))
|
||||
#if (COIN_MAJOR_VERSION * 100 + COIN_MINOR_VERSION * 10 + COIN_MICRO_VERSION < 406) \
|
||||
&& (defined(FC_OS_LINUX) || defined(FC_OS_BSD))
|
||||
// If QT is running with native Wayland then inform Coin to use EGL
|
||||
if (QGuiApplication::platformName() == QString::fromStdString("wayland")) {
|
||||
setenv("COIN_EGL", "1", 1);
|
||||
@@ -2486,7 +2547,7 @@ void Application::runApplication()
|
||||
|
||||
bool Application::hiddenMainWindow()
|
||||
{
|
||||
const std::map<std::string,std::string>& cfg = App::Application::Config();
|
||||
const std::map<std::string, std::string>& cfg = App::Application::Config();
|
||||
auto it = cfg.find("StartHidden");
|
||||
|
||||
return it != cfg.end();
|
||||
@@ -2638,16 +2699,19 @@ void Application::checkForDeprecatedSettings()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document")
|
||||
->GetBool("CreateBackupFiles", true);
|
||||
if (makeBackups) {
|
||||
bool useFCBakExtension =
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Document")
|
||||
->GetBool("UseFCBakExtension", true);
|
||||
bool useFCBakExtension = App::GetApplication()
|
||||
.GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Document"
|
||||
)
|
||||
->GetBool("UseFCBakExtension", true);
|
||||
if (!useFCBakExtension) {
|
||||
// TODO: This should be translated
|
||||
Base::Console().warning("The `.FCStd#` backup format is deprecated and may "
|
||||
"be removed in future versions.\n"
|
||||
"To update, check the 'Preferences->General->Document->Use "
|
||||
"date and FCBak extension' option.\n");
|
||||
Base::Console().warning(
|
||||
"The `.FCStd#` backup format is deprecated and may "
|
||||
"be removed in future versions.\n"
|
||||
"To update, check the 'Preferences->General->Document->Use "
|
||||
"date and FCBak extension' option.\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2669,8 +2733,10 @@ void Application::checkForPreviousCrashes()
|
||||
}
|
||||
catch (const boost::interprocess::interprocess_exception& e) {
|
||||
QString msg = QString::fromLocal8Bit(e.what());
|
||||
Base::Console().warning("Failed check for previous crashes because of IPC error: %s\n",
|
||||
msg.toUtf8().constData());
|
||||
Base::Console().warning(
|
||||
"Failed check for previous crashes because of IPC error: %s\n",
|
||||
msg.toUtf8().constData()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2690,8 +2756,7 @@ App::Document* Application::reopen(App::Document* doc)
|
||||
WaitCursor wc;
|
||||
wc.setIgnoreEvents(WaitCursor::NoEvents);
|
||||
|
||||
if (doc->testStatus(App::Document::PartialDoc)
|
||||
|| doc->testStatus(App::Document::PartialRestore)) {
|
||||
if (doc->testStatus(App::Document::PartialDoc) || doc->testStatus(App::Document::PartialRestore)) {
|
||||
App::GetApplication().openDocument(name.c_str());
|
||||
}
|
||||
else {
|
||||
@@ -2715,9 +2780,7 @@ App::Document* Application::reopen(App::Document* doc)
|
||||
}
|
||||
|
||||
for (auto& file : docs) {
|
||||
App::DocumentInitFlags initFlags {
|
||||
.createView = false
|
||||
};
|
||||
App::DocumentInitFlags initFlags {.createView = false};
|
||||
App::GetApplication().openDocument(file.c_str(), initFlags);
|
||||
}
|
||||
}
|
||||
@@ -2758,23 +2821,23 @@ App::Document* Application::reopen(App::Document* doc)
|
||||
return doc;
|
||||
}
|
||||
|
||||
void Application::getVerboseDPIStyleInfo(QTextStream& str) {
|
||||
void Application::getVerboseDPIStyleInfo(QTextStream& str)
|
||||
{
|
||||
// Add Stylesheet/Theme/Qtstyle information
|
||||
std::string styleSheet =
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow")
|
||||
->GetASCII("StyleSheet");
|
||||
std::string theme =
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow")
|
||||
->GetASCII("Theme");
|
||||
std::string styleSheet = App::GetApplication()
|
||||
.GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/MainWindow"
|
||||
)
|
||||
->GetASCII("StyleSheet");
|
||||
std::string theme = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow")
|
||||
->GetASCII("Theme");
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
|
||||
std::string style = qApp->style()->name().toStdString();
|
||||
#else
|
||||
std::string style =
|
||||
App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow")
|
||||
->GetASCII("QtStyle");
|
||||
std::string style = App::GetApplication()
|
||||
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/MainWindow")
|
||||
->GetASCII("QtStyle");
|
||||
if (style.empty()) {
|
||||
style = "Qt default";
|
||||
}
|
||||
@@ -2791,10 +2854,7 @@ void Application::getVerboseDPIStyleInfo(QTextStream& str) {
|
||||
|
||||
// Add DPI information
|
||||
str << "Logical DPI/Physical DPI/Pixel Ratio: "
|
||||
<< QApplication::primaryScreen()->logicalDotsPerInch()
|
||||
<< "/"
|
||||
<< QApplication::primaryScreen()->physicalDotsPerInch()
|
||||
<< "/"
|
||||
<< QApplication::primaryScreen()->devicePixelRatio()
|
||||
<< "\n";
|
||||
<< QApplication::primaryScreen()->logicalDotsPerInch() << "/"
|
||||
<< QApplication::primaryScreen()->physicalDotsPerInch() << "/"
|
||||
<< QApplication::primaryScreen()->devicePixelRatio() << "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user