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 <liang.qi@qt.io>
bb10
Tor Arne Vestbø 2023-09-20 21:29:16 +02:00
parent fdf7774bc6
commit eb4103e0b9
3 changed files with 3 additions and 38 deletions

View File

@ -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);

View File

@ -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 {

View File

@ -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)