Finish work in drag&drop of Actions

This commit is contained in:
feedc0de committed 2024-01-04 20:22:39 +01:00
1 parent 7571c4b1ad
commit ffe4a99baa
12 files changed
+782 -489

No files matched your search

+10 -2
View File
@@ -5,6 +5,10 @@
#include <QDrag>
#include <QMimeData>
#include "projectcontainer.h"
#include "projectserialization.h"
#include "stdserialization.h"
ActionDragWidget::ActionDragWidget(QWidget *parent) :
QToolButton{parent}
{
@@ -33,8 +37,12 @@ void ActionDragWidget::mouseMoveEvent(QMouseEvent *event)
drag->setPixmap(this->icon().pixmap(QSize{32, 32}));
QMimeData *mimeData = new QMimeData;
mimeData->setData("custom", QByteArray{"aaaaaa"});
QByteArray encoded;
QDataStream stream(&encoded, QDataStream::WriteOnly);
stream << Action{ExecuteCodeAction{ .script = "hatschi" }};
mimeData->setData("custom", encoded);
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
qDebug() << dropAction;
}
+47 -7
View File
@@ -4,6 +4,7 @@
#include <QDebug>
#include <QMessageBox>
#include <QMenu>
#include <QKeySequence>
#include "models/actionscontainermodel.h"
#include "dialogs/codeactiondialog.h"
@@ -84,16 +85,55 @@ void ActionsContainerWidget::actionsContextMenuRequested(const QPoint &pos)
auto action = index.isValid() ? m_actionsModel->getAction(index) : nullptr;
QMenu menu{this};
menu.addAction(tr("&Edit Values"), this, [this,index](){ actionDoubleClicked(index); })->setEnabled(action);
if (auto action = menu.addAction(tr("&Edit Values"), this, [this,index](){
actionDoubleClicked(index);
}))
action->setEnabled(action);
menu.addSeparator();
menu.addAction(tr("C&ut"))->setEnabled(false);
menu.addAction(tr("&Copy"))->setEnabled(false);
menu.addAction(tr("&Paste"))->setEnabled(false);
if (auto action = menu.addAction(tr("C&ut"), this, [this](){
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
}))
{
action->setEnabled(action);
action->setShortcut(QKeySequence::Cut);
}
if (auto action = menu.addAction(tr("&Copy"), this, [this](){
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
}))
{
action->setEnabled(action);
action->setShortcut(QKeySequence::Copy);
}
if (auto action = menu.addAction(tr("&Paste"), this, [this](){
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
}))
{
action->setEnabled(action);
action->setShortcut(QKeySequence::Paste);
}
menu.addSeparator();
menu.addAction(tr("&Delete"))->setEnabled(false);
if (auto action = menu.addAction(tr("&Delete"), this, [this,index](){
if (!m_actionsModel->removeRow(index.row()))
QMessageBox::warning(this, tr("Could not remove action!"), tr("Could not remove action!"));
}))
{
action->setEnabled(action);
action->setShortcut(QKeySequence::Delete);
}
menu.addSeparator();
menu.addAction(tr("Select &All"))->setEnabled(false);
if (auto action = menu.addAction(tr("Select &All"), this, [this](){
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
}))
{
action->setEnabled(m_actionsModel->actionsContainer() && !m_actionsModel->actionsContainer()->empty());
action->setShortcut(QKeySequence::SelectAll);
}
menu.addSeparator();
menu.addAction(tr("C&lear"))->setEnabled(false);
if (auto action = menu.addAction(tr("C&lear"), this, [this](){
QMessageBox::information(this, tr("Not implemented!"), tr("Not implemented!"));
}))
{
action->setEnabled(m_actionsModel->actionsContainer() && !m_actionsModel->actionsContainer()->empty());
}
menu.exec(m_ui->listViewActions->viewport()->mapToGlobal(pos));
}
+4 -1
View File
@@ -10,6 +10,9 @@
<height>667</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
@@ -56,7 +59,7 @@
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>