changes from master

This commit is contained in:
Uwe Rathmann 2022-03-25 13:23:44 +01:00
parent 2bfb68c7de
commit 1430210424
150 changed files with 2426 additions and 1329 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@ But so far only Linux is actively tested.
It might support all versions Qt >= 5.6, but you can rely on:
- Qt 5.6
- Qt 5.15
- current long term supported ( LTS ) version of Qt
- current version of Qt

View File

@ -33,7 +33,7 @@ namespace
connect( this, &QskTabView::currentIndexChanged,
this, &TabView::updateViewPanel );
}
}
protected:
void aboutToShow() override
@ -48,7 +48,7 @@ namespace
We should have a better way to set individual colors
for each tab page background
*/
if ( auto page = dynamic_cast< const ::Page* >( currentItem() ) )
setGradientHint( QskTabView::Page, page->gradient() );
}

View File

@ -165,14 +165,15 @@ bool LightDisplay::arcContainsPoint( const QRectF& rect, const QPointF& point )
const int tolerance = 20;
// 1. check angle
QPointF circlePos( point.x() - rect.center().x(),
rect.center().y() - point.y() );
QPointF circlePos(
point.x() - rect.center().x(),
rect.center().y() - point.y() );
const qreal angle = angleFromPoint( rect, point );
const bool angleWithinRange = angleInRange( metrics, angle )
|| angleDiff( angle, metrics.startAngle() ) <= tolerance
|| angleDiff( angle, metrics.endAngle() ) <= tolerance;
|| angleDiff( angle, metrics.startAngle() ) <= tolerance
|| angleDiff( angle, metrics.endAngle() ) <= tolerance;
// 2. check whether point is on arc
const qreal radiusMax = rect.width() / 2;
@ -181,7 +182,7 @@ bool LightDisplay::arcContainsPoint( const QRectF& rect, const QPointF& point )
const qreal polarRadius = qSqrt( qPow( circlePos.x(), 2 ) + qPow( circlePos.y(), 2 ) );
const bool pointOnArc = ( polarRadius + tolerance ) > radiusMin
&& ( polarRadius - tolerance ) < radiusMax;
&& ( polarRadius - tolerance ) < radiusMax;
bool ret = angleWithinRange && pointOnArc;

View File

