refactor: Remove advanced login dialog

All functionalities from the advanced dialog are also available
somewhere else.
This commit is contained in:
Lars Toenning
2024-08-24 00:06:12 +02:00
parent feeafd4afd
commit 8fc72226fb
9 changed files with 5 additions and 978 deletions

View File

@@ -399,7 +399,6 @@ add_library(gui SHARED
components/aircraftmodelvalidationcomponent.h components/aircraftmodelvalidationcomponent.h
components/autopublishdialog.h components/autopublishdialog.h
components/maininfoareacomponent.h components/maininfoareacomponent.h
components/logindialog.h
components/commandinput.h components/commandinput.h
components/configsimulatorcomponent.ui components/configsimulatorcomponent.ui
components/datamaininfoareacomponent.cpp components/datamaininfoareacomponent.cpp
@@ -465,7 +464,6 @@ add_library(gui SHARED
components/logcomponent.ui components/logcomponent.ui
components/settingsmatchingdialog.ui components/settingsmatchingdialog.ui
components/settingsfontdialog.ui components/settingsfontdialog.ui
components/loginadvcomponent.h
components/simulatorselector.ui components/simulatorselector.ui
components/aircraftcomponent.ui components/aircraftcomponent.ui
components/scalescreenfactor.ui components/scalescreenfactor.ui
@@ -672,7 +670,6 @@ add_library(gui SHARED
components/dbliverycolorsearchdialog.h components/dbliverycolorsearchdialog.h
components/modelbrowserdialog.h components/modelbrowserdialog.h
components/aboutdialog.ui components/aboutdialog.ui
components/logindialog.ui
components/cockpitcomcomponent.cpp components/cockpitcomcomponent.cpp
components/logcomponent.cpp components/logcomponent.cpp
components/configurationwizard.cpp components/configurationwizard.cpp
@@ -688,7 +685,6 @@ add_library(gui SHARED
components/transpondercodespinbox.cpp components/transpondercodespinbox.cpp
components/interpolationcomponent.h components/interpolationcomponent.h
components/dbairlineicaoselectorcomponent.h components/dbairlineicaoselectorcomponent.h
components/logindialog.cpp
components/maininfoareacomponent.cpp components/maininfoareacomponent.cpp
components/mappingcomponent.h components/mappingcomponent.h
components/dbautostashingcomponent.ui components/dbautostashingcomponent.ui
@@ -734,7 +730,6 @@ add_library(gui SHARED
components/logincomponent.ui components/logincomponent.ui
components/stringlistdialog.ui components/stringlistdialog.ui
components/dbcountrycomponent.ui components/dbcountrycomponent.ui
components/loginadvcomponent.cpp
components/selcalcodeselector.h components/selcalcodeselector.h
components/navigatordialog.cpp components/navigatordialog.cpp
components/dblogincomponent.ui components/dblogincomponent.ui
@@ -750,7 +745,6 @@ add_library(gui SHARED
components/networkaircraftvaluescomponent.ui components/networkaircraftvaluescomponent.ui
components/dbaircrafticaocomponent.h components/dbaircrafticaocomponent.h
components/corestatuscomponent.ui components/corestatuscomponent.ui
components/loginadvcomponent.ui
components/datasettingscomponent.ui components/datasettingscomponent.ui
components/cockpitcomtransmissioncomponent.cpp components/cockpitcomtransmissioncomponent.cpp
components/firstmodelsetcomponent.ui components/firstmodelsetcomponent.ui

View File

@@ -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 <QDialogButtonBox>
#include <QMessageBox>
#include <QGroupBox>
#include <QIntValidator>
#include <QLineEdit>
#include <QProgressBar>
#include <QPushButton>
#include <QTabWidget>
#include <QTimer>
#include <QToolButton>
#include <QStringBuilder>
#include <QtGlobal>
#include <QPointer>
#include <QPair>
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<ISimulator::SimulatorStatus>(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

View File

@@ -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 <QFrame>
#include <QIcon>
#include <QTimer>
#include <QObject>
#include <QScopedPointer>
#include <QString>
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::CLoginAdvComponent> ui;
BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginAdvComponent::loginDataChangedDigest, 1500, 10 };
BlackCore::Data::CNetworkSetup m_networkSetup; //!< servers last used
};
} // namespace
#endif // guard

View File

@@ -1,264 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CLoginAdvComponent</class>
<widget class="QFrame" name="CLoginAdvComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>264</height>
</rect>
</property>
<property name="windowTitle">
<string>Login component</string>
</property>
<layout class="QVBoxLayout" name="hl_LoginAdvComponent">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QGroupBox" name="gb_Network">
<property name="title">
<string>Network</string>
</property>
<layout class="QVBoxLayout" name="vl_Network">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Components::CNetworkDetailsComponent" name="comp_NetworkDetails">
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_MatchingLog">
<property name="title">
<string>Matching log.</string>
</property>
<layout class="QVBoxLayout" name="vl_MatchingLogConnected">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Components::CModelMatcherLogEnable" name="comp_MatchingLog">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_PilotsDetails">
<property name="title">
<string>Pilot's info</string>
</property>
<layout class="QVBoxLayout" name="vl_PilotIngoGroupBox">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Editors::CPilotForm" name="form_Pilot">
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_OwnAircraft">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="title">
<string>Own aircraft</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="vl_OwnAircraft">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Components::COwnAircraftComponent" name="comp_OwnAircraft">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="vs_LoginAdvComponent">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignBottom">
<widget class="QFrame" name="fr_Buttons">
<layout class="QGridLayout" name="gl_Buttons">
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item row="1" column="1">
<spacer name="hs_Buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pb_Cancel">
<property name="text">
<string>cancel</string>
</property>
<property name="shortcut">
<string>Esc</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pb_Connect">
<property name="text">
<string>connect</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CModelMatcherLogEnable</class>
<extends>QFrame</extends>
<header>blackgui/components/modelmatcherlogenable.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CPilotForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/pilotform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CNetworkDetailsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/networkdetailscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::COwnAircraftComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/ownaircraftcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>form_Pilot</tabstop>
<tabstop>pb_Connect</tabstop>
<tabstop>pb_Cancel</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@@ -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

View File

@@ -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 <QDialog>
#include <QScopedPointer>
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::CLoginDialog> ui;
};
} // ns
#endif // guard

View File

@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CLoginDialog</class>
<widget class="QDialog" name="CLoginDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>550</height>
</size>
</property>
<property name="windowTitle">
<string>Login dialog</string>
</property>
<layout class="QVBoxLayout" name="vl_LoginDialog">
<item>
<widget class="BlackGui::Components::CLoginAdvComponent" name="comp_LoginComponent">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Components::CLoginOverviewComponent" name="comp_LoginOverviewComponent">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CLoginAdvComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/loginadvcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CLoginOverviewComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/loginoverviewcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -7,7 +7,6 @@
#include "blackgui/components/logcomponent.h" #include "blackgui/components/logcomponent.h"
#include "blackgui/components/dbloaddatadialog.h" #include "blackgui/components/dbloaddatadialog.h"
#include "blackgui/components/autopublishdialog.h" #include "blackgui/components/autopublishdialog.h"
#include "blackgui/components/logindialog.h"
#include "blackgui/components/modelbrowserdialog.h" #include "blackgui/components/modelbrowserdialog.h"
#include "blackgui/components/settingscomponent.h" #include "blackgui/components/settingscomponent.h"
#include "blackgui/components/textmessagecomponent.h" #include "blackgui/components/textmessagecomponent.h"
@@ -244,22 +243,12 @@ void SwiftGuiStd::loginRequested()
{ {
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; } if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; }
const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; const bool changed = MainPageLogin != ui->sw_MainMiddle->currentIndex();
if (shift) this->setMainPage(MainPageLogin);
if (!changed)
{ {
if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); } // fake changed signal to trigger blinking disconnect button (issue #115)
connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings); emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget());
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());
}
} }
} }

