Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tix toggle action drag and drop #723

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ManiVault/cmake/CMakeMvSourcesPublic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ set(PUBLIC_ACTIONS_INTERNAL_HEADERS
src/actions/WidgetActionMimeData.h
src/actions/WidgetActionHighlightWidget.h
src/actions/WidgetActionBadge.h
src/actions/WidgetActionDrag.h
src/actions/TasksTreeAction.h
src/actions/TasksListAction.h
src/actions/SplashScreenAction.h
Expand Down Expand Up @@ -356,6 +357,7 @@ set(PUBLIC_ACTIONS_INTERNAL_SOURCES
src/actions/WidgetActionMimeData.cpp
src/actions/WidgetActionHighlightWidget.cpp
src/actions/WidgetActionBadge.cpp
src/actions/WidgetActionDrag.cpp
src/actions/TasksTreeAction.cpp
src/actions/TasksListAction.cpp
src/actions/SplashScreenAction.cpp
Expand Down
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
35 changes: 9 additions & 26 deletions ManiVault/src/actions/WidgetAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <QMenu>
#include <QJsonArray>
#include <QDrag>
#include <QDialog>
#include <QDialogButtonBox>
#include <QEventLoop>

#ifdef _DEBUG
//#define WIDGET_ACTION_VERBOSE
Expand All @@ -34,13 +32,12 @@ bool isInPopupMode(QWidget* parent) {
}

QMap<WidgetAction::Scope, QString> WidgetAction::scopeNames {
{ WidgetAction::Scope::Private, "Private" },
{ WidgetAction::Scope::Public, "Public" }
{ Scope::Private, "Private" },
{ Scope::Public, "Public" }
};

WidgetAction::WidgetAction(QObject* parent, const QString& title) :
QWidgetAction(parent),
util::Serializable(),
_defaultWidgetFlags(),
_sortIndex(-1),
_stretch(-1),
Expand All @@ -50,16 +47,11 @@ WidgetAction::WidgetAction(QObject* parent, const QString& title) :
_cachedConnectionPermissions(static_cast<std::int32_t>(ConnectionPermissionFlag::None)),
_scope(Scope::Private),
_publicAction(nullptr),
_connectedActions(),
_settingsPrefix(),
_highlighting(HighlightOption::None),
_popupSizeHint(),
_overrideSizeHint(),
_configuration(static_cast<std::int32_t>(ConfigurationFlag::Default)),
_location(),
_namedIcon(""),
_widgetConfigurationFunction(),
_badge(this)
_badge(this),
_drag(this)
{
Q_ASSERT(!title.isEmpty());

Expand Down Expand Up @@ -581,20 +573,6 @@ void WidgetAction::restoreConnectionPermissions(bool recursive /*= false*/)
childAction->restoreConnectionPermissions(recursive);
}

void WidgetAction::startDrag()
{
if (!mayConnect(WidgetAction::Gui))
return;

auto drag = new QDrag(this);
auto mimeData = new WidgetActionMimeData(this);

drag->setMimeData(mimeData);
drag->setPixmap(Application::getIconFont("FontAwesome").getIcon("link").pixmap(QSize(12, 12)));

drag->exec();
}

void WidgetAction::setSettingsPrefix(const QString& settingsPrefix, const bool& load /*= true*/)
{
_settingsPrefix = settingsPrefix;
Expand Down Expand Up @@ -964,6 +942,11 @@ WidgetActionBadge& WidgetAction::getBadge()
return _badge;
}

WidgetActionDrag& WidgetAction::getDrag()
{
return _drag;
}

void WidgetAction::setOverrideSizeHint(const QSize& sizeHint)
{
_overrideSizeHint = sizeHint;
Expand Down
Loading