-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputcontext.cpp
75 lines (60 loc) · 1.46 KB
/
inputcontext.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "inputcontext.h"
#include "inputview.h"
#include <QDesktopWidget>
#include <QDebug>
#include <QApplication>
InputContext::InputContext()
: m_inputView(NULL)
{
}
InputContext::~InputContext()
{
}
bool InputContext::isValid() const
{
return true;
}
QRectF InputContext::keyboardRect() const
{
return (m_inputView) ? m_inputView->rect() : QRectF();
}
void InputContext::showInputPanel()
{
if (!m_inputView)
{
m_inputView = new InputView(this);
}
QRect rect = QApplication::desktop()->availableGeometry();
//pos to bottom center of screen
QRect resultRect = rect;
resultRect.setTop((rect.height() - m_inputView->geometry().height()));
int x = rect.width() / 2 - m_inputView->geometry().width() / 2;
resultRect.setLeft(rect.x() + x);
m_inputView->setGeometry(resultRect);
m_inputView->show();
QPlatformInputContext::showInputPanel();
}
void InputContext::hideInputPanel()
{
if (m_inputView)
{
m_inputView->hide();
}
QPlatformInputContext::hideInputPanel();
}
bool InputContext::isInputPanelVisible() const
{
return (m_inputView) ? m_inputView->isVisible() : false;
}
void InputContext::setFocusObject(QObject *object)
{
if (!m_inputView)
{
m_inputView = new InputView(this);
}
m_inputView->setFocusItem(object);
}
void InputContext::commit()
{
qDebug() << "external commit";
}