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
  • Loading branch information
Johannes Bichler authored and Johannes Bichler committed Apr 24, 2024
1 parent 76db0aa commit 3e2e59e
Show file tree
Hide file tree
Showing 17 changed files with 380 additions and 492 deletions.
37 changes: 37 additions & 0 deletions src/InputPanelIface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "InputPanelIface.hpp"
#include "qdebug.h"

struct InputPanelIface::InputPanelIfacePrivate {
QColor backgroundColor{};
Expand All @@ -11,6 +12,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 +126,36 @@ 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.
7 changes: 6 additions & 1 deletion src/qml/CsLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,12 @@ ColumnLayout {
property real keyWeight: 154

SymbolKey {
weight: 217
weight: availableLanguageLayouts.length === 1? 217 : 108.5
}

LanguageKey{
visible: availableLanguageLayouts.length > 1
weight: 108.5
}

SpaceKey {
Expand Down
7 changes: 6 additions & 1 deletion src/qml/DeLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ ColumnLayout {
property real keyWeight: 154

SymbolKey {
weight: 217
weight: availableLanguageLayouts.length === 1? 217 : 108.5
}

LanguageKey{
visible: availableLanguageLayouts.length > 1
weight: 108.5
}

SpaceKey {
Expand Down
Loading

0 comments on commit 3e2e59e

Please sign in to comment.