Ref T420, setting to save "auto logoff"

* added flag in settings
* use in login component
This commit is contained in:
Klaus Basan
2018-11-28 02:33:18 +01:00
parent 0e5dc4e12a
commit 4792dbf8d1
4 changed files with 17 additions and 1 deletions

View File

@@ -32,6 +32,11 @@ namespace BlackCore
return m_lastVatsimServer.set(server);
}
CStatusMessage CNetworkSetup::setAutoLogoff(bool autoLogoff)
{
return m_autoLogoff.setAndSave(autoLogoff);
}
CServer CNetworkSetup::getLastServer() const
{
return m_lastServer.get();

View File

@@ -18,6 +18,7 @@
#include "blackmisc/network/data/lastserver.h"
#include "blackmisc/network/settings/serversettings.h"
#include "blackmisc/network/serverlist.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/settingscache.h"
#include "blackmisc/metaclass.h"
@@ -47,6 +48,9 @@ namespace BlackCore
//! Set value of last VATSIM server
BlackMisc::CStatusMessage setLastVatsimServer(const BlackMisc::Network::CServer &server);
//! Save auto logoff
BlackMisc::CStatusMessage setAutoLogoff(bool autoLogoff);
//! Last server (all networks)
BlackMisc::Network::CServer getLastServer() const;
@@ -68,6 +72,9 @@ namespace BlackCore
//! Used with an other server (i.e. non VATSIM)
bool wasLastUsedWithOtherServer() const;
//! Auto logoff?
bool useAutoLogoff() const { return m_autoLogoff.get(); }
signals:
//! Setup changed
void setupChanged();
@@ -77,6 +84,7 @@ namespace BlackCore
void onSettingsChanged();
BlackMisc::CSettingReadOnly<BlackMisc::Network::Settings::TTrafficServers> m_otherTrafficNetworkServers { this, &CNetworkSetup::onSettingsChanged };
BlackMisc::CSetting<BlackMisc::Network::Settings::TAutoLogoff> m_autoLogoff { this, &CNetworkSetup::onSettingsChanged };
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this, &CNetworkSetup::onSettingsChanged }; //!< recently used server (VATSIM, other)
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_lastVatsimServer { this, &CNetworkSetup::onSettingsChanged }; //!< recently used VATSIM server
};

View File

@@ -156,9 +156,11 @@ namespace BlackGui
this->onWebServiceDataRead(CEntityFlags::VatsimDataFile, CEntityFlags::ReadFinished, -1);
const CServerList otherServers(m_networkSetup.getOtherServersPlusTestServers());
ui->comp_OtherServers->setServers(otherServers);
ui->cb_AutoLogoff->setChecked(m_networkSetup.useAutoLogoff());
connect(ui->pb_OverrideCredentialsVatsim, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
connect(ui->pb_OverrideCredentialsOtherServers, &QPushButton::clicked, this, &CLoginComponent::overrideCredentialsToPilot);
this->setUiLoginState(false);
const int tab = m_networkSetup.wasLastUsedWithOtherServer() ? LoginOthers : LoginVATSIM;
@@ -234,6 +236,7 @@ namespace BlackGui
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
const bool vatsimLogin = this->isVatsimNetworkTabSelected();
m_networkSetup.setAutoLogoff(ui->cb_AutoLogoff->isChecked());
ui->form_Pilot->setVatsimValidation(vatsimLogin);
this->setUiLoginState(isConnected);

View File

@@ -238,7 +238,7 @@ namespace BlackGui
static constexpr int LogoffIntervalSeconds = 20; //!< time before logoff
QScopedPointer<Ui::CLoginComponent> ui;
QScopedPointer<CDbQuickMappingWizard> m_mappingWizard;
QScopedPointer<CDbQuickMappingWizard> m_mappingWizard; //!< mapping wizard
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?