Ref T659, ajusted login component/dialog for poup login

This commit is contained in:
Klaus Basan
2019-07-22 01:41:29 +02:00
committed by Mat Sutcliffe
parent eb4c8eed35
commit 34cdffc9fa
7 changed files with 37 additions and 82 deletions

View File

@@ -51,6 +51,7 @@
#include <QStringBuilder>
#include <QtGlobal>
#include <QPointer>
#include <QPair>
using namespace BlackConfig;
using namespace BlackMisc;
@@ -90,6 +91,13 @@ namespace BlackGui
this->setForceSmall(true);
this->showKillButton(false);
// auto logoff
// we decided to make it difficult for users to disable it
if (!CBuildConfig::isLocalDeveloperDebugBuild())
{
ui->cb_AutoLogoff->setChecked(true);
}
// Stored data
this->loadRememberedUserData();
@@ -109,42 +117,9 @@ namespace BlackGui
CLoginAdvComponent::~CLoginAdvComponent()
{ }
void CLoginAdvComponent::mainInfoAreaChanged(const QWidget *currentWidget)
void CLoginAdvComponent::setAutoLogoff(bool autoLogoff)
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (currentWidget != this && currentWidget != this->parentWidget())
{
// const bool wasVisible = m_visible;
m_visible = false;
/** T639
if (!wasVisible)
{
// set own values, and send signals
this->setOwnModelAndIcaoValues();
}
**/
}
else
{
if (m_visible)
{
// already visible:
// re-trigger! treat as same as OK
this->toggleNetworkConnection();
}
else
{
m_visible = true;
ui->comp_OwnAircraft->setOwnModelAndIcaoValues();
}
}
// we decided to make it difficult for users to disable it
if (!CBuildConfig::isLocalDeveloperDebugBuild())
{
ui->cb_AutoLogoff->setChecked(true);
}
ui->cb_AutoLogoff->setChecked(autoLogoff);
}
void CLoginAdvComponent::loginCancelled()
@@ -184,6 +159,7 @@ namespace BlackGui
}
// sync values with GUI values
const COwnAircraftComponent::CGuiAircraftValues values = ui->comp_OwnAircraft->getAircraftValuesFromGui();
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
ui->comp_OwnAircraft->updateOwnAircaftIcaoValuesFromGuiValues();
@@ -225,7 +201,7 @@ namespace BlackGui
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
}
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, mode);
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, values.ownLiverySend, values.useLivery, values.ownAircraftModelStringSend, values.useModelString, mode);
if (msg.isSuccess())
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
@@ -351,44 +327,6 @@ namespace BlackGui
emit this->requestLoginPage();
}
/**
void CLoginAdvComponent::onSimulatorModelChanged(const CAircraftModel &model)
{
if (!sGui || !sGui->getIContextNetwork() || sApp->isShuttingDown()) { return; }
const bool isNetworkConnected = sGui && sGui->getIContextNetwork()->isConnected();
if (isNetworkConnected) { return; }
// update with latest DB data
CAircraftModel reverseModel(model);
if (sGui->hasWebDataServices())
{
reverseModel = sGui->getWebDataServices()->getModelForModelString(model.getModelString());
if (!reverseModel.isLoadedFromDb()) { reverseModel = model; } // reset if not found
}
const QString modelStr(reverseModel.hasModelString() ? reverseModel.getModelString() : "<unknown>");
if (!reverseModel.hasModelString())
{
CLogMessage(this).validationInfo(u"Invalid lookup for '%1' successful: %2") << modelStr << reverseModel.toQString();
CLogMessage(this).validationInfo(u"Hint: Are you using the emulated driver? Set a model if so!");
return;
}
this->setOwnModelAndIcaoValues(reverseModel);
// open dialog for model mapping
if (m_autoPopupWizard && !reverseModel.isLoadedFromDb())
{
this->mappingWizard();
}
// check state of own aircraft
this->updateOwnAircraftCallsignAndPilotFromGuiValues();
// let others know data changed
m_changedLoginDataDigestSignal.inputSignal();
}
**/
bool CLoginAdvComponent::updateOwnAircraftCallsignAndPilotFromGuiValues()
{
if (!this->hasValidContexts()) { return false; }

View File

@@ -67,8 +67,11 @@ namespace BlackGui
//! Automatically popup
void setAutoPopupWizad(bool autoPopup);
//! Set auto logoff
void setAutoLogoff(bool autoLogoff);
//! Main info area changed
void mainInfoAreaChanged(const QWidget *currentWidget);
// void mainInfoAreaChanged(const QWidget *currentWidget);
//! Login requested
void toggleNetworkConnection();
@@ -150,7 +153,6 @@ namespace BlackGui
QScopedPointer<Ui::CLoginAdvComponent> ui;
BlackMisc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginAdvComponent::loginDataChangedDigest, 1500, 10 };
bool m_visible = false; //!< is this component selected?
BlackCore::Data::CNetworkSetup m_networkSetup; //!< servers last used
};
} // namespace

