Paste copied macro action depending on cursor position

If cursor is above else action section paste it there.
If cursor is above regular action section paste it there.

In case of neither paste in original position.
This commit is contained in:
WarmUpTill
2024-08-13 21:39:24 +02:00
committed by WarmUpTill
parent 2f4f8bcc74
commit 1a1028cbaa
4 changed files with 52 additions and 15 deletions

View File

@@ -1,5 +1,7 @@
#include "macro-segment-copy-paste.hpp"
#include "advanced-scene-switcher.hpp"
#include "macro.hpp"
#include "ui-helpers.hpp"
#include <QShortcut>
@@ -74,10 +76,22 @@ void AdvSceneSwitcher::PasteMacroSegment()
break;
}
case MacroSegmentCopyInfo::Type::ACTION:
if (IsCursorInWidgetArea(ui->macroElseActions)) {
AddMacroElseAction(macro.get(),
macro->ElseActions().size(),
copyInfo.segment->GetId(),
data.Get());
break;
}
AddMacroAction(macro.get(), macro->Actions().size(),
copyInfo.segment->GetId(), data.Get());
break;
case MacroSegmentCopyInfo::Type::ELSE:
if (IsCursorInWidgetArea(ui->macroActions)) {
AddMacroAction(macro.get(), macro->Actions().size(),
copyInfo.segment->GetId(), data.Get());
break;
}
AddMacroElseAction(macro.get(), macro->ElseActions().size(),
copyInfo.segment->GetId(), data.Get());
break;
@@ -91,6 +105,12 @@ bool MacroSegmentIsInClipboard()
return copyInfo.type != MacroSegmentCopyInfo::Type::NONE;
}
bool MacroActionIsInClipboard()
{
return copyInfo.type == MacroSegmentCopyInfo::Type::ACTION ||
copyInfo.type == MacroSegmentCopyInfo::Type::ELSE;
}
void SetupSegmentCopyPasteShortcutHandlers(AdvSceneSwitcher *window)
{
auto copyShortcut = new QShortcut(QKeySequence("Ctrl+C"), window);