Skip to content

Commit

Permalink
Merge pull request musescore#25296 from krasko78/20859-TextProperties…
Browse files Browse the repository at this point in the history
…InPropertiesPanelNotUpdated

musescore#20859: Text properties in the Properties panel are not updated
  • Loading branch information
cbjeukendrup authored Oct 28, 2024
2 parents 0da8989 + 2fb56e5 commit 059ced3
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 46 deletions.
144 changes: 98 additions & 46 deletions src/inspector/models/text/textsettingsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ void TextSettingsModel::createProperties()
m_frameMargin = buildPropertyItem(mu::engraving::Pid::FRAME_PADDING);
m_frameCornerRadius = buildPropertyItem(mu::engraving::Pid::FRAME_ROUND);

m_textType = buildPropertyItem(mu::engraving::Pid::TEXT_STYLE);
m_textType = buildPropertyItem(mu::engraving::Pid::TEXT_STYLE, [this](const mu::engraving::Pid pid, const QVariant& newValue) {
onPropertyValueChanged(pid, newValue);
emit requestReloadPropertyItems();
});
m_textPlacement = buildPropertyItem(mu::engraving::Pid::PLACEMENT);
m_textScriptAlignment = buildPropertyItem(mu::engraving::Pid::TEXT_SCRIPT_ALIGN);
}
Expand All @@ -100,55 +103,108 @@ void TextSettingsModel::requestElements()

void TextSettingsModel::loadProperties()
{
loadPropertyItem(m_fontFamily, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toString() == mu::engraving::TextBase::UNDEFINED_FONT_FAMILY
? QVariant() : elementPropertyValue.toString();
});

m_fontFamily->setIsEnabled(true);
static const PropertyIdSet propertyIdSet {
Pid::FONT_FACE,
Pid::FONT_STYLE,
Pid::FONT_SIZE,
Pid::TEXT_LINE_SPACING,
Pid::ALIGN,
Pid::TEXT_SIZE_SPATIUM_DEPENDENT,
Pid::FRAME_TYPE,
Pid::FRAME_BG_COLOR,
Pid::FRAME_FG_COLOR,
Pid::FRAME_WIDTH,
Pid::FRAME_PADDING,
Pid::FRAME_ROUND,
Pid::TEXT_STYLE,
Pid::PLACEMENT,
Pid::TEXT_SCRIPT_ALIGN
};

loadProperties(propertyIdSet);
}

void TextSettingsModel::loadProperties(const PropertyIdSet& propertyIdSet)
{
if (muse::contains(propertyIdSet, Pid::FONT_FACE)) {
loadPropertyItem(m_fontFamily, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toString() == mu::engraving::TextBase::UNDEFINED_FONT_FAMILY
? QVariant() : elementPropertyValue.toString();
});

m_fontFamily->setIsEnabled(true);
}

loadPropertyItem(m_fontStyle, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toInt() == static_cast<int>(mu::engraving::FontStyle::Undefined)
? QVariant() : elementPropertyValue.toInt();
});
if (muse::contains(propertyIdSet, Pid::FONT_STYLE)) {
loadPropertyItem(m_fontStyle, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toInt() == static_cast<int>(mu::engraving::FontStyle::Undefined)
? QVariant() : elementPropertyValue.toInt();
});

m_fontStyle->setIsEnabled(true);
m_fontStyle->setIsEnabled(true);
}

loadPropertyItem(m_fontSize, [](const QVariant& elementPropertyValue) -> QVariant {
return muse::RealIsEqual(elementPropertyValue.toDouble(), mu::engraving::TextBase::UNDEFINED_FONT_SIZE)
? QVariant() : elementPropertyValue.toDouble();
});
if (muse::contains(propertyIdSet, Pid::FONT_SIZE)) {
loadPropertyItem(m_fontSize, [](const QVariant& elementPropertyValue) -> QVariant {
return muse::RealIsEqual(elementPropertyValue.toDouble(), mu::engraving::TextBase::UNDEFINED_FONT_SIZE)
? QVariant() : elementPropertyValue.toDouble();
});

m_fontSize->setIsEnabled(true);
m_fontSize->setIsEnabled(true);
}

loadPropertyItem(m_textLineSpacing, formatDoubleFunc);
if (muse::contains(propertyIdSet, Pid::TEXT_LINE_SPACING)) {
loadPropertyItem(m_textLineSpacing, formatDoubleFunc);
}

