mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
refs #315 Style
This commit is contained in:
@@ -88,7 +88,7 @@ namespace BlackCore
|
||||
|
||||
void IContextApplication::changeSettings(uint typeValue)
|
||||
{
|
||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
auto type = static_cast<IContextSettings::SettingsType>(typeValue);
|
||||
switch (type)
|
||||
{
|
||||
case IContextSettings::SettingsHotKeys:
|
||||
@@ -109,8 +109,7 @@ namespace BlackCore
|
||||
{
|
||||
if (IContextApplication::s_oldHandler) IContextApplication::s_oldHandler(type, messageContext, message);
|
||||
if (IContextApplication::s_contexts.isEmpty()) return;
|
||||
IContextApplication *ctx;
|
||||
foreach(ctx, IContextApplication::s_contexts)
|
||||
foreach(IContextApplication *ctx, IContextApplication::s_contexts)
|
||||
{
|
||||
ctx->messageHandler(type, messageContext, message);
|
||||
}
|
||||
|
||||
@@ -61,14 +61,13 @@ namespace BlackCore
|
||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, { fileName, content.left(25) });
|
||||
if (fileName.isEmpty()) return false;
|
||||
QFile file(fileName);
|
||||
bool success = false;
|
||||
if ((success = file.open(QIODevice::WriteOnly | QIODevice::Text)))
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << content;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
return success;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -80,8 +79,7 @@ namespace BlackCore
|
||||
QFile file(fileName);
|
||||
QString content;
|
||||
if (fileName.isEmpty()) return content;
|
||||
bool success = false;
|
||||
if ((success = file.open(QIODevice::ReadOnly | QIODevice::Text)))
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
QTextStream in(&file);
|
||||
in >> content;
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace BlackCore
|
||||
Q_ASSERT(this->m_voice);
|
||||
this->getRuntime()->logSlot(c_logContext, Q_FUNC_INFO, QString::number(notification));
|
||||
|
||||
BlackSound::CNotificationSounds::Notification notificationSound = static_cast<BlackSound::CNotificationSounds::Notification>(notification);
|
||||
auto notificationSound = static_cast<BlackSound::CNotificationSounds::Notification>(notification);
|
||||
if (considerSettings)
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
@@ -388,16 +388,12 @@ namespace BlackCore
|
||||
break;
|
||||
case IVoiceChannel::ConnectingFailed:
|
||||
case IVoiceChannel::DisconnectedError:
|
||||
{
|
||||
const QString e = QString("Voice room COM1 error");
|
||||
qWarning(e.toUtf8().constData());
|
||||
|
||||
// no break here!
|
||||
}
|
||||
qWarning() << "Voice room COM1 error";
|
||||
// intentional fall-through
|
||||
case IVoiceChannel::Disconnected:
|
||||
// good chance to update aircraft
|
||||
if (this->getIContextOwnAircraft())
|
||||
{
|
||||
// good chance to update aircraft
|
||||
m_channelCom1->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
m_channelCom2->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
}
|
||||
@@ -423,16 +419,12 @@ namespace BlackCore
|
||||
break;
|
||||
case IVoiceChannel::ConnectingFailed:
|
||||
case IVoiceChannel::DisconnectedError:
|
||||
{
|
||||
const QString e = QString("Voice room COM2 error");
|
||||
qWarning(e.toUtf8().constData());
|
||||
|
||||
// no break here!
|
||||
}
|
||||
qWarning() << "Voice room COM2 error";
|
||||
// intentional fall-through
|
||||
case IVoiceChannel::Disconnected:
|
||||
// good chance to update aircraft
|
||||
if (this->getIContextOwnAircraft())
|
||||
{
|
||||
// good chance to update aircraft
|
||||
m_channelCom1->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
m_channelCom2->setMyAircraftCallsign(this->getIContextOwnAircraft()->getOwnAircraft().getCallsign());
|
||||
}
|
||||
|
||||
@@ -76,12 +76,10 @@ namespace BlackCore
|
||||
if (!this->getIContextAudio()) return; // no place to set rooms
|
||||
if (!this->m_automaticVoiceRoomResolution) return; // not responsible
|
||||
|
||||
CVoiceRoomList rooms;
|
||||
|
||||
// requires correct frequencies set
|
||||
// but local network uses exactly this object here, so if frequencies are set here,
|
||||
// they are for network context as well
|
||||
rooms = this->getIContextNetwork()->getSelectedVoiceRooms();
|
||||
CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms();
|
||||
|
||||
if (!this->m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(this->m_voiceRoom1UrlOverride);
|
||||
if (!this->m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(this->m_voiceRoom2UrlOverride);
|
||||
|
||||
@@ -305,7 +305,6 @@ namespace BlackCore
|
||||
this->connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CRuntime::gracefulShutdown);
|
||||
|
||||
// upfront reading of settings, as DBus server already relies on settings
|
||||
CContextSettings *settings = nullptr;
|
||||
QString dbusAddress;
|
||||
QMap<QString, int> times;
|
||||
QTime time;
|
||||
@@ -316,7 +315,7 @@ namespace BlackCore
|
||||
if (config.hasDBusAddress()) dbusAddress = config.getDBusAddress(); // bootstrap / explicit
|
||||
if (config.hasLocalSettings())
|
||||
{
|
||||
settings = new CContextSettings(config.getModeSettings(), this);
|
||||
auto *settings = new CContextSettings(config.getModeSettings(), this);
|
||||
if (settings) settings->read();
|
||||
if (dbusAddress.isEmpty()) dbusAddress = settings->getNetworkSettings().getDBusServerAddress();
|
||||
|
||||
@@ -396,7 +395,7 @@ namespace BlackCore
|
||||
|
||||
void CRuntime::initPostSetup()
|
||||
{
|
||||
bool c;
|
||||
bool c = false;
|
||||
Q_UNUSED(c); // for release version
|
||||
|
||||
if (this->m_contextSettings && this->m_contextApplication)
|
||||
@@ -548,11 +547,9 @@ namespace BlackCore
|
||||
void CRuntime::disconnectLogSignals(const QString &name)
|
||||
{
|
||||
if (!this->m_logSignalConnections.contains(name)) return;
|
||||
QMultiMap<QString, QMetaObject::Connection>::const_iterator i = this->m_logSignalConnections.constFind(name);
|
||||
while (i != this->m_logSignalConnections.end() && i.key() == name)
|
||||
for (auto i = this->m_logSignalConnections.lowerBound(name), end = this->m_logSignalConnections.upperBound(name); i != end; ++i)
|
||||
{
|
||||
disconnect(i.value());
|
||||
++i;
|
||||
}
|
||||
this->m_logSignalConnections.remove(name);
|
||||
}
|
||||
|
||||
@@ -225,10 +225,10 @@ namespace BlackCore
|
||||
const IContextAudio *getIContextAudio() const;
|
||||
|
||||
//! Context for application
|
||||
const IContextApplication *getIContextApplication() const;
|
||||
IContextApplication *getIContextApplication();
|
||||
|
||||
//! Context for application
|
||||
IContextApplication *getIContextApplication();
|
||||
const IContextApplication *getIContextApplication() const;
|
||||
|
||||
//! Context for own aircraft
|
||||
IContextOwnAircraft *getIContextOwnAircraft();
|
||||
@@ -243,10 +243,10 @@ namespace BlackCore
|
||||
const IContextSettings *getIContextSettings() const;
|
||||
|
||||
//! Context for simulator
|
||||
const IContextSimulator *getIContextSimulator() const;
|
||||
IContextSimulator *getIContextSimulator();
|
||||
|
||||
//! Context for simulator
|
||||
IContextSimulator *getIContextSimulator();
|
||||
const IContextSimulator *getIContextSimulator() const;
|
||||
|
||||
// ------- Context as implementing (local) class
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace BlackCore
|
||||
{
|
||||
if (command == CSettingUtilities::CmdUpdate())
|
||||
{
|
||||
BlackMisc::Settings::CSettingKeyboardHotkeyList hotkeys = value.value<BlackMisc::Settings::CSettingKeyboardHotkeyList>();
|
||||
auto hotkeys = value.value<BlackMisc::Settings::CSettingKeyboardHotkeyList>();
|
||||
this->m_hotkeys = hotkeys;
|
||||
msgs.push_back(this->write()); // write settings
|
||||
emit this->changedSettings(static_cast<uint>(SettingsHotKeys));
|
||||
|
||||
@@ -43,9 +43,6 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CContextSettings() {}
|
||||
|
||||
//! settings file
|
||||
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
|
||||
|
||||
//! \copydoc IContextSettings::value()
|
||||
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const BlackMisc::CVariant &value) override;
|
||||
|
||||
@@ -78,6 +75,9 @@ namespace BlackCore
|
||||
virtual QString getSettingsAsJsonString() const override;
|
||||
|
||||
private:
|
||||
//! settings directory
|
||||
const QString &getSettingsDirectory() const { return BlackMisc::Settings::CSettingUtilities::getSettingsDirectory(); }
|
||||
|
||||
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
|
||||
BlackMisc::Settings::CSettingsAudio m_settingsAudio;
|
||||
BlackSim::Settings::CSettingsSimulator m_settingsSimulator;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace BlackCore
|
||||
|
||||
signals:
|
||||
//! Emitted when the simulator connection changes
|
||||
void connectionChanged(bool value);
|
||||
void connectionChanged(bool connected);
|
||||
|
||||
//! Emitted when own aircraft model changes (TODO move to own aircraft context?)
|
||||
void ownAircraftModelChanged(BlackMisc::Network::CAircraftModel model);
|
||||
|
||||
@@ -140,8 +140,7 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
ISimulatorFactory *factory = nullptr;
|
||||
QSet<ISimulatorFactory *>::iterator iterator = std::find_if(m_simulatorFactories.begin(), m_simulatorFactories.end(), [ = ](const ISimulatorFactory * factory)
|
||||
auto iterator = std::find_if(m_simulatorFactories.begin(), m_simulatorFactories.end(), [ = ](const ISimulatorFactory * factory)
|
||||
{
|
||||
return factory->getSimulatorInfo() == simulatorInfo;
|
||||
});
|
||||
@@ -155,7 +154,7 @@ namespace BlackCore
|
||||
return false;
|
||||
}
|
||||
|
||||
factory = *iterator;
|
||||
ISimulatorFactory *factory = *iterator;
|
||||
Q_ASSERT(factory);
|
||||
|
||||
ISimulator *newSimulator = factory->create(this);
|
||||
@@ -164,7 +163,7 @@ namespace BlackCore
|
||||
this->unloadSimulatorPlugin(); // old plugin unloaded
|
||||
m_simulator = newSimulator;
|
||||
|
||||
connect(m_simulator, SIGNAL(statusChanged(ISimulator::Status)), this, SLOT(ps_setConnectionStatus(ISimulator::Status)));
|
||||
connect(m_simulator, &ISimulator::statusChanged, this, &CContextSimulator::ps_setConnectionStatus);
|
||||
connect(m_simulator, &ISimulator::aircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
|
||||
if (this->getIContextApplication() && this->getIContextApplication()->usingLocalObjects())
|
||||
{
|
||||
@@ -194,6 +193,8 @@ namespace BlackCore
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
if (!this->getIContextSettings()) return false;
|
||||
|
||||
// TODO warnings if we didn't load the plugin which the settings asked for
|
||||
|
||||
CSimulatorInfoList plugins = this->getAvailableSimulatorPlugins();
|
||||
if (plugins.size() == 1)
|
||||
{
|
||||
@@ -220,7 +221,7 @@ namespace BlackCore
|
||||
{
|
||||
if (m_simulator)
|
||||
{
|
||||
disconnect(m_simulator); // disconnect as receiver straight away
|
||||
this->QObject::disconnect(m_simulator); // disconnect as receiver straight away
|
||||
m_simulator->disconnectFrom(); // disconnect from simulator
|
||||
m_simulator->deleteLater();
|
||||
}
|
||||
@@ -308,7 +309,7 @@ namespace BlackCore
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
Q_ASSERT(this->m_simulator);
|
||||
if (!this->getIContextSettings()) return;
|
||||
IContextSettings::SettingsType settingsType = static_cast<IContextSettings::SettingsType>(type);
|
||||
auto settingsType = static_cast<IContextSettings::SettingsType>(type);
|
||||
if (settingsType != IContextSettings::SettingsSimulator) return;
|
||||
|
||||
// plugin
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace BlackCore
|
||||
virtual bool loadSimulatorPlugin(const BlackSim::CSimulatorInfo &simulatorInfo) override;
|
||||
|
||||
//! \copydoc IContextSimulator::loadSimulatorPluginFromSettings()
|
||||
virtual bool loadSimulatorPluginFromSettings();
|
||||
virtual bool loadSimulatorPluginFromSettings() override;
|
||||
|
||||
//! \copydoc IContextSimulator::unloadSimulatorPlugin()
|
||||
virtual void unloadSimulatorPlugin() override;
|
||||
|
||||
Reference in New Issue
Block a user