Skip to content

Commit

Permalink
Added language switching button
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Johannes Bichler authored and AndreaRicchi committed Apr 30, 2024
1 parent 9c45dbb commit 6371090
Show file tree
Hide file tree
Showing 17 changed files with 390 additions and 588 deletions.
35 changes: 35 additions & 0 deletions src/InputPanelIface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ struct InputPanelIface::InputPanelIfacePrivate {
QString shiftOnIcon{};
QString shiftOffIcon{};
QString hideKeyboardIcon{};
QString languageIcon{};
QStringList availableLanguageLayouts{};
QString languageLayout{};
};

InputPanelIface::InputPanelIface(QObject *parent)
Expand Down Expand Up @@ -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();
}
}
15 changes: 15 additions & 0 deletions src/InputPanelIface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand All @@ -69,6 +81,9 @@ class InputPanelIface : public QObject {
void shiftOnIconChanged();
void shiftOffIconChanged();
void hideKeyboardIconChanged();
void languageIconChanged();
void availableLanguageLayoutsChanged();
void languageLayoutChanged();

private:
struct InputPanelIfacePrivate;
Expand Down
Binary file added src/icons/language.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions src/qml/CsLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ ColumnLayout {
BackspaceKey {
inputPanelRef: inputPanel
}

}

RowLayout {
Expand Down Expand Up @@ -151,14 +150,12 @@ ColumnLayout {
weight: 283
inputPanelRef: inputPanel
}

}

RowLayout {
property real keyWeight: 156

ShiftKey {
}
ShiftKey {}

Key {
btnKey: Qt.Key_Y
Expand Down Expand Up @@ -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 {
Expand All @@ -245,7 +246,5 @@ ColumnLayout {
HideKey {
weight: 205
}

}

}
15 changes: 7 additions & 8 deletions src/qml/DeLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ ColumnLayout {
BackspaceKey {
inputPanelRef: inputPanel
}

}

RowLayout {
Expand Down Expand Up @@ -160,14 +159,12 @@ ColumnLayout {
weight: 283
inputPanelRef: inputPanel
}

}

RowLayout {
property real keyWeight: 156

ShiftKey {
}
ShiftKey {}

Key {
btnKey: Qt.Key_Y
Expand Down Expand Up @@ -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 {
Expand All @@ -257,7 +258,5 @@ ColumnLayout {
HideKey {
weight: 205
}

}

}
Loading

0 comments on commit 6371090

Please sign in to comment.