loadPropertyItem(m_horizontalAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
QVariantList list = elementPropertyValue.toList();
return list.size() >= 2 ? list[0] : QVariant();
});
if (muse::contains(propertyIdSet, Pid::ALIGN)) {
loadPropertyItem(m_horizontalAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
QVariantList list = elementPropertyValue.toList();
return list.size() >= 2 ? list[0] : QVariant();
});

loadPropertyItem(m_verticalAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
QVariantList list = elementPropertyValue.toList();
return list.size() >= 2 ? list[1] : QVariant();
});
loadPropertyItem(m_verticalAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
QVariantList list = elementPropertyValue.toList();
return list.size() >= 2 ? list[1] : QVariant();
});
}

loadPropertyItem(m_isSizeSpatiumDependent);
if (muse::contains(propertyIdSet, Pid::TEXT_SIZE_SPATIUM_DEPENDENT)) {
loadPropertyItem(m_isSizeSpatiumDependent);
}

loadPropertyItem(m_frameType);
loadPropertyItem(m_frameBorderColor);
loadPropertyItem(m_frameFillColor);
if (muse::contains(propertyIdSet, Pid::FRAME_TYPE)) {
loadPropertyItem(m_frameType);
}
if (muse::contains(propertyIdSet, Pid::FRAME_FG_COLOR)) {
loadPropertyItem(m_frameBorderColor);
}
if (muse::contains(propertyIdSet, Pid::FRAME_BG_COLOR)) {
loadPropertyItem(m_frameFillColor);
}

loadPropertyItem(m_frameThickness, formatDoubleFunc);
loadPropertyItem(m_frameMargin, formatDoubleFunc);
loadPropertyItem(m_frameCornerRadius, formatDoubleFunc);
if (muse::contains(propertyIdSet, Pid::FRAME_WIDTH)) {
loadPropertyItem(m_frameThickness, formatDoubleFunc);
}
if (muse::contains(propertyIdSet, Pid::FRAME_PADDING)) {
loadPropertyItem(m_frameMargin, formatDoubleFunc);
}
if (muse::contains(propertyIdSet, Pid::FRAME_ROUND)) {
loadPropertyItem(m_frameCornerRadius, formatDoubleFunc);
}

loadPropertyItem(m_textType);
loadPropertyItem(m_textPlacement);
loadPropertyItem(m_textScriptAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toInt() == static_cast<int>(mu::engraving::VerticalAlignment::AlignUndefined)
? QVariant() : elementPropertyValue.toInt();
});
if (muse::contains(propertyIdSet, Pid::TEXT_STYLE)) {
loadPropertyItem(m_textType);
}
if (muse::contains(propertyIdSet, Pid::PLACEMENT)) {
loadPropertyItem(m_textPlacement);
}
if (muse::contains(propertyIdSet, Pid::TEXT_SCRIPT_ALIGN)) {
loadPropertyItem(m_textScriptAlignment, [](const QVariant& elementPropertyValue) -> QVariant {
return elementPropertyValue.toInt() == static_cast<int>(mu::engraving::VerticalAlignment::AlignUndefined)
? QVariant() : elementPropertyValue.toInt();
});
}

updateFramePropertiesAvailability();
updateStaffPropertiesAvailability();
Expand Down Expand Up @@ -178,6 +234,8 @@ void TextSettingsModel::resetProperties()

void TextSettingsModel::onNotationChanged(const PropertyIdSet& changedProperyIds, const StyleIdSet& changedStyleIds)
{
loadProperties(changedProperyIds);

for (Sid s : {
Sid::user1Name,
Sid::user2Name,
Expand All @@ -195,15 +253,9 @@ void TextSettingsModel::onNotationChanged(const PropertyIdSet& changedProperyIds
if (changedStyleIds.find(s) != changedStyleIds.cend()) {
m_textStyles.clear();
emit textStylesChanged();
return;
break;
}
}

if (muse::contains(changedProperyIds, Pid::PLACEMENT)) {
loadPropertyItem(m_textPlacement);
}

updateIsHorizontalAlignmentAvailable();
}

void TextSettingsModel::insertSpecialCharacters()
Expand Down
2 changes: 2 additions & 0 deletions src/inspector/models/text/textsettingsmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public slots:
void updateIsDynamicSpecificSettings();
void updateIsHorizontalAlignmentAvailable();

void loadProperties(const mu::engraving::PropertyIdSet& propertyIdSet);

PropertyItem* m_fontFamily = nullptr;
PropertyItem* m_fontStyle = nullptr;
PropertyItem* m_fontSize = nullptr;
Expand Down

0 comments on commit 059ced3

Please sign in to comment.