QmlDesigner: Add indicator/warning if accessibility is disabled on macOS

Task-number: QDS-12889
Change-Id: I286628492e1ef195eafd529bf090c027d3bdde8b
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Ali Kianian <ali.kianian@qt.io>
This commit is contained in:
Shrief Gabr
2024-05-31 00:11:33 +03:00
parent 68123d07df
commit e00d00c069
7 changed files with 69 additions and 33 deletions

View File

@@ -12,9 +12,10 @@ Rectangle {
id: root
property int toolTipDelay: 1000
property bool qdsTrusted: isQDSTrusted()
width: 260
height: 150
height: root.qdsTrusted ? 150 : 210
color: StudioTheme.Values.themePanelBackground
border.color: StudioTheme.Values.themeControlOutline
border.width: StudioTheme.Values.border
@@ -151,6 +152,43 @@ Rectangle {
onClicked: resetDefaults()
}
}
Rectangle {
visible: !root.qdsTrusted
color: "transparent"
border.color: StudioTheme.Values.themeWarning
Layout.fillWidth: true
Layout.fillHeight: true
RowLayout {
anchors.fill: parent
HelperWidgets.IconLabel {
icon: StudioTheme.Constants.warning_medium
pixelSize: StudioTheme.Values.mediumIconFontSize
Layout.leftMargin: 10
}
Text {
text: qsTr('<p>You only have partial control in fly mode. For full control, please
enable the <span style="text-decoration: underline">Accessibility settings</span></p>')
color: StudioTheme.Values.themeTextColor
wrapMode: Text.WordWrap
Layout.fillWidth: true
Layout.margins: 6
textFormat: Text.RichText
MouseArea {
anchors.fill: parent
onClicked: {
Qt.openUrlExternally("x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")
accessibilityOpened()
}
}
}
}
}
}
}
}

View File

@@ -2,13 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "cameraspeedconfiguration.h"
#include "designersettings.h"
#include "edit3dview.h"
#include "edit3dviewconfig.h"
#include <coreplugin/icore.h>
#include <utils/environment.h>
#include <QCursor>
@@ -193,4 +189,9 @@ bool CameraSpeedConfiguration::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
bool CameraSpeedConfiguration::isQDSTrusted() const
{
return Edit3DView::isQDSTrusted();
}
} // namespace QmlDesigner

View File

@@ -39,6 +39,7 @@ public:
Q_INVOKABLE void restoreCursor();
Q_INVOKABLE void holdCursorInPlace();
Q_INVOKABLE int devicePixelRatio();
Q_INVOKABLE bool isQDSTrusted() const;
void cancel();
void apply();
@@ -58,6 +59,7 @@ signals:
void speedChanged();
void multiplierChanged();
void totalSpeedChanged();
void accessibilityOpened();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;

View File

@@ -81,21 +81,13 @@ QWidget *Edit3DCanvas::busyIndicator() const
return m_busyIndicator;
}
#ifdef Q_OS_MACOS
extern "C" bool AXIsProcessTrusted();
#endif
void Edit3DCanvas::setFlyMode(bool enabled, const QPoint &pos)
{
if (m_flyMode == enabled)
return;
#ifdef Q_OS_MACOS
if (!AXIsProcessTrusted())
m_isTrusted = false;
#endif
m_flyMode = enabled;
m_isQDSTrusted = Edit3DView::isQDSTrusted();
if (enabled) {
m_flyModeStartTime = QDateTime::currentMSecsSinceEpoch();
@@ -199,7 +191,7 @@ void Edit3DCanvas::mouseMoveEvent(QMouseEvent *e)
// We notify explicit camera rotation need for puppet rather than rely in mouse events,
// as mouse isn't grabbed on puppet side and can't handle fast movements that go out of
// edit camera mouse area. This also simplifies split view handling.
QPointF diff = m_isTrusted ? (m_hiddenCursorPos - e->globalPos()) : (m_lastCursorPos - e->globalPos());
QPointF diff = m_isQDSTrusted ? (m_hiddenCursorPos - e->globalPos()) : (m_lastCursorPos - e->globalPos());
if (e->buttons() == (Qt::LeftButton | Qt::RightButton)) {
m_parent->view()->emitView3DAction(View3DActionType::EditCameraMove,
@@ -212,7 +204,7 @@ void Edit3DCanvas::mouseMoveEvent(QMouseEvent *e)
m_flyModeFirstUpdate = false;
}
if (m_isTrusted)
if (m_isQDSTrusted)
QCursor::setPos(m_hiddenCursorPos);
else
m_lastCursorPos = e->globalPos();

View File

@@ -53,7 +53,7 @@ private:
qint32 m_activeScene = -1;
QElapsedTimer m_usageTimer;
qreal m_opacity = 1.0;
bool m_isTrusted = true;
bool m_isQDSTrusted = true;
QWidget *m_busyIndicator = nullptr;
bool m_flyMode = false;
QPoint m_flyModeStartCursorPos;

View File

@@ -42,7 +42,6 @@
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <utils/utilsicons.h>
#include <QToolButton>
namespace QmlDesigner {
@@ -57,19 +56,6 @@ inline static QIcon toolbarIcon(const DesignerIcons::IconId &iconId)
return DesignerActionManager::instance().toolbarIcon(iconId);
};
#ifdef Q_OS_MACOS
extern "C" bool AXIsProcessTrusted();
#endif
static bool isAXITrusted()
{
#ifdef Q_OS_MACOS
return AXIsProcessTrusted();
#else
return true;
#endif
}
Edit3DView::Edit3DView(ExternalDependenciesInterface &externalDependencies)
: AbstractView{externalDependencies}
{
@@ -1323,7 +1309,11 @@ void Edit3DView::createEdit3DActions()
this, [this] {
setCameraSpeedAuxData(m_cameraSpeedConfiguration->speed(),
m_cameraSpeedConfiguration->multiplier());
});
});
connect(m_cameraSpeedConfiguration.data(), &CameraSpeedConfiguration::accessibilityOpened,
this, [this] {
m_cameraSpeedConfigAction->setIndicator(false);
});
}
m_cameraSpeedConfiguration->showConfigDialog(resolveToolbarPopupPos(m_cameraSpeedConfigAction.get()));
};
@@ -1337,7 +1327,7 @@ void Edit3DView::createEdit3DActions()
cameraSpeedConfigTrigger,
this);
m_cameraSpeedConfigAction->setIndicator(!isAXITrusted());
m_cameraSpeedConfigAction->setIndicator(!isQDSTrusted());
m_leftActions << m_selectionModeAction.get();
m_leftActions << nullptr; // Null indicates separator

View File

@@ -18,6 +18,10 @@
#include <QVector>
#include <QVector3D>
#ifdef Q_OS_MACOS
extern "C" bool AXIsProcessTrusted();
#endif
QT_BEGIN_NAMESPACE
class QAction;
class QInputEvent;
@@ -41,6 +45,15 @@ public:
bool showWireframe = false;
};
static bool isQDSTrusted()
{
#ifdef Q_OS_MACOS
return AXIsProcessTrusted();
#else
return true;
#endif
}
Edit3DView(ExternalDependenciesInterface &externalDependencies);
WidgetInfo widgetInfo() override;