Browse Source

add translation for paperwallet

pull/29/head
R4SAS 7 years ago
parent
commit
791eabd806
  1. 18
      src/qt/locale/gostcoin_ru.ts
  2. 144
      src/qt/paperwallet.cpp
  3. 17
      src/qt/paperwallet.qrc
  4. 10
      src/qt/res/html/paperwallet_en.html
  5. 77
      src/qt/res/html/paperwallet_ru.html

18
src/qt/locale/gostcoin_ru.ts

@ -346,12 +346,12 @@ @@ -346,12 +346,12 @@
<name>BitcoinGUI</name>
<message>
<location filename="../bitcoingui.cpp" line="+77"/>
<location line="+592"/>
<location line="+602"/>
<source>Gostcoin</source>
<translation>ГОСТкойн</translation>
</message>
<message>
<location line="-592"/>
<location line="-602"/>
<source>Wallet</source>
<translation>Бумажник</translation>
</message>
@ -516,12 +516,22 @@ @@ -516,12 +516,22 @@
<translation>Открыть консоль отладки и диагностики</translation>
</message>
<message>
<location line="+25"/>
<location line="+14"/>
<source>&amp;Print paper wallet...</source>
<translation>&amp;Распечатать бумажный кошелек</translation>
</message>
<message>
<location line="+2"/>
<source>Generate new address and print</source>
<translation>Сгенерировать новый адрес и распечатать его</translation>
</message>
<message>
<location line="+16"/>
<source>&amp;File</source>
<translation>&amp;Файл</translation>
</message>
<message>
<location line="+7"/>
<location line="+11"/>
<source>&amp;Settings</source>
<translation>&amp;Настройки</translation>
</message>

144
src/qt/paperwallet.cpp

