panel property added

This commit is contained in:
Uwe Rathmann 2021-04-21 09:18:50 +02:00
parent 63619f68d4
commit 7b71744917
3 changed files with 35 additions and 2 deletions

View File

@ -290,6 +290,7 @@ class QskTextInput::PrivateData
QString description; // f.e. used as prompt in QskInputPanel QString description; // f.e. used as prompt in QskInputPanel
unsigned int activationModes : 3; unsigned int activationModes : 3;
bool hasPanel : 1;
}; };
QskTextInput::QskTextInput( QQuickItem* parent ) QskTextInput::QskTextInput( QQuickItem* parent )
@ -297,6 +298,7 @@ QskTextInput::QskTextInput( QQuickItem* parent )
, m_data( new PrivateData() ) , m_data( new PrivateData() )
{ {
m_data->activationModes = ActivationOnMouse | ActivationOnKey; m_data->activationModes = ActivationOnMouse | ActivationOnKey;
m_data->hasPanel = true;
setPolishOnResize( true ); setPolishOnResize( true );
setFocusPolicy( Qt::StrongFocus ); setFocusPolicy( Qt::StrongFocus );
@ -329,6 +331,23 @@ QskTextInput::~QskTextInput()
{ {
} }
void QskTextInput::setPanel( bool on )
{
if ( on != m_data->hasPanel )
{
m_data->hasPanel = on;
resetImplicitSize();
polish();
update();
}
}
bool QskTextInput::hasPanel() const
{
return m_data->hasPanel;
}
bool QskTextInput::event( QEvent* event ) bool QskTextInput::event( QEvent* event )
{ {
if ( event->type() == QEvent::ShortcutOverride ) if ( event->type() == QEvent::ShortcutOverride )
@ -473,8 +492,11 @@ QSizeF QskTextInput::layoutSizeHint( Qt::SizeHint which, const QSizeF& ) const
QSizeF hint( input->implicitWidth(), input->implicitHeight() ); QSizeF hint( input->implicitWidth(), input->implicitHeight() );
hint = outerBoxSize( Panel, hint ); if ( m_data->hasPanel )
hint = hint.expandedTo( strutSizeHint( Panel ) ); {
hint = outerBoxSize( Panel, hint );
hint = hint.expandedTo( strutSizeHint( Panel ) );
}
return hint; return hint;
} }

View File

@ -44,6 +44,9 @@ class QSK_EXPORT QskTextInput : public QskControl
WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay
NOTIFY passwordMaskDelayChanged ) NOTIFY passwordMaskDelayChanged )
Q_PROPERTY( bool panel READ hasPanel
WRITE setPanel NOTIFY panelChanged FINAL )
using Inherited = QskControl; using Inherited = QskControl;
public: public:
@ -87,6 +90,9 @@ class QSK_EXPORT QskTextInput : public QskControl
void setDescription( const QString& ); void setDescription( const QString& );
QString description() const; QString description() const;
void setPanel( bool );
bool hasPanel() const;
void setFontRole( int role ); void setFontRole( int role );
void resetFontRole(); void resetFontRole();
int fontRole() const; int fontRole() const;
@ -159,6 +165,7 @@ class QSK_EXPORT QskTextInput : public QskControl
void activationModesChanged(); void activationModesChanged();
void readOnlyChanged( bool ); void readOnlyChanged( bool );
void panelChanged( bool );
void textChanged( const QString& ); void textChanged( const QString& );
void displayTextChanged( const QString& ); void displayTextChanged( const QString& );

View File

@ -38,6 +38,10 @@ QSGNode* QskTextInputSkinlet::updateSubNode(
{ {
case PanelRole: case PanelRole:
{ {
const auto input = static_cast< const QskTextInput* >( skinnable );
if ( !input->hasPanel() )
return nullptr;
return updateBoxNode( skinnable, node, QskTextInput::Panel ); return updateBoxNode( skinnable, node, QskTextInput::Panel );
} }
} }