2018-04-03 10:47:21 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_TEXT_INPUT_H
|
|
|
|
#define QSK_TEXT_INPUT_H
|
|
|
|
|
|
|
|
#include "QskControl.h"
|
|
|
|
|
|
|
|
class QValidator;
|
|
|
|
|
|
|
|
class QSK_EXPORT QskTextInput : public QskControl
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( int fontRole READ fontRole
|
|
|
|
WRITE setFontRole NOTIFY fontRoleChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( Qt::Alignment alignment READ alignment
|
|
|
|
WRITE setAlignment NOTIFY alignmentChanged )
|
|
|
|
|
|
|
|
using Inherited = QskControl;
|
|
|
|
|
|
|
|
public:
|
|
|
|
QSK_SUBCONTROLS( Panel, Text )
|
|
|
|
|
|
|
|
enum EchoMode
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
NoEcho,
|
|
|
|
Password,
|
|
|
|
PasswordEchoOnEdit
|
|
|
|
};
|
|
|
|
Q_ENUM(EchoMode)
|
|
|
|
|
|
|
|
enum SelectionMode
|
|
|
|
{
|
|
|
|
SelectCharacters,
|
|
|
|
SelectWords
|
|
|
|
};
|
|
|
|
Q_ENUM(SelectionMode)
|
|
|
|
|
|
|
|
QskTextInput( QQuickItem* parent = nullptr );
|
|
|
|
QskTextInput( const QString& text, QQuickItem* parent = nullptr );
|
|
|
|
|
|
|
|
virtual ~QskTextInput();
|
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
|
|
|
|
void setFontRole( int role );
|
|
|
|
int fontRole() const;
|
|
|
|
|
|
|
|
void setAlignment( Qt::Alignment );
|
|
|
|
Qt::Alignment alignment() const;
|
|
|
|
|
|
|
|
virtual QSizeF contentsSizeHint() const override;
|
|
|
|
|
|
|
|
QFont font() const;
|
|
|
|
|
|
|
|
bool isReadOnly() const;
|
|
|
|
void setReadOnly(bool);
|
|
|
|
|
|
|
|
bool isCursorVisible() const;
|
|
|
|
void setCursorVisible( bool );
|
|
|
|
|
|
|
|
int cursorPosition() const;
|
|
|
|
void setCursorPosition( int );
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
QString displayText() const;
|
|
|
|
QString preeditText() const;
|
|
|
|
|
|
|
|
bool overwriteMode() const;
|
|
|
|
void setOverwriteMode( bool );
|
|
|
|
|
|
|
|
bool autoScroll() const;
|
|
|
|
void setAutoScroll(bool);
|
|
|
|
|
|
|
|
bool selectByMouse() const;
|
|
|
|
void setSelectByMouse(bool);
|
|
|
|
|
|
|
|
SelectionMode mouseSelectionMode() const;
|
|
|
|
void setMouseSelectionMode( SelectionMode );
|
|
|
|
|
|
|
|
bool persistentSelection() const;
|
|
|
|
void setPersistentSelection( bool );
|
|
|
|
|
|
|
|
bool hasAcceptableInput() const;
|
|
|
|
|
|
|
|
virtual QVariant inputMethodQuery( Qt::InputMethodQuery ) const override;
|
|
|
|
QVariant inputMethodQuery( Qt::InputMethodQuery, QVariant argument) const;
|
|
|
|
|
|
|
|
bool canUndo() const;
|
|
|
|
bool canRedo() const;
|
|
|
|
|
|
|
|
bool isInputMethodComposing() const;
|
|
|
|
|
|
|
|
Qt::InputMethodHints inputMethodHints() const;
|
|
|
|
void setInputMethodHints( Qt::InputMethodHints );
|
|
|
|
|
2018-04-09 10:05:59 +02:00
|
|
|
void ensureVisible( int position );
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
void setText( const QString& );
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void textChanged( const QString& );
|
|
|
|
void textEdited( const QString& );
|
|
|
|
|
|
|
|
void textOptionsChanged();
|
|
|
|
void fontRoleChanged();
|
|
|
|
void alignmentChanged();
|
|
|
|
|
|
|
|
void readOnlyChanged( bool );
|
|
|
|
|
|
|
|
void accepted();
|
|
|
|
void editingFinished();
|
|
|
|
|
|
|
|
void selectedTextChanged( const QString& );
|
|
|
|
|
|
|
|
void overwriteModeChanged( bool );
|
|
|
|
void maximumLengthChanged( int );
|
|
|
|
void echoModeChanged( EchoMode );
|
|
|
|
void autoScrollChanged( bool );
|
|
|
|
void selectByMouseChanged( bool );
|
|
|
|
void persistentSelectionChanged();
|
|
|
|
|
|
|
|
void validatorChanged();
|
|
|
|
void inputMaskChanged( const QString& );
|
|
|
|
|
|
|
|
protected:
|
2018-04-03 20:15:20 +02:00
|
|
|
virtual bool event( QEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2018-04-03 20:15:20 +02:00
|
|
|
virtual void inputMethodEvent( QInputMethodEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2018-04-03 20:15:20 +02:00
|
|
|
virtual void focusInEvent( QFocusEvent* ) override;
|
|
|
|
virtual void focusOutEvent( QFocusEvent* ) override;
|
|
|
|
|
2018-04-05 14:18:15 +02:00
|
|
|
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;
|
|
|
|
virtual void keyReleaseEvent( QKeyEvent* ) override;
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
virtual void updateLayout() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|