Skip to content

Commit

Permalink
Merge branch 'release/v2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kusharami committed Dec 18, 2020
2 parents 56cd403 + f4a2bce commit f017ba9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
QtnProperty
===========

v2.0.2 18.12.2020
[FIX] Don't break property view splitter with drag action

v2.0.1 30.11.2020
[REFINE] Show splitter line and change mouse cursor only for splittable property delegates
[FIX] Correct stripping redundant digits after decimal point when converting floating-point value to locale string
Expand All @@ -19,8 +22,8 @@ v2.0.0 20.11.2020
[NEW] QtnInt64SpinBox - used in uint and int64 properties
[NEW] QtnCompleterLineEdit - autocomplete popup view with input text highlighted (used in QtnPropertyDelegateQStringCallback)
[NEW] Property delegates for:
int64, uint64, QPointF, QSizeF, QRectF,
QVector3D, Button, QBrush, QPen, QVariant, QKeySequence
int64, uint64, QPointF, QSizeF, QRectF,
QVector3D, Button, QBrush, QPen, QVariant, QKeySequence
[NEW] Editing QVariant with CustomProperyEditorDialog and CustomPropertyWidget
[NEW] Ability to set custom property delegate factory for QtnPropertyView with delegateFactory()->setSuperFactory(factory)
[NEW] QtnPropertyDelegateMetaEnum - property delegate for registered enums (Register with QtnPropertyDelegateMetaEnum::Register, and use custom delegate factory)
Expand Down
6 changes: 3 additions & 3 deletions Demo/mydialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QtnPropertyWidget" name="widget" native="true"/>
<widget class="QtnPropertyWidgetEx" name="widget" native="true"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -66,9 +66,9 @@
</widget>
<customwidgets>
<customwidget>
<class>QtnPropertyWidget</class>
<class>QtnPropertyWidgetEx</class>
<extends>QWidget</extends>
<header>QtnProperty/PropertyWidget.h</header>
<header>QtnProperty/PropertyWidgetEx.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down
62 changes: 28 additions & 34 deletions QtnProperty/PropertyView.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
Copyright (c) 2012-2016 Alex Zhondin <[email protected]>
Copyright (c) 2012-2016, 2020 Alex Zhondin <[email protected]>
Copyright (c) 2015-2020 Alexandra Cherdantseva <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -77,10 +77,10 @@ QtnPropertyView::QtnPropertyView(QWidget *parent, QtnPropertySet *propertySet)
, m_itemHeightSpacing(6)
, m_valueLeftMargin(0)
, m_splitRatio(0.5f)
, m_rubberBand(nullptr)
, m_lastChangeReason(0)
, m_stopInvalidate(0)
, m_mouseAtSplitter(false)
, m_mouseCaptured(false)
, m_accessibilityProxy(nullptr)
{
set_smaller_text_osx(this);
Expand Down Expand Up @@ -291,6 +291,11 @@ int QtnPropertyView::valueLeftMargin() const
return m_valueLeftMargin;
}

bool QtnPropertyView::isMouseCaptured() const
{
return m_mouseCaptured || m_rubberBand;
}

void QtnPropertyView::connectPropertyToEdit(
QtnPropertyBase *property, QtnConnections &outConnections)
{
Expand Down Expand Up @@ -332,39 +337,28 @@ void QtnPropertyView::paintEvent(QPaintEvent *e)

QStylePainter painter(viewport());

int splitLineY1 = itemRect.top();
int splitLineY2 = splitLineY1;
int splitLineX = splitPosition();
QPen splitterPen;
splitterPen.setColor(this->palette().color(QPalette::Mid));
splitterPen.setStyle(Qt::DotLine);

int lastIndex = lastVisibleItemIndex + 1;
QPen splitLinePen;
splitLinePen.setColor(this->palette().color(QPalette::Mid));
splitLinePen.setStyle(Qt::DotLine);
for (int i = firstVisibleItemIndex; i <= lastIndex; ++i)
for (int i = firstVisibleItemIndex; i <= lastVisibleItemIndex; ++i)
{
QtnPropertyDelegate *delegate = nullptr;
if (i <= lastVisibleItemIndex)
{
const VisibleItem &vItem = m_visibleItems[i];
const VisibleItem &vItem = m_visibleItems[i];

drawItem(painter, itemRect, vItem);
delegate = vItem.item->delegate.get();
Q_ASSERT(delegate); // cannot be null
}
itemRect.translate(0, m_itemHeight);
if (!delegate || !delegate->isSplittable())
drawItem(painter, itemRect, vItem);
auto delegate = vItem.item->delegate.get();
Q_ASSERT(delegate); // cannot be null

if (delegate->isSplittable())
{
if (splitLineY2 > splitLineY1)
{
painter.save();
painter.setPen(splitLinePen);
painter.drawLine(
splitLineX, splitLineY1, splitLineX, splitLineY2);
painter.restore();
}
splitLineY1 = itemRect.top();
painter.save();
splitterPen.setDashOffset(itemRect.top());
painter.setPen(splitterPen);
painter.drawLine(splitPosition(), itemRect.top(), splitPosition(),
itemRect.bottom());
painter.restore();
}
splitLineY2 = itemRect.top();
itemRect.translate(0, m_itemHeight);
}
}

