crazy combination of LineEdit/QQuickTextInputPrivate removed.

Interesting that such a thing is doable, but way too weired to keep it.
This commit is contained in:
Uwe Rathmann 2017-10-25 13:40:32 +02:00
parent 19b64d5b97
commit e1e0edec3e
6 changed files with 4 additions and 1404 deletions

View File

@ -1,853 +0,0 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "LineEdit.h"
#include "LineEditSkinlet.h"
#include <QskAspect.h>
// VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set
#if ( _MSC_VER >= 1700 ) && !defined( _ALLOW_KEYWORD_MACROS )
#define _ALLOW_KEYWORD_MACROS
#endif
QSK_QT_PRIVATE_BEGIN
#define protected public
#define private public
#include <private/qquicktextinput_p.h>
#include <private/qquicktextinput_p_p.h>
#undef protected
#undef private
QSK_QT_PRIVATE_END
#define Q_P(ClassName) \
auto p = reinterpret_cast< ClassName* >( this )
QSK_SUBCONTROL( LineEdit, Panel )
QSK_SUBCONTROL( LineEdit, Text )
class LineEditPrivate : public QQuickTextInputPrivate
{
Q_DECLARE_PUBLIC(LineEdit)
using Inherited = QQuickTextInputPrivate;
public:
QLocale locale;
void mirrorChange() override
{
Q_Q( QskControl );
QEvent event( QEvent::LayoutDirectionChange );
QCoreApplication::sendEvent( q, &event );
}
};
LineEdit::LineEdit( QQuickItem* parent ):
QskControl( *( new LineEditPrivate ), parent )
{
Q_D( LineEdit );
d->init();
setFocusPolicy( Qt::StrongFocus );
#if 1
auto skinlet = new LineEditSkinlet();
skinlet->setOwnedBySkinnable( true );
setSkinlet( skinlet );
#endif
}
LineEdit::~LineEdit()
{
}
void LineEdit::updateLayout()
{
Inherited::updateLayout();
const QMarginsF padding = marginsHint( Panel | QskAspect::Padding );
Q_P( QQuickTextInput );
p->QQuickTextInput::setLeftPadding( padding.left() );
p->QQuickTextInput::setTopPadding( padding.top() );
p->QQuickTextInput::setRightPadding( padding.right() );
p->QQuickTextInput::setBottomPadding( padding.bottom() );
}
// Begin proxy methods
void LineEdit::componentComplete()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::componentComplete();
}
void LineEdit::positionAt( QQmlV4Function* args ) const
{
Q_P( const QQuickTextInput );
p->QQuickTextInput::positionAt( args );
}
QRectF LineEdit::positionToRectangle( int pos ) const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::positionToRectangle( pos );
}
void LineEdit::moveCursorSelection( int pos )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::moveCursorSelection( pos );
}
void LineEdit::moveCursorSelection( int pos, LineEdit::SelectionMode mode )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::moveCursorSelection(
pos, static_cast< QQuickTextInput::SelectionMode >( mode ) );
}
LineEdit::RenderType LineEdit::renderType() const
{
Q_P( const QQuickTextInput );
return static_cast< LineEdit::RenderType >( p->QQuickTextInput::renderType() );
}
void LineEdit::setRenderType( RenderType renderType )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setRenderType( static_cast< QQuickTextInput::RenderType >( renderType ) );
}
QString LineEdit::text() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::text();
}
void LineEdit::setText( const QString& text )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setText( text );
}
int LineEdit::length() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::length();
}
#if 0
QFont LineEdit::font() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::font();
}
void LineEdit::setFont( const QFont& font )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setFont( font );
}
QColor LineEdit::color() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::color();
}
void LineEdit::setColor( const QColor& color )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setColor( color );
}
QColor LineEdit::selectionColor() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectionColor();
}
void LineEdit::setSelectionColor( const QColor& color )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setSelectionColor( color );
}
QColor LineEdit::selectedTextColor() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectedTextColor();
}
void LineEdit::setSelectedTextColor( const QColor& color )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setSelectedTextColor( color );
}
LineEdit::HAlignment LineEdit::hAlign() const
{
Q_P( const QQuickTextInput );
return static_cast< HAlignment >( p->QQuickTextInput::hAlign() );
}
void LineEdit::setHAlign( HAlignment alignment )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setHAlign( static_cast< QQuickTextInput::HAlignment >( alignment ) );
}
void LineEdit::resetHAlign()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetHAlign();
}
LineEdit::HAlignment LineEdit::effectiveHAlign() const
{
Q_P( const QQuickTextInput );
return static_cast< HAlignment >( p->QQuickTextInput::effectiveHAlign() );
}
LineEdit::VAlignment LineEdit::vAlign() const
{
Q_P( const QQuickTextInput );
return static_cast< VAlignment >( p->QQuickTextInput::vAlign() );
}
void LineEdit::setVAlign( LineEdit::VAlignment alignment )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setVAlign( static_cast< QQuickTextInput::VAlignment >( alignment ) );
}
LineEdit::WrapMode LineEdit::wrapMode() const
{
Q_P( const QQuickTextInput );
return static_cast< WrapMode >( p->QQuickTextInput::wrapMode() );
}
void LineEdit::setWrapMode( LineEdit::WrapMode wrapMode )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setWrapMode( static_cast< QQuickTextInput::WrapMode >( wrapMode ) );
}
#endif
bool LineEdit::isReadOnly() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::isReadOnly();
}
void LineEdit::setReadOnly( bool readOnly )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setReadOnly( readOnly );
}
bool LineEdit::isCursorVisible() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::isCursorVisible();
}
void LineEdit::setCursorVisible( bool cursorVisible )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setCursorVisible( cursorVisible );
}
int LineEdit::cursorPosition() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::cursorPosition();
}
void LineEdit::setCursorPosition( int cursorPosition )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setCursorPosition( cursorPosition );
}
QRectF LineEdit::cursorRectangle() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::cursorRectangle();
}
int LineEdit::selectionStart() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectionStart();
}
int LineEdit::selectionEnd() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectionEnd();
}
QString LineEdit::selectedText() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectedText();
}
int LineEdit::maxLength() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::maxLength();
}
void LineEdit::setMaxLength( int maxLength )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setMaxLength( maxLength );
}
QValidator* LineEdit::validator() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::validator();
}
void LineEdit::setValidator( QValidator* validator )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setValidator( validator );
}
QString LineEdit::inputMask() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::inputMask();
}
void LineEdit::setInputMask( const QString& inputMask )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setInputMask( inputMask );
}
LineEdit::EchoMode LineEdit::echoMode() const
{
Q_P( const QQuickTextInput );
return static_cast< EchoMode >( p->QQuickTextInput::echoMode() );
}
void LineEdit::setEchoMode( LineEdit::EchoMode echoMode )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setEchoMode( static_cast< QQuickTextInput::EchoMode >( echoMode ) );
}
QString LineEdit::passwordCharacter() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::passwordCharacter();
}
void LineEdit::setPasswordCharacter( const QString& passordCharacter )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setPasswordCharacter( passordCharacter );
}
int LineEdit::passwordMaskDelay() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::passwordMaskDelay();
}
void LineEdit::setPasswordMaskDelay( int delay )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setPasswordMaskDelay( delay );
}
void LineEdit::resetPasswordMaskDelay()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetPasswordMaskDelay();
}
QString LineEdit::displayText() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::displayText();
}
#if 0
QQmlComponent* LineEdit::cursorDelegate() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::cursorDelegate();
}
void LineEdit::setCursorDelegate( QQmlComponent* component )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setCursorDelegate( component );
}
#endif
bool LineEdit::focusOnPress() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::focusOnPress();
}
void LineEdit::setFocusOnPress( bool focusOnPress )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setFocusOnPress( focusOnPress );
}
bool LineEdit::autoScroll() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::autoScroll();
}
void LineEdit::setAutoScroll( bool autoScroll )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setAutoScroll( autoScroll );
}
bool LineEdit::selectByMouse() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::selectByMouse();
}
void LineEdit::setSelectByMouse( bool selectByMouse )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setSelectByMouse( selectByMouse );
}
LineEdit::SelectionMode LineEdit::mouseSelectionMode() const
{
Q_P( const QQuickTextInput );
return static_cast< SelectionMode >( p->QQuickTextInput::mouseSelectionMode() );
}
void LineEdit::setMouseSelectionMode( SelectionMode selectionMode )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setMouseSelectionMode(
static_cast< QQuickTextInput::SelectionMode >( selectionMode ) );
}
bool LineEdit::persistentSelection() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::persistentSelection();
}
void LineEdit::setPersistentSelection( bool persistentSelection )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setPersistentSelection( persistentSelection );
}
bool LineEdit::hasAcceptableInput() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::hasAcceptableInput();
}
QVariant LineEdit::inputMethodQuery( Qt::InputMethodQuery inputMethodQuery ) const
{
Q_D( const LineEdit );
Q_P( const QQuickTextInput );
auto value = p->QQuickTextInput::inputMethodQuery( inputMethodQuery );
if ( inputMethodQuery == Qt::ImPreferredLanguage && value.isNull() )
return d->locale;
return value;
}
QVariant LineEdit::inputMethodQuery(
Qt::InputMethodQuery inputMethodQuery, QVariant argument ) const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::inputMethodQuery( inputMethodQuery, argument );
}
QRectF LineEdit::boundingRect() const
{
// Special case: we use the control definition of boundingRect instead of
// QQuickLineEdit's, because boundingRect is used in layout and rendering
return Inherited::boundingRect();
}
QRectF LineEdit::clipRect() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::clipRect();
}
bool LineEdit::canPaste() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::canPaste();
}
bool LineEdit::canUndo() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::canUndo();
}
bool LineEdit::canRedo() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::canRedo();
}
bool LineEdit::isInputMethodComposing() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::isInputMethodComposing();
}
Qt::InputMethodHints LineEdit::inputMethodHints() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::inputMethodHints();
}
void LineEdit::setInputMethodHints( Qt::InputMethodHints inputMethodHints )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setInputMethodHints( inputMethodHints );
}
QString LineEdit::getText( int start, int end ) const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::getText( start, end );
}
qreal LineEdit::contentWidth() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::contentWidth();
}
qreal LineEdit::contentHeight() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::contentHeight();
}
#if 0
qreal LineEdit::padding() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::padding();
}
void LineEdit::setPadding( qreal padding )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setPadding( padding );
}
void LineEdit::resetPadding()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetPadding();
}
qreal LineEdit::topPadding() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::padding();
}
void LineEdit::setTopPadding( qreal topPadding )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setTopPadding( topPadding );
}
void LineEdit::resetTopPadding()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetTopPadding();
}
qreal LineEdit::leftPadding() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::leftPadding();
}
void LineEdit::setLeftPadding( qreal leftPadding )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setLeftPadding( leftPadding );
}
void LineEdit::resetLeftPadding()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetLeftPadding();
}
qreal LineEdit::rightPadding() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::leftPadding();
}
void LineEdit::setRightPadding( qreal rightPadding )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setRightPadding( rightPadding );
}
void LineEdit::resetRightPadding()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetRightPadding();
}
qreal LineEdit::bottomPadding() const
{
Q_P( const QQuickTextInput );
return p->QQuickTextInput::leftPadding();
}
void LineEdit::setBottomPadding( qreal bottomPadding )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::setBottomPadding( bottomPadding );
}
void LineEdit::resetBottomPadding()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::resetBottomPadding();
}
#endif
void LineEdit::geometryChanged( const QRectF& newGeometry, const QRectF& oldGeometry )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::geometryChanged( newGeometry, oldGeometry );
}
void LineEdit::mousePressEvent( QMouseEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::mousePressEvent( event );
}
void LineEdit::mouseMoveEvent( QMouseEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::mouseMoveEvent( event );
}
void LineEdit::mouseReleaseEvent( QMouseEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::mouseReleaseEvent( event );
}
void LineEdit::mouseDoubleClickEvent( QMouseEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::mouseDoubleClickEvent( event );
}
void LineEdit::keyPressEvent( QKeyEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::keyPressEvent( event );
}
void LineEdit::inputMethodEvent( QInputMethodEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::inputMethodEvent( event );
}
void LineEdit::mouseUngrabEvent()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::mouseUngrabEvent();
}
bool LineEdit::event( QEvent* event )
{
Q_P( QQuickTextInput );
return p->QQuickTextInput::event( event );
}
void LineEdit::focusOutEvent( QFocusEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::focusOutEvent( event );
}
void LineEdit::focusInEvent( QFocusEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::focusInEvent( event );
}
void LineEdit::timerEvent( QTimerEvent* event )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::timerEvent( event );
}
void LineEdit::selectAll()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::selectAll();
}
void LineEdit::selectWord()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::selectWord();
}
void LineEdit::select( int start, int end )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::select( start, end );
}
void LineEdit::deselect()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::deselect();
}
bool LineEdit::isRightToLeft( int start, int end )
{
Q_P( QQuickTextInput );
return p->QQuickTextInput::isRightToLeft( start, end );
}
#ifndef QT_NO_CLIPBOARD
void LineEdit::cut()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::cut();
}
void LineEdit::copy()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::copy();
}
void LineEdit::paste()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::paste();
}
#endif // QT_NO_CLIPBOARD
void LineEdit::undo()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::undo();
}
void LineEdit::redo()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::redo();
}
void LineEdit::insert( int position, const QString& text )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::insert( position, text );
}
void LineEdit::remove( int start, int end )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::remove( start, end );
}
void LineEdit::ensureVisible( int position )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::ensureVisible( position );
}
void LineEdit::selectionChanged()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::selectionChanged();
}
void LineEdit::createCursor()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::createCursor();
}
void LineEdit::updateCursorRectangle( bool scroll )
{
Q_P( QQuickTextInput );
p->QQuickTextInput::updateCursorRectangle( scroll );
}
void LineEdit::q_canPasteChanged()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::q_canPasteChanged();
}
void LineEdit::q_updateAlignment()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::q_updateAlignment();
}
void LineEdit::triggerPreprocess()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::triggerPreprocess();
}
#ifndef QT_NO_VALIDATOR
void LineEdit::q_validatorChanged()
{
Q_P( QQuickTextInput );
p->QQuickTextInput::q_validatorChanged();
}
#endif
// end proxy methods
QSGNode* LineEdit::updateTextInputNode( QSGNode* node )
{
Q_P( QQuickTextInput );
return p->QQuickTextInput::updatePaintNode( node, nullptr );
}
#include "moc_LineEdit.cpp"

