1717#include < QProcess>
1818#include < QTimer>
1919
20+ #include " encrypt/EncryptData.h"
21+
2022MainWindow::MainWindow (SingleApplication *parentApp, QWidget *parent) :
2123 QDialog(parent),
2224 ui(new Ui::MainWindow),
@@ -159,7 +161,7 @@ void MainWindow::RestartDrcom()
159161void MainWindow::QuitDrcom ()
160162{
161163 // 退出之前恢复重试计数
162- QSettings s (SETTINGS_FILE_NAME, QSettings::IniFormat );
164+ QSettings s (SETTINGS_FILE_NAME);
163165 s.setValue (ID_RESTART_TIMES, 0 );
164166 qDebug () << " reset restartTimes" ;
165167 qDebug () << " QuitDrcom" ;
@@ -201,14 +203,12 @@ void MainWindow::IconActivated(QSystemTrayIcon::ActivationReason reason)
201203void MainWindow::LoadSettings () {
202204 QSettings s (SETTINGS_FILE_NAME);
203205 account = s.value (ID_ACCOUNT, " " ).toString ();
204- password = s.value (ID_PASSWORD, " " ).toString ();
205206 mac_addr = s.value (ID_MAC, " " ).toString ();
206207 bRemember = s.value (ID_REMEMBER, false ).toBool ();
207208 bAutoLogin = s.value (ID_AUTO_LOGIN, false ).toBool ();
208209 bHideWindow = s.value (ID_HIDE_WINDOW, false ).toBool ();
209210 bNotShowWelcome = s.value (ID_NOT_SHOW_WELCOME, false ).toBool ();
210211 ui->lineEditAccount ->setText (account);
211- ui->lineEditPass ->setText (password);
212212 SetMAC (mac_addr);
213213 if (bRemember)
214214 ui->checkBoxRemember ->setCheckState (Qt::CheckState::Checked);
@@ -226,15 +226,23 @@ void MainWindow::LoadSettings() {
226226 ui->checkBoxNotShowWelcome ->setCheckState (Qt::CheckState::Checked);
227227 else
228228 ui->checkBoxNotShowWelcome ->setCheckState (Qt::CheckState::Unchecked);
229+
230+ // 密码加密处理
231+ QString encryptedPasswd = s.value (ID_PASSWORD, " " ).toString ();
232+ password = DecryptString (encryptedPasswd);
233+ ui->lineEditPass ->setText (password);
229234}
230235
231236void MainWindow::SaveSettings () {
232237 QSettings s (SETTINGS_FILE_NAME);
233238 s.setValue (ID_ACCOUNT, account);
234- s.setValue (ID_PASSWORD, password);
235239 s.setValue (ID_MAC, mac_addr);
236240 s.setValue (ID_REMEMBER, bRemember);
237241 s.setValue (ID_AUTO_LOGIN, bAutoLogin);
242+
243+ // 密码加密处理
244+ QString enctyptedPasswd = EncryptString (password);
245+ s.setValue (ID_PASSWORD, enctyptedPasswd);
238246}
239247
240248void MainWindow::SetMAC (const QString &m)
0 commit comments