From eb4103e0b9d688d88146e434aa5840f944826f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 20 Sep 2023 21:29:16 +0200 Subject: [PATCH] Remove QKeyMapperPrivate There is no point in maintaining the keyboardInputLocale and keyboardInputDirection in the QKeyMapperPrivate, as these things are handled by QInputContext nowadays. The values were never updated either, so the base class implementation of QPlatformInputContext referring to them was confusing. With those gone, we can remove the entire class. Subclasses of QPlatformInputContext typically only override locale(), so we now base the input language direction on the current locale(), giving dynamic updates of the direction as well (without the signal, but this will be fixed in a follow up patch). Change-Id: I16ae4097eadadd278e60edea3c1101ab90ed7444 Reviewed-by: Liang Qi --- src/gui/kernel/qkeymapper.cpp | 18 +----------------- src/gui/kernel/qkeymapper_p.h | 19 ------------------- src/gui/kernel/qplatforminputcontext.cpp | 4 ++-- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp index b5405e3a54..d41f0bfdf3 100644 --- a/src/gui/kernel/qkeymapper.cpp +++ b/src/gui/kernel/qkeymapper.cpp @@ -23,8 +23,7 @@ QT_BEGIN_NAMESPACE /*! Constructs a new key mapper. */ -QKeyMapper::QKeyMapper() - : QObject(*new QKeyMapperPrivate, nullptr) +QKeyMapper::QKeyMapper() : QObject() { } @@ -73,21 +72,6 @@ QKeyMapper *QKeyMapper::instance() return keymapper(); } -QKeyMapperPrivate *qt_keymapper_private() -{ - return QKeyMapper::instance()->d_func(); -} - -QKeyMapperPrivate::QKeyMapperPrivate() -{ - keyboardInputLocale = QLocale::system(); - keyboardInputDirection = keyboardInputLocale.textDirection(); -} - -QKeyMapperPrivate::~QKeyMapperPrivate() -{ -} - void *QKeyMapper::resolveInterface(const char *name, int revision) const { Q_UNUSED(name); Q_UNUSED(revision); diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 6c9ea2f22c..2c36bcc5c5 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -25,7 +25,6 @@ QT_BEGIN_NAMESPACE -class QKeyMapperPrivate; class Q_GUI_EXPORT QKeyMapper : public QObject { Q_OBJECT @@ -40,27 +39,9 @@ public: QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QKeyMapper) private: - friend QKeyMapperPrivate *qt_keymapper_private(); - Q_DECLARE_PRIVATE(QKeyMapper) Q_DISABLE_COPY_MOVE(QKeyMapper) }; -struct KeyboardLayoutItem; -class QKeyEvent; - -class QKeyMapperPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QKeyMapper) -public: - QKeyMapperPrivate(); - ~QKeyMapperPrivate(); - - QLocale keyboardInputLocale; - Qt::LayoutDirection keyboardInputDirection; -}; - -QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp - // ----------------- QNativeInterface ----------------- namespace QNativeInterface::Private { diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp index 985cefa12c..4cf7acea2e 100644 --- a/src/gui/kernel/qplatforminputcontext.cpp +++ b/src/gui/kernel/qplatforminputcontext.cpp @@ -192,7 +192,7 @@ void QPlatformInputContext::emitInputPanelVisibleChanged() QLocale QPlatformInputContext::locale() const { - return qt_keymapper_private()->keyboardInputLocale; + return QLocale::system(); } void QPlatformInputContext::emitLocaleChanged() @@ -202,7 +202,7 @@ void QPlatformInputContext::emitLocaleChanged() Qt::LayoutDirection QPlatformInputContext::inputDirection() const { - return qt_keymapper_private()->keyboardInputDirection; + return locale().textDirection(); } void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection)