1
0
Fork 0
mirror of https://github.com/seiichiro0185/sailotp.git synced 2024-12-25 12:42:30 +00:00

Cleanup and minor Fixes

This commit is contained in:
seiichiro 2014-05-24 19:13:42 +02:00
parent 14f725f364
commit 8de63f5f68
5 changed files with 46 additions and 29 deletions

View file

@ -39,57 +39,62 @@ Lizenz: BSD (3-Klausel)</translation>
<translation>QR-Code anzeigen</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="76"/>
<location filename="../qml/pages/AddOTP.qml" line="69"/>
<source>Can&apos;t create QR-Code from incomplete settings!</source>
<translation>Ein QR-Code kann nur mit vollständigen Einstellungen erzeugt werden!</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="82"/>
<source>Save</source>
<translation>Speichern</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="76"/>
<location filename="../qml/pages/AddOTP.qml" line="82"/>
<source>Add</source>
<translation>Hinzufügen</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="81"/>
<location filename="../qml/pages/AddOTP.qml" line="87"/>
<source>Type</source>
<translation>Typ</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="83"/>
<location filename="../qml/pages/AddOTP.qml" line="89"/>
<source>Time-based (TOTP)</source>
<translation>Zeitbasiert (TOTP)</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="84"/>
<location filename="../qml/pages/AddOTP.qml" line="90"/>
<source>Counter-based (HOTP)</source>
<translation>Zählerbasiert (HOTP)</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="90"/>
<location filename="../qml/pages/AddOTP.qml" line="96"/>
<source>Title</source>
<translation>Titel</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="91"/>
<location filename="../qml/pages/AddOTP.qml" line="97"/>
<source>Title for the OTP</source>
<translation>Titel für das Token</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="103"/>
<location filename="../qml/pages/AddOTP.qml" line="109"/>
<source>Secret (at least 16 characters)</source>
<translation>Schlüssel (mindestens 16 Zeichen)</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="105"/>
<location filename="../qml/pages/AddOTP.qml" line="111"/>
<source>Secret OTP Key</source>
<translation>Geheimer Schlüssel</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="117"/>
<location filename="../qml/pages/AddOTP.qml" line="123"/>
<source>Next Counter Value</source>
<translation>Nächster Zählerwert</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="119"/>
<location filename="../qml/pages/AddOTP.qml" line="125"/>
<source>Next Value of the Counter</source>
<translation>Nächster Wert für den Zähler</translation>
</message>
@ -283,7 +288,7 @@ Lizenz: BSD (3-Klausel)</translation>
<context>
<name>QRPage</name>
<message>
<location filename="../qml/pages/QRPage.qml" line="70"/>
<location filename="../qml/pages/QRPage.qml" line="71"/>
<source>Can&apos;t create QR-Code from incomplete settings!</source>
<translation>Ein QR-Code kann nur mit vollständigen Einstellungen erzeugt werden!</translation>
</message>

View file

