diff --git a/app/layoutsDelegates/activitycmbboxdelegate.cpp b/app/layoutsDelegates/activitycmbboxdelegate.cpp index eabc5901d..0c758e483 100644 --- a/app/layoutsDelegates/activitycmbboxdelegate.cpp +++ b/app/layoutsDelegates/activitycmbboxdelegate.cpp @@ -127,6 +127,7 @@ void ActivityCmbBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem QTextDocument doc; QString css; + QString activitiesText = myOptions.text; QBrush nBrush; @@ -137,6 +138,7 @@ void ActivityCmbBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem } css = QString("body { color : %1; }").arg(nBrush.color().name()); + doc.setDefaultStyleSheet(css); doc.setHtml("" + myOptions.text + ""); @@ -144,11 +146,17 @@ void ActivityCmbBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem myOptions.widget->style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter); //we need an offset to be in the same vertical center of TextEdit - int offsetY = 1 + (myOptions.rect.height() - doc.size().height()) / 2; + int offsetY = ((myOptions.rect.height() - doc.size().height()) / 2); - painter->translate(myOptions.rect.left(), myOptions.rect.top() + offsetY); - QRect clip(0, 0, myOptions.rect.width(), myOptions.rect.height()); + if ((qApp->layoutDirection() == Qt::RightToLeft) && !activitiesText.isEmpty()) { + int textWidth = doc.size().width(); + + painter->translate(qMax(myOptions.rect.left(), myOptions.rect.right() - textWidth), myOptions.rect.top() + offsetY + 1); + } else { + painter->translate(myOptions.rect.left(), myOptions.rect.top() + offsetY + 1); + } + QRect clip(0, 0, myOptions.rect.width(), myOptions.rect.height()); doc.drawContents(painter, clip); } else { QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter); diff --git a/app/layoutsDelegates/layoutnamedelegate.cpp b/app/layoutsDelegates/layoutnamedelegate.cpp index b0c60a36c..e9ca9ec3e 100644 --- a/app/layoutsDelegates/layoutnamedelegate.cpp +++ b/app/layoutsDelegates/layoutnamedelegate.cpp @@ -47,10 +47,11 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QFontMetrics fm(option.font); int textWidth = fm.width(nameText); int thick = option.rect.height(); - int startWidth = qBound(0, option.rect.width() - textWidth - thick , thick); + int startWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? thick : qBound(0, option.rect.width() - textWidth - thick , thick); + int endWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? qBound(0, option.rect.width() - textWidth - thick , thick) : thick; QRect destinationS(option.rect.x(), option.rect.y(), startWidth, thick); - QRect destinationE(option.rect.x() + option.rect.width() - thick, option.rect.y(), thick, thick); + QRect destinationE(option.rect.x() + option.rect.width() - thick, option.rect.y(), endWidth, thick); QStyleOptionViewItem myOptionS = option; QStyleOptionViewItem myOptionE = option; @@ -58,7 +59,7 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op myOptionS.rect = destinationS; myOptionE.rect = destinationE; myOptionMain.rect.setX(option.rect.x() + startWidth); - myOptionMain.rect.setWidth(option.rect.width() - startWidth - thick); + myOptionMain.rect.setWidth(option.rect.width() - startWidth - endWidth); QStyledItemDelegate::paint(painter, myOptionMain, index); @@ -73,7 +74,12 @@ void LayoutNameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op //! Lock Icon 2: QIcon attempt that doesnt change color QIcon lockIcon = QIcon::fromTheme("object-locked"); - painter->drawPixmap(destinationE, lockIcon.pixmap(thick, thick)); + + if (qApp->layoutDirection() == Qt::RightToLeft) { + painter->drawPixmap(destinationS, lockIcon.pixmap(thick, thick)); + } else { + painter->drawPixmap(destinationE, lockIcon.pixmap(thick, thick)); + } //! Lock Icon 3: QIcon and change colors attempt /*QIcon lockIcon = QIcon::fromTheme("object-locked"); diff --git a/app/settingsdialog.cpp b/app/settingsdialog.cpp index 88d48d7e7..bd7a950a2 100644 --- a/app/settingsdialog.cpp +++ b/app/settingsdialog.cpp @@ -151,6 +151,13 @@ SettingsDialog::SettingsDialog(QWidget *parent, DockCorona *corona) QAction *aboutAction = helpMenu->addAction(i18n("About Latte")); aboutAction->setIcon(QIcon::fromTheme("latte-dock")); + //! RTL support for labels in preferences + if (qApp->layoutDirection() == Qt::RightToLeft) { + ui->behaviorLbl->setAlignment(Qt::AlignRight | Qt::AlignTop); + ui->mouseSensetivityLbl->setAlignment(Qt::AlignRight | Qt::AlignTop); + ui->delayLbl->setAlignment(Qt::AlignRight | Qt::AlignTop); + } + loadSettings(); //! SIGNALS diff --git a/shell/package/contents/configuration/BehaviorConfig.qml b/shell/package/contents/configuration/BehaviorConfig.qml index c0f3b4cd8..2d7f03bc1 100644 --- a/shell/package/contents/configuration/BehaviorConfig.qml +++ b/shell/package/contents/configuration/BehaviorConfig.qml @@ -465,7 +465,8 @@ PlasmaComponents.Page { PlasmaComponents.Label { Layout.fillWidth: false - Layout.rightMargin: units.smallSpacing + Layout.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? 0 : units.smallSpacing + Layout.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? units.smallSpacing : 0 horizontalAlignment: Text.AlignRight text: i18n("Show") } @@ -480,8 +481,10 @@ PlasmaComponents.Page { PlasmaComponents.Label { Layout.fillWidth: false - Layout.leftMargin: units.largeSpacing - Layout.rightMargin: units.smallSpacing + Layout.leftMargin: Qt.application.layoutDirection === Qt.RightToLeft ? + units.smallSpacing : units.largeSpacing + Layout.rightMargin: Qt.application.layoutDirection === Qt.RightToLeft ? + units.largeSpacing : units.smallSpacing horizontalAlignment: Text.AlignRight text: i18n("Hide") }