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 )
|
|
|
|
|
2018-04-18 19:41:46 +02:00
|
|
|
Q_PROPERTY( QString description READ description
|
|
|
|
WRITE setDescription NOTIFY descriptionChanged )
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
Q_PROPERTY( int fontRole READ fontRole
|
2020-12-27 16:31:07 +01:00
|
|
|
WRITE setFontRole RESET resetFontRole NOTIFY fontRoleChanged )
|
2018-04-03 10:47:21 +02:00
|
|
|
|
2020-07-15 16:17:50 +02:00
|
|
|
Q_PROPERTY( QFont font READ font )
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
Q_PROPERTY( Qt::Alignment alignment READ alignment
|
|
|
|
WRITE setAlignment NOTIFY alignmentChanged )
|
|
|
|
|
2018-04-13 16:32:48 +02:00
|
|
|
Q_PROPERTY( ActivationModes activationModes READ activationModes
|
|
|
|
WRITE setActivationModes NOTIFY activationModesChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( bool editing READ isEditing
|
|
|
|
WRITE setEditing NOTIFY editingChanged )
|
|
|
|
|
2018-06-02 17:10:41 +02:00
|
|
|
Q_PROPERTY( EchoMode echoMode READ echoMode
|
|
|
|
WRITE setEchoMode NOTIFY echoModeChanged )
|
|
|
|
|
2018-04-27 16:55:50 +02:00
|
|
|
Q_PROPERTY( QString passwordCharacter READ passwordCharacter
|
|
|
|
WRITE setPasswordCharacter RESET resetPasswordCharacter
|
|
|
|
NOTIFY passwordCharacterChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( int passwordMaskDelay READ passwordMaskDelay
|
|
|
|
WRITE setPasswordMaskDelay RESET resetPasswordMaskDelay
|
|
|
|
NOTIFY passwordMaskDelayChanged )
|
|
|
|
|
2021-04-21 09:18:50 +02:00
|
|
|
Q_PROPERTY( bool panel READ hasPanel
|
2021-04-21 09:28:57 +02:00
|
|
|
WRITE setPanel NOTIFY panelChanged )
|
2021-04-21 09:18:50 +02:00
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
using Inherited = QskControl;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2018-04-18 10:46:11 +02:00
|
|
|
QSK_SUBCONTROLS( Panel, Text, PanelSelected, TextSelected )
|
2018-04-13 16:32:48 +02:00
|
|
|
QSK_STATES( ReadOnly, Editing )
|
|
|
|
|
|
|
|
enum ActivationMode
|
|
|
|
{
|
|
|
|
NoActivation,
|
|
|
|
|
2018-04-18 19:41:46 +02:00
|
|
|
ActivationOnFocus = 1 << 0,
|
2018-04-13 16:32:48 +02:00
|
|
|
ActivationOnMouse = 1 << 1,
|
2018-04-18 10:46:11 +02:00
|
|
|
ActivationOnKey = 1 << 2,
|
|
|
|
|
|
|
|
ActivationOnInput = ActivationOnMouse | ActivationOnKey,
|
|
|
|
ActivationOnAll = ActivationOnFocus | ActivationOnMouse | ActivationOnKey
|
2018-04-13 16:32:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_ENUM( ActivationMode )
|
|
|
|
Q_DECLARE_FLAGS( ActivationModes, ActivationMode )
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
enum EchoMode
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
NoEcho,
|
|
|
|
Password,
|
|
|
|
PasswordEchoOnEdit
|
|
|
|
};
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_ENUM( EchoMode )
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
QskTextInput( QQuickItem* parent = nullptr );
|
|
|
|
QskTextInput( const QString& text, QQuickItem* parent = nullptr );
|
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
~QskTextInput() override;
|
2018-04-03 10:47:21 +02:00
|
|
|
|
2018-06-02 17:10:41 +02:00
|
|
|
void setupFrom( const QQuickItem* );
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
QString text() const;
|
|
|
|
|
2018-04-18 19:41:46 +02:00
|
|
|
void setDescription( const QString& );
|
|
|
|
QString description() const;
|
|
|
|
|
2021-04-21 09:18:50 +02:00
|
|
|
void setPanel( bool );
|
|
|
|
bool hasPanel() const;
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void setFontRole( int role );
|
2020-12-27 16:31:07 +01:00
|
|
|
void resetFontRole();
|
2018-04-03 10:47:21 +02:00
|
|
|
int fontRole() const;
|
|
|
|
|
|
|
|
void setAlignment( Qt::Alignment );
|
2020-12-27 16:31:07 +01:00
|
|
|
void resetAlignment();
|
2018-04-03 10:47:21 +02:00
|
|
|
Qt::Alignment alignment() const;
|
|
|
|
|
2018-04-13 16:32:48 +02:00
|
|
|
void setActivationModes( ActivationModes );
|
|
|
|
ActivationModes activationModes() const;
|
|
|
|
|
|
|
|
bool isEditing() const;
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
QFont font() const;
|
|
|
|
|
|
|
|
bool isReadOnly() const;
|
2018-08-03 08:15:28 +02:00
|
|
|
void setReadOnly( bool );
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
int cursorPosition() const;
|
|
|
|
void setCursorPosition( int );
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2018-04-27 16:55:50 +02:00
|
|
|
QString passwordCharacter() const;
|
|
|
|
void setPasswordCharacter( const QString& );
|
|
|
|
void resetPasswordCharacter();
|
2018-04-18 19:41:46 +02:00
|
|
|
|
2018-04-27 16:55:50 +02:00
|
|
|
int passwordMaskDelay() const;
|
|
|
|
void setPasswordMaskDelay( int );
|
|
|
|
void resetPasswordMaskDelay();
|
|
|
|
|
|
|
|
QString displayText() const;
|
2018-04-03 10:47:21 +02:00
|
|
|
QString preeditText() const;
|
|
|
|
|
|
|
|
bool overwriteMode() const;
|
|
|
|
void setOverwriteMode( bool );
|
|
|
|
|
2018-09-28 10:07:18 +02:00
|
|
|
bool hasAcceptableInput() const;
|
|
|
|
bool fixup();
|
2018-04-03 10:47:21 +02:00
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
QVariant inputMethodQuery( Qt::InputMethodQuery ) const override;
|
2018-08-03 08:15:28 +02:00
|
|
|
QVariant inputMethodQuery( Qt::InputMethodQuery, QVariant argument ) const;
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
bool canUndo() const;
|
|
|
|
bool canRedo() const;
|
|
|
|
|
|
|
|
Qt::InputMethodHints inputMethodHints() const;
|
|
|
|
void setInputMethodHints( Qt::InputMethodHints );
|
|
|
|
|
2018-04-09 10:05:59 +02:00
|
|
|
void ensureVisible( int position );
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public Q_SLOTS:
|
2018-04-03 10:47:21 +02:00
|
|
|
void setText( const QString& );
|
2018-04-13 16:32:48 +02:00
|
|
|
void setEditing( bool );
|
2018-04-03 10:47:21 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2018-04-13 16:32:48 +02:00
|
|
|
void editingChanged( bool );
|
|
|
|
|
|
|
|
void activationModesChanged();
|
|
|
|
void readOnlyChanged( bool );
|
2021-04-21 09:18:50 +02:00
|
|
|
void panelChanged( bool );
|
2018-04-13 16:32:48 +02:00
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void textChanged( const QString& );
|
2021-03-02 16:17:56 +01:00
|
|
|
void displayTextChanged( const QString& );
|
2018-06-11 11:34:12 +02:00
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void textEdited( const QString& );
|
2018-04-18 19:41:46 +02:00
|
|
|
void descriptionChanged( const QString& );
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void textOptionsChanged();
|
|
|
|
void fontRoleChanged();
|
|
|
|
void alignmentChanged();
|
|
|
|
|
|
|
|
void overwriteModeChanged( bool );
|
|
|
|
void maximumLengthChanged( int );
|
2018-04-27 16:55:50 +02:00
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void echoModeChanged( EchoMode );
|
2018-04-27 16:55:50 +02:00
|
|
|
void passwordMaskDelayChanged();
|
|
|
|
void passwordCharacterChanged();
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
void validatorChanged();
|
|
|
|
void inputMaskChanged( const QString& );
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
protected:
|
2018-07-31 17:32:25 +02:00
|
|
|
bool event( QEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
void inputMethodEvent( QInputMethodEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
void focusInEvent( QFocusEvent* ) override;
|
|
|
|
void focusOutEvent( QFocusEvent* ) override;
|
2018-04-03 20:15:20 +02:00
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
void mousePressEvent( QMouseEvent* ) override;
|
|
|
|
void mouseMoveEvent( QMouseEvent* ) override;
|
|
|
|
void mouseReleaseEvent( QMouseEvent* ) override;
|
|
|
|
void mouseDoubleClickEvent( QMouseEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2018-07-31 17:32:25 +02:00
|
|
|
void keyPressEvent( QKeyEvent* ) override;
|
|
|
|
void keyReleaseEvent( QKeyEvent* ) override;
|
2018-04-05 14:18:15 +02:00
|
|
|
|
2020-12-29 09:45:00 +01:00
|
|
|
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
2019-09-05 15:16:33 +02:00
|
|
|
|
2019-09-10 17:01:47 +02:00
|
|
|
void updateLayout() override;
|
2018-08-03 08:15:28 +02:00
|
|
|
void updateNode( QSGNode* ) override;
|
2018-04-03 10:47:21 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2018-04-03 10:47:21 +02:00
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
2018-04-13 16:32:48 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QskTextInput::ActivationModes )
|
|
|
|
Q_DECLARE_METATYPE( QskTextInput::ActivationModes )
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
#endif
|