From fd945131256f2e3fca8c61ef36c887d23ac28198 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 15 Oct 2024 12:34:31 +0200 Subject: [PATCH] input text: styling and small stuff Resolves #400 --- designsystems/material3/QskMaterial3TextInputSkinlet.cpp | 6 ++++-- src/controls/QskTextInput.h | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/designsystems/material3/QskMaterial3TextInputSkinlet.cpp b/designsystems/material3/QskMaterial3TextInputSkinlet.cpp index 040d506de..44c1b74d6 100644 --- a/designsystems/material3/QskMaterial3TextInputSkinlet.cpp +++ b/designsystems/material3/QskMaterial3TextInputSkinlet.cpp @@ -36,12 +36,14 @@ namespace const auto iconMargins = input->marginHint( Q::LeadingIcon ); const auto x1 = iconMargins.left() - margins.left(); - const auto r1 = x1 / panelRect.width(); + auto r1 = x1 / panelRect.width(); + r1 = qBound( 0.0, r1, 1.0 ); const auto w = qskHorizontalAdvance( input->effectiveFont( Q::LabelText ), input->labelText() ); const auto x2 = x1 + w + margins.right(); - const auto r2 = x2 / panelRect.width(); + auto r2 = x2 / panelRect.width(); + r2 = qBound( 0.0, r2, 1.0 ); topGradient.setStops( { { 0.0, topGradient.startColor() }, diff --git a/src/controls/QskTextInput.h b/src/controls/QskTextInput.h index 2b182bc5b..0de406328 100644 --- a/src/controls/QskTextInput.h +++ b/src/controls/QskTextInput.h @@ -16,9 +16,11 @@ class QSK_EXPORT QskTextInput : public QskControl { Q_OBJECT - Q_PROPERTY( QString inputText READ inputText WRITE setInputText NOTIFY inputTextChanged USER true ) + Q_PROPERTY( QString inputText READ inputText + WRITE setInputText NOTIFY inputTextChanged USER true ) - Q_PROPERTY( QString labelText READ labelText WRITE setLabelText NOTIFY labelTextChanged ) + Q_PROPERTY( QString labelText READ labelText + WRITE setLabelText NOTIFY labelTextChanged ) Q_PROPERTY( QString hintText READ hintText WRITE setHintText NOTIFY hintTextChanged ) @@ -99,7 +101,7 @@ class QSK_EXPORT QskTextInput : public QskControl Q_ENUM( EchoMode ) QskTextInput( QQuickItem* parent = nullptr ); - QskTextInput( const QString&, QQuickItem* parent = nullptr ); // ### do we need this constructor? + QskTextInput( const QString&, QQuickItem* parent = nullptr ); ~QskTextInput() override;