HGGitLab

Commit 4b607674 authored by luoliangyi's avatar luoliangyi

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

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