View File

@@ -325,7 +325,7 @@ namespace BlackGui
sGui->getIContextAudio()->setVoiceSetup(currentServer.getVoiceSetup());
}
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, mode);
msg = sGui->getIContextNetwork()->connectToNetwork(currentServer, {}, true, {}, true, mode);
if (msg.isSuccess())
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");

View File

@@ -28,6 +28,11 @@ namespace BlackGui
CLoginDialog::~CLoginDialog()
{ }
void CLoginDialog::setAutoLogoff(bool logoff)
{
ui->comp_LoginComponent->setAutoLogoff(logoff);
}
void CLoginDialog::onLoginOrLogoffCancelled()
{
this->reject();

View File

@@ -33,6 +33,9 @@ namespace BlackGui
//! Destructor
virtual ~CLoginDialog() override;
//! Set auto logoff
void setAutoLogoff(bool logoff);
signals:
//! Request server settings
void requestNetworkSettings();

View File

@@ -7,19 +7,19 @@
<x>0</x>
<y>0</y>
<width>350</width>
<height>500</height>
<height>550</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>500</height>
<height>550</height>
</size>
</property>
<property name="windowTitle">
<string>Login dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vl_LoginDialog">
<item>
<widget class="BlackGui::Components::CLoginAdvComponent" name="comp_LoginComponent">
<property name="frameShape">

View File

@@ -6,6 +6,8 @@
* or distributed except according to the terms contained in the LICENSE file.
*/
#include "ui_swiftguistd.h"
#include "blackgui/components/infobarstatuscomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/components/dbloaddatadialog.h"
@@ -28,7 +30,7 @@
#include "blackmisc/logcategorylist.h"
#include "blackmisc/logmessage.h"
#include "blackmisc/threadutils.h"
#include "ui_swiftguistd.h"
#include "blackconfig/buildconfig.h"
#include "swiftguistd.h"
#include <QAction>
@@ -57,9 +59,9 @@ namespace BlackMisc { class CIdentifiable; }
using namespace BlackCore;
using namespace BlackCore::Context;
using namespace BlackMisc;
using namespace BlackGui;
using namespace BlackGui::Components;
using namespace BlackMisc;
using namespace BlackMisc::Network;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
@@ -67,6 +69,7 @@ using namespace BlackMisc::Geo;
using namespace BlackMisc::Audio;
using namespace BlackMisc::Input;
using namespace BlackMisc::Simulation;
using namespace BlackConfig;
// Constructor
SwiftGuiStd::SwiftGuiStd(BlackGui::CEnableForFramelessWindow::WindowMode windowMode, QWidget *parent) :
@@ -255,6 +258,10 @@ void SwiftGuiStd::loginRequested()
{
if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); }
connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings);
if (!CBuildConfig::isLocalDeveloperDebugBuild())
{
m_loginDialog->setAutoLogoff(true);
}
m_loginDialog->show();
}
else