Compare commits

...

4 Commits

Author SHA1 Message Date
Uwe Rathmann 01fca282b7 Merge branch 'master' into Qt-5.6 2022-04-16 12:53:29 +02:00
Uwe Rathmann f1b32e5d45 making QVector happy 2022-04-06 10:59:02 +02:00
Uwe Rathmann a0f3a925ff Merge branch 'master' into Qt-5.6 2022-04-06 10:50:13 +02:00
Uwe Rathmann 1430210424 changes from master 2022-03-25 13:23:44 +01:00
48 changed files with 408 additions and 366 deletions

View File

@ -27,8 +27,9 @@ controls is limited to the needs of the driving projects.
QSkinny is supposed to run on all platforms being supported by Qt/Quick. QSkinny is supposed to run on all platforms being supported by Qt/Quick.
But so far only Linux is actively tested. But so far only Linux is actively tested.
It might support all versions Qt >= 5.12, but you can rely on: It might support all versions Qt >= 5.6, but you can rely on:
- Qt 5.6
- Qt 5.15 - Qt 5.15
- current long term supported ( LTS ) version of Qt - current long term supported ( LTS ) version of Qt
- current version of Qt - current version of Qt

View File

@ -28,7 +28,11 @@ namespace
LinesNode( int lineCount = 0 ) LinesNode( int lineCount = 0 )
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 2 * lineCount ) : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 2 * lineCount )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLines ); m_geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
m_geometry.setDrawingMode( GL_LINES );
#endif
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
setGeometry( &m_geometry ); setGeometry( &m_geometry );

View File

@ -48,7 +48,11 @@ void DiagramDataNode::update( const QRectF& rect, Type type,
m_type = type; m_type = type;
const auto drawingMode = const auto drawingMode =
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
( m_type == Line ) ? QSGGeometry::DrawLines : QSGGeometry::DrawTriangleStrip; ( m_type == Line ) ? QSGGeometry::DrawLines : QSGGeometry::DrawTriangleStrip;
#else
( m_type == Line ) ? GL_LINES : GL_TRIANGLE_STRIP;
#endif
m_geometry.setDrawingMode( drawingMode ); m_geometry.setDrawingMode( drawingMode );

View File

@ -10,7 +10,11 @@
DiagramSegmentsNode::DiagramSegmentsNode() DiagramSegmentsNode::DiagramSegmentsNode()
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLines ); m_geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
m_geometry.setDrawingMode( GL_LINES );
#endif
setGeometry( &m_geometry ); setGeometry( &m_geometry );
setMaterial( &m_material ); setMaterial( &m_material );

View File

@ -12,7 +12,11 @@
RadialTickmarksNode::RadialTickmarksNode() RadialTickmarksNode::RadialTickmarksNode()
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLines ); m_geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
m_geometry.setDrawingMode( GL_LINES );
#endif
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
setGeometry( &m_geometry ); setGeometry( &m_geometry );

View File

@ -37,7 +37,11 @@ namespace
TicksNode( const QColor& color ) TicksNode( const QColor& color )
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLines ); m_geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
m_geometry.setDrawingMode( GL_LINES );
#endif
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
m_material.setColor( color ); m_material.setColor( color );

View File

@ -158,7 +158,7 @@ class IconGrid : public QskLinearBox
const int dim = dimension(); const int dim = dimension();
// we know, that all items have the same size // we know, that all items have the same size
const auto itemSize = itemAtIndex( 0 )->size(); const auto itemSize = qskItemSize( itemAtIndex( 0 ) );
const int rowMin = rect.top() / ( itemSize.height() + spacing() ); const int rowMin = rect.top() / ( itemSize.height() + spacing() );
const int rowMax = rect.bottom() / ( itemSize.height() + spacing() ); const int rowMax = rect.bottom() / ( itemSize.height() + spacing() );

View File

@ -172,6 +172,7 @@ debug {
} }
# DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x000000 # DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x000000
DEFINES += QSK_BUILD
LOCAL_PRI=$$(QSK_LOCAL_PRI) LOCAL_PRI=$$(QSK_LOCAL_PRI)

View File

