qskinny/src/inputpanel/QskInputContext.h

89 lines
2.1 KiB
C
Raw Normal View History

2018-02-06 13:55:35 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
2017-07-21 16:21:34 +00:00
#ifndef QSK_INPUT_CONTEXT_H
#define QSK_INPUT_CONTEXT_H
#include "QskGlobal.h"
#include <QObject>
#include <Qt>
2017-07-21 16:21:34 +00:00
#include <memory>
class QskTextPredictor;
2018-06-12 06:20:48 +00:00
class QskInputPanel;
class QskInputEngine;
2018-04-30 08:03:51 +00:00
class QskPopup;
class QskWindow;
2018-04-03 18:15:20 +00:00
class QQuickItem;
2018-04-20 06:52:26 +00:00
2018-06-12 06:20:48 +00:00
class QSK_EXPORT QskInputContextFactory : public QObject
{
Q_OBJECT
public:
QskInputContextFactory( QObject* parent = nullptr );
virtual ~QskInputContextFactory();
virtual QskTextPredictor* createPredictor( const QLocale& ) const;
virtual QskInputPanel* createPanel() const;
};
class QSK_EXPORT QskInputContext : public QObject
2017-07-21 16:21:34 +00:00
{
Q_OBJECT
using Inherited = QObject;
2017-07-21 16:21:34 +00:00
public:
QskInputContext();
2018-04-01 10:47:44 +00:00
virtual ~QskInputContext();
2018-06-12 06:20:48 +00:00
void setFactory( QskInputContextFactory* );
QskInputContextFactory* factory() const;
2018-04-01 10:47:44 +00:00
2018-06-01 10:00:31 +00:00
QRectF panelRect() const;
2017-07-21 16:21:34 +00:00
2018-06-01 10:00:31 +00:00
void setActive( bool );
bool isActive() const;
2018-06-01 10:00:31 +00:00
QLocale locale() const;
QQuickItem* inputItem() const;
2018-04-03 18:15:20 +00:00
static QskInputContext* instance();
static void setInstance( QskInputContext* );
2018-04-04 10:05:01 +00:00
2018-06-12 06:20:48 +00:00
QskTextPredictor* textPredictor( const QLocale& locale );
2018-06-01 10:00:31 +00:00
Q_SIGNALS:
void activeChanged();
void panelRectChanged();
2017-07-21 16:21:34 +00:00
2018-04-27 11:48:51 +00:00
protected:
virtual bool eventFilter( QObject*, QEvent* ) override;
2018-06-12 06:20:48 +00:00
virtual QskPopup* createEmbeddingPopup( QskInputPanel* );
virtual QskWindow* createEmbeddingWindow( QskInputPanel* );
2018-04-30 08:03:51 +00:00
virtual void showPanel();
virtual void hidePanel();
2017-07-21 16:21:34 +00:00
private:
friend class QskPlatformInputContext;
// called from QskPlatformInputContext
void setFocusObject( QObject* );
void update( const QQuickItem*, Qt::InputMethodQueries );
void processClickAt( int cursorPosition );
void commitPrediction( bool );
2018-06-12 06:20:48 +00:00
void ensurePanel();
2018-04-01 10:47:44 +00:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
2017-07-21 16:21:34 +00:00
};
#endif