Add stylehint to use querying RTL keyboard support.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Fri, 29 Jun 2012 10:38:53 +0000 (12:38 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 11 Jul 2012 12:52:17 +0000 (14:52 +0200)
Change-Id: Ic58ed7cb64cc7fe60b4d431e9f29e389c62265fc
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
src/gui/kernel/qplatformintegration.cpp
src/gui/kernel/qplatformintegration.h
src/gui/kernel/qstylehints.cpp
src/gui/kernel/qstylehints.h
src/plugins/platforms/windows/qwindowscontext.cpp
src/plugins/platforms/windows/qwindowscontext.h
src/plugins/platforms/windows/qwindowsintegration.cpp
src/widgets/widgets/qlineedit.cpp
src/widgets/widgets/qwidgettextcontrol.cpp

index 3021f63..d9e9c75 100644 (file)
@@ -298,6 +298,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
         return qreal(1.7);
     case StartDragVelocity:
         return 0; // no limit
+    case UseRtlExtensions:
+        return QVariant(false);
     }
 
     return 0;
index ea13a25..8ed48b2 100644 (file)
@@ -133,7 +133,8 @@ public:
         ShowIsFullScreen,
         PasswordMaskDelay,
         FontSmoothingGamma,
-        StartDragVelocity
+        StartDragVelocity,
+        UseRtlExtensions
     };
 
     virtual QVariant styleHint(StyleHint hint) const;
index 194b5d3..99e37e4 100644 (file)
@@ -112,4 +112,9 @@ qreal QStyleHints::fontSmoothingGamma() const
     return hint(QPlatformIntegration::FontSmoothingGamma).toReal();
 }
 
+bool QStyleHints::useRtlExtensions() const
+{
+    return hint(QPlatformIntegration::UseRtlExtensions).toBool();
+}
+
 QT_END_NAMESPACE
index f15679b..a82af89 100644 (file)
@@ -65,6 +65,7 @@ public:
     bool showIsFullScreen() const;
     int passwordMaskDelay() const;
     qreal fontSmoothingGamma() const;
+    bool useRtlExtensions() const;
 
 private:
     friend class QGuiApplication;
index a988aef..7da9ae1 100644 (file)
@@ -335,6 +335,11 @@ unsigned QWindowsContext::systemInfo() const
     return d->m_systemInfo;
 }
 
+bool QWindowsContext::useRTLExtensions() const
+{
+    return d->m_keyMapper.useRTLExtensions();
+}
+
 void QWindowsContext::setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx)
 {
     d->m_creationContext = ctx;
index e95ea7f..0b18196 100644 (file)
@@ -172,6 +172,8 @@ public:
     // Returns a combination of SystemInfoFlags
     unsigned systemInfo() const;
 
+    bool useRTLExtensions() const;
+
     QWindowsMimeConverter &mimeConverter() const;
     QWindowsScreenManager &screenManager();
 #ifndef Q_OS_WINCE
index fea7fec..55662e1 100644 (file)
@@ -408,6 +408,8 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
         if (const int ms = GetDoubleClickTime())
             return QVariant(ms);
         break;
+    case QPlatformIntegration::UseRtlExtensions:
+        return QVariant(d->m_context.useRTLExtensions());
     }
     return QPlatformIntegration::styleHint(hint);
 }
index fc37501..590a006 100644 (file)
@@ -50,6 +50,7 @@
 #include "qdrawutil.h"
 #include "qevent.h"
 #include "qfontmetrics.h"
+#include "qstylehints.h"
 #include "qmenu.h"
 #include "qpainter.h"
 #include "qpixmap.h"
@@ -1992,10 +1993,6 @@ void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
     }
 }
 
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
-    extern bool qt_use_rtl_extensions;
-#endif
-
 /*!  This function creates the standard context menu which is shown
         when the user clicks on the line edit with the right mouse
         button. It is called from the default contextMenuEvent() handler.
@@ -2055,11 +2052,7 @@ QMenu *QLineEdit::createStandardContextMenu()
     d->selectAllAction = action;
     connect(action, SIGNAL(triggered()), SLOT(selectAll()));
 
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
-    if (!d->control->isReadOnly() && qt_use_rtl_extensions) {
-#else
-    if (!d->control->isReadOnly()) {
-#endif
+    if (!d->control->isReadOnly() && qApp->styleHints()->useRtlExtensions()) {
         popup->addSeparator();
         QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, popup);
         popup->addMenu(ctrlCharacterMenu);
index 3448bf8..b21d7b8 100644 (file)
@@ -64,6 +64,7 @@
 #include "qpagedpaintdevice.h"
 #include "private/qpagedpaintdevice_p.h"
 #include "qtextdocumentwriter.h"
+#include "qstylehints.h"
 #include "private/qtextcursor_p.h"
 
 #include <qtextformat.h>
 
 QT_BEGIN_NAMESPACE
 
-#ifndef QT_NO_CONTEXTMENU
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
-extern bool qt_use_rtl_extensions;
-#endif
-#endif
-
 // could go into QTextCursor...
 static QTextLine currentTextLine(const QTextCursor &cursor)
 {
@@ -2181,11 +2176,7 @@ QMenu *QWidgetTextControl::createStandardContextMenu(const QPointF &pos, QWidget
         a->setEnabled(!d->doc->isEmpty());
     }
 
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
-    if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
-#else
-    if (d->interactionFlags & Qt::TextEditable) {
-#endif
+    if ((d->interactionFlags & Qt::TextEditable) && qApp->styleHints()->useRtlExtensions()) {
         menu->addSeparator();
         QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu);
         menu->addMenu(ctrlCharacterMenu);