Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/palette/internal/palettecell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "engraving/dom/textbase.h"
#include "engraving/dom/tremolosinglechord.h"
#include "engraving/dom/tremolotwochord.h"
#include "engraving/types/typesconv.h"

#include "engraving/rw/rwregister.h"
#include "engraving/rw/compat/tremolocompat.h"
Expand All @@ -45,6 +46,30 @@ using namespace muse;
using namespace mu::palette;
using namespace mu::engraving;

static ElementPtr makeParenthesesActionIcon()
{
const muse::actions::ActionCode code = "add-parentheses";
auto icon = std::make_shared<ActionIcon>(gpaletteScore->dummy());
icon->setActionType(ActionIconType::PARENTHESES);
icon->setAction(code, 0);
return icon;
}

static ElementPtr makeElementFromMimeData(const QByteArray& data)
{
PointF dragOffset;
Fraction duration(1, 4);
muse::ByteArray byteArray = ByteArray::fromQByteArrayNoCopy(data);
XmlReader typeReader(byteArray);
const ElementType type = EngravingItem::readType(typeReader, &dragOffset, &duration);

if (type == ElementType::PARENTHESIS) {
return makeParenthesesActionIcon();
}

return ElementPtr(EngravingItem::readMimeData(gpaletteScore, byteArray, &dragOffset, &duration));
}

static bool needsStaff(ElementPtr e)
{
if (!e) {
Expand Down Expand Up @@ -323,9 +348,7 @@ PaletteCellPtr PaletteCell::fromMimeData(const QByteArray& data, const muse::mod

PaletteCellPtr PaletteCell::fromElementMimeData(const QByteArray& data, const muse::modularity::ContextPtr& iocCtx)
{
PointF dragOffset;
Fraction duration(1, 4);
ElementPtr element(EngravingItem::readMimeData(gpaletteScore, ByteArray::fromQByteArrayNoCopy(data), &dragOffset, &duration));
ElementPtr element = makeElementFromMimeData(data);

if (!element) {
return nullptr;
Expand All @@ -344,7 +367,10 @@ PaletteCellPtr PaletteCell::fromElementMimeData(const QByteArray& data, const mu
}
}

const String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName();
String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName();
if (element->isActionIcon() && toActionIcon(element.get())->actionType() == ActionIconType::PARENTHESES) {
name = TConv::capitalizedUserName(ElementType::ACCIDENTAL).translated();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that this part of the fix is for consistency ONLY. It is not in a right direction, in the perspective of #34514

}

return std::make_shared<PaletteCell>(iocCtx, element, name);
}
Expand Down
Loading