Skip to content

Commit b29a4d5

Browse files
committed
Add copy/paste for server's actions
1 parent 61712c7 commit b29a4d5

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/server/gui/server_ui.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,12 +833,41 @@ void mbServerUi::menuSlotWindowDeviceCloseActive()
833833

834834
void mbServerUi::slotActionCopy()
835835
{
836-
836+
QList<mbServerAction*> selectedItems = m_actionsUi->selectedItems();
837+
if (selectedItems.count())
838+
{
839+
QBuffer buff;
840+
buff.open(QIODevice::ReadWrite);
841+
builder()->exportActions(&buff, selectedItems);
842+
buff.seek(0);
843+
QByteArray b = buff.readAll();
844+
QApplication::clipboard()->setText(QString::fromUtf8(b));
845+
}
837846
}
838847

839848
void mbServerUi::slotActionPaste()
840849
{
841-
850+
if (core()->isRunning())
851+
return;
852+
mbServerProject *project = core()->project();
853+
if (project)
854+
{
855+
QString text = QApplication::clipboard()->text();
856+
if (text.isEmpty())
857+
return;
858+
QByteArray b = text.toUtf8();
859+
QBuffer buff(&b);
860+
buff.open(QIODevice::ReadOnly);
861+
QList<mbServerAction*> items = builder()->importActions(&buff);
862+
if (items.count())
863+
{
864+
int index = -1;
865+
QList<mbServerAction*> selectedItems = m_actionsUi->selectedItems();
866+
if (selectedItems.count())
867+
index = project->actionIndex(selectedItems.first());
868+
project->actionsInsert(items, index);
869+
}
870+
}
842871
}
843872

844873
void mbServerUi::slotActionSelectAll()

0 commit comments

Comments
 (0)