HGGitLab

Commit 4b607674 authored by luoliangyi's avatar luoliangyi

1.解决sane设置对话框中英文的问题

2.密码保存到配置文件时进行加密
parent aaf5aea2
......@@ -1390,7 +1390,7 @@ Do you want to clear?</source>
<message>
<location filename="mainwindow.cpp" line="1201"/>
<source>Insufficient disk space</source>
<translation type="unfinished">磁盘空间不足,请删除不需要的文件,以保证有足够的空间</translation>
<translation type="unfinished">磁盘空间不足,请删除不需要的文件,以保证有足够的空间</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1368"/>
......@@ -1773,8 +1773,8 @@ Continue to close?</source>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="189"/>
<location filename="hg_settingdialog.cpp" line="1709"/>
<location filename="hg_settingdialog.cpp" line="1724"/>
<location filename="hg_settingdialog.cpp" line="1719"/>
<location filename="hg_settingdialog.cpp" line="1739"/>
<source>No custom configuration was found</source>
<translation>无配置方案</translation>
</message>
......@@ -1821,61 +1821,88 @@ Continue to close?</source>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1448"/>
<source>The Settings you just set are in the original configuration </source>
<translation>您刚才的设置是在原有配置 </translation>
<source>The Settings you just set are in the original configuration &quot;</source>
<oldsource>The Settings you just set are in the original configuration </oldsource>
<translation type="unfinished">您刚才的设置是在原有配置 </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1451"/>
<source> changed on the basis,Please select overwrite this configuration or add a new one?
Yes: cover </source>
<translation> 基础上更改的,请选择是覆盖这个配置,还是增加新的配置?
Yes: 覆盖 </translation>
<source>&quot; changed on the basis,Please select overwrite this configuration or add a new one?
Yes: cover &quot;</source>
<oldsource> changed on the basis,Please select overwrite this configuration or add a new one?
Yes: cover </oldsource>
<translation type="unfinished"> 基础上更改的,请选择是覆盖这个配置,还是增加新的配置?
: 覆盖 </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1452"/>
<source>
<source>&quot;
No: add new configuration</source>
<translation>
No: 增加新的配置:</translation>
<oldsource>
No: add new configuration</oldsource>
<translation type="unfinished">
: 增加新的配置:</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1656"/>
<location filename="hg_settingdialog.cpp" line="1455"/>
<location filename="hg_settingdialog.cpp" line="1699"/>
<location filename="hg_settingdialog.cpp" line="1732"/>
<source>yes</source>
<translation type="unfinished">确定</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1456"/>
<location filename="hg_settingdialog.cpp" line="1700"/>
<location filename="hg_settingdialog.cpp" line="1733"/>
<source>no</source>
<translation type="unfinished">取消</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1661"/>
<source>&lt;h6&gt;&lt;b&gt;</source>
<translation>&lt;h6&gt;&lt;b&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1656"/>
<location filename="hg_settingdialog.cpp" line="1661"/>
<source>:&lt;/b&gt;&lt;/h6&gt;</source>
<translation>:&lt;/b&gt;&lt;/h6&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1657"/>
<location filename="hg_settingdialog.cpp" line="1662"/>
<source>&lt;p&gt; </source>
<translation>&lt;p&gt; </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1657"/>
<location filename="hg_settingdialog.cpp" line="1662"/>
<source>&lt;/p&gt;</source>
<translation>&lt;/p&gt;</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1692"/>
<location filename="hg_settingdialog.cpp" line="1720"/>
<location filename="hg_settingdialog.cpp" line="1697"/>
<location filename="hg_settingdialog.cpp" line="1730"/>
<source>be sure to delete the configuration</source>
<translation>确认删除配置</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1692"/>
<location filename="hg_settingdialog.cpp" line="1698"/>
<source>Are you sure you want to delete the configuration &quot;</source>
<translation type="unfinished">您确认要删除配置</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1698"/>
<source>&quot; ?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Are you sure you want to delete the configuration </source>
<translation>您确认要删除配置 </translation>
<translation type="vanished">您确认要删除配置 </translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1692"/>
<source> ?</source>
<translation> 吗?</translation>
<translation type="vanished"> 吗?</translation>
</message>
<message>
<location filename="hg_settingdialog.cpp" line="1720"/>
<location filename="hg_settingdialog.cpp" line="1731"/>
<source>Are you sure you want to delete the configuration?</source>
<translation>您确认要删除所有配置吗?</translation>
</message>
......
......@@ -20,8 +20,8 @@
THE SOFTWARE.
*/
#ifndef cJSON__h
#define cJSON__h
#ifndef CJSON_H
#define CJSON_H
#include <stdlib.h>
#ifdef __cplusplus
......
......@@ -33,6 +33,7 @@ typedef struct _opt_val
return name == n;
}
}OPTVAL;
typedef struct _opt_scheme
{
std::string name; // scheme name
......@@ -61,6 +62,7 @@ typedef struct _opt_scheme
return equal;
}
}OPTSCHEME;
typedef struct _dev_configs
{
std::string name; // device name
......@@ -101,30 +103,6 @@ typedef struct _dev_configs
}
}DEVCFG;
//
// {
// "G100" : [
// {
// "scheme": "color-A4R",
// "opts": [
// {
// "name": "color-mode",
// "type": "string",
// "value": "24-bits",
// "init": "24-bits"
// },
// {
// "name": "paper",
// "type": "string",
// "value": "A4R"
// "init": "A4"
// }],
// }],
//
// "G200" : [ ... ]
//
// }
//
class config
{
QSettings *ini_;
......
......@@ -1445,12 +1445,17 @@ void hg_settingdialog::save_scheme(void)
if (cur_ind_ >= 0 && cur_ind_ + 1 < (int)schemes_->schemes.size())
{
QString title(tr("save the configuration"));
QString text(tr("The Settings you just set are in the original configuration "));
QString text(tr("The Settings you just set are in the original configuration \""));
text += QString::fromStdString(schemes_->schemes[cur_ind_ + 1].name);
text += tr("” changed on the basis,Please select overwrite this configuration or add a new one?\nYes: cover “") + QString::fromStdString(schemes_->schemes[cur_ind_ + 1].name);
text += tr("”\nNo: add new configuration") + QString::fromStdString(os.name);
if(QMessageBox::question(this, title, text) == QMessageBox::Yes)
text += tr("\" changed on the basis,Please select overwrite this configuration or add a new one?\nYes: cover \"") + QString::fromStdString(schemes_->schemes[cur_ind_ + 1].name);
text += tr("\"\nNo: add new configuration") + QString::fromStdString(os.name);
QMessageBox msg(QMessageBox::Question, title, text, QMessageBox::Yes | QMessageBox::No, this);
msg.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() == msg.button(QMessageBox::Yes))
{
os.name = schemes_->schemes[cur_ind_ + 1].name;
schemes_->schemes.erase(schemes_->schemes.begin() + cur_ind_ + 1);
......@@ -1689,7 +1694,12 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
if(!act)
return;
if(QMessageBox::question(this, tr("be sure to delete the configuration"), tr("Are you sure you want to delete the configuration ‘") + act->text() + tr("’ ?")) != QMessageBox::Yes)
QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"),
tr("Are you sure you want to delete the configuration \"") + act->text() + tr("\" ?"), QMessageBox::Yes | QMessageBox::No, this);
msg.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
return;
if(id >= 0)
......@@ -1717,7 +1727,12 @@ void hg_settingdialog::slot_pushButton_scheme_management(void)
}
else if(btn == del_all_)
{
if(QMessageBox::question(this, tr("be sure to delete the configuration"), tr("Are you sure you want to delete the configuration?")) != QMessageBox::Yes)
QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"),
tr("Are you sure you want to delete the configuration?"), QMessageBox::Yes | QMessageBox::No, this);
msg.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
return;
schemes_->schemes.erase(schemes_->schemes.begin() + 1, schemes_->schemes.end());
......
......@@ -36,6 +36,8 @@
#include "HGUIGlobal.h"
#include "app_cfg.h"
#define PASSWORD_KEY 4
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
......@@ -222,7 +224,12 @@ MainWindow::MainWindow(QWidget *parent)
m_saneDeviceAction = nullptr;
m_saneDeviceHandle = nullptr;
m_password = getCfgValue("login", "password", "123456");
QString password = getCfgValue("login", "password", QString(""));
if (password.isEmpty())
m_password = "123456";
else
m_password = passwordDecrypt(password);
m_config.load();
SANE_Int v = 0;
......@@ -1207,6 +1214,33 @@ bool MainWindow::startSpaceCheck(QWidget* parent)
return true;
}
QString MainWindow::passwordEncrypt(const QString& password)
{
QString p = password;
int num = PASSWORD_KEY - p.length() % PASSWORD_KEY;
for (int i = 0; i < num; i++)
p.append("+");
int rows = p.length() / 4;
QString transcode;
for (int i = 0; i < PASSWORD_KEY; i++)
for (int j = 0; j < rows; j++)
transcode.append(p[i + j * PASSWORD_KEY]);
return transcode;
}
QString MainWindow::passwordDecrypt(const QString& transcode)
{
QString t = transcode;
int cols = t.length() / 4;
QString password;
for (int i = 0; i < cols; i++)
for (int j = 0; j < PASSWORD_KEY; j++)
password.append(t[i + j * cols]);
password.remove("+");
return password;
}
void MainWindow::on_act_openPageNum_triggered()
{
int count = 0;
......@@ -1949,7 +1983,7 @@ void MainWindow::on_act_passwordChange_triggered()
if (dlg.exec())
{
m_password = dlg.getNewPassword();
saveCfgValue("login", "password", m_password);
saveCfgValue("login", "password", passwordEncrypt(m_password));
}
}
......
......@@ -200,6 +200,8 @@ private:
void updateActionStatus();
askIfClear startScanMessageBox(QWidget* parent);
bool startSpaceCheck(QWidget* parent);
QString passwordEncrypt(const QString& password);
QString passwordDecrypt(const QString& transcode);
private:
Ui::MainWindow *ui;
......
......@@ -10,6 +10,8 @@ CONFIG += c++11
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += _CRT_SECURE_NO_WARNINGS
RC_ICONS = ../../../app/scanner/image_rsc/logo/logo.ico
# You can also make your code fail to compile if it uses deprecated APIs.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment