Skip to content
Snippets Groups Projects
Commit e073c6f8 authored by Sébastien Blin's avatar Sébastien Blin Committed by Aline Gondim Santos
Browse files

i18n: support RTL languages

This patch introduces some mechanisms to fully support RTL languages:
1. RTL detection via UtilsAdapter::isRTL() checking the locale name
2. Using QML mirroring when needed based on UtilsAdapter.isRTL
3. Inverting panels in DualPaneView and JamiListView when needed
with SinglePane support

Moreover, lot of anchors are added to automatically manage layout
updates.

GitLab: #235
Change-Id: I40c245f2d7fae96d796c53505af5403f5e813e7f
parent 44d807e6
No related branches found
No related tags found
No related merge requests found
Showing
with 31 additions and 9 deletions
...@@ -144,6 +144,7 @@ Item { ...@@ -144,6 +144,7 @@ Item {
Layout.preferredHeight: 50 Layout.preferredHeight: 50
leftPadding: 16 leftPadding: 16
rightPadding: 16
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
......
...@@ -189,6 +189,7 @@ ColumnLayout { ...@@ -189,6 +189,7 @@ ColumnLayout {
id: messageBarRowLayout id: messageBarRowLayout
spacing: JamiTheme.chatViewFooterRowSpacing spacing: JamiTheme.chatViewFooterRowSpacing
anchors.left: parent.left
Row { Row {
...@@ -843,6 +844,8 @@ ColumnLayout { ...@@ -843,6 +844,8 @@ ColumnLayout {
toolTipText: JamiStrings.send toolTipText: JamiStrings.send
mirror: UtilsAdapter.isRTL
source: JamiResources.send_black_24dp_svg source: JamiResources.send_black_24dp_svg
normalColor: JamiTheme.chatViewFooterSendButtonColor normalColor: JamiTheme.chatViewFooterSendButtonColor
......
...@@ -87,6 +87,7 @@ JamiFlickable { ...@@ -87,6 +87,7 @@ JamiFlickable {
selectByMouse: true selectByMouse: true
textFormat: TextEdit.PlainText textFormat: TextEdit.PlainText
placeholderTextColor: JamiTheme.placeholderTextColor placeholderTextColor: JamiTheme.placeholderTextColor
horizontalAlignment: Text.AlignLeft
background: Rectangle { background: Rectangle {
border.width: 0 border.width: 0
......
...@@ -119,7 +119,7 @@ Rectangle { ...@@ -119,7 +119,7 @@ Rectangle {
} }
} }
SplitView { JamiSplitView {
id: mainColumnLayout id: mainColumnLayout
anchors.fill: parent anchors.fill: parent
...@@ -127,12 +127,6 @@ Rectangle { ...@@ -127,12 +127,6 @@ Rectangle {
property bool isHorizontal: false // Calculated when showing the stack view property bool isHorizontal: false // Calculated when showing the stack view
orientation: isHorizontal ? Qt.Horizontal : Qt.Vertical orientation: isHorizontal ? Qt.Horizontal : Qt.Vertical
handle: Rectangle {
implicitWidth: isHorizontal ? JamiTheme.splitViewHandlePreferredWidth : root.width
implicitHeight: isHorizontal ? root.height : JamiTheme.splitViewHandlePreferredWidth
color: SplitHandle.pressed ? JamiTheme.pressColor : (SplitHandle.hovered ? JamiTheme.hoverColor : JamiTheme.tabbarBorderColor)
}
Rectangle { Rectangle {
id: callPageMainRect id: callPageMainRect
......
...@@ -135,6 +135,7 @@ ItemDelegate { ...@@ -135,6 +135,7 @@ ItemDelegate {
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumHeight: 20 Layout.minimumHeight: 20
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignLeft
elide: Text.ElideMiddle elide: Text.ElideMiddle
text: Title === undefined ? "" : Title text: Title === undefined ? "" : Title
textFormat: TextEdit.PlainText textFormat: TextEdit.PlainText
...@@ -166,6 +167,7 @@ ItemDelegate { ...@@ -166,6 +167,7 @@ ItemDelegate {
elide: Text.ElideRight elide: Text.ElideRight
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignLeft
text: Draft ? text: Draft ?
Draft : Draft :
(LastInteraction === undefined ? "" : LastInteraction) (LastInteraction === undefined ? "" : LastInteraction)
......
...@@ -178,6 +178,7 @@ ListSelectionView { ...@@ -178,6 +178,7 @@ ListSelectionView {
Flow { Flow {
id: flow id: flow
spacing: 13 spacing: 13
layoutDirection: UtilsAdapter.isRTL ? Qt.RightToLeft : Qt.LeftToRight
Repeater { Repeater {
id: tipsRepeater id: tipsRepeater
......
...@@ -50,6 +50,7 @@ ItemDelegate { ...@@ -50,6 +50,7 @@ ItemDelegate {
Layout.rightMargin: JamiTheme.preferredMarginSize Layout.rightMargin: JamiTheme.preferredMarginSize
Layout.preferredWidth: JamiTheme.preferredFieldHeight Layout.preferredWidth: JamiTheme.preferredFieldHeight
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
horizontalAlignment: Text.AlignLeft
background: Avatar { background: Avatar {
id: avatar id: avatar
......
...@@ -116,9 +116,10 @@ ItemDelegate { ...@@ -116,9 +116,10 @@ ItemDelegate {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: editDeviceName.leftPadding Layout.leftMargin: editDeviceName.leftPadding
Layout.rightMargin: editDeviceName.leftPadding
Layout.bottomMargin: 10 Layout.bottomMargin: 10
horizontalAlignment: Text.AlignLeft
elide: Text.ElideRight elide: Text.ElideMiddle
font.pointSize: JamiTheme.textFontSize font.pointSize: JamiTheme.textFontSize
color: JamiTheme.textColor color: JamiTheme.textColor
text: deviceId === "" ? JamiStrings.deviceId : deviceId text: deviceId === "" ? JamiStrings.deviceId : deviceId
......
...@@ -26,6 +26,8 @@ ProgressBar { ...@@ -26,6 +26,8 @@ ProgressBar {
property real rmsLevel: 0 property real rmsLevel: 0
LayoutMirroring.enabled: false
value: { value: {
return clamp(rmsLevel * 300.0, 0.0, 100.0); return clamp(rmsLevel * 300.0, 0.0, 100.0);
} }
......
...@@ -63,6 +63,8 @@ RowLayout { ...@@ -63,6 +63,8 @@ RowLayout {
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
font.pointSize: JamiTheme.settingsFontSize font.pointSize: JamiTheme.settingsFontSize
font.kerning: true font.kerning: true
LayoutMirroring.enabled: false
LayoutMirroring.childrenInherit: true
onValueChanged: newValue() onValueChanged: newValue()
......
...@@ -139,6 +139,7 @@ SettingsPageBase { ...@@ -139,6 +139,7 @@ SettingsPageBase {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight
LayoutMirroring.enabled: false
labelText: JamiStrings.language labelText: JamiStrings.language
tipText: JamiStrings.language tipText: JamiStrings.language
......
...@@ -48,6 +48,7 @@ UtilsAdapter::UtilsAdapter(AppSettingsManager* settingsManager, ...@@ -48,6 +48,7 @@ UtilsAdapter::UtilsAdapter(AppSettingsManager* settingsManager,
if (lrcInstance_->avModel().getRecordPath().isEmpty()) { if (lrcInstance_->avModel().getRecordPath().isEmpty()) {
lrcInstance_->avModel().setRecordPath(getDefaultRecordPath()); lrcInstance_->avModel().setRecordPath(getDefaultRecordPath());
} }
set_isRTL(isRTL());
} }
QVariant QVariant
...@@ -80,6 +81,7 @@ UtilsAdapter::setAppValue(const Settings::Key key, const QVariant& value) ...@@ -80,6 +81,7 @@ UtilsAdapter::setAppValue(const Settings::Key key, const QVariant& value)
if (key == Settings::Key::LANG) { if (key == Settings::Key::LANG) {
settingsManager_->loadTranslations(); settingsManager_->loadTranslations();
Q_EMIT changeLanguage(); Q_EMIT changeLanguage();
set_isRTL(isRTL());
} else if (key == Settings::Key::BaseZoom) } else if (key == Settings::Key::BaseZoom)
Q_EMIT changeFontSize(); Q_EMIT changeFontSize();
else if (key == Settings::Key::EnableExperimentalSwarm) else if (key == Settings::Key::EnableExperimentalSwarm)
...@@ -808,3 +810,11 @@ UtilsAdapter::getVideoPlayer(const QString& resource, const QString& bgColor) ...@@ -808,3 +810,11 @@ UtilsAdapter::getVideoPlayer(const QString& resource, const QString& bgColor)
{"html", htmlVideo.arg(resource, bgColor)}, {"html", htmlVideo.arg(resource, bgColor)},
}; };
} }
bool
UtilsAdapter::isRTL()
{
auto pref = getAppValue(Settings::Key::LANG).toString();
pref == "SYSTEM" ? QLocale::system().name() : pref;
return pref == "ar" || pref == "he" || pref == "fa" || pref == "ur";
}
\ No newline at end of file
...@@ -66,6 +66,7 @@ class UtilsAdapter final : public QmlAdapterBase ...@@ -66,6 +66,7 @@ class UtilsAdapter final : public QmlAdapterBase
{ {
Q_OBJECT Q_OBJECT
QML_PROPERTY(QStringList, logList) QML_PROPERTY(QStringList, logList)
QML_RO_PROPERTY(bool, isRTL)
public: public:
explicit UtilsAdapter(AppSettingsManager* settingsManager, explicit UtilsAdapter(AppSettingsManager* settingsManager,
SystemTray* systemTray, SystemTray* systemTray,
...@@ -149,6 +150,8 @@ public: ...@@ -149,6 +150,8 @@ public:
Q_INVOKABLE QVariantMap getVideoPlayer(const QString& resource, const QString& bgColor); Q_INVOKABLE QVariantMap getVideoPlayer(const QString& resource, const QString& bgColor);
Q_INVOKABLE bool isRTL();
Q_SIGNALS: Q_SIGNALS:
void debugMessageReceived(const QString& message); void debugMessageReceived(const QString& message);
void changeFontSize(); void changeFontSize();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment