Skip to content

Commit

Permalink
Check for dragging inside the ToggleAction and some housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKroes committed Nov 20, 2024
1 parent 6fac62a commit 25079ec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 6 additions & 2 deletions ManiVault/src/actions/ToggleAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,14 @@ bool ToggleAction::CheckBoxWidget::eventFilter(QObject* target, QEvent* event)
{
case QEvent::MouseButtonPress:
{
auto mouseEvent = static_cast<QMouseEvent*>(event);
auto mouseEvent = dynamic_cast<QMouseEvent*>(event);

if (_toggleAction->isEnabled() && mouseEvent->button() == Qt::LeftButton)
if (_toggleAction->isEnabled() && mouseEvent->button() == Qt::LeftButton && !_toggleAction->getDrag().isDragging())
{
qDebug() << "Toggle!";
_toggleAction->setChecked(!_toggleAction->isChecked());
}


return true;
}
Expand Down
4 changes: 2 additions & 2 deletions ManiVault/src/actions/WidgetActionDrag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void WidgetActionDrag::start()
if (!_dragAction)
return;

_isDragging = true;
setIsDragging(true);
{
auto drag = new QDrag(this);
auto mimeData = new WidgetActionMimeData(_dragAction);
Expand All @@ -44,7 +44,7 @@ void WidgetActionDrag::start()

drag->exec();
}
_isDragging = false;
QTimer::singleShot(100, [this]() { setIsDragging(false); });
}

void WidgetActionDrag::setIsDragging(bool dragging)
Expand Down
10 changes: 4 additions & 6 deletions ManiVault/src/actions/WidgetActionLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ namespace mv::gui {
WidgetActionLabel::WidgetActionLabel(WidgetAction* action, QWidget* parent /*= nullptr*/, const std::uint32_t& flags /*= ColonAfterName*/) :
WidgetActionViewWidget(parent, action),
_flags(flags),
_nameLabel(),
_elide(false),
_drag(nullptr),
_lastMousePressPosition()
_drag(nullptr)
{
setAction(action);
setAcceptDrops(true);
Expand Down Expand Up @@ -63,7 +61,7 @@ bool WidgetActionLabel::eventFilter(QObject* target, QEvent* event)
if (dynamic_cast<QWidget*>(target) != &_nameLabel)
break;

auto mouseEvent = static_cast<QMouseEvent*>(event);
auto mouseEvent = dynamic_cast<QMouseEvent*>(event);

switch (mouseEvent->button())
{
Expand All @@ -75,7 +73,7 @@ bool WidgetActionLabel::eventFilter(QObject* target, QEvent* event)
if (!getAction()->mayConnect(WidgetAction::Gui))
break;

getAction()->getDrag().start();
getAction()->getDrag().start();

break;
}
Expand All @@ -99,7 +97,7 @@ bool WidgetActionLabel::eventFilter(QObject* target, QEvent* event)
if (contextMenu->actions().isEmpty())
return QWidget::eventFilter(target, event);

contextMenu->exec(cursor().pos());
contextMenu->exec(QCursor::pos());

break;
}
Expand Down
4 changes: 1 addition & 3 deletions ManiVault/src/actions/WidgetActionMimeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
namespace mv::gui {

WidgetActionMimeData::WidgetActionMimeData(WidgetAction* action) :
QMimeData(),
_action(action),
_highlightActions()
_action(action)
{
ActionsListModel actionsListModel; /** Actions list model */
ActionsFilterModel actionsFilterModel; /** Filtered actions model */
Expand Down

0 comments on commit 25079ec

Please sign in to comment.