Restore hover actions for the cpp message delegate
Restore hover actions for the cpp message delegate BUG: 503843
This commit is contained in:
committed by
Joshua Goins
parent
3183be460e
commit
0a2af02c5f
@@ -68,7 +68,6 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
||||
qml/NeochatMaximizeComponent.qml
|
||||
qml/TypingPane.qml
|
||||
qml/QuickSwitcher.qml
|
||||
qml/HoverActions.qml
|
||||
qml/AttachmentPane.qml
|
||||
qml/QuickFormatBar.qml
|
||||
qml/UserDetailDialog.qml
|
||||
|
||||
@@ -7,6 +7,7 @@ ecm_add_qml_module(Timeline GENERATE_PLUGIN_SOURCE
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/timeline
|
||||
QML_FILES
|
||||
TimelineView.qml
|
||||
HoverActions.qml
|
||||
EventDelegate.qml
|
||||
HiddenDelegate.qml
|
||||
MessageDelegate.qml
|
||||
|
||||
@@ -59,7 +59,7 @@ QQC2.Control {
|
||||
|
||||
function updatePosition(): void {
|
||||
if (delegate) {
|
||||
root.x = delegate.contentItem.x + delegate.bubbleX + delegate.bubbleWidth - root.implicitWidth;
|
||||
root.x = delegate.contentItem.x + delegate.bubbleWidth - root.implicitWidth - Kirigami.Units.largeSpacing;
|
||||
root.y = delegate.mapToItem(parent, 0, 0).y + delegate.bubbleY - height + Kirigami.Units.smallSpacing;
|
||||
}
|
||||
}
|
||||
@@ -89,13 +89,6 @@ MessageDelegateBase {
|
||||
*/
|
||||
required property bool verified
|
||||
|
||||
/**
|
||||
* @brief The x position of the message bubble.
|
||||
*
|
||||
* @note Used for positioning the hover actions.
|
||||
*/
|
||||
readonly property real bubbleX: bubble.x + bubble.anchors.leftMargin
|
||||
|
||||
/**
|
||||
* @brief The y position of the message bubble.
|
||||
*
|
||||
@@ -110,11 +103,6 @@ MessageDelegateBase {
|
||||
*/
|
||||
readonly property alias bubbleWidth: bubble.width
|
||||
|
||||
/**
|
||||
* @brief Whether this message is hovered.
|
||||
*/
|
||||
readonly property alias hovered: bubble.hovered
|
||||
|
||||
/**
|
||||
* @brief Open the any message media externally.
|
||||
*/
|
||||
@@ -214,6 +202,13 @@ MessageDelegateBase {
|
||||
radius: Kirigami.Units.cornerRadius
|
||||
}
|
||||
|
||||
// show hover actions
|
||||
onHoveredChanged: {
|
||||
if (hovered && !Kirigami.Settings.isMobile) {
|
||||
root.setHoverActionsToDelegate();
|
||||
}
|
||||
}
|
||||
|
||||
function setHoverActionsToDelegate() {
|
||||
if (ListView.view.setHoverActionsToDelegate) {
|
||||
ListView.view.setHoverActionsToDelegate(root);
|
||||
|
||||
@@ -39,6 +39,7 @@ MessageDelegateBase::MessageDelegateBase(QQuickItem *parent)
|
||||
: TimelineDelegate(parent)
|
||||
{
|
||||
m_contentSizeHelper.setParentItem(this);
|
||||
setAcceptHoverEvents(true);
|
||||
setPercentageValues();
|
||||
|
||||
connect(this, &MessageDelegateBase::leftPaddingChanged, this, &MessageDelegateBase::setContentPadding);
|
||||
@@ -395,7 +396,6 @@ void MessageDelegateBase::setCompactMode(bool compactMode)
|
||||
m_compactMode = compactMode;
|
||||
setAlwaysFillWidth(m_isThreaded || m_compactMode);
|
||||
setPercentageValues(m_isThreaded || m_compactMode);
|
||||
setAcceptHoverEvents(m_compactMode);
|
||||
setBaseRightPadding();
|
||||
|
||||
Q_EMIT compactModeChanged();
|
||||
@@ -542,13 +542,18 @@ void MessageDelegateBase::resizeContent()
|
||||
void MessageDelegateBase::hoverEnterEvent(QHoverEvent *event)
|
||||
{
|
||||
m_hovered = true;
|
||||
Q_EMIT hoveredChanged();
|
||||
event->setAccepted(true);
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
void MessageDelegateBase::hoverMoveEvent(QHoverEvent *event)
|
||||
{
|
||||
bool oldHovered = m_hovered;
|
||||
m_hovered = contains(event->pos());
|
||||
if (oldHovered != m_hovered) {
|
||||
Q_EMIT hoveredChanged();
|
||||
}
|
||||
event->setAccepted(true);
|
||||
updateBackground();
|
||||
}
|
||||
@@ -556,6 +561,7 @@ void MessageDelegateBase::hoverMoveEvent(QHoverEvent *event)
|
||||
void MessageDelegateBase::hoverLeaveEvent(QHoverEvent *event)
|
||||
{
|
||||
m_hovered = false;
|
||||
Q_EMIT hoveredChanged();
|
||||
event->setAccepted(true);
|
||||
updateBackground();
|
||||
}
|
||||
@@ -587,4 +593,9 @@ void MessageDelegateBase::setIsTemporaryHighlighted(bool isTemporaryHighlighted)
|
||||
Q_EMIT isTemporaryHighlightedChanged();
|
||||
}
|
||||
|
||||
bool MessageDelegateBase::hovered() const
|
||||
{
|
||||
return m_hovered;
|
||||
}
|
||||
|
||||
#include "moc_messagedelegate.cpp"
|
||||
|
||||
@@ -114,6 +114,11 @@ class MessageDelegateBase : public TimelineDelegate
|
||||
*/
|
||||
Q_PROPERTY(bool isTemporaryHighlighted READ isTemporaryHighlighted WRITE setIsTemporaryHighlighted NOTIFY isTemporaryHighlightedChanged FINAL)
|
||||
|
||||
/**
|
||||
* @brief Whether the delegate is hovered.
|
||||
*/
|
||||
Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged FINAL)
|
||||
|
||||
public:
|
||||
MessageDelegateBase(QQuickItem *parent = nullptr);
|
||||
|
||||
@@ -153,6 +158,8 @@ public:
|
||||
bool isTemporaryHighlighted() const;
|
||||
void setIsTemporaryHighlighted(bool isTemporaryHighlighted);
|
||||
|
||||
bool hovered() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void authorChanged();
|
||||
void isThreadedChanged();
|
||||
@@ -168,6 +175,7 @@ Q_SIGNALS:
|
||||
void compactModeChanged();
|
||||
void showLocalMessagesOnRightChanged();
|
||||
void isTemporaryHighlightedChanged();
|
||||
void hoveredChanged();
|
||||
|
||||
private:
|
||||
DelegateSizeHelper m_contentSizeHelper;
|
||||
@@ -222,7 +230,7 @@ private:
|
||||
}
|
||||
cleanupIncubator(incubator);
|
||||
};
|
||||
static void cleanupIncubator(MessageObjectIncubator *incubator);
|
||||
void cleanupIncubator(MessageObjectIncubator *incubator);
|
||||
void cleanupItem(QQuickItem *item);
|
||||
|
||||
qreal m_spacing = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user