mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
refs #690, remember last login data
* cache/setting for last values * integrated in login component * allow to set default value for server selection
This commit is contained in:
@@ -43,8 +43,7 @@ namespace BlackCore
|
|||||||
IndexDataFiles,
|
IndexDataFiles,
|
||||||
IndexMetarFiles,
|
IndexMetarFiles,
|
||||||
IndexFsdServers,
|
IndexFsdServers,
|
||||||
IndexCVoiceServers,
|
IndexCVoiceServers
|
||||||
IndexLastLoginUser
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
@@ -74,9 +73,6 @@ namespace BlackCore
|
|||||||
//! FSD test servers
|
//! FSD test servers
|
||||||
const BlackMisc::Network::CServerList &getFsdServers() const { return m_fsdServers; }
|
const BlackMisc::Network::CServerList &getFsdServers() const { return m_fsdServers; }
|
||||||
|
|
||||||
//! User for last login
|
|
||||||
const BlackMisc::Network::CUser &getLastLoginUser() const { return m_lastLoginUser; }
|
|
||||||
|
|
||||||
//! Set FSD servers
|
//! Set FSD servers
|
||||||
void setFsdServers(const BlackMisc::Network::CServerList &servers) { m_fsdServers = servers; }
|
void setFsdServers(const BlackMisc::Network::CServerList &servers) { m_fsdServers = servers; }
|
||||||
|
|
||||||
@@ -86,9 +82,6 @@ namespace BlackCore
|
|||||||
//! Set voice servers
|
//! Set voice servers
|
||||||
void setVoiceServers(const BlackMisc::Network::CServerList &servers) { m_voiceServers = servers; }
|
void setVoiceServers(const BlackMisc::Network::CServerList &servers) { m_voiceServers = servers; }
|
||||||
|
|
||||||
//! User for last login
|
|
||||||
void setLastLoginUser(const BlackMisc::Network::CUser &user) { m_lastLoginUser = user; }
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
@@ -107,7 +100,6 @@ namespace BlackCore
|
|||||||
BlackMisc::Network::CUrlList m_metarFileUrls; //!< METAR files
|
BlackMisc::Network::CUrlList m_metarFileUrls; //!< METAR files
|
||||||
BlackMisc::Network::CServerList m_fsdServers; //!< FSD test servers
|
BlackMisc::Network::CServerList m_fsdServers; //!< FSD test servers
|
||||||
BlackMisc::Network::CServerList m_voiceServers; //!< voice servers
|
BlackMisc::Network::CServerList m_voiceServers; //!< voice servers
|
||||||
BlackMisc::Network::CUser m_lastLoginUser; //!< last login user
|
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CVatsimSetup,
|
CVatsimSetup,
|
||||||
@@ -116,7 +108,6 @@ namespace BlackCore
|
|||||||
BLACK_METAMEMBER(metarFileUrls),
|
BLACK_METAMEMBER(metarFileUrls),
|
||||||
BLACK_METAMEMBER(fsdServers),
|
BLACK_METAMEMBER(fsdServers),
|
||||||
BLACK_METAMEMBER(voiceServers),
|
BLACK_METAMEMBER(voiceServers),
|
||||||
BLACK_METAMEMBER(lastLoginUser),
|
|
||||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -125,7 +116,17 @@ namespace BlackCore
|
|||||||
struct VatsimSetup : public BlackMisc::CDataTrait<CVatsimSetup>
|
struct VatsimSetup : public BlackMisc::CDataTrait<CVatsimSetup>
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "vatsim"; }
|
static const char *key() { return "vatsimsetup"; }
|
||||||
|
|
||||||
|
//! First load is synchronous
|
||||||
|
static constexpr bool isPinned() { return true; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Trait for currently used VATSIM server and user
|
||||||
|
struct VatsimCurrentServer : public BlackMisc::CDataTrait<BlackMisc::Network::CServer>
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "vatsimserver"; }
|
||||||
|
|
||||||
//! First load is synchronous
|
//! First load is synchronous
|
||||||
static constexpr bool isPinned() { return true; }
|
static constexpr bool isPinned() { return true; }
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ namespace BlackGui
|
|||||||
this->ui->lblp_VatsimPassword->setToolTips("ok", "wrong");
|
this->ui->lblp_VatsimPassword->setToolTips("ok", "wrong");
|
||||||
this->ui->lblp_VatsimRealName->setToolTips("ok", "wrong");
|
this->ui->lblp_VatsimRealName->setToolTips("ok", "wrong");
|
||||||
|
|
||||||
// Settings loaded
|
// Stored data
|
||||||
this->loadFromSettings();
|
this->loadRememberedVatsimData();
|
||||||
|
|
||||||
// Remark: The validators affect the signals such as returnPressed, editingFinished
|
// Remark: The validators affect the signals such as returnPressed, editingFinished
|
||||||
// So I use no ranges in the CUpperCaseValidators, as this disables the signals for invalid values
|
// So I use no ranges in the CUpperCaseValidators, as this disables the signals for invalid values
|
||||||
@@ -137,7 +137,7 @@ namespace BlackGui
|
|||||||
otherServers.push_back(sGui->getGlobalSetup().getFsdTestServersPlusHardcodedServers());
|
otherServers.push_back(sGui->getGlobalSetup().getFsdTestServersPlusHardcodedServers());
|
||||||
CLogMessage(this).info("Added servers for testing");
|
CLogMessage(this).info("Added servers for testing");
|
||||||
}
|
}
|
||||||
this->ui->cbp_OtherServers->setServers(otherServers);
|
this->ui->comp_OtherServers->setServers(otherServers);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLoginComponent::~CLoginComponent()
|
CLoginComponent::~CLoginComponent()
|
||||||
@@ -180,12 +180,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CLoginComponent::ps_toggleNetworkConnection()
|
void CLoginComponent::ps_toggleNetworkConnection()
|
||||||
{
|
{
|
||||||
bool isConnected = sGui->getIContextNetwork()->isConnected();
|
const bool isConnected = sGui->getIContextNetwork()->isConnected();
|
||||||
|
const bool vatsimLogin = (this->ui->tw_Network->currentWidget() == this->ui->pg_NetworkVatsim);
|
||||||
|
CServer currentServer; // used for login
|
||||||
|
CSimulatedAircraft ownAircraft; // used own aircraft
|
||||||
CStatusMessage msg;
|
CStatusMessage msg;
|
||||||
if (!isConnected)
|
if (!isConnected)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool vatsimLogin = (this->ui->tw_Network->currentWidget() == this->ui->pg_NetworkVatsim);
|
|
||||||
if (!this->ps_validateAircraftValues())
|
if (!this->ps_validateAircraftValues())
|
||||||
{
|
{
|
||||||
CLogMessage(this).warning("Invalid aircraft data, login not possible");
|
CLogMessage(this).warning("Invalid aircraft data, login not possible");
|
||||||
@@ -200,7 +202,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
// sync values with GUI values
|
// sync values with GUI values
|
||||||
CGuiAircraftValues aircraftValues = this->getAircraftValuesFromGui();
|
CGuiAircraftValues aircraftValues = this->getAircraftValuesFromGui();
|
||||||
CSimulatedAircraft ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
ownAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
|
||||||
CAircraftIcaoCode aircraftCode(ownAircraft.getAircraftIcaoCode());
|
CAircraftIcaoCode aircraftCode(ownAircraft.getAircraftIcaoCode());
|
||||||
CAirlineIcaoCode airlineCode(ownAircraft.getAirlineIcaoCode());
|
CAirlineIcaoCode airlineCode(ownAircraft.getAirlineIcaoCode());
|
||||||
|
|
||||||
@@ -244,11 +246,10 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
CServer currentServer;
|
|
||||||
if (vatsimLogin)
|
if (vatsimLogin)
|
||||||
{
|
{
|
||||||
currentServer = this->getCurrentVatsimServer();
|
currentServer = this->getCurrentVatsimServer();
|
||||||
CUser vatsimUser = this->getUserFromVatsimGuiValues();
|
const CUser vatsimUser = this->getUserFromVatsimGuiValues();
|
||||||
currentServer.setUser(vatsimUser);
|
currentServer.setUser(vatsimUser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -274,6 +275,11 @@ namespace BlackGui
|
|||||||
if (msg.isSeverityInfoOrLess())
|
if (msg.isSeverityInfoOrLess())
|
||||||
{
|
{
|
||||||
emit loginOrLogoffSuccessful();
|
emit loginOrLogoffSuccessful();
|
||||||
|
if (vatsimLogin)
|
||||||
|
{
|
||||||
|
this->m_currentVatsimServer.set(currentServer);
|
||||||
|
this->m_currentAircraftModel.setAndSave(ownAircraft.getModel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -281,16 +287,17 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::ps_onWebServiceDataRead(int entityI, int stateI, int number)
|
void CLoginComponent::ps_onWebServiceDataRead(int entityInt, int stateI, int number)
|
||||||
// void CLoginComponent::ps_onWebServiceDataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState, int number)
|
|
||||||
{
|
{
|
||||||
CEntityFlags::EntityFlag entity = static_cast<CEntityFlags::EntityFlag>(entityI);
|
const CEntityFlags::EntityFlag entity = static_cast<CEntityFlags::EntityFlag>(entityInt);
|
||||||
CEntityFlags::ReadState state = static_cast<CEntityFlags::ReadState>(stateI);
|
const CEntityFlags::ReadState state = static_cast<CEntityFlags::ReadState>(stateI);
|
||||||
if (entity != CEntityFlags::VatsimDataFile || state != CEntityFlags::ReadFinished) { return; }
|
if (entity != CEntityFlags::VatsimDataFile || state != CEntityFlags::ReadFinished) { return; }
|
||||||
Q_UNUSED(number);
|
Q_UNUSED(number);
|
||||||
CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
const CServerList vatsimFsdServers = sGui->getIContextNetwork()->getVatsimFsdServers();
|
||||||
if (vatsimFsdServers.isEmpty()) { return; }
|
if (vatsimFsdServers.isEmpty()) { return; }
|
||||||
this->ui->cbp_VatsimServer->setServers(vatsimFsdServers);
|
const CServer currentServer = this->m_currentVatsimServer.get();
|
||||||
|
this->ui->comp_VatsimServer->setServers(vatsimFsdServers);
|
||||||
|
this->ui->comp_VatsimServer->preSelect(currentServer.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::setGuiValuesFromAircraft(const CSimulatedAircraft &ownAircraft)
|
void CLoginComponent::setGuiValuesFromAircraft(const CSimulatedAircraft &ownAircraft)
|
||||||
@@ -302,15 +309,28 @@ namespace BlackGui
|
|||||||
this->ui->le_AircraftCombinedType->setText(aircraftIcao.getCombinedType());
|
this->ui->le_AircraftCombinedType->setText(aircraftIcao.getCombinedType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::loadFromSettings()
|
void CLoginComponent::loadRememberedVatsimData()
|
||||||
|
{
|
||||||
|
const CServer lastServer = this->m_currentVatsimServer.get();
|
||||||
|
const CUser lastUser = lastServer.getUser();
|
||||||
|
if (lastUser.hasValidCallsign())
|
||||||
|
{
|
||||||
|
this->ui->le_Callsign->setText(lastUser.getCallsign().asString());
|
||||||
|
this->ui->le_VatsimId->setText(lastUser.getId());
|
||||||
|
this->ui->le_VatsimPassword->setText(lastUser.getPassword());
|
||||||
|
this->ui->le_VatsimHomeAirport->setText(lastUser.getHomebase().asString());
|
||||||
|
this->ui->le_VatsimRealName->setText(lastUser.getRealName());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//! \todo replace with loading from settings when completed
|
|
||||||
this->ui->le_Callsign->setText("SWIFT");
|
this->ui->le_Callsign->setText("SWIFT");
|
||||||
this->ui->le_VatsimId->setText("1288459");
|
this->ui->le_VatsimId->setText("1288459");
|
||||||
this->ui->le_VatsimPassword->setText("4769");
|
this->ui->le_VatsimPassword->setText("4769");
|
||||||
this->ui->le_VatsimHomeAirport->setText("LOWI");
|
this->ui->le_VatsimHomeAirport->setText("LOWI");
|
||||||
this->ui->le_VatsimRealName->setText("Black Swift");
|
this->ui->le_VatsimRealName->setText("Black Swift");
|
||||||
}
|
}
|
||||||
|
this->ui->comp_OtherServers->preSelect(lastServer.getName());
|
||||||
|
}
|
||||||
|
|
||||||
CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const
|
CLoginComponent::CGuiAircraftValues CLoginComponent::getAircraftValuesFromGui() const
|
||||||
{
|
{
|
||||||
@@ -337,6 +357,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CVatsimValues values = getVatsimValuesFromGui();
|
CVatsimValues values = getVatsimValuesFromGui();
|
||||||
CUser user(values.vatsimId, values.vatsimRealName, "", values.vatsimPassword, getCallsignFromGui());
|
CUser user(values.vatsimId, values.vatsimRealName, "", values.vatsimPassword, getCallsignFromGui());
|
||||||
|
user.setHomebase(values.vatsimHomeAirport);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,12 +369,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
CServer CLoginComponent::getCurrentVatsimServer() const
|
CServer CLoginComponent::getCurrentVatsimServer() const
|
||||||
{
|
{
|
||||||
return this->ui->cbp_VatsimServer->currentServer();
|
return this->ui->comp_VatsimServer->currentServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
CServer CLoginComponent::getCurrentOtherServer() const
|
CServer CLoginComponent::getCurrentOtherServer() const
|
||||||
{
|
{
|
||||||
return this->ui->cbp_OtherServers->currentServer();
|
return this->ui->comp_OtherServers->currentServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::setOkButtonString(bool connected)
|
void CLoginComponent::setOkButtonString(bool connected)
|
||||||
@@ -382,12 +403,8 @@ namespace BlackGui
|
|||||||
Q_ASSERT(sGui->getIContextOwnAircraft());
|
Q_ASSERT(sGui->getIContextOwnAircraft());
|
||||||
Q_ASSERT(sGui->getIContextSimulator());
|
Q_ASSERT(sGui->getIContextSimulator());
|
||||||
|
|
||||||
static const CAircraftModel defaultModel(
|
|
||||||
"", CAircraftModel::TypeOwnSimulatorModel, "default model",
|
|
||||||
CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0));
|
|
||||||
|
|
||||||
CAircraftModel model;
|
CAircraftModel model;
|
||||||
bool simulating = sGui->getIContextSimulator() &&
|
const bool simulating = sGui->getIContextSimulator() &&
|
||||||
(sGui->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating);
|
(sGui->getIContextSimulator()->getSimulatorStatus() & ISimulator::Simulating);
|
||||||
if (simulating)
|
if (simulating)
|
||||||
{
|
{
|
||||||
@@ -396,10 +413,12 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Set observer mode without simulator
|
static const CAircraftModel defaultModel(
|
||||||
//! \todo Currently not working in OBS mode
|
"", CAircraftModel::TypeOwnSimulatorModel, "default model",
|
||||||
model = CAircraftModel(defaultModel);
|
CAircraftIcaoCode("C172", "L1P", "Cessna", "172", "L", true, false, false, 0));
|
||||||
this->ui->gbp_LoginMode->setLoginMode(INetwork::LoginNormal);
|
model = this->m_currentAircraftModel.get();
|
||||||
|
if (!model.hasAircraftDesignator()) { model = defaultModel; }
|
||||||
|
this->ui->gbp_LoginMode->setLoginMode(INetwork::LoginNormal); //! \todo Set observer mode without simulator, currently not working in OBS mode
|
||||||
this->ui->le_SimulatorModel->setText("No simulator");
|
this->ui->le_SimulatorModel->setText("No simulator");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +490,7 @@ namespace BlackGui
|
|||||||
void CLoginComponent::ps_reloadSettings()
|
void CLoginComponent::ps_reloadSettings()
|
||||||
{
|
{
|
||||||
CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
|
CServerList otherServers(this->m_otherTrafficNetworkServers.getThreadLocal());
|
||||||
this->ui->cbp_OtherServers->setServers(otherServers);
|
this->ui->comp_OtherServers->setServers(otherServers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLoginComponent::ps_logoffCountdown()
|
void CLoginComponent::ps_logoffCountdown()
|
||||||
@@ -504,6 +523,5 @@ namespace BlackGui
|
|||||||
CLogMessage(this).validationInfo("Reverse lookup for %1 failed, set data manually") << modelStr;
|
CLogMessage(this).validationInfo("Reverse lookup for %1 failed, set data manually") << modelStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -13,12 +13,15 @@
|
|||||||
#define BLACKGUI_LOGINCOMPONENT_H
|
#define BLACKGUI_LOGINCOMPONENT_H
|
||||||
|
|
||||||
#include "blackcore/settings/network.h"
|
#include "blackcore/settings/network.h"
|
||||||
|
#include "blackcore/data/vatsimsetup.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include "blackgui/settings/settingsgui.h"
|
||||||
#include "blackmisc/aviation/callsign.h"
|
#include "blackmisc/aviation/callsign.h"
|
||||||
#include "blackmisc/network/entityflags.h"
|
#include "blackmisc/network/entityflags.h"
|
||||||
#include "blackmisc/network/server.h"
|
#include "blackmisc/network/server.h"
|
||||||
#include "blackmisc/network/user.h"
|
#include "blackmisc/network/user.h"
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
|
#include "blackmisc/datacache.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
@@ -38,7 +41,6 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace Ui { class CLoginComponent; }
|
namespace Ui { class CLoginComponent; }
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
@@ -119,7 +121,7 @@ namespace BlackGui
|
|||||||
void setGuiValuesFromAircraft(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
void setGuiValuesFromAircraft(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
||||||
|
|
||||||
//! Load from settings
|
//! Load from settings
|
||||||
void loadFromSettings();
|
void loadRememberedVatsimData();
|
||||||
|
|
||||||
//! Values from GUI
|
//! Values from GUI
|
||||||
CGuiAircraftValues getAircraftValuesFromGui() const;
|
CGuiAircraftValues getAircraftValuesFromGui() const;
|
||||||
@@ -154,13 +156,14 @@ namespace BlackGui
|
|||||||
//! Set ICAO values
|
//! Set ICAO values
|
||||||
void setGuiIcaoValues(const BlackMisc::Simulation::CAircraftModel &model, bool onlyIfEmpty);
|
void setGuiIcaoValues(const BlackMisc::Simulation::CAircraftModel &model, bool onlyIfEmpty);
|
||||||
|
|
||||||
bool m_visible = false; //!< is this component selected?
|
|
||||||
QScopedPointer<Ui::CLoginComponent> ui;
|
QScopedPointer<Ui::CLoginComponent> ui;
|
||||||
|
bool m_visible = false; //!< is this component selected?
|
||||||
const int LogoffIntervalSeconds = 10;
|
const int LogoffIntervalSeconds = 10;
|
||||||
QTimer *m_logoffCountdownTimer { nullptr };
|
QTimer *m_logoffCountdownTimer { nullptr };
|
||||||
BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings };
|
BlackMisc::CSettingReadOnly<BlackCore::Settings::Network::TrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings };
|
||||||
|
BlackMisc::CSetting<BlackGui::Settings::OwnAircraftModel> m_currentAircraftModel { this };
|
||||||
|
BlackMisc::CData<BlackCore::Data::VatsimCurrentServer> m_currentVatsimServer { this };
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>463</width>
|
<width>463</width>
|
||||||
<height>412</height>
|
<height>443</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1" colspan="4">
|
<item row="4" column="1" colspan="4">
|
||||||
<widget class="BlackGui::Components::CServerListSelector" name="cbp_VatsimServer"/>
|
<widget class="BlackGui::Components::CServerListSelector" name="comp_VatsimServer"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="BlackGui::CTickLabel" name="lblp_VatsimId">
|
<widget class="BlackGui::CTickLabel" name="lblp_VatsimId">
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="BlackGui::Components::CServerListSelector" name="cbp_OtherServers"/>
|
<widget class="BlackGui::Components::CServerListSelector" name="comp_OtherServers"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="lbl_OtherServersEdit">
|
<widget class="QLabel" name="lbl_OtherServersEdit">
|
||||||
@@ -584,13 +584,13 @@
|
|||||||
<tabstop>le_VatsimPassword</tabstop>
|
<tabstop>le_VatsimPassword</tabstop>
|
||||||
<tabstop>le_VatsimRealName</tabstop>
|
<tabstop>le_VatsimRealName</tabstop>
|
||||||
<tabstop>le_VatsimHomeAirport</tabstop>
|
<tabstop>le_VatsimHomeAirport</tabstop>
|
||||||
<tabstop>cbp_VatsimServer</tabstop>
|
<tabstop>comp_VatsimServer</tabstop>
|
||||||
<tabstop>le_SimulatorModel</tabstop>
|
<tabstop>le_SimulatorModel</tabstop>
|
||||||
<tabstop>le_Callsign</tabstop>
|
<tabstop>le_Callsign</tabstop>
|
||||||
<tabstop>le_AircraftIcaoDesignator</tabstop>
|
<tabstop>le_AircraftIcaoDesignator</tabstop>
|
||||||
<tabstop>le_AircraftIcaoAirline</tabstop>
|
<tabstop>le_AircraftIcaoAirline</tabstop>
|
||||||
<tabstop>le_AircraftCombinedType</tabstop>
|
<tabstop>le_AircraftCombinedType</tabstop>
|
||||||
<tabstop>cbp_OtherServers</tabstop>
|
<tabstop>comp_OtherServers</tabstop>
|
||||||
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
<tabstop>pb_OtherServersGotoSettings</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@@ -27,15 +27,39 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (this->m_servers == servers) { return; }
|
if (this->m_servers == servers) { return; }
|
||||||
this->setItemStrings(servers);
|
this->setItemStrings(servers);
|
||||||
|
if (!servers.isEmpty() && !m_pendingPreselect.isEmpty())
|
||||||
|
{
|
||||||
|
this->preSelect(m_pendingPreselect);
|
||||||
|
m_pendingPreselect.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::Network::CServer CServerListSelector::currentServer() const
|
CServer CServerListSelector::currentServer() const
|
||||||
{
|
{
|
||||||
int i = currentIndex();
|
const int i = currentIndex();
|
||||||
if (i < 0 || i >= m_servers.size()) { return CServer(); }
|
if (i < 0 || i >= m_servers.size()) { return CServer(); }
|
||||||
return m_servers[i];
|
return m_servers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CServerListSelector::preSelect(const QString &name)
|
||||||
|
{
|
||||||
|
if (name.isEmpty()) { return false; }
|
||||||
|
if (m_servers.isEmpty())
|
||||||
|
{
|
||||||
|
m_pendingPreselect = name; // save for later
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < m_servers.size(); i++)
|
||||||
|
{
|
||||||
|
if (m_servers[i].matchesName(name))
|
||||||
|
{
|
||||||
|
this->setCurrentIndex(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CServerListSelector::setItemStrings(const CServerList &servers)
|
void CServerListSelector::setItemStrings(const CServerList &servers)
|
||||||
{
|
{
|
||||||
QString currentlySelected(this->currentText());
|
QString currentlySelected(this->currentText());
|
||||||
|
|||||||
@@ -41,12 +41,16 @@ namespace BlackGui
|
|||||||
//! Get the current server
|
//! Get the current server
|
||||||
BlackMisc::Network::CServer currentServer() const;
|
BlackMisc::Network::CServer currentServer() const;
|
||||||
|
|
||||||
|
//! Preselect
|
||||||
|
bool preSelect(const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Build the item string descriptions
|
//! Build the item string descriptions
|
||||||
void setItemStrings(const BlackMisc::Network::CServerList &servers);
|
void setItemStrings(const BlackMisc::Network::CServerList &servers);
|
||||||
|
|
||||||
BlackMisc::Network::CServerList m_servers; //!< corresponding servers
|
BlackMisc::Network::CServerList m_servers; //!< corresponding servers
|
||||||
QStringList m_items; //!< items strings
|
QStringList m_items; //!< items strings
|
||||||
|
QString m_pendingPreselect; //!< pending preselect value
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
32
src/blackgui/settings/settingsgui.h
Normal file
32
src/blackgui/settings/settingsgui.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* swift project community / contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_SETTINGS_GUI_H
|
||||||
|
#define BLACKGUI_SETTINGS_GUI_H
|
||||||
|
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
//! Settings for last manual entries of own aircraft mode
|
||||||
|
struct OwnAircraftModel : public BlackMisc::CSettingTrait<BlackMisc::Simulation::CAircraftModel>
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "guinownaircraftmodel"; }
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user