mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 03:35:35 +08:00
Ref T639, unify the connect buttons
* toggle connection from button bar directly -> public * use Qt::QueuedConnection * allow to reset values
This commit is contained in:
@@ -91,11 +91,11 @@ namespace BlackGui
|
||||
connect(ui->comp_OtherServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
||||
connect(ui->comp_VatsimServers, &CServerListSelector::serverChanged, this, &CLoginComponent::onSelectedServerChanged);
|
||||
connect(ui->pb_RefreshOtherServers, &QToolButton::clicked, this, &CLoginComponent::reloadOtherServersSetup);
|
||||
connect(ui->tw_Network, &QTabWidget::currentChanged, this, &CLoginComponent::onServerTabWidgetChanged);
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginComponent::loginCancelled);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &CLoginComponent::toggleNetworkConnection);
|
||||
connect(ui->tw_Network, &QTabWidget::currentChanged, this, &CLoginComponent::onServerTabWidgetChanged);
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CLoginComponent::loginCancelled, Qt::QueuedConnection);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &CLoginComponent::toggleNetworkConnection, Qt::QueuedConnection);
|
||||
connect(ui->pb_OtherServersGotoSettings, &QPushButton::pressed, this, &CLoginComponent::requestNetworkSettings);
|
||||
connect(ui->pb_MappingWizard, &QToolButton::clicked, this, &CLoginComponent::mappingWizard);
|
||||
connect(ui->pb_MappingWizard, &QToolButton::clicked, this, &CLoginComponent::mappingWizard, Qt::QueuedConnection);
|
||||
connect(&m_networkSetup, &CNetworkSetup::setupChanged, this, &CLoginComponent::reloadOtherServersSetup, Qt::QueuedConnection);
|
||||
|
||||
ui->form_FsdDetails->showEnableInfo(true);
|
||||
@@ -184,19 +184,20 @@ namespace BlackGui
|
||||
m_logoffCountdownTimer.stop(); // in any case stop the timer
|
||||
if (currentWidget != this && currentWidget != this->parentWidget())
|
||||
{
|
||||
const bool wasVisible = m_visible;
|
||||
// const bool wasVisible = m_visible;
|
||||
m_visible = false;
|
||||
m_logoffCountdownTimer.stop();
|
||||
|
||||
if (wasVisible)
|
||||
/** T639
|
||||
if (!wasVisible)
|
||||
{
|
||||
// set own values, and send signals
|
||||
this->setOwnModelAndIcaoValues();
|
||||
}
|
||||
**/
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setOwnModelAndIcaoValues();
|
||||
if (m_visible)
|
||||
{
|
||||
// already visible:
|
||||
@@ -206,6 +207,7 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
m_visible = true;
|
||||
this->setOwnModelAndIcaoValues();
|
||||
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||
this->setUiLoginState(isConnected);
|
||||
if (isConnected) { this->startLogoffTimerCountdown(); }
|
||||
@@ -503,15 +505,18 @@ namespace BlackGui
|
||||
m_logoffCountdownTimer.start();
|
||||
}
|
||||
|
||||
void CLoginComponent::setOwnModelAndIcaoValues()
|
||||
void CLoginComponent::setOwnModelAndIcaoValues(const CAircraftModel &ownModel)
|
||||
{
|
||||
if (!this->hasValidContexts()) { return; }
|
||||
CAircraftModel model;
|
||||
CAircraftModel model = ownModel;
|
||||
const bool simulating = sGui->getIContextSimulator() &&
|
||||
(sGui->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating);
|
||||
if (simulating)
|
||||
{
|
||||
model = sGui->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||
if (!model.hasModelString())
|
||||
{
|
||||
model = sGui->getIContextOwnAircraft()->getOwnAircraft().getModel();
|
||||
}
|
||||
const QString modelAndKey(model.getModelStringAndDbKey());
|
||||
ui->le_SimulatorModel->setText(modelAndKey);
|
||||
ui->le_SimulatorModel->home(false);
|
||||
@@ -524,7 +529,10 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
model = this->getPrefillModel();
|
||||
if (!model.hasModelString())
|
||||
{
|
||||
model = this->getPrefillModel();
|
||||
}
|
||||
ui->le_SimulatorModel->clear();
|
||||
this->highlightModelField();
|
||||
}
|
||||
@@ -698,7 +706,7 @@ namespace BlackGui
|
||||
CLogMessage(this).validationInfo(u"Hint: Are you using the emulated driver? Set a model if so!");
|
||||
return;
|
||||
}
|
||||
this->setOwnModelAndIcaoValues();
|
||||
this->setOwnModelAndIcaoValues(reverseModel);
|
||||
|
||||
// open dialog for model mapping
|
||||
if (m_autoPopupWizard && !reverseModel.isLoadedFromDb())
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackGui
|
||||
explicit CLoginComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CLoginComponent();
|
||||
virtual ~CLoginComponent() override;
|
||||
|
||||
//! Automatically popup
|
||||
void setAutoPopupWizad(bool autoPopup);
|
||||
@@ -83,6 +83,9 @@ namespace BlackGui
|
||||
//! Set a logoff time
|
||||
void setLogoffCountdown(int timeoutSeconds = -1);
|
||||
|
||||
//! Login requested
|
||||
void toggleNetworkConnection();
|
||||
|
||||
signals:
|
||||
//! Login
|
||||
void loginOrLogoffSuccessful();
|
||||
@@ -158,9 +161,6 @@ namespace BlackGui
|
||||
//! Login cancelled
|
||||
void loginCancelled();
|
||||
|
||||
//! Login requested
|
||||
void toggleNetworkConnection();
|
||||
|
||||
//! VATSIM data file was loaded
|
||||
void onWebServiceDataRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState state, int number);
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace BlackGui
|
||||
void setUiLoginState(bool connected);
|
||||
|
||||
//! Own model and ICAO data for GUI and own aircraft
|
||||
void setOwnModelAndIcaoValues();
|
||||
void setOwnModelAndIcaoValues(const BlackMisc::Simulation::CAircraftModel &ownModel = {});
|
||||
|
||||
//! Set OK button string
|
||||
void setOkButtonString(bool connected);
|
||||
|
||||
@@ -231,7 +231,8 @@ void SwiftGuiStd::loginRequested()
|
||||
if (ui->sw_MainMiddle->currentIndex() == static_cast<int>(MainPageLogin))
|
||||
{
|
||||
// already main page, we fake a re-trigger here
|
||||
emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget());
|
||||
// emit this->currentMainInfoAreaChanged(ui->sw_MainMiddle->currentWidget());
|
||||
ui->comp_Login->toggleNetworkConnection();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -245,7 +245,7 @@ void SwiftGuiStd::initGuiSignals()
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
ui->sw_MainMiddle->setCurrentIndex(MainPageLogin);
|
||||
});
|
||||
connect(this, &SwiftGuiStd::currentMainInfoAreaChanged, ui->comp_Login, &CLoginComponent::mainInfoAreaChanged);
|
||||
connect(this, &SwiftGuiStd::currentMainInfoAreaChanged, ui->comp_Login, &CLoginComponent::mainInfoAreaChanged, Qt::QueuedConnection);
|
||||
|
||||
// text messages
|
||||
connect(ui->comp_MainInfoArea->getAtcStationComponent(), &CAtcStationComponent::requestTextMessageWidget, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::showCorrespondingTab, Qt::QueuedConnection);
|
||||
|
||||
Reference in New Issue
Block a user