Expand Down Expand Up @@ -493,6 +487,7 @@ static const int TOLERANCE = 3;

void QtnPropertyView::mousePressEvent(QMouseEvent *e)
{
m_mouseCaptured = false;
if (e->button() == Qt::RightButton)
{
auto property = getPropertyAt(e->pos());
Expand All @@ -513,8 +508,7 @@ void QtnPropertyView::mousePressEvent(QMouseEvent *e)
: false;
if (isSplittableItem && qAbs(e->x() - splitPosition()) < TOLERANCE)
{
Q_ASSERT(!m_rubberBand);
m_rubberBand = new QRubberBand(QRubberBand::Line, this);
m_rubberBand.reset(new QRubberBand(QRubberBand::Line, this));

QRect rect = viewport()->rect();
rect.setLeft(e->x());
Expand All @@ -526,7 +520,7 @@ void QtnPropertyView::mousePressEvent(QMouseEvent *e)
if (index >= 0)
{
changeActivePropertyByIndex(index);
handleMouseEvent(index, e, e->pos());
m_mouseCaptured = handleMouseEvent(index, e, e->pos());
}
}
QAbstractScrollArea::mousePressEvent(e);
Expand All @@ -542,7 +536,6 @@ void QtnPropertyView::mouseReleaseEvent(QMouseEvent *e)

if (m_rubberBand)
{
delete m_rubberBand;
m_rubberBand = nullptr;

// update split ratio
Expand All @@ -555,6 +548,7 @@ void QtnPropertyView::mouseReleaseEvent(QMouseEvent *e)
}

QAbstractScrollArea::mouseReleaseEvent(e);
m_mouseCaptured = false;
}

void QtnPropertyView::mouseMoveEvent(QMouseEvent *e)
Expand Down
5 changes: 4 additions & 1 deletion QtnProperty/PropertyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class QTN_IMPORT_EXPORT QtnPropertyView : public QAbstractScrollArea
QtnPropertyBase *property, QtnConnections &outConnections);
int valueLeftMargin() const;

bool isMouseCaptured() const;

public slots:
QtnAccessibilityProxy *accessibilityProxy();

Expand Down Expand Up @@ -190,10 +192,11 @@ public slots:
QColor m_propertySetBackdroundColor;

float m_splitRatio;
QRubberBand *m_rubberBand;
std::unique_ptr<QRubberBand> m_rubberBand;
QtnPropertyChangeReason m_lastChangeReason;
unsigned m_stopInvalidate;
bool m_mouseAtSplitter;
bool m_mouseCaptured;

friend class QtnAccessibilityProxy;
QtnAccessibilityProxy *m_accessibilityProxy;
Expand Down
9 changes: 9 additions & 0 deletions QtnProperty/PropertyWidgetEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ bool QtnPropertyWidgetEx::eventFilter(QObject *obj, QEvent *event)

if (mevent->button() == Qt::LeftButton)
{
if (propertyView()->isMouseCaptured())
{
break;
}
dragStartPos = mevent->pos();
draggedProperty = propertyView()->getPropertyAt(dragStartPos);
canRemove = canDeleteProperty(draggedProperty);
Expand All @@ -325,6 +329,11 @@ bool QtnPropertyWidgetEx::eventFilter(QObject *obj, QEvent *event)
if (mDrag)
break;

if (propertyView()->isMouseCaptured())
{
break;
}

auto mevent = static_cast<QMouseEvent *>(event);

if (nullptr != draggedProperty &&
Expand Down
2 changes: 1 addition & 1 deletion QtnProperty/QtnProperty.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include(../Internal/TargetConfig.pri)

TARGET = QtnProperty
TEMPLATE = lib
VERSION = 2.0.1
VERSION = 2.0.2

qtnproperty_dynamic {
DEFINES += QTN_DYNAMIC_LIBRARY
Expand Down

0 comments on commit f017ba9

Please sign in to comment.