From 8fc72226fb7f6d7db2d773d01b226c8d7abc1f54 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Sat, 24 Aug 2024 00:06:12 +0200 Subject: [PATCH] refactor: Remove advanced login dialog All functionalities from the advanced dialog are also available somewhere else. --- src/blackgui/CMakeLists.txt | 6 - src/blackgui/components/loginadvcomponent.cpp | 349 ------------------ src/blackgui/components/loginadvcomponent.h | 145 -------- src/blackgui/components/loginadvcomponent.ui | 264 ------------- src/blackgui/components/logindialog.cpp | 84 ----- src/blackgui/components/logindialog.h | 51 --- src/blackgui/components/logindialog.ui | 61 --- src/swiftguistandard/swiftguistd.cpp | 21 +- src/swiftguistandard/swiftguistd.h | 2 - 9 files changed, 5 insertions(+), 978 deletions(-) delete mode 100644 src/blackgui/components/loginadvcomponent.cpp delete mode 100644 src/blackgui/components/loginadvcomponent.h delete mode 100644 src/blackgui/components/loginadvcomponent.ui delete mode 100644 src/blackgui/components/logindialog.cpp delete mode 100644 src/blackgui/components/logindialog.h delete mode 100644 src/blackgui/components/logindialog.ui diff --git a/src/blackgui/CMakeLists.txt b/src/blackgui/CMakeLists.txt index 62bcc4987..14a075dde 100644 --- a/src/blackgui/CMakeLists.txt +++ b/src/blackgui/CMakeLists.txt @@ -399,7 +399,6 @@ add_library(gui SHARED components/aircraftmodelvalidationcomponent.h components/autopublishdialog.h components/maininfoareacomponent.h - components/logindialog.h components/commandinput.h components/configsimulatorcomponent.ui components/datamaininfoareacomponent.cpp @@ -465,7 +464,6 @@ add_library(gui SHARED components/logcomponent.ui components/settingsmatchingdialog.ui components/settingsfontdialog.ui - components/loginadvcomponent.h components/simulatorselector.ui components/aircraftcomponent.ui components/scalescreenfactor.ui @@ -672,7 +670,6 @@ add_library(gui SHARED components/dbliverycolorsearchdialog.h components/modelbrowserdialog.h components/aboutdialog.ui - components/logindialog.ui components/cockpitcomcomponent.cpp components/logcomponent.cpp components/configurationwizard.cpp @@ -688,7 +685,6 @@ add_library(gui SHARED components/transpondercodespinbox.cpp components/interpolationcomponent.h components/dbairlineicaoselectorcomponent.h - components/logindialog.cpp components/maininfoareacomponent.cpp components/mappingcomponent.h components/dbautostashingcomponent.ui @@ -734,7 +730,6 @@ add_library(gui SHARED components/logincomponent.ui components/stringlistdialog.ui components/dbcountrycomponent.ui - components/loginadvcomponent.cpp components/selcalcodeselector.h components/navigatordialog.cpp components/dblogincomponent.ui @@ -750,7 +745,6 @@ add_library(gui SHARED components/networkaircraftvaluescomponent.ui components/dbaircrafticaocomponent.h components/corestatuscomponent.ui - components/loginadvcomponent.ui components/datasettingscomponent.ui components/cockpitcomtransmissioncomponent.cpp components/firstmodelsetcomponent.ui diff --git a/src/blackgui/components/loginadvcomponent.cpp b/src/blackgui/components/loginadvcomponent.cpp deleted file mode 100644 index c95f2680e..000000000 --- a/src/blackgui/components/loginadvcomponent.cpp +++ /dev/null @@ -1,349 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "ui_loginadvcomponent.h" -#include "loginadvcomponent.h" -#include "blackgui/components/serverlistselector.h" -#include "blackgui/editors/serverform.h" -#include "blackgui/editors/pilotform.h" -#include "blackgui/guiapplication.h" -#include "blackgui/loginmodebuttons.h" -#include "blackgui/ticklabel.h" -#include "blackgui/uppercasevalidator.h" -#include "blackcore/context/contextaudio.h" -#include "blackcore/context/contextownaircraft.h" -#include "blackcore/context/contextsimulator.h" -#include "blackcore/context/contextnetwork.h" -#include "blackcore/data/globalsetup.h" -#include "blackcore/webdataservices.h" -#include "blackcore/simulator.h" -#include "blackmisc/simulation/simulatorinternals.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/aviation/aircrafticaocode.h" -#include "blackmisc/aviation/airlineicaocode.h" -#include "blackmisc/aviation/airporticaocode.h" -#include "blackmisc/network/entityflags.h" -#include "blackmisc/network/serverlist.h" -#include "blackmisc/icons.h" -#include "blackmisc/logmessage.h" -#include "blackmisc/statusmessage.h" -#include "blackmisc/crashhandler.h" -#include "blackconfig/buildconfig.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace BlackConfig; -using namespace BlackMisc; -using namespace BlackMisc::Aviation; -using namespace BlackMisc::Audio; -using namespace BlackMisc::Network; -using namespace BlackMisc::Simulation; -using namespace BlackCore; -using namespace BlackCore::Data; -using namespace BlackCore::Context; -using namespace BlackGui; - -namespace BlackGui::Components -{ - const QStringList &CLoginAdvComponent::getLogCategories() - { - static const QStringList cats { CLogCategories::guiComponent() }; - return cats; - } - - CLoginAdvComponent::CLoginAdvComponent(QWidget *parent) : COverlayMessagesFrame(parent), - ui(new Ui::CLoginAdvComponent) - { - ui->setupUi(this); - - connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginAdvComponent::loginCancelled, Qt::QueuedConnection); - connect(ui->pb_Connect, &QPushButton::clicked, this, &CLoginAdvComponent::toggleNetworkConnection, Qt::QueuedConnection); - connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::overridePilot, this, &CLoginAdvComponent::overrideCredentialsToPilot, Qt::QueuedConnection); - connect(ui->comp_NetworkDetails, &CNetworkDetailsComponent::requestNetworkSettings, this, &CLoginAdvComponent::requestNetworkSettings, Qt::QueuedConnection); - - // overlay - this->setOverlaySizeFactors(0.8, 0.5); - this->setReducedInfo(true); - this->setForceSmall(true); - this->showKillButton(false); - - // Stored data - this->loadRememberedUserData(); - - // signals - if (sGui && sGui->getIContextSimulator()) - { - connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginAdvComponent::autoLogoffDetection, Qt::QueuedConnection); - connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CLoginAdvComponent::onSimulatorStatusChanged, Qt::QueuedConnection); - connect(sGui->getIContextSimulator(), &IContextSimulator::insufficientFrameRateDetected, this, &CLoginAdvComponent::autoLogoffFrameRate, Qt::QueuedConnection); - } - - // inital setup, if data already available - ui->form_Pilot->validate(); - } - - CLoginAdvComponent::~CLoginAdvComponent() - {} - - void CLoginAdvComponent::loginCancelled() - { - this->closeOverlay(); - emit this->loginOrLogoffCancelled(); - } - - void CLoginAdvComponent::toggleNetworkConnection() - { - if (!sGui || sGui->isShuttingDown()) { return; } - if (!sGui->getIContextNetwork() || !sGui->getIContextAudio()) { return; } - - const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected(); - const bool vatsimLogin = ui->comp_NetworkDetails->isVatsimServerSelected(); - - ui->form_Pilot->setVatsimValidation(vatsimLogin); - - CServer currentServer; // used for login - CSimulatedAircraft ownAircraft; // used own aircraft - CStatusMessage msg; - if (!isConnected) - { - const CStatusMessageList aircraftMsgs = ui->comp_OwnAircraft->validate(); - if (aircraftMsgs.isFailure()) - { - this->showOverlayHTMLMessage(CStatusMessage(this).validationWarning(u"Invalid aircraft data, login not possible"), OverlayMessageMs); - return; - } - - const CStatusMessageList pilotMsgs = ui->form_Pilot->validate(); - if (pilotMsgs.isFailure()) - { - // this->showOverlayHTMLMessage(CStatusMessage(this).validationWarning(u"Invalid pilot data, login not possible"), OverlayMessageMs); - this->showOverlayMessagesOrHTMLMessage(pilotMsgs, false, OverlayMessageMs); - return; - } - - // sync values with GUI values - const COwnAircraftComponent::CGuiAircraftValues values = ui->comp_OwnAircraft->getAircraftValuesFromGui(); - this->updateOwnAircraftCallsignAndPilotFromGuiValues(); - ui->comp_OwnAircraft->updateOwnAircaftIcaoValuesFromGuiValues(); - - // Login mode - const CLoginMode mode = ui->comp_NetworkDetails->getLoginMode(); - switch (mode.getLoginMode()) - { - case CLoginMode::Observer: CLogMessage(this).info(u"Login in observer mode"); break; - default: break; // INetwork::LoginNormal - } - - // Server - currentServer = this->getCurrentServer(); - const CUser user = this->getUserFromPilotGuiValues(); - currentServer.setUser(user); - - // update for own aircraft context - sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(currentServer.getUser()); - - // set own aircraft from all values - ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); - - // check the copilot stuff - CCallsign partnerCs; - if (ui->comp_NetworkDetails->hasPartnerCallsign()) - { - partnerCs = ui->comp_NetworkDetails->getPartnerCallsign(); - if (partnerCs == ownAircraft.getCallsign()) - { - this->showOverlayHTMLMessage("Your callsign and the pilot/copilot callsign must be NOT the same", OverlayMessageMs); - return; - } - - const bool ok = (partnerCs.asString().startsWith(ownAircraft.getCallsignAsString(), Qt::CaseInsensitive) || ownAircraft.getCallsignAsString().startsWith(partnerCs.asString(), Qt::CaseInsensitive)); - if (!ok) - { - this->showOverlayHTMLMessage("Callsign and the pilot/copilot callsign appear not to be synchronized", OverlayMessageMs); - return; - } - } - - // Login - msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, partnerCs, mode); - if (msg.isSuccess()) - { - Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server"); - sGui->setExtraWindowTitle(QStringLiteral("[%1]").arg(ownAircraft.getCallsignAsString())); - CCrashHandler::instance()->crashAndLogInfoUserName(currentServer.getUser().getRealNameAndId()); - CCrashHandler::instance()->crashAndLogInfoFlightNetwork(currentServer.getEcosystem().toQString(true)); - CCrashHandler::instance()->crashAndLogAppendInfo(currentServer.getServerSessionId(false)); - m_networkSetup.setLastServer(currentServer); - if (vatsimLogin) { m_networkSetup.setLastVatsimServer(currentServer); } - } - else - { - sGui->setExtraWindowTitle(""); - } - } - else - { - // disconnect from network - sGui->setExtraWindowTitle(""); - msg = sGui->getIContextNetwork()->disconnectFromNetwork(); - } - - // log message and trigger events - msg.addCategories(this); - CLogMessage::preformatted(msg); - if (msg.isSuccess()) - { - this->setGuiLoginAsValues(ownAircraft); - emit this->loginOrLogoffSuccessful(); - } - else - { - emit this->loginOrLogoffCancelled(); - } - } - - void CLoginAdvComponent::loadRememberedUserData() - { - const CServer lastServer = m_networkSetup.getLastServer(); - const CUser lastUser = lastServer.getUser(); - ui->form_Pilot->setUser(lastUser); - ui->comp_OwnAircraft->setUser(lastUser); - } - - void CLoginAdvComponent::overrideCredentialsToPilot(const CUser &user) - { - ui->form_Pilot->setUser(user, true); - } - - void CLoginAdvComponent::onSimulatorStatusChanged(int status) - { - ISimulator::SimulatorStatus s = static_cast(status); - if (!this->hasValidContexts()) { return; } - if (sGui->getIContextNetwork()->isConnected()) - { - if (!s.testFlag(ISimulator::Connected)) - { - // sim NOT connected but network connected - this->autoLogoffDetection(); - } - } - } - - bool CLoginAdvComponent::hasValidContexts() const - { - if (!sGui || !sGui->supportsContexts()) { return false; } - if (sGui->isShuttingDown()) { return false; } - if (!sGui->getIContextSimulator()) { return false; } - if (!sGui->getIContextNetwork()) { return false; } - if (!sGui->getIContextOwnAircraft()) { return false; } - return true; - } - - CUser CLoginAdvComponent::getUserFromPilotGuiValues() const - { - CUser user = ui->form_Pilot->getUser(); - user.setCallsign(ui->comp_OwnAircraft->getCallsignFromGui()); - return user; - } - - void CLoginAdvComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft) - { - Q_UNUSED(ownAircraft) - } - - CServer CLoginAdvComponent::getCurrentVatsimServer() const - { - return ui->comp_NetworkDetails->getCurrentVatsimServer(); - } - - CServer CLoginAdvComponent::getCurrentOtherServer() const - { - return ui->comp_NetworkDetails->getCurrentOtherServer(); - } - - CServer CLoginAdvComponent::getCurrentServer() const - { - return ui->comp_NetworkDetails->getCurrentServer(); - } - - void CLoginAdvComponent::autoLogoffDetection() - { - if (!this->hasValidContexts()) { return; } - if (!sGui->getIContextNetwork()->isConnected()) { return; } // nothing to logoff - - const CStatusMessage m = CStatusMessage(this, CStatusMessage::SeverityInfo, u"Auto logoff in progress (could be simulator shutdown, crash, closing simulator)"); - const int delaySecs = 30; - this->showOverlayHTMLMessage(m, qRound(1000 * delaySecs * 0.8)); - - emit this->requestLoginPage(); - } - - void CLoginAdvComponent::autoLogoffFrameRate(bool fatal) - { - //! \fixme code duplication with function above - if (!this->hasValidContexts()) { return; } - if (!sGui->getIContextNetwork()->isConnected()) { return; } - - const auto msg = fatal ? CStatusMessage(this, CStatusMessage::SeverityError, u"Sim frame rate too low to maintain constant simulation rate. Disconnecting to avoid disrupting the network.") : CStatusMessage(this, CStatusMessage::SeverityWarning, u"Sim frame rate too low to maintain constant simulation rate. Reduce graphics quality to avoid disconnection."); - const int delaySecs = 30; - this->showOverlayHTMLMessage(msg, qRound(1000 * delaySecs * 0.8)); - - emit this->requestLoginPage(); - } - - bool CLoginAdvComponent::updateOwnAircraftCallsignAndPilotFromGuiValues() - { - if (!this->hasValidContexts()) { return false; } - CSimulatedAircraft ownAircraft(sGui->getIContextOwnAircraft()->getOwnAircraft()); - const CCallsign cs = ui->comp_OwnAircraft->getCallsignFromGui(); - bool changedCallsign = false; - if (!cs.isEmpty() && ownAircraft.getCallsign() != cs) - { - sGui->getIContextOwnAircraft()->updateOwnCallsign(cs); - ownAircraft.setCallsign(cs); // also update - changedCallsign = true; - } - CUser pilot = ownAircraft.getPilot(); - const CUser uiUser = ui->form_Pilot->getUser(); - pilot.setRealName(uiUser.getRealName()); - pilot.setHomeBase(uiUser.getHomeBase()); - pilot.setId(uiUser.getId()); - pilot.setCallsign(cs); - bool changedPilot = false; - if (ownAircraft.getPilot() != pilot) - { - // it can be that the callsign was changed and this results in unchanged here - changedPilot = sGui->getIContextOwnAircraft()->updateOwnAircraftPilot(pilot); - } - return changedCallsign || changedPilot; - } - - void CLoginAdvComponent::updateGui() - { - if (!this->hasValidContexts()) { return; } - if (!sGui->getIContextNetwork()) { return; } - const IContextNetwork *nwc = sGui->getIContextNetwork(); - const bool connected = nwc->isConnected(); - if (!connected) { return; } - - // in any case override if connected - ui->comp_OwnAircraft->setOwnModelAndIcaoValues(); - ui->comp_NetworkDetails->setLoginMode(nwc->getLoginMode()); - const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); - this->setGuiLoginAsValues(ownAircraft); - } -} // namespace diff --git a/src/blackgui/components/loginadvcomponent.h b/src/blackgui/components/loginadvcomponent.h deleted file mode 100644 index 6479427e0..000000000 --- a/src/blackgui/components/loginadvcomponent.h +++ /dev/null @@ -1,145 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKGUI_COMPONENTS_LOGINADVCOMPONENT_H -#define BLACKGUI_COMPONENTS_LOGINADVCOMPONENT_H - -#include "blackcore/vatsim/vatsimsettings.h" -#include "blackcore/data/networksetup.h" -#include "blackgui/settings/guisettings.h" -#include "blackgui/overlaymessagesframe.h" -#include "blackgui/blackguiexport.h" -#include "blackmisc/simulation/data/lastmodel.h" -#include "blackmisc/simulation/simulatedaircraft.h" -#include "blackmisc/aviation/callsign.h" -#include "blackmisc/network/server.h" -#include "blackmisc/network/user.h" -#include "blackmisc/digestsignal.h" -#include "blackmisc/settingscache.h" -#include "blackmisc/datacache.h" - -#include -#include -#include -#include -#include -#include - -namespace Ui -{ - class CLoginAdvComponent; -} -namespace BlackMisc::Simulation -{ - class CAircraftModel; - class CSimulatedAircraft; -} -namespace BlackGui::Components -{ - /*! - * Login component to flight network - */ - class BLACKGUI_EXPORT CLoginAdvComponent : public COverlayMessagesFrame - { - Q_OBJECT - - public: - //! Log categories - static const QStringList &getLogCategories(); - - //! Constructor - explicit CLoginAdvComponent(QWidget *parent = nullptr); - - //! Destructor - virtual ~CLoginAdvComponent() override; - - //! Automatically popup - void setAutoPopupWizad(bool autoPopup); - - //! Login requested - void toggleNetworkConnection(); - - signals: - //! Login - void loginOrLogoffSuccessful(); - - //! Cancelled - void loginOrLogoffCancelled(); - - //! Request to be shown - void requestLoginPage(); - - //! Request server settigs - void requestNetworkSettings(); - - //! Relevant login data changed (digest version) - void loginDataChangedDigest(); - - private: - // -------------- values from GUI ----------------- - - //! User from VATSIM data - BlackMisc::Network::CUser getUserFromPilotGuiValues() const; - - //! Update own callsign (own aircraft from what is set in the GUI) - //! \return changed? - bool updateOwnAircraftCallsignAndPilotFromGuiValues(); - - // -------------- values to GUI ----------------- - - //! Update GUI values - void updateGui(); - - //! Set the "login as" values - void setGuiLoginAsValues(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft); - - // -------------- others ----------------- - - //! Selected server (VATSIM) - BlackMisc::Network::CServer getCurrentVatsimServer() const; - - //! Selected server (others) - BlackMisc::Network::CServer getCurrentOtherServer() const; - - //! Current server based on selected tab - BlackMisc::Network::CServer getCurrentServer() const; - - //! Login cancelled - void loginCancelled(); - - //! Auto-logoff detection - void autoLogoffDetection(); - - //! Logoff due to insufficient simulator frame rate - void autoLogoffFrameRate(bool fatal); - - //! Pause/Continue timeout - void toggleTimeout(); - - //! Set OK button string - void setOkButtonString(bool connected); - - //! Load from settings - void loadRememberedUserData(); - - //! Copy credentials to pilot - void overrideCredentialsToPilot(const BlackMisc::Network::CUser &user); - - //! Simulator status changed - void onSimulatorStatusChanged(int status); - - //! Has contexts? - bool hasValidContexts() const; - - static constexpr int OverlayMessageMs = 5000; - static constexpr int LogoffIntervalSeconds = 20; //!< time before logoff - - QScopedPointer ui; - BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginAdvComponent::loginDataChangedDigest, 1500, 10 }; - BlackCore::Data::CNetworkSetup m_networkSetup; //!< servers last used - }; -} // namespace - -#endif // guard diff --git a/src/blackgui/components/loginadvcomponent.ui b/src/blackgui/components/loginadvcomponent.ui deleted file mode 100644 index 113fbe72f..000000000 --- a/src/blackgui/components/loginadvcomponent.ui +++ /dev/null @@ -1,264 +0,0 @@ - - - CLoginAdvComponent - - - - 0 - 0 - 295 - 264 - - - - Login component - - - - 2 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - Network - - - - 3 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - QFrame::Panel - - - - - - - - - - Matching log. - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - Pilot's info - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 60 - - - - Qt::NoFocus - - - - - - - - - - Qt::StrongFocus - - - Own aircraft - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 10 - - - 3 - - - 3 - - - 3 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - cancel - - - Esc - - - - - - - connect - - - - - - - - - - - BlackGui::Components::CModelMatcherLogEnable - QFrame -
blackgui/components/modelmatcherlogenable.h
- 1 -
- - BlackGui::Editors::CPilotForm - QFrame -
blackgui/editors/pilotform.h
- 1 -
- - BlackGui::Components::CNetworkDetailsComponent - QFrame -
blackgui/components/networkdetailscomponent.h
- 1 -
- - BlackGui::Components::COwnAircraftComponent - QFrame -
blackgui/components/ownaircraftcomponent.h
- 1 -
-
- - form_Pilot - pb_Connect - pb_Cancel - - - -
diff --git a/src/blackgui/components/logindialog.cpp b/src/blackgui/components/logindialog.cpp deleted file mode 100644 index f456c9f81..000000000 --- a/src/blackgui/components/logindialog.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "logindialog.h" -#include "ui_logindialog.h" - -#include "blackgui/guiapplication.h" -#include "blackcore/context/contextnetwork.h" - -using namespace BlackMisc::Network; -using namespace BlackCore; -using namespace BlackCore::Context; - -namespace BlackGui::Components -{ - CLoginDialog::CLoginDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::CLoginDialog) - { - ui->setupUi(this); - this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); - - connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffSuccessful, this, &CLoginDialog::onLoginOrLogoffSuccessful); - connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffCancelled, this, &CLoginDialog::onLoginOrLogoffCancelled); - connect(ui->comp_LoginComponent, &CLoginAdvComponent::requestNetworkSettings, this, &CLoginDialog::onRequestNetworkSettings); - - connect(ui->comp_LoginOverviewComponent, &CLoginOverviewComponent::closeOverview, this, &CLoginDialog::close); - connect(ui->comp_LoginOverviewComponent, &CLoginOverviewComponent::loginOrLogoffSuccessful, this, &CLoginDialog::onLoginOrLogoffCancelled); - - if (sGui && sGui->getIContextNetwork()) - { - connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CLoginDialog::onNetworkStatusChanged, Qt::QueuedConnection); - } - } - - CLoginDialog::~CLoginDialog() - {} - - void CLoginDialog::show() - { - this->init(); - QDialog::show(); - } - - void CLoginDialog::init() - { - bool connected = false; - if (sGui && sGui->getIContextNetwork()) - { - connected = sGui->getIContextNetwork()->isConnected(); - if (connected) - { - ui->comp_LoginOverviewComponent->showCurrentValues(); - } - } - - ui->comp_LoginComponent->setVisible(!connected); - ui->comp_LoginOverviewComponent->setVisible(connected); - } - - void CLoginDialog::onLoginOrLogoffCancelled() - { - this->reject(); - } - - void CLoginDialog::onLoginOrLogoffSuccessful() - { - this->accept(); - } - - void CLoginDialog::onRequestNetworkSettings() - { - emit this->requestNetworkSettings(); - this->close(); - } - - void CLoginDialog::onNetworkStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to) - { - Q_UNUSED(from); - if (to.isDisconnected() || to.isConnected()) - { - this->init(); - } - } -} // ns diff --git a/src/blackgui/components/logindialog.h b/src/blackgui/components/logindialog.h deleted file mode 100644 index 6f58d460f..000000000 --- a/src/blackgui/components/logindialog.h +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKGUI_COMPONENTS_LOGINDIALOG_H -#define BLACKGUI_COMPONENTS_LOGINDIALOG_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/aviation/airport.h" -#include "blackmisc/network/connectionstatus.h" -#include -#include - -namespace Ui -{ - class CLoginDialog; -} -namespace BlackGui::Components -{ - //! Login dialog - class BLACKGUI_EXPORT CLoginDialog : public QDialog - { - Q_OBJECT - - public: - //! Constructor - explicit CLoginDialog(QWidget *parent = nullptr); - - //! Destructor - virtual ~CLoginDialog() override; - - //! Init and show - void show(); - - signals: - //! Request server settings - void requestNetworkSettings(); - - private: - void init(); - void onLoginOrLogoffCancelled(); - void onLoginOrLogoffSuccessful(); - void onRequestNetworkSettings(); - void onNetworkStatusChanged(const BlackMisc::Network::CConnectionStatus &from, const BlackMisc::Network::CConnectionStatus &to); - - QScopedPointer ui; - }; -} // ns - -#endif // guard diff --git a/src/blackgui/components/logindialog.ui b/src/blackgui/components/logindialog.ui deleted file mode 100644 index d1c199acd..000000000 --- a/src/blackgui/components/logindialog.ui +++ /dev/null @@ -1,61 +0,0 @@ - - - CLoginDialog - - - - 0 - 0 - 450 - 600 - - - - - 350 - 550 - - - - Login dialog - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - BlackGui::Components::CLoginAdvComponent - QFrame -
blackgui/components/loginadvcomponent.h
- 1 -
- - BlackGui::Components::CLoginOverviewComponent - QFrame -
blackgui/components/loginoverviewcomponent.h
- 1 -
-
- - -
diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index d05f5d646..5ad3f85cf 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -7,7 +7,6 @@ #include "blackgui/components/logcomponent.h" #include "blackgui/components/dbloaddatadialog.h" #include "blackgui/components/autopublishdialog.h" -#include "blackgui/components/logindialog.h" #include "blackgui/components/modelbrowserdialog.h" #include "blackgui/components/settingscomponent.h" #include "blackgui/components/textmessagecomponent.h" @@ -244,22 +243,12 @@ void SwiftGuiStd::loginRequested() { if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; } - const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; - if (shift) + const bool changed = MainPageLogin != ui->sw_MainMiddle->currentIndex(); + this->setMainPage(MainPageLogin); + if (!changed) { - if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); } - connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings); - m_loginDialog->show(); - } - else - { - const bool changed = MainPageLogin != ui->sw_MainMiddle->currentIndex(); - this->setMainPage(MainPageLogin); - if (!changed) - { - // fake changed signal to trigger blinking disconnect button (issue #115) - emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget()); - } + // fake changed signal to trigger blinking disconnect button (issue #115) + emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget()); } } diff --git a/src/swiftguistandard/swiftguistd.h b/src/swiftguistandard/swiftguistd.h index 1ff6f829b..77b067a51 100644 --- a/src/swiftguistandard/swiftguistd.h +++ b/src/swiftguistandard/swiftguistd.h @@ -47,7 +47,6 @@ namespace BlackGui::Components { class CDbLoadDataDialog; class CAutoPublishDialog; - class CLoginDialog; class CModelBrowserDialog; } namespace Ui @@ -122,7 +121,6 @@ private: QScopedPointer m_navigator { new BlackGui::Components::CNavigatorDialog() }; //!< navigator dialog bar, if I pass the parent, the dialog is always centered over the parent QScopedPointer m_dbLoadDialog; //!< load DB data, lazy init UI component QScopedPointer m_autoPublishDialog; //!< auto publish dialog - QScopedPointer m_loginDialog; //!< login dialog QScopedPointer m_modelBrower; //!< model browser QScopedPointer m_validationDialog; //!< aircraft model validation dialog BlackMisc::CData m_lastAutoPublish { this };