2019-09-04 06:59:43 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_QUICK_ITEM_H
|
|
|
|
#define QSK_QUICK_ITEM_H
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
|
|
|
#include <qquickitem.h>
|
|
|
|
|
|
|
|
class QskQuickItemPrivate;
|
|
|
|
class QskGeometryChangeEvent;
|
|
|
|
class QskWindowChangeEvent;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskQuickItem : public QQuickItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QRectF geometry READ geometry WRITE setGeometry )
|
2021-02-02 10:15:01 +01:00
|
|
|
Q_PROPERTY( QRectF rect READ rect )
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
Q_PROPERTY( bool transparentForPositioners READ isTransparentForPositioner
|
|
|
|
WRITE setTransparentForPositioner NOTIFY itemFlagsChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool tabFence READ isTabFence
|
|
|
|
WRITE setTabFence NOTIFY itemFlagsChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool polishOnResize READ polishOnResize
|
|
|
|
WRITE setPolishOnResize NOTIFY itemFlagsChanged FINAL )
|
|
|
|
|
2021-02-01 10:09:37 +01:00
|
|
|
Q_PROPERTY( bool visibleToParent READ isVisibleToParent )
|
|
|
|
Q_PROPERTY( bool hasChildItems READ hasChildItems )
|
|
|
|
Q_PROPERTY( bool initiallyPainted READ isInitiallyPainted )
|
|
|
|
|
2021-02-09 12:26:58 +01:00
|
|
|
Q_PROPERTY( UpdateFlags updateFlags READ updateFlags NOTIFY updateFlagsChanged )
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
using Inherited = QQuickItem;
|
|
|
|
|
|
|
|
public:
|
2021-02-09 08:13:20 +01:00
|
|
|
enum UpdateFlag
|
2019-09-04 06:59:43 +02:00
|
|
|
{
|
|
|
|
DeferredUpdate = 1 << 0,
|
|
|
|
DeferredPolish = 1 << 1,
|
|
|
|
DeferredLayout = 1 << 2,
|
|
|
|
CleanupOnVisibility = 1 << 3,
|
|
|
|
|
|
|
|
PreferRasterForTextures = 1 << 4,
|
|
|
|
|
2021-02-02 10:15:01 +01:00
|
|
|
DebugForceBackground = 1 << 7
|
2019-09-04 06:59:43 +02:00
|
|
|
};
|
|
|
|
|
2021-02-09 08:13:20 +01:00
|
|
|
Q_ENUM( UpdateFlag )
|
|
|
|
Q_DECLARE_FLAGS( UpdateFlags, UpdateFlag )
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
~QskQuickItem() override;
|
|
|
|
|
|
|
|
const char* className() const;
|
|
|
|
|
|
|
|
bool isVisibleTo( const QQuickItem* ) const;
|
2019-09-06 19:56:03 +02:00
|
|
|
bool isVisibleToParent() const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
2020-12-27 16:08:18 +01:00
|
|
|
bool hasChildItems() const;
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
QRectF rect() const;
|
2020-01-17 13:58:15 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
2019-09-04 06:59:43 +02:00
|
|
|
QSizeF size() const;
|
2020-01-17 13:58:15 +01:00
|
|
|
#endif
|
2019-09-04 06:59:43 +02:00
|
|
|
QSizeF implicitSize() const;
|
|
|
|
|
|
|
|
void setGeometry( qreal x, qreal y, qreal width, qreal height );
|
2021-08-04 18:48:26 +02:00
|
|
|
void setGeometry( const QPointF&, const QSizeF& );
|
2021-01-25 11:04:25 +01:00
|
|
|
QRectF geometry() const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
2021-08-04 18:48:26 +02:00
|
|
|
using QQuickItem::setPosition;
|
|
|
|
using QQuickItem::setSize;
|
|
|
|
|
|
|
|
void setPosition( qreal x, qreal y );
|
|
|
|
void setSize( qreal width, qreal height );
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
void setPolishOnResize( bool );
|
|
|
|
bool polishOnResize() const;
|
|
|
|
|
|
|
|
void setTransparentForPositioner( bool );
|
|
|
|
bool isTransparentForPositioner() const;
|
|
|
|
|
|
|
|
void setTabFence( bool );
|
|
|
|
bool isTabFence() const;
|
|
|
|
|
2021-02-03 13:20:23 +01:00
|
|
|
void setLayoutMirroring( bool on, bool childrenInherit = false );
|
2019-09-04 06:59:43 +02:00
|
|
|
void resetLayoutMirroring();
|
|
|
|
bool layoutMirroring() const;
|
|
|
|
|
2021-02-09 08:13:20 +01:00
|
|
|
void resetUpdateFlags();
|
|
|
|
UpdateFlags updateFlags() const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
2021-02-09 08:13:20 +01:00
|
|
|
Q_INVOKABLE void setUpdateFlag( UpdateFlag, bool on = true );
|
|
|
|
Q_INVOKABLE void resetUpdateFlag( UpdateFlag );
|
|
|
|
Q_INVOKABLE bool testUpdateFlag( UpdateFlag ) const;
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
void classBegin() override;
|
|
|
|
void componentComplete() override;
|
|
|
|
void releaseResources() override;
|
|
|
|
|
|
|
|
bool isPolishScheduled() const;
|
|
|
|
bool isUpdateNodeScheduled() const;
|
|
|
|
bool isInitiallyPainted() const;
|
|
|
|
|
|
|
|
bool maybeUnresized() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void itemFlagsChanged();
|
2021-02-09 08:13:20 +01:00
|
|
|
void updateFlagsChanged( UpdateFlags );
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void setGeometry( const QRectF& );
|
|
|
|
|
|
|
|
void show();
|
|
|
|
void hide();
|
2021-02-15 09:17:29 +01:00
|
|
|
|
|
|
|
void setHidden( bool );
|
|
|
|
void setDisabled( bool );
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
void resetImplicitSize();
|
|
|
|
|
2021-02-15 09:17:29 +01:00
|
|
|
#ifdef Q_MOC_RUN
|
|
|
|
// methods from QQuickItem, we want to be available as string based slots
|
|
|
|
void setVisible( bool );
|
|
|
|
void setEnabled( bool );
|
|
|
|
#endif
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
protected:
|
|
|
|
QskQuickItem( QskQuickItemPrivate&, QQuickItem* = nullptr );
|
|
|
|
|
|
|
|
bool event( QEvent* ) override;
|
|
|
|
|
|
|
|
virtual void changeEvent( QEvent* );
|
|
|
|
virtual void geometryChangeEvent( QskGeometryChangeEvent* );
|
|
|
|
virtual void windowChangeEvent( QskWindowChangeEvent* );
|
|
|
|
|
2021-08-04 09:31:16 +02:00
|
|
|
void mouseUngrabEvent() override;
|
2021-02-26 12:42:49 +01:00
|
|
|
void touchUngrabEvent() override;
|
2021-03-02 17:09:38 +01:00
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
2021-02-26 12:42:49 +01:00
|
|
|
void windowDeactivateEvent() override;
|
2021-03-02 17:09:38 +01:00
|
|
|
#endif
|
2021-02-26 12:42:49 +01:00
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
void itemChange( ItemChange, const ItemChangeData& ) override;
|
2020-10-26 17:59:19 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
|
|
void geometryChange( const QRectF&, const QRectF& ) override;
|
|
|
|
#else
|
|
|
|
// using geometryChange also for Qt5
|
|
|
|
void geometryChanged( const QRectF&, const QRectF& ) override final;
|
|
|
|
virtual void geometryChange( const QRectF&, const QRectF& );
|
|
|
|
#endif
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
virtual void aboutToShow(); // called in updatePolish
|
|
|
|
|
|
|
|
private:
|
|
|
|
// don't use boundingRect - it seems to be deprecated
|
|
|
|
QRectF boundingRect() const override final { return rect(); }
|
|
|
|
|
|
|
|
/*
|
|
|
|
childrenRect()/childrenRectChanged does not make much sense
|
|
|
|
in a system, where the parent is responsible for laying out
|
|
|
|
its children.
|
|
|
|
*/
|
|
|
|
void childrenRect() = delete;
|
|
|
|
|
2021-02-09 08:13:20 +01:00
|
|
|
void applyUpdateFlag( UpdateFlag, bool on );
|
2019-09-23 16:59:48 +02:00
|
|
|
void sendEnabledChangeEvent();
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override final;
|
|
|
|
virtual QSGNode* updateItemPaintNode( QSGNode* );
|
|
|
|
|
|
|
|
void updatePolish() override final;
|
|
|
|
virtual void updateItemPolish();
|
|
|
|
|
|
|
|
Q_DECLARE_PRIVATE( QskQuickItem )
|
|
|
|
};
|
|
|
|
|
2020-12-27 16:08:18 +01:00
|
|
|
inline bool QskQuickItem::hasChildItems() const
|
|
|
|
{
|
|
|
|
return !childItems().isEmpty();
|
|
|
|
}
|
|
|
|
|
2021-08-04 18:48:26 +02:00
|
|
|
inline void QskQuickItem::setGeometry( const QPointF& pos, const QSizeF& size )
|
|
|
|
{
|
|
|
|
setGeometry( pos.x(), pos.y(), size.width(), size.height() );
|
|
|
|
}
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline void QskQuickItem::setGeometry( const QRectF& rect )
|
|
|
|
{
|
|
|
|
setGeometry( rect.x(), rect.y(), rect.width(), rect.height() );
|
|
|
|
}
|
|
|
|
|
2021-08-04 18:48:26 +02:00
|
|
|
inline void QskQuickItem::setPosition( qreal x, qreal y )
|
|
|
|
{
|
|
|
|
QQuickItem::setPosition( QPointF( x, y ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void QskQuickItem::setSize( qreal width, qreal height )
|
|
|
|
{
|
|
|
|
QQuickItem::setSize( QSizeF( width, height ) );
|
|
|
|
}
|
|
|
|
|
2020-01-17 13:58:15 +01:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline QSizeF QskQuickItem::size() const
|
|
|
|
{
|
|
|
|
return QSizeF( width(), height() );
|
|
|
|
}
|
|
|
|
|
2020-01-17 13:58:15 +01:00
|
|
|
#endif
|
|
|
|
|
2019-09-04 06:59:43 +02:00
|
|
|
inline QSizeF QskQuickItem::implicitSize() const
|
|
|
|
{
|
|
|
|
return QSizeF( implicitWidth(), implicitHeight() );
|
|
|
|
}
|
|
|
|
|
2021-02-09 08:13:20 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QskQuickItem::UpdateFlags )
|
|
|
|
Q_DECLARE_METATYPE( QskQuickItem::UpdateFlags )
|
2019-09-04 06:59:43 +02:00
|
|
|
|
|
|
|
#endif
|