diff --git a/src/lib/navigation/completer/locationcompleterdelegate.cpp b/src/lib/navigation/completer/locationcompleterdelegate.cpp index d7f7e96ca..b768c1b61 100644 --- a/src/lib/navigation/completer/locationcompleterdelegate.cpp +++ b/src/lib/navigation/completer/locationcompleterdelegate.cpp @@ -108,11 +108,19 @@ void LocationCompleterDelegate::paint(QPainter* painter, const QStyleOptionViewI // Draw link const int infoYPos = titleRect.bottom() + opt.fontMetrics.leading() + 2; QRect linkRect(titleRect.x(), infoYPos, titleRect.width(), opt.fontMetrics.height()); + const QByteArray &linkArray = index.data(Qt::DisplayRole).toByteArray(); // Let's assume that more than 500 characters won't fit in line on any display... // Fixes performance when trying to get elidedText for a really long // (length() > 1000000) urls - data: urls can get that long - const QString &linkUrl = index.data(Qt::DisplayRole).toString().left(500); - QString link(opt.fontMetrics.elidedText(linkUrl, Qt::ElideRight, linkRect.width())); + QString link; + if (!linkArray.startsWith("data") && !linkArray.startsWith("javascript")) { + link = QString::fromUtf8(QByteArray::fromPercentEncoding(linkArray)).left(500); + } + else { + link = QString::fromLatin1(linkArray.left(500)); + } + + link = opt.fontMetrics.elidedText(link, Qt::ElideRight, linkRect.width()); painter->setFont(opt.font); TabPosition pos = index.data(LocationCompleterModel::TabPositionRole).value(); if (m_drawSwitchToTab && pos.windowIndex != -1) { @@ -256,11 +264,6 @@ void LocationCompleterDelegate::drawHighlightedTextLine(const QRect &rect, const } } -// RTL Support -#define LRE QChar(0x202A) -#define RLE QChar(0x202B) -#define PDF QChar(0x202C) - void LocationCompleterDelegate::drawTextLine(const QRect &rect, QString text, QPainter* painter, const QStyle* style, const QStyleOptionViewItemV4 &option, const QPalette::ColorRole &role) const @@ -270,8 +273,9 @@ void LocationCompleterDelegate::drawTextLine(const QRect &rect, QString text, QP Qt::LayoutDirection textDirection = text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight; Qt::Alignment alignment = textDirection == direction ? Qt::AlignLeft : Qt::AlignRight; - text.isRightToLeft() ? text.prepend(RLE) : text.prepend(LRE); - text.append(PDF); + // Insert unicode control characters: prepend RLE or LRE and append (RLM or LRM)+PDF + text.isRightToLeft() ? text.prepend(QChar(0x202B)).append(0x200F) : text.prepend(QChar(0x202A)).append(0x200E); + text.append(QChar(0x202C)); style->drawItemText(painter, rect, Qt::TextSingleLine | alignment, option.palette, true, text, role); } diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index 06ca9b2d2..7407f5ea0 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -756,6 +756,11 @@ void LocationBar::paintEvent(QPaintEvent* event) currentRect.setX(currentRect.x() + hostWidth); currentRect.setWidth(textRect.width() - currentRect.x() + textRect.x()); p.setPen(lightPen); + + if (currentText.isRightToLeft()) { + // Insert unicode control characters: prepend LRE then append LRM+PDF + currentText.prepend(QChar(0x202A)).append(QChar(0x200E)).append(QChar(0x202C)); + } } } diff --git a/src/lib/tools/aesinterface.h b/src/lib/tools/aesinterface.h index 7529178ab..c8f23d7d0 100644 --- a/src/lib/tools/aesinterface.h +++ b/src/lib/tools/aesinterface.h @@ -24,14 +24,12 @@ #include "qz_namespace.h" #include -#include #include #include + class QT_QUPZILLA_EXPORT AesInterface : public QObject { - Q_OBJECT - public: static const int VERSION; @@ -43,9 +41,7 @@ public: QByteArray encrypt(const QByteArray &plainData, const QByteArray &password); QByteArray decrypt(const QByteArray &cipherData, const QByteArray &password); - static void encryptSomeData(const QByteArray &pass = QByteArray()); static QByteArray passwordToHash(const QString &masterPassword); - static QByteArray createRandomData(int length); private: diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index 580b2568e..bfd651135 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -198,7 +198,7 @@ void TabbedWebView::linkHovered(const QString &link, const QString &title, const p_QupZilla->statusBarMessage()->clearMessage(); } else { - p_QupZilla->statusBarMessage()->showMessage(link); + p_QupZilla->statusBarMessage()->showMessage(QString::fromUtf8(QByteArray::fromPercentEncoding(link.toUtf8()))); } } }