diff options
author | Piotr Mikolajczyk <piotr.mikolajczyk@qt.io> | 2021-02-25 15:36:29 +0100 |
---|---|---|
committer | Piotr Mikolajczyk <piotr.mikolajczyk@qt.io> | 2021-03-30 10:35:59 +0200 |
commit | c80f262258b7846bf199887bcfdbb6dcfda6ad6f (patch) | |
tree | 509ec5a3dde42db3af4fa29f6a1fe7f154f85e98 /src/widgets/widgets/qtextbrowser.cpp | |
parent | 9275edbc31a0ca83740df5b4450b7776c59012dc (diff) |
Android: Add select and copy capability to read-only text widgets
In case of a read-only text editing widget it was imposibble to copy text
from it. In QtWidgets you could not even see the selection handless.
Text selection in QtWidgets module was filtered depending on readOnly
property of the widget. Additionally, in InputMethod the read-only state
was translated into disabled.
Patch also makes the edit menu to be aware of the read-only status of
the control - the menu items are different for rw and ro controls.
Task-number: QTBUG-91417
Change-Id: Ic7b27f78678eeaa87a38607af787f254db1383b8
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qtextbrowser.cpp')
-rw-r--r-- | src/widgets/widgets/qtextbrowser.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp index 99ebaa93bf..6b05156ea3 100644 --- a/src/widgets/widgets/qtextbrowser.cpp +++ b/src/widgets/widgets/qtextbrowser.cpp @@ -57,6 +57,15 @@ QT_BEGIN_NAMESPACE +static inline bool shouldEnableInputMethod(QTextBrowser *texbrowser) +{ +#if defined (Q_OS_ANDROID) + return !texbrowser->isReadOnly() || (texbrowser->textInteractionFlags() & Qt::TextSelectableByMouse); +#else + return !texbrowser->isReadOnly(); +#endif +} + Q_LOGGING_CATEGORY(lcBrowser, "qt.text.browser") class QTextBrowserPrivate : public QTextEditPrivate @@ -692,7 +701,7 @@ void QTextBrowserPrivate::init() #ifndef QT_NO_CURSOR viewport->setCursor(oldCursor); #endif - q->setAttribute(Qt::WA_InputMethodEnabled, !q->isReadOnly()); + q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(q)); q->setUndoRedoEnabled(false); viewport->setMouseTracking(true); QObject::connect(q->document(), SIGNAL(contentsChanged()), q, SLOT(_q_documentModified())); |