加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
inputcontext.cpp 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
lgao622 提交于 2016-12-03 16:41 . add project in github
#include <QtDebug>
#include <QEvent>
#include <QApplication>
#include <QDesktopWidget>
#include <QtWidgets/QMainWindow>
#include <QInputDialog>
#include "inputcontext.h"
#include "pinyininputmethod.h"
#define WINDOW_HEIGHT QApplication::desktop()->height()
static InputContext *instance = NULL;
InputContextPrivate::InputContextPrivate() : KeyBoard(0)
{
}
InputContextPrivate::~InputContextPrivate()
{
if (KeyBoard)
delete KeyBoard;
}
InputContext* InputContext::Instance()
{
return instance;
}
InputContext::InputContext() :
QPlatformInputContext()
{
d = new InputContextPrivate();
instance = this;
}
InputContext::~InputContext()
{
}
bool InputContext::isValid() const
{
return true;
}
QRectF InputContext::keyboardRect() const
{
return (d->KeyBoard) ? d->KeyBoard->rect() : QRectF();
}
void InputContext::showInputPanel()
{
if (!d->KeyBoard) {
d->KeyBoard = new KeyboardForm();
connect(d->KeyBoard, SIGNAL(sendKeyToFocusItem(QString)), &d->keyEventDispatcher, SLOT(sendKeyToFocusItem(QString)));
}
d->KeyBoard->show();
d->KeyBoard->move(d->KeyBoard->x(), WINDOW_HEIGHT - d->KeyBoard->height());
QPlatformInputContext::showInputPanel();
}
void InputContext::hideInputPanel()
{
if (d->KeyBoard)
d->KeyBoard->hide();
QPlatformInputContext::hideInputPanel();
}
bool InputContext::isInputPanelVisible() const
{
return (d->KeyBoard) ? d->KeyBoard->isVisible() : false;
}
void InputContext::setFocusObject(QObject *object)
{
d->keyEventDispatcher.setFocusItem(object);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化