Fix #19113 Added "Swap" to "Copy, Cut, Paste" commands
This commit is contained in:
parent
fc849b08ed
commit
216ea9f1f3
8 changed files with 187 additions and 8 deletions
85
mscore/data/icons/edit-swap.svg
Normal file
85
mscore/data/icons/edit-swap.svg
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="16.016466"
|
||||
version="1.1"
|
||||
width="16"
|
||||
id="svg2"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="edit-swap.svg">
|
||||
<metadata
|
||||
id="metadata24">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs22" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="745"
|
||||
id="namedview20"
|
||||
showgrid="true"
|
||||
inkscape:zoom="64"
|
||||
inkscape:cx="9.7134418"
|
||||
inkscape:cy="13.163801"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g4">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3352" />
|
||||
</sodipodi:namedview>
|
||||
<g
|
||||
transform="translate(-41.0004,-123)"
|
||||
id="g4">
|
||||
<rect
|
||||
height="4"
|
||||
rx="0.53033006"
|
||||
ry="0.53033006"
|
||||
style="fill:#3b3f45"
|
||||
width="6"
|
||||
x="46.000393"
|
||||
y="123"
|
||||
id="rect6" />
|
||||
<path
|
||||
d="m 43.53125,124 c -0.292435,0 -0.647518,0.036 -1,0.3125 C 42.178768,124.58897 42,125.08125 42,125.4375 l 0,12.03125 c 0,0.384 0.128379,0.81517 0.4375,1.125 0.284782,0.28544 0.678742,0.44852 1.0625,0.4375 l 5.546875,-5e-5 -0.01563,-2.03125 -5.03125,0 0,-11 1,0 0,-2 -1.46875,0 z M 53,124 l 0,2 1,0 0,6.0625 2.015625,0 0.01563,-6.59375 c 7.9e-4,-0.33333 -0.150824,-0.82334 -0.4375,-1.09375 C 55.307075,124.10459 54.924184,124 54.625,124 Z"
|
||||
style="fill:#3b3f45;stroke-width:2"
|
||||
id="path8"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccsssccccccccccccccsssc" />
|
||||
<path
|
||||
d="m 56.016458,133.97513 -5.024812,-0.002 0.03159,5.06494 0.857063,-0.007 c 0.382876,-0.003 0.83411,-0.4532 0.830109,-0.84231 l -0.01378,-1.34034 1.889792,1.9206 c 0.791566,0.80456 1.979015,-0.40224 1.187349,-1.2067 l -1.916603,-1.88741 1.342547,0.0128 c 0.493604,0.005 0.800808,-0.46902 0.805711,-0.85176 z"
|
||||
style="fill:#3b3f45;stroke-width:2;enable-background:new"
|
||||
id="path12"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccssccccssc" />
|
||||
<path
|
||||
d="m 44.992618,133.08484 5.024806,0.002 -0.03155,-5.00244 -0.857063,0.007 c -0.382875,0.003 -0.834109,0.44762 -0.830111,0.83192 l 0.01379,1.3238 -1.889787,-1.89689 c -0.79157,-0.79464 -1.979017,0.39727 -1.187347,1.19181 l 1.916598,1.86412 -1.34255,-0.0127 c -0.493598,-0.005 -0.800805,0.46323 -0.805703,0.84125 z"
|
||||
style="fill:#3b3f45;stroke-width:2;enable-background:new"
|
||||
id="path12-5"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccssccccssc" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.3 KiB |
|
@ -62,6 +62,7 @@ static const char* iconNames[] = {
|
|||
"edit-cut.svg",
|
||||
"edit-copy.svg",
|
||||
"edit-paste.svg",
|
||||
"edit-swap.svg",
|
||||
"document-print.svg",
|
||||
"clef.svg",
|
||||
"midi-input.svg",
|
||||
|
|
|
@ -31,7 +31,7 @@ enum class Icons : signed char { Invalid_ICON = -1,
|
|||
natural_ICON, sharp_ICON, sharpsharp_ICON, flat_ICON, flatflat_ICON,
|
||||
quartrest_ICON, dot_ICON, dotdot_ICON,
|
||||
flip_ICON,
|
||||
undo_ICON, redo_ICON, cut_ICON, copy_ICON, paste_ICON, print_ICON, clef_ICON,
|
||||
undo_ICON, redo_ICON, cut_ICON, copy_ICON, paste_ICON, swap_ICON, print_ICON, clef_ICON,
|
||||
midiin_ICON, speaker_ICON, start_ICON, play_ICON, repeat_ICON, pan_ICON,
|
||||
sbeam_ICON, mbeam_ICON, nbeam_ICON, beam32_ICON, beam64_ICON, abeam_ICON, fbeam1_ICON, fbeam2_ICON,
|
||||
file_ICON, fileOpen_ICON, fileNew_ICON, fileSave_ICON, fileSaveAs_ICON,
|
||||
|
|
|
@ -549,6 +549,7 @@ MuseScore::MuseScore()
|
|||
getAction("undo")->setEnabled(false);
|
||||
getAction("redo")->setEnabled(false);
|
||||
getAction("paste")->setEnabled(false);
|
||||
getAction("swap")->setEnabled(false);
|
||||
selectionChanged(SelState::NONE);
|
||||
|
||||
//---------------------------------------------------
|
||||
|
@ -709,6 +710,7 @@ MuseScore::MuseScore()
|
|||
menuEdit->addAction(getAction("cut"));
|
||||
menuEdit->addAction(getAction("copy"));
|
||||
menuEdit->addAction(getAction("paste"));
|
||||
menuEdit->addAction(getAction("swap"));
|
||||
|
||||
menuEdit->addSeparator();
|
||||
menuEdit->addAction(getAction("select-all"));
|
||||
|
@ -2638,6 +2640,7 @@ void MuseScore::clipboardChanged()
|
|||
|
||||
bool flag = true;
|
||||
getAction("paste")->setEnabled(flag);
|
||||
getAction("swap")->setEnabled(flag);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -153,5 +153,6 @@
|
|||
<file>data/icons/arrow_up.svg</file>
|
||||
<file>data/icons/clef-bass.svg</file>
|
||||
<file>data/solid_note_head.dat</file>
|
||||
<file>data/icons/edit-swap.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -746,13 +746,16 @@ ScoreView::ScoreView(QWidget* parent)
|
|||
s->addTransition(new CommandTransition("mag", states[MAG])); // ->mag
|
||||
s->addTransition(new CommandTransition("play", states[PLAY])); // ->play
|
||||
s->addTransition(new CommandTransition("fotomode", states[FOTOMODE])); // ->fotomode
|
||||
ct = new CommandTransition("swap", 0); // swap
|
||||
connect(ct, SIGNAL(triggered()), SLOT(normalSwap()));
|
||||
s->addTransition(ct);
|
||||
ct = new CommandTransition("paste", 0); // paste
|
||||
connect(ct, SIGNAL(triggered()), SLOT(normalPaste()));
|
||||
s->addTransition(ct);
|
||||
ct = new CommandTransition("copy", 0); // copy
|
||||
connect(ct, SIGNAL(triggered()), SLOT(normalCopy()));
|
||||
s->addTransition(ct);
|
||||
ct = new CommandTransition("cut", 0); // copy
|
||||
ct = new CommandTransition("cut", 0); // cut
|
||||
connect(ct, SIGNAL(triggered()), SLOT(normalCut()));
|
||||
s->addTransition(ct);
|
||||
|
||||
|
@ -822,6 +825,10 @@ ScoreView::ScoreView(QWidget* parent)
|
|||
connect(ct, SIGNAL(triggered()), SLOT(editPaste()));
|
||||
s->addTransition(ct);
|
||||
|
||||
ct = new CommandTransition("swap", 0); // swap
|
||||
connect(ct, SIGNAL(triggered()), SLOT(editSwap()));
|
||||
s->addTransition(ct);
|
||||
|
||||
//----------------------------------
|
||||
// setup drag edit state
|
||||
//----------------------------------
|
||||
|
@ -1024,6 +1031,7 @@ void ScoreView::objectPopup(const QPoint& pos, Element* obj)
|
|||
popup->addAction(getAction("cut"));
|
||||
popup->addAction(getAction("copy"));
|
||||
popup->addAction(getAction("paste"));
|
||||
popup->addAction(getAction("swap"));
|
||||
|
||||
QMenu* selMenu = popup->addMenu(tr("Select"));
|
||||
selMenu->addAction(getAction("select-similar"));
|
||||
|
@ -1052,7 +1060,7 @@ void ScoreView::objectPopup(const QPoint& pos, Element* obj)
|
|||
if (a == 0)
|
||||
return;
|
||||
QString cmd(a->data().toString());
|
||||
if (cmd == "cut" || cmd =="copy" || cmd == "paste") {
|
||||
if (cmd == "cut" || cmd =="copy" || cmd == "paste" || cmd == "swap") {
|
||||
// these actions are already activated
|
||||
return;
|
||||
}
|
||||
|
@ -1128,6 +1136,7 @@ void ScoreView::measurePopup(const QPoint& gpos, Measure* obj)
|
|||
popup->addAction(getAction("cut"));
|
||||
popup->addAction(getAction("copy"));
|
||||
popup->addAction(getAction("paste"));
|
||||
popup->addAction(getAction("swap"));
|
||||
popup->addAction(getAction("delete"));
|
||||
popup->addAction(getAction("insert-measure"));
|
||||
popup->addSeparator();
|
||||
|
@ -1145,8 +1154,8 @@ void ScoreView::measurePopup(const QPoint& gpos, Measure* obj)
|
|||
if (a == 0)
|
||||
return;
|
||||
QString cmd(a->data().toString());
|
||||
if (cmd == "cut" || cmd =="copy" || cmd == "paste" || cmd == "insert-measure"
|
||||
|| cmd == "select-similar"
|
||||
if (cmd == "cut" || cmd =="copy" || cmd == "paste" || cmd == "swap"
|
||||
|| cmd == "insert-measure" || cmd == "select-similar"
|
||||
|| cmd == "delete") {
|
||||
// these actions are already activated
|
||||
return;
|
||||
|
@ -2547,6 +2556,21 @@ void ScoreView::normalCut()
|
|||
_score->endCmd();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// editSwap
|
||||
//---------------------------------------------------------
|
||||
|
||||
void ScoreView::editSwap()
|
||||
{
|
||||
if (editObject && editObject->isText() && !(editObject->type() == Element::Type::LYRICS)) {
|
||||
Text* text = static_cast<Text*>(editObject);
|
||||
QString s = text->selectedText();
|
||||
text->paste();
|
||||
if (!s.isEmpty())
|
||||
QApplication::clipboard()->setText(s, QClipboard::Clipboard);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// editPaste
|
||||
//---------------------------------------------------------
|
||||
|
@ -2561,11 +2585,58 @@ void ScoreView::editPaste()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// normalSwap
|
||||
//---------------------------------------------------------
|
||||
|
||||
void ScoreView::normalSwap()
|
||||
{
|
||||
if (!checkCopyOrCut())
|
||||
return;
|
||||
QString mimeType = _score->selection().mimeType();
|
||||
const QMimeData* ms = QApplication::clipboard()->mimeData();
|
||||
if (mimeType == mimeStaffListFormat) { // determine size of clipboard selection
|
||||
int tickLen = 0, staves = 0;
|
||||
QByteArray data(ms->data(mimeStaffListFormat));
|
||||
XmlReader e(data);
|
||||
e.readNextStartElement();
|
||||
if (e.name() == "StaffList") {
|
||||
tickLen = e.intAttribute("len", 0);
|
||||
staves = e.intAttribute("staves", 0);
|
||||
}
|
||||
if (tickLen > 0) { // attempt to extend selection to match clipboard size
|
||||
Segment* seg = _score->selection().startSegment();
|
||||
int tick = _score->selection().tickStart() + tickLen;
|
||||
Segment* segAfter = _score->tick2leftSegment(tick);
|
||||
int staffIdx = _score->selection().staffStart() + staves - 1;
|
||||
if (staffIdx >= _score->nstaves())
|
||||
staffIdx = _score->nstaves() - 1;
|
||||
tick = _score->selection().tickStart();
|
||||
int etick = tick + tickLen;
|
||||
if (MScore::debugMode)
|
||||
_score->selection().dump();
|
||||
_score->selection().extendRangeSelection(seg, segAfter, staffIdx, tick, etick);
|
||||
_score->selection().update();
|
||||
if (MScore::debugMode)
|
||||
_score->selection().dump();
|
||||
if (!checkCopyOrCut())
|
||||
return;
|
||||
ms = QApplication::clipboard()->mimeData();
|
||||
}
|
||||
}
|
||||
QByteArray data(_score->selection().mimeData());
|
||||
if (this->normalPaste()) {
|
||||
QMimeData* mimeData = new QMimeData;
|
||||
mimeData->setData(mimeType, data);
|
||||
QApplication::clipboard()->setMimeData(mimeData);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// normalPaste
|
||||
//---------------------------------------------------------
|
||||
|
||||
void ScoreView::normalPaste()
|
||||
bool ScoreView::normalPaste()
|
||||
{
|
||||
_score->startCmd();
|
||||
|
||||
|
@ -2595,6 +2666,11 @@ void ScoreView::normalPaste()
|
|||
}
|
||||
|
||||
_score->endCmd();
|
||||
|
||||
if (status == PasteState::PS_NO_ERROR)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -2627,7 +2703,7 @@ void ScoreView::cmd(const QAction* a)
|
|||
sm->postEvent(new CommandEvent(cmd));
|
||||
}
|
||||
else if (cmd == "note-input" || cmd == "copy" || cmd == "paste"
|
||||
|| cmd == "cut" || cmd == "fotomode") {
|
||||
|| cmd == "swap" || cmd == "cut" || cmd == "fotomode") {
|
||||
sm->postEvent(new CommandEvent(cmd));
|
||||
}
|
||||
else if (cmd == "lyrics") {
|
||||
|
|
|
@ -302,11 +302,13 @@ class ScoreView : public QWidget, public MuseScoreView {
|
|||
void editCopy();
|
||||
void editCut();
|
||||
void editPaste();
|
||||
void editSwap();
|
||||
|
||||
void normalCut();
|
||||
void normalCopy();
|
||||
void fotoModeCopy();
|
||||
void normalPaste();
|
||||
bool normalPaste();
|
||||
void normalSwap();
|
||||
|
||||
void cloneElement(Element* e);
|
||||
void doFotoDragEdit(QMouseEvent* ev);
|
||||
|
|
|
@ -214,6 +214,17 @@ Shortcut Shortcut::_sc[] = {
|
|||
Icons::paste_ICON,
|
||||
Qt::ApplicationShortcut
|
||||
},
|
||||
{
|
||||
MsWidget::SCORE_TAB,
|
||||
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_TEXT_EDIT |STATE_LYRICS_EDIT
|
||||
| STATE_HARMONY_FIGBASS_EDIT,
|
||||
"swap",
|
||||
QT_TRANSLATE_NOOP("action","Swap Clipboard and Selection"),
|
||||
0,
|
||||
0,
|
||||
Icons::swap_ICON,
|
||||
Qt::ApplicationShortcut
|
||||
},
|
||||
{
|
||||
MsWidget::MAIN_WINDOW,
|
||||
STATE_NORMAL | STATE_NOTE_ENTRY,
|
||||
|
|
Loading…
Reference in a new issue