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
unsigned int activationModes : 3;
bool hasPanel : 1;
};
QskTextInput::QskTextInput( QQuickItem* parent )
@ -297,6 +298,7 @@ QskTextInput::QskTextInput( QQuickItem* parent )
, m_data( new PrivateData() )
{
m_data->activationModes = ActivationOnMouse | ActivationOnKey;
m_data->hasPanel = true;
setPolishOnResize( true );
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 )
{
if ( event->type() == QEvent::ShortcutOverride )
@ -473,8 +492,11 @@ QSizeF QskTextInput::layoutSizeHint( Qt::SizeHint which, const QSizeF& ) const
QSizeF hint( input->implicitWidth(), input->implicitHeight() );
if ( m_data->hasPanel )
{
hint = outerBoxSize( Panel, hint );
hint = hint.expandedTo( strutSizeHint( Panel ) );
}
return hint;
}

View File

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

View File

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