|
|
@ -18,21 +18,23 @@ |
|
|
|
using qrcodegen::QrCode; |
|
|
|
using qrcodegen::QrCode; |
|
|
|
|
|
|
|
|
|
|
|
PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) { |
|
|
|
PairingQRWidget::PairingQRWidget(QWidget* parent) : QWidget(parent) { |
|
|
|
QTimer* timer = new QTimer(this); |
|
|
|
timer = new QTimer(this); |
|
|
|
timer->start(5 * 60 * 1000); |
|
|
|
|
|
|
|
connect(timer, &QTimer::timeout, this, &PairingQRWidget::refresh); |
|
|
|
connect(timer, &QTimer::timeout, this, &PairingQRWidget::refresh); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PairingQRWidget::showEvent(QShowEvent *event) { |
|
|
|
void PairingQRWidget::showEvent(QShowEvent *event) { |
|
|
|
refresh(); |
|
|
|
refresh(); |
|
|
|
|
|
|
|
timer->start(5 * 60 * 1000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PairingQRWidget::hideEvent(QHideEvent *event) { |
|
|
|
|
|
|
|
timer->stop(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PairingQRWidget::refresh() { |
|
|
|
void PairingQRWidget::refresh() { |
|
|
|
if (isVisible()) { |
|
|
|
|
|
|
|
QString pairToken = CommaApi::create_jwt({{"pair", true}}); |
|
|
|
QString pairToken = CommaApi::create_jwt({{"pair", true}}); |
|
|
|
QString qrString = "https://connect.comma.ai/?pair=" + pairToken; |
|
|
|
QString qrString = "https://connect.comma.ai/?pair=" + pairToken; |
|
|
|
this->updateQrCode(qrString); |
|
|
|
this->updateQrCode(qrString); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PairingQRWidget::updateQrCode(const QString &text) { |
|
|
|
void PairingQRWidget::updateQrCode(const QString &text) { |
|
|
|