Merge branch 'FreeCAD:main' into CAM_Fix_SetupSheet_Table_MinHeight

This commit is contained in:
Syres916
2025-10-18 11:27:03 +01:00
committed by GitHub
845 changed files with 34569 additions and 593180 deletions

View File

@@ -1371,11 +1371,10 @@ Gui::MDIView* Application::editViewOfNode(SoNode* node) const
void Application::setEditDocument(Gui::Document* doc)
{
if (doc == d->editDocument) {
return;
}
if (!doc) {
d->editDocument = nullptr;
} else if (doc == d->editDocument) {
return;
}
for (auto& v : d->documents) {
v.second->_resetEdit();

View File

@@ -1603,7 +1603,7 @@ void StdCmdPlacement::activated(int iMsg)
bool StdCmdPlacement::isActive()
{
std::vector<App::DocumentObject*> sel = Gui::Selection().getObjectsOfType(App::GeoFeature::getClassTypeId());
return (sel.size() == 1 && ! sel.front()->isFreezed());
return !(sel.empty() || std::ranges::any_of(sel, [](auto obj){return obj->isFreezed();}));
}
//===========================================================================

View File

@@ -349,12 +349,21 @@ void DlgAddProperty::addEnumEditor(PropertyItem* propertyItem)
void DlgAddProperty::addNormalEditor(PropertyItem* propertyItem)
{
editor.reset(propertyItem->createEditor(this, []() {},
FrameOption::WithFrame));
editor.reset(propertyItem->createEditor(this, [this]() {
this->valueChanged();
}, FrameOption::WithFrame));
}
void DlgAddProperty::addEditor(PropertyItem* propertyItem)
{
if (isSubLinkPropertyItem()) {
// Since sublinks need the 3D view to select an object and the dialog
// is modal, we do not provide an editor for sublinks. It is possible
// to create a property of this type though and the property can be set
// in the property view later which does give access to the 3D view.
return;
}
if (isEnumPropertyItem()) {
addEnumEditor(propertyItem);
}
@@ -404,6 +413,10 @@ bool DlgAddProperty::isTypeWithEditor(const Base::Type& type)
App::PropertyFloatList::getClassTypeId(),
App::PropertyFont::getClassTypeId(),
App::PropertyIntegerList::getClassTypeId(),
App::PropertyLink::getClassTypeId(),
App::PropertyLinkSub::getClassTypeId(),
App::PropertyLinkList::getClassTypeId(),
App::PropertyLinkSubList::getClassTypeId(),
App::PropertyMaterialList::getClassTypeId(),
App::PropertyPath::getClassTypeId(),
App::PropertyString::getClassTypeId(),
@@ -619,6 +632,13 @@ bool DlgAddProperty::isEnumPropertyItem() const
QString::fromLatin1(App::PropertyEnumeration::getClassTypeId().getName());
}
bool DlgAddProperty::isSubLinkPropertyItem() const
{
const QString& type = ui->comboBoxType->currentText();
return type == QString::fromLatin1(App::PropertyLinkSub::getClassTypeId().getName()) ||
type == QString::fromLatin1(App::PropertyLinkSubList::getClassTypeId().getName());
}
QVariant DlgAddProperty::getEditorData() const
{
if (isEnumPropertyItem()) {
@@ -663,6 +683,11 @@ void DlgAddProperty::setEditor(bool valueNeedsReset)
else {
initializeValue();
}
if (editor) {
QVariant data = propertyItem->editorData(editor.get());
propertyItem->setData(data);
}
}
void DlgAddProperty::setPropertyItem(App::Property* prop, bool supportsExpressions)
@@ -807,6 +832,12 @@ void DlgAddProperty::valueChangedEnum()
propEnum->setEnums(enumValuesVec);
}
void DlgAddProperty::valueChanged()
{
QVariant data = propertyItem->editorData(editor.get());
propertyItem->setData(data);
}
/* We use these functions rather than the functions provided by App::Document
* because this dialog may be opened when another transaction is in progress.
* An example is opening a sketch. If this dialog uses the functions provided
@@ -924,10 +955,6 @@ void DlgAddProperty::addDocumentation() {
void DlgAddProperty::accept()
{
if (editor) {
QVariant data = propertyItem->editorData(editor.get());
propertyItem->setData(data);
}
addDocumentation();
auto* object = freecad_cast<App::DocumentObject*>(container);
if (object) {

View File

@@ -95,6 +95,7 @@ public:
QLayout* layout);
public Q_SLOTS:
void valueChanged();
void valueChangedEnum();
private:
@@ -122,6 +123,7 @@ private:
void removeSelectionEditor();
QVariant getEditorData() const;
void setEditorData(const QVariant& data);
bool isSubLinkPropertyItem() const;
bool isEnumPropertyItem() const;
void addEnumEditor(PropertyEditor::PropertyItem* propertyItem);
void addNormalEditor(PropertyEditor::PropertyItem* propertyItem);

View File

@@ -99,7 +99,6 @@ bool MacroFile::commit()
}
QString header;
header += QStringLiteral("# -*- coding: utf-8 -*-\n\n");
header += QStringLiteral("# Macro Begin: ");
header += this->macroName;
header += QStringLiteral(" +++++++++++++++++++++++++++++++++++++++++++++++++\n");

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com>*
# * *

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com>*
# * *

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#/******************************************************************************
# * Copyright (c) 2020 Werner Mayer <wmayer[at]users.sourceforge.net> *
# * *

View File

@@ -4064,6 +4064,8 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view,
// during item creation or deletion
bool lock = blockSelection(true);
bool needUpdate = false;
QTreeWidgetItem* newFocusItem = nullptr;
bool hadFocus = (QApplication::focusWidget() == this);
for (const auto& data : itEntry->second) {
DocumentItem* docItem = data->docItem;
@@ -4078,8 +4080,25 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view,
for (auto cit = items.begin(), citNext = cit; cit != items.end(); cit = citNext) {
++citNext;
(*cit)->myOwner = nullptr;
delete* cit;
DocumentObjectItem* itemToDelete = *cit;
// get next item based on currently deleted item to select it
// as the next one
if (currentItem() == itemToDelete && !newFocusItem) {
QTreeWidgetItem* parent = itemToDelete->parent();
int index = parent->indexOfChild(itemToDelete);
if (index > 0) {
newFocusItem = parent->child(index - 1);
} else if (parent->childCount() > 1) {
newFocusItem = parent->child(index + 1);
} else {
// no siblings, move to parent
newFocusItem = parent;
}
}
itemToDelete->myOwner = nullptr;
delete itemToDelete;
}
// Check for any child of the deleted object that is not in the tree, and put it
@@ -4110,6 +4129,20 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view,
// Restore signal state
blockSelection(lock);
// restore focus to the appropriate item after deletion
if (newFocusItem) {
setCurrentItem(newFocusItem);
newFocusItem->setSelected(true);
}
// restore focus to the tree widget if it had focus before deletion
if (hadFocus) {
QTimer::singleShot(0, this, [this]() {
setFocus(Qt::OtherFocusReason);
activateWindow();
});
}
if (needUpdate)
_updateStatus();
}

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# ***************************************************************************
# * Copyright (c) 2022 Zheng Lei (realthunder) <realthunder.dev@gmail.com>*
# * *

View File

@@ -149,9 +149,9 @@ void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) {
QString cmd;
cmd = QStringLiteral("App.getDocument(\"%1\").getObject(\"%2\").addObject("
"App.getDocument(\"%1\").getObject(\"%3\"))")
.arg(QString::fromLatin1(doc->getName()),
QString::fromLatin1(grp->getNameInDocument()),
QString::fromLatin1(obj->getNameInDocument()));
.arg(QString::fromUtf8(doc->getName()),
QString::fromUtf8(grp->getNameInDocument()),
QString::fromUtf8(obj->getNameInDocument()));
Gui::Command::doCommand(Gui::Command::App, cmd.toUtf8());
}