mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
Use encapsulated network setup and display correct server tab, follow up of Ref T272
This commit is contained in:
@@ -88,11 +88,11 @@ namespace BlackGui
|
|||||||
connect(ui->comp_OtherServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
connect(ui->comp_OtherServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
||||||
connect(ui->comp_VatsimServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
connect(ui->comp_VatsimServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
||||||
connect(ui->tw_Network, &QTabWidget::currentChanged, this, &CLoginComponent::onServerTabWidgetChanged);
|
connect(ui->tw_Network, &QTabWidget::currentChanged, this, &CLoginComponent::onServerTabWidgetChanged);
|
||||||
|
|
||||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginComponent::loginCancelled);
|
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginComponent::loginCancelled);
|
||||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &CLoginComponent::toggleNetworkConnection);
|
connect(ui->pb_Ok, &QPushButton::clicked, this, &CLoginComponent::toggleNetworkConnection);
|
||||||
connect(ui->pb_OtherServersGotoSettings, &QPushButton::pressed, this, &CLoginComponent::requestNetworkSettings);
|
connect(ui->pb_OtherServersGotoSettings, &QPushButton::pressed, this, &CLoginComponent::requestNetworkSettings);
|
||||||
connect(ui->tb_MappingWizard, &QToolButton::clicked, this, &CLoginComponent::mappingWizard);
|
connect(ui->tb_MappingWizard, &QToolButton::clicked, this, &CLoginComponent::mappingWizard);
|
||||||
|
connect(&m_networkSetup, &CNetworkSetup::setupChanged, this, &CLoginComponent::reloadSetup, Qt::QueuedConnection);
|
||||||
|
|
||||||
ui->comp_FsdDetails->showEnableInfo(true);
|
ui->comp_FsdDetails->showEnableInfo(true);
|
||||||
ui->comp_FsdDetails->setFsdSetupEnabled(false);
|
ui->comp_FsdDetails->setFsdSetupEnabled(false);
|
||||||
@@ -144,19 +144,15 @@ namespace BlackGui
|
|||||||
this->validateAircraftValues();
|
this->validateAircraftValues();
|
||||||
ui->editor_Pilot->validate();
|
ui->editor_Pilot->validate();
|
||||||
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
|
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
|
||||||
CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal());
|
const CServerList otherServers(m_networkSetup.getOtherServersPlusTestServers());
|
||||||
|
|
||||||
// add a testserver when no servers can be loaded
|
|
||||||
if (otherServers.isEmpty() && CBuildConfig::isLocalDeveloperDebugBuild())
|
|
||||||
{
|
|
||||||
otherServers.push_back(sGui->getGlobalSetup().getFsdTestServersPlusHardcodedServers());
|
|
||||||
CLogMessage(this).info("Added servers for testing");
|
|
||||||
}
|
|
||||||
ui->comp_OtherServers->setServers(otherServers);
|
ui->comp_OtherServers->setServers(otherServers);
|
||||||
|
|
||||||
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
||||||
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
|
||||||
this->setUiLoginState(false);
|
this->setUiLoginState(false);
|
||||||
|
|
||||||
|
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
|
||||||
|
ui->tw_Network->setCurrentIndex(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLoginComponent::~CLoginComponent()
|
CLoginComponent::~CLoginComponent()
|
||||||
@@ -243,12 +239,8 @@ namespace BlackGui
|
|||||||
const INetwork::LoginMode mode = ui->frp_LoginMode->getLoginMode();
|
const INetwork::LoginMode mode = ui->frp_LoginMode->getLoginMode();
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case INetwork::LoginStealth:
|
case INetwork::LoginStealth: CLogMessage(this).info("login in stealth mode"); break;
|
||||||
CLogMessage(this).info("login in stealth mode");
|
case INetwork::LoginAsObserver: CLogMessage(this).info("login in observer mode"); break;
|
||||||
break;
|
|
||||||
case INetwork::LoginAsObserver:
|
|
||||||
CLogMessage(this).info("login in observer mode");
|
|
||||||
break;
|
|
||||||
case INetwork::LoginNormal:
|
case INetwork::LoginNormal:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -279,10 +271,10 @@ namespace BlackGui
|
|||||||
if (msg.isSuccess())
|
if (msg.isSuccess())
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
|
||||||
m_lastServer.set(currentServer);
|
m_networkSetup.setLastServer(currentServer);
|
||||||
m_lastAircraftModel.set(ownAircraft.getModel());
|
m_lastAircraftModel.set(ownAircraft.getModel());
|
||||||
ui->le_HomeBase->setText(currentServer.getUser().getHomeBase().asString());
|
ui->le_HomeBase->setText(currentServer.getUser().getHomeBase().asString());
|
||||||
if (vatsimLogin) { m_lastVatsimServer.set(currentServer); }
|
if (vatsimLogin) { m_networkSetup.setLastVatsimServer(currentServer); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -320,7 +312,7 @@ namespace BlackGui
|
|||||||
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
||||||
if (vatsimFsdServers.isEmpty()) { return; }
|
if (vatsimFsdServers.isEmpty()) { return; }
|
||||||
vatsimFsdServers.sortBy(&CServer::getName);
|
vatsimFsdServers.sortBy(&CServer::getName);
|
||||||
const CServer currentServer = m_lastVatsimServer.get();
|
const CServer currentServer = m_networkSetup.getLastVatsimServer();
|
||||||
ui->comp_VatsimServers->setServers(vatsimFsdServers, true);
|
ui->comp_VatsimServers->setServers(vatsimFsdServers, true);
|
||||||
ui->comp_VatsimServers->preSelect(currentServer.getName());
|
ui->comp_VatsimServers->preSelect(currentServer.getName());
|
||||||
}
|
}
|
||||||
@@ -328,7 +320,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::loadRememberedUserData()
|
void CLoginComponent::loadRememberedUserData()
|
||||||
{
|
{
|
||||||
const CServer lastServer = m_lastServer.get();
|
const CServer lastServer = m_networkSetup.getLastServer();
|
||||||
if (!lastServer.isNull())
|
if (!lastServer.isNull())
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -360,12 +352,9 @@ namespace BlackGui
|
|||||||
else if (s == ui->pb_OverrideCredentialsVatsim)
|
else if (s == ui->pb_OverrideCredentialsVatsim)
|
||||||
{
|
{
|
||||||
// the VATSIM server selected has no valid user credentials
|
// the VATSIM server selected has no valid user credentials
|
||||||
server = m_lastVatsimServer.get();
|
server = m_networkSetup.getLastVatsimServer();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else { return; }
|
||||||
ui->editor_Pilot->setUser(server.getUser(), true);
|
ui->editor_Pilot->setUser(server.getUser(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,10 +377,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CLoginComponent::hasContexts()
|
bool CLoginComponent::hasContexts()
|
||||||
{
|
{
|
||||||
if (!sApp || !sApp->supportsContexts()) { return false; }
|
if (!sGui || !sGui->supportsContexts()) { return false; }
|
||||||
if (!sApp->getIContextSimulator()) { return false; }
|
if (sGui->isShuttingDown()) { return false; }
|
||||||
if (!sApp->getIContextNetwork()) { return false; }
|
if (!sGui->getIContextSimulator()) { return false; }
|
||||||
if (!sApp->getIContextOwnAircraft()) { return false; }
|
if (!sGui->getIContextNetwork()) { return false; }
|
||||||
|
if (!sGui->getIContextOwnAircraft()) { return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +415,7 @@ namespace BlackGui
|
|||||||
if (!server.getUser().hasValidVatsimId())
|
if (!server.getUser().hasValidVatsimId())
|
||||||
{
|
{
|
||||||
// normally VATSIM server have no valid user associated
|
// normally VATSIM server have no valid user associated
|
||||||
const CUser user = m_lastVatsimServer.get().getUser();
|
const CUser user = m_networkSetup.getLastVatsimServer().getUser();
|
||||||
server.setUser(user);
|
server.setUser(user);
|
||||||
}
|
}
|
||||||
return server;
|
return server;
|
||||||
@@ -547,10 +537,9 @@ namespace BlackGui
|
|||||||
this->validateAircraftValues();
|
this->validateAircraftValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::reloadSettings()
|
void CLoginComponent::reloadSetup()
|
||||||
{
|
{
|
||||||
CServerList otherServers(m_otherTrafficNetworkServers.getThreadLocal());
|
ui->comp_OtherServers->setServers(m_networkSetup.getOtherServers());
|
||||||
ui->comp_OtherServers->setServers(otherServers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::logoffCountdown()
|
void CLoginComponent::logoffCountdown()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#define BLACKGUI_LOGINCOMPONENT_H
|
#define BLACKGUI_LOGINCOMPONENT_H
|
||||||
|
|
||||||
#include "blackcore/vatsim/vatsimsettings.h"
|
#include "blackcore/vatsim/vatsimsettings.h"
|
||||||
#include "blackcore/data/vatsimsetup.h"
|
#include "blackcore/data/networksetup.h"
|
||||||
#include "blackgui/settings/guisettings.h"
|
#include "blackgui/settings/guisettings.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackgui/overlaymessagesframe.h"
|
#include "blackgui/overlaymessagesframe.h"
|
||||||
@@ -60,6 +60,14 @@ namespace BlackGui
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! The tabs
|
||||||
|
enum Tab
|
||||||
|
{
|
||||||
|
LoginVATSIM,
|
||||||
|
LoginOthers,
|
||||||
|
LoginFSD
|
||||||
|
};
|
||||||
|
|
||||||
//! Log categories
|
//! Log categories
|
||||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||||
|
|
||||||
@@ -154,7 +162,7 @@ namespace BlackGui
|
|||||||
void changedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
void changedAirlineIcao(const BlackMisc::Aviation::CAirlineIcaoCode &icao);
|
||||||
|
|
||||||
//! Settings have been changed
|
//! Settings have been changed
|
||||||
void reloadSettings();
|
void reloadSetup();
|
||||||
|
|
||||||
//! Logoff countdown
|
//! Logoff countdown
|
||||||
void logoffCountdown();
|
void logoffCountdown();
|
||||||
@@ -215,10 +223,8 @@ namespace BlackGui
|
|||||||
const QIcon m_iconPause {":/famfamfam/icons/famfamfam/icons/silk/control_pause_blue.png"};
|
const QIcon m_iconPause {":/famfamfam/icons/famfamfam/icons/silk/control_pause_blue.png"};
|
||||||
const int LogoffIntervalSeconds = 20; //!< time before logoff
|
const int LogoffIntervalSeconds = 20; //!< time before logoff
|
||||||
QTimer m_logoffCountdownTimer; //!< timer for logoff countdown
|
QTimer m_logoffCountdownTimer; //!< timer for logoff countdown
|
||||||
BlackMisc::CSettingReadOnly<BlackCore::Vatsim::TTrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::reloadSettings };
|
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
||||||
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
|
BlackCore::Data::CNetworkSetup m_networkSetup; //!< servers last used
|
||||||
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_lastVatsimServer { this }; //!< recently used VATSIM server
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user