Skip to content

Commit

Permalink
Work on highlighting system
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKroes committed Nov 20, 2024
1 parent 69f638d commit 6fa5860
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 131 deletions.
22 changes: 22 additions & 0 deletions ManiVault/src/AbstractActionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,28 @@ class CORE_EXPORT AbstractActionsManager : public AbstractManager
}
}

/**
* Get a list of candidate connections between descendants of \p widgetActionLhs and \p widgetActionRhs
* @param widgetActionLhs Pointer to widget action
* @param widgetActionRhs Pointer to widget action
* @return List of candidate connections
*/
static std::vector<std::pair<QWidgetAction*, QWidgetAction*>> getCandidateConnectionsForDescendants(const gui::WidgetAction* widgetActionLhs, const gui::WidgetAction* widgetActionRhs) {
const auto widgetActionDescendantsLhs = widgetActionLhs->getChildren(true);
const auto widgetActionDescendantsRhs = widgetActionRhs->getChildren(true);

std::vector<std::pair<QWidgetAction*, QWidgetAction*>> candidateConnections;

for (const auto widgetActionDescendantLhs : widgetActionDescendantsLhs) {
for (const auto widgetActionDescendantRhs : widgetActionDescendantsRhs) {
if (widgetActionDescendantLhs->getTypeString() == widgetActionDescendantRhs->getTypeString())
candidateConnections.push_back({ widgetActionDescendantLhs, widgetActionDescendantRhs });
}
}

return candidateConnections;
}

protected:

/**
Expand Down
54 changes: 34 additions & 20 deletions ManiVault/src/actions/WidgetAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,10 @@ 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(),
_highlightVisible(false),
_highlightMode(HighlightMode::Light),
_configuration(static_cast<std::int32_t>(ConfigurationFlag::Default)),
_location(),
_namedIcon(""),
_widgetConfigurationFunction(),
_badge(this)
{
Q_ASSERT(!title.isEmpty());
Expand All @@ -75,7 +70,6 @@ WidgetAction::WidgetAction(QObject* parent, const QString& title) :
if (projects().hasProject())
setStudioMode(projects().getCurrentProject()->getStudioModeAction().isChecked(), false);
}

}

WidgetAction::~WidgetAction()
Expand Down Expand Up @@ -230,39 +224,59 @@ void WidgetAction::setDefaultWidgetFlag(const std::int32_t& widgetFlag, bool uns
_defaultWidgetFlags |= static_cast<std::int32_t>(widgetFlag);
}

WidgetAction::HighlightOption WidgetAction::getHighlighting() const
WidgetAction::HighlightMode WidgetAction::getHighlightMode() const
{
return _highlighting;
return _highlightMode;
}

bool WidgetAction::isHighlighted() const
bool WidgetAction::isHighlightVisible() const
{
return (_highlighting == HighlightOption::Moderate) || (_highlighting == HighlightOption::Strong);
return _highlightVisible;
}

void WidgetAction::setHighlighting(const HighlightOption& highlighting)
void WidgetAction::setHighlightMode(const HighlightMode& highlightMode)
{
if (highlighting == _highlighting)
if (highlightMode == _highlightMode)
return;

_highlighting = highlighting;
_highlightMode = highlightMode;

emit highlightingChanged(_highlighting);
emit highlightModeChanged(_highlightMode);
}

void WidgetAction::setHighlighted(bool highlighted)
void WidgetAction::setHighlightVisible(bool highlightVisible)
{
setHighlighting(highlighted ? HighlightOption::Moderate : HighlightOption::None);
if (highlightVisible == _highlightVisible)
return;

_highlightVisible = highlightVisible;

emit highlightVisibilityChanged(_highlightVisible);
}

void WidgetAction::highlight()
{
setHighlighted(true);
setHighlightVisible(true);
}

void WidgetAction::unHighlight()
{
setHighlighted(false);
setHighlightVisible(false);
}

QString WidgetAction::getHighlightDescription() const
{
return _highlightDescription;
}

void WidgetAction::setHighlightDescription(const QString& highlightDescription)
{
if (highlightDescription == _highlightDescription)
return;

_highlightDescription = highlightDescription;

emit highlightDescriptionChanged(_highlightDescription);
}

WidgetAction::Scope WidgetAction::getScope() const
Expand Down
Loading

0 comments on commit 6fa5860

Please sign in to comment.