mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 00:25:35 +08:00
Ref T420, trigger logoff countdown when simulator is no longer vital
This commit is contained in:
@@ -134,6 +134,7 @@ namespace BlackGui
|
||||
if (sGui && sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::ownAircraftModelChanged, this, &CLoginComponent::onSimulatorModelChanged);
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::vitalityLost, this, &CLoginComponent::autoLogoffDetection);
|
||||
}
|
||||
|
||||
// server and UI elements when in disconnect state
|
||||
@@ -208,19 +209,20 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CLoginComponent::setLogoffCountdown(int timeout)
|
||||
void CLoginComponent::setLogoffCountdown(int timeoutSeconds)
|
||||
{
|
||||
if (timeout < 0) { timeout = LogoffIntervalSeconds; }
|
||||
if (timeoutSeconds < 0) { timeoutSeconds = LogoffIntervalSeconds; }
|
||||
|
||||
ui->pb_LogoffTimeout->setMaximum(timeout);
|
||||
ui->pb_LogoffTimeout->setValue(timeout);
|
||||
m_logoffIntervalSeconds = timeout;
|
||||
ui->pb_LogoffTimeout->setMaximum(timeoutSeconds);
|
||||
ui->pb_LogoffTimeout->setValue(timeoutSeconds);
|
||||
m_logoffIntervalSeconds = timeoutSeconds;
|
||||
}
|
||||
|
||||
void CLoginComponent::loginCancelled()
|
||||
{
|
||||
m_logoffCountdownTimer.stop();
|
||||
ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds);
|
||||
this->setLogoffCountdown(); // reset time
|
||||
this->closeOverlay();
|
||||
emit this->loginOrLogoffCancelled();
|
||||
}
|
||||
|
||||
@@ -235,6 +237,9 @@ namespace BlackGui
|
||||
ui->form_Pilot->setVatsimValidation(vatsimLogin);
|
||||
this->setUiLoginState(isConnected);
|
||||
|
||||
// reset time
|
||||
this->setLogoffCountdown();
|
||||
|
||||
CServer currentServer; // used for login
|
||||
CSimulatedAircraft ownAircraft; // used own aircraft
|
||||
CStatusMessage msg;
|
||||
@@ -322,7 +327,6 @@ namespace BlackGui
|
||||
sGui->getIContextAudio()->leaveAllVoiceRooms();
|
||||
sGui->setExtraWindowTitle("");
|
||||
msg = sGui->getIContextNetwork()->disconnectFromNetwork();
|
||||
|
||||
}
|
||||
|
||||
// log message and trigger events
|
||||
@@ -481,7 +485,7 @@ namespace BlackGui
|
||||
void CLoginComponent::startLogoffTimerCountdown()
|
||||
{
|
||||
ui->pb_LogoffTimeout->setValue(m_logoffIntervalSeconds);
|
||||
m_logoffCountdownTimer.setInterval(m_logoffIntervalSeconds * 1000 / 10);
|
||||
m_logoffCountdownTimer.setInterval(1000);
|
||||
m_logoffCountdownTimer.start();
|
||||
}
|
||||
|
||||
@@ -622,6 +626,20 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CLoginComponent::autoLogoffDetection()
|
||||
{
|
||||
if (!ui->cb_AutoLogoff->isChecked()) { return; }
|
||||
if (!this->hasValidContexts()) { return; }
|
||||
if (!sGui->getIContextNetwork()->isConnected()) { return; } // nothing to logoff
|
||||
|
||||
const CStatusMessage m = CStatusMessage(this, CStatusMessage::SeverityInfo, "Auto logoff in progress");
|
||||
const int delaySecs = 45;
|
||||
this->showOverlayMessage(m, qRound(1000 * delaySecs * 0.8));
|
||||
this->setLogoffCountdown(delaySecs);
|
||||
|
||||
emit this->requestLoginPage();
|
||||
}
|
||||
|
||||
void CLoginComponent::reverseLookupAircraftModel()
|
||||
{
|
||||
if (!sGui->getIContextSimulator()->isSimulatorAvailable()) { return; }
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace BlackGui
|
||||
//! Main info area changed
|
||||
void mainInfoAreaChanged(const QWidget *currentWidget);
|
||||
|
||||
//! Set a logoof time
|
||||
void setLogoffCountdown(int timeout = -1);
|
||||
//! Set a logoff time
|
||||
void setLogoffCountdown(int timeoutSeconds = -1);
|
||||
|
||||
signals:
|
||||
//! Login
|
||||
@@ -94,6 +94,9 @@ namespace BlackGui
|
||||
//! Request network settings
|
||||
void requestNetworkSettings();
|
||||
|
||||
//! Request to be shown
|
||||
void requestLoginPage();
|
||||
|
||||
//! Relevant login data changed (digest version)
|
||||
void loginDataChangedDigest();
|
||||
|
||||
@@ -174,6 +177,9 @@ namespace BlackGui
|
||||
//! Logoff countdown
|
||||
void logoffCountdown();
|
||||
|
||||
//! Auto-logoff detection
|
||||
void autoLogoffDetection();
|
||||
|
||||
//! Reverse lookup model
|
||||
void reverseLookupAircraftModel();
|
||||
|
||||
@@ -232,7 +238,7 @@ namespace BlackGui
|
||||
QScopedPointer<CDbQuickMappingWizard> m_mappingWizard;
|
||||
BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest, 1500, 10 };
|
||||
bool m_autoPopupWizard = false; //!< automatically popup wizard if mapping is needed
|
||||
bool m_visible = false; //!< is this component selected?
|
||||
bool m_visible = false; //!< is this component selected?
|
||||
bool m_updatePilotOnServerChanges = true;
|
||||
const QIcon m_iconPlay {":/famfamfam/icons/famfamfam/icons/silk/control_play_blue.png"};
|
||||
const QIcon m_iconPause {":/famfamfam/icons/famfamfam/icons/silk/control_pause_blue.png"};
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>272</width>
|
||||
<height>748</height>
|
||||
<width>295</width>
|
||||
<height>735</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -226,7 +226,7 @@
|
||||
<item alignment="Qt::AlignTop">
|
||||
<widget class="QTabWidget" name="tw_Details">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_LoginMode">
|
||||
<attribute name="title">
|
||||
@@ -788,7 +788,7 @@
|
||||
<widget class="QFrame" name="fr_Buttons">
|
||||
<layout class="QGridLayout" name="gl_Buttons">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
@@ -799,7 +799,7 @@
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1">
|
||||
<spacer name="hs_Buttons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@@ -812,7 +812,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pb_Cancel">
|
||||
<property name="text">
|
||||
<string>cancel</string>
|
||||
@@ -822,13 +822,23 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pb_Ok">
|
||||
<property name="text">
|
||||
<string>ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_AutoLogoff">
|
||||
<property name="toolTip">
|
||||
<string>automatically logoff when simulator changes or appears crashed</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>auto logoff</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user