mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
Ref T659, login dialog can display connected and disconnected state and also change its state
This commit is contained in:
committed by
Mat Sutcliffe
parent
1c0e57bb95
commit
b33fe9048a
@@ -9,6 +9,12 @@
|
||||
#include "logindialog.h"
|
||||
#include "ui_logindialog.h"
|
||||
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/context/contextnetwork.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -23,6 +29,11 @@ namespace BlackGui
|
||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffSuccessful, this, &CLoginDialog::onLoginOrLogoffSuccessful);
|
||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffCancelled, this, &CLoginDialog::onLoginOrLogoffCancelled);
|
||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::requestNetworkSettings, this, &CLoginDialog::onRequestNetworkSettings);
|
||||
|
||||
if (sGui && sGui->getIContextNetwork())
|
||||
{
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CLoginDialog::onNetworkStatusChanged, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
CLoginDialog::~CLoginDialog()
|
||||
@@ -31,6 +42,29 @@ namespace BlackGui
|
||||
void CLoginDialog::setAutoLogoff(bool logoff)
|
||||
{
|
||||
ui->comp_LoginComponent->setAutoLogoff(logoff);
|
||||
ui->comp_LoginOverviewComponent->setAutoLogoff(logoff);
|
||||
}
|
||||
|
||||
void CLoginDialog::show()
|
||||
{
|
||||
this->init();
|
||||
QDialog::show();
|
||||
}
|
||||
|
||||
void CLoginDialog::init()
|
||||
{
|
||||
bool connected = false;
|
||||
if (sGui && sGui->getIContextNetwork())
|
||||
{
|
||||
connected = sGui->getIContextNetwork()->isConnected();
|
||||
if (connected)
|
||||
{
|
||||
ui->comp_LoginOverviewComponent->showCurrentValues();
|
||||
}
|
||||
}
|
||||
|
||||
ui->comp_LoginComponent->setVisible(!connected);
|
||||
ui->comp_LoginOverviewComponent->setVisible(connected);
|
||||
}
|
||||
|
||||
void CLoginDialog::onLoginOrLogoffCancelled()
|
||||
@@ -48,5 +82,14 @@ namespace BlackGui
|
||||
emit this->requestNetworkSettings();
|
||||
this->close();
|
||||
}
|
||||
|
||||
void CLoginDialog::onNetworkStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
if (to == INetwork::Disconnected || to == INetwork::Connected)
|
||||
{
|
||||
this->init();
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
}// ns
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define BLACKGUI_COMPONENTS_LOGINDIALOG_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/aviation/airport.h"
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
@@ -36,18 +37,22 @@ namespace BlackGui
|
||||
//! Set auto logoff
|
||||
void setAutoLogoff(bool logoff);
|
||||
|
||||
//! Init and show
|
||||
void show();
|
||||
|
||||
signals:
|
||||
//! Request server settings
|
||||
void requestNetworkSettings();
|
||||
|
||||
private:
|
||||
void init();
|
||||
void onLoginOrLogoffCancelled();
|
||||
void onLoginOrLogoffSuccessful();
|
||||
void onRequestNetworkSettings();
|
||||
void onNetworkStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
|
||||
QScopedPointer<Ui::CLoginDialog> ui;
|
||||
};
|
||||
|
||||
} // ns
|
||||
}// ns
|
||||
|
||||
|
||||
@@ -30,6 +30,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CLoginOverviewComponent" name="comp_LoginOverviewComponent">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
@@ -39,6 +49,12 @@
|
||||
<header>blackgui/components/loginadvcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CLoginOverviewComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/loginoverviewcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -252,9 +252,9 @@ void SwiftGuiStd::loginRequested()
|
||||
}
|
||||
else
|
||||
{
|
||||
// const bool connected = sGui->getIContextNetwork()->isConnected();
|
||||
const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
|
||||
const bool connected = sGui->getIContextNetwork()->isConnected();
|
||||
if (!connected && shift)
|
||||
if (shift)
|
||||
{
|
||||
if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); }
|
||||
connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings);
|
||||
|
||||
Reference in New Issue
Block a user