Skip to content

Commit

Permalink
Merge pull request #5289 from dmitrio95/palette-model-view-squashed
Browse files Browse the repository at this point in the history
Inital version of the redesigned palettes
  • Loading branch information
anatoly-os committed Aug 31, 2019
2 parents 4c61088 + a1a940c commit c3f76ef
Show file tree
Hide file tree
Showing 53 changed files with 7,019 additions and 187 deletions.
3 changes: 3 additions & 0 deletions build/gen-qt-projectfile
Expand Up @@ -20,4 +20,7 @@ for a in $uis; do
echo " " $a \\;
done
echo

echo "RESOURCES = ./mscore/qml.qrc"

echo
2 changes: 2 additions & 0 deletions build/gen-qt-projectfile.bat
Expand Up @@ -17,4 +17,6 @@ for /r %1 %%a in (*.cpp) do echo %%a \
echo.
echo.

echo RESOURCES = ./mscore/qml.qrc

cd /d %OLD_DIR%
22 changes: 22 additions & 0 deletions libmscore/element.cpp
Expand Up @@ -948,6 +948,28 @@ ElementType Element::readType(XmlReader& e, QPointF* dragOffset,
return ElementType::INVALID;
}

//---------------------------------------------------------
// readMimeData
//---------------------------------------------------------

Element* Element::readMimeData(Score* score, const QByteArray& data, QPointF* dragOffset, Fraction* duration)
{
XmlReader e(data);
const ElementType type = Element::readType(e, dragOffset, duration);
e.setPasteMode(true);

if (type == ElementType::INVALID) {
qDebug("cannot read type");
return nullptr;
}

Element* el = Element::create(type, score);
if (el)
el->read(e);

return el;
}

