-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added share vpn key to subscription settings page
- Loading branch information
Showing
12 changed files
with
147 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "qrCodeUtils.h" | ||
|
||
#include <QIODevice> | ||
#include <QList> | ||
|
||
QList<QString> qrCodeUtuls::generateQrCodeImageSeries(const QByteArray &data) | ||
{ | ||
double k = 850; | ||
|
||
quint8 chunksCount = std::ceil(data.size() / k); | ||
QList<QString> chunks; | ||
for (int i = 0; i < data.size(); i = i + k) { | ||
QByteArray chunk; | ||
QDataStream s(&chunk, QIODevice::WriteOnly); | ||
s << qrCodeUtuls::qrMagicCode << chunksCount << (quint8)std::round(i / k) << data.mid(i, k); | ||
|
||
QByteArray ba = chunk.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); | ||
|
||
qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(ba, qrcodegen::QrCode::Ecc::LOW); | ||
QString svg = QString::fromStdString(toSvgString(qr, 1)); | ||
chunks.append(svgToBase64(svg)); | ||
} | ||
|
||
return chunks; | ||
} | ||
|
||
QString qrCodeUtuls::svgToBase64(const QString &image) | ||
{ | ||
return "data:image/svg;base64," + QString::fromLatin1(image.toUtf8().toBase64().data()); | ||
} | ||
|
||
qrcodegen::QrCode qrCodeUtuls::generateQrCode(const QByteArray &data) | ||
{ | ||
return qrcodegen::QrCode::encodeText(data, qrcodegen::QrCode::Ecc::LOW); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef QRCODEUTILS_H | ||
#define QRCODEUTILS_H | ||
|
||
#include <QString> | ||
|
||
#include "qrcodegen.hpp" | ||
|
||
namespace qrCodeUtuls | ||
{ | ||
constexpr const qint16 qrMagicCode = 1984; | ||
|
||
QList<QString> generateQrCodeImageSeries(const QByteArray &data); | ||
qrcodegen::QrCode generateQrCode(const QByteArray &data); | ||
QString svgToBase64(const QString &image); | ||
}; | ||
|
||
#endif // QRCODEUTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.