@ -15,104 +15,104 @@ @@ -15,104 +15,104 @@
static void printAsQR(QPainter &painter, QString &vchKey, int shift)
{
QRcode *qr = QRcode_encodeString(vchKey.toStdString().c_str(), 1, QR_ECLEVEL_L, QR_MODE_8, 1);
if (qr)
QRcode *qr = QRcode_encodeString(vchKey.toStdString().c_str(), 1, QR_ECLEVEL_L, QR_MODE_8, 1);
if (qr)
{
QPaintDevice *pd = painter.device();
const double w = pd->width();
const double h = pd->height();
QColor bg("white");
QColor fg("black");
painter.setBrush(bg);
painter.fillRect(0, 0, w, h, bg);
painter.setPen(Qt::SolidLine);
painter.setPen(fg);
painter.setBrush(fg);
const int s=qr->width > 0 ? qr->width : 1;
const double aspect = w / h;
const double scale = ((aspect > 1.0) ? h : w) / s;// * 0.3;
for(int y = 0; y < s; y++)
QPaintDevice *pd = painter.device();
const double w = pd->width();
const double h = pd->height();
QColor bg("white");
QColor fg("black");
painter.setBrush(bg);
painter.fillRect(0, 0, w, h, bg);
painter.setPen(Qt::SolidLine);
painter.setPen(fg);
painter.setBrush(fg);
const int s=qr->width > 0 ? qr->width : 1;
const double aspect = w / h;
const double scale = ((aspect > 1.0) ? h : w) / s;// * 0.3;
for(int y = 0; y < s; y++)
{
const int yy = y*s;
for(int x = 0; x < s; x++)
const int yy = y*s;
for(int x = 0; x < s; x++)
{
const int xx = yy + x;
const unsigned char b = qr->data[xx];
if(b & 0x01)
const int xx = yy + x;
const unsigned char b = qr->data[xx];
if(b & 0x01)
{
const double rx1 = x*scale, ry1 = y*scale;
QRectF r(rx1 + shift, ry1, scale, scale);
painter.drawRects(&r, 1);
}
}
}
QRcode_free(qr);
}
const double rx1 = x*scale, ry1 = y*scale;
QRectF r(rx1 + shift, ry1, scale, scale);
painter.drawRects(&r, 1);
}
}
}
QRcode_free(qr);
}
}
static bool readHtmlTemplate(const QString &res_name, QString &htmlContent)
{
QFile htmlFile(res_name);
if (!htmlFile.open(QIODevice::ReadOnly | QIODevice::Text))
QFile htmlFile(res_name);
if (!htmlFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
printf("Cant open %s\n", res_name.toStdString().c_str ());
return false;
}
printf("Cant open %s\n", res_name.toStdString().c_str ());
return false;
}
QTextStream in(&htmlFile);
in.setCodec("UTF-8");
htmlContent = in.readAll();
return true;
QTextStream in(&htmlFile);
in.setCodec("UTF-8");
htmlContent = in.readAll();
return true;
}
void PrintPaperWallet (QWidget * parent)
{
RandAddSeedPerfmon();
CKey secret;
secret.MakeNewKey(true);
secret.MakeNewKey(true);
CPrivKey privkey = secret.GetPrivKey();
CPubKey pubkey = secret.GetPubKey();
CKeyID keyid = pubkey.GetID();
CPubKey pubkey = secret.GetPubKey();
CKeyID keyid = pubkey.GetID();
std::string secret_str = CBitcoinSecret(secret).ToString();
std::string address = CBitcoinAddress(keyid).ToString();
QString qsecret = QString::fromStdString(secret_str);
QString qaddress = QString::fromStdString(address);
std::string address = CBitcoinAddress(keyid).ToString();
QString qsecret = QString::fromStdString(secret_str);
QString qaddress = QString::fromStdString(address);
QPrinter printer(QPrinter::HighResolution);
printer.setPageMargins(0, 10, 0, 0, QPrinter::Millimeter);
QPrintDialog dlg(&printer, parent);
if(dlg.exec() == QDialog::Accepted)
printer.setPageMargins(0, 10, 0, 0, QPrinter::Millimeter);
QPrintDialog dlg(&printer, parent);
if(dlg.exec() == QDialog::Accepted)
{
QImage img1(200, 200, QImage::Format_ARGB32);
QImage img2(200, 200, QImage::Format_ARGB32);
QPainter painter(&img1);
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setRenderHint(QPainter::TextAntialiasing, false);
painter.setRenderHint(QPainter::SmoothPixmapTransform, false);
painter.setRenderHint(QPainter::HighQualityAntialiasing, false);
painter.setRenderHint(QPainter::NonCosmeticDefaultPen, false);
printAsQR(painter, qaddress, 0);
QImage img2(200, 200, QImage::Format_ARGB32);
QPainter painter(&img1);
painter.setRenderHint(QPainter::Antialiasing, false);
painter.setRenderHint(QPainter::TextAntialiasing, false);
painter.setRenderHint(QPainter::SmoothPixmapTransform, false);
painter.setRenderHint(QPainter::HighQualityAntialiasing, false);
painter.setRenderHint(QPainter::NonCosmeticDefaultPen, false);
printAsQR(painter, qaddress, 0);
painter.end();
painter.begin(&img2);
printAsQR(painter, qsecret, 0);
painter.end();
painter.begin(&img2);
printAsQR(painter, qsecret, 0);
painter.end();
QString html;
readHtmlTemplate(":/html/paperwallet", html);
html.replace("__ADDRESS__", qaddress);
html.replace("__PRIVATE__", qsecret);
QTextDocument document;
document.addResource(QTextDocument::ImageResource, QUrl(":qr1.png" ), img1);
document.addResource(QTextDocument::ImageResource, QUrl(":qr2.png" ), img2);
document.setHtml(html);
document.setPageSize(QSizeF(printer.pageRect(QPrinter::Point).size()));
document.print(&printer);
}
readHtmlTemplate(":/html/paperwallet", html);
html.replace("__ADDRESS__", qaddress);
html.replace("__PRIVATE__", qsecret);
QTextDocument document;
document.addResource(QTextDocument::ImageResource, QUrl(":qr1.png" ), img1);
document.addResource(QTextDocument::ImageResource, QUrl(":qr2.png" ), img2);
document.setHtml(html);
document.setPageSize(QSizeF(printer.pageRect(QPrinter::Point).size()));
document.print(&printer);
}
}

17
src/qt/paperwallet.qrc

