Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows Korean input #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ AbstractKeyHandler::~AbstractKeyHandler() = default;
void AbstractKeyHandler::handle(QEvent* _event)
{
if (_event->type() == QEvent::KeyPress) {
qDebug("press");
handleKeyEvent(static_cast<QKeyEvent*>(_event));
} else if (_event->type() == QEvent::InputMethod) {
qDebug("input");
handleInput(static_cast<QInputMethodEvent*>(_event));
} else if (_event->type() == QEvent::InputMethod) {
qDebug("quesry");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ void SceneHeadingHandler::handleInput(QInputMethodEvent* _event)
void SceneHeadingHandler::complete(const QString& _currentBlockText,
const QString& _cursorBackwardText)
{
qDebug("comp");
//
// Текущая секция
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ void ScreenplayTextEdit::keyPressEvent(QKeyEvent* _event)
}
}

void ScreenplayTextEdit::inputMethodEvent(QInputMethodEvent* _event)
{
BaseTextEdit::inputMethodEvent(_event);

if (!_event->commitString().isEmpty()) {
auto handler = KeyProcessingLayer::KeyPressHandlerFacade::instance(this);
handler->handle(_event);
}
}

bool ScreenplayTextEdit::keyPressEventReimpl(QKeyEvent* _event)
{
bool isEventHandled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class ScreenplayTextEdit : public BaseTextEdit
* @brief Нажатия многих клавиш обрабатываются вручную
*/
void keyPressEvent(QKeyEvent* _event) override;
void inputMethodEvent(QInputMethodEvent* _event) override;

/**
* @brief Обрабатываем специфичные ситуации для редактора сценария
Expand Down
35 changes: 18 additions & 17 deletions src/corelib/ui/widgets/text_edit/completer/completer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Completer::Implementation::Implementation(QWidget* _parent)
: popup(new TreeView(_parent))
, popupDelegate(new TreeDelegate(popup))
{
popup->setEditTriggers(QAbstractItemView::NoEditTriggers);
popup->setHeaderHidden(true);
popup->setRootIsDecorated(false);
popup->setMouseTracking(true);
Expand Down Expand Up @@ -150,23 +151,23 @@ void Completer::showCompleter(const QRect& _rect)
// FIXME: разобраться с проблемами backing store в маке
// FIXME: в винде тоже не работает как хотелось бы, какие-то моргания
//
#ifdef Q_OS_LINUX
const int finalHeight = static_cast<int>(std::min(maxVisibleItems(), completionCount())
* Ui::DesignSystem::treeOneLineItem().height());
if (d->popupHeightAnimation.state() == QVariantAnimation::Stopped) {
d->popup->resize(d->popup->width(), d->popupHeightAnimation.startValue().toInt());
d->popupHeightAnimation.setEndValue(finalHeight);
d->popupHeightAnimation.start();
} else {
d->popup->resize(d->popup->width(), d->popupHeightAnimation.currentValue().toInt());
if (d->popupHeightAnimation.endValue().toInt() != finalHeight) {
d->popupHeightAnimation.stop();
d->popupHeightAnimation.setStartValue(d->popupHeightAnimation.currentValue());
d->popupHeightAnimation.setEndValue(finalHeight);
d->popupHeightAnimation.start();
}
}
#endif
//#ifdef Q_OS_LINUX
// const int finalHeight = static_cast<int>(std::min(maxVisibleItems(), completionCount())
// * Ui::DesignSystem::treeOneLineItem().height());
// if (d->popupHeightAnimation.state() == QVariantAnimation::Stopped) {
// d->popup->resize(d->popup->width(), d->popupHeightAnimation.startValue().toInt());
// d->popupHeightAnimation.setEndValue(finalHeight);
// d->popupHeightAnimation.start();
// } else {
// d->popup->resize(d->popup->width(), d->popupHeightAnimation.currentValue().toInt());
// if (d->popupHeightAnimation.endValue().toInt() != finalHeight) {
// d->popupHeightAnimation.stop();
// d->popupHeightAnimation.setStartValue(d->popupHeightAnimation.currentValue());
// d->popupHeightAnimation.setEndValue(finalHeight);
// d->popupHeightAnimation.start();
// }
// }
//#endif
}

void Completer::closeCompleter()
Expand Down
10 changes: 2 additions & 8 deletions src/corelib/ui/widgets/text_edit/page/page_text_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2417,19 +2417,13 @@ void PageTextEdit::dropEvent(QDropEvent* e)
*/
void PageTextEdit::inputMethodEvent(QInputMethodEvent* e)
{

#ifdef QT_KEYPAD_NAVIGATION
Q_D(PageTextEdit);
#ifdef QT_KEYPAD_NAVIGATION
if (d->control->textInteractionFlags() & Qt::TextEditable
&& QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
setEditFocus(true);
#endif
//
// На десктопе совершенно бесполезное действие, которое приводит только к лишнему срабатыванию
// события обработки текста документа
//
// d->sendControlEvent(e);
Q_UNUSED(e)
d->sendControlEvent(e);
ensureCursorVisible();
}

Expand Down