@ -31,6 +31,29 @@ qvgrcc.CONFIG += add_inputs_as_makefile_deps
QRC_SHADOW_CLONE = $$shell_path( $${OUT_PWD}/${QMAKE_FILE_BASE}_shadow.qrc ) QRC_SHADOW_CLONE = $$shell_path( $${OUT_PWD}/${QMAKE_FILE_BASE}_shadow.qrc )
qtPrepareTool(QMAKE_RCC, rcc, _DEP) qtPrepareTool(QMAKE_RCC, rcc, _DEP)
lessThan(QT_MAJOR_VERSION, 6): lessThan(QT_MINOR_VERSION, 12) {
# Since Qt 5.12 "rcc --list" works for qvg files, that do not yet exist
# To get these rules working for earlier versions we derive the qvg
# files from the SVGSOURCES
defineReplace(qvgfiles) {
svgfiles = $$1
files =
for( svgfile, svgfiles) {
filename = $$basename( svgfile )
files += $$shell_path( $${QVG_DIR}/$$replace( filename, svg, qvg ) )
}
return( $$files )
}
qvgrcc.depends += $$qvgfiles( $${SVGSOURCES} )
} else {
equals( OUT_PWD, $${_PRO_FILE_PWD_} ) { equals( OUT_PWD, $${_PRO_FILE_PWD_} ) {
qvgrcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN} qvgrcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
@ -42,6 +65,7 @@ equals( OUT_PWD, $${_PRO_FILE_PWD_} ) {
$$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS $${QRC_SHADOW_CLONE} && \ $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS $${QRC_SHADOW_CLONE} && \
$${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE} $${QMAKE_DEL_FILE} $${QRC_SHADOW_CLONE}
} }
}
equals( OUT_PWD, $${_PRO_FILE_PWD_} ) { equals( OUT_PWD, $${_PRO_FILE_PWD_} ) {

View File

@ -5,14 +5,13 @@
#include "Image.h" #include "Image.h"
QSK_QT_PRIVATE_BEGIN // QQuickImagePrivate is not exported, so we
#include <private/qquickimage_p_p.h> // we can't derive here
QSK_QT_PRIVATE_END
class ImagePrivate : public QQuickImagePrivate class Image::PrivateData
{ {
public: public:
ImagePrivate() PrivateData()
: sourceSizeAdjustment( false ) : sourceSizeAdjustment( false )
, deferredUpdates( true ) , deferredUpdates( true )
, dirtyPolish( false ) , dirtyPolish( false )
@ -28,7 +27,8 @@ class ImagePrivate : public QQuickImagePrivate
}; };
Image::Image( QQuickItem* parent ) Image::Image( QQuickItem* parent )
: QQuickImage( *( new ImagePrivate() ), parent ) : Inherited( parent )
, m_data( new PrivateData() )
{ {
} }
@ -48,36 +48,32 @@ void Image::hide()
void Image::setSourceSizeAdjustment( bool on ) void Image::setSourceSizeAdjustment( bool on )
{ {
Q_D( Image ); if ( on != m_data->sourceSizeAdjustment )
if ( on != d->sourceSizeAdjustment )
{ {
d->sourceSizeAdjustment = on; m_data->sourceSizeAdjustment = on;
Q_EMIT sourceSizeAdjustmentChanged(); Q_EMIT sourceSizeAdjustmentChanged();
} }
} }
bool Image::sourceSizeAdjustment() const bool Image::sourceSizeAdjustment() const
{ {
return d_func()->sourceSizeAdjustment; return m_data->sourceSizeAdjustment;
} }
void Image::setDeferredUpdates( bool on ) void Image::setDeferredUpdates( bool on )
{ {
Q_D( Image ); if ( on != m_data->deferredUpdates )
if ( on != d->deferredUpdates )
{ {
d->deferredUpdates = on; m_data->deferredUpdates = on;
if ( !on ) if ( !on )
{ {
// when having blocked updates we reschedule them // when having blocked updates we reschedule them
if ( d->dirtyPolish ) if ( m_data->dirtyPolish )
polish(); polish();
if ( d->dirtyUpdate ) if ( m_data->dirtyUpdate )
update(); update();
} }
} }
@ -85,20 +81,18 @@ void Image::setDeferredUpdates( bool on )
bool Image::deferredUpdates() const bool Image::deferredUpdates() const
{ {
return d_func()->deferredUpdates; return m_data->deferredUpdates;
} }
void Image::setSourceSize( const QSize& size ) void Image::setSourceSize( const QSize& size )
{ {
if ( !( size.isEmpty() && sourceSize().isEmpty() ) ) if ( !( size.isEmpty() && sourceSize().isEmpty() ) )
Inherited::setSourceSize( size ); QQuickImage::setSourceSize( size );
} }
void Image::componentComplete() void Image::componentComplete()
{ {
Q_D( const Image ); if ( m_data->deferredUpdates && m_data->sourceSizeAdjustment )
if ( d->deferredUpdates && d->sourceSizeAdjustment )
{ {
// QQuickImage::componentComplete() calls load // QQuickImage::componentComplete() calls load
// long before we have the final geometry // long before we have the final geometry
@ -119,14 +113,12 @@ void Image::itemChange( QQuickItem::ItemChange change,
if ( change == ItemVisibleHasChanged ) if ( change == ItemVisibleHasChanged )
{ {
Q_D( const Image );
if ( value.boolValue ) if ( value.boolValue )
{ {
if ( d->dirtyPolish ) if ( m_data->dirtyPolish )
polish(); polish();
if ( d->dirtyUpdate ) if ( m_data->dirtyUpdate )
update(); update();
} }
} }
@ -158,11 +150,9 @@ void Image::geometryChanged(
void Image::adjustSourceSize( const QSizeF& size ) void Image::adjustSourceSize( const QSizeF& size )
{ {
Q_D( const Image ); if ( m_data->sourceSizeAdjustment )
if ( d->sourceSizeAdjustment )
{ {
if ( d->deferredUpdates ) if ( m_data->deferredUpdates )
{ {
setImplicitSize( size.width(), size.height() ); setImplicitSize( size.width(), size.height() );
polish(); polish();
@ -176,39 +166,35 @@ void Image::adjustSourceSize( const QSizeF& size )
void Image::updatePolish() void Image::updatePolish()
{ {
Q_D( Image ); if ( m_data->deferredUpdates )
if ( d->deferredUpdates )
{ {
if ( !isVisible() ) if ( !isVisible() )
{ {
d->dirtyPolish = true; m_data->dirtyPolish = true;
return; return;
} }
if ( d->sourceSizeAdjustment ) if ( m_data->sourceSizeAdjustment )
setSourceSize( QSize( int( width() ), int( height() ) ) ); setSourceSize( QSize( int( width() ), int( height() ) ) );
} }
d->dirtyPolish = false; m_data->dirtyPolish = false;
Inherited::updatePolish(); Inherited::updatePolish();
} }
QSGNode* Image::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* data ) QSGNode* Image::updatePaintNode( QSGNode* oldNode, UpdatePaintNodeData* data )
{ {
Q_D( Image ); if ( m_data->deferredUpdates )
if ( d->deferredUpdates )
{ {
if ( !isVisible() ) if ( !isVisible() )
{ {
d->dirtyUpdate = true; m_data->dirtyUpdate = true;
return oldNode; return oldNode;
} }
} }
d->dirtyUpdate = false; m_data->dirtyUpdate = false;
return Inherited::updatePaintNode( oldNode, data ); return Inherited::updatePaintNode( oldNode, data );
} }

View File

@ -19,7 +19,7 @@ QSK_QT_PRIVATE_BEGIN
QSK_QT_PRIVATE_END QSK_QT_PRIVATE_END
class ImagePrivate; #include <memory>
class Image : public QQuickImage class Image : public QQuickImage
{ {
@ -80,5 +80,6 @@ class Image : public QQuickImage
private: private:
void adjustSourceSize( const QSizeF& ); void adjustSourceSize( const QSizeF& );
Q_DECLARE_PRIVATE( Image ) class PrivateData;
std::unique_ptr< PrivateData > m_data;
}; };

View File

@ -29,8 +29,12 @@ namespace
private: private:
static ImageType type() static ImageType type()
{ {
#if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 )
return Texture;
#else
const auto backend = QQuickWindow::sceneGraphBackend(); const auto backend = QQuickWindow::sceneGraphBackend();
return ( backend == "software" ) ? Image : Texture; return ( backend == "software" ) ? Image : Texture;
#endif
} }
}; };
} }

View File

@ -94,7 +94,9 @@ namespace
bool updateMaterial = ( oldMaterial == nullptr ) bool updateMaterial = ( oldMaterial == nullptr )
|| newMaterial->compare( oldMaterial ) != 0; || newMaterial->compare( oldMaterial ) != 0;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
updateMaterial |= state.isCachedMaterialDataDirty(); updateMaterial |= state.isCachedMaterialDataDirty();
#endif
if ( updateMaterial ) if ( updateMaterial )
{ {

View File

@ -7,7 +7,6 @@ SUBDIRS = \
qmlexport \ qmlexport \
tools \ tools \
support \ support \
tests \
examples \ examples \
playground playground
@ -23,7 +22,6 @@ qmlexport.depends = src
inputcontext.depends = src inputcontext.depends = src
skins.depends = src skins.depends = src
tools.depends = src tools.depends = src
tests.depends = src support
support.depends = src skins support.depends = src skins
examples.depends = tools support skins qmlexport examples.depends = tools support skins qmlexport
playground.depends = tools support skins qmlexport playground.depends = tools support skins qmlexport

View File

@ -159,7 +159,11 @@ qreal qskHorizontalAdvance( const QFont& font, const QString& text )
qreal qskHorizontalAdvance( const QFontMetricsF& fontMetrics, const QString& text ) qreal qskHorizontalAdvance( const QFontMetricsF& fontMetrics, const QString& text )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 )
return fontMetrics.horizontalAdvance( text ); return fontMetrics.horizontalAdvance( text );
#else
return fontMetrics.width( text );
#endif
} }
qreal qskFuzzyFloor( qreal value, qreal stepSize ) qreal qskFuzzyFloor( qreal value, qreal stepSize )

View File

@ -39,6 +39,22 @@
#define QSK_QT_PRIVATE_END \ #define QSK_QT_PRIVATE_END \
QT_WARNING_POP QT_WARNING_POP
#if defined( QSK_BUILD )
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
template< typename T >
struct QskAddConst { typedef const T Type; };
template< typename T >
constexpr typename QskAddConst< T >::Type& qAsConst( T& t ) noexcept { return t; }
template< typename T >
void qAsConst( const T&& ) = delete;
#endif
#endif
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
using QskHashValue = uint; using QskHashValue = uint;
#else #else

View File

@ -233,10 +233,7 @@ QskGradient::QskGradient( Orientation orientation, const QskGradientStops& stops
setStops( stops ); setStops( stops );
} }
QskGradient::QskGradient( Qt::Orientation orientation, QGradient::Preset preset ) #if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
: QskGradient( qskOrientation( orientation ), preset )
{
}
QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset ) QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset )
: QskGradient( orientation ) : QskGradient( orientation )
@ -244,6 +241,8 @@ QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset )
setStops( qskGradientStops( QGradient( preset ).stops() ) ); setStops( qskGradientStops( QGradient( preset ).stops() ) );
} }
#endif
QskGradient::~QskGradient() QskGradient::~QskGradient()
{ {
} }

View File

@ -48,15 +48,17 @@ class QSK_EXPORT QskGradient
QskGradient( Qt::GlobalColor ); QskGradient( Qt::GlobalColor );
QskGradient( QRgb ); QskGradient( QRgb );
QskGradient( const QColor& ); QskGradient( const QColor& );
QskGradient( QGradient::Preset );
QskGradient( Qt::Orientation, const QVector< QskGradientStop >& ); QskGradient( Qt::Orientation, const QVector< QskGradientStop >& );
QskGradient( Qt::Orientation, const QColor&, const QColor& ); QskGradient( Qt::Orientation, const QColor&, const QColor& );
QskGradient( Qt::Orientation, QGradient::Preset );
QskGradient( Orientation, const QVector< QskGradientStop >& ); QskGradient( Orientation, const QVector< QskGradientStop >& );
QskGradient( Orientation, const QColor&, const QColor& ); QskGradient( Orientation, const QColor&, const QColor& );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
QskGradient( QGradient::Preset );
QskGradient( Orientation, QGradient::Preset ); QskGradient( Orientation, QGradient::Preset );
#endif
~QskGradient(); ~QskGradient();
@ -136,11 +138,15 @@ inline QskGradient::QskGradient( QRgb rgb )
{ {
} }
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
inline QskGradient::QskGradient( QGradient::Preset preset ) inline QskGradient::QskGradient( QGradient::Preset preset )
: QskGradient( Vertical, preset ) : QskGradient( Vertical, preset )
{ {
} }
#endif
inline QskGradient::Orientation QskGradient::orientation() const inline QskGradient::Orientation QskGradient::orientation() const
{ {
return static_cast< Orientation >( m_orientation ); return static_cast< Orientation >( m_orientation );

View File

@ -19,22 +19,21 @@ class QSK_EXPORT QskGradientStop
Q_PROPERTY( QColor color READ color WRITE setColor RESET resetColor ) Q_PROPERTY( QColor color READ color WRITE setColor RESET resetColor )
public: public:
constexpr QskGradientStop() noexcept; QskGradientStop() noexcept;
constexpr QskGradientStop( qreal position, const QColor& ) noexcept; QskGradientStop( qreal position, const QColor& ) noexcept;
QskGradientStop( qreal position, Qt::GlobalColor ) noexcept; QskGradientStop( qreal position, Qt::GlobalColor ) noexcept;
QskGradientStop( qreal position, QRgb ) noexcept; QskGradientStop( qreal position, QRgb ) noexcept;
constexpr bool operator==( const QskGradientStop& ) const noexcept; bool operator==( const QskGradientStop& ) const noexcept;
constexpr bool operator!=( const QskGradientStop& ) const noexcept; bool operator!=( const QskGradientStop& ) const noexcept;
void setStop( qreal position, const QColor& ) noexcept; void setStop( qreal position, const QColor& ) noexcept;
constexpr qreal position() const noexcept; qreal position() const noexcept;
void setPosition( qreal position ) noexcept; void setPosition( qreal position ) noexcept;
void resetPosition() noexcept; void resetPosition() noexcept;
constexpr const QColor& color() const noexcept; const QColor& color() const noexcept;
void setColor( const QColor& ) noexcept; void setColor( const QColor& ) noexcept;
void resetColor() noexcept; void resetColor() noexcept;
@ -54,12 +53,12 @@ class QSK_EXPORT QskGradientStop
Q_DECLARE_METATYPE( QskGradientStop ) Q_DECLARE_METATYPE( QskGradientStop )
inline constexpr QskGradientStop::QskGradientStop() noexcept inline QskGradientStop::QskGradientStop() noexcept
: m_position( -1.0 ) : m_position( -1.0 )
{ {
} }
inline constexpr QskGradientStop::QskGradientStop( inline QskGradientStop::QskGradientStop(
qreal position, const QColor& color ) noexcept qreal position, const QColor& color ) noexcept
: m_position( position ) : m_position( position )
, m_color( color ) , m_color( color )
@ -78,22 +77,22 @@ inline QskGradientStop::QskGradientStop(
{ {
} }
inline constexpr qreal QskGradientStop::position() const noexcept inline qreal QskGradientStop::position() const noexcept
{ {
return m_position; return m_position;
} }
inline constexpr const QColor& QskGradientStop::color() const noexcept inline const QColor& QskGradientStop::color() const noexcept
{ {
return m_color; return m_color;
} }
inline constexpr bool QskGradientStop::operator==( const QskGradientStop& other ) const noexcept inline bool QskGradientStop::operator==( const QskGradientStop& other ) const noexcept
{ {
return ( m_position == other.m_position ) && ( m_color == other.m_color ); return ( m_position == other.m_position ) && ( m_color == other.m_color );
} }
inline constexpr bool QskGradientStop::operator!=( const QskGradientStop& other ) const noexcept inline bool QskGradientStop::operator!=( const QskGradientStop& other ) const noexcept
{ {
return ( !( *this == other ) ); return ( !( *this == other ) );
} }

View File

@ -9,9 +9,36 @@
#include "QskGlobal.h" #include "QskGlobal.h"
#include <qmetaobject.h> #include <qmetaobject.h>
namespace Qsk #if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 )
// hack to run moc over a namespace
#ifdef Q_MOC_RUN
#define QSK_NAMESPACE( name ) struct name
#define QSK_ENUM( name ) Q_GADGET Q_ENUM( name )
#else
#define QSK_NAMESPACE( name ) namespace name
#define QSK_ENUM( name ) \
inline constexpr const QMetaObject* qt_getEnumMetaObject(name) noexcept { return &staticMetaObject; } \
inline constexpr const char* qt_getEnumName(name) noexcept { return #name; }
#endif
#define QSK_Q_NAMESPACE extern const QMetaObject staticMetaObject;
#else
#define QSK_NAMESPACE( name ) namespace name
#define QSK_ENUM Q_ENUM_NS
#define QSK_Q_NAMESPACE Q_NAMESPACE
#endif
QSK_NAMESPACE( Qsk )
{ {
QSK_EXPORT Q_NAMESPACE QSK_EXPORT QSK_Q_NAMESPACE
enum Direction enum Direction
{ {
@ -20,7 +47,7 @@ namespace Qsk
TopToBottom, TopToBottom,
BottomToTop BottomToTop
}; };
Q_ENUM_NS( Direction ) QSK_ENUM( Direction )
enum Position enum Position
{ {
@ -29,7 +56,7 @@ namespace Qsk
Right, Right,
Bottom Bottom
}; };
Q_ENUM_NS( Position ) QSK_ENUM( Position )
enum TextStyle enum TextStyle
{ {
@ -38,17 +65,21 @@ namespace Qsk
Raised, Raised,
Sunken Sunken
}; };
Q_ENUM_NS( TextStyle ) QSK_ENUM( TextStyle )
enum Visibility enum Visibility
{ {
Visible = 1 << 0, Visible = 1 << 0,
Hidden = 1 << 1 Hidden = 1 << 1
}; };
Q_ENUM_NS( Visibility ) QSK_ENUM( Visibility )
Q_DECLARE_FLAGS( Visibilities, Visibility ) Q_DECLARE_FLAGS( Visibilities, Visibility )
Q_DECLARE_OPERATORS_FOR_FLAGS( Visibilities ) Q_DECLARE_OPERATORS_FOR_FLAGS( Visibilities )
} }
#undef QSK_NAMESPACE
#undef QSK_ENUM
#undef QSK_Q_NAMESPACE
#endif #endif

View File

@ -5,6 +5,14 @@
QSK_QT_PRIVATE_BEGIN QSK_QT_PRIVATE_BEGIN
#include <private/qguiapplication_p.h> #include <private/qguiapplication_p.h>
#if QT_VERSION < QT_VERSION_CHECK( 5, 8, 0 )
#ifndef foreach
// qhighdpiscaling_p.h needs it
#define foreach Q_FOREACH
#endif
#endif
#include <private/qhighdpiscaling_p.h> #include <private/qhighdpiscaling_p.h>
QSK_QT_PRIVATE_END QSK_QT_PRIVATE_END
@ -42,10 +50,16 @@ const QPlatformIntegration* qskPlatformIntegration()
bool qskMaybeDesktopPlatform() bool qskMaybeDesktopPlatform()
{ {
#if QT_CONFIG(cursor) // this is what QC2 is doing for menus ?
#if QT_VERSION >= QT_VERSION_CHECK( 5, 15, 0 )
#if !QT_CONFIG(cursor)
return false;
#endif
#endif
if ( const auto platform = QGuiApplicationPrivate::platformIntegration() ) if ( const auto platform = QGuiApplicationPrivate::platformIntegration() )
return platform->hasCapability( QPlatformIntegration::MultipleWindows ); return platform->hasCapability( QPlatformIntegration::MultipleWindows );
#endif
return false; return false;
} }

View File

@ -18,7 +18,11 @@ namespace
IndicatorNode() IndicatorNode()
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 3 ) : m_geometry( QSGGeometry::defaultAttributes_Point2D(), 3 )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLineStrip ); m_geometry.setDrawingMode( QSGGeometry::DrawLineStrip );
#else
m_geometry.setDrawingMode( GL_LINE_STRIP );
#endif
m_geometry.setLineWidth( 2 ); m_geometry.setLineWidth( 2 );
setGeometry( &m_geometry ); setGeometry( &m_geometry );

View File

@ -769,6 +769,55 @@ bool QskControl::event( QEvent* event )
bool QskControl::childMouseEventFilter( QQuickItem* item, QEvent* event ) bool QskControl::childMouseEventFilter( QQuickItem* item, QEvent* event )
{ {
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
if ( event->type() == QEvent::MouseButtonPress )
{
auto me = static_cast< QMouseEvent* >( event );
if ( me->source() == Qt::MouseEventSynthesizedByQt )
{
/*
Unhandled touch events result in creating synthetic
mouse events. For all versions < 5.10 those events are
passed through childMouseEventFilter without doing the
extra checks, that are done for real mouse events.
Furthermore the coordinates are relative
to this - not to item.
To avoid having a different behavior between using
mouse and touch, we do those checks here.
*/
auto itm = item;
auto pos = item->mapFromScene( me->windowPos() );
for ( itm = item; itm != this; itm = itm->parentItem() )
{
if ( itm->acceptedMouseButtons() & me->button() )
{
if ( itm->contains( pos ) )
break;
}
pos += QPointF( itm->x(), itm->y() );
}
if ( itm != item )
{
if ( itm == this )
return false;
QScopedPointer< QMouseEvent > clonedEvent(
QQuickWindowPrivate::cloneMouseEvent( me, &pos ) );
return d_func()->maybeGesture( itm, clonedEvent.data() );
}
}
}
#endif
return d_func()->maybeGesture( item, event ); return d_func()->maybeGesture( item, event );
} }

View File

@ -105,8 +105,10 @@ qreal qskWheelIncrement( const QWheelEvent* event )
auto angleDelta = event->angleDelta(); auto angleDelta = event->angleDelta();
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
if ( event->inverted() ) if ( event->inverted() )
angleDelta.setY( -angleDelta.y() ); angleDelta.setY( -angleDelta.y() );
#endif
const qreal delta = angleDelta.y() ? angleDelta.y() : angleDelta.x(); const qreal delta = angleDelta.y() ? angleDelta.y() : angleDelta.x();
return delta / QWheelEvent::DefaultDeltasPerStep; return delta / QWheelEvent::DefaultDeltasPerStep;

View File

@ -74,6 +74,7 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener
} }
private: private:
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
void itemGeometryChanged( QQuickItem* item, void itemGeometryChanged( QQuickItem* item,
QQuickGeometryChange change, const QRectF& ) override QQuickGeometryChange change, const QRectF& ) override
{ {
@ -87,6 +88,21 @@ class QskInputGrabber::PrivateData final : public QQuickItemChangeListener
if ( doUpdate ) if ( doUpdate )
m_grabber->updateGeometry(); m_grabber->updateGeometry();
} }
#else
void itemGeometryChanged(
QQuickItem* item, const QRectF& newRect, const QRectF& oldRect ) override
{
bool doUpdate = false;
if ( item == itemAbove )
doUpdate = newRect.topLeft() != oldRect.topLeft();
else
doUpdate = newRect.size() != oldRect.size();
if ( doUpdate )
m_grabber->updateGeometry();
}
#endif
void itemParentChanged( QQuickItem* item, QQuickItem* parentItem ) override void itemParentChanged( QQuickItem* item, QQuickItem* parentItem ) override
{ {
@ -109,7 +125,9 @@ QskInputGrabber::QskInputGrabber( QQuickItem* parent )
, m_data( new PrivateData( this ) ) , m_data( new PrivateData( this ) )
{ {
setAcceptedMouseButtons( Qt::AllButtons ); setAcceptedMouseButtons( Qt::AllButtons );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
setAcceptTouchEvents( true ); setAcceptTouchEvents( true );
#endif
setAcceptHoverEvents( true ); setAcceptHoverEvents( true );
setPlacementPolicy( QskPlacementPolicy::Ignore ); setPlacementPolicy( QskPlacementPolicy::Ignore );

View File

@ -323,7 +323,10 @@ QPointF QskListView::scrollOffset( const QWheelEvent* event ) const
const auto viewHeight = viewContentsRect().height(); const auto viewHeight = viewContentsRect().height();
const qreal rowHeight = this->rowHeight(); const qreal rowHeight = this->rowHeight();
const int numLines = QGuiApplication::styleHints()->wheelScrollLines(); int numLines = 3;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 )
numLines = QGuiApplication::styleHints()->wheelScrollLines();
#endif
qreal dy = numLines * rowHeight; qreal dy = numLines * rowHeight;
if ( event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ) ) if ( event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ) )

View File

@ -26,6 +26,8 @@ namespace
class Option class Option
{ {
public: public:
Option() = default;
Option( const QUrl& graphicSource, const QString& text ) Option( const QUrl& graphicSource, const QString& text )
: graphicSource( graphicSource ) : graphicSource( graphicSource )
, text( text ) , text( text )

View File

@ -16,6 +16,13 @@ QSK_QT_PRIVATE_END
#include <qpa/qplatforminputcontext.h> #include <qpa/qplatforminputcontext.h>
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
QSizeF qskItemSize( const QQuickItem* item )
{
// obsolete for Qt >= 5.10
auto d = QQuickItemPrivate::get( item );
return QSizeF( d->width, d->height );
}
QRectF qskItemRect( const QQuickItem* item ) QRectF qskItemRect( const QQuickItem* item )
{ {
auto d = QQuickItemPrivate::get( item ); auto d = QQuickItemPrivate::get( item );
@ -51,7 +58,19 @@ bool qskIsAncestorOf( const QQuickItem* item, const QQuickItem* child )
if ( item == nullptr || child == nullptr ) if ( item == nullptr || child == nullptr )
return false; return false;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
return item->isAncestorOf( child ); return item->isAncestorOf( child );
#else
while ( child )
{
if ( child == item )
return true;
child = child->parentItem();
}
return false;
#endif
} }
bool qskIsVisibleToParent( const QQuickItem* item ) bool qskIsVisibleToParent( const QQuickItem* item )
@ -656,7 +675,7 @@ void qskItemUpdateRecursive( QQuickItem* item )
qskItemUpdateRecursive( child ); qskItemUpdateRecursive( child );
} }
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) && QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
static const QQuickPointerTouchEvent* qskPointerPressEvent( const QQuickWindowPrivate* wd ) static const QQuickPointerTouchEvent* qskPointerPressEvent( const QQuickWindowPrivate* wd )
{ {
@ -693,7 +712,7 @@ bool qskGrabMouse( QQuickItem* item )
item->setKeepMouseGrab( true ); item->setKeepMouseGrab( true );
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) #if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 ) && QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
auto wd = QQuickWindowPrivate::get( item->window() ); auto wd = QQuickWindowPrivate::get( item->window() );
if ( wd->touchMouseDevice == nullptr ) if ( wd->touchMouseDevice == nullptr )

View File

@ -53,6 +53,7 @@ QSK_EXPORT void qskSetPlacementPolicy( QQuickItem*, QskPlacementPolicy );
QSK_EXPORT QskPlacementPolicy::Policy qskEffectivePlacementPolicy( const QQuickItem* ); QSK_EXPORT QskPlacementPolicy::Policy qskEffectivePlacementPolicy( const QQuickItem* );
QSK_EXPORT QSizeF qskItemSize( const QQuickItem* );
QSK_EXPORT QRectF qskItemRect( const QQuickItem* ); QSK_EXPORT QRectF qskItemRect( const QQuickItem* );
QSK_EXPORT QRectF qskItemGeometry( const QQuickItem* ); QSK_EXPORT QRectF qskItemGeometry( const QQuickItem* );

View File

@ -166,6 +166,12 @@ QskQuickItem::QskQuickItem( QskQuickItemPrivate& dd, QQuickItem* parent )
{ {
setFlag( QQuickItem::ItemHasContents, true ); setFlag( QQuickItem::ItemHasContents, true );
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
// since Qt 5.10 we have QQuickItem::ItemEnabledHasChanged
connect( this, &QQuickItem::enabledChanged,
this, &QskQuickItem::sendEnabledChangeEvent );
#endif
if ( dd.updateFlags & QskQuickItem::DeferredUpdate ) if ( dd.updateFlags & QskQuickItem::DeferredUpdate )
qskFilterWindow( window() ); qskFilterWindow( window() );
@ -183,6 +189,11 @@ QskQuickItem::~QskQuickItem()
if ( qskRegistry ) if ( qskRegistry )
qskRegistry->remove( this ); qskRegistry->remove( this );
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
disconnect( this, &QQuickItem::enabledChanged,
this, &QskQuickItem::sendEnabledChangeEvent );
#endif
} }
const char* QskQuickItem::className() const const char* QskQuickItem::className() const
@ -580,6 +591,11 @@ void QskQuickItem::resetImplicitSize()
} }
} }
void QskQuickItem::sendEnabledChangeEvent()
{
qskSendEventTo( this, QEvent::EnabledChange );
}
bool QskQuickItem::event( QEvent* event ) bool QskQuickItem::event( QEvent* event )
{ {
const int eventType = event->type(); const int eventType = event->type();
@ -771,11 +787,13 @@ void QskQuickItem::itemChange( QQuickItem::ItemChange change,
break; break;
} }
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
case QQuickItem::ItemEnabledHasChanged: case QQuickItem::ItemEnabledHasChanged:
{ {
qskSendEventTo( this, QEvent::EnabledChange ); sendEnabledChangeEvent();
break; break;
} }
#endif
case QQuickItem::ItemVisibleHasChanged: case QQuickItem::ItemVisibleHasChanged:
{ {
Q_D( QskQuickItem ); Q_D( QskQuickItem );

View File

@ -60,6 +60,9 @@ class QSK_EXPORT QskQuickItem : public QQuickItem
bool hasChildItems() const; bool hasChildItems() const;
QRectF rect() const; QRectF rect() const;
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
QSizeF size() const;
#endif
QSizeF implicitSize() const; QSizeF implicitSize() const;
void setGeometry( qreal x, qreal y, qreal width, qreal height ); void setGeometry( qreal x, qreal y, qreal width, qreal height );
@ -159,6 +162,7 @@ class QSK_EXPORT QskQuickItem : public QQuickItem
void childrenRect() = delete; void childrenRect() = delete;
void applyUpdateFlag( UpdateFlag, bool on ); void applyUpdateFlag( UpdateFlag, bool on );
void sendEnabledChangeEvent();
QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override final; QSGNode* updatePaintNode( QSGNode*, UpdatePaintNodeData* ) override final;
virtual QSGNode* updateItemPaintNode( QSGNode* ); virtual QSGNode* updateItemPaintNode( QSGNode* );
@ -194,6 +198,15 @@ inline void QskQuickItem::setSize( qreal width, qreal height )
QQuickItem::setSize( QSizeF( width, height ) ); QQuickItem::setSize( QSizeF( width, height ) );
} }
#if QT_VERSION < QT_VERSION_CHECK( 5, 10, 0 )
inline QSizeF QskQuickItem::size() const
{
return QSizeF( width(), height() );
}
#endif
inline QSizeF QskQuickItem::implicitSize() const inline QSizeF QskQuickItem::implicitSize() const
{ {
return QSizeF( implicitWidth(), implicitHeight() ); return QSizeF( implicitWidth(), implicitHeight() );

View File

@ -241,6 +241,7 @@ namespace
void itemChange( ItemChange, const ItemChangeData& ) override; void itemChange( ItemChange, const ItemChangeData& ) override;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
void itemGeometryChanged( QQuickItem*, void itemGeometryChanged( QQuickItem*,
QQuickGeometryChange change, const QRectF& ) override QQuickGeometryChange change, const QRectF& ) override
{ {
@ -248,6 +249,15 @@ namespace
scrolledItemGeometryChange(); scrolledItemGeometryChange();
} }
#else
void itemGeometryChanged( QQuickItem*,
const QRectF& newRect, const QRectF& oldRect ) override
{
if ( oldRect.size() != newRect.size() )
scrolledItemGeometryChange();
}
#endif
void updateNode( QSGNode* ) override; void updateNode( QSGNode* ) override;
private: private:
@ -500,7 +510,7 @@ QSizeF QskScrollArea::layoutSizeHint( Qt::SizeHint which, const QSizeF& constrai
} }
else else
{ {
hint = contentItem->size(); hint = qskItemSize( contentItem );
} }
if ( verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff ) if ( verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOff )

View File

@ -332,7 +332,11 @@ QString QskSkin::dialogButtonText( int action ) const
const auto theme = QGuiApplicationPrivate::platformTheme(); const auto theme = QGuiApplicationPrivate::platformTheme();
auto text = theme->standardButtonText( action ); auto text = theme->standardButtonText( action );
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
text.remove( '&' );
#else
text = QPlatformTheme::removeMnemonics( text ); text = QPlatformTheme::removeMnemonics( text );
#endif
return text; return text;
} }

View File

@ -35,7 +35,18 @@
static inline bool qskIsControl( const QskSkinnable* skinnable ) static inline bool qskIsControl( const QskSkinnable* skinnable )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
return skinnable->metaObject()->inherits( &QskControl::staticMetaObject ); return skinnable->metaObject()->inherits( &QskControl::staticMetaObject );
#else
for ( auto mo = skinnable->metaObject();
mo != nullptr; mo = mo->superClass() )
{
if ( mo == &QskControl::staticMetaObject )
return true;
}
return false;
#endif
} }
static inline bool qskSetFlag( QskSkinnable* skinnable, static inline bool qskSetFlag( QskSkinnable* skinnable,

View File

@ -126,8 +126,8 @@ void QskSubWindowArea::itemChange(
{ {
// the child is not fully constructed // the child is not fully constructed
// and we have to delay checking for sub windows // and we have to delay checking for sub windows
QMetaObject::invokeMethod( this, QTimer::singleShot( 0, this,
[ this ] { qskUpdateEventFilter( this ); }, Qt::QueuedConnection ); [ this ] { qskUpdateEventFilter( this ); } );
break; break;
} }

View File

@ -36,8 +36,10 @@ static inline void qskBindSignals(
QObject::connect( wrappedInput, &QQuickTextInput::displayTextChanged, QObject::connect( wrappedInput, &QQuickTextInput::displayTextChanged,
input, [ input ] { Q_EMIT input->displayTextChanged( input->displayText() ); } ); input, [ input ] { Q_EMIT input->displayTextChanged( input->displayText() ); } );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 )
QObject::connect( wrappedInput, &QQuickTextInput::textEdited, QObject::connect( wrappedInput, &QQuickTextInput::textEdited,
input, [ input ] { Q_EMIT input->textEdited( input->text() ); } ); input, [ input ] { Q_EMIT input->textEdited( input->text() ); } );
#endif
QObject::connect( wrappedInput, &QQuickTextInput::validatorChanged, QObject::connect( wrappedInput, &QQuickTextInput::validatorChanged,
input, &QskTextInput::validatorChanged ); input, &QskTextInput::validatorChanged );
@ -48,8 +50,10 @@ static inline void qskBindSignals(
QObject::connect( wrappedInput, &QQuickTextInput::readOnlyChanged, QObject::connect( wrappedInput, &QQuickTextInput::readOnlyChanged,
input, [ input ] { qskPropagateReadOnly( input ); } ); input, [ input ] { qskPropagateReadOnly( input ); } );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
QObject::connect( wrappedInput, &QQuickTextInput::overwriteModeChanged, QObject::connect( wrappedInput, &QQuickTextInput::overwriteModeChanged,
input, &QskTextInput::overwriteModeChanged ); input, &QskTextInput::overwriteModeChanged );
#endif
QObject::connect( wrappedInput, &QQuickTextInput::maximumLengthChanged, QObject::connect( wrappedInput, &QQuickTextInput::maximumLengthChanged,
input, &QskTextInput::maximumLengthChanged ); input, &QskTextInput::maximumLengthChanged );
@ -215,7 +219,9 @@ namespace
return; return;
setCursorVisible( on ); setCursorVisible( on );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
d->setBlinkingCursorEnabled( on ); d->setBlinkingCursorEnabled( on );
#endif
if ( !on ) if ( !on )
{ {
@ -557,7 +563,11 @@ void QskTextInput::setActivationModes( ActivationModes modes )
static inline void qskUpdateInputMethodFont( const QskTextInput* input ) static inline void qskUpdateInputMethodFont( const QskTextInput* input )
{ {
const auto queries = Qt::ImCursorRectangle | Qt::ImFont | Qt::ImAnchorRectangle; auto queries = Qt::ImCursorRectangle | Qt::ImFont;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
queries |= Qt::ImAnchorRectangle;
#endif
qskUpdateInputMethod( input, queries ); qskUpdateInputMethod( input, queries );
} }
@ -777,6 +787,8 @@ QString QskTextInput::preeditText() const
return d->m_textLayout.preeditAreaText(); return d->m_textLayout.preeditAreaText();
} }
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
bool QskTextInput::overwriteMode() const bool QskTextInput::overwriteMode() const
{ {
return m_data->textInput->overwriteMode(); return m_data->textInput->overwriteMode();
@ -787,6 +799,8 @@ void QskTextInput::setOverwriteMode( bool overwrite )
m_data->textInput->setOverwriteMode( overwrite ); m_data->textInput->setOverwriteMode( overwrite );
} }
#endif
bool QskTextInput::hasAcceptableInput() const bool QskTextInput::hasAcceptableInput() const
{ {
return m_data->textInput->hasAcceptableInput(); return m_data->textInput->hasAcceptableInput();
@ -820,7 +834,9 @@ QVariant QskTextInput::inputMethodQuery(
{ {
return locale(); return locale();
} }
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
case Qt::ImInputItemClipRectangle: case Qt::ImInputItemClipRectangle:
#endif
case Qt::ImCursorRectangle: case Qt::ImCursorRectangle:
{ {
QVariant v = m_data->textInput->inputMethodQuery( query, argument ); QVariant v = m_data->textInput->inputMethodQuery( query, argument );

View File

@ -137,8 +137,10 @@ class QSK_EXPORT QskTextInput : public QskControl
QString displayText() const; QString displayText() const;
QString preeditText() const; QString preeditText() const;
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
bool overwriteMode() const; bool overwriteMode() const;
void setOverwriteMode( bool ); void setOverwriteMode( bool );
#endif
bool hasAcceptableInput() const; bool hasAcceptableInput() const;
bool fixup(); bool fixup();
@ -168,14 +170,20 @@ class QSK_EXPORT QskTextInput : public QskControl
void textChanged( const QString& ); void textChanged( const QString& );
void displayTextChanged( const QString& ); void displayTextChanged( const QString& );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 )
void textEdited( const QString& ); void textEdited( const QString& );
#endif
void descriptionChanged( const QString& ); void descriptionChanged( const QString& );
void textOptionsChanged(); void textOptionsChanged();
void fontRoleChanged(); void fontRoleChanged();
void alignmentChanged(); void alignmentChanged();
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
void overwriteModeChanged( bool ); void overwriteModeChanged( bool );
#endif
void maximumLengthChanged( int ); void maximumLengthChanged( int );
void echoModeChanged( EchoMode ); void echoModeChanged( EchoMode );

View File

@ -204,6 +204,18 @@ QskWindow::~QskWindow()
{ {
} }
#if QT_VERSION < QT_VERSION_CHECK( 5, 9, 0 )
void QskWindow::setFlag(Qt::WindowType flag, bool on)
{
if( on )
setFlags( flags() | flag );
else
setFlags( flags() & ~flag );
}
#endif
void QskWindow::setScreen( const QString& name ) void QskWindow::setScreen( const QString& name )
{ {
if ( !name.isEmpty() ) if ( !name.isEmpty() )

View File

@ -43,6 +43,10 @@ class QSK_EXPORT QskWindow : public QQuickWindow
using Inherited::setScreen; using Inherited::setScreen;
void setScreen( const QString& ); void setScreen( const QString& );
#if QT_VERSION < QT_VERSION_CHECK( 5, 9, 0 )
void setFlag( Qt::WindowType, bool on = true );
#endif
bool deleteOnClose() const; bool deleteOnClose() const;
void setDeleteOnClose( bool ); void setDeleteOnClose( bool );

View File

@ -55,8 +55,8 @@ QskGraphicProvider* QskGraphicProviderMap::take( const QString& providerId )
{ {
QskGraphicProvider* provider = nullptr; QskGraphicProvider* provider = nullptr;
const auto it = m_data->hashTab.constFind( qskKey( providerId ) ); const auto it = m_data->hashTab.find( qskKey( providerId ) );
if ( it != m_data->hashTab.constEnd() ) if ( it != m_data->hashTab.end() )
{ {
provider = it.value(); provider = it.value();
m_data->hashTab.erase( it ); m_data->hashTab.erase( it );
@ -67,8 +67,8 @@ QskGraphicProvider* QskGraphicProviderMap::take( const QString& providerId )
QskGraphicProvider* QskGraphicProviderMap::provider( const QString& providerId ) const QskGraphicProvider* QskGraphicProviderMap::provider( const QString& providerId ) const
{ {
const auto it = m_data->hashTab.constFind( qskKey( providerId ) ); const auto it = m_data->hashTab.find( qskKey( providerId ) );
if ( it == m_data->hashTab.constEnd() ) if ( it == m_data->hashTab.end() )
return nullptr; return nullptr;
if ( it.value().isNull() ) if ( it.value().isNull() )

View File

@ -11,10 +11,11 @@
class QskGraphic; class QskGraphic;
namespace QskStandardSymbol class QSK_EXPORT QskStandardSymbol
{ {
QSK_EXPORT Q_NAMESPACE Q_GADGET
public:
enum Type enum Type
{ {
NoSymbol = -1, NoSymbol = -1,
@ -30,9 +31,9 @@ namespace QskStandardSymbol
SymbolTypeCount SymbolTypeCount
}; };
Q_ENUM_NS( Type ) Q_ENUM( Type )
QSK_EXPORT QskGraphic graphic( Type ); static QskGraphic graphic( Type );
} };
#endif #endif

View File

@ -454,6 +454,7 @@ void QskInputPanel::updateInputPanel( Qt::InputMethodQueries queries )
setLocale( event.value( Qt::ImPreferredLanguage ).toLocale() ); setLocale( event.value( Qt::ImPreferredLanguage ).toLocale() );
} }
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
if ( queries & Qt::ImInputItemClipRectangle ) if ( queries & Qt::ImInputItemClipRectangle )
{ {
/* /*
@ -461,6 +462,7 @@ void QskInputPanel::updateInputPanel( Qt::InputMethodQueries queries )
so that it does not hide the item. so that it does not hide the item.
*/ */
} }
#endif
} }
void QskInputPanel::updateLocale( const QLocale& locale ) void QskInputPanel::updateLocale( const QLocale& locale )

View File

@ -27,11 +27,15 @@
static inline bool qskHasOpenGLRenderer( const QQuickWindow* window ) static inline bool qskHasOpenGLRenderer( const QQuickWindow* window )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
if ( window == nullptr ) if ( window == nullptr )
return false; return false;
const auto renderer = window->rendererInterface(); const auto renderer = window->rendererInterface();
return renderer->graphicsApi() == QSGRendererInterface::OpenGL; return renderer->graphicsApi() == QSGRendererInterface::OpenGL;
#else
return true;
#endif
} }
static uint qskCreateTextureOpenGL( QQuickWindow* window, static uint qskCreateTextureOpenGL( QQuickWindow* window,

View File

@ -21,7 +21,11 @@ class QskTickmarksNodePrivate final : public QSGGeometryNodePrivate
QskTickmarksNodePrivate() QskTickmarksNodePrivate()
: geometry( QSGGeometry::defaultAttributes_Point2D(), 0 ) : geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{ {
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
geometry.setDrawingMode( QSGGeometry::DrawLines ); geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
geometry.setDrawingMode( GL_LINES );
#endif
geometry.setVertexDataPattern( QSGGeometry::StaticPattern ); geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
} }

View File

@ -1,11 +0,0 @@
CONFIG += qskexample
CONFIG += console
CONFIG += testcase
QT += testlib
HEADERS += \
main.h
SOURCES += \
main.cpp

View File

@ -1,223 +0,0 @@
#include "main.h"
#include <QskCheckBox.h>
void CheckBoxTests::init()
{
root = new QskControl();
}
void CheckBoxTests::cleanup()
{
delete root;
}
void CheckBoxTests::checkbox()
{
auto t = new QskCheckBox( root );
QVERIFY( t->isCheckable() );
}
void CheckBoxTests::click()
{
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
t->click();
QVERIFY( t->isChecked() );
}
void CheckBoxTests::toggle()
{
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
t->toggle();
QVERIFY( t->isChecked() );
t->toggle();
QVERIFY( t->isChecked() == false );
}
void CheckBoxTests::tristate()
{
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
QVERIFY( t->isTristate() == false );
t->setCheckState( Qt::CheckState::PartiallyChecked );
QVERIFY( t->isChecked() == true );
QVERIFY( t->isTristate() == true );
}
void CheckBoxTests::higherGroupUpdatesLower()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
auto t3 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t2 );
t->addToGroup( t3 );
QVERIFY( t->isChecked() == false );
QVERIFY( t1->isChecked() == false );
QVERIFY( t2->isChecked() == false );
QVERIFY( t3->isChecked() == false );
t->setChecked( true );
QVERIFY( t->isChecked() );
QVERIFY( t1->isChecked() );
QVERIFY( t2->isChecked() );
QVERIFY( t3->isChecked() );
t->setChecked( false );
QVERIFY( t->isChecked() == false );
QVERIFY( t1->isChecked() == false );
QVERIFY( t2->isChecked() == false );
QVERIFY( t3->isChecked() == false );
}
void CheckBoxTests::lowerGroupUpdatesHigher()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t2 );
t1->setChecked( true );
QVERIFY( t->isChecked() );
QVERIFY( t->isTristate() );
QVERIFY( t->checkState() == Qt::CheckState::PartiallyChecked );
QVERIFY( t1->isChecked() == true );
QVERIFY( t2->isChecked() == false );
t2->setChecked( true );
QVERIFY( t->isChecked() );
QVERIFY( t->isTristate() );
QVERIFY( t->checkState() == Qt::CheckState::Checked );
QVERIFY( t1->isChecked() == true );
QVERIFY( t2->isChecked() == true );
t1->setChecked( false );
QVERIFY( t->isChecked() );
QVERIFY( t->isTristate() );
QVERIFY( t->checkState() == Qt::CheckState::PartiallyChecked );
QVERIFY( t1->isChecked() == false );
QVERIFY( t2->isChecked() == true );
t2->setChecked( false );
QVERIFY( t->isChecked() == false );
QVERIFY( t->isTristate() );
QVERIFY( t->checkState() == Qt::CheckState::Unchecked );
QVERIFY( t1->isChecked() == false );
QVERIFY( t2->isChecked() == false );
}
void CheckBoxTests::addToGroup()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t2 );
t->setChecked( true );
QVERIFY( t->isChecked() );
QVERIFY( t1->isChecked() );
QVERIFY( t2->isChecked() );
auto t3 = new QskCheckBox( root );
t->addToGroup( t3 );
QVERIFY( t->checkState() == Qt::CheckState::PartiallyChecked );
t3->setChecked( true );
QVERIFY( t->checkState() == Qt::CheckState::Checked );
auto t4 = new QskCheckBox( root );
t4->setChecked( true );
t->addToGroup( t4 );
QVERIFY( t->checkState() == Qt::CheckState::Checked );
}
void CheckBoxTests::addPartlyToGroup() {
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t1a = new QskCheckBox( root );
auto t1b = new QskCheckBox( root );
t1->addToGroup( t1a );
t1->addToGroup( t1b );
t1a->setChecked( true );
QVERIFY( t1->checkState() == Qt::CheckState::PartiallyChecked );
t->addToGroup( t1 );
QVERIFY( t1->checkState() == Qt::CheckState::PartiallyChecked );
}
void CheckBoxTests::removeFromGroup()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t2 );
t2->setChecked( true );
QVERIFY( t->checkState() == Qt::CheckState::PartiallyChecked );
t->removeFromGroup( t2 );
QVERIFY( t->isChecked() == false );
}
void CheckBoxTests::groupMemberGetsDeleted()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t2 );
t2->setChecked( true );
QVERIFY( t->checkState() == Qt::CheckState::PartiallyChecked );
delete t2;
QVERIFY( t->isChecked() == false );
}
void CheckBoxTests::addTwiceToSameGroup()
{
auto t = new QskCheckBox( root );
auto t1 = new QskCheckBox( root );
auto t2 = new QskCheckBox( root );
t->addToGroup( t1 );
t->addToGroup( t1 );
t->removeFromGroup( t1 );
t->addToGroup( t2 );
t2->setChecked( true );
QVERIFY( t->checkState() == Qt::CheckState::Checked );
}
#include "moc_main.cpp"

View File

@ -1,30 +0,0 @@
#pragma once
#include <qobject.h>
#include <QtTest/QtTest>
class QskControl;
class CheckBoxTests : public QObject
{
Q_OBJECT
QskControl * root;
private Q_SLOTS:
void init();
void cleanup();
void checkbox();
void click();
void toggle();
void tristate();
void higherGroupUpdatesLower();
void lowerGroupUpdatesHigher();
void addToGroup();
void addPartlyToGroup();
void removeFromGroup();
void groupMemberGetsDeleted();
void addTwiceToSameGroup();
};
QTEST_MAIN(CheckBoxTests)

View File

@ -1,5 +0,0 @@
TEMPLATE = subdirs
SUBDIRS += \
checkboxes