@ -1,9 +1,12 @@ @@ -1,9 +1,12 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/html">
<file alias="paperwallet">res/html/paperwallet.html</file>
</qresource>
<qresource prefix="/icons">
<file alias="cash">res/icons/cash.png</file>
<file alias="cash_print">res/icons/cash_print.png</file>
</qresource>
<qresource prefix="/html" lang="en">
<file alias="paperwallet">res/html/paperwallet_en.html</file>
</qresource>
<qresource prefix="/html" lang="ru">
<file alias="paperwallet">res/html/paperwallet_ru.html</file>
</qresource>
<qresource prefix="/icons">
<file alias="cash">res/icons/cash.png</file>
<file alias="cash_print">res/icons/cash_print.png</file>
</qresource>
</RCC>

10
src/qt/res/html/paperwallet.html → src/qt/res/html/paperwallet_en.html

@ -16,8 +16,8 @@ @@ -16,8 +16,8 @@
__ADDRESS__
</div>
<div>
<p>Use this address to deposit your Gostcoins. </p>
<p>The balance and transactoin history you can find in public blockchain: <a href=«http://explorer.gostco.in»>http://explorer.gostco.in</a></p> <br /><br /><br /><br />
<p>Use this address to deposit your Gostcoins. </p>
<p>The balance and transactoin history you can find in public blockchain: <a href=«http://explorer.gostco.in»>http://explorer.gostco.in</a></p> <br /><br /><br /><br />
</div>
</td>
@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
__PRIVATE__
</div>
<div>
<p>To send your Gostcoins you need to import this key into you wallet, using importprivkey command.</p>
<p>To send your Gostcoins you need to import this key into you wallet, using importprivkey command.</p>
</div>
</td>
</tr>
@ -41,11 +41,11 @@ @@ -41,11 +41,11 @@
Attention!
</h3>
<div>
<ul>
<ul>
<li> You should use a paper wallet only once. When you import your key it stays forever</li>
<li>If you lose your key, you will lose your Gostcoins</li>
<li>All transactions on the Gostcoin network irrevocable, they can not be canceled. Be careful when entering addresses to avoid typos. If possible, use the QR-code reading function.</li>
</ul>
</ul>
</div>
</td>
</tr>

77
src/qt/res/html/paperwallet_ru.html

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
<!DOCTYPE html>
<html>
<head lang="ru">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body style="font-family: sans-serif; font-size: 9px; height: 842px; width: 595px; margin-left: auto; margin-right: auto;">
<table style="width: 100%; margin-bottom: 10px" border="1px" cellpadding="10px">
<tr style="vertical-align: top">
<td align="left" width="50%">
<img src=":qr1.png"/>
<h4>
Ваш адрес пополнения:
</h4>
<div style="margin-bottom: 10px">
__ADDRESS__
</div>
<div>
<p>Используйте данный адрес для зачисления ГОСТКоинов. </p>
<p>Баланс и историю по данному адресу вы можете посмотреть в реестре сети: <a href=«http://explorer.gostco.in»>http://explorer.gostco.in</a></p> <br /><br /><br /><br />
</div>
</td>
<td align="left" width="50%">
<img src=":qr2.png"/>
<!--width="150" height="150"/>-->
<h4>
Ваш ключ для отправки ГОСТКоинов:
</h4>
<div style="margin-bottom: 10px">
__PRIVATE__
</div>
<div>
<p>Чтобы отправить монеты вам необходимо импортировать данный ключ в кошелек, используя команду importprivkey.</p>
</div>
</td>
</tr>
<tr style="margin-bottom: 20px">
<td colspan="2" >
<h3>
Внимание!
</h3>
<div>
<ul>
<li>Старайтесь использовать бумажный кошелек однократно. В момент импортирования ключ сохраняется в кошельке навсегда</li>
<li>Если вы потеряете ключ, то не сможете воспользоваться монетами, зачисленными на адрес бумажного кошелька</li>
<li>Все транзакции в сети безотзывные, отменить их невозможно. Будьте внимательны при вводе адресов для пополнения и отправки монет. По возможности пользуйтесь функцией сканирования QR-кода при вводе ключа или адреса, чтобы избежать опечаток.</li>
</ul>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<table style="margin-bottom: 10px; margin-top: 10px">
<tr>
<td width="200">
<div style="display: inline-block;">
<img src=":/icons/cash_print" width="160" height="107">
</div>
</td>
<td>
<div style="display: inline-block; vertical-align: top; margin-left: 20px">
<h2>ГОСТКоин (GST)</h2>
<div>
<h3>
Бумажный кошелек
</h3>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Loading…
Cancel
Save