View File

@ -1,430 +0,0 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef _LINE_EDIT_H
#define _LINE_EDIT_H
#include "QskControl.h"
#include <QTextOption>
class QValidator;
class QQuickTextInput;
class LineEditPrivate;
class LineEdit : public QskControl
{
Q_OBJECT
#if 1 // begin QQuickTextInput properties
#if 0
// properties we hide from C++, as they are clash with QskSkinnable skin hints
Q_PRIVATE_PROPERTY( p_func(), QColor color READ color
WRITE setColor NOTIFY colorChanged )
Q_PRIVATE_PROPERTY( p_func(), QColor selectionColor READ selectionColor
WRITE setSelectionColor NOTIFY selectionColorChanged )
Q_PRIVATE_PROPERTY( p_func(), QColor selectedTextColor READ selectedTextColor
WRITE setSelectedTextColor NOTIFY selectedTextColorChanged )
Q_PRIVATE_PROPERTY( p_func(), QFont font READ font
WRITE setFont NOTIFY fontChanged )
Q_PRIVATE_PROPERTY( p_func(), HAlignment horizontalAlignment READ hAlign
WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged )
Q_PRIVATE_PROPERTY( p_func(), HAlignment effectiveHorizontalAlignment
READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged )
Q_PRIVATE_PROPERTY( p_func(), VAlignment verticalAlignment READ vAlign
WRITE setVAlign NOTIFY verticalAlignmentChanged )
Q_PRIVATE_PROPERTY( p_func(), qreal padding READ padding
WRITE setPadding RESET resetPadding NOTIFY paddingChanged )
Q_PRIVATE_PROPERTY( p_func(), qreal topPadding READ topPadding
WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged )
Q_PRIVATE_PROPERTY( p_func(), qreal leftPadding READ leftPadding
WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged )
Q_PRIVATE_PROPERTY( p_func(), qreal rightPadding READ rightPadding
WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged )
Q_PRIVATE_PROPERTY( p_func(), qreal bottomPadding READ bottomPadding
WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged )
// text options
Q_PRIVATE_PROPERTY( p_func(), WrapMode wrapMode READ wrapMode
WRITE setWrapMode NOTIFY wrapModeChanged )
// skinlet
Q_PRIVATE_PROPERTY( p_func(), QQmlComponent* cursorDelegate READ cursorDelegate
WRITE setCursorDelegate NOTIFY cursorDelegateChanged )
#endif
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(int length READ length NOTIFY textChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged)
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay NOTIFY passwordMaskDelayChanged)
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
#endif
using Inherited = QskControl;
public:
QSK_SUBCONTROLS( Panel, Text )
LineEdit( QQuickItem* parent = nullptr );
~LineEdit();
virtual void updateLayout() override;
#if 1 // begin QQuickTextInput API
enum EchoMode
{
//To match QLineEdit::EchoMode
Normal,
NoEcho,
Password,
PasswordEchoOnEdit
};
Q_ENUM(EchoMode)
#if 0 // provided by other means
enum HAlignment
{
AlignLeft = Qt::AlignLeft,
AlignRight = Qt::AlignRight,
AlignHCenter = Qt::AlignHCenter
};
Q_ENUM(HAlignment)
enum VAlignment
{
AlignTop = Qt::AlignTop,
AlignBottom = Qt::AlignBottom,
AlignVCenter = Qt::AlignVCenter
};
Q_ENUM(VAlignment)
enum WrapMode
{
NoWrap = QTextOption::NoWrap,
WordWrap = QTextOption::WordWrap,
WrapAnywhere = QTextOption::WrapAnywhere,
WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
};
Q_ENUM(WrapMode)
#endif
enum SelectionMode
{
SelectCharacters,
SelectWords
};
Q_ENUM(SelectionMode)
enum CursorPosition
{
CursorBetweenCharacters,
CursorOnCharacter
};
Q_ENUM(CursorPosition)
enum RenderType { QtRendering, NativeRendering };
Q_ENUM(RenderType)
#ifndef QT_NO_QML
virtual void componentComplete() override;
Q_INVOKABLE void positionAt( QQmlV4Function* ) const;
#endif
Q_INVOKABLE QRectF positionToRectangle( int ) const;
Q_INVOKABLE void moveCursorSelection( int );
Q_INVOKABLE void moveCursorSelection( int, SelectionMode );
RenderType renderType() const;
void setRenderType( RenderType );
QString text() const;
void setText( const QString& );
int length() const;
#if 0 // Equivalents provided by QskSkinnable
QFont font() const;
void setFont( const QFont& font );
QColor color() const;
void setColor( const QColor& );
QColor selectionColor() const;
void setSelectionColor( const QColor& );
QColor selectedTextColor() const;
void setSelectedTextColor( const QColor& );
HAlignment hAlign() const;
void setHAlign( HAlignment );
void resetHAlign();
HAlignment effectiveHAlign() const;
VAlignment vAlign() const;
void setVAlign( VAlignment );
WrapMode wrapMode() const;
void setWrapMode( WrapMode );
qreal padding() const;
void setPadding(qreal padding);
void resetPadding();
qreal topPadding() const;
void setTopPadding(qreal padding);
void resetTopPadding();
qreal leftPadding() const;
void setLeftPadding(qreal padding);
void resetLeftPadding();
qreal rightPadding() const;
void setRightPadding(qreal padding);
void resetRightPadding();
qreal bottomPadding() const;
void setBottomPadding(qreal padding);
void resetBottomPadding();
#endif
bool isReadOnly() const;
void setReadOnly( bool );
bool isCursorVisible() const;
void setCursorVisible( bool );
int cursorPosition() const;
void setCursorPosition( int );
QRectF cursorRectangle() const;
int selectionStart() const;
int selectionEnd() const;
QString selectedText() const;
int maxLength() const;
void setMaxLength( int );
QValidator* validator() const;
void setValidator( QValidator* );
QString inputMask() const;
void setInputMask( const QString& );
EchoMode echoMode() const;
void setEchoMode( EchoMode echo );
QString passwordCharacter() const;
void setPasswordCharacter(const QString& str);
int passwordMaskDelay() const;
void setPasswordMaskDelay(int delay);
void resetPasswordMaskDelay();
QString displayText() const;
#if 0 // provided by skinlet
QQmlComponent* cursorDelegate() const;
void setCursorDelegate(QQmlComponent*);
#endif
bool focusOnPress() const;
void setFocusOnPress(bool);
bool autoScroll() const;
void setAutoScroll(bool);
bool selectByMouse() const;
void setSelectByMouse(bool);
SelectionMode mouseSelectionMode() const;
void setMouseSelectionMode(SelectionMode mode);
bool persistentSelection() const;
void setPersistentSelection(bool persist);
bool hasAcceptableInput() const;
#ifndef QT_NO_IM
QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
#endif
QRectF boundingRect() const Q_DECL_OVERRIDE;
QRectF clipRect() const Q_DECL_OVERRIDE;
bool canPaste() const;
bool canUndo() const;
bool canRedo() const;
bool isInputMethodComposing() const;
Qt::InputMethodHints inputMethodHints() const;
void setInputMethodHints(Qt::InputMethodHints hints);
Q_INVOKABLE QString getText(int start, int end) const;
qreal contentWidth() const;
qreal contentHeight() const;
protected:
virtual void geometryChanged( const QRectF&, const QRectF& ) override;
virtual void mousePressEvent( QMouseEvent* ) override;
virtual void mouseMoveEvent( QMouseEvent* ) override;
virtual void mouseReleaseEvent( QMouseEvent* ) override;
virtual void mouseDoubleClickEvent( QMouseEvent* ) override;
virtual void keyPressEvent( QKeyEvent* ) override;
#ifndef QT_NO_IM
virtual void inputMethodEvent( QInputMethodEvent* ) override;
#endif
virtual void mouseUngrabEvent() override;
virtual bool event(QEvent* ) override;
virtual void focusOutEvent(QFocusEvent* ) override;
virtual void focusInEvent(QFocusEvent* ) override;
virtual void timerEvent(QTimerEvent* ) override;
Q_SIGNALS:
void textChanged();
void cursorPositionChanged();
void cursorRectangleChanged();
void selectionStartChanged();
void selectionEndChanged();
void selectedTextChanged();
void accepted();
void acceptableInputChanged();
void editingFinished();
#ifdef QSK_MAKEDLL
void colorChanged();
void selectionColorChanged();
void selectedTextColorChanged();
void fontChanged(const QFont& );
void horizontalAlignmentChanged( int alignment );
void verticalAlignmentChanged( int alignment );
void wrapModeChanged();
#endif
void readOnlyChanged(bool isReadOnly);
void cursorVisibleChanged(bool isCursorVisible);
void cursorDelegateChanged();
void maximumLengthChanged(int maximumLength);
void validatorChanged();
void inputMaskChanged(const QString& inputMask);
void echoModeChanged(LineEdit::EchoMode echoMode);
void passwordCharacterChanged();
void passwordMaskDelayChanged(int delay);
void displayTextChanged();
void activeFocusOnPressChanged(bool activeFocusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
void mouseSelectionModeChanged(LineEdit::SelectionMode mode);
void persistentSelectionChanged();
void canPasteChanged();
void canUndoChanged();
void canRedoChanged();
void inputMethodComposingChanged();
void effectiveHorizontalAlignmentChanged();
void contentSizeChanged();
void inputMethodHintsChanged();
void renderTypeChanged();
#ifdef QSK_MAKEDLL
void paddingChanged();
void topPaddingChanged();
void leftPaddingChanged();
void rightPaddingChanged();
void bottomPaddingChanged();
#endif
void localeChanged();
void fontChanged();
public Q_SLOTS:
void selectAll();
void selectWord();
void select( int, int );
void deselect();
bool isRightToLeft( int, int );
#ifndef QT_NO_CLIPBOARD
void cut();
void copy();
void paste();
#endif
void undo();
void redo();
void insert( int, const QString& );
void remove( int, int );
void ensureVisible(int position);
private Q_SLOTS:
void selectionChanged();
void createCursor();
void updateCursorRectangle( bool = true );
void q_canPasteChanged();
void q_updateAlignment();
void triggerPreprocess();
#ifndef QT_NO_VALIDATOR
void q_validatorChanged();
#endif
#endif // end QQuickTextInput API
private:
QSGNode* updateTextInputNode( QSGNode* );
QQuickTextInput* p_func() const;
Q_DECLARE_PRIVATE( LineEdit )
friend class LineEditSkinlet;
};
#endif