View File

@@ -47,7 +47,6 @@ namespace BlackGui::Components
{ {
class CDbLoadDataDialog; class CDbLoadDataDialog;
class CAutoPublishDialog; class CAutoPublishDialog;
class CLoginDialog;
class CModelBrowserDialog; class CModelBrowserDialog;
} }
namespace Ui namespace Ui
@@ -122,7 +121,6 @@ private:
QScopedPointer<BlackGui::Components::CNavigatorDialog> m_navigator { new BlackGui::Components::CNavigatorDialog() }; //!< navigator dialog bar, if I pass the parent, the dialog is always centered over the parent QScopedPointer<BlackGui::Components::CNavigatorDialog> m_navigator { new BlackGui::Components::CNavigatorDialog() }; //!< navigator dialog bar, if I pass the parent, the dialog is always centered over the parent
QScopedPointer<BlackGui::Components::CDbLoadDataDialog> m_dbLoadDialog; //!< load DB data, lazy init UI component QScopedPointer<BlackGui::Components::CDbLoadDataDialog> m_dbLoadDialog; //!< load DB data, lazy init UI component
QScopedPointer<BlackGui::Components::CAutoPublishDialog> m_autoPublishDialog; //!< auto publish dialog QScopedPointer<BlackGui::Components::CAutoPublishDialog> m_autoPublishDialog; //!< auto publish dialog
QScopedPointer<BlackGui::Components::CLoginDialog> m_loginDialog; //!< login dialog
QScopedPointer<BlackGui::Components::CModelBrowserDialog> m_modelBrower; //!< model browser QScopedPointer<BlackGui::Components::CModelBrowserDialog> m_modelBrower; //!< model browser
QScopedPointer<BlackGui::Components::CAircraftModelSetValidationDialog> m_validationDialog; //!< aircraft model validation dialog QScopedPointer<BlackGui::Components::CAircraftModelSetValidationDialog> m_validationDialog; //!< aircraft model validation dialog
BlackMisc::CData<BlackMisc::Simulation::Data::TLastAutoPublish> m_lastAutoPublish { this }; BlackMisc::CData<BlackMisc::Simulation::Data::TLastAutoPublish> m_lastAutoPublish { this };