mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
fixed UI scanner iOS
This commit is contained in:
@@ -166,7 +166,9 @@ bool PairingUiController::isPairingCameraAccessGranted() const
|
||||
#if defined(Q_OS_ANDROID)
|
||||
return AndroidController::instance()->isCameraPermissionGranted();
|
||||
#elif defined(Q_OS_IOS)
|
||||
return amneziaIosPairingCameraAccessGranted();
|
||||
const bool ok = amneziaIosPairingCameraAccessGranted();
|
||||
qInfo() << "[PairingUi] iOS isPairingCameraAccessGranted =" << ok;
|
||||
return ok;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
@@ -178,6 +180,7 @@ void PairingUiController::requestPairingCameraAccess()
|
||||
AndroidController::instance()->requestCameraPermissionForQrPairing();
|
||||
#elif defined(Q_OS_IOS)
|
||||
amneziaIosRequestPairingCameraAccess([this](bool granted) {
|
||||
qInfo() << "[PairingUi] iOS requestPairingCameraAccess callback granted =" << granted;
|
||||
QMetaObject::invokeMethod(
|
||||
this, [this, granted]() { emit pairingCameraAccessFinished(granted); }, Qt::QueuedConnection);
|
||||
});
|
||||
@@ -195,6 +198,44 @@ void PairingUiController::openPairingCameraAppSettings()
|
||||
#endif
|
||||
}
|
||||
|
||||
void PairingUiController::setEmbeddedPairingQrCameraActive(bool active)
|
||||
{
|
||||
if (m_embeddedPairingQrCameraActive == active) {
|
||||
return;
|
||||
}
|
||||
m_embeddedPairingQrCameraActive = active;
|
||||
#if defined(Q_OS_IOS)
|
||||
qInfo() << "[PairingUi] iOS embeddedPairingQrCameraActive ->" << active;
|
||||
amneziaIosApplyEmbeddedCameraUnderlayToQtView(active);
|
||||
#endif
|
||||
#if defined(Q_OS_ANDROID)
|
||||
if (active) {
|
||||
AndroidController::instance()->startPairingQrEmbeddedCamera();
|
||||
} else {
|
||||
AndroidController::instance()->stopPairingQrEmbeddedCamera();
|
||||
}
|
||||
#endif
|
||||
emit embeddedPairingQrCameraActiveChanged();
|
||||
}
|
||||
|
||||
void PairingUiController::syncIosEmbeddedPairingQrNativeBottomExtra(int extraPt)
|
||||
{
|
||||
#if defined(Q_OS_IOS)
|
||||
amneziaIosSetPairingEmbeddedCameraNativeBottomExtraPt(extraPt);
|
||||
#else
|
||||
Q_UNUSED(extraPt);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PairingUiController::setPairingQrTorchEnabled(bool enabled)
|
||||
{
|
||||
#if defined(Q_OS_ANDROID)
|
||||
AndroidController::instance()->setPairingQrEmbeddedTorch(enabled);
|
||||
#else
|
||||
Q_UNUSED(enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PairingUiController::applyScannedTextAsPairingUuid(const QString &raw)
|
||||
{
|
||||
const QString t = raw.trimmed();
|
||||
@@ -522,6 +563,8 @@ void PairingUiController::cancelAllPairingActivity()
|
||||
}
|
||||
|
||||
cancelTvQrSession();
|
||||
|
||||
setEmbeddedPairingQrCameraActive(false);
|
||||
}
|
||||
|
||||
void PairingUiController::submitPhonePairing(const QString &qrUuid, int serverIndex)
|
||||
|
||||
@@ -35,6 +35,9 @@ class PairingUiController : public QObject
|
||||
lastSuccessfulPhonePairingDisplayNameChanged)
|
||||
/** TV flow for QA: 0=idle, 1=waitingForPeer, 2=error, 3=sessionExpired */
|
||||
Q_PROPERTY(int tvPairingUiPhase READ tvPairingUiPhase NOTIFY tvPairingUiPhaseChanged)
|
||||
/** Full-screen pairing QR camera under QML (mobile); drives translucent main window. */
|
||||
Q_PROPERTY(bool embeddedPairingQrCameraActive READ embeddedPairingQrCameraActive WRITE setEmbeddedPairingQrCameraActive NOTIFY
|
||||
embeddedPairingQrCameraActiveChanged)
|
||||
|
||||
public:
|
||||
PairingUiController(PairingController *pairingController, ServersController *serversController,
|
||||
@@ -55,6 +58,10 @@ public:
|
||||
void setPendingPhonePairingUuid(const QString &uuid);
|
||||
QString lastSuccessfulPhonePairingDisplayName() const { return m_lastSuccessfulPhonePairingDisplayName; }
|
||||
int tvPairingUiPhase() const { return m_tvPairingUiPhase; }
|
||||
bool embeddedPairingQrCameraActive() const { return m_embeddedPairingQrCameraActive; }
|
||||
Q_INVOKABLE void setEmbeddedPairingQrCameraActive(bool active);
|
||||
/** iOS: native dim strip height uses safe bottom + extraPt (see PageSettingsApiQrPairingSend scanDimBleedBottom). No-op elsewhere. */
|
||||
Q_INVOKABLE void syncIosEmbeddedPairingQrNativeBottomExtra(int extraPt);
|
||||
|
||||
#if defined(Q_OS_ANDROID)
|
||||
static bool tryConsumeAndroidQrScan(const QString &code);
|
||||
@@ -80,6 +87,8 @@ public slots:
|
||||
Q_INVOKABLE void requestPairingCameraAccess();
|
||||
/** Open system settings for this app (camera can be enabled there). No-op on desktop. */
|
||||
Q_INVOKABLE void openPairingCameraAppSettings();
|
||||
/** Android: torch for embedded pairing camera. No-op elsewhere. */
|
||||
Q_INVOKABLE void setPairingQrTorchEnabled(bool enabled);
|
||||
|
||||
/** If \a raw contains a session UUID (not vpn://), emits pairingUuidFromScan and returns true. */
|
||||
bool applyScannedTextAsPairingUuid(const QString &raw);
|
||||
@@ -106,6 +115,7 @@ signals:
|
||||
void tvPairingUiPhaseChanged();
|
||||
/** After requestPairingCameraAccess(): true if OS granted camera access. */
|
||||
void pairingCameraAccessFinished(bool granted);
|
||||
void embeddedPairingQrCameraActiveChanged();
|
||||
|
||||
private:
|
||||
void setTvBusy(bool busy);
|
||||
@@ -138,6 +148,8 @@ private:
|
||||
QPointer<QFutureWatcher<QPair<amnezia::ErrorCode, QByteArray>>> m_phoneWatcher;
|
||||
QPointer<QNetworkReply> m_phoneNetworkReply;
|
||||
quint64 m_phoneSessionGeneration { 0 };
|
||||
|
||||
bool m_embeddedPairingQrCameraActive = false;
|
||||
};
|
||||
|
||||
#endif // PAIRINGUICONTROLLER_H
|
||||
|
||||
Reference in New Issue
Block a user