mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-21 13:15:57 +00:00
Manually propagate clicks on custom tooltip to underlying widget
* Qt::WA_TransparentForMouseEvents is supposed to do this but clearly doesn't work as it's supposed to.
This commit is contained in:
@@ -67,7 +67,7 @@ void RDTreeViewDelegate::initStyleOption(QStyleOptionViewItem *option, const QMo
|
||||
}
|
||||
}
|
||||
|
||||
RDTipLabel::RDTipLabel() : QLabel(NULL)
|
||||
RDTipLabel::RDTipLabel(QWidget *listener) : QLabel(NULL), mouseListener(listener)
|
||||
{
|
||||
int margin = style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, NULL, this);
|
||||
int opacity = style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, NULL, this);
|
||||
@@ -94,6 +94,32 @@ void RDTipLabel::paintEvent(QPaintEvent *ev)
|
||||
QLabel::paintEvent(ev);
|
||||
}
|
||||
|
||||
void RDTipLabel::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if(mouseListener)
|
||||
sendListenerEvent(e);
|
||||
}
|
||||
|
||||
void RDTipLabel::sendListenerEvent(QMouseEvent *e)
|
||||
{
|
||||
QMouseEvent *duplicate =
|
||||
new QMouseEvent(e->type(), mouseListener->mapFromGlobal(e->globalPos()), e->windowPos(),
|
||||
e->globalPos(), e->button(), e->buttons(), e->modifiers(), e->source());
|
||||
QCoreApplication::postEvent(mouseListener, duplicate);
|
||||
}
|
||||
|
||||
void RDTipLabel::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if(mouseListener)
|
||||
sendListenerEvent(e);
|
||||
}
|
||||
|
||||
void RDTipLabel::mouseDoubleClickEvent(QMouseEvent *e)
|
||||
{
|
||||
if(mouseListener)
|
||||
sendListenerEvent(e);
|
||||
}
|
||||
|
||||
void RDTipLabel::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QStyleHintReturnMask frameMask;
|
||||
@@ -112,7 +138,7 @@ RDTreeView::RDTreeView(QWidget *parent) : QTreeView(parent)
|
||||
m_delegate = new RDTreeViewDelegate(this);
|
||||
QTreeView::setItemDelegate(m_delegate);
|
||||
|
||||
m_ElidedTooltip = new RDTipLabel();
|
||||
m_ElidedTooltip = new RDTipLabel(viewport());
|
||||
m_ElidedTooltip->hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,14 +57,20 @@ private:
|
||||
Q_OBJECT
|
||||
|
||||
int m_TooltipMargin = 0;
|
||||
QWidget *mouseListener;
|
||||
|
||||
public:
|
||||
explicit RDTipLabel();
|
||||
explicit RDTipLabel(QWidget *listener = NULL);
|
||||
|
||||
int tipMargin() { return m_TooltipMargin; }
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void mouseDoubleClickEvent(QMouseEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
void sendListenerEvent(QMouseEvent *e);
|
||||
};
|
||||
|
||||
class RDTreeView : public QTreeView
|
||||
|
||||
Reference in New Issue
Block a user