From 6371090b7565bfe8fc180066c67fed93eaf0fe4d Mon Sep 17 00:00:00 2001 From: Johannes Bichler Date: Tue, 23 Apr 2024 17:17:32 +0200 Subject: [PATCH] Added language switching button Added a button to switch language with an Icon and a property to set a list of available languages as StringList, same Format as languageLayout Reformatted code according to requested changes --- src/InputPanelIface.cpp | 35 ++ src/InputPanelIface.hpp | 15 + src/icons/language.png | Bin 0 -> 8622 bytes src/qml/CsLayout.qml | 15 +- src/qml/DeLayout.qml | 15 +- src/qml/ElLayout.qml | 685 ++++++++++++--------------------------- src/qml/EnLayout.qml | 15 +- src/qml/EsLayout.qml | 15 +- src/qml/FrLayout.qml | 15 +- src/qml/InputPanel.qml | 66 ++-- src/qml/ItLayout.qml | 15 +- src/qml/LanguageKey.qml | 26 ++ src/qml/NlLayout.qml | 15 +- src/qml/PlLayout.qml | 15 +- src/qml/PtLayout.qml | 15 +- src/qml/QwertyLayout.qml | 15 +- src/resources.qrc | 1 + 17 files changed, 390 insertions(+), 588 deletions(-) create mode 100644 src/icons/language.png create mode 100644 src/qml/LanguageKey.qml diff --git a/src/InputPanelIface.cpp b/src/InputPanelIface.cpp index a9cc8f1..1a58488 100644 --- a/src/InputPanelIface.cpp +++ b/src/InputPanelIface.cpp @@ -11,6 +11,9 @@ struct InputPanelIface::InputPanelIfacePrivate { QString shiftOnIcon{}; QString shiftOffIcon{}; QString hideKeyboardIcon{}; + QString languageIcon{}; + QStringList availableLanguageLayouts{}; + QString languageLayout{}; }; InputPanelIface::InputPanelIface(QObject *parent) @@ -122,3 +125,35 @@ void InputPanelIface::setHideKeyboardIcon(const QString &hideKeyboardIcon) { emit hideKeyboardIconChanged(); } } + +QString InputPanelIface::languageIcon() const { return pimpl->languageIcon; } + +void InputPanelIface::setLanguageIcon(const QString &languageIcon) { + if (pimpl->languageIcon != languageIcon) { + pimpl->languageIcon = languageIcon; + emit languageIconChanged(); + } +} + +QStringList InputPanelIface::availableLanguageLayouts() const { + return pimpl->availableLanguageLayouts; +} + +void InputPanelIface::setAvailableLanguageLayouts( + const QStringList &availableLanguageLayouts) { + if (pimpl->availableLanguageLayouts != availableLanguageLayouts) { + pimpl->availableLanguageLayouts = availableLanguageLayouts; + emit availableLanguageLayoutsChanged(); + } +} + +QString InputPanelIface::languageLayout() const { + return pimpl->languageLayout; +} + +void InputPanelIface::setLanguageLayout(const QString &languageLayout) { + if (pimpl->languageLayout != languageLayout) { + pimpl->languageLayout = languageLayout; + emit languageLayoutChanged(); + } +} diff --git a/src/InputPanelIface.hpp b/src/InputPanelIface.hpp index 5a46243..faf33df 100644 --- a/src/InputPanelIface.hpp +++ b/src/InputPanelIface.hpp @@ -22,6 +22,9 @@ class InputPanelIface : public QObject { Q_PROPERTY(QString shiftOnIcon READ shiftOnIcon WRITE setShiftOnIcon NOTIFY shiftOnIconChanged) Q_PROPERTY(QString shiftOffIcon READ shiftOffIcon WRITE setShiftOffIcon NOTIFY shiftOffIconChanged) Q_PROPERTY(QString hideKeyboardIcon READ hideKeyboardIcon WRITE setHideKeyboardIcon NOTIFY hideKeyboardIconChanged) + Q_PROPERTY(QString languageIcon READ languageIcon WRITE setLanguageIcon NOTIFY languageIconChanged) + Q_PROPERTY(QStringList availableLanguageLayouts READ availableLanguageLayouts WRITE setAvailableLanguageLayouts NOTIFY availableLanguageLayoutsChanged) + Q_PROPERTY(QString languageLayout READ languageLayout WRITE setLanguageLayout NOTIFY languageLayoutChanged FINAL) // clang-format on public: @@ -58,6 +61,15 @@ class InputPanelIface : public QObject { QString hideKeyboardIcon() const; void setHideKeyboardIcon(const QString &hideKeyboardIcon); + QString languageIcon() const; + void setLanguageIcon(const QString &languageIcon); + + QStringList availableLanguageLayouts() const; + void setAvailableLanguageLayouts(const QStringList &availableLanguageLayouts); + + QString languageLayout() const; + void setLanguageLayout(const QString &languageIcon); + signals: void backgroundColorChanged(); void btnBackgroundColorChanged(); @@ -69,6 +81,9 @@ class InputPanelIface : public QObject { void shiftOnIconChanged(); void shiftOffIconChanged(); void hideKeyboardIconChanged(); + void languageIconChanged(); + void availableLanguageLayoutsChanged(); + void languageLayoutChanged(); private: struct InputPanelIfacePrivate; diff --git a/src/icons/language.png b/src/icons/language.png new file mode 100644 index 0000000000000000000000000000000000000000..69679a895db70d9ba4076165c8395d04ac10d77c GIT binary patch literal 8622 zcmeHLc{tSD|DU03S+bQS8e2t}#SCVUb(kTt6)BoAGZ^b&tckful07Z9NT@6kN@b61 z*+S`xNVX(h#44*02&`) zZ)3Kb2zd8S9}U=|KkOvHKJo*@1lVve6Nn4w(}0EmYyqIp0~+C-Y8*UVQ@HASJxD; zs|%rdc{osADIk!4+JyuST)ozT7w38mv2xt|1U#Ef)8!)#J$vN@ZtL6=wDEyGUD}f( zlqj&@pzhJ|aFhM(x)-OdSgo}8u7f;%Y3B3k^;UA{}_zyg)N za51e(ZbG5M=24@~@+dS~U};R|LC*nwjy=}lyLdUA?`3j`dfNDy%affnKYcvtwZZpP z!0TjfGdzyVDc)9d<>30v8#xmbe|&;;*Vhr%gHl@l`<>p1O{~53OgXGIC;X)Q-DV66 zYy%%yRrn&7QSCN7@~lwyeC-%FY=zvMJ8h_)qVtfgGUJuX*l(L>G96!kE_@W%!wNC7 z&GBG_=@QEHes?)GJ2Nx=Wk{)TGZ};97FPOQzVi->?w-= zZnW(K1F38J(}*M&3LRokaiqFyNX}N&NJ6M&4M{7MG0d2zOL3y&0=*~}fhLxuKo=64 zEU9^nL){+(5V%q3M2NqetGhSGUqf<-7X#Sa!%#`c4utNaA!!Zdk*p^w^fbk?Ka<@dCvD84iB%VA-TOihU`J2k}*4`G8&0irJ!I6a3l$(fF#206^KX_ zQo#WQha*)eFu0N``4=j@yEmQaPNHm60pyBQfXAL>Pb896kqRiJ5(1!5u~$GNh)4w$ z5=x=Ej)J4%$X~oqQM|l?Ox)(&shvCS+sA?dHUkJt+|E;g zU}qfI3r5$ALZo|mS$cT5YDoU9x<99lf$Kyj(usORIt3v8S%)qEtiwlP2n_6d0NZrN z9%QOR!2gBbzB~|h01q5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#d-7rU3rB_$|O!uDXzy;ZVG-sg{xqm3%*Y55e3?5lkW*6pMwe-n1; z*{d|oxhhi5?e0K}WewE%;TH8}(0ck~vS{6vXCe-@4->PV7)szwYM2ja1SOcy`pvB^ z6z~3I`tC%;*ZW9=lkiW6b?{hT)AdcN;pQ3D-y@}79%$c>tWFH#k4a{{ezjrzyu*b% zF$7d07Do>`OATKk!nFc(#|WC-(xF!`sJu{1O0 z#re{5>#@=s1A%YFYG*3HMo(0=g{RP+rlpvbP?e?7q^8oSy$05ts;AJtg@V|zD8s{N ztGLy)hC-qm;>)x{y{G5Z(&gSnCctQc~^4@KIR2qcg2Mo7KP|c zV*0*(Ha3Py5lY`dIA?W{BYZW7d1#Ce4-7k~q5cX1$#}lk@@l-sm3l4v?|sI8nGh~8 zU8ouTkOThkl)yN{Y6I`)_uss&k*gnll`Y`w)0Q&g$TFq6FYfAwk#U3%@A9CWs&vU9 zWPYL>`Yil8c2)fy4G2fA9+ic$EB{0{TIQx4&h(5CYaL}bTMb{plp8m dbj+`4+RN8>(udk7fd90B@K_VQ2Rek%{{aQ*4EO*5 literal 0 HcmV?d00001 diff --git a/src/qml/CsLayout.qml b/src/qml/CsLayout.qml index 43a2eeb..8e703b8 100644 --- a/src/qml/CsLayout.qml +++ b/src/qml/CsLayout.qml @@ -77,7 +77,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -151,14 +150,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Y @@ -220,14 +217,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -245,7 +246,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/DeLayout.qml b/src/qml/DeLayout.qml index 5364b28..850ff13 100644 --- a/src/qml/DeLayout.qml +++ b/src/qml/DeLayout.qml @@ -76,7 +76,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -160,14 +159,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Y @@ -232,14 +229,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -257,7 +258,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/ElLayout.qml b/src/qml/ElLayout.qml index e0b87cb..a1ed519 100644 --- a/src/qml/ElLayout.qml +++ b/src/qml/ElLayout.qml @@ -1,496 +1,219 @@ -import QtQml 2.0 import QtQuick 2.0 import QtQuick.Layouts 1.12 -Loader { +ColumnLayout { property var inputPanel - property bool latinKeyboard: false - - sourceComponent: latinKeyboard ? latinLayout : greekLayout - - Component { - id: greekLayout - - ColumnLayout { - RowLayout { - property real keyWeight: 160 - - Key { - btnText: "ς" - inputPanelRef: inputPanel - } - - Key { - btnText: "ε" - alternativeKeys: "έ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ρ" - inputPanelRef: inputPanel - } - - Key { - btnText: "τ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ψ" - inputPanelRef: inputPanel - } - - Key { - btnText: "υ" - alternativeKeys: "ύϋΰ" - inputPanelRef: inputPanel - } - - Key { - btnText: "θ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ι" - alternativeKeys: "ίϊΐ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ο" - alternativeKeys: "ό" - inputPanelRef: inputPanel - } - - Key { - btnText: "π" - inputPanelRef: inputPanel - } - - BackspaceKey { - inputPanelRef: inputPanel - } - - } - - RowLayout { - property real keyWeight: 160 - - Key { - weight: 56 - functionKey: true - showPreview: false - btnBackground: "transparent" - } - - Key { - btnText: "α" - alternativeKeys: "ά" - inputPanelRef: inputPanel - } - - Key { - btnText: "σ" - inputPanelRef: inputPanel - } - - Key { - btnText: "δ" - inputPanelRef: inputPanel - } - - Key { - btnText: "φ" - inputPanelRef: inputPanel - } - - Key { - btnText: "γ" - inputPanelRef: inputPanel - } - - Key { - btnText: "η" - alternativeKeys: "ή" - inputPanelRef: inputPanel - } - - Key { - btnText: "ξ" - inputPanelRef: inputPanel - } - - Key { - btnText: "κ" - inputPanelRef: inputPanel - } - - Key { - btnText: "λ" - inputPanelRef: inputPanel - } - - EnterKey { - weight: 283 - inputPanelRef: inputPanel - } - - } - - RowLayout { - property real keyWeight: 156 - - Key { - btnDisplayedText: "ABC" - showPreview: false - inputPanelRef: inputPanel - functionKey: true - onClicked: latinKeyboard = true - } - - Key { - btnText: "ζ" - inputPanelRef: inputPanel - } - - Key { - btnText: "χ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ψ" - inputPanelRef: inputPanel - } - - Key { - btnText: "ω" - alternativeKeys: "ώ" - inputPanelRef: inputPanel - } - - Key { - btnText: "β" - inputPanelRef: inputPanel - } - - Key { - btnText: "ν" - inputPanelRef: inputPanel - } - - Key { - btnText: "μ" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_Comma - btnText: "," - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_Period - btnText: "." - alternativeKeys: "!.;?" - inputPanelRef: inputPanel - } - - ShiftKey { - weight: 204 - } - - } - - RowLayout { - property real keyWeight: 154 - - SymbolKey { - weight: 217 - } - - SpaceKey { - weight: 1168 - inputPanelRef: inputPanel - btnDisplayedText: "Ελληνικός" - } - - Key { - btnKey: Qt.Key_Apostrophe - btnText: "'" - inputPanelRef: inputPanel - } - - HideKey { - weight: 205 - } - - } + RowLayout { + property real keyWeight: 160 + + Key { + btnText: "ς" + inputPanelRef: inputPanel + } + + Key { + btnText: "ε" + alternativeKeys: "έ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ρ" + inputPanelRef: inputPanel + } + + Key { + btnText: "τ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ψ" + inputPanelRef: inputPanel + } + + Key { + btnText: "υ" + alternativeKeys: "ύϋΰ" + inputPanelRef: inputPanel + } + + Key { + btnText: "θ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ι" + alternativeKeys: "ίϊΐ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ο" + alternativeKeys: "ό" + inputPanelRef: inputPanel + } + + Key { + btnText: "π" + inputPanelRef: inputPanel } + BackspaceKey { + inputPanelRef: inputPanel + } } - Component { - id: latinLayout - - ColumnLayout { - RowLayout { - property real keyWeight: 160 - - Key { - btnKey: Qt.Key_Q - btnText: "q" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_W - btnText: "w" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_E - btnText: "e" - alternativeKeys: "êëèé" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_R - btnText: "r" - alternativeKeys: "ŕř" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_T - btnText: "t" - alternativeKeys: "ţŧť" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_Y - btnText: "y" - alternativeKeys: "ÿýŷ" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_U - btnText: "u" - alternativeKeys: "űūũûüùú" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_I - btnText: "i" - alternativeKeys: "îïīĩìí" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_O - btnText: "o" - alternativeKeys: "œøõôöòó" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_P - btnText: "p" - inputPanelRef: inputPanel - } - - BackspaceKey { - inputPanelRef: inputPanel - } - - } - - RowLayout { - property real keyWeight: 160 - - Key { - weight: 56 - functionKey: true - showPreview: false - btnBackground: "transparent" - } - - Key { - btnKey: Qt.Key_A - btnText: "a" - alternativeKeys: "äåãâàá" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_S - btnText: "s" - alternativeKeys: "šşś" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_D - btnText: "d" - alternativeKeys: "đď" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_F - btnText: "f" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_G - btnText: "g" - alternativeKeys: "ġģĝğ" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_H - btnText: "h" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_J - btnText: "j" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_K - btnText: "k" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_L - btnText: "l" - alternativeKeys: "ĺŀłļľ" - inputPanelRef: inputPanel - } - - EnterKey { - weight: 283 - inputPanelRef: inputPanel - } - - } - - RowLayout { - property real keyWeight: 156 - - Key { - btnDisplayedText: "ΑΒΓ" - showPreview: false - inputPanelRef: inputPanel - functionKey: true - onClicked: latinKeyboard = false - } - - Key { - btnKey: Qt.Key_Z - btnText: "z" - alternativeKeys: "žż" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_X - btnText: "x" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_C - btnText: "c" - alternativeKeys: "çċčć" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_V - btnText: "v" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_B - btnText: "b" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_N - btnText: "n" - alternativeKeys: "ņńň" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_M - btnText: "m" - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_Comma - btnText: "," - inputPanelRef: inputPanel - } - - Key { - btnKey: Qt.Key_Period - btnText: "." - inputPanelRef: inputPanel - } - - ShiftKey { - weight: 204 - } - - } - - RowLayout { - property real keyWeight: 154 - - SymbolKey { - weight: 217 - } - - SpaceKey { - weight: 1168 - inputPanelRef: inputPanel - btnDisplayedText: "Ελληνικός" - } - - Key { - btnKey: Qt.Key_Apostrophe - btnText: "'" - inputPanelRef: inputPanel - } - - HideKey { - weight: 205 - } - - } + RowLayout { + property real keyWeight: 160 + + Key { + weight: 56 + functionKey: true + showPreview: false + btnBackground: "transparent" + } + + Key { + btnText: "α" + alternativeKeys: "ά" + inputPanelRef: inputPanel + } + + Key { + btnText: "σ" + inputPanelRef: inputPanel + } + + Key { + btnText: "δ" + inputPanelRef: inputPanel + } + + Key { + btnText: "φ" + inputPanelRef: inputPanel + } + Key { + btnText: "γ" + inputPanelRef: inputPanel } + Key { + btnText: "η" + alternativeKeys: "ή" + inputPanelRef: inputPanel + } + + Key { + btnText: "ξ" + inputPanelRef: inputPanel + } + + Key { + btnText: "κ" + inputPanelRef: inputPanel + } + + Key { + btnText: "λ" + inputPanelRef: inputPanel + } + + EnterKey { + weight: 283 + inputPanelRef: inputPanel + } + } + + RowLayout { + property real keyWeight: 156 + + ShiftKey {} + + Key { + btnText: "ζ" + inputPanelRef: inputPanel + } + + Key { + btnText: "χ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ψ" + inputPanelRef: inputPanel + } + + Key { + btnText: "ω" + alternativeKeys: "ώ" + inputPanelRef: inputPanel + } + + Key { + btnText: "β" + inputPanelRef: inputPanel + } + + Key { + btnText: "ν" + inputPanelRef: inputPanel + } + + Key { + btnText: "μ" + inputPanelRef: inputPanel + } + + Key { + btnKey: Qt.Key_Comma + btnText: "," + inputPanelRef: inputPanel + } + + Key { + btnKey: Qt.Key_Period + btnText: "." + alternativeKeys: "!.;?" + inputPanelRef: inputPanel + } + + ShiftKey { + weight: 204 + } } + RowLayout { + property real keyWeight: 154 + + SymbolKey { + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 + } + + SpaceKey { + weight: 1168 + inputPanelRef: inputPanel + btnDisplayedText: "Ελληνικός" + } + + Key { + btnKey: Qt.Key_Apostrophe + btnText: "'" + inputPanelRef: inputPanel + } + + HideKey { + weight: 205 + } + } } diff --git a/src/qml/EnLayout.qml b/src/qml/EnLayout.qml index dddff59..d2bcd28 100644 --- a/src/qml/EnLayout.qml +++ b/src/qml/EnLayout.qml @@ -77,7 +77,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -153,14 +152,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -222,14 +219,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -247,7 +248,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/EsLayout.qml b/src/qml/EsLayout.qml index 1d4c481..abfd1c0 100644 --- a/src/qml/EsLayout.qml +++ b/src/qml/EsLayout.qml @@ -74,7 +74,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -151,14 +150,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -223,14 +220,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -248,7 +249,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/FrLayout.qml b/src/qml/FrLayout.qml index 2a11c13..81ee6ab 100644 --- a/src/qml/FrLayout.qml +++ b/src/qml/FrLayout.qml @@ -76,7 +76,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -153,14 +152,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_W @@ -220,14 +217,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -245,7 +246,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/InputPanel.qml b/src/qml/InputPanel.qml index 7712631..8c268d3 100644 --- a/src/qml/InputPanel.qml +++ b/src/qml/InputPanel.qml @@ -17,28 +17,30 @@ Item { property string shiftOnIcon: "qrc:/icons/caps-lock-on.png" property string shiftOffIcon: "qrc:/icons/caps-lock-off.png" property string hideKeyboardIcon: "qrc:/icons/hide-arrow.png" + property string languageIcon: "qrc:/icons/language.png" + property var availableLanguageLayouts: ["En"] function showKeyPopup(keyButton) { - keyPopup.popup(keyButton, root); + keyPopup.popup(keyButton, root) } function hideKeyPopup() { - keyPopup.visible = false; + keyPopup.visible = false } function showAlternativesKeyPopup(keyButton) { - alternativesKeyPopup.open(keyButton, root); + alternativesKeyPopup.open(keyButton, root) } function loadLettersLayout() { if (InputEngine.inputLayoutValid(languageLayout)) layoutLoader.setSource(languageLayout + "Layout.qml", { - "inputPanel": root - }); + "inputPanel": root + }) else layoutLoader.setSource("EnLayout.qml", { - "inputPanel": root - }); + "inputPanel": root + }) } objectName: "inputPanel" @@ -47,22 +49,27 @@ Item { onYChanged: InputEngine.setKeyboardRectangle(Qt.rect(x, y, width, height)) onActiveChanged: { if (alternativesKeyPopup.visible && !active) - alternativesKeyPopup.visible = false; - + alternativesKeyPopup.visible = false } onLanguageLayoutChanged: loadLettersLayout() Component.onCompleted: { - InputPanel.backgroundColor = backgroundColor; - InputPanel.btnBackgroundColor = btnBackgroundColor; - InputPanel.btnSpecialBackgroundColor = btnSpecialBackgroundColor; - InputPanel.btnTextColor = btnTextColor; - InputPanel.btnTextFontFamily = btnTextFontFamily; - InputPanel.backspaceIcon = backspaceIcon; - InputPanel.enterIcon = enterIcon; - InputPanel.shiftOnIcon = shiftOnIcon; - InputPanel.shiftOffIcon = shiftOffIcon; - InputPanel.hideKeyboardIcon = hideKeyboardIcon; - loadLettersLayout(); + if (availableLanguageLayouts.length == 0) { + availableLanguageLayouts = ["En"] + } + InputPanel.backgroundColor = backgroundColor + InputPanel.btnBackgroundColor = btnBackgroundColor + InputPanel.btnSpecialBackgroundColor = btnSpecialBackgroundColor + InputPanel.btnTextColor = btnTextColor + InputPanel.btnTextFontFamily = btnTextFontFamily + InputPanel.backspaceIcon = backspaceIcon + InputPanel.enterIcon = enterIcon + InputPanel.shiftOnIcon = shiftOnIcon + InputPanel.shiftOffIcon = shiftOffIcon + InputPanel.hideKeyboardIcon = hideKeyboardIcon + InputPanel.languageIcon = languageIcon + InputPanel.availableLanguageLayouts = availableLanguageLayouts + InputPanel.languageLayout = languageLayout + loadLettersLayout() } KeyPopup { @@ -109,21 +116,20 @@ Item { fill: parent margins: 5 } - } Connections { function refreshLayouts() { if (InputEngine.symbolMode) layoutLoader.setSource("SymbolLayout.qml", { - "inputPanel": root - }); + "inputPanel": root + }) else if (InputEngine.inputMode === InputEngine.DigitsOnly) layoutLoader.setSource("DigitsLayout.qml", { - "inputPanel": root - }); + "inputPanel": root + }) else - loadLettersLayout(); + loadLettersLayout() } target: InputEngine @@ -135,6 +141,12 @@ Item { } } + Connections { + target: InputPanel + onLanguageLayoutChanged: { + languageLayout = InputPanel.languageLayout + loadLettersLayout() + } + } } - } diff --git a/src/qml/ItLayout.qml b/src/qml/ItLayout.qml index 49a9e73..8283d13 100644 --- a/src/qml/ItLayout.qml +++ b/src/qml/ItLayout.qml @@ -74,7 +74,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -146,14 +145,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -212,14 +209,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -237,7 +238,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/LanguageKey.qml b/src/qml/LanguageKey.qml new file mode 100644 index 0000000..2c39a55 --- /dev/null +++ b/src/qml/LanguageKey.qml @@ -0,0 +1,26 @@ +import CuteKeyboard 1.0 +import QtQuick 2.0 + +Key { + weight: 108.5 + btnKey: Qt.Key_Context2 + btnIcon: InputPanel.languageIcon + functionKey: true + showPreview: false + btnBackground: InputPanel.btnSpecialBackgroundColor + onClicked: { + var indx = InputPanel.availableLanguageLayouts.indexOf( + InputPanel.languageLayout) + if (indx != -1) { + var nextIndx = (indx + 1) % InputPanel.availableLanguageLayouts.length + var nextLangLayout = InputPanel.availableLanguageLayouts[nextIndx] + if (InputEngine.inputLayoutValid(nextLangLayout)) { + InputPanel.languageLayout = nextLangLayout + } else { + InputPanel.languageLayout = "En" + } + } else { + InputPanel.languageLayout = InputPanel.availableLanguageLayouts[0] + } + } +} diff --git a/src/qml/NlLayout.qml b/src/qml/NlLayout.qml index 9776cfc..4ef5e20 100644 --- a/src/qml/NlLayout.qml +++ b/src/qml/NlLayout.qml @@ -77,7 +77,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -153,14 +152,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -222,14 +219,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -247,7 +248,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/PlLayout.qml b/src/qml/PlLayout.qml index eade3ae..e30a4d6 100644 --- a/src/qml/PlLayout.qml +++ b/src/qml/PlLayout.qml @@ -72,7 +72,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -146,14 +145,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -216,14 +213,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -241,7 +242,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/PtLayout.qml b/src/qml/PtLayout.qml index acdd9cd..5debd6c 100644 --- a/src/qml/PtLayout.qml +++ b/src/qml/PtLayout.qml @@ -74,7 +74,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -152,14 +151,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -225,14 +222,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -250,7 +251,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/qml/QwertyLayout.qml b/src/qml/QwertyLayout.qml index f253c39..77ab42f 100644 --- a/src/qml/QwertyLayout.qml +++ b/src/qml/QwertyLayout.qml @@ -70,7 +70,6 @@ ColumnLayout { BackspaceKey { inputPanelRef: inputPanel } - } RowLayout { @@ -141,14 +140,12 @@ ColumnLayout { weight: 283 inputPanelRef: inputPanel } - } RowLayout { property real keyWeight: 156 - ShiftKey { - } + ShiftKey {} Key { btnKey: Qt.Key_Z @@ -207,14 +204,18 @@ ColumnLayout { ShiftKey { weight: 204 } - } RowLayout { property real keyWeight: 154 SymbolKey { - weight: 217 + weight: availableLanguageLayouts.length === 1 ? 217 : 108.5 + } + + LanguageKey { + visible: availableLanguageLayouts.length > 1 + weight: 108.5 } SpaceKey { @@ -231,7 +232,5 @@ ColumnLayout { HideKey { weight: 205 } - } - } diff --git a/src/resources.qrc b/src/resources.qrc index d3d47f4..8ac254c 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -4,5 +4,6 @@ icons/caps-lock-off.png icons/caps-lock-on.png icons/hide-arrow.png + icons/language.png