correctly use RTL text for rtl feeds

This commit is contained in:
Martin Rotter 2023-07-31 08:33:04 +02:00
parent 066221e2ef
commit 8133fce9e8
4 changed files with 14 additions and 1 deletions

View File

@ -50,7 +50,8 @@
#define MSG_SCORE_MIN 0.0
#define LOWER_TITLE_ROLE 64
#define HIGHLIGHTED_FOREGROUND_TITLE_ROLE 128
#define HIGHLIGHTED_FOREGROUND_TITLE_ROLE 65
#define TEXT_DIRECTION_ROLE 66
#define SOUNDS_BUILTIN_DIRECTORY ":/sounds"
#define ARGUMENTS_LIST_SEPARATOR "\n"

View File

@ -524,6 +524,9 @@ void MessagesView::loadItem(RootItem* item) {
setLayoutDirection(Qt::LayoutDirection::LeftToRight);
}
}
else {
setLayoutDirection(Qt::LayoutDirection::LeftToRight);
}
// Messages are loaded, make sure that previously
// active message is not shown in browser.

View File

@ -16,6 +16,12 @@ void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
item_option.state = item_option.state ^ QStyle::StateFlag::State_HasFocus;
}
bool rtl = index.data(TEXT_DIRECTION_ROLE).value<Qt::LayoutDirection>() == Qt::LayoutDirection::RightToLeft;
if (rtl) {
item_option.direction = Qt::LayoutDirection::RightToLeft;
}
if ((item_option.state & QStyle::StateFlag::State_Selected) == QStyle::StateFlag::State_Selected &&
index.data(Qt::ItemDataRole::ForegroundRole).isValid()) {
item_option.palette.setColor(QPalette::ColorRole::HighlightedText,

View File

@ -82,6 +82,9 @@ QVariant Feed::data(int column, int role) const {
return QVariant();
}
case TEXT_DIRECTION_ROLE:
return isRtl() ? Qt::LayoutDirection::RightToLeft : Qt::LayoutDirection::LayoutDirectionAuto;
case Qt::ItemDataRole::ForegroundRole:
switch (status()) {
case Status::NewMessages: