Login UI improvements

This commit is contained in:
Klaus Basan
2018-11-11 00:38:38 +01:00
parent 4f74a36596
commit 79547efe0a
3 changed files with 73 additions and 32 deletions

View File

@@ -129,6 +129,7 @@ namespace BlackGui
connect(ui->selector_AircraftIcao, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CLoginComponent::changedAircraftIcao, Qt::QueuedConnection); connect(ui->selector_AircraftIcao, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CLoginComponent::changedAircraftIcao, Qt::QueuedConnection);
connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CLoginComponent::changedAirlineIcao, Qt::QueuedConnection); connect(ui->selector_AirlineIcao, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CLoginComponent::changedAirlineIcao, Qt::QueuedConnection);
connect(ui->tb_SimulatorIcaoReverseLookup, &QToolButton::clicked, this, &CLoginComponent::reverseLookupAircraftModel); connect(ui->tb_SimulatorIcaoReverseLookup, &QToolButton::clicked, this, &CLoginComponent::reverseLookupAircraftModel);
connect(ui->tw_Details, &QTabWidget::currentChanged, this, &CLoginComponent::onDetailsTabChanged);
if (sGui && sGui->getIContextSimulator()) if (sGui && sGui->getIContextSimulator())
{ {
@@ -142,7 +143,10 @@ namespace BlackGui
connect(ui->tb_Timeout, &QToolButton::clicked, this, &CLoginComponent::toggleTimeout); connect(ui->tb_Timeout, &QToolButton::clicked, this, &CLoginComponent::toggleTimeout);
// web service data // web service data
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CLoginComponent::onWebServiceDataRead, Qt::QueuedConnection); if (sGui && sGui->getWebDataServices())
{
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CLoginComponent::onWebServiceDataRead, Qt::QueuedConnection);
}
// inital setup, if data already available // inital setup, if data already available
this->validateAircraftValues(); this->validateAircraftValues();
@@ -223,6 +227,7 @@ namespace BlackGui
void CLoginComponent::toggleNetworkConnection() void CLoginComponent::toggleNetworkConnection()
{ {
if (!sGui || sGui->isShuttingDown()) { return; } if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextNetwork() || !sGui->getIContextAudio()) { return; }
const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected(); const bool isConnected = sGui && sGui->getIContextNetwork()->isConnected();
const bool vatsimLogin = this->isVatsimNetworkTabSelected(); const bool vatsimLogin = this->isVatsimNetworkTabSelected();
@@ -262,9 +267,7 @@ namespace BlackGui
} }
// Server // Server
currentServer = vatsimLogin ? currentServer = vatsimLogin ? this->getCurrentVatsimServer() : this->getCurrentOtherServer();
this->getCurrentVatsimServer() :
this->getCurrentOtherServer();
const CUser user = this->getUserFromPilotGuiValues(); const CUser user = this->getUserFromPilotGuiValues();
currentServer.setUser(user); currentServer.setUser(user);
@@ -304,7 +307,8 @@ namespace BlackGui
m_networkSetup.setLastServer(currentServer); m_networkSetup.setLastServer(currentServer);
m_lastAircraftModel.set(ownAircraft.getModel()); m_lastAircraftModel.set(ownAircraft.getModel());
ui->le_HomeBase->setText(currentServer.getUser().getHomeBase().asString()); ui->le_LoginCallsign->setText(ownAircraft.getCallsignAsString());
ui->le_LoginHomeBase->setText(currentServer.getUser().getHomeBase().asString());
if (vatsimLogin) { m_networkSetup.setLastVatsimServer(currentServer); } if (vatsimLogin) { m_networkSetup.setLastVatsimServer(currentServer); }
} }
else else
@@ -376,8 +380,8 @@ namespace BlackGui
void CLoginComponent::overrideCredentialsToPilot() void CLoginComponent::overrideCredentialsToPilot()
{ {
const QObject *s = QObject::sender();
CServer server; CServer server;
const QObject *s = QObject::sender();
if (s == ui->pb_OverrideCredentialsOtherServers) if (s == ui->pb_OverrideCredentialsOtherServers)
{ {
server = this->getCurrentOtherServer(); server = this->getCurrentOtherServer();
@@ -408,7 +412,7 @@ namespace BlackGui
ui->form_Pilot->setUser(server.getUser(), true); ui->form_Pilot->setUser(server.getUser(), true);
} }
bool CLoginComponent::hasValidContexts() bool CLoginComponent::hasValidContexts() const
{ {
if (!sGui || !sGui->supportsContexts()) { return false; } if (!sGui || !sGui->supportsContexts()) { return false; }
if (sGui->isShuttingDown()) { return false; } if (sGui->isShuttingDown()) { return false; }
@@ -418,6 +422,21 @@ namespace BlackGui
return true; return true;
} }
void CLoginComponent::setServerButtonsVisible(bool visible)
{
ui->wi_OtherServersButtons->setVisible(visible);
ui->wi_VatsimButtons->setVisible(visible);
}
void CLoginComponent::onDetailsTabChanged(int index)
{
Q_UNUSED(index);
const bool showNetwork = (ui->tw_Details->currentWidget() != ui->tb_FsdDetails);
ui->tw_Network->setVisible(showNetwork);
// this->setServerButtonsVisible(showNetwork);
ui->tw_Details->setMinimumHeight(showNetwork ? 0 : 125);
}
CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const
{ {
CGuiAircraftValues values; CGuiAircraftValues values;
@@ -538,11 +557,15 @@ namespace BlackGui
void CLoginComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft) void CLoginComponent::setGuiLoginAsValues(const CSimulatedAircraft &ownAircraft)
{ {
QString ac(ownAircraft.getCallsignAsString() % QLatin1Char(' ') % ownAircraft.getAircraftIcaoCodeDesignator()); const QString ac(
if (ownAircraft.hasAirlineDesignator()) { ac += QLatin1Char(' ') % ownAircraft.getAirlineIcaoCodeDesignator(); } ownAircraft.getAircraftIcaoCodeDesignator() %
if (!ownAircraft.getAircraftIcaoCombinedType().isEmpty()) { ac += QLatin1Char(' ') % ownAircraft.getAircraftIcaoCode().getCombinedType(); } (ownAircraft.hasAirlineDesignator() ? (QLatin1Char(' ') % ownAircraft.getAirlineIcaoCodeDesignator()) : QStringLiteral("")) %
(ownAircraft.hasModelString() ? (QLatin1Char(' ') % ownAircraft.getModelString()) : QStringLiteral(""))
);
ui->le_LoginSince->setText(QDateTime::currentDateTimeUtc().toString()); ui->le_LoginSince->setText(QDateTime::currentDateTimeUtc().toString());
ui->le_LoginAsAircaft->setText(ac); ui->le_LoginAsAircaft->setText(ac);
ui->le_LoginCallsign->setText(ownAircraft.getCallsignAsString());
ui->le_LoginAsAircaft->home(false);
} }
bool CLoginComponent::validateAircraftValues() bool CLoginComponent::validateAircraftValues()
@@ -771,14 +794,15 @@ namespace BlackGui
void CLoginComponent::updateGui() void CLoginComponent::updateGui()
{ {
if (!this->hasValidContexts()) { return; } if (!this->hasValidContexts()) { return; }
if (!sGui->getIContextNetwork()) { return; }
IContextNetwork *nwc = sGui->getIContextNetwork(); IContextNetwork *nwc = sGui->getIContextNetwork();
const bool connected = nwc->isConnected(); const bool connected = nwc->isConnected();
if (!connected) { return; } if (!connected) { return; }
this->setUiLoginState(connected); this->setUiLoginState(connected);
this->setOwnModelAndIcaoValues(); this->setOwnModelAndIcaoValues();
const CServer server = nwc->getConnectedServer(); const CServer server = nwc->getConnectedServer();
ui->le_HomeBase->setText(server.getUser().getHomeBase().asString()); ui->le_LoginHomeBase->setText(server.getUser().getHomeBase().asString());
ui->frp_CurrentServer->setServer(server); ui->frp_CurrentServer->setServer(server);
ui->frp_LoginMode->setLoginMode(nwc->getLoginMode()); ui->frp_LoginMode->setLoginMode(nwc->getLoginMode());
const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft(); const CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();

View File

@@ -304,17 +304,17 @@
<number>3</number> <number>3</number>
</property> </property>
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="sa_FsdDetails">
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="sa_FsdDetails"> <widget class="QWidget" name="qw_FsdDetails">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>253</width> <width>253</width>
<height>55</height> <height>45</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="vl_ScrollAreaFsdDetails"> <layout class="QVBoxLayout" name="vl_ScrollAreaFsdDetails">
@@ -755,36 +755,53 @@
<item> <item>
<widget class="QFrame" name="fr_CurrentLoginAddInfo"> <widget class="QFrame" name="fr_CurrentLoginAddInfo">
<layout class="QGridLayout" name="gl_AddInfo" columnstretch="1,2,1"> <layout class="QGridLayout" name="gl_AddInfo" columnstretch="1,2,1">
<item row="0" column="2"> <item row="2" column="0">
<widget class="QLineEdit" name="le_HomeBase">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_LoginSince"> <widget class="QLabel" name="lbl_LoginSince">
<property name="text"> <property name="text">
<string>Login since:</string> <string>Login since:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="1" column="0">
<widget class="QLineEdit" name="le_LoginAsAircaft"> <widget class="QLabel" name="lbl_LoginAsAircraft">
<property name="text">
<string>Aircraft:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="le_LoginSince">
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="lbl_LoginAsAircraft"> <widget class="QLabel" name="lbl_LoginCallsign">
<property name="toolTip">
<string>Callsign/home</string>
</property>
<property name="text"> <property name="text">
<string>Aircraft/home:</string> <string>CS/home:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_LoginCallsign">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="le_LoginHomeBase">
<property name="readOnly">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="2"> <item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="le_LoginSince"> <widget class="QLineEdit" name="le_LoginAsAircaft">
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
@@ -961,7 +978,7 @@
<tabstop>pb_OtherServersGotoSettings</tabstop> <tabstop>pb_OtherServersGotoSettings</tabstop>
<tabstop>pb_OverrideCredentialsOtherServers</tabstop> <tabstop>pb_OverrideCredentialsOtherServers</tabstop>
<tabstop>tw_Details</tabstop> <tabstop>tw_Details</tabstop>
<tabstop>scrollArea</tabstop> <tabstop>sa_FsdDetails</tabstop>
<tabstop>le_SimulatorModel</tabstop> <tabstop>le_SimulatorModel</tabstop>
<tabstop>tb_SimulatorIcaoReverseLookup</tabstop> <tabstop>tb_SimulatorIcaoReverseLookup</tabstop>
<tabstop>tb_MappingWizard</tabstop> <tabstop>tb_MappingWizard</tabstop>
@@ -969,8 +986,8 @@
<tabstop>selector_AircraftIcao</tabstop> <tabstop>selector_AircraftIcao</tabstop>
<tabstop>le_AircraftCombinedType</tabstop> <tabstop>le_AircraftCombinedType</tabstop>
<tabstop>selector_AirlineIcao</tabstop> <tabstop>selector_AirlineIcao</tabstop>
<tabstop>le_LoginCallsign</tabstop>
<tabstop>le_LoginAsAircaft</tabstop> <tabstop>le_LoginAsAircaft</tabstop>
<tabstop>le_HomeBase</tabstop>
<tabstop>le_LoginSince</tabstop> <tabstop>le_LoginSince</tabstop>
<tabstop>tb_Timeout</tabstop> <tabstop>tb_Timeout</tabstop>
<tabstop>pb_Ok</tabstop> <tabstop>pb_Ok</tabstop>

View File

@@ -68,10 +68,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignLeft"> <item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_SetDefaults"> <widget class="QPushButton" name="pb_SetDefaults">
<property name="text"> <property name="text">
<string> set defaults </string> <string>set defaults</string>
</property> </property>
</widget> </widget>
</item> </item>