2018-04-06 15:30:24 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
#ifndef QSK_INPUT_ENGINE_H
|
|
|
|
#define QSK_INPUT_ENGINE_H
|
2018-04-06 15:30:24 +00:00
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
2018-06-11 16:55:48 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <memory>
|
2018-04-06 15:30:24 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
class QskTextPredictor;
|
|
|
|
class QskControl;
|
|
|
|
class QQuickItem;
|
2018-04-10 14:51:35 +00:00
|
|
|
class QLocale;
|
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
class QSK_EXPORT QskInputEngine : public QObject
|
2018-04-10 14:51:35 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
using Inherited = QObject;
|
2018-04-18 17:41:46 +00:00
|
|
|
|
2018-04-10 14:51:35 +00:00
|
|
|
public:
|
2018-06-11 16:55:48 +00:00
|
|
|
QskInputEngine( QObject* parent = nullptr );
|
|
|
|
virtual ~QskInputEngine() override;
|
2018-06-02 15:10:41 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
virtual void attachInputItem( QQuickItem* );
|
|
|
|
virtual void updateInputPanel( Qt::InputMethodQueries );
|
2018-06-02 15:10:41 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
QskControl* panel( bool doCreate );
|
|
|
|
virtual Qt::Alignment panelAlignment() const;
|
2018-04-10 14:51:35 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
virtual QQuickItem* inputProxy() const;
|
|
|
|
virtual QQuickItem* inputItem() const;
|
2018-04-26 12:42:33 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
void commitKey( int keyCode );
|
|
|
|
void commitPredictiveText( int index );
|
2018-04-26 12:42:33 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void activeChanged();
|
|
|
|
void localeChanged();
|
2018-06-01 15:26:22 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
protected:
|
|
|
|
virtual QskControl* createPanel() = 0;
|
|
|
|
virtual void attachToPanel( QQuickItem* ) = 0;
|
2018-04-18 17:41:46 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
virtual void setPredictionEnabled( bool on );
|
|
|
|
virtual void showPrediction( const QStringList& );
|
2018-04-18 17:41:46 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
void applyInput( bool success );
|
|
|
|
void applyText( const QString&, bool isFinal );
|
|
|
|
void applyKey( int keyCode );
|
2018-04-18 17:41:46 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
private:
|
|
|
|
void resetPredictor( const QLocale& );
|
|
|
|
void updatePrediction();
|
2018-06-01 15:26:22 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
void updatePanel();
|
2018-04-10 14:51:35 +00:00
|
|
|
|
2018-06-11 16:55:48 +00:00
|
|
|
void updateLocale( const QLocale& );
|
2018-05-01 09:52:29 +00:00
|
|
|
|
2018-04-10 14:51:35 +00:00
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
2018-04-06 15:30:24 +00:00
|
|
|
|
|
|
|
#endif
|