gui: add QInputDevice::seatNames()

Change-Id: Ie6cedd62dcd684a8fd9adbc2409e5aa1f3490ede
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Liang Qi 2021-10-25 15:21:27 +02:00
parent 0e72a846d3
commit 143f20692e
2 changed files with 20 additions and 0 deletions

View File

@ -280,6 +280,25 @@ QList<const QInputDevice *> QInputDevice::devices()
return *deviceList(); return *deviceList();
} }
/*!
\since 6.3
Returns a list of seat names for all registered input devices (keyboards and pointing devices).
*/
QStringList QInputDevice::seatNames()
{
QMutexLocker locker(&devicesMutex);
const InputDevicesList devices = *deviceList();
locker.unlock();
QStringList result;
for (const QInputDevice *d : devices) {
if (!result.contains(d->seatName()))
result.append(d->seatName());
}
return result;
}
/*! /*!
Returns the core or master keyboard on the given seat \a seatName. Returns the core or master keyboard on the given seat \a seatName.
*/ */

View File

@ -110,6 +110,7 @@ public:
QString seatName() const; QString seatName() const;
QRect availableVirtualGeometry() const; QRect availableVirtualGeometry() const;
static QStringList seatNames();
static QList<const QInputDevice *> devices(); static QList<const QInputDevice *> devices();
static const QInputDevice *primaryKeyboard(const QString& seatName = QString()); static const QInputDevice *primaryKeyboard(const QString& seatName = QString());