mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05: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
d52eb9c8d6
commit
d1715ef5ba
@@ -9,6 +9,12 @@
|
|||||||
#include "logindialog.h"
|
#include "logindialog.h"
|
||||||
#include "ui_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 BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
@@ -23,6 +29,11 @@ namespace BlackGui
|
|||||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffSuccessful, this, &CLoginDialog::onLoginOrLogoffSuccessful);
|
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffSuccessful, this, &CLoginDialog::onLoginOrLogoffSuccessful);
|
||||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffCancelled, this, &CLoginDialog::onLoginOrLogoffCancelled);
|
connect(ui->comp_LoginComponent, &CLoginAdvComponent::loginOrLogoffCancelled, this, &CLoginDialog::onLoginOrLogoffCancelled);
|
||||||
connect(ui->comp_LoginComponent, &CLoginAdvComponent::requestNetworkSettings, this, &CLoginDialog::onRequestNetworkSettings);
|
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()
|
CLoginDialog::~CLoginDialog()
|
||||||
@@ -31,6 +42,29 @@ namespace BlackGui
|
|||||||
void CLoginDialog::setAutoLogoff(bool logoff)
|
void CLoginDialog::setAutoLogoff(bool logoff)
|
||||||
{
|
{
|
||||||
ui->comp_LoginComponent->setAutoLogoff(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()
|
void CLoginDialog::onLoginOrLogoffCancelled()
|
||||||
@@ -48,5 +82,14 @@ namespace BlackGui
|
|||||||
emit this->requestNetworkSettings();
|
emit this->requestNetworkSettings();
|
||||||
this->close();
|
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
|
||||||
}// ns
|
}// ns
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#define BLACKGUI_COMPONENTS_LOGINDIALOG_H
|
#define BLACKGUI_COMPONENTS_LOGINDIALOG_H
|
||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include "blackcore/network.h"
|
||||||
#include "blackmisc/aviation/airport.h"
|
#include "blackmisc/aviation/airport.h"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
@@ -36,18 +37,22 @@ namespace BlackGui
|
|||||||
//! Set auto logoff
|
//! Set auto logoff
|
||||||
void setAutoLogoff(bool logoff);
|
void setAutoLogoff(bool logoff);
|
||||||
|
|
||||||
|
//! Init and show
|
||||||
|
void show();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Request server settings
|
//! Request server settings
|
||||||
void requestNetworkSettings();
|
void requestNetworkSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void init();
|
||||||
void onLoginOrLogoffCancelled();
|
void onLoginOrLogoffCancelled();
|
||||||
void onLoginOrLogoffSuccessful();
|
void onLoginOrLogoffSuccessful();
|
||||||
void onRequestNetworkSettings();
|
void onRequestNetworkSettings();
|
||||||
|
void onNetworkStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||||
|
|
||||||
QScopedPointer<Ui::CLoginDialog> ui;
|
QScopedPointer<Ui::CLoginDialog> ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
}// ns
|
}// ns
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
@@ -39,6 +49,12 @@
|
|||||||
<header>blackgui/components/loginadvcomponent.h</header>
|
<header>blackgui/components/loginadvcomponent.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CLoginOverviewComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/loginoverviewcomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
@@ -252,9 +252,9 @@ void SwiftGuiStd::loginRequested()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// const bool connected = sGui->getIContextNetwork()->isConnected();
|
||||||
const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
|
const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
|
||||||
const bool connected = sGui->getIContextNetwork()->isConnected();
|
if (shift)
|
||||||
if (!connected && shift)
|
|
||||||
{
|
{
|
||||||
if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); }
|
if (!m_loginDialog) { m_loginDialog.reset(new CLoginDialog(this)); }
|
||||||
connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings);
|
connect(m_loginDialog.data(), &CLoginDialog::requestNetworkSettings, this, &SwiftGuiStd::displayNetworkSettings);
|
||||||
|
|||||||
Reference in New Issue
Block a user