View File

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

View File

@ -1,44 +0,0 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef _LINE_EDIT_SKINLET_H
#define _LINE_EDIT_SKINLET_H
#include "QskGlobal.h"
#include "QskSkinlet.h"
class LineEdit;
class LineEditSkinlet : public QskSkinlet
{
Q_GADGET
using Inherited = QskSkinlet;
public:
enum NodeRole
{
BackgroundRole,
ForegroundRole
};
Q_INVOKABLE LineEditSkinlet( QskSkin* = nullptr );
virtual ~LineEditSkinlet();
virtual QRectF subControlRect( const QskSkinnable*,
QskAspect::Subcontrol ) const override;
protected:
virtual QSGNode* updateSubNode( const QskSkinnable*,
quint8, QSGNode* ) const override;
private:
QRectF panelRect( const LineEdit* ) const;
QSGNode* updateBackgroundNode( const LineEdit*, QSGNode* ) const;
QSGNode* updateForegroundNode( const LineEdit*, QSGNode* ) const;
};
#endif

View File

@ -4,11 +4,5 @@ TARGET = inputpanel
DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_OUT_ROOT/plugins )
HEADERS += \
LineEditSkinlet.h \
LineEdit.h
SOURCES += \
LineEditSkinlet.cpp \
LineEdit.cpp \
main.cpp

View File

@ -3,8 +3,6 @@
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "LineEdit.h"
#include <SkinnyFont.h>
#include <SkinnyShortcut.h>
@ -23,6 +21,8 @@
#include <QGuiApplication>
#include <QFontMetricsF>
#include <private/qquicktextinput_p.h>
#define STRINGIFY(x) #x
#define STRING(x) STRINGIFY(x)
@ -39,11 +39,8 @@ public:
setMargins( 10 );
setSpacing( 10 );
auto* lineEdit = new LineEdit( this );
lineEdit->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
lineEdit->setBackgroundColor( Qt::white );
lineEdit->setText( "I am a line edit. Press and edit Me." );
auto* textInput = new QQuickTextInput( this );
textInput->setText( "I am a line edit. Press and edit Me." );
#if LOCAL_PANEL
auto* inputPanel = new QskInputPanel( this );