#include "LtsVirtualKeyboard.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace LtsVirtualKeyboard { static LtsVirtualKeyboard *s_ltsVirtualKeyboard = nullptr; static bool lastState = false; LtsVirtualKeyboard::LtsVirtualKeyboard(LtsSession::LtsSession *session, QWidget *activeForm, bool onlyNumericPad, QWidget *parent) : QWidget(parent) , m_te(nullptr) , m_le(nullptr) , m_nextInput(nullptr) , m_activeWindow(activeForm) , m_echoMode(false) , m_enablePasswordEcho(false) , m_numericPad(onlyNumericPad) , m_isAlt(false) , m_isCap(false) , m_enableEnter(true) , m_ready(false) , m_height(0) , m_clipboard(QApplication::clipboard()) , m_session(session) { setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint | Qt::Dialog); setFocusPolicy(Qt::NoFocus); setWindowTitle(QString()); connect(m_activeWindow, &QWidget::destroyed, this, [this](QObject *obj) { if (static_cast(m_activeWindow) == obj) m_activeWindow = nullptr; }); } LtsVirtualKeyboard::~LtsVirtualKeyboard() { } LtsVirtualKeyboard *LtsVirtualKeyboard::getInstance(LtsSession::LtsSession *session, QWidget *activeForm, bool onlyNumericPad, QWidget *parent) { onlyNumericPad = false; if (s_ltsVirtualKeyboard && onlyNumericPad == lastState ) { if (activeForm) s_ltsVirtualKeyboard->setActiveWindw(activeForm); if (parent) s_ltsVirtualKeyboard->setParent(parent); s_ltsVirtualKeyboard->setSession(session); return s_ltsVirtualKeyboard; } cleanupLtsVirtualKeyboard(); lastState = onlyNumericPad; s_ltsVirtualKeyboard = new LtsVirtualKeyboard(session, activeForm, onlyNumericPad, parent); s_ltsVirtualKeyboard->createKeyboard(); qAddPostRoutine(&cleanupLtsVirtualKeyboard); return s_ltsVirtualKeyboard; } void LtsVirtualKeyboard::cleanupLtsVirtualKeyboard() { delete s_ltsVirtualKeyboard; s_ltsVirtualKeyboard = nullptr; } void LtsVirtualKeyboard::enableSwitchingEcho(bool status) { m_enablePasswordEcho = status; } bool LtsVirtualKeyboard::isEnabledSwitchingEcho() const { return (m_enablePasswordEcho); } LtsKeyPushButton *LtsVirtualKeyboard::createNewKey(const QString &keyValue, const QString ¬TranslatedValue, const QString ¬TranslatedValueAlt) { QString altText = notTranslatedValueAlt; if (altText.isEmpty()) altText = notTranslatedValue; LtsKeyPushButton *tmp = new LtsKeyPushButton(notTranslatedValue, altText, this); QString style = QStringLiteral(DEFAULT_STYLE_BUTTON) + QStringLiteral(DEFAULT_BACKGROUND_BUTTON); QSize imageDim; int width = 0, height = 0; imageDim.setWidth(32); imageDim.setHeight(32); if (IS_PASSWORD(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setIcon(QPixmap(QStringLiteral(":/TastieraVirtuale/normalEcho"))); } else if (IS_PASTE(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setEnabled(false); tmp->setIcon(QPixmap(QStringLiteral("icon:edit-paste.svg"))); tmp->setToolButtonStyle(Qt::ToolButtonIconOnly); } else if (IS_COPY(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setIcon(QPixmap(QStringLiteral("icon:edit-copy.svg"))); tmp->setToolButtonStyle(Qt::ToolButtonIconOnly); } else if (IS_CUT_LEFT(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setIcon(QPixmap(QStringLiteral("icon:edit-cut.svg"))); tmp->setToolButtonStyle(Qt::ToolButtonIconOnly); } else if (IS_CAPS(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setIcon(QPixmap(QStringLiteral("icon:shift_capslook.svg"))); tmp->setToolButtonStyle(Qt::ToolButtonIconOnly); } else if (IS_RETURN(keyValue) == true) { tmp->setIconSize(imageDim); tmp->setIcon(QPixmap(QStringLiteral("icon:carriage_return.svg"))); tmp->setToolButtonStyle(Qt::ToolButtonIconOnly); } tmp->setStyleSheet(style); width = 54; height = 40; #ifdef TABLET_MODE width = width * 2.0; height = height * 2.0; #endif tmp->setMinimumSize(width, height); tmp->setMaximumSize(width, height); if (IS_SPACE(keyValue) == true) { tmp->setMinimumSize(width * 20, height); tmp->setMaximumSize(width * 20, height); } if (IS_FIN(keyValue) == true) { tmp->setStyleSheet(style + QStringLiteral(CHANGED_BACKGROUND_BUTTON)); } tmp->setText(keyValue); tmp->setCapsMode(m_isCap); tmp->setObjectName(keyValue); return tmp; } void LtsVirtualKeyboard::controlKeyEcho(QWidget *control) { Q_UNUSED(control); QString textToSearch; LtsKeyPushButton *echoControlKey; QString tmpStyle; QPushButton *pasteButton = findChild(KEY_PASTE); QPushButton *cutButton = findChild(KEY_CUT_LEFT); QPushButton *copyButton = findChild(KEY_COPY); textToSearch = KEY_HIDECHAR; if (pasteButton != nullptr && copyButton != nullptr) { cutButton->setEnabled(true); copyButton->setEnabled(true); if (m_clipboard->text().length() > 0) pasteButton->setEnabled(true); else pasteButton->setEnabled(false); } echoControlKey = findChild(textToSearch); if (echoControlKey != nullptr) { echoControlKey->setStyleSheet(QStringLiteral(DEFAULT_STYLE_BUTTON) + QStringLiteral(DEFAULT_BACKGROUND_BUTTON) + tmpStyle); echoControlKey->setIcon(QPixmap(QStringLiteral(":/TastieraVirtuale/normalEcho"))); echoControlKey->repaint(); QApplication::processEvents(); } } void LtsVirtualKeyboard::setTextToCurrentWidget(const QString &text) { if (m_nextInput->inherits("QLineEdit")) qobject_cast(m_nextInput)->setText(text); if (m_nextInput->inherits("QTextEdit")) qobject_cast(m_nextInput)->setText(text); if (m_nextInput->inherits("QPlainTextEdit")) qobject_cast(m_nextInput)->setPlainText(text); if (m_nextInput->inherits("QSpinBox")) qobject_cast(m_nextInput)->setValue(text.toInt()); if (m_nextInput->inherits("QDoubleSpinBox")) qobject_cast(m_nextInput)->setValue(text.toDouble()); } QString LtsVirtualKeyboard::getTextFromCurrentWidget() { if (qobject_cast(m_nextInput)) return qobject_cast(m_nextInput)->text(); if (qobject_cast(m_nextInput)) return qobject_cast(m_nextInput)->toPlainText(); if (qobject_cast(m_nextInput)) return qobject_cast(m_nextInput)->toPlainText(); if (qobject_cast(m_nextInput)) return QString::number(qobject_cast(m_nextInput)->value()); if (qobject_cast(m_nextInput)) return QString::number(qobject_cast(m_nextInput)->value()); return QString(); } QString LtsVirtualKeyboard::getCurretText() const { if (m_te->isVisible()) return m_te->toPlainText(); return m_le->text(); } void LtsVirtualKeyboard::setCurrentText(const QString &text) { if(m_te->isVisible()) m_te->setText(text); else m_le->setText(text); } int LtsVirtualKeyboard::getCurrentTextCursorPosition() { if(m_te->isVisible()) return m_te->textCursor().position(); return m_le->cursorPosition(); } void LtsVirtualKeyboard::setCurrentTextCursorPosition(int cursor) { if(m_te->isVisible()) { QTextCursor cur = m_te->textCursor(); cur.setPosition(cursor); m_te->setTextCursor(cur); }else { m_le->setCursorPosition(cursor); } } bool LtsVirtualKeyboard::hasSelection() const { if(m_te->isVisible()) return m_te->textCursor().hasSelection(); return m_le->hasSelectedText(); } QString LtsVirtualKeyboard::getSelectedText() const { if (m_te->isVisible()) return m_te->textCursor().selectedText(); return m_le->selectedText(); } int LtsVirtualKeyboard::getSelectionStart() const { if (m_te->isVisible()) return m_te->textCursor().selectionStart(); return m_le->selectionStart(); } void LtsVirtualKeyboard::reinit() { qDeleteAll(findChildren()); m_te->deleteLater(); m_le->deleteLater(); delete layout(); createKeyboard(); } void LtsVirtualKeyboard::receiptChildKey(QWidget *focusThisControl, QKeyEvent *event, bool reset) { if (!m_ready) return; if (reset == true) { m_nextInput = getNextTextbox(focusThisControl, true); return; } if (m_nextInput == nullptr || !event) { return; } QString newKey = event->text(); QString tmpReceiptString = getCurretText(); int tmpPos = getCurrentTextCursorPosition(); if (isNumericPad()) newKey = newKey.trimmed(); if (NO_SPECIAL_KEY(newKey) == false) { if (IS_RETURN(newKey) == true) { tmpReceiptString = tmpReceiptString.insert(tmpPos, QChar(13)); setTextToCurrentWidget(tmpReceiptString); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(tmpPos+1); } else if (IS_FIN(newKey) == true) { hide(true); if (!qobject_cast(m_nextInput) && !qobject_cast(m_nextInput)) { QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QApplication::sendEvent(m_nextInput, &event); } m_nextInput->clearFocus(); m_nextInput = nullptr; return; } else if (IS_BACK(newKey) == true) { if (!hasSelection()) { tmpReceiptString = tmpReceiptString.remove(tmpPos - 1, 1); setTextToCurrentWidget(tmpReceiptString); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(tmpPos-1); } else { if (tmpPos - 1 >= 0) { int selectionStart = getSelectionStart(); tmpReceiptString = tmpReceiptString.remove(selectionStart, getSelectedText().size()); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(selectionStart); setTextToCurrentWidget(tmpReceiptString); } } } else if (IS_CANC(newKey) == true) { tmpReceiptString = tmpReceiptString.remove(tmpPos, 1); setTextToCurrentWidget(tmpReceiptString); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(tmpPos); } else if (IS_COPY(newKey) == true || IS_CUT_LEFT(newKey) == true) { LtsKeyPushButton *button = findChild(KEY_PASTE); if (button != nullptr) { if (hasSelection()) { m_clipboard->setText(getSelectedText()); if (IS_CUT_LEFT(newKey) == true) { int selectionStart =getSelectionStart(); tmpReceiptString = tmpReceiptString.remove(selectionStart, getSelectedText().size()); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(selectionStart); setTextToCurrentWidget(tmpReceiptString); } button->setEnabled(true); } else button->setEnabled(false); } } else if (IS_PASTE(newKey) == true) { tmpReceiptString.insert(tmpPos, m_clipboard->text()); setTextToCurrentWidget(tmpReceiptString); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(tmpPos + m_clipboard->text().length()); } else if (IS_ALT(newKey) == true || IS_ALT2(newKey) == true) { QList kList = findChildren(); m_isAlt = !m_isAlt; auto i = kList.begin(); for (; i != kList.end(); ++i) { LtsKeyPushButton *tw = *i; tw->setAltMode(m_isAlt); } } else if (IS_CAPS(newKey) == true) { QList kList = findChildren(); m_isCap = !m_isCap; auto i = kList.begin(); for (; i != kList.end(); ++i) { LtsKeyPushButton *tw = *i; tw->setCapsMode(m_isCap); } } } else { if (getSelectedText().size()) { tmpPos = getSelectionStart(); tmpReceiptString = tmpReceiptString.remove(tmpPos, getSelectedText().size()); } tmpReceiptString = tmpReceiptString.insert(tmpPos, newKey); setTextToCurrentWidget(tmpReceiptString); setCurrentText(tmpReceiptString); setCurrentTextCursorPosition(tmpPos + 1); } } void LtsVirtualKeyboard::switchKeyEchoMode(QWidget *control) { setStatusEchoMode(!statusEchoMode()); controlKeyEcho(control); } QWidget *LtsVirtualKeyboard::getNextTextbox(QWidget *thisControl, bool reset) { QWidget *tmpInputFound = nullptr; m_echoMode = false; if (m_activeWindow == nullptr) { m_nextInput = nullptr; return (nullptr); } if (thisControl != nullptr) { if (m_activeWindow->findChild(thisControl->objectName()) == 0 && m_activeWindow->findChild(thisControl->objectName()) == 0 && m_activeWindow->findChild(thisControl->objectName()) == 0 && m_activeWindow->findChild(thisControl->objectName()) == 0 && m_activeWindow->findChild(thisControl->objectName()) == 0) { return (nullptr); } else { return setCurrentTextStyle(thisControl); } } if (m_nextInput == nullptr || reset == true) m_nextInput = m_activeWindow->nextInFocusChain(); else m_nextInput = m_nextInput->nextInFocusChain(); do { if (m_nextInput->inherits("QLineEdit") == true) { tmpInputFound = qobject_cast(m_nextInput); return setCurrentTextStyle(tmpInputFound); } if (m_nextInput->inherits("QTextEdit") == true) { tmpInputFound = qobject_cast(m_nextInput); return setCurrentTextStyle(tmpInputFound); } if (m_nextInput->inherits("QPlainTextEdit") == true) { tmpInputFound = qobject_cast(m_nextInput); return setCurrentTextStyle(tmpInputFound); } if (m_nextInput->inherits("QSpinBox") == true) { tmpInputFound = qobject_cast(m_nextInput); return setCurrentTextStyle(tmpInputFound); } if (m_nextInput->inherits("QDoubleSpinBox") == true) { tmpInputFound = qobject_cast(m_nextInput); return setCurrentTextStyle(tmpInputFound); } m_nextInput = m_nextInput->nextInFocusChain(); } while (m_nextInput != nullptr); return nullptr; } QWidget *LtsVirtualKeyboard::setCurrentTextStyle(QWidget *control) { m_nextInput = control; control->setStyleSheet(QStringLiteral(STYLE_FOCUS_TEXT)); return (control); } QWidget *LtsVirtualKeyboard::setDefaultTextStyle(QWidget *control) { if (!m_nextInput) return nullptr; QLineEdit le; control->setStyleSheet(le.styleSheet()); return (control); } QSize LtsVirtualKeyboard::availableDesktopSize() const { #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) return QApplication::desktop()->availableGeometry().size(); #else const QWindow *win = window()->windowHandle(); const QScreen *scr = (win && win->screen()) ? win->screen() : QGuiApplication::primaryScreen(); return scr ? scr->availableSize() : QSize(1280, 1024); #endif } void LtsVirtualKeyboard::init_keyboard(QWidget *focusThisControl) { m_nextInput = focusThisControl; checkInput(); receiptChildKey(focusThisControl, nullptr, true); } void LtsVirtualKeyboard::show(QWidget *first, bool frameless) { Q_UNUSED(frameless); init_keyboard(first); if (windowState() == Qt::WindowMinimized) setWindowState(Qt::WindowNoState); setStatusEchoMode(false); setVisible(true); const auto availSize = availableDesktopSize(); move((availSize.width() - width()) / 2, (availSize.height() - height()) - 10); QTimer::singleShot(300, this, [this]() { m_ready = true; }); } void LtsVirtualKeyboard::borderFrame(bool visible) { if (visible == true) setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::MSWindowsFixedSizeDialogHint); else setWindowFlags(Qt::Window | Qt::FramelessWindowHint); } void LtsVirtualKeyboard::checkInput() { m_enableEnter = false; m_echoMode = false; m_le->setVisible(true); m_te->setVisible(false); if (qobject_cast(m_nextInput)) { QLineEdit *le = qobject_cast(m_nextInput); m_le->setEchoMode(le->echoMode()); } if (qobject_cast(m_nextInput) || qobject_cast(m_nextInput)) { m_le->setVisible(false); m_te->setVisible(true); m_enableEnter = true; } LtsKeyPushButton *crButton = findChild(KEY_RETURN); if (crButton) { crButton->setEnabled(m_enableEnter); } if (m_te->isVisible()) setMaximumHeight(m_height+m_te->height()); else setMaximumHeight(m_height+m_le->height()); } bool LtsVirtualKeyboard::isNumericPad() const { return (m_numericPad); } void LtsVirtualKeyboard::focusThis(QWidget *control, bool numpad) { m_ready = false; if (m_activeWindow != nullptr) { if (m_numericPad != numpad) { m_numericPad = numpad; reinit(); } if (m_nextInput != nullptr) m_nextInput = setDefaultTextStyle(m_nextInput); init_keyboard(control); controlKeyEcho(control); setCurrentText(getTextFromCurrentWidget()); if(m_te->isVisible()) m_te->moveCursor(QTextCursor::Start); else m_le->end(false); if (m_nextInput) setWindowTitle(m_nextInput->toolTip()); } QTimer::singleShot(300, this, [this]() { m_ready = true; }); const auto availSize = availableDesktopSize(); if (isNumericPad()) move((availSize.width() - width()) / 2, (availSize.height() - height()) - 10); else move(10, availSize.height() - height() - 10); } void LtsVirtualKeyboard::closeEvent(QCloseEvent *event) { event->ignore(); } void LtsVirtualKeyboard::hide(bool changeColor) { m_ready = false; try { if (changeColor == true) { if (m_activeWindow != nullptr) setDefaultTextStyle(m_nextInput); } if (!parent()) setVisible(false); } catch (...) { } } void LtsVirtualKeyboard::createKeyboard() { LtsKeyPushButton *tmp = nullptr; QVBoxLayout *tmpVLayout = new QVBoxLayout; QHBoxLayout *tmpLayout = new QHBoxLayout; QString tmpStyle; QString backspace; m_ready = false; m_te = new QTextEdit(this); m_te->setMaximumHeight(210); m_te->setMinimumHeight(210); m_te->setObjectName(QStringLiteral("internalLE")); tmpVLayout->addWidget(m_te); m_te->hide(); m_le = new QLineEdit(this); m_le->setObjectName(QStringLiteral("internalLE")); tmpVLayout->addWidget(m_le); if (isNumericPad() == true) { QGridLayout *gridLayout = new QGridLayout(this); gridLayout->addLayout(tmpVLayout,0,0); for (short i = 49; i <= 51; i++) tmpLayout->addWidget(createNewKey(QChar(i), QString::number(i - 48), QString::number(i - 48))); gridLayout->addLayout(tmpLayout, 3, 0); tmpLayout = new QHBoxLayout(this); for (short i = 52; i <= 54; i++) tmpLayout->addWidget(createNewKey(QChar(i), QString::number(i - 48), QString::number(i - 48))); gridLayout->addLayout(tmpLayout, 2, 0); tmpLayout = new QHBoxLayout(this); for (short i = 55; i <= 57; i++) tmpLayout->addWidget(createNewKey(QChar(i), QString::number(i - 48), QString::number(i - 48))); gridLayout->addLayout(tmpLayout, 1, 0); tmpLayout = new QHBoxLayout(this); tmp = createNewKey(QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("0")); tmp->setMinimumSize(tmp->minimumSize().width() * 2, tmp->minimumSize().height()); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(QStringLiteral("."), QStringLiteral(" . "), QStringLiteral(" . "))); gridLayout->addLayout(tmpLayout, 4, 0); tmpLayout = new QHBoxLayout(this); tmpLayout->addWidget(createNewKey(QStringLiteral(","), QStringLiteral(" , "), QStringLiteral(" , "))); backspace = QStringLiteral("BACKSPACE"); tmpStyle = (KEY_BACKSPACE); tmp = createNewKey(tmpStyle, backspace); tmp->setMaximumWidth(tmp->maximumWidth() * 1.5); tmp->setMinimumWidth(tmp->minimumWidth() * 1.5); tmpLayout->addWidget(tmp); tmp = createNewKey(KEY_FIN,KEY_FIN); tmp->setMaximumWidth(tmp->maximumWidth() * 1.5); tmp->setMinimumWidth(tmp->minimumWidth() * 1.5); tmpLayout->addWidget(tmp); gridLayout->addLayout(tmpLayout, 5, 0); setLayout(gridLayout); setMaximumWidth(tmp->width()*3); m_height= tmp->height()*5; } else { tmpLayout->addWidget(createNewKey(QStringLiteral("^"), QStringLiteral("^"), QStringLiteral("^"))); tmpLayout->addWidget(createNewKey(QStringLiteral("1"), QStringLiteral("1"), QStringLiteral("!"))); tmpLayout->addWidget(createNewKey(QStringLiteral("2"), QStringLiteral("2"), QStringLiteral("\""))); tmpLayout->addWidget(createNewKey(QStringLiteral("3"), QStringLiteral("3"), QChar(207))); tmpLayout->addWidget(createNewKey(QStringLiteral("4"), QStringLiteral("4"), QStringLiteral("$"))); tmpLayout->addWidget(createNewKey(QStringLiteral("5"), QStringLiteral("5"), QStringLiteral("%"))); tmpLayout->addWidget(createNewKey(QStringLiteral("6"), QStringLiteral("6"), QStringLiteral("&&"))); tmpLayout->addWidget(createNewKey(QStringLiteral("7"), QStringLiteral("7"), QStringLiteral("/"))); tmpLayout->addWidget(createNewKey(QStringLiteral("8"), QStringLiteral("8"), QStringLiteral("("))); tmpLayout->addWidget(createNewKey(QStringLiteral("9"), QStringLiteral("9"), QStringLiteral(")"))); tmpLayout->addWidget(createNewKey(QStringLiteral("0"), QStringLiteral("0"), QStringLiteral("="))); tmpLayout->addWidget(createNewKey(QChar(223), QChar(223), QStringLiteral("?"))); tmpLayout->addWidget(createNewKey(QStringLiteral("`"), QChar(180), QStringLiteral("`"))); tmpLayout->addWidget(createNewKey(QStringLiteral("["), QStringLiteral("["), QStringLiteral("{"))); backspace = QStringLiteral("<----"); tmpStyle = KEY_BACKSPACE; tmp = createNewKey(tmpStyle, backspace); tmp->setMaximumWidth(tmp->maximumWidth() * 1.2); tmp->setMinimumWidth(tmp->maximumWidth() * 1.2); tmpLayout->addWidget(tmp); tmpLayout->insertStretch(-1, 1); tmpVLayout->addLayout(tmpLayout); tmpLayout = new QHBoxLayout(); QVBoxLayout *layoutReturn = new QVBoxLayout(); tmp = createNewKey(KEY_ALT, KEY_ALT, KEY_ALT2); tmp->setMaximumWidth(tmp->maximumWidth()); tmp->setMinimumWidth(tmp->minimumWidth()); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(QStringLiteral("Q"), QStringLiteral("Q"), QStringLiteral("@"))); tmpLayout->addWidget(createNewKey(QStringLiteral("W"), QStringLiteral("W"))); tmpLayout->addWidget(createNewKey(QStringLiteral("E"), QStringLiteral("E"), QChar(8364))); tmpLayout->addWidget(createNewKey(QStringLiteral("R"), QStringLiteral("R"))); tmpLayout->addWidget(createNewKey(QStringLiteral("T"), QStringLiteral("T"))); tmpLayout->addWidget(createNewKey(QStringLiteral("Z"), QStringLiteral("Z"))); tmpLayout->addWidget(createNewKey(QStringLiteral("U"), QStringLiteral("U"))); tmpLayout->addWidget(createNewKey(QStringLiteral("I"), QStringLiteral("I"))); tmpLayout->addWidget(createNewKey(QStringLiteral("O"), QStringLiteral("O"))); tmpLayout->addWidget(createNewKey(QStringLiteral("P"), QStringLiteral("P"))); tmpLayout->addWidget(createNewKey(QChar(220), QChar(220))); tmpLayout->addWidget(createNewKey(QStringLiteral("+"), QStringLiteral("+"), QStringLiteral("*"))); tmpLayout->addWidget(createNewKey(QStringLiteral("]"), QStringLiteral("]"), QStringLiteral("}"))); tmpStyle = KEY_CANC; tmp = createNewKey(tmpStyle, QStringLiteral("->")); tmp->setMaximumWidth(tmp->maximumWidth()); tmp->setMinimumWidth(tmp->minimumWidth()); tmpLayout->addWidget(tmp); tmpLayout->insertStretch(-1, 1); layoutReturn->addLayout(tmpLayout, 1); tmpLayout = new QHBoxLayout(); tmp = createNewKey(KEY_CAPS, KEY_CAPS); tmp->setMinimumWidth(tmp->minimumWidth() * 1.5 + 5); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(QStringLiteral("A"), QStringLiteral("A"))); tmpLayout->addWidget(createNewKey(QStringLiteral("S"), QStringLiteral("S"))); tmpLayout->addWidget(createNewKey(QStringLiteral("D"), QStringLiteral("D"))); tmpLayout->addWidget(createNewKey(QStringLiteral("F"), QStringLiteral("F"))); tmpLayout->addWidget(createNewKey(QStringLiteral("G"), QStringLiteral("G"))); tmpLayout->addWidget(createNewKey(QStringLiteral("H"), QStringLiteral("H"))); tmpLayout->addWidget(createNewKey(QStringLiteral("J"), QStringLiteral("J"))); tmpLayout->addWidget(createNewKey(QStringLiteral("K"), QStringLiteral("K"))); tmpLayout->addWidget(createNewKey(QStringLiteral("L"), QStringLiteral("L"))); tmpLayout->addWidget(createNewKey(QChar(214), QChar(214))); tmpLayout->addWidget(createNewKey(QChar(196), QChar(196))); tmpLayout->addWidget(createNewKey(QStringLiteral("'"), QStringLiteral("'"), QStringLiteral("#"))); tmpLayout->addWidget(createNewKey(QStringLiteral("|"), QStringLiteral("|"), QStringLiteral("\\"))); tmpLayout->insertStretch(-1, 1); layoutReturn->setSpacing(5); layoutReturn->addLayout(tmpLayout, 1); tmpLayout = new QHBoxLayout(); tmpLayout->addLayout(layoutReturn, 1); tmp = createNewKey(KEY_RETURN, QStringLiteral("RETURN")); tmp->setEnabled(m_enableEnter); tmp->setMaximumWidth(tmp->maximumWidth() * 1.4); tmp->setMinimumWidth(tmp->minimumWidth() * 1.4); tmp->setMinimumHeight(tmp->minimumHeight() * 1.4); tmpLayout->addWidget(tmp, 2); tmpVLayout->addLayout(tmpLayout); tmpLayout = new QHBoxLayout(); tmp = createNewKey(KEY_CUT_LEFT, KEY_CUT_LEFT); tmp->setMaximumWidth(tmp->maximumWidth() * 1.2); tmp->setMinimumWidth(tmp->minimumWidth() * 1.2); tmpLayout->addWidget(tmp); tmpLayout->addWidget(createNewKey(QStringLiteral("<"), QStringLiteral("<"), QStringLiteral(">"))); tmpLayout->addWidget(createNewKey(QStringLiteral("Y"), QStringLiteral("Y"))); tmpLayout->addWidget(createNewKey(QStringLiteral("X"), QStringLiteral("X"))); tmpLayout->addWidget(createNewKey(QStringLiteral("C"), QStringLiteral("C"))); tmpLayout->addWidget(createNewKey(QStringLiteral("V"), QStringLiteral("V"))); tmpLayout->addWidget(createNewKey(QStringLiteral("B"), QStringLiteral("B"))); tmpLayout->addWidget(createNewKey(QStringLiteral("N"), QStringLiteral("N"))); tmpLayout->addWidget(createNewKey(QStringLiteral("M"), QStringLiteral("M"))); tmpLayout->addWidget(createNewKey(QStringLiteral(","), QStringLiteral(","), QStringLiteral(";"))); tmpLayout->addWidget(createNewKey(QStringLiteral("."), QStringLiteral("."), QStringLiteral(":"))); tmpLayout->addWidget(createNewKey(QStringLiteral("-"), QStringLiteral("-"), QStringLiteral("_"))); tmpLayout->insertStretch(-1, 1); tmpVLayout->addLayout(tmpLayout); tmpLayout = new QHBoxLayout(); tmp = createNewKey(KEY_COPY, KEY_COPY); tmp->setMaximumWidth(tmp->maximumWidth()); tmp->setMinimumWidth(tmp->maximumWidth()); tmpLayout->addWidget(tmp); tmp = createNewKey(KEY_PASTE, KEY_PASTE); tmp->setMaximumWidth(tmp->maximumWidth()); tmp->setMinimumWidth(tmp->maximumWidth()); tmpLayout->addWidget(tmp); QWidget *empty = new QWidget(this); empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); tmpLayout->addWidget(empty); tmp = createNewKey(QStringLiteral(KEY_SPACE), QStringLiteral(" ")); tmp->setMinimumWidth(300); tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpLayout->addWidget(tmp, 3); empty = new QWidget(this); empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); tmpLayout->addWidget(empty); tmp = createNewKey(KEY_FIN, KEY_FIN); tmp->setMaximumWidth(tmp->maximumWidth() * 1.5); tmp->setMinimumWidth(tmp->minimumWidth() * 1.5); tmpLayout->addWidget(tmp); tmpVLayout->addLayout(tmpLayout); setLayout(tmpVLayout); m_height = tmp->height()*5+10; setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); } }