QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskInputContext.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_INPUT_CONTEXT_H
7#define QSK_INPUT_CONTEXT_H
8
9#include "QskGlobal.h"
10
11#include <qinputmethod.h>
12#include <qnamespace.h>
13#include <qobject.h>
14
15#include <memory>
16
18class QskInputPanel;
19class QskInputEngine;
20class QskPopup;
21class QskWindow;
22class QQuickItem;
23
24class QSK_EXPORT QskInputContextFactory : public QObject
25{
26 Q_OBJECT
27
28 public:
29 QskInputContextFactory( QObject* parent = nullptr );
30 ~QskInputContextFactory() override;
31
32 std::shared_ptr< QskTextPredictor > setupPredictor( const QLocale& );
33 virtual QskInputPanel* createPanel() const;
34
35 protected:
36 virtual QskTextPredictor* createPredictor( const QLocale& );
37
38 private:
39 class PrivateData;
40 std::unique_ptr< PrivateData > m_data;
41};
42
43class QSK_EXPORT QskInputContext : public QObject
44{
45 Q_OBJECT
46
47 using Inherited = QObject;
48
49 public:
51 ~QskInputContext() override;
52
53 void setFactory( QskInputContextFactory* );
54 QskInputContextFactory* factory() const;
55
56 QRectF panelRect() const;
57
58 void setInputPanelVisible( const QQuickItem*, bool );
59 bool isInputPanelVisible() const;
60
61 QLocale locale() const;
62
63 static QskInputContext* instance();
64 static void setInstance( QskInputContext* );
65
66 std::shared_ptr< QskTextPredictor > textPredictor( const QLocale& locale );
67
68 Q_SIGNALS:
69 void activeChanged();
70 void panelRectChanged();
71
72 protected:
73 virtual void showPanel( const QQuickItem* );
74 virtual void hidePanel( const QQuickItem* );
75
76 private:
77 void hideChannel( const QskInputPanel* );
78
79 // called from QskPlatformInputContext
80 friend class QskPlatformInputContext;
81 virtual void setFocusObject( QObject* );
82 virtual void update( const QQuickItem*, Qt::InputMethodQueries );
83 virtual void invokeAction( QInputMethod::Action, int cursorPosition );
84
85 void commitPrediction( bool );
86
87 class PrivateData;
88 std::unique_ptr< PrivateData > m_data;
89};
90
91#endif