mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
NavigtionMode: fix bug when input method is enabled
This commit is contained in:
parent
3025e8e01c
commit
30f73cb004
@ -1 +1 @@
|
|||||||
Subproject commit a6a9a31cf64b4a159d360f0ef6ed6cf296f8eca8
|
Subproject commit 5c52cfe2b211b021773d9e3c9559e5358a312381
|
@ -81,19 +81,32 @@ bool IconUtils::isMonochrome(const QString &p_iconContent)
|
|||||||
// Match color-hex codes.
|
// Match color-hex codes.
|
||||||
QRegExp monoRe("#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})");
|
QRegExp monoRe("#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})");
|
||||||
|
|
||||||
int i = 0;
|
QString lastColor = "";
|
||||||
QString cur, next = "";
|
int pos = 0;
|
||||||
while ((i = monoRe.indexIn(p_iconContent, i)) != -1) {
|
while (pos < p_iconContent.size()) {
|
||||||
if (i != 0) {
|
int idx = p_iconContent.indexOf(monoRe, pos);
|
||||||
next = cur;
|
if (idx == -1) {
|
||||||
}
|
break;
|
||||||
cur = monoRe.cap(1);
|
|
||||||
if (next != "" && cur != next) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i += monoRe.matchedLength();
|
auto curColor = monoRe.cap(1);
|
||||||
|
if (curColor.size() == 3) {
|
||||||
|
for (int i = curColor.size() - 1; i >= 0; --i) {
|
||||||
|
curColor.insert(i, curColor[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastColor != curColor) {
|
||||||
|
if (lastColor.isEmpty()) {
|
||||||
|
lastColor = curColor;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += monoRe.matchedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <core/configmgr.h>
|
#include <core/configmgr.h>
|
||||||
#include <core/coreconfig.h>
|
#include <core/coreconfig.h>
|
||||||
#include <utils/widgetutils.h>
|
#include <utils/widgetutils.h>
|
||||||
|
#include <vtextedit/vtextedit.h>
|
||||||
|
|
||||||
#include "navigationmode.h"
|
#include "navigationmode.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
@ -73,6 +75,9 @@ void NavigationModeMgr::triggerNavigationMode()
|
|||||||
|
|
||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
|
|
||||||
|
// Qt bug: the shortcut key sequence may be swallowed by input method first.
|
||||||
|
vte::VTextEdit::forceInputMethodDisabled(true);
|
||||||
|
|
||||||
for (auto &target : m_targets) {
|
for (auto &target : m_targets) {
|
||||||
target.m_available = true;
|
target.m_available = true;
|
||||||
target.m_target->showNavigation();
|
target.m_target->showNavigation();
|
||||||
@ -89,6 +94,8 @@ void NavigationModeMgr::exitNavigationMode()
|
|||||||
m_activated = false;
|
m_activated = false;
|
||||||
qApp->removeEventFilter(this);
|
qApp->removeEventFilter(this);
|
||||||
|
|
||||||
|
vte::VTextEdit::forceInputMethodDisabled(false);
|
||||||
|
|
||||||
for (auto &target : m_targets) {
|
for (auto &target : m_targets) {
|
||||||
target.m_available = true;
|
target.m_available = true;
|
||||||
target.m_target->hideNavigation();
|
target.m_target->hideNavigation();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user