dead inputcontext related code removed
This commit is contained in:
parent
67052eb60a
commit
7b2e63c7e5
|
@ -93,13 +93,6 @@ QString QskHunspellCompositionModel::polishPreedit( const QString& preedit )
|
||||||
return preedit;
|
return preedit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskHunspellCompositionModel::isComposable( const QStringRef& preedit ) const
|
|
||||||
{
|
|
||||||
// ### What is this function even supposed do?
|
|
||||||
Q_UNUSED( preedit );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QskHunspellCompositionModel::hasIntermediate() const
|
bool QskHunspellCompositionModel::hasIntermediate() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,7 +25,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual bool hasIntermediate() const override;
|
virtual bool hasIntermediate() const override;
|
||||||
virtual QString polishPreedit( const QString& ) override;
|
virtual QString polishPreedit( const QString& ) override;
|
||||||
virtual bool isComposable( const QStringRef& ) const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
|
|
@ -42,8 +42,6 @@ public:
|
||||||
QString preedit;
|
QString preedit;
|
||||||
QTextCharFormat preeditFormat;
|
QTextCharFormat preeditFormat;
|
||||||
QList< QInputMethodEvent::Attribute > preeditAttributes;
|
QList< QInputMethodEvent::Attribute > preeditAttributes;
|
||||||
|
|
||||||
int groupIndex = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QskInputCompositionModel::QskInputCompositionModel( QskInputContext* context ):
|
QskInputCompositionModel::QskInputCompositionModel( QskInputContext* context ):
|
||||||
|
@ -272,40 +270,4 @@ bool QskInputCompositionModel::hasIntermediate() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskInputCompositionModel::isComposable( const QStringRef& preedit ) const
|
|
||||||
{
|
|
||||||
Q_UNUSED( preedit );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QskInputCompositionModel::groupIndex() const
|
|
||||||
{
|
|
||||||
return m_data->groupIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskInputCompositionModel::setGroupIndex( int groupIndex )
|
|
||||||
{
|
|
||||||
if ( groupIndex == m_data->groupIndex )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_data->groupIndex = groupIndex;
|
|
||||||
const QString displayText = polishPreedit( m_data->preedit );
|
|
||||||
m_data->preeditAttributes.first().length = displayText.length();
|
|
||||||
|
|
||||||
QInputMethodEvent event( displayText, m_data->preeditAttributes );
|
|
||||||
sendCompositionEvent( &event );
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector< Qt::Key > QskInputCompositionModel::groups() const
|
|
||||||
{
|
|
||||||
return QVector< Qt::Key >();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QskInputCompositionModel::nextGroupIndex( int& index, bool forward ) const
|
|
||||||
{
|
|
||||||
Q_UNUSED( index );
|
|
||||||
Q_UNUSED( forward );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_QskInputCompositionModel.cpp"
|
#include "moc_QskInputCompositionModel.cpp"
|
||||||
|
|
|
@ -17,8 +17,6 @@ class QskInputCompositionModel : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY( QVector< Qt::Key > groups READ groups NOTIFY groupsChanged )
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QskInputCompositionModel( QskInputContext* context );
|
QskInputCompositionModel( QskInputContext* context );
|
||||||
virtual ~QskInputCompositionModel();
|
virtual ~QskInputCompositionModel();
|
||||||
|
@ -35,22 +33,14 @@ public:
|
||||||
virtual int candidateCount() const;
|
virtual int candidateCount() const;
|
||||||
virtual QString candidate( int ) const;
|
virtual QString candidate( int ) const;
|
||||||
|
|
||||||
int groupIndex() const;
|
|
||||||
void setGroupIndex( int groupIndex );
|
|
||||||
virtual bool nextGroupIndex( int&, bool = true ) const;
|
|
||||||
|
|
||||||
virtual QVector< Qt::Key > groups() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Used for text composition
|
// Used for text composition
|
||||||
virtual bool hasIntermediate() const;
|
virtual bool hasIntermediate() const;
|
||||||
virtual QString polishPreedit( const QString& preedit );
|
virtual QString polishPreedit( const QString& preedit );
|
||||||
virtual bool isComposable( const QStringRef& preedit ) const;
|
|
||||||
|
|
||||||
QskInputContext* context() const;
|
QskInputContext* context() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void groupsChanged( const QVector< Qt::Key >& );
|
|
||||||
void candidatesChanged();
|
void candidatesChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -4,24 +4,63 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskInputContext.h"
|
#include "QskInputContext.h"
|
||||||
|
#include "QskVirtualKeyboard.h"
|
||||||
|
|
||||||
#include "QskInputCompositionModel.h"
|
#include "QskInputCompositionModel.h"
|
||||||
#include "QskPinyinCompositionModel.h"
|
#include "QskPinyinCompositionModel.h"
|
||||||
|
|
||||||
#include <QskVirtualKeyboard.h>
|
|
||||||
#include <QskDialog.h>
|
#include <QskDialog.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
#include <QskControl.h>
|
||||||
#include <QskSetup.h>
|
#include <QskSetup.h>
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
void qskSetLocale( QQuickItem* inputPanel, const QLocale& locale )
|
||||||
|
{
|
||||||
|
if ( auto control = qobject_cast< QskControl* >( inputPanel ) )
|
||||||
|
{
|
||||||
|
control->setLocale( locale );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto mo = inputPanel->metaObject();
|
||||||
|
|
||||||
|
const auto property = mo->property( mo->indexOfProperty( "locale" ) );
|
||||||
|
if ( property.isWritable() )
|
||||||
|
property.write( inputPanel, locale );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QLocale qskLocale( const QQuickItem* inputPanel )
|
||||||
|
{
|
||||||
|
if ( inputPanel == nullptr )
|
||||||
|
return QLocale();
|
||||||
|
|
||||||
|
if ( auto control = qobject_cast< const QskControl* >( inputPanel ) )
|
||||||
|
return control->locale();
|
||||||
|
|
||||||
|
return inputPanel->property( "locale" ).toLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
QskVirtualKeyboard* qskVirtualKeyboard( QQuickItem* inputPanel )
|
||||||
|
{
|
||||||
|
// we should not depend on QskVirtualKeyboard TODO ...
|
||||||
|
|
||||||
|
if ( inputPanel )
|
||||||
|
return inputPanel->findChild< QskVirtualKeyboard* >();
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
class QskInputContext::PrivateData
|
class QskInputContext::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QPointer< QQuickItem > inputItem;
|
QPointer< QQuickItem > inputItem;
|
||||||
QPointer< QskVirtualKeyboard > inputPanel;
|
QPointer< QQuickItem > inputPanel;
|
||||||
|
|
||||||
QskInputCompositionModel* compositionModel;
|
QskInputCompositionModel* compositionModel;
|
||||||
QHash< QLocale, QskInputCompositionModel* > compositionModels;
|
QHash< QLocale, QskInputCompositionModel* > compositionModels;
|
||||||
};
|
};
|
||||||
|
@ -119,23 +158,17 @@ void QskInputContext::update( Qt::InputMethodQueries queries )
|
||||||
auto oldModel = compositionModel();
|
auto oldModel = compositionModel();
|
||||||
|
|
||||||
if( m_data->inputPanel )
|
if( m_data->inputPanel )
|
||||||
m_data->inputPanel->setLocale( locale );
|
qskSetLocale( m_data->inputPanel, locale );
|
||||||
|
|
||||||
auto newModel = compositionModel();
|
auto newModel = compositionModel();
|
||||||
|
|
||||||
if( oldModel != newModel )
|
if( oldModel != newModel )
|
||||||
{
|
{
|
||||||
if( m_data->inputPanel )
|
|
||||||
{
|
|
||||||
m_data->inputPanel->setCandidateBarVisible( newModel->supportsSuggestions() );
|
|
||||||
m_data->inputPanel->disconnect( oldModel );
|
|
||||||
|
|
||||||
connect( newModel, &QskInputCompositionModel::groupsChanged,
|
|
||||||
m_data->inputPanel.data(), &QskVirtualKeyboard::setPreeditGroups );
|
|
||||||
|
|
||||||
connect( newModel, &QskInputCompositionModel::candidatesChanged,
|
connect( newModel, &QskInputCompositionModel::candidatesChanged,
|
||||||
this, &QskInputContext::handleCandidatesChanged );
|
this, &QskInputContext::handleCandidatesChanged );
|
||||||
}
|
|
||||||
|
if ( auto keyboard = qskVirtualKeyboard( m_data->inputPanel ) )
|
||||||
|
keyboard->setCandidateBarVisible( newModel->supportsSuggestions() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +193,7 @@ QRectF QskInputContext::keyboardRect() const
|
||||||
if ( m_data->inputPanel
|
if ( m_data->inputPanel
|
||||||
&& QskDialog::instance()->policy() != QskDialog::TopLevelWindow )
|
&& QskDialog::instance()->policy() != QskDialog::TopLevelWindow )
|
||||||
{
|
{
|
||||||
return m_data->inputPanel->geometry();
|
return qskItemGeometry( m_data->inputPanel );
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inherited::keyboardRect();
|
return Inherited::keyboardRect();
|
||||||
|
@ -226,7 +259,7 @@ bool QskInputContext::isInputPanelVisible() const
|
||||||
|
|
||||||
QLocale QskInputContext::locale() const
|
QLocale QskInputContext::locale() const
|
||||||
{
|
{
|
||||||
return m_data->inputPanel ? m_data->inputPanel->locale() : QLocale();
|
return qskLocale( m_data->inputPanel );
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::LayoutDirection QskInputContext::inputDirection() const
|
Qt::LayoutDirection QskInputContext::inputDirection() const
|
||||||
|
@ -308,7 +341,7 @@ QskInputCompositionModel* QskInputContext::compositionModel() const
|
||||||
return m_data->compositionModels.value( locale(), m_data->compositionModel );
|
return m_data->compositionModels.value( locale(), m_data->compositionModel );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputContext::invokeAction( QInputMethod::Action action, int cursorPosition )
|
void QskInputContext::invokeAction( QInputMethod::Action action, int value )
|
||||||
{
|
{
|
||||||
auto model = compositionModel();
|
auto model = compositionModel();
|
||||||
|
|
||||||
|
@ -316,20 +349,15 @@ void QskInputContext::invokeAction( QInputMethod::Action action, int cursorPosit
|
||||||
{
|
{
|
||||||
case QskVirtualKeyboard::Compose:
|
case QskVirtualKeyboard::Compose:
|
||||||
{
|
{
|
||||||
model->composeKey( static_cast< Qt::Key >( cursorPosition ) );
|
model->composeKey( static_cast< Qt::Key >( value ) );
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QskVirtualKeyboard::SelectGroup:
|
|
||||||
{
|
|
||||||
model->setGroupIndex( cursorPosition );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QskVirtualKeyboard::SelectCandidate:
|
case QskVirtualKeyboard::SelectCandidate:
|
||||||
{
|
{
|
||||||
model->commitCandidate( cursorPosition );
|
model->commitCandidate( value );
|
||||||
|
|
||||||
if ( m_data->inputPanel )
|
if ( auto keyboard = qskVirtualKeyboard( m_data->inputPanel ) )
|
||||||
m_data->inputPanel->setPreeditCandidates( QVector< QString >() );
|
keyboard->setPreeditCandidates( QVector< QString >() );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -355,10 +383,11 @@ void QskInputContext::handleCandidatesChanged()
|
||||||
for( int i = 0; i < count; i++ )
|
for( int i = 0; i < count; i++ )
|
||||||
candidates += model->candidate( i );
|
candidates += model->candidate( i );
|
||||||
|
|
||||||
m_data->inputPanel->setPreeditCandidates( candidates );
|
if ( auto keyboard = qskVirtualKeyboard( m_data->inputPanel ) )
|
||||||
|
keyboard->setPreeditCandidates( candidates );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskInputContext::setInputPanel( QskVirtualKeyboard* inputPanel )
|
void QskInputContext::setInputPanel( QQuickItem* inputPanel )
|
||||||
{
|
{
|
||||||
if ( m_data->inputPanel == inputPanel )
|
if ( m_data->inputPanel == inputPanel )
|
||||||
return;
|
return;
|
||||||
|
@ -377,22 +406,34 @@ void QskInputContext::setInputPanel( QskVirtualKeyboard* inputPanel )
|
||||||
|
|
||||||
if ( inputPanel )
|
if ( inputPanel )
|
||||||
{
|
{
|
||||||
connect( inputPanel, &QskVirtualKeyboard::visibleChanged,
|
// maybe using a QQuickItemChangeListener instead
|
||||||
|
#if 1
|
||||||
|
connect( inputPanel, &QQuickItem::visibleChanged,
|
||||||
this, &QPlatformInputContext::emitInputPanelVisibleChanged );
|
this, &QPlatformInputContext::emitInputPanelVisibleChanged );
|
||||||
|
|
||||||
connect( inputPanel, &QskVirtualKeyboard::keyboardRectChanged,
|
connect( inputPanel, &QQuickItem::xChanged,
|
||||||
this, &QPlatformInputContext::emitKeyboardRectChanged );
|
this, &QPlatformInputContext::emitKeyboardRectChanged );
|
||||||
|
|
||||||
connect( inputPanel, &QskVirtualKeyboard::localeChanged,
|
connect( inputPanel, &QQuickItem::yChanged,
|
||||||
|
this, &QPlatformInputContext::emitKeyboardRectChanged );
|
||||||
|
|
||||||
|
connect( inputPanel, &QQuickItem::widthChanged,
|
||||||
|
this, &QPlatformInputContext::emitKeyboardRectChanged );
|
||||||
|
|
||||||
|
connect( inputPanel, &QQuickItem::heightChanged,
|
||||||
|
this, &QPlatformInputContext::emitKeyboardRectChanged );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( auto control = qobject_cast< QskControl* >( inputPanel ) )
|
||||||
|
{
|
||||||
|
connect( control, &QskControl::localeChanged,
|
||||||
this, &QPlatformInputContext::emitLocaleChanged );
|
this, &QPlatformInputContext::emitLocaleChanged );
|
||||||
|
}
|
||||||
|
|
||||||
if ( model )
|
if ( model )
|
||||||
{
|
{
|
||||||
inputPanel->setCandidateBarVisible(
|
if ( auto keyboard = qskVirtualKeyboard( inputPanel ) )
|
||||||
model->supportsSuggestions() );
|
keyboard->setCandidateBarVisible( model->supportsSuggestions() );
|
||||||
|
|
||||||
connect( model, &QskInputCompositionModel::groupsChanged,
|
|
||||||
inputPanel, &QskVirtualKeyboard::setPreeditGroups );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <qpa/qplatforminputcontext.h>
|
#include <qpa/qplatforminputcontext.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QskVirtualKeyboard;
|
|
||||||
class QskInputCompositionModel;
|
class QskInputCompositionModel;
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class QInputMethodQueryEvent;
|
class QInputMethodQueryEvent;
|
||||||
|
@ -56,7 +55,7 @@ public:
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void handleCandidatesChanged();
|
void handleCandidatesChanged();
|
||||||
void setInputPanel( QskVirtualKeyboard* );
|
void setInputPanel( QQuickItem* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setInputItem( QQuickItem* );
|
void setInputItem( QQuickItem* );
|
||||||
|
|
|
@ -8,15 +8,13 @@
|
||||||
|
|
||||||
#include "pinyinime.h"
|
#include "pinyinime.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class QskPinyinCompositionModel::PrivateData
|
class QskPinyinCompositionModel::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QStringList candidates;
|
QStringList candidates;
|
||||||
QVector< Qt::Key > groups;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QskPinyinCompositionModel::QskPinyinCompositionModel( QskInputContext* context ):
|
QskPinyinCompositionModel::QskPinyinCompositionModel( QskInputContext* context ):
|
||||||
|
@ -59,11 +57,6 @@ QString QskPinyinCompositionModel::candidate( int index ) const
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector< Qt::Key > QskPinyinCompositionModel::groups() const
|
|
||||||
{
|
|
||||||
return m_data->groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QskPinyinCompositionModel::hasIntermediate() const
|
bool QskPinyinCompositionModel::hasIntermediate() const
|
||||||
{
|
{
|
||||||
return m_data->candidates.count() > 0;
|
return m_data->candidates.count() > 0;
|
||||||
|
@ -114,14 +107,3 @@ QString QskPinyinCompositionModel::polishPreedit( const QString& preedit )
|
||||||
|
|
||||||
return preedit;
|
return preedit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskPinyinCompositionModel::isComposable( const QStringRef& preedit ) const
|
|
||||||
{
|
|
||||||
Q_UNUSED( preedit );
|
|
||||||
return false; // ### implement
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskPinyinCompositionModel::handleGroupIndexChanged()
|
|
||||||
{
|
|
||||||
// ### implement
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,17 +21,12 @@ public:
|
||||||
virtual int candidateCount() const override;
|
virtual int candidateCount() const override;
|
||||||
virtual QString candidate( int ) const override;
|
virtual QString candidate( int ) const override;
|
||||||
|
|
||||||
virtual QVector< Qt::Key > groups() const override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Used for text composition
|
// Used for text composition
|
||||||
virtual bool hasIntermediate() const override;
|
virtual bool hasIntermediate() const override;
|
||||||
virtual QString polishPreedit( const QString& preedit ) override;
|
virtual QString polishPreedit( const QString& preedit ) override;
|
||||||
virtual bool isComposable( const QStringRef& preedit ) const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleGroupIndexChanged();
|
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,17 +90,6 @@ public:
|
||||||
setPreferredWidth( columnWidth( 0 ) + 20 );
|
setPreferredWidth( columnWidth( 0 ) + 20 );
|
||||||
|
|
||||||
setScrollableSize( QSizeF( columnWidth( 0 ), rowCount() * rowHeight() ) );
|
setScrollableSize( QSizeF( columnWidth( 0 ), rowCount() * rowHeight() ) );
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// 1) changing the keyboard layouts does not yet work
|
|
||||||
// 2) QskInputPanel does not work properly in the threaded environment
|
|
||||||
#if 1
|
|
||||||
connect( this, &QskListView::selectedRowChanged,
|
|
||||||
this, [ this ] { qskSetup->inputPanel()->setLocale( m_values[selectedRow()].second ); } );
|
|
||||||
#else
|
|
||||||
connect( this, &QskListView::selectedRowChanged,
|
|
||||||
this, [ this ] { QLocale::setDefault( m_values[selectedRow()].second ); } );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int rowCount() const override final
|
virtual int rowCount() const override final
|
||||||
|
@ -146,6 +135,14 @@ public:
|
||||||
return m_values[row].first;
|
return m_values[row].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLocale localeAt( int row ) const
|
||||||
|
{
|
||||||
|
if ( row >= 0 && row < m_values.size() )
|
||||||
|
return m_values[row].second;
|
||||||
|
|
||||||
|
return QLocale();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void append( QLocale locale, const QString& name )
|
inline void append( QLocale locale, const QString& name )
|
||||||
{
|
{
|
||||||
|
@ -179,8 +176,11 @@ int main( int argc, char* argv[] )
|
||||||
box->setSpacing( 10 );
|
box->setSpacing( 10 );
|
||||||
box->setMargins( 20 );
|
box->setMargins( 20 );
|
||||||
|
|
||||||
(void) new LocaleListView( box );
|
auto listView = new LocaleListView( box );
|
||||||
(void) new InputBox( box );
|
auto inputBox = new InputBox( box );
|
||||||
|
|
||||||
|
QObject::connect( listView, &QskListView::selectedRowChanged,
|
||||||
|
inputBox, [ = ]( int row ) { inputBox->setLocale( listView->localeAt( row ) ); } );
|
||||||
|
|
||||||
QskWindow window;
|
QskWindow window;
|
||||||
window.setColor( "PapayaWhip" );
|
window.setColor( "PapayaWhip" );
|
||||||
|
|
|
@ -159,7 +159,7 @@ public:
|
||||||
|
|
||||||
Q_PROPERTY( QStringList skinList READ skinList NOTIFY skinListChanged )
|
Q_PROPERTY( QStringList skinList READ skinList NOTIFY skinListChanged )
|
||||||
|
|
||||||
Q_PRIVATE_PROPERTY( setup(), QskVirtualKeyboard* inputPanel READ inputPanel
|
Q_PRIVATE_PROPERTY( setup(), QQuickItem* inputPanel READ inputPanel
|
||||||
WRITE setInputPanel NOTIFY inputPanelChanged )
|
WRITE setInputPanel NOTIFY inputPanelChanged )
|
||||||
|
|
||||||
Q_PRIVATE_PROPERTY( setup(), QskSetupFlagsProvider controlFlags
|
Q_PRIVATE_PROPERTY( setup(), QskSetupFlagsProvider controlFlags
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "QskSkinManager.h"
|
#include "QskSkinManager.h"
|
||||||
#include "QskGraphicProviderMap.h"
|
#include "QskGraphicProviderMap.h"
|
||||||
#include "QskControl.h"
|
#include "QskControl.h"
|
||||||
#include "QskVirtualKeyboard.h"
|
|
||||||
#include "QskWindow.h"
|
#include "QskWindow.h"
|
||||||
#include "QskObjectTree.h"
|
#include "QskObjectTree.h"
|
||||||
|
|
||||||
|
@ -127,7 +126,7 @@ public:
|
||||||
|
|
||||||
QskGraphicProviderMap graphicProviders;
|
QskGraphicProviderMap graphicProviders;
|
||||||
|
|
||||||
QPointer< QskVirtualKeyboard > inputPanel;
|
QPointer< QQuickItem > inputPanel;
|
||||||
QskSetup::Flags controlFlags;
|
QskSetup::Flags controlFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,7 +261,7 @@ QskGraphicProvider* QskSetup::graphicProvider( const QString& providerId ) const
|
||||||
return m_data->graphicProviders.provider( providerId );
|
return m_data->graphicProviders.provider( providerId );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskSetup::setInputPanel( QskVirtualKeyboard* inputPanel )
|
void QskSetup::setInputPanel( QQuickItem* inputPanel )
|
||||||
{
|
{
|
||||||
if ( m_data->inputPanel == inputPanel )
|
if ( m_data->inputPanel == inputPanel )
|
||||||
return;
|
return;
|
||||||
|
@ -271,7 +270,7 @@ void QskSetup::setInputPanel( QskVirtualKeyboard* inputPanel )
|
||||||
Q_EMIT inputPanelChanged( m_data->inputPanel );
|
Q_EMIT inputPanelChanged( m_data->inputPanel );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskVirtualKeyboard* QskSetup::inputPanel()
|
QQuickItem* QskSetup::inputPanel()
|
||||||
{
|
{
|
||||||
return m_data->inputPanel;
|
return m_data->inputPanel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,8 @@
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QskVirtualKeyboard;
|
|
||||||
class QskSkin;
|
class QskSkin;
|
||||||
class QskSkinlet;
|
class QQuickItem;
|
||||||
class QskControl;
|
|
||||||
class QskGraphicProvider;
|
class QskGraphicProvider;
|
||||||
|
|
||||||
class QLocale;
|
class QLocale;
|
||||||
|
@ -60,8 +58,8 @@ public:
|
||||||
|
|
||||||
QskSkin* skin();
|
QskSkin* skin();
|
||||||
|
|
||||||
void setInputPanel( QskVirtualKeyboard* );
|
void setInputPanel( QQuickItem* );
|
||||||
QskVirtualKeyboard* inputPanel();
|
QQuickItem* inputPanel();
|
||||||
|
|
||||||
void addGraphicProvider( const QString& providerId, QskGraphicProvider* );
|
void addGraphicProvider( const QString& providerId, QskGraphicProvider* );
|
||||||
QskGraphicProvider* graphicProvider( const QString& providerId ) const;
|
QskGraphicProvider* graphicProvider( const QString& providerId ) const;
|
||||||
|
@ -76,7 +74,7 @@ public:
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void skinChanged( QskSkin* );
|
void skinChanged( QskSkin* );
|
||||||
void inputPanelChanged( QskVirtualKeyboard* );
|
void inputPanelChanged( QQuickItem* );
|
||||||
void controlFlagsChanged();
|
void controlFlagsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -271,9 +271,6 @@ public:
|
||||||
qint16 selectedGroup;
|
qint16 selectedGroup;
|
||||||
qint32 candidateOffset;
|
qint32 candidateOffset;
|
||||||
|
|
||||||
QLocale locale;
|
|
||||||
|
|
||||||
QVector< Qt::Key > groups;
|
|
||||||
QVector< QString > candidates;
|
QVector< QString > candidates;
|
||||||
|
|
||||||
KeyTable keyTable[ ModeCount ];
|
KeyTable keyTable[ ModeCount ];
|
||||||
|
@ -506,25 +503,6 @@ QString QskVirtualKeyboard::displayLanguageName() const
|
||||||
return QLocale::languageToString( locale.language() );
|
return QLocale::languageToString( locale.language() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskVirtualKeyboard::setPreeditGroups( const QVector< Qt::Key >& groups )
|
|
||||||
{
|
|
||||||
auto& topRow = m_data->keyTable[ LowercaseMode ].data[ 0 ];
|
|
||||||
|
|
||||||
for( const auto& group : groups )
|
|
||||||
{
|
|
||||||
auto& keyData = topRow[ &group - groups.data() ];
|
|
||||||
keyData.key = group;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_data->groups = groups;
|
|
||||||
selectGroup( -1 );
|
|
||||||
|
|
||||||
if( m_data->mode == LowercaseMode )
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskVirtualKeyboard::setPreeditCandidates( const QVector< QString >& candidates )
|
void QskVirtualKeyboard::setPreeditCandidates( const QVector< QString >& candidates )
|
||||||
{
|
{
|
||||||
if( m_data->candidates == candidates )
|
if( m_data->candidates == candidates )
|
||||||
|
@ -540,7 +518,6 @@ void QskVirtualKeyboard::setCandidateOffset( int candidateOffset )
|
||||||
{
|
{
|
||||||
m_data->candidateOffset = candidateOffset;
|
m_data->candidateOffset = candidateOffset;
|
||||||
|
|
||||||
const auto groupCount = m_data->groups.length();
|
|
||||||
const auto candidateCount = m_data->candidates.length();
|
const auto candidateCount = m_data->candidates.length();
|
||||||
const auto count = std::min( candidateCount, QskVirtualKeyboardCandidateButton::maxCandidates() );
|
const auto count = std::min( candidateCount, QskVirtualKeyboardCandidateButton::maxCandidates() );
|
||||||
const bool continueLeft = m_data->candidateOffset > 0;
|
const bool continueLeft = m_data->candidateOffset > 0;
|
||||||
|
@ -554,7 +531,7 @@ void QskVirtualKeyboard::setCandidateOffset( int candidateOffset )
|
||||||
{
|
{
|
||||||
button->setIndexAndText( i, textForKey( Qt::Key_ApplicationLeft ) );
|
button->setIndexAndText( i, textForKey( Qt::Key_ApplicationLeft ) );
|
||||||
}
|
}
|
||||||
else if( continueRight && ( i == KeyCount - groupCount - 1 ) )
|
else if( continueRight && ( i == KeyCount - 1 ) )
|
||||||
{
|
{
|
||||||
button->setIndexAndText( i, textForKey( Qt::Key_ApplicationRight ) );
|
button->setIndexAndText( i, textForKey( Qt::Key_ApplicationRight ) );
|
||||||
}
|
}
|
||||||
|
@ -727,33 +704,6 @@ void QskVirtualKeyboard::compose( int key )
|
||||||
static_cast< QInputMethod::Action >( Compose ), key );
|
static_cast< QInputMethod::Action >( Compose ), key );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskVirtualKeyboard::selectGroup( int index )
|
|
||||||
{
|
|
||||||
auto& topRow = m_data->keyTable[ m_data->mode ].data[ 0 ];
|
|
||||||
|
|
||||||
if( m_data->selectedGroup >= 0 )
|
|
||||||
{
|
|
||||||
auto group = static_cast< int >( m_data->selectedGroup );
|
|
||||||
topRow[ group ].key &= ~KeyLocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_data->selectedGroup == index )
|
|
||||||
{
|
|
||||||
index = -1; // clear selection
|
|
||||||
}
|
|
||||||
|
|
||||||
m_data->selectedGroup = index;
|
|
||||||
QGuiApplication::inputMethod()->invokeAction(
|
|
||||||
static_cast< QInputMethod::Action >( SelectGroup ), m_data->selectedGroup + 1 );
|
|
||||||
|
|
||||||
if( m_data->selectedGroup < 0 )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
topRow[ m_data->selectedGroup ].key |= KeyLocked;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskVirtualKeyboard::selectCandidate( int index )
|
void QskVirtualKeyboard::selectCandidate( int index )
|
||||||
{
|
{
|
||||||
QGuiApplication::inputMethod()->invokeAction(
|
QGuiApplication::inputMethod()->invokeAction(
|
||||||
|
|
|
@ -84,8 +84,7 @@ public:
|
||||||
enum Action
|
enum Action
|
||||||
{
|
{
|
||||||
Compose = 0x10,
|
Compose = 0x10,
|
||||||
SelectGroup = 0x11,
|
SelectCandidate = 0x11,
|
||||||
SelectCandidate = 0x12,
|
|
||||||
};
|
};
|
||||||
Q_ENUM( Action )
|
Q_ENUM( Action )
|
||||||
|
|
||||||
|
@ -133,7 +132,6 @@ public:
|
||||||
void setCandidateBarVisible( bool visible );
|
void setCandidateBarVisible( bool visible );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setPreeditGroups( const QVector< Qt::Key >& );
|
|
||||||
void setPreeditCandidates( const QVector< QString >& );
|
void setPreeditCandidates( const QVector< QString >& );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue