From 1b4543aa11b2da509c6d90730e4bfd08905b8aa4 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Thu, 1 Apr 2021 07:46:53 +0200 Subject: [PATCH] Fix 4294 (#4302) * save forgot password settings when opening dialog * add restore password menu item --- cockatrice/src/dlg_connect.cpp | 5 +++++ cockatrice/src/window_main.cpp | 8 ++++++++ cockatrice/src/window_main.h | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/dlg_connect.cpp b/cockatrice/src/dlg_connect.cpp index df290d64..f057b204 100644 --- a/cockatrice/src/dlg_connect.cpp +++ b/cockatrice/src/dlg_connect.cpp @@ -347,6 +347,11 @@ bool DeleteHighlightedItemWhenShiftDelPressedEventFilter::eventFilter(QObject *o void DlgConnect::actForgotPassword() { + ServersSettings &servers = SettingsCache::instance().servers(); + servers.setFPHostName(hostEdit->text()); + servers.setFPPort(portEdit->text()); + servers.setFPPlayerName(playernameEdit->text().trimmed()); + emit sigStartForgotPasswordRequest(); reject(); } diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index f9feb7e2..fe9db724 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -146,12 +146,14 @@ void MainWindow::statusChanged(ClientStatus _status) aConnect->setEnabled(true); aRegister->setEnabled(true); aDisconnect->setEnabled(false); + aForgotPassword->setEnabled(true); break; case StatusLoggingIn: aSinglePlayer->setEnabled(false); aConnect->setEnabled(false); aRegister->setEnabled(false); aDisconnect->setEnabled(true); + aForgotPassword->setEnabled(false); break; case StatusConnecting: case StatusRegistering: @@ -219,6 +221,7 @@ void MainWindow::actSinglePlayer() aConnect->setEnabled(false); aRegister->setEnabled(false); + aForgotPassword->setEnabled(false); aSinglePlayer->setEnabled(false); localServer = new LocalServer(this); @@ -269,6 +272,7 @@ void MainWindow::localGameEnded() aConnect->setEnabled(true); aRegister->setEnabled(true); + aForgotPassword->setEnabled(true); aSinglePlayer->setEnabled(true); } @@ -628,6 +632,7 @@ void MainWindow::retranslateUi() aDeckEditor->setText(tr("&Deck editor")); aFullScreen->setText(tr("&Full screen")); aRegister->setText(tr("&Register to server...")); + aForgotPassword->setText(tr("&Restore password...")); aSettings->setText(tr("&Settings...")); aSettings->setIcon(QPixmap("theme:icons/settings")); aExit->setText(tr("&Exit")); @@ -672,6 +677,8 @@ void MainWindow::createActions() connect(aFullScreen, SIGNAL(toggled(bool)), this, SLOT(actFullScreen(bool))); aRegister = new QAction(this); connect(aRegister, SIGNAL(triggered()), this, SLOT(actRegister())); + aForgotPassword = new QAction(this); + connect(aForgotPassword, SIGNAL(triggered()), this, SLOT(actForgotPasswordRequest())); aSettings = new QAction(this); connect(aSettings, SIGNAL(triggered()), this, SLOT(actSettings())); aExit = new QAction(this); @@ -739,6 +746,7 @@ void MainWindow::createMenus() cockatriceMenu->addAction(aConnect); cockatriceMenu->addAction(aDisconnect); cockatriceMenu->addAction(aRegister); + cockatriceMenu->addAction(aForgotPassword); cockatriceMenu->addSeparator(); cockatriceMenu->addAction(aSinglePlayer); cockatriceMenu->addAction(aWatchReplay); diff --git a/cockatrice/src/window_main.h b/cockatrice/src/window_main.h index e9f3c733..c17ef498 100644 --- a/cockatrice/src/window_main.h +++ b/cockatrice/src/window_main.h @@ -125,7 +125,7 @@ private: QList tabMenus; QMenu *cockatriceMenu, *dbMenu, *helpMenu, *trayIconMenu; QAction *aConnect, *aDisconnect, *aSinglePlayer, *aWatchReplay, *aDeckEditor, *aFullScreen, *aSettings, *aExit, - *aAbout, *aTips, *aCheckCardUpdates, *aRegister, *aUpdate, *aViewLog, *closeAction; + *aAbout, *aTips, *aCheckCardUpdates, *aRegister, *aForgotPassword, *aUpdate, *aViewLog, *closeAction; QAction *aManageSets, *aEditTokens, *aOpenCustomFolder, *aOpenCustomsetsFolder, *aAddCustomSet; TabSupervisor *tabSupervisor; WndSets *wndSets;