QupZilla / qupzilla

Cross-platform Qt web browser
http://www.qupzilla.com
GNU General Public License v3.0
1.11k stars 350 forks source link

[Qt5] Application Layout still LTR even if it's language is RTL #1557

Closed SafaAlfulaij closed 9 years ago

SafaAlfulaij commented 9 years ago

qupzillaqt5rtl

As in the screenshot, The UI doesn't reverse. I tried the -reverse option and it worked great.

srazi commented 9 years ago

You should place qt_ar.qm in /usr/share/qupzilla/locale (maybe different on your distribution)

SafaAlfulaij commented 9 years ago

I think that this thing should be done automatically. You may use: app.setLayoutDirection(QLocale('localeCode').textDirection());

I don't see qt_ar.qm anywhere in the QupZilla package filelist...

srazi commented 9 years ago

We don't need to do this, because layout direction is set by Qt after loading qt_*.qm.

I don't see qt_ar.qm anywhere in the QupZilla package filelist...

It's not part of QupZilla source code, but it's there in Windows installer, I'm not sure about Linux packages. Also always you can find it in Qt SDK or by googling.

SafaAlfulaij commented 9 years ago

I've copied it and nothing changed. I suggest a game developers to use that line and it worked for them. Are you sure that Qt do that automatically?

srazi commented 9 years ago

I've copied it and nothing changed.

Are you sure it was loaded successfully? For example does Insert Unicode Character within context-menu of location bar is translated to Arabic? Note: The Qt version ofqt_ar.qm and QupZilla (Help->About Qt) should be the same.

Are you sure that Qt do that automatically?

Yes

SafaAlfulaij commented 9 years ago

Are you sure it was loaded successfully? For example does Insert Unicode Character within context-menu of location bar is translated to Arabic?

This menu item is not available for Linux yet, It's a Qt5 problem.

Qt uses libxcb to communicate with X and thus the xcb platform plugin is responsible for part of the abstractions. one of those is indicating whether RTL extensions should be used. you're already using the xcb platform plugin. you just cannot enable the useRtlExtensionsyada flag on anything but Windows currently

I tried the Qt4 version and it got flipped. Maybe it's a problem with Qt5?

srazi commented 9 years ago

Oh... you are right it's a Qt5 issue.

BTW, the following workaround works correctly:

diff --git a/src/main/main.cpp b/src/main/main.cpp
index 070d42e..9939dbf 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -187,6 +187,7 @@ int main(int argc, char* argv[])
     if (app.isClosing())
         return 0;

+    app.setLayoutDirection(QApplication::tr("QT_LAYOUT_DIRECTION") == QLatin1String("RTL") ? Qt::RightToLeft : Qt::LeftToRight);
     app.setProxyStyle(new ProxyStyle);

     return app.exec();
pejakm commented 9 years ago

@srazi Here's the screenshot:

https://a.pomf.se/lgbcsc.png

Qt-5.4. Without the patch Qz looks like the OP's screenshot.

srazi commented 9 years ago

@pejakm Thanks for the test. I opened an upstream bug report: https://bugreports.qt-project.org/browse/QTBUG-43447

SafaAlfulaij commented 9 years ago

UPDATE: They moved the string to QCoreApplication.

BTW, Why don't you set the "document-start" and "document-end" translatable?

Also, Why don't QupZilla loads this file? ftp://ftp.qt-project.org/qt/l10n/index.html It says that I have to download/open it

srazi commented 9 years ago

BTW, Why don't you set the "document-start" and "document-end" translatable?

If you mean document-start and document-end in GreasMonkey plugin then they are not translatable they are supported values of @run-at.

Also, Why don't QupZilla loads this file? ftp://ftp.qt-project.org/qt/l10n/index.html

Please open another issue for this one.

SafaAlfulaij commented 9 years ago

If you mean document-start and document-end in GreasMonkey plugin then they are not translatable they are supported values of @run-at.

I mean in the settings dialog, Here: https://github.com/QupZilla/qupzilla/blob/478b5ddb84499148055ffb27f7f7666614f3356b/src/plugins/GreaseMonkey/settings/gm_settingsscriptinfo.cpp#L51 The values are got from an another cpp file.

srazi commented 9 years ago

That file is part of GreasMonkey plugin, and as I said those are values and not translatable strings.