Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-11042 Add right-to-left locale support to QtQuick elements
  3. QTBUG-15883

Investigate a way to automatically mirror QML applications for right-to-left locales

    XMLWordPrintable

Details

    Description

      Automatic reversing may not be viable, but as it promises a lot of benefits, it should be investigated. See parent task QTBUG-11042 for more info about QtQuick right-to-left support.

      Working assumptions

      • 95% of layouts and animations should be mirrored
      • 5% of special cases shouldn't where Arabic person has gotten used to LTR (number dialer, multimedia buttons)
      • content (maps, images, videos) direction should be retained
      • text direction should be retained, bi-directional text mirroring is complex (strong/weak direction, bi-directional text, etc.) problem and handled elsewhere

      1. Don't modify the scene, just provide horizontal symmetry in layout elements

      • layoutDirection for anchors, mirror property for Image element, RightToLeft mode for positioners and GridView
      • possible to write RTL support, but not without considerable changes made to application QML code
        + if wanted the mirroring can be partially automatic by changing the default value of layoutDirection, positioner flow properties in Arabic variants
        + content doesn't get accidentally mirrored (images, videos, maps, text)
        + the meaning of x and co-ordinate system is retained
        - layouts and animations that modify items x co-ordinate directly don't get mirrored, often breaking the application layouts and animation flow
        - more code changes are needed to enable RTL layouts than when mirroring the scene
        - application developer needs to rewrite position-handling JavaScript and C++ code twice

      2. Mirror x property of the item in relation to it's parent

      • transformed x axis by modifying QGraphicsItem::setPos() function: arabic_x = parent.width - (item.width+item.x)
      • not really a practical solution, included here for inclusiveness
        + all layouts and animations are mirrored, content doesn't get mirrored
        + less code needed for Arabic variants
        + could get some demos like Photoviewer and Minehunt executing on RTL direction, though ..
        - .. most demos crashed with segmentation faults
        - re-entrancy and setter and getter symmetry is broken (calling setX(getX()) multiple times leads to different result), which is not really acceptable
        - hacky, mirroring x depends on the parent width, meaning x should be updated when parent changes
        - still needs support reversed anchros and positioners to cover the special cases when RTL application goes partly LTR, so doesn't really free us from supporting approach 1.
        - mouse events and position-handling functions need to be mirrored that access content inside an item, like selecting text inside TextEdit, choosing a position on a Map, flicking a Map using pan() function
        -> hacky, we can do this for our elements, but how can we do this automatically for custom visual elements written by Mobility and applications teams
        - no good place to do this as there are containers items that handle mouse handling for their childs childs that are independent
        - the readability of code suffers (e.g. left means right in anchors, x: 4 actually means x: 323)

      3. Mirror the whole scene
      + all layouts and animations are mirrored
      + internally item code and code paths remain intact (e.g. x: 4 still means item property x returns 4, just the scene above is reversed)
      + less code needed for Arabic variants
      - paintable items (content) get mirrored as well
      - Flipable got confused on when to show front and back items, though easy to fix: activeItem = isMirrored ? backItem : frontItem and vice versa
      - dilemma: container items positioning child items should be mirrored, paintable items providing content shouldn't be, a QML element can do both
      - there are mouse event -driven interaction between the scene and the content painted inside the items, causing breakages
      - the mouse event -driven interaction that accesses content inside the items doesn't work, like text selection in TextEdit,
      choosing a position from a Map, flicking a Map using a Map::pan() function
      - we can mirror the item mouse handling to fix interaction accessing content, but that would break MouseAreas handling mouse interactions for many child items
      - no good level to mirror mouse events, geometry-handling code flows from C++ to QML to C++, and from scene to item to scene
      - still needs to support reversed anchros and positioners to cover the special cases for RTL application goes partly LTR, so doesn't really free us from supporting approach 1.
      - the readability of code suffers (left means right in anchors, x: 4 actually means 4 from the right)

      3. a.) Mirror the whole scene, mirror the item painting back
      + all layouts and animations are mirrored
      + the item content painted in right direction
      + child element positioning is still mirrored as they should be
      - double mirroring to get rightly drawn content feels hacky

      3. b.) Mirror the whole scene, mirror content items back
      + the item content painted in right direction
      - double mirroring to get rightly drawn content feels hacky
      - breaks RTL for items parented to the content items

      4. Mirror the painting of the scene

      • item position on the screen gets mirrored during painting
        + all layouts and animations get mirrored
        + internally item code and code paths remain intact (e.g. x: 4 still means item property x returns 4, just the scene above is reversed)
        - mouse handling still needs to be mirrored separately
        - same problems as applying mirroring transformation in approach 3.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jpetrell Joona Petrell
            jpetrell Joona Petrell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes