diff --git a/src/blackgui/components/logincomponent.cpp b/src/blackgui/components/logincomponent.cpp index f1e81d7cf..ba31e8c9d 100644 --- a/src/blackgui/components/logincomponent.cpp +++ b/src/blackgui/components/logincomponent.cpp @@ -77,8 +77,7 @@ namespace BlackGui { ui->setupUi(this); m_logoffCountdownTimer.setObjectName("CLoginComponent:m_logoffCountdownTimer"); - ui->pb_LogoffTimeout->setMaximum(LogoffIntervalSeconds); - ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds); + this->setLogoffCountdown(); connect(&m_logoffCountdownTimer, &QTimer::timeout, this, &CLoginComponent::logoffCountdown); ui->tw_Network->setCurrentIndex(0); @@ -205,6 +204,15 @@ namespace BlackGui } } + void CLoginComponent::setLogoffCountdown(int timeout) + { + if (timeout < 0) { timeout = LogoffIntervalSeconds; } + + ui->pb_LogoffTimeout->setMaximum(timeout); + ui->pb_LogoffTimeout->setValue(timeout); + m_logoffIntervalSeconds = timeout; + } + void CLoginComponent::loginCancelled() { m_logoffCountdownTimer.stop(); @@ -450,8 +458,8 @@ namespace BlackGui void CLoginComponent::startLogoffTimerCountdown() { - ui->pb_LogoffTimeout->setValue(LogoffIntervalSeconds); - m_logoffCountdownTimer.setInterval(1000); + ui->pb_LogoffTimeout->setValue(m_logoffIntervalSeconds); + m_logoffCountdownTimer.setInterval(m_logoffIntervalSeconds * 1000 / 10); m_logoffCountdownTimer.start(); } diff --git a/src/blackgui/components/logincomponent.h b/src/blackgui/components/logincomponent.h index 86f0c2b61..f7cce3149 100644 --- a/src/blackgui/components/logincomponent.h +++ b/src/blackgui/components/logincomponent.h @@ -81,6 +81,9 @@ namespace BlackGui //! Main info area changed void mainInfoAreaChanged(const QWidget *currentWidget); + //! Set a logoof time + void setLogoffCountdown(int timeout = -1); + signals: //! Login void loginOrLogoffSuccessful(); @@ -216,7 +219,9 @@ namespace BlackGui //! Has contexts? bool hasValidContexts(); - static const int OverlayMessageMs = 5000; + static constexpr int OverlayMessageMs = 5000; + static constexpr int LogoffIntervalSeconds = 20; //!< time before logoff + QScopedPointer ui; QScopedPointer m_mappingWizard; BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest, 1500, 10 }; @@ -225,8 +230,9 @@ namespace BlackGui 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"}; - const int LogoffIntervalSeconds = 20; //!< time before logoff + int m_logoffIntervalSeconds = LogoffIntervalSeconds; QTimer m_logoffCountdownTimer; //!< timer for logoff countdown + BlackMisc::CData m_lastAircraftModel { this }; //!< recently used aircraft model BlackCore::Data::CNetworkSetup m_networkSetup; //!< servers last used };