mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
* Fix focus and screen reader on Dialog #LINQT-2197 * Fix dialer accessibility #LINQT-2204 * Add accessibility to voicemail button #LINQT-2200 *Add list annoncement on magicsearch suggestions #LINQT-2205 * Fix accessibility on contact lists #LINQT-2206 * Fix screen reader does not say values on combobox #LINQT-2195 * Fix focus when close modal #LINQT-2220 * Focus end call button when accepting a call #LINQT-2223
63 lines
2 KiB
C++
63 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2010-2025 Belledonne Communications SARL.
|
|
*
|
|
* This file is part of linphone-desktop
|
|
* (see https://www.linphone.org).
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "FocusNavigator.hpp"
|
|
|
|
#include <QGuiApplication>
|
|
#include <QQuickItem>
|
|
|
|
FocusNavigator::FocusNavigator(QObject *parent) : QObject(parent) {
|
|
connect(qApp, &QGuiApplication::focusObjectChanged, this, &FocusNavigator::onFocusObjectChanged);
|
|
qApp->installEventFilter(this);
|
|
}
|
|
|
|
bool FocusNavigator::doesLastFocusWasKeyboard() {
|
|
return mLastFocusWasKeyboard;
|
|
}
|
|
|
|
QQuickItem *FocusNavigator::getLastFocusItem() {
|
|
return mLastFocusItem;
|
|
}
|
|
|
|
bool FocusNavigator::eventFilter(QObject *obj, QEvent *event) {
|
|
switch (event->type()) {
|
|
case QEvent::FocusIn: {
|
|
auto fe = static_cast<QFocusEvent *>(event);
|
|
if (fe) {
|
|
int focusReason = fe->reason();
|
|
// qDebug() << "New focus object" << obj << "| reason" << focusReason;
|
|
mLastFocusWasKeyboard = (focusReason == Qt::TabFocusReason || focusReason == Qt::BacktabFocusReason);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return QObject::eventFilter(obj, event);
|
|
}
|
|
|
|
void FocusNavigator::onFocusObjectChanged(QObject *obj) {
|
|
// qDebug() << "New focus object" << obj; // Usefull to debug focus problems
|
|
auto item = qobject_cast<QQuickItem *>(obj);
|
|
mLastFocusItem = item;
|
|
if (!item) return;
|
|
emit focusChanged(item, mLastFocusWasKeyboard);
|
|
emit lastFocusItemChanged();
|
|
}
|