Commit 29b41d1e authored by Victor Yacovlev's avatar Victor Yacovlev

Fxd #kumir2-1777 + Esc-actions redeveloped entirely not to use buggy Qt

parent 6dd61944
......@@ -361,15 +361,16 @@ void EditorInstance::updateInsertMenu()
insertMenu_->addAction(m.action);
connect(m.action, SIGNAL(triggered()), this, SLOT(playMacro()));
if (!m.key.isNull()) {
const QKeySequence ks(escComa+QString(Utils::latinKey(m.key)));
// const QKeySequence ks(escComa+QString(Utils::latinKey(m.key)));
const QKeySequence ks2(escComa + QString(m.key));
if (ks == ks2) {
m.action->setShortcut(ks);
}
else {
const QList<QKeySequence> shortcuts = QList<QKeySequence>() << ks << ks2;
m.action->setShortcuts(shortcuts);
}
m.action->setProperty("fakeShortcut", ks2.toString());
// if (ks == ks2) {
// m.action->setShortcut(ks);
// }
// else {
// const QList<QKeySequence> shortcuts = QList<QKeySequence>() << ks << ks2;
// m.action->setShortcuts(shortcuts);
// }
}
else if (uint(m.extKey) != 0u) {
QString repr;
......@@ -414,10 +415,12 @@ bool EditorInstance::tryEscKeyAction(const QString &text)
}
const QList<Macro> allMacros = systemMacros_ + userMacros_;
const QChar ch = text.at(0).toUpper();
const QChar altCh = Utils::cyrillicKey(ch).toUpper();
foreach (const Macro & m, allMacros) {
bool keyMatch = m.key.toUpper() == ch;
bool altKeyMatch = m.key.toUpper() == altCh;
bool enabled = m.action && m.action->isEnabled();
if (keyMatch && enabled) {
if ( (keyMatch || altKeyMatch) && enabled) {
m.action->trigger();
return true;
}
......@@ -517,7 +520,12 @@ void EditorInstance::updateFromAnalizer()
int newIndent = doc_->indentAt(i);
int diffIndent = newIndent - oldIndent;
if (cursor_->row()==i) {
cursor_->setColumn(qMax(cursor_->column()+2*diffIndent, 0u));
if (doc_->at(i).text.isEmpty()) {
cursor_->setColumn(qMax(2 * newIndent, 0));
}
else {
cursor_->setColumn(qMax(cursor_->column()+2*diffIndent, 0u));
}
}
}
}
......
......@@ -340,4 +340,110 @@ QChar Utils::latinKey(const QChar &cyrillicKey)
}
}
QChar Utils::cyrillicKey(const QChar &latinKey)
{
if (latinKey.toLower()==QString::fromLatin1("q")[0]) {
return QString::fromUtf8("й")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("w")[0]) {
return QString::fromUtf8("ц")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("e")[0]) {
return QString::fromUtf8("у")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("r")[0]) {
return QString::fromUtf8("к")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("t")[0]) {
return QString::fromUtf8("е")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("y")[0]) {
return QString::fromUtf8("н")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("u")[0]) {
return QString::fromUtf8("г")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("i")[0]) {
return QString::fromUtf8("ш")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("o")[0]) {
return QString::fromUtf8("щ")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("p")[0]) {
return QString::fromUtf8("з")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("[")[0]) {
return QString::fromUtf8("х")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("]")[0]) {
return QString::fromUtf8("ъ")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("a")[0]) {
return QString::fromUtf8("ф")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("s")[0]) {
return QString::fromUtf8("ы")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("d")[0]) {
return QString::fromUtf8("в")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("f")[0]) {
return QString::fromUtf8("а")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("g")[0]) {
return QString::fromUtf8("п")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("h")[0]) {
return QString::fromUtf8("р")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("j")[0]) {
return QString::fromUtf8("о")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("k")[0]) {
return QString::fromUtf8("л")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("l")[0]) {
return QString::fromUtf8("д")[0];
}
else if (latinKey.toLower()==QString::fromLatin1(";")[0]) {
return QString::fromUtf8("ж")[0];
}
else if (latinKey.toLower()==QString::fromUtf8("э")[0]) {
return '\'';
}
else if (latinKey.toLower()==QString::fromLatin1("z")[0]) {
return QString::fromUtf8("я")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("x")[0]) {
return QString::fromUtf8("ч")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("c")[0]) {
return QString::fromUtf8("с")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("v")[0]) {
return QString::fromUtf8("м")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("b")[0]) {
return QString::fromUtf8("и")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("n")[0]) {
return QString::fromUtf8("т")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("m")[0]) {
return QString::fromUtf8("ь")[0];
}
else if (latinKey.toLower()==QString::fromLatin1(",")[0]) {
return QString::fromUtf8("б")[0];
}
else if (latinKey.toLower()==QString::fromLatin1(".")[0]) {
return QString::fromUtf8("ю")[0];
}
else if (latinKey.toLower()==QString::fromLatin1("`")[0]) {
return QString::fromUtf8("ё")[0];
}
else {
return latinKey.toLower();
}
}
} // namespace Editor
......@@ -19,6 +19,7 @@ public:
bool teacherMode
);
static QChar latinKey(const QChar & cyrillicKey);
static QChar cyrillicKey(const QChar & latinKey);
};
} // namespace Editor
......
......@@ -23,7 +23,12 @@ void CyrillicMenu::paintEvent(QPaintEvent *event)
opt.rect = actionGeometry(action);
if (!action->isSeparator()) {
opt.text = action->text()+"\t";
opt.text += shortcutToText(action->shortcut());
if (action->property("fakeShortcut").toString().length() > 0) {
opt.text += action->property("fakeShortcut").toString();
}
else {
opt.text += shortcutToText(action->shortcut());
}
}
QRegion adjustedActionReg(opt.rect);
emptyArea -= adjustedActionReg;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment