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