@@ -100,7 +100,7 @@ MainWindow::MainWindow(QWidget *parent) :
100100 int restartTimes = s.value (ID_RESTART_TIMES, 0 ).toInt ();
101101 qDebug () << " MainWindow constructor: restartTimes=" << restartTimes;
102102 if (restartTimes == 0 ) {
103- if (auto_login ) {
103+ if (bAutoLogin ) {
104104 emit ui->pushButtonLogin ->click ();
105105 }
106106 }
@@ -196,28 +196,38 @@ void MainWindow::LoadSettings() {
196196 account = s.value (ID_ACCOUNT, " " ).toString ();
197197 password = s.value (ID_PASSWORD, " " ).toString ();
198198 mac_addr = s.value (ID_MAC, " " ).toString ();
199- remember = s.value (ID_REMEMBER, false ).toBool ();
200- auto_login = s.value (ID_AUTO_LOGIN, false ).toBool ();
199+ bRemember = s.value (ID_REMEMBER, false ).toBool ();
200+ bAutoLogin = s.value (ID_AUTO_LOGIN, false ).toBool ();
201+ bHideWindow = s.value (ID_HIDE_WINDOW, false ).toBool ();
202+ bNotShowWelcome = s.value (ID_NOT_SHOW_WELCOME, false ).toBool ();
201203 ui->lineEditAccount ->setText (account);
202204 ui->lineEditPass ->setText (password);
203205 SetMAC (mac_addr);
204- if (remember )
206+ if (bRemember )
205207 ui->checkBoxRemember ->setCheckState (Qt::CheckState::Checked);
206208 else
207209 ui->checkBoxRemember ->setCheckState (Qt::CheckState::Unchecked);
208- if (auto_login )
210+ if (bAutoLogin )
209211 ui->checkBoxAutoLogin ->setCheckState (Qt::CheckState::Checked);
210212 else
211213 ui->checkBoxAutoLogin ->setCheckState (Qt::CheckState::Unchecked);
214+ if (bHideWindow)
215+ ui->checkBoxHideLoginWindow ->setCheckState (Qt::CheckState::Checked);
216+ else
217+ ui->checkBoxHideLoginWindow ->setCheckState (Qt::CheckState::Unchecked);
218+ if (bNotShowWelcome)
219+ ui->checkBoxNotShowWelcome ->setCheckState (Qt::CheckState::Checked);
220+ else
221+ ui->checkBoxNotShowWelcome ->setCheckState (Qt::CheckState::Unchecked);
212222}
213223
214224void MainWindow::SaveSettings () {
215225 QSettings s (SETTINGS_FILE_NAME);
216226 s.setValue (ID_ACCOUNT, account);
217227 s.setValue (ID_PASSWORD, password);
218228 s.setValue (ID_MAC, mac_addr);
219- s.setValue (ID_REMEMBER, remember );
220- s.setValue (ID_AUTO_LOGIN, auto_login );
229+ s.setValue (ID_REMEMBER, bRemember );
230+ s.setValue (ID_AUTO_LOGIN, bAutoLogin );
221231}
222232
223233void MainWindow::SetMAC (const QString &m)
@@ -342,8 +352,8 @@ void MainWindow::GetInputs() {
342352 mac_addr = ui->comboBoxMAC ->currentText ();
343353 }
344354 mac_addr = mac_addr.remove (17 , mac_addr.length ()).toUpper ();
345- remember = ui->checkBoxRemember ->checkState ();
346- auto_login = ui->checkBoxAutoLogin ->checkState ();
355+ bRemember = ui->checkBoxRemember ->checkState ();
356+ bAutoLogin = ui->checkBoxAutoLogin ->checkState ();
347357}
348358
349359void MainWindow::HandleOffline (int reason)
@@ -432,7 +442,7 @@ void MainWindow::HandleOffline(int reason)
432442 case OFF_TIMEOUT: {
433443 // 先尝试自己重启若干次,自个重启还不行的话再提示用户
434444 // 自己重启的话需要用户提前勾选记住密码
435- if (remember ) {
445+ if (bRemember ) {
436446 QSettings s (SETTINGS_FILE_NAME);
437447 int restartTimes = s.value (ID_RESTART_TIMES, 0 ).toInt ();
438448 qDebug () << " case OFF_TIMEOUT: restartTimes=" << restartTimes;
@@ -471,8 +481,8 @@ void MainWindow::HandleOffline(int reason)
471481 // 清除已保存的密码
472482 account = " " ;
473483 password = " " ;
474- remember = false ;
475- auto_login = false ;
484+ bRemember = false ;
485+ bAutoLogin = false ;
476486 SaveSettings ();
477487 }
478488 // 重新启用输入
@@ -492,14 +502,16 @@ void MainWindow::HandleLoggedIn()
492502
493503 CURR_STATE = STATE_ONLINE;
494504 // 显示欢迎页
495- if (restartTimes == 0 ) {
505+ bool bNotShowWelcome = s.value (ID_NOT_SHOW_WELCOME, false ).toBool ();
506+ if (restartTimes == 0 && !bNotShowWelcome) {
507+ qDebug ()<<" open welcome page" ;
496508 QDesktopServices::openUrl (QUrl (" http://login.jlu.edu.cn/notice.php" ));
497509 }
498510 else {
499511 // 自行尝试重启的,不显示欢迎页
500512 }
501513 // 登录成功,保存密码
502- if (remember ) {
514+ if (bRemember ) {
503515 SaveSettings ();
504516 }
505517 else {
@@ -538,3 +550,15 @@ void MainWindow::DisableLogOutButton(bool yes) {
538550 logOutAction->setEnabled (true );
539551 }
540552}
553+
554+ void MainWindow::on_checkBoxNotShowWelcome_toggled (bool checked)
555+ {
556+ QSettings s (SETTINGS_FILE_NAME);
557+ s.setValue (ID_NOT_SHOW_WELCOME, checked);
558+ }
559+
560+ void MainWindow::on_checkBoxHideLoginWindow_toggled (bool checked)
561+ {
562+ QSettings s (SETTINGS_FILE_NAME);
563+ s.setValue (ID_HIDE_WINDOW, checked);
564+ }
0 commit comments