2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
#include "LineEditSkinlet.h"
|
|
|
|
#include "LineEdit.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
LineEditSkinlet::LineEditSkinlet( QskSkin* skin ):
|
2017-07-21 18:21:34 +02:00
|
|
|
Inherited( skin )
|
|
|
|
{
|
|
|
|
setNodeRoles( { BackgroundRole, ForegroundRole } );
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
LineEditSkinlet::~LineEditSkinlet() = default;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
QRectF LineEditSkinlet::subControlRect(
|
2017-07-21 18:21:34 +02:00
|
|
|
const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const
|
2017-07-28 14:47:11 +02:00
|
|
|
{
|
2017-07-24 07:48:36 +02:00
|
|
|
const auto lineEdit = static_cast< const LineEdit* >( skinnable );
|
2017-07-28 14:47:11 +02:00
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
if ( subControl == LineEdit::Panel )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
return panelRect( lineEdit );
|
|
|
|
}
|
2017-07-28 14:47:11 +02:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
return Inherited::subControlRect( skinnable, subControl );
|
2017-07-28 14:47:11 +02:00
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
QRectF LineEditSkinlet::panelRect( const LineEdit* lineEdit ) const
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
return lineEdit->contentsRect();
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
QSGNode* LineEditSkinlet::updateSubNode(
|
2017-07-21 18:21:34 +02:00
|
|
|
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
|
|
|
{
|
2017-07-24 07:48:36 +02:00
|
|
|
const auto lineEdit = static_cast< const LineEdit* >( skinnable );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
switch( nodeRole )
|
|
|
|
{
|
|
|
|
case BackgroundRole:
|
|
|
|
return updateBackgroundNode( lineEdit, node );
|
|
|
|
|
|
|
|
case ForegroundRole:
|
|
|
|
return updateForegroundNode( lineEdit, node );
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
QSGNode* LineEditSkinlet::updateBackgroundNode(
|
|
|
|
const LineEdit* lineEdit, QSGNode* node ) const
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2017-07-24 07:48:36 +02:00
|
|
|
return updateBoxNode( lineEdit, node, LineEdit::Panel );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
QSGNode* LineEditSkinlet::updateForegroundNode(
|
|
|
|
const LineEdit* lineEdit, QSGNode* node ) const
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2017-07-24 07:48:36 +02:00
|
|
|
auto edit = const_cast< LineEdit* >( lineEdit );
|
2017-07-21 18:21:34 +02:00
|
|
|
return edit->updateTextInputNode( node );
|
|
|
|
}
|
|
|
|
|
2017-07-24 07:48:36 +02:00
|
|
|
#include "moc_LineEditSkinlet.cpp"
|