Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a language layout switching button #14

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading