initial version of QskTextInput wrapping QQuickTextInput
This commit is contained in:
parent
6f4a0045d5
commit
26417ed49a
|
@ -1,17 +0,0 @@
|
|||
#include "TextInput.h"
|
||||
|
||||
TextInput::TextInput( QQuickItem* parent )
|
||||
: QQuickTextInput( parent )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TextInput::~TextInput()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TextInput::inputMethodEvent(QInputMethodEvent *event)
|
||||
{
|
||||
QQuickTextInput::inputMethodEvent(event);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef TEXTINPUT_H
|
||||
#define TEXTINPUT_H
|
||||
|
||||
#include <private/qquicktextinput_p.h>
|
||||
|
||||
class TextInput : public QQuickTextInput
|
||||
{
|
||||
public:
|
||||
TextInput( QQuickItem* parent );
|
||||
virtual ~TextInput() override;
|
||||
|
||||
protected:
|
||||
void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // TEXTINPUT_H
|
|
@ -5,8 +5,4 @@ TARGET = inputpanel
|
|||
DEFINES += PLUGIN_PATH=$$clean_path( $$QSK_OUT_ROOT/plugins )
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
TextInput.cpp
|
||||
|
||||
HEADERS += \
|
||||
TextInput.h
|
||||
main.cpp
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "TextInput.h"
|
||||
|
||||
#include <SkinnyFont.h>
|
||||
#include <SkinnyShortcut.h>
|
||||
|
||||
|
@ -13,6 +11,7 @@
|
|||
#include <QskFocusIndicator.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskListView.h>
|
||||
#include <QskTextInput.h>
|
||||
|
||||
#include <QskWindow.h>
|
||||
#include <QskSetup.h>
|
||||
|
@ -39,8 +38,7 @@ public:
|
|||
setMargins( 10 );
|
||||
setSpacing( 10 );
|
||||
|
||||
auto* textInput = new QQuickTextInput( this );
|
||||
textInput->setActiveFocusOnTab( true );
|
||||
auto* textInput = new QskTextInput( this );
|
||||
textInput->setText( "I am a line edit. Press and edit Me." );
|
||||
|
||||
#if LOCAL_PANEL
|
||||
|
|
|
@ -5,21 +5,22 @@
|
|||
|
||||
#include "QskMaterialSkin.h"
|
||||
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskFocusIndicator.h>
|
||||
#include <QskSeparator.h>
|
||||
#include <QskDialogButton.h>
|
||||
#include <QskDialogButtonBox.h>
|
||||
#include <QskDialogButton.h>
|
||||
#include <QskFocusIndicator.h>
|
||||
#include <QskListView.h>
|
||||
#include <QskPageIndicator.h>
|
||||
#include <QskPushButton.h>
|
||||
#include <QskScrollView.h>
|
||||
#include <QskSeparator.h>
|
||||
#include <QskSlider.h>
|
||||
#include <QskSubWindow.h>
|
||||
#include <QskTabButton.h>
|
||||
#include <QskTabBar.h>
|
||||
#include <QskTabView.h>
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskTextInput.h>
|
||||
#include <QskVirtualKeyboard.h>
|
||||
#include <QskScrollView.h>
|
||||
#include <QskListView.h>
|
||||
#include <QskSubWindow.h>
|
||||
|
||||
#include <QskSkinlet.h>
|
||||
|
||||
|
@ -121,22 +122,24 @@ QskMaterialSkin::~QskMaterialSkin()
|
|||
void QskMaterialSkin::initHints()
|
||||
{
|
||||
initCommonHints();
|
||||
initTextLabelHints();
|
||||
initFocusIndicatorHints();
|
||||
initSeparatorHints();
|
||||
initPageIndicatorHints();
|
||||
initPushButtonHints();
|
||||
initPopupHints();
|
||||
initDialogButtonHints();
|
||||
|
||||
initDialogButtonBoxHints();
|
||||
initDialogButtonHints();
|
||||
initFocusIndicatorHints();
|
||||
initInputPanelHints();
|
||||
initListViewHints();
|
||||
initPageIndicatorHints();
|
||||
initPopupHints();
|
||||
initPushButtonHints();
|
||||
initScrollViewHints();
|
||||
initSeparatorHints();
|
||||
initSliderHints();
|
||||
initSubWindowHints();
|
||||
initTabButtonHints();
|
||||
initTabBarHints();
|
||||
initTabViewHints();
|
||||
initInputPanelHints();
|
||||
initScrollViewHints();
|
||||
initListViewHints();
|
||||
initSubWindowHints();
|
||||
initTextLabelHints();
|
||||
initTextInputHints();
|
||||
}
|
||||
|
||||
void QskMaterialSkin::resetColors( const QColor& accent )
|
||||
|
@ -188,6 +191,25 @@ void QskMaterialSkin::initTextLabelHints()
|
|||
setColor( Q::Text, pal.textColor );
|
||||
}
|
||||
|
||||
void QskMaterialSkin::initTextInputHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskTextInput;
|
||||
|
||||
setSkinHint( Q::Text | Alignment,
|
||||
static_cast<int>( Qt::AlignLeft | Qt::AlignTop ) );
|
||||
|
||||
const ColorPalette& pal = m_data->palette;
|
||||
|
||||
setColor( Q::Text, pal.textColor );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxBorderColors( Q::Panel, pal.darker125 );
|
||||
setGradient( Q::Panel, pal.baseColor );
|
||||
}
|
||||
|
||||
void QskMaterialSkin::initFocusIndicatorHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
|
|
@ -25,22 +25,24 @@ private:
|
|||
void initHints();
|
||||
|
||||
void initCommonHints();
|
||||
void initTextLabelHints();
|
||||
void initFocusIndicatorHints();
|
||||
void initSeparatorHints();
|
||||
void initPageIndicatorHints();
|
||||
void initPushButtonHints();
|
||||
void initPopupHints();
|
||||
void initDialogButtonHints();
|
||||
|
||||
void initDialogButtonBoxHints();
|
||||
void initDialogButtonHints();
|
||||
void initFocusIndicatorHints();
|
||||
void initInputPanelHints();
|
||||
void initListViewHints();
|
||||
void initPageIndicatorHints();
|
||||
void initPopupHints();
|
||||
void initPushButtonHints();
|
||||
void initScrollViewHints();
|
||||
void initSeparatorHints();
|
||||
void initSubWindowHints();
|
||||
void initSliderHints();
|
||||
void initTabButtonHints();
|
||||
void initTabBarHints();
|
||||
void initTabViewHints();
|
||||
void initInputPanelHints();
|
||||
void initScrollViewHints();
|
||||
void initListViewHints();
|
||||
void initSubWindowHints();
|
||||
void initTextInputHints();
|
||||
void initTextLabelHints();
|
||||
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "QskSquiekSkin.h"
|
||||
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskTextInput.h>
|
||||
#include <QskFocusIndicator.h>
|
||||
#include <QskSeparator.h>
|
||||
#include <QskDialogButton.h>
|
||||
|
@ -227,22 +228,24 @@ void QskSquiekSkin::setTab( QskAspect::Aspect aspect,
|
|||
void QskSquiekSkin::initHints()
|
||||
{
|
||||
initCommonHints();
|
||||
initTextLabelHints();
|
||||
initFocusIndicatorHints();
|
||||
initSeparatorHints();
|
||||
initPageIndicatorHints();
|
||||
initPushButtonHints();
|
||||
initPopupHints();
|
||||
initDialogButtonHints();
|
||||
|
||||
initDialogButtonBoxHints();
|
||||
initDialogButtonHints();
|
||||
initFocusIndicatorHints();
|
||||
initInputPanelHints();
|
||||
initListViewHints();
|
||||
initPageIndicatorHints();
|
||||
initPopupHints();
|
||||
initPushButtonHints();
|
||||
initScrollViewHints();
|
||||
initSeparatorHints();
|
||||
initSliderHints();
|
||||
initSubWindowHints();
|
||||
initTabButtonHints();
|
||||
initTabBarHints();
|
||||
initTabViewHints();
|
||||
initInputPanelHints();
|
||||
initScrollViewHints();
|
||||
initListViewHints();
|
||||
initSubWindowHints();
|
||||
initTextLabelHints();
|
||||
initTextInputHints();
|
||||
}
|
||||
|
||||
void QskSquiekSkin::resetColors( const QColor& accent )
|
||||
|
@ -285,6 +288,32 @@ void QskSquiekSkin::initTextLabelHints()
|
|||
setColor( Q::Text, pal.themeForeground );
|
||||
}
|
||||
|
||||
void QskSquiekSkin::initTextInputHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
using Q = QskTextInput;
|
||||
|
||||
const ColorPalette& pal = m_data->palette;
|
||||
|
||||
setSkinHint( Q::Text | Alignment,
|
||||
static_cast<int>( Qt::AlignLeft | Qt::AlignTop ) );
|
||||
|
||||
setColor( Q::Text, pal.themeForeground );
|
||||
|
||||
setMargins( Q::Panel | Padding, 5 );
|
||||
setBoxBorderMetrics( Q::Panel, 2 );
|
||||
setBoxShape( Q::Panel, 4 );
|
||||
|
||||
QColor fillColor( Qt::white );
|
||||
|
||||
const QskBoxBorderColors borderColors(
|
||||
fillColor.darker( 170 ), fillColor.darker( 170 ),
|
||||
fillColor.darker( 105 ), fillColor.darker( 105 ) );
|
||||
|
||||
setBoxBorderColors( Q::Panel, borderColors );
|
||||
setGradient( Q::Panel, fillColor );
|
||||
}
|
||||
|
||||
void QskSquiekSkin::initFocusIndicatorHints()
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
|
|
@ -25,22 +25,24 @@ private:
|
|||
void initHints();
|
||||
|
||||
void initCommonHints();
|
||||
void initTextLabelHints();
|
||||
void initFocusIndicatorHints();
|
||||
void initSeparatorHints();
|
||||
void initPageIndicatorHints();
|
||||
void initPushButtonHints();
|
||||
void initPopupHints();
|
||||
|
||||
void initDialogButtonHints();
|
||||
void initDialogButtonBoxHints();
|
||||
void initFocusIndicatorHints();
|
||||
void initInputPanelHints();
|
||||
void initListViewHints();
|
||||
void initPageIndicatorHints();
|
||||
void initPopupHints();
|
||||
void initPushButtonHints();
|
||||
void initScrollViewHints();
|
||||
void initSeparatorHints();
|
||||
void initSliderHints();
|
||||
void initSubWindowHints();
|
||||
void initTabButtonHints();
|
||||
void initTabBarHints();
|
||||
void initTabViewHints();
|
||||
void initInputPanelHints();
|
||||
void initScrollViewHints();
|
||||
void initListViewHints();
|
||||
void initSubWindowHints();
|
||||
void initTextLabelHints();
|
||||
void initTextInputHints();
|
||||
|
||||
enum PanelStyle
|
||||
{
|
||||
|
|
|
@ -63,6 +63,9 @@ QSK_QT_PRIVATE_END
|
|||
#include "QskTextLabel.h"
|
||||
#include "QskTextLabelSkinlet.h"
|
||||
|
||||
#include "QskTextInput.h"
|
||||
#include "QskTextInputSkinlet.h"
|
||||
|
||||
#include "QskSeparator.h"
|
||||
#include "QskSeparatorSkinlet.h"
|
||||
|
||||
|
@ -140,6 +143,7 @@ QskSkin::QskSkin( QObject* parent ):
|
|||
declareSkinlet< QskTabButton, QskTabButtonSkinlet >();
|
||||
declareSkinlet< QskTabView, QskTabViewSkinlet >();
|
||||
declareSkinlet< QskTextLabel, QskTextLabelSkinlet >();
|
||||
declareSkinlet< QskTextInput, QskTextInputSkinlet >();
|
||||
|
||||
const QFont font = QGuiApplication::font();
|
||||
setupFonts( font.family(), font.weight(), font.italic() );
|
||||
|
|
|
@ -0,0 +1,397 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskTextInput.h"
|
||||
#include "QskTextOptions.h"
|
||||
|
||||
QSK_QT_PRIVATE_BEGIN
|
||||
#include <private/qquicktextinput_p.h>
|
||||
QSK_QT_PRIVATE_END
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextInput final : public QQuickTextInput
|
||||
{
|
||||
public:
|
||||
TextInput( QQuickItem* parent ) :
|
||||
QQuickTextInput( parent )
|
||||
{
|
||||
}
|
||||
|
||||
void setAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
setHAlign( ( HAlignment ) ( int( alignment ) & 0x0f ) );
|
||||
setVAlign( ( VAlignment ) ( int( alignment ) & 0xf0 ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void inputMethodEvent( QInputMethodEvent* event ) override
|
||||
{
|
||||
QQuickTextInput::inputMethodEvent( event );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
QSK_SUBCONTROL( QskTextInput, Panel )
|
||||
QSK_SUBCONTROL( QskTextInput, Text )
|
||||
|
||||
class QskTextInput::PrivateData
|
||||
{
|
||||
public:
|
||||
TextInput* textInput;
|
||||
};
|
||||
|
||||
QskTextInput::QskTextInput( QQuickItem* parent ):
|
||||
QskTextInput( QString(), parent )
|
||||
{
|
||||
}
|
||||
|
||||
QskTextInput::QskTextInput( const QString& text, QQuickItem* parent ):
|
||||
Inherited( parent ),
|
||||
m_data( new PrivateData() )
|
||||
{
|
||||
auto input = new TextInput( this );
|
||||
|
||||
connect( input, &QQuickTextInput::textChanged,
|
||||
this, [ this ] { Q_EMIT textChanged( this->text() ); } );
|
||||
|
||||
connect( input, &QQuickTextInput::textEdited,
|
||||
this, [ this ] { Q_EMIT textEdited( this->text() ); } );
|
||||
|
||||
connect( input, &QQuickTextInput::textChanged,
|
||||
this, [ this ] { Q_EMIT textChanged( this->text() ); } );
|
||||
|
||||
connect( input, &QQuickTextInput::selectedTextChanged,
|
||||
this, [ this ] { Q_EMIT selectedTextChanged( selectedText() ); } );
|
||||
|
||||
connect( input, &QQuickTextInput::validatorChanged,
|
||||
this, &QskTextInput::validatorChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::inputMaskChanged,
|
||||
this, &QskTextInput::inputMaskChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::readOnlyChanged,
|
||||
this, &QskTextInput::readOnlyChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::overwriteModeChanged,
|
||||
this, &QskTextInput::overwriteModeChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::maximumLengthChanged,
|
||||
this, &QskTextInput::maximumLengthChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::echoModeChanged,
|
||||
this, [ this ] { Q_EMIT echoModeChanged( echoMode() ); } );
|
||||
|
||||
connect( input, &QQuickTextInput::autoScrollChanged,
|
||||
this, &QskTextInput::autoScrollChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::selectByMouseChanged,
|
||||
this, &QskTextInput::selectByMouseChanged );
|
||||
|
||||
connect( input, &QQuickTextInput::persistentSelectionChanged,
|
||||
this, &QskTextInput::persistentSelectionChanged );
|
||||
|
||||
connect( input, &QQuickItem::implicitWidthChanged,
|
||||
this, &QskControl::resetImplicitSize );
|
||||
|
||||
connect( input, &QQuickItem::implicitHeightChanged,
|
||||
this, &QskControl::resetImplicitSize );
|
||||
|
||||
input->setAlignment( alignment() );
|
||||
input->setFont( font() );
|
||||
input->setText( text );
|
||||
|
||||
m_data->textInput = input;
|
||||
|
||||
setPolishOnResize( true );
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
#if 1
|
||||
input->setActiveFocusOnTab( true );
|
||||
#endif
|
||||
setAcceptedMouseButtons( Qt::LeftButton );
|
||||
|
||||
initSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Fixed );
|
||||
}
|
||||
|
||||
QskTextInput::~QskTextInput()
|
||||
{
|
||||
}
|
||||
|
||||
QSizeF QskTextInput::contentsSizeHint() const
|
||||
{
|
||||
using namespace QskAspect;
|
||||
|
||||
const qreal w = m_data->textInput->implicitWidth();
|
||||
const qreal h = m_data->textInput->implicitHeight();
|
||||
|
||||
const QSizeF minSize( metric( Panel | MinimumWidth ),
|
||||
metric( Panel | MinimumHeight ) );
|
||||
|
||||
return outerBoxSize( Panel, QSizeF( w, h ) ).expandedTo( minSize );
|
||||
}
|
||||
|
||||
void QskTextInput::updateLayout()
|
||||
{
|
||||
qskSetItemGeometry( m_data->textInput, subControlRect( Text ) );
|
||||
}
|
||||
|
||||
QString QskTextInput::text() const
|
||||
{
|
||||
return m_data->textInput->text();
|
||||
}
|
||||
|
||||
void QskTextInput::setText( const QString& text )
|
||||
{
|
||||
m_data->textInput->setText( text );
|
||||
}
|
||||
|
||||
int QskTextInput::fontRole() const
|
||||
{
|
||||
return QskSkinnable::fontRole( Text );
|
||||
}
|
||||
|
||||
void QskTextInput::setFontRole( int role )
|
||||
{
|
||||
const int oldRole = fontRole();
|
||||
|
||||
QskSkinnable::setFontRole( effectiveSubcontrol( Text ), role );
|
||||
|
||||
if ( oldRole != role )
|
||||
{
|
||||
#if 1
|
||||
m_data->textInput->setFont( font() );
|
||||
#endif
|
||||
Q_EMIT fontRoleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QskTextOptions QskTextInput::textOptions() const
|
||||
{
|
||||
return QskTextOptions();
|
||||
}
|
||||
|
||||
void QskTextInput::setTextOptions( const QskTextOptions& options )
|
||||
{
|
||||
Q_UNUSED( options )
|
||||
}
|
||||
|
||||
void QskTextInput::setAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
if ( alignment != this->alignment() )
|
||||
{
|
||||
const auto subControl = effectiveSubcontrol( Text );
|
||||
setFlagHint( subControl | QskAspect::Alignment, alignment );
|
||||
|
||||
m_data->textInput->setAlignment( alignment );
|
||||
|
||||
Q_EMIT alignmentChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::Alignment QskTextInput::alignment() const
|
||||
{
|
||||
return flagHint< Qt::Alignment >(
|
||||
Text | QskAspect::Alignment, Qt::AlignLeft | Qt::AlignTop );
|
||||
}
|
||||
|
||||
QFont QskTextInput::font() const
|
||||
{
|
||||
return effectiveFont( QskTextInput::Text );
|
||||
}
|
||||
|
||||
bool QskTextInput::isReadOnly() const
|
||||
{
|
||||
return m_data->textInput->isReadOnly();
|
||||
}
|
||||
|
||||
void QskTextInput::setReadOnly( bool on )
|
||||
{
|
||||
m_data->textInput->setReadOnly( on );
|
||||
}
|
||||
|
||||
bool QskTextInput::isCursorVisible() const
|
||||
{
|
||||
return m_data->textInput->isCursorVisible();
|
||||
}
|
||||
|
||||
void QskTextInput::setCursorVisible( bool on )
|
||||
{
|
||||
m_data->textInput->setCursorVisible( on );
|
||||
}
|
||||
|
||||
int QskTextInput::cursorPosition() const
|
||||
{
|
||||
return m_data->textInput->cursorPosition();
|
||||
}
|
||||
|
||||
void QskTextInput::setCursorPosition(int pos)
|
||||
{
|
||||
m_data->textInput->setCursorPosition( pos );
|
||||
}
|
||||
|
||||
int QskTextInput::selectionStart() const
|
||||
{
|
||||
return m_data->textInput->selectionStart();
|
||||
}
|
||||
|
||||
int QskTextInput::selectionEnd() const
|
||||
{
|
||||
return m_data->textInput->selectionEnd();
|
||||
}
|
||||
|
||||
QString QskTextInput::selectedText() const
|
||||
{
|
||||
return m_data->textInput->selectedText();
|
||||
}
|
||||
|
||||
int QskTextInput::maxLength() const
|
||||
{
|
||||
return m_data->textInput->maxLength();
|
||||
}
|
||||
|
||||
void QskTextInput::setMaxLength(int length)
|
||||
{
|
||||
m_data->textInput->setMaxLength( length );
|
||||
}
|
||||
|
||||
QValidator* QskTextInput::validator() const
|
||||
{
|
||||
return m_data->textInput->validator();
|
||||
}
|
||||
|
||||
void QskTextInput::setValidator( QValidator* validator )
|
||||
{
|
||||
m_data->textInput->setValidator( validator );
|
||||
}
|
||||
|
||||
QString QskTextInput::inputMask() const
|
||||
{
|
||||
return m_data->textInput->inputMask();
|
||||
}
|
||||
|
||||
void QskTextInput::setInputMask( const QString& mask )
|
||||
{
|
||||
m_data->textInput->setInputMask( mask );
|
||||
}
|
||||
|
||||
QskTextInput::EchoMode QskTextInput::echoMode() const
|
||||
{
|
||||
const auto mode = m_data->textInput->echoMode();
|
||||
return static_cast< QskTextInput::EchoMode >( mode );
|
||||
}
|
||||
|
||||
void QskTextInput::setEchoMode( EchoMode mode )
|
||||
{
|
||||
m_data->textInput->setEchoMode(
|
||||
static_cast< QQuickTextInput::EchoMode >( mode ) );
|
||||
}
|
||||
|
||||
QString QskTextInput::displayText() const
|
||||
{
|
||||
return m_data->textInput->displayText();
|
||||
}
|
||||
|
||||
QString QskTextInput::preeditText() const
|
||||
{
|
||||
return m_data->textInput->preeditText();
|
||||
}
|
||||
|
||||
bool QskTextInput::overwriteMode() const
|
||||
{
|
||||
return m_data->textInput->overwriteMode();
|
||||
}
|
||||
|
||||
void QskTextInput::setOverwriteMode( bool overwrite )
|
||||
{
|
||||
m_data->textInput->setOverwriteMode( overwrite );
|
||||
}
|
||||
|
||||
bool QskTextInput::autoScroll() const
|
||||
{
|
||||
return m_data->textInput->autoScroll();
|
||||
}
|
||||
|
||||
void QskTextInput::setAutoScroll(bool on)
|
||||
{
|
||||
m_data->textInput->setAutoScroll( on );
|
||||
}
|
||||
|
||||
bool QskTextInput::selectByMouse() const
|
||||
{
|
||||
return m_data->textInput->selectByMouse();
|
||||
}
|
||||
|
||||
void QskTextInput::setSelectByMouse(bool on)
|
||||
{
|
||||
m_data->textInput->setSelectByMouse( on );
|
||||
}
|
||||
|
||||
QskTextInput::SelectionMode QskTextInput::mouseSelectionMode() const
|
||||
{
|
||||
const auto mode = m_data->textInput->mouseSelectionMode();
|
||||
return static_cast< SelectionMode >( mode );
|
||||
}
|
||||
|
||||
void QskTextInput::setMouseSelectionMode( SelectionMode mode )
|
||||
{
|
||||
m_data->textInput->setMouseSelectionMode(
|
||||
static_cast< QQuickTextInput::SelectionMode >( mode ) );
|
||||
}
|
||||
|
||||
bool QskTextInput::persistentSelection() const
|
||||
{
|
||||
return m_data->textInput->persistentSelection();
|
||||
}
|
||||
|
||||
void QskTextInput::setPersistentSelection(bool persist)
|
||||
{
|
||||
m_data->textInput->setPersistentSelection( persist );
|
||||
}
|
||||
|
||||
bool QskTextInput::hasAcceptableInput() const
|
||||
{
|
||||
return m_data->textInput->hasAcceptableInput();
|
||||
}
|
||||
|
||||
QVariant QskTextInput::inputMethodQuery(
|
||||
Qt::InputMethodQuery property) const
|
||||
{
|
||||
return m_data->textInput->inputMethodQuery( property );
|
||||
}
|
||||
|
||||
QVariant QskTextInput::inputMethodQuery(
|
||||
Qt::InputMethodQuery query, QVariant argument) const
|
||||
{
|
||||
return m_data->textInput->inputMethodQuery( query, argument );
|
||||
}
|
||||
|
||||
bool QskTextInput::canUndo() const
|
||||
{
|
||||
return m_data->textInput->canUndo();
|
||||
}
|
||||
|
||||
bool QskTextInput::canRedo() const
|
||||
{
|
||||
return m_data->textInput->canRedo();
|
||||
}
|
||||
|
||||
bool QskTextInput::isInputMethodComposing() const
|
||||
{
|
||||
return m_data->textInput->isInputMethodComposing();
|
||||
}
|
||||
|
||||
Qt::InputMethodHints QskTextInput::inputMethodHints() const
|
||||
{
|
||||
return m_data->textInput->inputMethodHints();
|
||||
}
|
||||
|
||||
void QskTextInput::setInputMethodHints(Qt::InputMethodHints hints )
|
||||
{
|
||||
m_data->textInput->setInputMethodHints( hints );
|
||||
}
|
||||
|
||||
#include "moc_QskTextInput.cpp"
|
|
@ -0,0 +1,163 @@
|
|||
/******************************************************************************
|
||||
* 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 QskTextOptions;
|
||||
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( QskTextOptions textOptions READ textOptions
|
||||
WRITE setTextOptions NOTIFY textOptionsChanged )
|
||||
|
||||
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 setTextOptions( const QskTextOptions& );
|
||||
QskTextOptions textOptions() 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 );
|
||||
|
||||
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:
|
||||
virtual void updateLayout() override;
|
||||
|
||||
private:
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,50 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskTextInputSkinlet.h"
|
||||
#include "QskTextInput.h"
|
||||
|
||||
QskTextInputSkinlet::QskTextInputSkinlet( QskSkin* skin ):
|
||||
Inherited( skin )
|
||||
{
|
||||
setNodeRoles( { PanelRole } );
|
||||
}
|
||||
|
||||
QskTextInputSkinlet::~QskTextInputSkinlet()
|
||||
{
|
||||
}
|
||||
|
||||
QRectF QskTextInputSkinlet::subControlRect(
|
||||
const QskSkinnable* skinnable, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
if ( subControl == QskTextInput::Panel )
|
||||
{
|
||||
const auto textInput = static_cast< const QskTextInput* >( skinnable );
|
||||
return textInput->contentsRect();
|
||||
}
|
||||
else if ( subControl == QskTextInput::Text )
|
||||
{
|
||||
return skinnable->innerBox( QskTextInput::Panel,
|
||||
subControlRect( skinnable, QskTextInput::Panel ) );
|
||||
}
|
||||
|
||||
return Inherited::subControlRect( skinnable, subControl );
|
||||
}
|
||||
|
||||
QSGNode* QskTextInputSkinlet::updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||
{
|
||||
switch( nodeRole )
|
||||
{
|
||||
case PanelRole:
|
||||
{
|
||||
return updateBoxNode( skinnable, node, QskTextInput::Panel );
|
||||
}
|
||||
}
|
||||
|
||||
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
||||
}
|
||||
|
||||
#include "moc_QskTextInputSkinlet.cpp"
|
|
@ -0,0 +1,36 @@
|
|||
/******************************************************************************
|
||||
* 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_SKINLET_H
|
||||
#define QSK_TEXT_INPUT_SKINLET_H
|
||||
|
||||
#include "QskGlobal.h"
|
||||
#include "QskSkinlet.h"
|
||||
|
||||
class QSK_EXPORT QskTextInputSkinlet : public QskSkinlet
|
||||
{
|
||||
Q_GADGET
|
||||
|
||||
using Inherited = QskSkinlet;
|
||||
|
||||
public:
|
||||
enum NodeRole
|
||||
{
|
||||
PanelRole
|
||||
};
|
||||
|
||||
Q_INVOKABLE QskTextInputSkinlet( QskSkin* = nullptr );
|
||||
virtual ~QskTextInputSkinlet();
|
||||
|
||||
virtual QRectF subControlRect( const QskSkinnable*,
|
||||
QskAspect::Subcontrol ) const override;
|
||||
|
||||
protected:
|
||||
virtual QSGNode* updateSubNode( const QskSkinnable*,
|
||||
quint8 nodeRole, QSGNode* ) const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -177,6 +177,8 @@ HEADERS += \
|
|||
controls/QskTabButtonSkinlet.h \
|
||||
controls/QskTabView.h \
|
||||
controls/QskTabViewSkinlet.h \
|
||||
controls/QskTextInput.h \
|
||||
controls/QskTextInputSkinlet.h \
|
||||
controls/QskTextLabel.h \
|
||||
controls/QskTextLabelSkinlet.h \
|
||||
controls/QskVariantAnimator.h \
|
||||
|
@ -241,6 +243,8 @@ SOURCES += \
|
|||
controls/QskTabButtonSkinlet.cpp \
|
||||
controls/QskTabView.cpp \
|
||||
controls/QskTabViewSkinlet.cpp \
|
||||
controls/QskTextInput.cpp \
|
||||
controls/QskTextInputSkinlet.cpp \
|
||||
controls/QskTextLabel.cpp \
|
||||
controls/QskTextLabelSkinlet.cpp \
|
||||
controls/QskVariantAnimator.cpp \
|
||||
|
|
Loading…
Reference in New Issue