@ -29,57 +29,62 @@ License: BSD (3-clause)</source>
<translation>Show QR-Code</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="76"/>
<location filename="../qml/pages/AddOTP.qml" line="69"/>
<source>Can&apos;t create QR-Code from incomplete settings!</source>
<translation>Can&apos;t create QR-Code from incomplete settings!</translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="82"/>
<source>Save</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="76"/>
<location filename="../qml/pages/AddOTP.qml" line="82"/>
<source>Add</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="81"/>
<location filename="../qml/pages/AddOTP.qml" line="87"/>
<source>Type</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="83"/>
<location filename="../qml/pages/AddOTP.qml" line="89"/>
<source>Time-based (TOTP)</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="84"/>
<location filename="../qml/pages/AddOTP.qml" line="90"/>
<source>Counter-based (HOTP)</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="90"/>
<location filename="../qml/pages/AddOTP.qml" line="96"/>
<source>Title</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="91"/>
<location filename="../qml/pages/AddOTP.qml" line="97"/>
<source>Title for the OTP</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="103"/>
<location filename="../qml/pages/AddOTP.qml" line="109"/>
<source>Secret (at least 16 characters)</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="105"/>
<location filename="../qml/pages/AddOTP.qml" line="111"/>
<source>Secret OTP Key</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="117"/>
<location filename="../qml/pages/AddOTP.qml" line="123"/>
<source>Next Counter Value</source>
<translation></translation>
</message>
<message>
<location filename="../qml/pages/AddOTP.qml" line="119"/>
<location filename="../qml/pages/AddOTP.qml" line="125"/>
<source>Next Value of the Counter</source>
<translation></translation>
</message>
@ -265,7 +270,7 @@ License: BSD (3-clause)</source>
<context>
<name>QRPage</name>
<message>
<location filename="../qml/pages/QRPage.qml" line="70"/>
<location filename="../qml/pages/QRPage.qml" line="71"/>
<source>Can&apos;t create QR-Code from incomplete settings!</source>
<translation>Can&apos;t create QR-Code from incomplete settings!</translation>
</message>

View file

@ -64,7 +64,13 @@ Dialog {
visible: checkQR()
MenuItem {
text: qsTr("Show QR-Code")
onClicked: pageStack.push(Qt.resolvedUrl("QRPage.qml"), {paramLabel: otpLabel.text, paramKey: otpSecret.text, paramType: paramType, paramCounter: otpCounter.text})
onClicked: {
if ((paramType == "TOTP" && (otpLabel.text == "" || otpSecret.text == "")) || (paramType == "HOTP" && (otpLabel.text == "" || otpSecret.text == "" || otpCounter.text <= 0))) {
notify.show(qsTr("Can't create QR-Code from incomplete settings!"), 4000);
} else {
pageStack.push(Qt.resolvedUrl("QRPage.qml"), {paramLabel: otpLabel.text, paramKey: otpSecret.text, paramType: paramType, paramCounter: otpCounter.text});
}
}
}
}

View file

@ -51,6 +51,7 @@ Page {
id: qrImage
anchors.horizontalCenter: parent.horizontalCenter
y: 200
cache: false
}
Component.onCompleted: {
@ -61,7 +62,7 @@ Page {
otpurl = "otpauth://totp/"+paramLabel+"?secret="+paramKey;
} else if (paramType == "HOTP") {
if (paramLabel != "" && paramKey != "" && paramCounter > 0) return;
if (paramLabel != "" && paramKey != "" && paramCounter > 0)
otpurl = "otpauth://hotp/"+paramLabel+"?secret="+paramKey+"&counter="+paramCounter;
}
if (otpurl != "") {

View file

@ -13,9 +13,9 @@ QImage QQRencoder::requestImage(const QString &id, QSize *size, const QSize &req
// Encode QR-Data
QRcode *qrdata = QRcode_encodeString(qPrintable(id), 0, QR_ECLEVEL_M, QR_MODE_8, 1);
// Calculate width of the image
// Calculate qr-pixel size
int datawidth = qrdata->width;
int pixsize = static_cast<int>((imgSize - 16) / datawidth);
int pixsize = static_cast<int>((imgSize - 64) / datawidth);
// allocate memory for the image
QImage image(imgSize, imgSize, QImage::Format_Mono);
@ -26,7 +26,7 @@ QImage QQRencoder::requestImage(const QString &id, QSize *size, const QSize &req
painter.fillRect(image.rect(),Qt::white);
for(int x=0;x<datawidth;x++) {
for(int y=0;y<datawidth;y++) {
if(1 & qrdata->data[y*datawidth+x]) painter.fillRect(QRect(x*pixsize+16, y*pixsize+16, pixsize, pixsize), Qt::black);
if(1 & qrdata->data[y*datawidth+x]) painter.fillRect(QRect(x*pixsize+32, y*pixsize+32, pixsize, pixsize), Qt::black);
}
}