//---------------------------------------------------------
// add
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/element.h
Expand Up @@ -341,6 +341,7 @@ class Element : public ScoreElement {
void undoSetVisible(bool v);

static ElementType readType(XmlReader& node, QPointF*, Fraction*);
static Element* readMimeData(Score* score, const QByteArray& data, QPointF*, Fraction*);

virtual QByteArray mimeData(const QPointF&) const;
/**
Expand Down
72 changes: 32 additions & 40 deletions libmscore/paste.cpp
Expand Up @@ -957,60 +957,52 @@ void Score::cmdPaste(const QMimeData* ms, MuseScoreView* view, Fraction scale)
if ((_selection.isSingle() || _selection.isList()) && ms->hasFormat(mimeSymbolFormat)) {
QByteArray data(ms->data(mimeSymbolFormat));

XmlReader e(data);
QPointF dragOffset;
Fraction duration(1, 4);
ElementType type = Element::readType(e, &dragOffset, &duration);
e.setPasteMode(true);
std::unique_ptr<Element> el(Element::readMimeData(this, data, &dragOffset, &duration));

if (!el)
return;

QList<Element*> els;
if (_selection.isSingle())
els.append(_selection.element());
else
els.append(_selection.elements());

if (type != ElementType::INVALID) {
Element* el = Element::create(type, this);
if (el) {
el->read(e);
for (Element* target : els) {
el->setTrack(target->track());
Element* nel = el->clone();
addRefresh(target->abbox()); // layout() ?!
EditData ddata(view);
ddata.view = view;
ddata.dropElement = nel;
ddata.duration = duration;
if (target->acceptDrop(ddata)) {
if (type == ElementType::NOTE) {
// dropping a note replaces and invalidates the target,
// so we need to deselect it
ElementType targetType = target->type();
deselect(target);
for (Element* target : els) {
el->setTrack(target->track());
Element* nel = el->clone();
addRefresh(target->abbox()); // layout() ?!
EditData ddata(view);
ddata.view = view;
ddata.dropElement = nel;
ddata.duration = duration;
if (target->acceptDrop(ddata)) {
if (el->isNote()) {
// dropping a note replaces and invalidates the target,
// so we need to deselect it
ElementType targetType = target->type();
deselect(target);

// perform the drop
target->drop(ddata);
// perform the drop
target->drop(ddata);

// if the target is a rest rather than a note,
// a new note is generated, and nel becomes invalid as well
// (ChordRest::drop() will select it for us)
if (targetType == ElementType::NOTE)
select(nel);
}
else {
target->drop(ddata);
}
if (_selection.element())
addRefresh(_selection.element()->abbox());
}
else
delete nel;
// if the target is a rest rather than a note,
// a new note is generated, and nel becomes invalid as well
// (ChordRest::drop() will select it for us)
if (targetType == ElementType::NOTE)
select(nel);
}
else {
target->drop(ddata);
}
if (_selection.element())
addRefresh(_selection.element()->abbox());
}
delete el;
else
delete nel;
}
else
qDebug("cannot read type");
}
else if ((_selection.isRange() || _selection.isList()) && ms->hasFormat(mimeStaffListFormat)) {
ChordRest* cr = 0;
Expand Down
12 changes: 11 additions & 1 deletion mscore/CMakeLists.txt
Expand Up @@ -52,6 +52,7 @@ if (SCRIPT_INTERFACE)
set (SCRIPT_FILES
plugin/pluginCreator.h plugin/pluginManager.h plugin/qmledit.h
plugin/qmlplugin.h plugin/qmlpluginengine.h
plugin/qmliconview.h
plugin/api/qmlpluginapi.h plugin/api/cursor.h plugin/api/scoreelement.h plugin/api/elements.h
plugin/api/part.h
plugin/api/score.h
Expand All @@ -65,6 +66,7 @@ if (SCRIPT_INTERFACE)
plugin/api/enums.cpp
plugin/mscorePlugins.cpp plugin/pluginCreator.cpp plugin/pluginManager.cpp plugin/qmledit.cpp
plugin/qmlplugin.cpp plugin/qmlpluginengine.cpp
plugin/qmliconview.cpp
plugin/api/qmlpluginapi.cpp plugin/api/cursor.cpp plugin/api/scoreelement.cpp plugin/api/elements.cpp
plugin/api/score.cpp
plugin/api/excerpt.cpp
Expand Down Expand Up @@ -206,9 +208,13 @@ QT5_WRAP_UI (ui_headers
)

if (APPLE)
QT5_ADD_RESOURCES (qrc_files musescore.qrc musescorefonts-Mac.qrc shortcut-Mac.qrc)
QT5_ADD_RESOURCES (qrc_files musescore.qrc
qml.qrc # TODO: replace with qtquick_compiler_add_resources on Qt >= 5.11
musescorefonts-Mac.qrc shortcut-Mac.qrc
)
else (APPLE)
QT5_ADD_RESOURCES (qrc_files musescore.qrc
qml.qrc # TODO: replace with qtquick_compiler_add_resources on Qt >= 5.11
musescorefonts-MScore.qrc
musescorefonts-Gootville.qrc
musescorefonts-Bravura.qrc
Expand Down Expand Up @@ -384,6 +390,7 @@ add_executable ( ${ExecutableName}
selinstrument.cpp editstafftype.cpp texttools.cpp
editpitch.cpp editstringdata.cpp editraster.cpp pianotools.cpp mediadialog.cpp
workspace.cpp workspacedialog.cpp chordview.cpp
workspacecombobox.cpp
albummanager.cpp
stafftextproperties.cpp splitstaff.cpp
tupletdialog.cpp
Expand Down Expand Up @@ -466,6 +473,8 @@ add_executable ( ${ExecutableName}
importmidi/importmidi_voice.cpp importmidi/importmidi_view.cpp importmidi/importmidi_key.cpp
importmidi/importmidi_tempo.cpp importmidi/importmidi_instrument.cpp
importmidi/importmidi_chordname.cpp
palette/palettedialogs.cpp
palette/palettemodel.cpp palette/palettetree.cpp palette/paletteworkspace.cpp palette/palettewidget.cpp
scorecmp/scorecmp.cpp scorecmp/scorediffmodel.cpp scorecmp/scorelistmodel.cpp
resourceManager.cpp downloadUtils.cpp
textcursor.cpp continuouspanel.cpp accessibletoolbutton.cpp scoreaccessibility.cpp
Expand All @@ -480,6 +489,7 @@ add_executable ( ${ExecutableName}
extension.cpp extension.h
tourhandler.cpp
script/script.cpp script/scriptentry.cpp script/testscript.cpp script/recorderwidget.cpp
qmldockwidget.cpp

${WIDGETS_SOURCE_FILES}
${COCOABRIDGE}
Expand Down
18 changes: 16 additions & 2 deletions mscore/dragdrop.cpp
Expand Up @@ -210,12 +210,18 @@ void ScoreView::dragEnterEvent(QDragEnterEvent* event)
const QMimeData* dta = event->mimeData();

if (dta->hasFormat(mimeSymbolListFormat) || dta->hasFormat(mimeStaffListFormat)) {
event->accept();
if (event->possibleActions() & Qt::CopyAction) {
event->setDropAction(Qt::CopyAction);
event->accept();
}
return;
}

if (dta->hasFormat(mimeSymbolFormat)) {
event->accept();
if (event->possibleActions() & Qt::CopyAction) {
event->setDropAction(Qt::CopyAction);
event->accept();
}

QByteArray a = dta->data(mimeSymbolFormat);

Expand Down Expand Up @@ -336,6 +342,14 @@ void ScoreView::dragMoveEvent(QDragMoveEvent* event)
return;
}

const QMimeData* dta = event->mimeData();
if (dta->hasFormat(mimeSymbolFormat)
|| dta->hasFormat(mimeSymbolListFormat)
|| dta->hasFormat(mimeStaffListFormat)) {
if (event->possibleActions() & Qt::CopyAction)
event->setDropAction(Qt::CopyAction);
}

// convert window to canvas position
QPointF pos(imatrix.map(QPointF(event->pos())));
editData.pos = pos;
Expand Down

0 comments on commit c3f76ef

Please sign in to comment.