@ -11,6 +11,7 @@
#include <QskArcMetrics.h>
#include <QskTextOptions.h>
#include <QskScaleTickmarks.h>
#include <QFontMetrics>
#include <QtMath>
@ -33,15 +34,15 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable,
QRectF rect = contentsRect;
const qreal ticksSpacing = 4; // space between the ticks and the arc
if( subControl == LightDisplay::Groove
|| subControl == LightDisplay::Panel )
if( subControl == LightDisplay::Groove || subControl == LightDisplay::Panel )
{
QSizeF textSize = textLabelsSize( display );
QskArcMetrics arcMetrics = display->arcMetricsHint( LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint( LightDisplay::Tickmarks ).width() + ticksSpacing;
const qreal x = textSize.width() + arcMetrics.width() + ticksWidth;
const qreal w = contentsRect.width() - ( 2 * ( textSize.width() + arcMetrics.width() + ticksWidth ) );
const qreal w = contentsRect.width() -
( 2 * ( textSize.width() + arcMetrics.width() + ticksWidth ) );
const qreal y = arcMetrics.width() + ticksWidth;
const qreal h = contentsRect.height() - 2 * ( arcMetrics.width() + ticksWidth );
@ -52,24 +53,24 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable,
}
else if( subControl == LightDisplay::ColdAndWarmArc )
{
const QRectF panelRect = subControlRect( skinnable, contentsRect,
LightDisplay::Panel );
const QRectF panelRect = subControlRect( skinnable, contentsRect, LightDisplay::Panel );
auto barWidth = display->arcMetricsHint( LightDisplay::ColdAndWarmArc ).width();
auto rect = panelRect.marginsAdded( { barWidth, barWidth, barWidth, barWidth } );
return rect;
}
else if( subControl == LightDisplay::Tickmarks )
{
const QRectF arcRect = subControlRect( skinnable, contentsRect,
LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint( LightDisplay::Tickmarks ).width() + ticksSpacing;
const QRectF rect = arcRect.marginsAdded( { ticksWidth, ticksWidth, ticksWidth, ticksWidth } );
const QRectF arcRect = subControlRect(
skinnable, contentsRect, LightDisplay::ColdAndWarmArc );
const qreal ticksWidth = display->arcMetricsHint(
LightDisplay::Tickmarks ).width() + ticksSpacing;
const QRectF rect =
arcRect.marginsAdded( { ticksWidth, ticksWidth, ticksWidth, ticksWidth } );
return rect;
}
else if( subControl == LightDisplay::ValueText )
{
QRectF valueTextRect = subControlRect( skinnable, contentsRect,
LightDisplay::Panel );
QRectF valueTextRect = subControlRect( skinnable, contentsRect, LightDisplay::Panel );
const QFontMetricsF fm( skinnable->effectiveFont( subControl ) );
const qreal fontWidth = fm.width( QStringLiteral( "100 %" ) );
const QPointF center = valueTextRect.center();
@ -125,8 +126,7 @@ QRectF LightDisplaySkinlet::subControlRect( const QskSkinnable* skinnable,
QSGNode* LightDisplaySkinlet::updateSubNode(
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
{
auto* display = static_cast< const LightDisplay* >( skinnable );
const auto* display = static_cast< const LightDisplay* >( skinnable );
switch( nodeRole )
{
@ -166,16 +166,16 @@ QSGNode* LightDisplaySkinlet::updateSubNode(
if ( ticksNode == nullptr )
ticksNode = new RadialTickmarksNode();
QColor color = display->color( LightDisplay::Tickmarks );
QRectF ticksRect = display->subControlRect( LightDisplay::Tickmarks );
QskArcMetrics arcMetrics = display->arcMetricsHint( LightDisplay::Tickmarks );
QskIntervalF boundaries = display->boundaries();
QskScaleTickmarks tickmarks;
tickmarks.setMajorTicks( {0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180 } );
int tickLineWidth = display->metric( LightDisplay::Tickmarks );
const auto color = display->color( LightDisplay::Tickmarks );
const auto ticksRect = display->subControlRect( LightDisplay::Tickmarks );
const auto arcMetrics = display->arcMetricsHint( LightDisplay::Tickmarks );
ticksNode->update( color, ticksRect, arcMetrics, boundaries,
tickmarks, tickLineWidth, Qt::Horizontal );
QskScaleTickmarks tickmarks;
tickmarks.setMajorTicks( { 0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180 } );
const auto tickLineWidth = display->metric( LightDisplay::Tickmarks );
ticksNode->update( color, ticksRect, arcMetrics, tickmarks, tickLineWidth );
return ticksNode;
}
@ -207,11 +207,11 @@ QSGNode* LightDisplaySkinlet::updateSubNode(
QSizeF LightDisplaySkinlet::textLabelsSize( const LightDisplay* display ) const
{
QFont font = display->effectiveFont( LightDisplay::LeftLabel );
QFontMetricsF fm( font );
const QFontMetricsF fm( display->effectiveFont( LightDisplay::LeftLabel ) );
qreal w = fm.width( QStringLiteral( " 100" ) );
qreal h = fm.height();
return { w, h };
}

View File

@ -46,7 +46,7 @@ MenuBar::MenuBar( QQuickItem* parent )
m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" };
for( const auto& entryString : qskAsConst( m_entryStrings ) )
for( const auto& entryString : qAsConst( m_entryStrings ) )
{
auto* entry = new MenuItem( entryString, this );
m_entries.append( entry );

View File

@ -125,7 +125,7 @@ QColor ShadowedBox::shadowColor() const
return m_shadowColor;
}
QRectF ShadowedBox::layoutRectForSize( const QSizeF &size ) const
QRectF ShadowedBox::layoutRectForSize( const QSizeF& size ) const
{
auto padding = paddingHint( Panel );
return { padding.left() / 2, padding.top() / 2,

View File

@ -1,6 +1,7 @@
CONFIG += qskexample
QT += svg
QT += quick_private # TODO: examples should not use private headers
SOURCES += \
Box.cpp \

View File

@ -46,9 +46,9 @@ namespace
int compare( const QSGMaterial* other ) const override;
QVector2D aspect = QVector2D{1.0, 1.0};
QVector2D aspect = QVector2D{ 1.0, 1.0 };
float blurExtent = 0.0;
QVector4D radius = QVector4D{0.0, 0.0, 0.0, 0.0};
QVector4D radius = QVector4D{ 0.0, 0.0, 0.0, 0.0 };
QColor color = Qt::black;
};

View File

@ -5,82 +5,48 @@
#include "RadialTickmarksNode.h"
#include <QSGFlatColorMaterial>
#include <QskScaleTickmarks.h>
#include <QskArcMetrics.h>
#include <QtMath>
QSK_QT_PRIVATE_BEGIN
#include <private/qsgnode_p.h>
QSK_QT_PRIVATE_END
static constexpr inline qreal qskTickFactor( QskScaleTickmarks::TickType type )
{
using TM = QskScaleTickmarks;
return type == TM::MinorTick ? 0.7 : ( type == TM::MinorTick ? 0.85 : 1.0 );
}
class RadialTickmarksNodePrivate final : public QSGGeometryNodePrivate
{
public:
RadialTickmarksNodePrivate()
: geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
geometry.setDrawingMode( GL_LINES );
#endif
geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
}
QSGGeometry geometry;
QSGFlatColorMaterial material;
QskIntervalF boundaries;
QskScaleTickmarks tickmarks;
QRectF rect;
int lineWidth = 0;
uint hash = 0;
};
RadialTickmarksNode::RadialTickmarksNode()
: QSGGeometryNode( *new RadialTickmarksNodePrivate )
: m_geometry( QSGGeometry::defaultAttributes_Point2D(), 0 )
{
Q_D( RadialTickmarksNode );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 8, 0 )
m_geometry.setDrawingMode( QSGGeometry::DrawLines );
#else
m_geometry.setDrawingMode( GL_LINES );
#endif
m_geometry.setVertexDataPattern( QSGGeometry::StaticPattern );
setGeometry( &d->geometry );
setMaterial( &d->material );
setGeometry( &m_geometry );
setMaterial( &m_material );
}
RadialTickmarksNode::~RadialTickmarksNode()
{
}
void RadialTickmarksNode::update(const QColor& color, const QRectF& rect,
const QskArcMetrics& arcMetrics, const QskIntervalF& /*boundaries*/,
const QskScaleTickmarks& tickmarks, int lineWidth,
Qt::Orientation /*orientation*/ )
void RadialTickmarksNode::update( const QColor& color, const QRectF& rect,
const QskArcMetrics& arcMetrics, const QskScaleTickmarks& tickmarks, int lineWidth )
{
Q_D( RadialTickmarksNode );
if( lineWidth != d->lineWidth )
if( lineWidth != m_lineWidth )
{
d->lineWidth = lineWidth;
d->geometry.setLineWidth( lineWidth );
m_lineWidth = lineWidth;
m_geometry.setLineWidth( lineWidth );
markDirty( QSGNode::DirtyGeometry );
}
const uint hash = tickmarks.hash( 17435 );
const auto hash = tickmarks.hash( 17435 );
if( ( hash != d->hash ) || ( rect != d->rect ) )
if( ( hash != m_hash ) || ( rect != m_rect ) )
{
d->hash = hash;
d->rect = rect;
m_hash = hash;
m_rect = rect;
d->geometry.allocate( tickmarks.tickCount() * 2 );
auto vertexData = d->geometry.vertexDataAsPoint2D();
m_geometry.allocate( tickmarks.tickCount() * 2 );
auto vertexData = m_geometry.vertexDataAsPoint2D();
const auto center = rect.center();
const auto radius = 0.5 * rect.width();
@ -117,13 +83,13 @@ void RadialTickmarksNode::update(const QColor& color, const QRectF& rect,
}
}
d->geometry.markVertexDataDirty();
m_geometry.markVertexDataDirty();
markDirty( QSGNode::DirtyGeometry );
}
if ( color != d->material.color() )
if ( color != m_material.color() )
{
d->material.setColor( color );
m_material.setColor( color );
markDirty( QSGNode::DirtyMaterial );
}
}

View File

@ -5,13 +5,13 @@
#pragma once
#include <QskArcMetrics.h>
#include <QskIntervalF.h>
#include <QskScaleTickmarks.h>
#include <QSGGeometryNode>
#include <QSGFlatColorMaterial>
class RadialTickmarksNodePrivate;
class QskArcMetrics;
class QskScaleTickmarks;
class RadialTickmarksNode : public QSGGeometryNode
{
@ -19,9 +19,15 @@ class RadialTickmarksNode : public QSGGeometryNode
RadialTickmarksNode();
~RadialTickmarksNode() override;
void update( const QColor&, const QRectF&, const QskArcMetrics&,
const QskIntervalF&, const QskScaleTickmarks&, int, Qt::Orientation );
void update( const QColor&, const QRectF&,
const QskArcMetrics&, const QskScaleTickmarks&, int lineWidth );
private:
Q_DECLARE_PRIVATE( RadialTickmarksNode )
QSGGeometry m_geometry;
QSGFlatColorMaterial m_material;
QRectF m_rect;
int m_lineWidth = 0;
QskHashValue m_hash = 0;
};

View File

@ -34,9 +34,14 @@ class ListBox : public QskSimpleListBox
private:
void populate()
{
const int count = 10000;
const QString format( "Row %1: The quick brown fox jumps over the lazy dog" );
QStringList entries;
for ( int i = 0; i < 10000; i++ )
entries.reserve( count );
for ( int i = 0; i < count; i++ )
{
entries += format.arg( i + 1 );
}

View File

@ -16,6 +16,7 @@
#include <QskBox.h>
#include <QskLinearBox.h>
#include <QskSkinManager.h>
#include <QskAnimationHint.h>
#include <QskSkinTransition.h>
#include <QskSetup.h>
#include <QskSkin.h>

View File

@ -37,7 +37,7 @@ CONFIG += no_private_qt_headers_warning
CONFIG += warn_on
CONFIG += no_keywords
CONFIG += silent
CONFIG -= depend_includepath
#CONFIG -= depend_includepath
CONFIG += strict_c++
CONFIG += c++11
@ -64,16 +64,6 @@ RCC_DIR = rcc
QSK_CONFIG += QskDll
*-g++* {
GCC_VERSION = $$system("$$QMAKE_CXX -dumpversion")
equals(GCC_VERSION,4) || contains(GCC_VERSION, 4.* ) {
# gcc4 is too old for certain checks
CONFIG -= pedantic sanitize
}
}
linux {
pedantic {
@ -83,16 +73,20 @@ linux {
# Qt headers do not stand pedantic checks, so it's better
# to exclude them by declaring them as system includes
CONFIG += qtassysteminclude
}
qtassysteminclude {
# As most distros set QT_INSTALL_HEADERS to /usr/include we
# would run into gcc compiler errors and better drop it
# from the list below. Should be no problem as we don't
# add the Qt module to our includes and therefore don't
# need this path.
# QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS]
QMAKE_CXXFLAGS += \
-isystem $$[QT_INSTALL_HEADERS]/QtCore \
-isystem $$[QT_INSTALL_HEADERS]/QtCore/$$[QT_VERSION]/QtCore \
-isystem $$[QT_INSTALL_HEADERS]/QtGui \
-isystem $$[QT_INSTALL_HEADERS]/QtGui/$$[QT_VERSION]/QtGui \
-isystem $$[QT_INSTALL_HEADERS]/QtQuick \
@ -114,13 +108,6 @@ linux-g++ | linux-g++-64 {
# QMAKE_CXXFLAGS_RELEASE *= -Ofast
# QMAKE_CXXFLAGS_RELEASE *= -Os
# Some versions ( here 2.31.1 ) of the BFD linker may generate shared
# libraries with corrupt symbol version info which leads to
# "invalid version 21" errors when the corrupt shared library is used.
# One possible workaround is to use the gold linker instead.
# QMAKE_LFLAGS *= -Wl,-fuse-ld=gold
}
pedantic {
@ -130,7 +117,7 @@ pedantic {
QMAKE_CXXFLAGS *= -pedantic-errors
QMAKE_CXXFLAGS *= -Wextra
QMAKE_CXXFLAGS *= -Werror=format-security
QMAKE_CXXFLAGS *= -Wlogical-op
#QMAKE_CXXFLAGS *= -Wlogical-op
# QMAKE_CXXFLAGS *= -Wconversion
# QMAKE_CXXFLAGS *= -Wfloat-equal
@ -172,8 +159,7 @@ sanitize {
CONFIG += sanitizer
CONFIG += sanitize_address
#CONFIG *= sanitize_memory
CONFIG *= sanitize_undefined
# CONFIG *= sanitize_undefined
linux-g++ | linux-g++-64 {
#QMAKE_CXXFLAGS *= -fsanitize-address-use-after-scope
@ -185,7 +171,16 @@ debug {
DEFINES += ITEM_STATISTICS=1
}
# Help out Qt Creator
ide: DEFINES += QT_IDE
# DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x000000
DEFINES += QSK_BUILD
LOCAL_PRI=$$(QSK_LOCAL_PRI)
if ( exists( $${LOCAL_PRI} ) ) {
# When not working with the Qt/Creator it is often more convenient
# to include the specific options of your local build, than passing
# them all on the command line
include( $${LOCAL_PRI} )
}

View File

@ -1,12 +1,3 @@
/******************************************************************************
* This code is a stripped down version of the Cassowary constraint solving
* algorithm. The implementation has been taken from the Kiwi project:
*
* Copyright (c) 2013-2017, Nucleic Development Team.
* Distributed under the terms of the Modified BSD License.
* https://github.com/nucleic/kiwi/blob/master/LICENSE
*****************************************************************************/
#include "Solver.h"
#include "Constraint.h"
#include "Variable.h"

View File

@ -59,7 +59,7 @@ GridQuick::GridQuick( QWidget* parent )
createQml( "import QtQuick 2.0\nimport QtQuick.Layouts 1.1\nItem { GridLayout {} }" );
setContent( QUrl(), nullptr, contentItem );
m_grid = contentItem->childItems().first();
m_grid = contentItem->childItems().constFirst();
m_grid->setProperty( "rowSpacing", 5 );
m_grid->setProperty( "columnSpacing", 5 );
}
@ -78,7 +78,7 @@ void GridQuick::insert( const QByteArray& colorName,
*/
auto layout = createQml( "import QtQuick 2.0\nimport QtQuick.Layouts 1.15\nGridLayout { Rectangle {} }" );
auto rectangle = layout->childItems().first();
auto rectangle = layout->childItems().constFirst();
rectangle->setParent( nullptr );
delete layout;

View File

@ -391,7 +391,7 @@ int main( int argc, char** argv )
#if 1
/*
we don't need the fonts, but by calling something from
we don't need the fonts, but by calling something from
the support library initializations regarding the skins
are loaded. TODO ...
*/

View File

@ -7,17 +7,18 @@
#include "QskGlobal.h"
#ifdef QT_NO_KEYWORDS
// qquickimage_p.h uses emit
#define emit Q_EMIT
#include <private/qquickimage_p.h>
#undef emit
QSK_QT_PRIVATE_BEGIN
#ifndef emit
#define emit
#include <private/qquickimage_p.h>
#undef emit
#else
#include <private/qquickimage_p.h>
#include <private/qquickimage_p.h>
#endif
QSK_QT_PRIVATE_END
#include <memory>
class Image : public QQuickImage

View File

@ -46,9 +46,9 @@ namespace
int compare( const QSGMaterial* other ) const override;
QVector2D aspect = QVector2D{1.0, 1.0};
QVector2D aspect = QVector2D{ 1.0, 1.0 };
float blurExtent = 0.0;
QVector4D radius = QVector4D{0.0, 0.0, 0.0, 0.0};
QVector4D radius = QVector4D{ 0.0, 0.0, 0.0, 0.0 };
QColor color = Qt::black;
};

View File

@ -36,7 +36,6 @@
#include <QskSkin.h>
#include <QskSkinManager.h>
#include <QskSlider.h>
#include <QskStandardSymbol.h>
#include <QskStatusIndicator.h>
#include <QskSubWindow.h>
#include <QskSubWindowArea.h>
@ -115,8 +114,8 @@ namespace
static inline QskGradientStop qskToGradientStop( const QJSValue& value )
{
return QskGradientStop(
value.property( QLatin1String( "position" ) ).toNumber(),
value.property( QLatin1String( "color" ) ).toVariant().value< QColor >()
value.property( QStringLiteral( "position" ) ).toNumber(),
value.property( QStringLiteral( "color" ) ).toVariant().value< QColor >()
);
}
@ -194,7 +193,6 @@ void QskQml::registerTypes()
#endif
QSK_REGISTER_GADGET( QskRgbValueQml, "RgbValue" );
QSK_REGISTER_GADGET( QskStandardSymbol, "StandardSymbol" );
QSK_REGISTER_GADGET( QskBoxBorderMetrics, "BorderMetrics" );
QSK_REGISTER_GADGET( QskBoxShapeMetrics, "Shape" );
QSK_REGISTER_GADGET( QskShadowMetrics, "ShadowMetrics" );

View File

@ -79,7 +79,7 @@ class QskShortcutQml : public QObject, public QQmlParserStatus
void activated();
void activatedAmbiguously();
int shortcutIdChanged( int );
void shortcutIdChanged( int );
protected:
bool event( QEvent* ) override;

View File

@ -21,6 +21,7 @@ OTHER_FILES = \
qmlexport.depends = src
inputcontext.depends = src
skins.depends = src
tools.depends = src
support.depends = src skins
examples.depends = tools support skins qmlexport
playground.depends = tools support skins qmlexport

View File

@ -785,7 +785,7 @@ QskMaterialSkin::QskMaterialSkin( QObject* parent )
QskRgb::Blue500, QskRgb::White );
// Default theme colors
setupFonts( "Roboto" );
setupFonts( QStringLiteral( "Roboto" ) );
auto buttonFont = font( QskSkin::DefaultFont );
buttonFont.setCapitalization( QFont::AllUppercase );

View File

@ -941,7 +941,7 @@ QskSquiekSkin::QskSquiekSkin( QObject* parent )
: Inherited( parent )
, m_data( new PrivateData() )
{
setupFonts( "DejaVuSans" );
setupFonts( QStringLiteral( "DejaVuSans" ) );
Editor editor( &hintTable(), m_data->palette );
editor.setup();

View File

@ -86,9 +86,9 @@ QskArcMetrics QskArcMetrics::toAbsolute( const QSizeF& size ) const noexcept
return absoluted;
}
uint QskArcMetrics::hash( uint seed ) const noexcept
QskHashValue QskArcMetrics::hash( QskHashValue seed ) const noexcept
{
uint hash = qHash( m_width, seed );
auto hash = qHash( m_width, seed );
hash = qHash( m_startAngle, hash );
hash = qHash( m_spanAngle, hash );

View File

@ -24,7 +24,7 @@ class QSK_EXPORT QskArcMetrics
public:
constexpr QskArcMetrics() noexcept;
constexpr QskArcMetrics( qreal width, qreal startAngle, qreal spanAngle,
Qt::SizeMode = Qt::AbsoluteSize ) noexcept;
Qt::SizeMode = Qt::AbsoluteSize ) noexcept;
bool operator==( const QskArcMetrics& ) const noexcept;
bool operator!=( const QskArcMetrics& ) const noexcept;
@ -50,7 +50,7 @@ class QSK_EXPORT QskArcMetrics
QskArcMetrics toAbsolute( const QSizeF& ) const noexcept;
uint hash( uint seed = 0 ) const noexcept;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
static QVariant interpolate( const QskArcMetrics&,
const QskArcMetrics&, qreal progress );

View File

@ -185,9 +185,9 @@ QVariant QskBoxBorderColors::interpolate(
return QVariant::fromValue( from.interpolated( to, ratio ) );
}
uint QskBoxBorderColors::hash( uint seed ) const
QskHashValue QskBoxBorderColors::hash( QskHashValue seed ) const
{
uint h = m_gradients[ 0 ].hash( seed );
auto h = m_gradients[ 0 ].hash( seed );
h = m_gradients[ 1 ].hash( h );
h = m_gradients[ 2 ].hash( h );
h = m_gradients[ 3 ].hash( h );

View File

@ -49,7 +49,7 @@ class QSK_EXPORT QskBoxBorderColors
static QVariant interpolate( const QskBoxBorderColors&,
const QskBoxBorderColors&, qreal ratio );
uint hash( uint seed = 0 ) const;
QskHashValue hash( QskHashValue seed = 0 ) const;
bool isMonochrome() const;
bool isVisible() const;

View File

@ -92,9 +92,9 @@ QVariant QskBoxBorderMetrics::interpolate(
return QVariant::fromValue( from.interpolated( to, progress ) );
}
uint QskBoxBorderMetrics::hash( uint seed ) const noexcept
QskHashValue QskBoxBorderMetrics::hash( QskHashValue seed ) const noexcept
{
uint hash = qHashBits( &m_widths, sizeof( m_widths ), seed );
auto hash = qHashBits( &m_widths, sizeof( m_widths ), seed );
const int mode = m_sizeMode;
return qHashBits( &mode, sizeof( mode ), hash );

View File

@ -55,7 +55,7 @@ class QSK_EXPORT QskBoxBorderMetrics
QskBoxBorderMetrics toAbsolute( const QSizeF& ) const noexcept;
uint hash( uint seed = 0 ) const noexcept;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
static QVariant interpolate( const QskBoxBorderMetrics&,
const QskBoxBorderMetrics&, qreal progress );

View File

@ -36,17 +36,17 @@ QskBoxHints QskBoxHints::interpolated(
}
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>
QDebug operator<<( QDebug debug, const QskBoxHints& hints )
{
{
debug << hints.shape << hints.borderMetrics
<< hints.borderColors << hints.gradient;
return debug;
}
#endif
#include "moc_QskBoxHints.cpp"

View File

@ -151,9 +151,9 @@ QVariant QskBoxShapeMetrics::interpolate(
return QVariant::fromValue( from.interpolated( to, progress ) );
}
uint QskBoxShapeMetrics::hash( uint seed ) const noexcept
QskHashValue QskBoxShapeMetrics::hash( QskHashValue seed ) const noexcept
{
uint hash = qHash( static_cast< int >( m_sizeMode ), seed );
auto hash = qHash( static_cast< int >( m_sizeMode ), seed );
return qHashBits( m_radii, sizeof( m_radii ), hash );
}

View File

@ -93,7 +93,7 @@ class QSK_EXPORT QskBoxShapeMetrics
constexpr QskBoxShapeMetrics transposed() const noexcept;
uint hash( uint seed = 0 ) const noexcept;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
static QVariant interpolate( const QskBoxShapeMetrics&,
const QskBoxShapeMetrics&, qreal progress ) noexcept;

View File

@ -122,7 +122,7 @@ QRectF qskValidOrEmptyInnerRect( const QRectF& rect, const QMarginsF& margins )
return QRectF( x, y, w, h );
}
QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress )
QRectF qskInterpolatedRect( const QRectF& from, const QRectF& to, qreal progress )
{
if ( progress <= 0.0 )
return from;
@ -138,7 +138,7 @@ QRectF qskInterpolatedRect( const QRectF &from, const QRectF &to, qreal progress
return QRectF( x, y, w, h );
}
QSizeF qskInterpolatedSize( const QSizeF &from, const QSizeF &to, qreal progress )
QSizeF qskInterpolatedSize( const QSizeF& from, const QSizeF& to, qreal progress )
{
if ( progress <= 0.0 )
return from;

View File

@ -17,15 +17,15 @@
#ifdef QSK_DLL
#if defined( QSK_MAKEDLL ) // create a DLL library
#define QSK_EXPORT Q_DECL_EXPORT
#define QSK_EXPORT Q_DECL_EXPORT
#else // use a DLL library
#define QSK_EXPORT Q_DECL_IMPORT
#define QSK_EXPORT Q_DECL_IMPORT
#endif
#endif // QSK_DLL
#ifndef QSK_EXPORT
#define QSK_EXPORT
#define QSK_EXPORT
#endif
#define QSK_QT_PRIVATE_BEGIN \
@ -39,27 +39,26 @@
#define QSK_QT_PRIVATE_END \
QT_WARNING_POP
#if QT_VERSION >= QT_VERSION_CHECK( 5, 7, 0 )
#if defined( QSK_BUILD )
#define qskAsConst qAsConst
#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 )
using QskHashValue = uint;
#else
template< typename T >
struct QskAddConst { typedef const T Type; };
template< typename T >
constexpr typename QskAddConst< T >::Type& qskAsConst( T& t ) noexcept { return t; }
template< typename T >
void qskAsConst( const T&& ) = delete;
#endif
#ifdef Q_FALLTHROUGH
#define QSK_FALLTHROUGH Q_FALLTHROUGH
#else
#define QSK_FALLTHROUGH
using QskHashValue = size_t;
#endif
#endif

View File

@ -70,7 +70,7 @@ static inline bool qskIsVisible( const QskGradientStops& stops )
const auto& c = stop.color();
if ( c.isValid() && c.alpha() > 0 )
return true;
}
}
return false;
}
@ -179,6 +179,17 @@ static inline QskGradientStops qskExtractedStops(
return extracted;
}
static inline QskGradientStops qskGradientStops( const QGradientStops& qtStops )
{
QskGradientStops stops;
stops.reserve( qtStops.count() );
for ( const auto& s : qtStops )
stops += QskGradientStop( s.first, s.second );
return stops;
}
QskGradient::QskGradient( Orientation orientation )
: m_orientation( orientation )
, m_isDirty( false )
@ -218,6 +229,16 @@ QskGradient::QskGradient( Orientation orientation, const QskGradientStops& stops
setStops( stops );
}
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset )
: QskGradient( orientation )
{
setStops( qskGradientStops( QGradient( preset ).stops() ) );
}
#endif
QskGradient::~QskGradient()
{
}
@ -301,8 +322,17 @@ void QskGradient::setStops( const QskGradientStops& stops )
m_isDirty = true;
}
QskGradientStops QskGradient::stops() const
const QskGradientStops& QskGradient::stops() const
{
#if 1
/*
Returning a const& so that it is possible to write:
for ( const auto& stop : qAsConst( gradient.stops() ) )
Once we have changed QskGradientStop from QColor to QRgb
we should check if there is a better solution possible
*/
#endif
return m_stops;
}
@ -387,14 +417,14 @@ bool QskGradient::hasStopAt( qreal value ) const
return false;
}
uint QskGradient::hash( uint seed ) const
QskHashValue QskGradient::hash( QskHashValue seed ) const
{
if ( m_stops.isEmpty() )
return seed;
const auto o = orientation();
uint hash = qHashBits( &o, sizeof( o ), seed );
auto hash = qHashBits( &o, sizeof( o ), seed );
for ( const auto& stop : m_stops )
hash = stop.hash( hash );

View File

@ -9,7 +9,7 @@
#include "QskGlobal.h"
#include "QskGradientStop.h"
#include <qcolor.h>
#include <qbrush.h>
#include <qmetatype.h>
#include <qvector.h>
@ -49,12 +49,18 @@ class QSK_EXPORT QskGradient
QskGradient( QRgb );
QskGradient( const QColor& );
QskGradient( Qt::Orientation, const QVector< QskGradientStop >& );
QskGradient( Qt::Orientation, const QColor&, const QColor& );
QskGradient( Orientation, const QVector< QskGradientStop >& );
QskGradient( Orientation, const QColor&, const QColor& );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
QskGradient( QGradient::Preset );
QskGradient( Orientation, QGradient::Preset );
#endif
~QskGradient();
void setOrientation( Qt::Orientation );
@ -74,7 +80,7 @@ class QSK_EXPORT QskGradient
Q_INVOKABLE QColor endColor() const;
Q_INVOKABLE void setStops( const QVector< QskGradientStop >& );
Q_INVOKABLE QVector< QskGradientStop > stops() const;
Q_INVOKABLE const QVector< QskGradientStop >& stops() const;
Q_INVOKABLE bool hasStopAt( qreal value ) const;
@ -94,7 +100,7 @@ class QSK_EXPORT QskGradient
static QVariant interpolate( const QskGradient&,
const QskGradient&, qreal progress );
uint hash( uint seed ) const;
QskHashValue hash( QskHashValue seed ) const;
Q_INVOKABLE qreal stopAt( int index ) const;
Q_INVOKABLE QColor colorAt( int index ) const;
@ -133,6 +139,15 @@ inline QskGradient::QskGradient( QRgb rgb )
{
}
#if QT_VERSION >= QT_VERSION_CHECK( 5, 12, 0 )
inline QskGradient::QskGradient( QGradient::Preset preset )
: QskGradient( Vertical, preset )
{
}
#endif
inline QskGradient::Orientation QskGradient::orientation() const
{
return static_cast< Orientation >( m_orientation );

View File

@ -44,9 +44,9 @@ void QskGradientStop::setStop( qreal position, const QColor& color ) noexcept
m_color = color;
}
uint QskGradientStop::hash( uint seed ) const noexcept
QskHashValue QskGradientStop::hash( QskHashValue seed ) const noexcept
{
uint hash = qHashBits( &m_position, sizeof( m_position ), seed );
auto hash = qHashBits( &m_position, sizeof( m_position ), seed );
return qHashBits( &m_color, sizeof( m_color ), hash );
}

View File

@ -11,13 +11,6 @@
#include <qcolor.h>
#include <qmetatype.h>
#if QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 )
/*
since Qt >= 5.14 QColor has constexpr declarations and we could declare
several methods of QskGradientStop being constexpr as well. TODO ...
*/
#endif
class QSK_EXPORT QskGradientStop
{
Q_GADGET
@ -47,7 +40,7 @@ class QSK_EXPORT QskGradientStop
static QColor interpolated(
const QskGradientStop&, const QskGradientStop&, qreal position ) noexcept;
uint hash( uint seed ) const noexcept;
QskHashValue hash( QskHashValue seed ) const noexcept;
private:
qreal m_position;

View File

@ -70,7 +70,7 @@ namespace
int maximum;
};
class CounterData final : public QObject
class CounterData
{
public:
Counter counter[ 2 ];
@ -162,7 +162,7 @@ void CounterHook::addObject( QObject* object )
{
const bool isItem = qskIsItem( object );
for ( auto counterData : qskAsConst( m_counterDataSet ) )
for ( auto counterData : qAsConst( m_counterDataSet ) )
{
counterData->counter[ QskObjectCounter::Objects ].increment();
@ -182,7 +182,7 @@ void CounterHook::removeObject( QObject* object )
{
const bool isItem = qskIsItem( object );
for ( auto counterData : qskAsConst( m_counterDataSet ) )
for ( auto counterData : qAsConst( m_counterDataSet ) )
{
counterData->counter[ QskObjectCounter::Objects ].decrement();

View File

@ -37,6 +37,8 @@ class QSK_EXPORT QskObjectCounter
void dump() const;
private:
Q_DISABLE_COPY( QskObjectCounter )
class PrivateData;
std::unique_ptr< PrivateData > m_data;

View File

@ -63,7 +63,7 @@ void QskScaleTickmarks::invert()
std::reverse( m_ticks[ 2 ].begin(), m_ticks[ 2 ].end() );
}
uint QskScaleTickmarks::hash( uint seed ) const
QskHashValue QskScaleTickmarks::hash( QskHashValue seed ) const noexcept
{
seed = qHash( m_ticks[0], seed );
seed = qHash( m_ticks[1], seed );

View File

@ -53,7 +53,7 @@ class QSK_EXPORT QskScaleTickmarks
void invert();
void reset();
uint hash( uint seed = 0 ) const;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
private:
QVector< qreal > m_ticks[ 3 ];

View File

@ -83,9 +83,9 @@ QRectF QskShadowMetrics::shadowRect( const QRectF& sourceRect ) const
sourceRect.height() + 2 * extent );
}
uint QskShadowMetrics::hash( uint seed ) const noexcept
QskHashValue QskShadowMetrics::hash( QskHashValue seed ) const noexcept
{
uint hash;
QskHashValue hash;
hash = qHash( m_offset.x(), seed );
hash = qHash( m_offset.y(), seed );

View File

@ -56,7 +56,7 @@ class QSK_EXPORT QskShadowMetrics
QRectF shadowRect( const QRectF& sourceRect ) const;
uint hash( uint seed = 0 ) const noexcept;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
static QVariant interpolate( const QskShadowMetrics&,
const QskShadowMetrics&, qreal progress );

View File

@ -9,7 +9,7 @@
#include <qhashfunctions.h>
#include <qvariant.h>
uint QskTextColors::hash( uint seed ) const
QskHashValue QskTextColors::hash( QskHashValue seed ) const noexcept
{
const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() };
return qHashBits( rgb, sizeof( rgb ), seed );

View File

@ -25,7 +25,7 @@ class QSK_EXPORT QskTextColors
static QVariant interpolate( const QskTextColors&,
const QskTextColors&, qreal ratio );
uint hash( uint seed = 0 ) const;
QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
QColor textColor;
QColor styleColor;

View File

@ -50,15 +50,13 @@ QskTextOptions::TextFormat QskTextOptions::effectiveFormat( const QString& text
return m_format;
}
uint qHash( const QskTextOptions& options, uint seed ) noexcept
QskHashValue QskTextOptions::hash( QskHashValue seed ) const noexcept
{
uint hash;
hash = qHash( options.maximumLineCount(), seed );
hash = qHash( options.fontSizeMode(), hash );
hash = qHash( options.wrapMode(), hash );
hash = qHash( options.format(), hash );
hash = qHash( options.elideMode(), hash );
auto hash = qHash( m_maximumLineCount, seed );
hash = qHash( m_fontSizeMode, hash );
hash = qHash( m_wrapMode, hash );
hash = qHash( m_format, hash );
hash = qHash( m_elideMode, hash );
return hash;
}

View File

@ -74,6 +74,8 @@ class QSK_EXPORT QskTextOptions
constexpr bool operator==( const QskTextOptions& other ) const noexcept;
constexpr bool operator!=( const QskTextOptions& other ) const noexcept;
QskHashValue hash( QskHashValue seed ) const noexcept;
int textFlags() const noexcept;
private:
@ -164,8 +166,6 @@ inline constexpr bool QskTextOptions::operator!=(
return !( *this == other );
}
QSK_EXPORT uint qHash( const QskTextOptions&, uint seed = 0 ) noexcept;
#ifndef QT_NO_DEBUG_STREAM
class QDebug;

View File

@ -1,2 +0,0 @@
TEMPLATE = subdirs
SUBDIRS = ../

View File

@ -181,13 +181,15 @@ void QskBoundedInput::keyPressEvent( QKeyEvent* event )
{
if ( !isReadOnly() )
{
if ( event->key() == Qt::Key_Up || event->matches( QKeySequence::MoveToNextChar ) )
if ( event->key() == Qt::Key_Up ||
qskIsStandardKeyInput( event, QKeySequence::MoveToNextChar ) )
{
increment( m_stepSize );
return;
}
if ( event->key() == Qt::Key_Down || event->matches( QKeySequence::MoveToPreviousChar ) )
if ( event->key() == Qt::Key_Down ||
qskIsStandardKeyInput( event, QKeySequence::MoveToPreviousChar ) )
{
increment( -m_stepSize );
return;

View File

@ -92,7 +92,7 @@ qreal qskWheelSteps( const QWheelEvent* event )
const auto angleDelta = event->angleDelta();
const qreal delta = angleDelta.y() ? angleDelta.y() : angleDelta.x();
return delta / QWheelEvent::DefaultDeltasPerStep;
return delta / QWheelEvent::DefaultDeltasPerStep;
}
qreal qskWheelIncrement( const QWheelEvent* event )
@ -111,11 +111,26 @@ qreal qskWheelIncrement( const QWheelEvent* event )
#endif
const qreal delta = angleDelta.y() ? angleDelta.y() : angleDelta.x();
return delta / QWheelEvent::DefaultDeltasPerStep;
return delta / QWheelEvent::DefaultDeltasPerStep;
}
#endif
bool qskIsStandardKeyInput( const QKeyEvent* event, QKeySequence::StandardKey key )
{
#if 1
return event->matches( key );
#else
constexpr auto mask = ~( Qt::KeypadModifier | Qt::GroupSwitchModifier );
// We should route this call through the skin. TODO
const auto theme = QGuiApplicationPrivate::platformTheme();
const auto bindings = theme->keyBindings( ( event->modifiers() | event->key() ) & mask );
return bindings.contains( QKeySequence(searchkey) );
#endif
}
QskEvent::QskEvent( QskEvent::Type type )
: QEvent( static_cast< QEvent::Type >( type ) )
{

View File

@ -10,6 +10,7 @@
#include <qcoreevent.h>
#include <qrect.h>
#include <qkeysequence.h>
#include <memory>
class QskGesture;
@ -20,6 +21,7 @@ class QQuickItem;
class QMouseEvent;
class QWheelEvent;
class QHoverEvent;
class QKeyEvent;
class QSK_EXPORT QskEvent : public QEvent
{
@ -148,4 +150,6 @@ QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* );
#endif
QSK_EXPORT bool qskIsStandardKeyInput( const QKeyEvent*, QKeySequence::StandardKey );
#endif

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_FLICK_ANIMATOR_H
#define QSK_FLICK_ANIMATOR_H 1
#define QSK_FLICK_ANIMATOR_H
#include "QskAnimator.h"

View File

@ -49,7 +49,7 @@ class QskFocusIndicator::PrivateData
public:
void resetConnections()
{
for ( const auto& connection : qskAsConst( connections ) )
for ( const auto& connection : qAsConst( connections ) )
QObject::disconnect( connection );
connections.clear();

View File

@ -52,6 +52,8 @@ class QSK_EXPORT QskGesture
inline State state() const { return m_state; }
protected:
Q_DISABLE_COPY( QskGesture )
QskGesture( Type type );
const Type m_type;

View File

@ -11,13 +11,15 @@
#include <qvector.h>
QSK_QT_PRIVATE_BEGIN
#include <private/qquickwindow_p.h>
QSK_QT_PRIVATE_END
#if QT_VERSION >= QT_VERSION_CHECK( 6, 3, 0 )
#include <private/qeventpoint_p.h>
#endif
QSK_QT_PRIVATE_END
static QMouseEvent* qskClonedMouseEventAt(
const QMouseEvent* event, QPointF* localPos )
{
@ -130,7 +132,7 @@ namespace
{
Timer* timer = nullptr;
for ( auto t : qskAsConst( m_table ) )
for ( auto t : qAsConst( m_table ) )
{
if ( t->recognizer() == nullptr ||
t->recognizer() == recognizer )
@ -151,7 +153,7 @@ namespace
void stopTimer( const QskGestureRecognizer* recognizer )
{
for ( auto timer : qskAsConst( m_table ) )
for ( auto timer : qAsConst( m_table ) )
{
if ( timer->recognizer() == recognizer )
{

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_INPUT_GRABBER_H
#define QSK_INPUT_GRABBER_H 1
#define QSK_INPUT_GRABBER_H
#include "QskControl.h"

View File

@ -8,10 +8,8 @@
#include "QskColorFilter.h"
#include "QskEvent.h"
#if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 )
#include <qguiapplication.h>
#include <qstylehints.h>
#endif
#include <qmath.h>
@ -198,11 +196,13 @@ void QskListView::keyPressEvent( QKeyEvent* event )
case Qt::Key_PageDown:
{
// TODO ...
return Inherited::keyPressEvent( event );
Inherited::keyPressEvent( event );
return;
}
default:
{
return Inherited::keyPressEvent( event );
Inherited::keyPressEvent( event );
return;
}
}

View File

@ -108,13 +108,19 @@ QPointF QskMenu::origin() const
void QskMenu::addOption( const QUrl& graphicSource, const QString& text )
{
#if 0
// does not work with Qt 5.6 version of QVector. TODO ...
m_data->options += Option( graphicSource, text );
#else
Q_UNUSED( graphicSource )
Q_UNUSED( text )
#endif
resetImplicitSize();
update();
if ( isComponentComplete() )
countChanged( count() );
Q_EMIT countChanged( count() );
}
void QskMenu::addOption( const QString& graphicSource, const QString& text )
@ -278,14 +284,14 @@ void QskMenu::traverse( int steps )
if ( hasAnimationHint( Cursor | QskAspect::Position | QskAspect::Metric ) )
{
// when cycling we want slide in
// when cycling we want slide in
if ( index < 0 )
setPositionHint( Cursor, count() );
if ( index >= count() )
setPositionHint( Cursor, -1 );
movePositionHint( Cursor, newIndex );
}
@ -308,7 +314,7 @@ void QskMenu::mousePressEvent( QMouseEvent* event )
return;
}
return Inherited::mousePressEvent( event );
Inherited::mousePressEvent( event );
}
void QskMenu::mouseReleaseEvent( QMouseEvent* event )
@ -327,7 +333,7 @@ void QskMenu::mouseReleaseEvent( QMouseEvent* event )
return;
}
return Inherited::mouseReleaseEvent( event );
Inherited::mouseReleaseEvent( event );
}
void QskMenu::aboutToShow()

View File

@ -52,7 +52,8 @@ class QskMenuSkinlet::PrivateData
{
m_data->enableCache( false );
}
private:
private:
PrivateData* m_data;
};
@ -168,7 +169,7 @@ class QskMenuSkinlet::PrivateData
const auto sample = skinlet->sampleAt( menu, QskMenu::Text, i );
if ( sample.canConvert< QString >() )
{
const auto text = sample.value< QString >();
const auto text = sample.toString();
if( !text.isEmpty() )
{
const auto w = qskHorizontalAdvance( fm, text );

View File

@ -21,6 +21,8 @@ QObjectList QskObjectTree::childNodes( const QObject* object )
if ( object == nullptr )
{
const auto windows = QGuiApplication::topLevelWindows();
children.reserve( windows.count() );
for ( auto window : windows )
children += window;
}
@ -43,6 +45,7 @@ QObjectList QskObjectTree::childNodes( const QObject* object )
else if ( auto item = qobject_cast< const QQuickItem* >( object ) )
{
const auto childItems = item->childItems();
children.reserve( childItems.count() );
for ( auto child : childItems )
children += child;

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_OBJECT_TREE_H
#define QSK_OBJECT_TREE_H 1
#define QSK_OBJECT_TREE_H
#include "QskControl.h"
#include "QskWindow.h"
@ -16,10 +16,14 @@ namespace QskObjectTree
class Visitor
{
public:
Visitor() = default;
virtual ~Visitor() = default;
virtual bool visitDown( QObject* object ) = 0;
virtual bool visitUp( const QObject* object ) = 0;
private:
Q_DISABLE_COPY( Visitor )
};
QSK_EXPORT QObjectList childNodes( const QObject* );

View File

@ -15,10 +15,10 @@ QSK_SYSTEM_STATE( QskPageIndicator, Selected, QskAspect::FirstSystemState << 1 )
static int qskKeyIncrement(
const QskPageIndicator* indicator, const QKeyEvent* event )
{
if ( event->matches( QKeySequence::MoveToNextChar ) )
if ( qskIsStandardKeyInput( event, QKeySequence::MoveToNextChar ) )
return 1;
if ( event->matches( QKeySequence::MoveToPreviousChar ) )
if ( qskIsStandardKeyInput( event, QKeySequence::MoveToPreviousChar ) )
return -1;
const auto key = event->key();
@ -29,10 +29,10 @@ static int qskKeyIncrement(
if ( key == Qt::Key_Left )
return mirrored ? 1 : -1;
if ( key == Qt::Key_Right )
return mirrored ? -1 : 1;
}
}
else
{
if ( key == Qt::Key_Up )
@ -40,10 +40,10 @@ static int qskKeyIncrement(
if ( key == Qt::Key_Down )
return 1;
}
}
return 0;
}
}
class QskPageIndicator::PrivateData
@ -145,8 +145,8 @@ qreal QskPageIndicator::valueRatioAt( int index ) const
const qreal diff = 1.0 - std::abs( pos - index );
return std::max( diff, 0.0 );
}
}
return 0.0;
}
@ -184,7 +184,7 @@ void QskPageIndicator::mousePressEvent( QMouseEvent* event )
return;
}
return Inherited::mousePressEvent( event );
Inherited::mousePressEvent( event );
}
void QskPageIndicator::mouseUngrabEvent()
@ -205,11 +205,11 @@ void QskPageIndicator::mouseReleaseEvent( QMouseEvent* event )
if ( indexAtPosition( pos ) == index )
Q_EMIT pageRequested( index );
}
return;
}
return Inherited::mouseReleaseEvent( event );
Inherited::mouseReleaseEvent( event );
}
void QskPageIndicator::keyPressEvent( QKeyEvent* event )

View File

@ -10,15 +10,6 @@
#include "QskSGNode.h"
#include "QskFunctions.h"
static inline int qskCurrentIndex( const QskPageIndicator* indicator )
{
int index = qRound( indicator->currentIndex() );
if ( index >= indicator->count() )
index = 0;
return index;
}
static QRectF qskBulletRect( const QskPageIndicator* indicator,
const QRectF& rect, int index )
{
@ -44,7 +35,7 @@ static QRectF qskBulletRect( const QskPageIndicator* indicator,
{
const auto maxWidth = n * size.width() + ( n - 1 ) * spacing;
const auto r = qskAlignedRectF( rect, maxWidth, size.height(), alignment );
x = r.x() + index * ( size.width() + spacing );
y = r.y();
}
@ -52,7 +43,7 @@ static QRectF qskBulletRect( const QskPageIndicator* indicator,
{
const auto maxHeight = n * size.height() + ( n - 1 ) * spacing;
const auto r = qskAlignedRectF( rect, maxHeight, size.height(), alignment );
x = r.x();
y = r.y() + index * ( size.height() + spacing );;
}

View File

@ -382,7 +382,7 @@ bool QskPopup::hasFaderEffect() const
void QskPopup::setPopupFlags( PopupFlags flags )
{
if ( static_cast<int>(flags) != m_data->flags )
if ( static_cast< int >( flags ) != m_data->flags )
{
m_data->flags = flags;
updateInputGrabber();
@ -654,7 +654,7 @@ int QskPopup::execPopup()
if ( popup->isOpen() || popup->isFading() )
return;
}
QEventLoop::exit( 0 );
}
};
@ -679,10 +679,10 @@ int QskPopup::execPopup()
}
if ( auto mouseGrabber = window()->mouseGrabberItem() )
{
{
// when being called from QQuickWindow::mouseReleaseEvent
// the mouse grabber has not yet been released.
if( !qskIsAncestorOf( this, mouseGrabber ) )
qskUngrabMouse( mouseGrabber );
}

View File

@ -649,7 +649,7 @@ void qskItemUpdateRecursive( QQuickItem* item )
static const QQuickPointerTouchEvent* qskPointerPressEvent( const QQuickWindowPrivate* wd )
{
for ( const auto event : wd->pointerEventInstances )
for ( const auto event : qAsConst( wd->pointerEventInstances ) )
{
if ( auto touchEvent = event->asPointerTouchEvent() )
{

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_QUICK_H
#define QSK_QUICK_H 1
#define QSK_QUICK_H
#include "QskGlobal.h"
#include <qnamespace.h>

View File

@ -15,16 +15,21 @@
#include <qquickwindow.h>
#if defined( QT_DEBUG )
QSK_QT_PRIVATE_BEGIN
#if QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 )
#ifndef emit
// qvariantanimation_p.h needs it
#define emit
#include <private/qabstractanimation_p.h>
#undef emit
#endif
#endif
#include <private/qquickpositioners_p.h>
QSK_QT_PRIVATE_END
#endif
#include <unordered_set>
@ -65,6 +70,10 @@ namespace
QObject::connect( qskSetup, &QskSetup::itemUpdateFlagsChanged,
qskSetup, [ this ] { updateControlFlags(); } );
/*
We would also need to send QEvent::StyleChange, when
a window has a new skin. TODO ...
*/
QObject::connect( qskSetup, &QskSetup::skinChanged,
qskSetup, [ this ] { updateSkin(); } );
}
@ -200,9 +209,9 @@ void QskQuickItem::classBegin()
void QskQuickItem::componentComplete()
{
#if defined( QT_DEBUG )
if ( qobject_cast< const QQuickBasePositioner* >( parent() ) )
if ( d_func()->updateFlags & QskQuickItem::DeferredLayout )
{
if ( d_func()->updateFlags & QskQuickItem::DeferredLayout )
if ( qobject_cast< const QQuickBasePositioner* >( parent() ) )
{
qWarning( "QskQuickItem in DeferredLayout mode under control of a positioner" );
}

View File

@ -173,7 +173,7 @@ void QskShortcutHandler::remove( int id )
Finally let's check if we can disconnect
from the destroyed signals
*/
for ( const auto& entry : qskAsConst( m_invokeDataMap ) )
for ( const auto& entry : qAsConst( m_invokeDataMap ) )
{
if ( item == nullptr && receiver == nullptr )
break;
@ -276,7 +276,7 @@ bool QskShortcutHandler::invoke( QQuickItem* item, const QKeySequence& sequence
{
bool found = false;
for ( const auto& entry : qskAsConst( m_invokeDataMap ) )
for ( const auto& entry : qAsConst( m_invokeDataMap ) )
{
auto& data = entry.second;

View File

@ -321,6 +321,20 @@ bool QskSkin::hasGraphicProvider() const
return m_data->graphicProviders.size() > 0;
}
QString QskSkin::dialogButtonText( int action ) const
{
const auto theme = QGuiApplicationPrivate::platformTheme();
auto text = theme->standardButtonText( action );
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
text.remove( '&' );
#else
text = QPlatformTheme::removeMnemonics( text );
#endif
return text;
}
const int* QskSkin::dialogButtonLayout( Qt::Orientation orientation ) const
{
// auto policy = QPlatformDialogHelper::UnknownLayout;

View File

@ -75,6 +75,7 @@ class QSK_EXPORT QskSkin : public QObject
bool hasGraphicProvider() const;
virtual const int* dialogButtonLayout( Qt::Orientation ) const;
virtual QString dialogButtonText( int button ) const;
void setStateMask( QskAspect::States );
QskAspect::States stateMask() const;

View File

@ -244,10 +244,10 @@ void QskSkinHintTableEditor::setPosition(
setMetricHint( aspectPosition( aspect ), position, combination );
}
void QskSkinHintTableEditor::removePosition(
bool QskSkinHintTableEditor::removePosition(
QskAspect aspect, QskStateCombination combination )
{
removeMetricHint( aspectPosition( aspect ), combination );
return removeMetricHint( aspectPosition( aspect ), combination );
}
qreal QskSkinHintTableEditor::position( QskAspect aspect ) const
@ -268,10 +268,10 @@ void QskSkinHintTableEditor::setStrutSize(
QSizeF( width, height ), combination );
}
void QskSkinHintTableEditor::removeStrutSize(
bool QskSkinHintTableEditor::removeStrutSize(
QskAspect aspect, QskStateCombination combination )
{
removeMetricHint( aspectStrutSize( aspect ), combination );
return removeMetricHint( aspectStrutSize( aspect ), combination );
}
QSizeF QskSkinHintTableEditor::strutSize( QskAspect aspect ) const
@ -293,10 +293,10 @@ void QskSkinHintTableEditor::setMargin( QskAspect aspect,
setMetricHint( aspectMargin( aspect ), margins, combination );
}
void QskSkinHintTableEditor::removeMargin(
bool QskSkinHintTableEditor::removeMargin(
QskAspect aspect, QskStateCombination combination )
{
removeMetricHint( aspectMargin( aspect ), combination );
return removeMetricHint( aspectMargin( aspect ), combination );
}
QskMargins QskSkinHintTableEditor::margin( QskAspect aspect ) const
@ -319,10 +319,10 @@ void QskSkinHintTableEditor::setPadding( QskAspect aspect,
setMetricHint( aspectPadding( aspect ), padding, combination );
}
void QskSkinHintTableEditor::removePadding(
bool QskSkinHintTableEditor::removePadding(
QskAspect aspect, QskStateCombination combination )
{
removeMetricHint( aspectPadding( aspect ), combination );
return removeMetricHint( aspectPadding( aspect ), combination );
}
QskMargins QskSkinHintTableEditor::padding( QskAspect aspect ) const
@ -336,10 +336,10 @@ void QskSkinHintTableEditor::setSpacing(
setMetricHint( aspectSpacing( aspect ), spacing, combination );
}
void QskSkinHintTableEditor::removeSpacing(
bool QskSkinHintTableEditor::removeSpacing(
QskAspect aspect, QskStateCombination combination )
{
removeMetricHint( aspectSpacing( aspect ), combination );
return removeMetricHint( aspectSpacing( aspect ), combination );
}
qreal QskSkinHintTableEditor::spacing( QskAspect aspect ) const
@ -354,7 +354,7 @@ void QskSkinHintTableEditor::setAlignment(
static_cast< int >( alignment ), combination );
}
void QskSkinHintTableEditor::removeAlignment(
bool QskSkinHintTableEditor::removeAlignment(
QskAspect aspect, QskStateCombination combination )
{
return removeFlagHint( aspectAlignment( aspect ), combination );
@ -371,7 +371,7 @@ void QskSkinHintTableEditor::setFontRole(
setFlagHint( aspectFontRole( aspect ), fontRole, combination );
}
void QskSkinHintTableEditor::removeFontRole(
bool QskSkinHintTableEditor::removeFontRole(
QskAspect aspect, QskStateCombination combination )
{
return removeFlagHint( aspectFontRole( aspect ), combination );
@ -388,7 +388,7 @@ void QskSkinHintTableEditor::setGraphicRole(
setFlagHint( aspectGraphicRole( aspect ), graphicRole, combination );
}
void QskSkinHintTableEditor::removeGraphicRole(
bool QskSkinHintTableEditor::removeGraphicRole(
QskAspect aspect, QskStateCombination combination )
{
return removeFlagHint( aspectGraphicRole( aspect ), combination );
@ -421,7 +421,7 @@ void QskSkinHintTableEditor::setBoxShape(
setMetricHint( aspectShape( aspect ), shape, combination );
}
void QskSkinHintTableEditor::removeBoxShape(
bool QskSkinHintTableEditor::removeBoxShape(
QskAspect aspect, QskStateCombination combination )
{
return removeMetricHint( aspectShape( aspect ), combination );
@ -453,7 +453,7 @@ void QskSkinHintTableEditor::setBoxBorderMetrics(
setMetricHint( aspectBorder( aspect ), borderMetrics, combination );
}
void QskSkinHintTableEditor::removeBoxBorderMetric(
bool QskSkinHintTableEditor::removeBoxBorderMetric(
QskAspect aspect, QskStateCombination combination )
{
return removeMetricHint( aspectBorder( aspect ), combination );
@ -480,7 +480,7 @@ void QskSkinHintTableEditor::setBoxBorderColors(QskAspect aspect,
combination );
}
void QskSkinHintTableEditor::removeBoxBorderColors(
bool QskSkinHintTableEditor::removeBoxBorderColors(
QskAspect aspect, QskStateCombination combination )
{
return removeColorHint( aspectBorder( aspect ), combination );
@ -504,7 +504,7 @@ void QskSkinHintTableEditor::setArcMetrics( QskAspect aspect,
setMetricHint( aspectShape( aspect ), arcMetrics, combination );
}
void QskSkinHintTableEditor::removeArcMetrics( QskAspect aspect,
bool QskSkinHintTableEditor::removeArcMetrics( QskAspect aspect,
QskStateCombination combination )
{
return removeMetricHint( aspectShape( aspect ), combination );

View File

@ -63,7 +63,7 @@ class QSK_EXPORT QskSkinHintTableEditor
template< typename T > void setFlagHint( QskAspect, const T&,
QskStateCombination = QskStateCombination() );
void removeFlagHint( QskAspect, QskStateCombination = QskStateCombination() );
bool removeFlagHint( QskAspect, QskStateCombination = QskStateCombination() );
QVariant flagHint( QskAspect ) const;
template< typename T > T flagHint( QskAspect ) const;
@ -76,7 +76,7 @@ class QSK_EXPORT QskSkinHintTableEditor
template< typename T > void setMetricHint(
QskAspect, const T&, QskStateCombination = QskStateCombination() );
void removeMetricHint( QskAspect, QskStateCombination = QskStateCombination() );
bool removeMetricHint( QskAspect, QskStateCombination = QskStateCombination() );
QVariant metricHint( QskAspect ) const;
template< typename T > T metricHint( QskAspect ) const;
@ -89,7 +89,7 @@ class QSK_EXPORT QskSkinHintTableEditor
template< typename T > void setColorHint(
QskAspect, const T&, QskStateCombination = QskStateCombination() );
void removeColorHint( QskAspect, QskStateCombination = QskStateCombination() );
bool removeColorHint( QskAspect, QskStateCombination = QskStateCombination() );
QVariant colorHint( QskAspect ) const;
template< typename T > T colorHint( QskAspect ) const;
@ -126,7 +126,7 @@ class QSK_EXPORT QskSkinHintTableEditor
void setPosition( QskAspect, qreal,
QskStateCombination = QskStateCombination() );
void removePosition( QskAspect, QskStateCombination = QskStateCombination() );
bool removePosition( QskAspect, QskStateCombination = QskStateCombination() );
qreal position( QskAspect ) const;
@ -138,7 +138,7 @@ class QSK_EXPORT QskSkinHintTableEditor
void setStrutSize( QskAspect, qreal width, qreal height,
QskStateCombination = QskStateCombination() );
void removeStrutSize( QskAspect, QskStateCombination = QskStateCombination() );
bool removeStrutSize( QskAspect, QskStateCombination = QskStateCombination() );
QSizeF strutSize( QskAspect ) const;
@ -151,7 +151,7 @@ class QSK_EXPORT QskSkinHintTableEditor
qreal left, qreal top, qreal right, qreal bottom,
QskStateCombination = QskStateCombination() );
void removeMargin( QskAspect, QskStateCombination = QskStateCombination() );
bool removeMargin( QskAspect, QskStateCombination = QskStateCombination() );
QskMargins margin( QskAspect ) const;
@ -164,32 +164,32 @@ class QSK_EXPORT QskSkinHintTableEditor
qreal left, qreal top, qreal right, qreal bottom,
QskStateCombination = QskStateCombination() );
void removePadding( QskAspect, QskStateCombination = QskStateCombination() );
bool removePadding( QskAspect, QskStateCombination = QskStateCombination() );
QskMargins padding( QskAspect ) const;
// spacing
void setSpacing( QskAspect, qreal, QskStateCombination = QskStateCombination() );
void removeSpacing( QskAspect, QskStateCombination = QskStateCombination() );
bool removeSpacing( QskAspect, QskStateCombination = QskStateCombination() );
qreal spacing( QskAspect ) const;
// alignment
void setAlignment( QskAspect, Qt::Alignment, QskStateCombination = QskStateCombination() );
void removeAlignment( QskAspect, QskStateCombination = QskStateCombination() );
bool removeAlignment( QskAspect, QskStateCombination = QskStateCombination() );
Qt::Alignment alignment( QskAspect ) const;
// fontRole
void setFontRole( QskAspect, int, QskStateCombination = QskStateCombination() );
void removeFontRole( QskAspect, QskStateCombination = QskStateCombination() );
bool removeFontRole( QskAspect, QskStateCombination = QskStateCombination() );
int fontRole( QskAspect ) const;
// graphicRole
void setGraphicRole( QskAspect, int, QskStateCombination = QskStateCombination() );
void removeGraphicRole( QskAspect, QskStateCombination = QskStateCombination() );
bool removeGraphicRole( QskAspect, QskStateCombination = QskStateCombination() );
int graphicRole( QskAspect ) const;
// boxShape
@ -202,7 +202,7 @@ class QSK_EXPORT QskSkinHintTableEditor
void setBoxShape( QskAspect, const QskBoxShapeMetrics&,
QskStateCombination = QskStateCombination() );
void removeBoxShape( QskAspect, QskStateCombination = QskStateCombination() );
bool removeBoxShape( QskAspect, QskStateCombination = QskStateCombination() );
QskBoxShapeMetrics boxShape( QskAspect ) const;
@ -217,7 +217,7 @@ class QSK_EXPORT QskSkinHintTableEditor
void setBoxBorderMetrics( QskAspect,
const QskBoxBorderMetrics&, QskStateCombination = QskStateCombination() );
void removeBoxBorderMetric( QskAspect, QskStateCombination = QskStateCombination() );
bool removeBoxBorderMetric( QskAspect, QskStateCombination = QskStateCombination() );
QskBoxBorderMetrics boxBorderMetrics( QskAspect ) const;
@ -231,7 +231,7 @@ class QSK_EXPORT QskSkinHintTableEditor
const QskGradient& right, const QskGradient& bottom,
QskStateCombination = QskStateCombination() );
void removeBoxBorderColors( QskAspect, QskStateCombination = QskStateCombination() );
bool removeBoxBorderColors( QskAspect, QskStateCombination = QskStateCombination() );
QskBoxBorderColors boxBorderColors( QskAspect ) const;
// arcMetrics
@ -241,7 +241,7 @@ class QSK_EXPORT QskSkinHintTableEditor
void setArcMetrics( QskAspect,
const QskArcMetrics&, QskStateCombination = QskStateCombination() );
void removeArcMetrics( QskAspect, QskStateCombination = QskStateCombination() );
bool removeArcMetrics( QskAspect, QskStateCombination = QskStateCombination() );
QskArcMetrics arcMetrics( QskAspect ) const;
@ -294,10 +294,10 @@ inline void QskSkinHintTableEditor::setFlagHint(
setHint( aspect | QskAspect::Flag, hint, combination );
}
inline void QskSkinHintTableEditor::removeFlagHint(
inline bool QskSkinHintTableEditor::removeFlagHint(
QskAspect aspect, QskStateCombination combination )
{
removeHint( aspect | QskAspect::Flag, combination );
return removeHint( aspect | QskAspect::Flag, combination );
}
inline QVariant QskSkinHintTableEditor::flagHint( QskAspect aspect ) const
@ -326,10 +326,10 @@ inline void QskSkinHintTableEditor::setMetricHint(
setHint( aspect | QskAspect::Metric, hint, combination );
}
inline void QskSkinHintTableEditor::removeMetricHint(
inline bool QskSkinHintTableEditor::removeMetricHint(
QskAspect aspect, QskStateCombination combination )
{
removeHint( aspect | QskAspect::Metric, combination );
return removeHint( aspect | QskAspect::Metric, combination );
}
inline QVariant QskSkinHintTableEditor::metricHint( QskAspect aspect ) const
@ -358,10 +358,10 @@ inline void QskSkinHintTableEditor::setColorHint(
setHint( aspect | QskAspect::Color, hint, combination );
}
inline void QskSkinHintTableEditor::removeColorHint(
inline bool QskSkinHintTableEditor::removeColorHint(
QskAspect aspect, QskStateCombination combination )
{
removeHint( aspect | QskAspect::Color, combination );
return removeHint( aspect | QskAspect::Color, combination );
}
inline QVariant QskSkinHintTableEditor::colorHint( QskAspect aspect ) const

View File

@ -292,7 +292,7 @@ namespace
m_skinMap.clear();
// first we try all factories, that have been added manually
for ( auto it = m_factoryMap.begin(); it != m_factoryMap.end(); ++it )
for ( auto it = m_factoryMap.constBegin(); it != m_factoryMap.constEnd(); ++it )
{
const auto& data = it.value();
@ -301,7 +301,7 @@ namespace
}
// all factories from plugins are following
for ( auto it = m_factoryMap.begin(); it != m_factoryMap.end(); ++it )
for ( auto it = m_factoryMap.constBegin(); it != m_factoryMap.constEnd(); ++it )
{
const auto& data = it.value();
if ( data.loader )
@ -341,7 +341,7 @@ class QskSkinManager::PrivateData
{
if ( !pluginsRegistered )
{
for ( const auto& path : qskAsConst( pluginPaths ) )
for ( const auto& path : qAsConst( pluginPaths ) )
registerPlugins( path + QStringLiteral( "/skins" ) );
pluginsRegistered = true;

View File

@ -1,7 +1,13 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskSkinTransition.h"
#include "QskColorFilter.h"
#include "QskControl.h"
#include "QskWindow.h"
#include "QskAnimationHint.h"
#include "QskHintAnimator.h"
#include "QskSkin.h"
#include "QskSkinHintTable.h"
@ -39,7 +45,8 @@ namespace
public:
AnimatorCandidate() = default;
inline AnimatorCandidate( QskAspect aspect, QVariant from, QVariant to )
inline AnimatorCandidate( QskAspect aspect,
const QVariant& from, const QVariant& to )
: aspect( aspect )
, from( from )
, to( to )
@ -518,10 +525,17 @@ namespace
Q_GLOBAL_STATIC( AnimatorGroups, qskSkinAnimator )
QskSkinTransition::QskSkinTransition()
: m_mask( QskSkinTransition::AllTypes )
class QskSkinTransition::PrivateData
{
public:
QskSkin* skins[ 2 ] = {};
QskAnimationHint animationHint;
Type mask = QskSkinTransition::AllTypes;
};
QskSkinTransition::QskSkinTransition()
: m_data( new PrivateData() )
{
m_skins[ 0 ] = m_skins[ 1 ] = nullptr;
}
QskSkinTransition::~QskSkinTransition()
@ -530,42 +544,42 @@ QskSkinTransition::~QskSkinTransition()
void QskSkinTransition::setMask( Type type )
{
m_mask = type;
m_data->mask = type;
}
QskSkinTransition::Type QskSkinTransition::mask() const
{
return m_mask;
return m_data->mask;
}
void QskSkinTransition::setSourceSkin( QskSkin* skin )
{
m_skins[ 0 ] = skin;
m_data->skins[ 0 ] = skin;
}
QskSkin* QskSkinTransition::sourceSkin() const
{
return m_skins[ 0 ];
return m_data->skins[ 0 ];
}
void QskSkinTransition::setTargetSkin( QskSkin* skin )
{
m_skins[ 1 ] = skin;
m_data->skins[ 1 ] = skin;
}
QskSkin* QskSkinTransition::targetSkin() const
{
return m_skins[ 1 ];
return m_data->skins[ 1 ];
}
void QskSkinTransition::setAnimation( QskAnimationHint animationHint )
{
m_animationHint = animationHint;
m_data->animationHint = animationHint;
}
QskAnimationHint QskSkinTransition::animation() const
{
return m_animationHint;
return m_data->animationHint;
}
void QskSkinTransition::updateSkin( QskSkin*, QskSkin* )
@ -575,7 +589,10 @@ void QskSkinTransition::updateSkin( QskSkin*, QskSkin* )
void QskSkinTransition::process()
{
if ( ( m_skins[ 0 ] == nullptr ) || ( m_skins[ 1 ] == nullptr ) )
auto skinFrom = m_data->skins[ 0 ];
auto skinTo = m_data->skins[ 1 ];
if ( ( skinFrom == nullptr ) || ( skinTo == nullptr ) )
{
// do nothing
return;
@ -583,32 +600,32 @@ void QskSkinTransition::process()
qskSkinAnimator->reset();
if ( ( m_animationHint.duration <= 0 ) || ( m_mask == 0 ) )
if ( ( m_data->animationHint.duration <= 0 ) || ( m_data->mask == 0 ) )
{
// no animations, we can apply the changes
updateSkin( m_skins[ 0 ], m_skins[ 1 ] );
updateSkin( skinFrom, skinTo );
return;
}
QVector< AnimatorCandidate > candidates;
const auto oldFilters = m_skins[ 0 ]->graphicFilters();
const auto oldFilters = skinFrom->graphicFilters();
{
// copy out all hints before updating the skin
// - would be good to have Copy on Write here
const auto oldTable = m_skins[ 0 ]->hintTable();
const auto oldTable = skinFrom->hintTable();
// apply the changes
updateSkin( m_skins[ 0 ], m_skins[ 1 ] );
updateSkin( skinFrom, skinTo );
candidates = qskAnimatorCandidates( m_mask, oldTable, oldFilters,
m_skins[ 1 ]->hintTable(), m_skins[ 1 ]->graphicFilters() );
candidates = qskAnimatorCandidates( m_data->mask, oldTable, oldFilters,
skinTo->hintTable(), skinTo->graphicFilters() );
}
if ( !candidates.isEmpty() )
{
bool doGraphicFilter = m_mask & QskSkinTransition::Color;
bool doGraphicFilter = m_data->mask & QskSkinTransition::Color;
const auto windows = qGuiApp->topLevelWindows();
@ -617,7 +634,7 @@ void QskSkinTransition::process()
if ( auto quickWindow = qobject_cast< QQuickWindow* >( window ) )
{
if ( !quickWindow->isVisible() ||
( qskEffectiveSkin( quickWindow ) != m_skins[ 1 ] ) )
( qskEffectiveSkin( quickWindow ) != skinTo ) )
{
continue;
}
@ -627,8 +644,8 @@ void QskSkinTransition::process()
if ( doGraphicFilter )
{
group->addGraphicFilterAnimators(
m_animationHint, oldFilters,
m_skins[ 1 ]->graphicFilters() );
m_data->animationHint, oldFilters,
skinTo->graphicFilters() );
doGraphicFilter = false;
}
@ -639,7 +656,7 @@ void QskSkinTransition::process()
*/
group->addAnimators( quickWindow->contentItem(),
m_animationHint, candidates, m_skins[ 1 ] );
m_data->animationHint, candidates, skinTo );
qskSkinAnimator->add( group );
}

View File

@ -1,10 +1,11 @@
#ifndef QSK_SKIN_TRANSITION_H
#define QSK_SKIN_TRANSITION_H
#include "QskAnimationHint.h"
#include "QskAspect.h"
#include <memory>
class QskSkin;
class QskAnimationHint;
class QQuickWindow;
class QVariant;
@ -44,9 +45,10 @@ class QSK_EXPORT QskSkinTransition
virtual void updateSkin( QskSkin*, QskSkin* );
private:
QskSkin* m_skins[ 2 ];
QskAnimationHint m_animationHint;
Type m_mask : 2;
Q_DISABLE_COPY( QskSkinTransition )
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif

View File

@ -263,7 +263,7 @@ void QskSkinlet::updateNode( QskSkinnable* skinnable, QSGNode* parentNode ) cons
replaceChildNode( DebugRole, parentNode, oldNode, newNode );
}
for ( const auto nodeRole : m_data->nodeRoles )
for ( const auto nodeRole : qAsConst( m_data->nodeRoles ) )
{
Q_ASSERT( nodeRole < FirstReservedRole );

View File

@ -167,6 +167,8 @@ class QSK_EXPORT QskSkinlet
const QSizeF& hint, const QSizeF& constraint ) const;
private:
Q_DISABLE_COPY( QskSkinlet )
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};

View File

@ -220,8 +220,7 @@ static inline QskAspect qskSubstitutedAspect(
if ( aspect.hasStates() )
{
qWarning() << "QskSkinnable::(re)setSkinHint: setting hints with states "
"is discouraged - use QskSkinTableEditor if you are "
"sure, that you need this.";
"is discouraged - use QskSkinTableEditor if you are sure, that you need this.";
qWarning() << "QskAspect:" << aspect.stateless()
<< skinnable->skinStatesAsPrintable( aspect.states() );
@ -1167,14 +1166,14 @@ bool QskSkinnable::isTransitionAccepted( QskAspect aspect ) const
}
void QskSkinnable::startTransition( QskAspect aspect,
QskAnimationHint animationHint, QVariant from, QVariant to )
QskAnimationHint animationHint, const QVariant& from, const QVariant& to )
{
aspect.setSubControl( effectiveSubcontrol( aspect.subControl() ) );
startHintTransition( aspect, animationHint, from, to );
}
void QskSkinnable::startHintTransition( QskAspect aspect,
QskAnimationHint animationHint, QVariant from, QVariant to )
QskAnimationHint animationHint, const QVariant& from, const QVariant& to )
{
if ( animationHint.duration <= 0 || ( from == to ) )
return;
@ -1189,15 +1188,18 @@ void QskSkinnable::startHintTransition( QskAspect aspect,
to fallback to 0.0 ). In this case we create a default one.
*/
if ( !from.isValid() )
auto v1 = from;
auto v2 = to;
if ( !v1.isValid() )
{
from = qskTypedNullValue( to );
v1 = qskTypedNullValue( v2 );
}
else if ( !to.isValid() )
else if ( !v2.isValid() )
{
to = qskTypedNullValue( from );
v2 = qskTypedNullValue( v1 );
}
else if ( from.userType() != to.userType() )
else if ( v1.userType() != v2.userType() )
{
return;
}
@ -1206,8 +1208,8 @@ void QskSkinnable::startHintTransition( QskAspect aspect,
{
const auto skin = effectiveSkin();
from.setValue( skin->graphicFilter( from.toInt() ) );
to.setValue( skin->graphicFilter( to.toInt() ) );
v1.setValue( skin->graphicFilter( v1.toInt() ) );
v2.setValue( skin->graphicFilter( v2.toInt() ) );
}
aspect.clearStates();
@ -1220,9 +1222,9 @@ void QskSkinnable::startHintTransition( QskAspect aspect,
auto animator = m_data->animators.animator( aspect );
if ( animator && animator->isRunning() )
from = animator->currentValue();
v1 = animator->currentValue();
m_data->animators.start( control, aspect, animationHint, from, to );
m_data->animators.start( control, aspect, animationHint, v1, v2 );
}
void QskSkinnable::setSkinStateFlag( QskAspect::State stateFlag, bool on )

View File

@ -119,7 +119,7 @@ class QSK_EXPORT QskSkinnable
QskSkin* effectiveSkin() const;
void startTransition( QskAspect,
QskAnimationHint, QVariant from, QVariant to );
QskAnimationHint, const QVariant& from, const QVariant& to );
QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol ) const;
@ -240,8 +240,10 @@ class QSK_EXPORT QskSkinnable
const QskSkinHintTable& hintTable() const;
private:
Q_DISABLE_COPY( QskSkinnable )
void startHintTransition( QskAspect,
QskAnimationHint, QVariant from, QVariant to );
QskAnimationHint, const QVariant& from, const QVariant& to );
QVariant animatedValue( QskAspect, QskSkinHintStatus* ) const;
const QVariant& storedHint( QskAspect, QskSkinHintStatus* = nullptr ) const;

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_SUB_WINDOW_H
#define QSK_SUB_WINDOW_H 1
#define QSK_SUB_WINDOW_H
#include "QskPopup.h"

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_SUB_WINDOW_AREA_H
#define QSK_SUB_WINDOW_AREA_H 1
#define QSK_SUB_WINDOW_AREA_H
#include "QskControl.h"

View File

@ -219,7 +219,7 @@ namespace
inline QskLinearBox* buttonBox() const
{
return qobject_cast< QskLinearBox* >( childItems().first() );
return qobject_cast< QskLinearBox* >( childItems().constFirst() );
}
void enableAutoTranslation( bool on )

View File

@ -766,12 +766,12 @@ int QskTextInput::passwordMaskDelay() const
void QskTextInput::setPasswordMaskDelay( int ms )
{
return m_data->textInput->setPasswordMaskDelay( ms );
m_data->textInput->setPasswordMaskDelay( ms );
}
void QskTextInput::resetPasswordMaskDelay()
{
return m_data->textInput->resetPasswordMaskDelay();
m_data->textInput->resetPasswordMaskDelay();
}
QString QskTextInput::displayText() const
@ -781,7 +781,7 @@ QString QskTextInput::displayText() const
QString QskTextInput::preeditText() const
{
auto d = QQuickTextInputPrivate::get( m_data->textInput );
const auto d = QQuickTextInputPrivate::get( m_data->textInput );
return d->m_textLayout.preeditAreaText();
}
@ -816,7 +816,7 @@ QVariant QskTextInput::inputMethodQuery(
}
QVariant QskTextInput::inputMethodQuery(
Qt::InputMethodQuery query, QVariant argument ) const
Qt::InputMethodQuery query, const QVariant& argument ) const
{
switch ( query )
{

View File

@ -146,7 +146,7 @@ class QSK_EXPORT QskTextInput : public QskControl
bool fixup();
QVariant inputMethodQuery( Qt::InputMethodQuery ) const override;
QVariant inputMethodQuery( Qt::InputMethodQuery, QVariant argument ) const;
QVariant inputMethodQuery( Qt::InputMethodQuery, const QVariant& argument ) const;
bool canUndo() const;
bool canRedo() const;

View File

@ -21,14 +21,17 @@
#include <qvariantanimation.h>
QSK_QT_PRIVATE_BEGIN
#if QT_VERSION >= QT_VERSION_CHECK( 6, 2, 0 )
#ifndef emit
// qvariantanimation_p.h needs it
#define emit
#include <private/qabstractanimation_p.h>
#undef emit
#endif
#endif
#include <private/qvariantanimation_p.h>
QSK_QT_PRIVATE_END
#if 1

View File

@ -119,7 +119,7 @@ static inline void qskSetVisualizationMode(
#endif
}
static inline QByteArray qskVisualizationMode( const QQuickWindow* window )
static inline const QByteArray& qskVisualizationMode( const QQuickWindow* window )
{
auto d = QQuickWindowPrivate::get( const_cast< QQuickWindow* >( window ) );
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
@ -128,6 +128,7 @@ static inline QByteArray qskVisualizationMode( const QQuickWindow* window )
return d->customRenderMode;
#endif
}
class QskWindowPrivate : public QQuickWindowPrivate
{
Q_DECLARE_PUBLIC( QskWindow )
@ -201,23 +202,6 @@ QskWindow::QskWindow( QQuickRenderControl* renderControl, QWindow* parent )
QskWindow::~QskWindow()
{
#if QT_VERSION < QT_VERSION_CHECK( 5, 12, 0 )
// When being used from Qml the item destruction would run in the most
// unefficient way, leading to lots of QQuickItem::ItemChildRemovedChange
// depending operations.
QVector< QPointer< QQuickItem > > items;
const auto children = contentItem()->childItems();
for ( auto child : children )
{
if ( child->parent() == contentItem() )
items += child;
}
for ( auto& item : qskAsConst( items ) )
delete item;
#endif
}
#if QT_VERSION < QT_VERSION_CHECK( 5, 9, 0 )
@ -236,7 +220,8 @@ void QskWindow::setScreen( const QString& name )
{
if ( !name.isEmpty() )
{
for ( auto screen : QGuiApplication::screens() )
const auto screens = QGuiApplication::screens();
for ( auto screen : screens )
{
if ( screen->name() == name )
{
@ -579,7 +564,7 @@ void QskWindow::setCustomRenderMode( const char* mode )
class RenderJob final : public QRunnable
{
public:
RenderJob( QQuickWindow* window, const QByteArray mode )
RenderJob( QQuickWindow* window, const QByteArray& mode )
: m_window( window )
, m_mode( mode )
{

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_WINDOW_H
#define QSK_WINDOW_H 1
#define QSK_WINDOW_H
#include "QskGlobal.h"
#include <qquickwindow.h>

View File

@ -1,2 +0,0 @@
TEMPLATE = subdirs
SUBDIRS = ../

View File

@ -19,6 +19,8 @@
#include <qpointer.h>
#include <qquickwindow.h>
#include <qpa/qplatformdialoghelper.h>
static QskDialog::Action qskActionCandidate( const QskDialogButtonBox* buttonBox )
{
// not the fastest code ever, but usually we always
@ -45,7 +47,7 @@ static QskDialog::Action qskActionCandidate( const QskDialogButtonBox* buttonBox
static QskDialog::DialogCode qskExec( QskDialogWindow* dialogWindow )
{
#if 1
QskFocusIndicator* focusIndicator = new QskFocusIndicator();
auto focusIndicator = new QskFocusIndicator();
focusIndicator->setObjectName( QStringLiteral( "DialogFocusIndicator" ) );
dialogWindow->addItem( focusIndicator );
#endif
@ -58,7 +60,7 @@ static QQuickWindow* qskSomeQuickWindow()
// not the best code ever, but as it is a fallback only
// maybe we should also add the stacking order
QWindowList windows = QGuiApplication::topLevelWindows();
const auto windows = QGuiApplication::topLevelWindows();
for ( auto window : windows )
{
if ( window->isVisible() )
@ -336,4 +338,12 @@ QString QskDialog::select(
}
QskDialog::ActionRole QskDialog::actionRole( Action action )
{
using Q = QPlatformDialogHelper;
const auto role = Q::buttonRole( static_cast< Q::StandardButton >( action ) );
return static_cast< ActionRole >( role );
}
#include "moc_QskDialog.cpp"

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_DIALOG_H
#define QSK_DIALOG_H 1
#define QSK_DIALOG_H
#include "QskGlobal.h"
@ -139,6 +139,8 @@ class QSK_EXPORT QskDialog : public QObject
const QString& title, const QString& text,
const QStringList& entries, int selectedRow = 0 ) const;
static ActionRole actionRole( Action action );
Q_SIGNALS:
void transientParentChanged();
void policyChanged();

View File

@ -5,6 +5,7 @@
#include "QskDialogButton.h"
#include "QskDialogButtonBox.h"
#include "QskSkin.h"
QSK_SUBCONTROL( QskDialogButton, Panel )
QSK_SUBCONTROL( QskDialogButton, Text )
@ -15,7 +16,7 @@ QskDialogButton::QskDialogButton(
: QskPushButton( parent )
, m_action( action )
{
setText( QskDialogButtonBox::buttonText( m_action ) );
resetButton();
}
QskDialogButton::QskDialogButton( QQuickItem* parent )
@ -47,7 +48,7 @@ void QskDialogButton::setAction( QskDialog::Action action )
if ( action != m_action )
{
m_action = action;
setText( QskDialogButtonBox::buttonText( m_action ) );
resetButton();
Q_EMIT actionChanged();
}
@ -60,10 +61,21 @@ QskDialog::Action QskDialogButton::action() const
void QskDialogButton::changeEvent( QEvent* event )
{
if ( event->type() == QEvent::LocaleChange )
setText( QskDialogButtonBox::buttonText( m_action ) );
switch( static_cast< int >( event->type() ) )
{
case QEvent::LocaleChange:
case QEvent::StyleChange:
resetButton();
break;
}
Inherited::changeEvent( event );
}
void QskDialogButton::resetButton()
{
if ( const auto skin = effectiveSkin() )
setText( skin->dialogButtonText( m_action ) );
}
#include "moc_QskDialogButton.cpp"

View File

@ -39,6 +39,8 @@ class QSK_EXPORT QskDialogButton : public QskPushButton
QskAspect::Subcontrol ) const override;
private:
void resetButton();
QskDialog::Action m_action;
};

View File

@ -15,11 +15,6 @@
#include <qvector.h>
#include <qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
QSK_QT_PRIVATE_BEGIN
#include <private/qguiapplication_p.h>
QSK_QT_PRIVATE_END
#include <limits>
@ -31,14 +26,6 @@ static void qskSendEventTo( QObject* object, QEvent::Type type )
QCoreApplication::sendEvent( object, &event );
}
static inline QskDialog::ActionRole qskActionRole( QskDialog::Action action )
{
const auto role = QPlatformDialogHelper::buttonRole(
static_cast< QPlatformDialogHelper::StandardButton >( action ) );
return static_cast< QskDialog::ActionRole >( role );
}
namespace
{
class LayoutEngine : public QskLinearLayoutEngine
@ -131,7 +118,7 @@ QskDialogButtonBox::~QskDialogButtonBox()
{
for ( int i = 0; i < QskDialog::NActionRoles; i++ )
{
for ( auto button : qskAsConst( m_data->buttons[ i ] ) )
for ( auto button : qAsConst( m_data->buttons[ i ] ) )
{
/*
The destructor of QQuickItem sets the parentItem of
@ -346,9 +333,8 @@ void QskDialogButtonBox::addButton(
void QskDialogButtonBox::addAction( QskDialog::Action action )
{
QskPushButton* button = createButton( action );
if ( button )
addButton( button, qskActionRole( action ) );
if ( auto button = createButton( action ) )
addButton( button, QskDialog::actionRole( action ) );
}
void QskDialogButtonBox::removeButton( QskPushButton* button )
@ -579,32 +565,10 @@ void QskDialogButtonBox::itemChange(
bool QskDialogButtonBox::isDefaultButtonKeyEvent( const QKeyEvent* event )
{
if ( event->modifiers() & Qt::KeypadModifier && event->key() == Qt::Key_Enter )
{
return ( event->modifiers() & Qt::KeypadModifier )
&& ( event->key() == Qt::Key_Enter );
}
else
{
return ( event->key() == Qt::Key_Enter ) ||
( event->key() == Qt::Key_Return );
}
}
if ( !event->modifiers() )
return ( event->key() == Qt::Key_Enter ) || ( event->key() == Qt::Key_Return );
QString QskDialogButtonBox::buttonText( QskDialog::Action action )
{
// should be redirected through the skin !
const QPlatformTheme* theme = QGuiApplicationPrivate::platformTheme();
QString text = theme->standardButtonText( action );
#if QT_VERSION < QT_VERSION_CHECK( 5, 7, 0 )
text.remove( '&' );
#else
text = QPlatformTheme::removeMnemonics( text );
#endif
return text;
return ( event->modifiers() & Qt::KeypadModifier ) && ( event->key() == Qt::Key_Enter );
}
#include "moc_QskDialogButtonBox.cpp"

View File

@ -61,7 +61,6 @@ class QSK_EXPORT QskDialogButtonBox : public QskBox
QskPushButton* defaultButton() const;
static bool isDefaultButtonKeyEvent( const QKeyEvent* );
static QString buttonText( QskDialog::Action );
Q_SIGNALS:
void clicked( QskPushButton* button );

View File

@ -7,6 +7,7 @@
#include "QskDialogButtonBox.h"
#include "QskPushButton.h"
#include "QskQuick.h"
#include "QskEvent.h"
#include <qquickwindow.h>
#include <qpointer.h>
@ -280,7 +281,7 @@ void QskDialogSubWindow::keyPressEvent( QKeyEvent* event )
button->click();
}
if ( event->matches( QKeySequence::Cancel ) )
if ( qskIsStandardKeyInput( event, QKeySequence::Cancel ) )
{
// using shortcuts instead ???

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_DIALOG_SUB_WINDOW_H
#define QSK_DIALOG_SUB_WINDOW_H 1
#define QSK_DIALOG_SUB_WINDOW_H
#include "QskDialog.h"
#include "QskSubWindow.h"

View File

@ -8,6 +8,7 @@
#include "QskLinearBox.h"
#include "QskPushButton.h"
#include "QskQuick.h"
#include "QskEvent.h"
#include <qeventloop.h>
#include <qpointer.h>
@ -248,7 +249,7 @@ void QskDialogWindow::keyPressEvent( QKeyEvent* event )
button->click();
}
if ( event->matches( QKeySequence::Cancel ) )
if ( qskIsStandardKeyInput( event, QKeySequence::Cancel ) )
{
// using shortcuts instead ???

View File

@ -4,7 +4,7 @@
*****************************************************************************/
#ifndef QSK_DIALOG_WINDOW_H
#define QSK_DIALOG_WINDOW_H 1
#define QSK_DIALOG_WINDOW_H
#include "QskDialog.h"
#include "QskWindow.h"

Some files were not shown because too many files have changed in this diff Show More