1
0
Fork 0
mirror of https://github.com/seiichiro0185/sailotp.git synced 2024-11-25 00:29:42 +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> <translation>QR-Code anzeigen</translation>
</message> </message>
<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> <source>Save</source>
<translation>Speichern</translation> <translation>Speichern</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="76"/> <location filename="../qml/pages/AddOTP.qml" line="82"/>
<source>Add</source> <source>Add</source>
<translation>Hinzufügen</translation> <translation>Hinzufügen</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="81"/> <location filename="../qml/pages/AddOTP.qml" line="87"/>
<source>Type</source> <source>Type</source>
<translation>Typ</translation> <translation>Typ</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="83"/> <location filename="../qml/pages/AddOTP.qml" line="89"/>
<source>Time-based (TOTP)</source> <source>Time-based (TOTP)</source>
<translation>Zeitbasiert (TOTP)</translation> <translation>Zeitbasiert (TOTP)</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="84"/> <location filename="../qml/pages/AddOTP.qml" line="90"/>
<source>Counter-based (HOTP)</source> <source>Counter-based (HOTP)</source>
<translation>Zählerbasiert (HOTP)</translation> <translation>Zählerbasiert (HOTP)</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="90"/> <location filename="../qml/pages/AddOTP.qml" line="96"/>
<source>Title</source> <source>Title</source>
<translation>Titel</translation> <translation>Titel</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="91"/> <location filename="../qml/pages/AddOTP.qml" line="97"/>
<source>Title for the OTP</source> <source>Title for the OTP</source>
<translation>Titel für das Token</translation> <translation>Titel für das Token</translation>
</message> </message>
<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> <source>Secret (at least 16 characters)</source>
<translation>Schlüssel (mindestens 16 Zeichen)</translation> <translation>Schlüssel (mindestens 16 Zeichen)</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="105"/> <location filename="../qml/pages/AddOTP.qml" line="111"/>
<source>Secret OTP Key</source> <source>Secret OTP Key</source>
<translation>Geheimer Schlüssel</translation> <translation>Geheimer Schlüssel</translation>
</message> </message>
<message> <message>
<location filename="../qml/pages/AddOTP.qml" line="117"/> <location filename="../qml/pages/AddOTP.qml" line="123"/>
<source>Next Counter Value</source> <source>Next Counter Value</source>
<translation>Nächster Zählerwert</translation> <translation>Nächster Zählerwert</translation>
</message> </message>
<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> <source>Next Value of the Counter</source>
<translation>Nächster Wert für den Zähler</translation> <translation>Nächster Wert für den Zähler</translation>
</message> </message>
@ -283,7 +288,7 @@ Lizenz: BSD (3-Klausel)</translation>
<context> <context>
<name>QRPage</name> <name>QRPage</name>
<message> <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> <source>Can&apos;t create QR-Code from incomplete settings!</source>
<translation>Ein QR-Code kann nur mit vollständigen Einstellungen erzeugt werden!</translation> <translation>Ein QR-Code kann nur mit vollständigen Einstellungen erzeugt werden!</translation>
</message> </message>

View file

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

View file

@ -64,7 +64,13 @@ Dialog {
visible: checkQR() visible: checkQR()
MenuItem { MenuItem {
text: qsTr("Show QR-Code") 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 id: qrImage
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
y: 200 y: 200
cache: false
} }
Component.onCompleted: { Component.onCompleted: {
@ -61,7 +62,7 @@ Page {
otpurl = "otpauth://totp/"+paramLabel+"?secret="+paramKey; otpurl = "otpauth://totp/"+paramLabel+"?secret="+paramKey;
} else if (paramType == "HOTP") { } else if (paramType == "HOTP") {
if (paramLabel != "" && paramKey != "" && paramCounter > 0) return; if (paramLabel != "" && paramKey != "" && paramCounter > 0)
otpurl = "otpauth://hotp/"+paramLabel+"?secret="+paramKey+"&counter="+paramCounter; otpurl = "otpauth://hotp/"+paramLabel+"?secret="+paramKey+"&counter="+paramCounter;
} }
if (otpurl != "") { if (otpurl != "") {

View file

@ -13,9 +13,9 @@ QImage QQRencoder::requestImage(const QString &id, QSize *size, const QSize &req
// Encode QR-Data // Encode QR-Data
QRcode *qrdata = QRcode_encodeString(qPrintable(id), 0, QR_ECLEVEL_M, QR_MODE_8, 1); 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 datawidth = qrdata->width;
int pixsize = static_cast<int>((imgSize - 16) / datawidth); int pixsize = static_cast<int>((imgSize - 64) / datawidth);
// allocate memory for the image // allocate memory for the image
QImage image(imgSize, imgSize, QImage::Format_Mono); 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); painter.fillRect(image.rect(),Qt::white);
for(int x=0;x<datawidth;x++) { for(int x=0;x<datawidth;x++) {
for(int y=0;y<datawidth;y++) { 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);
} }
} }