QskControl::focusIndicatorRect introduced
This commit is contained in:
parent
19c0e43e5c
commit
2cdabf34d6
|
@ -43,6 +43,9 @@ Slider::Slider( QQuickItem* parentItem ):
|
||||||
skinlet->setOwnedBySkinnable( true );
|
skinlet->setOwnedBySkinnable( true );
|
||||||
|
|
||||||
setSkinlet( skinlet );
|
setSkinlet( skinlet );
|
||||||
|
|
||||||
|
connect( this, &QskRangeControl::valueChanged,
|
||||||
|
this, &QskControl::focusIndicatorRectChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF Slider::contentsSizeHint() const
|
QSizeF Slider::contentsSizeHint() const
|
||||||
|
@ -51,3 +54,7 @@ QSizeF Slider::contentsSizeHint() const
|
||||||
return Inherited::contentsSizeHint() + QSizeF( 0, extra );
|
return Inherited::contentsSizeHint() + QSizeF( 0, extra );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF Slider::focusIndicatorRect() const
|
||||||
|
{
|
||||||
|
return subControlRect( QskSlider::Handle );
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
QSK_SUBCONTROLS( Scale, Decoration )
|
QSK_SUBCONTROLS( Scale, Decoration )
|
||||||
|
|
||||||
Slider( QQuickItem* parent = nullptr );
|
Slider( QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
|
virtual QRectF focusIndicatorRect() const override;
|
||||||
virtual QSizeF contentsSizeHint() const override;
|
virtual QSizeF contentsSizeHint() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1454,6 +1454,11 @@ QRectF QskControl::gestureRect() const
|
||||||
return boundingRect();
|
return boundingRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF QskControl::focusIndicatorRect() const
|
||||||
|
{
|
||||||
|
return boundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
void QskControl::updateLayout()
|
void QskControl::updateLayout()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ public:
|
||||||
|
|
||||||
virtual QRectF layoutRect() const;
|
virtual QRectF layoutRect() const;
|
||||||
virtual QRectF gestureRect() const;
|
virtual QRectF gestureRect() const;
|
||||||
|
virtual QRectF focusIndicatorRect() const;
|
||||||
|
|
||||||
void setAutoFillBackground( bool );
|
void setAutoFillBackground( bool );
|
||||||
bool autoFillBackground() const;
|
bool autoFillBackground() const;
|
||||||
|
@ -163,6 +164,7 @@ public:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void backgroundChanged();
|
void backgroundChanged();
|
||||||
void marginsChanged();
|
void marginsChanged();
|
||||||
|
void focusIndicatorRectChanged();
|
||||||
void localeChanged( const QLocale& );
|
void localeChanged( const QLocale& );
|
||||||
void controlFlagsChanged();
|
void controlFlagsChanged();
|
||||||
void focusPolicyChanged();
|
void focusPolicyChanged();
|
||||||
|
|
|
@ -19,8 +19,32 @@ static void qskSetupGeometryConnections(
|
||||||
QObject::connect( sender, SIGNAL( yChanged() ), receiver, method );
|
QObject::connect( sender, SIGNAL( yChanged() ), receiver, method );
|
||||||
QObject::connect( sender, SIGNAL( widthChanged() ), receiver, method );
|
QObject::connect( sender, SIGNAL( widthChanged() ), receiver, method );
|
||||||
QObject::connect( sender, SIGNAL( heightChanged() ), receiver, method );
|
QObject::connect( sender, SIGNAL( heightChanged() ), receiver, method );
|
||||||
|
|
||||||
|
bool hasIndicatorSignal = ( qobject_cast< const QskControl* >( sender ) != nullptr );
|
||||||
|
if ( !hasIndicatorSignal )
|
||||||
|
{
|
||||||
|
const auto mo = sender->metaObject();
|
||||||
|
hasIndicatorSignal = ( mo->indexOfSignal( "focusIndicatorRectChanged()" ) >= 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( hasIndicatorSignal )
|
||||||
|
{
|
||||||
|
QObject::connect( sender, SIGNAL( focusIndicatorRectChanged() ), receiver, method );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QRectF qskFocusIndicatorRect( const QQuickItem* item )
|
||||||
|
{
|
||||||
|
if ( auto control = qobject_cast< const QskControl* >( item ) )
|
||||||
|
return control->focusIndicatorRect();
|
||||||
|
|
||||||
|
const QVariant v = item->property( "focusIndicatorRect" );
|
||||||
|
if ( v.canConvert( QMetaType::QRectF ) )
|
||||||
|
return v.toRectF();
|
||||||
|
|
||||||
|
return item->boundingRect();
|
||||||
|
}
|
||||||
|
|
||||||
QskFocusIndicator::QskFocusIndicator( QQuickItem* parent ):
|
QskFocusIndicator::QskFocusIndicator( QQuickItem* parent ):
|
||||||
Inherited( parent ) // parentItem() might change, but parent() stays
|
Inherited( parent ) // parentItem() might change, but parent() stays
|
||||||
{
|
{
|
||||||
|
@ -120,7 +144,10 @@ QRectF QskFocusIndicator::focusRect() const
|
||||||
{
|
{
|
||||||
const QQuickItem* focusItem = window()->activeFocusItem();
|
const QQuickItem* focusItem = window()->activeFocusItem();
|
||||||
if ( focusItem && ( focusItem != window()->contentItem() ) )
|
if ( focusItem && ( focusItem != window()->contentItem() ) )
|
||||||
return parentItem()->mapRectFromItem( focusItem, focusItem->boundingRect() );
|
{
|
||||||
|
const auto rect = qskFocusIndicatorRect( focusItem );
|
||||||
|
return parentItem()->mapRectFromItem( focusItem, rect );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QRectF();
|
return QRectF();
|
||||||
|
@ -133,7 +160,7 @@ void QskFocusIndicator::resetConnections()
|
||||||
QQuickItem* item = parentItem();
|
QQuickItem* item = parentItem();
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
qskSetupGeometryConnections( item, this, SLOT(updateFocusFrame()) );
|
qskSetupGeometryConnections( item, this, SLOT( updateFocusFrame() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue