Ref T180, dot commands to set rendering setup

* enable parts/debug messages via dot command
* allow to log to console via application context
This commit is contained in:
Klaus Basan
2017-11-05 20:15:01 +01:00
parent 1bf2f63589
commit 482023b2c0
7 changed files with 64 additions and 5 deletions

View File

@@ -168,6 +168,7 @@ namespace BlackCore
// startup done // startup done
connect(this, &CApplication::startUpCompleted, this, &CApplication::onStartUpCompleted, Qt::QueuedConnection); connect(this, &CApplication::startUpCompleted, this, &CApplication::onStartUpCompleted, Qt::QueuedConnection);
connect(this, &CApplication::coreFacadeStarted, this, &CApplication::onCoreFacadeStarted, Qt::QueuedConnection);
// notify when app goes down // notify when app goes down
connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown); connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CApplication::gracefulShutdown);
@@ -1316,6 +1317,11 @@ namespace BlackCore
return m_coreFacade->getIContextSimulator(); return m_coreFacade->getIContextSimulator();
} }
void CApplication::onCoreFacadeStarted()
{
// void
}
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
// Setup // Setup
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------

View File

@@ -506,6 +506,9 @@ namespace BlackCore
//! Can be used to parse specialized arguments //! Can be used to parse specialized arguments
virtual bool parsingHookIn() { return true; } virtual bool parsingHookIn() { return true; }
//! Called when facade/contexts have been started
virtual void onCoreFacadeStarted();
//! Can be used to start special services //! Can be used to start special services
virtual BlackMisc::CStatusMessageList startHookIn() { return BlackMisc::CStatusMessageList(); } virtual BlackMisc::CStatusMessageList startHookIn() { return BlackMisc::CStatusMessageList(); }

View File

@@ -62,6 +62,9 @@ namespace BlackCore
Q_ASSERT(s); Q_ASSERT(s);
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"hotkeyActionsRegistered", this, SIGNAL(hotkeyActionsRegistered(QStringList, BlackMisc::CIdentifier))); "hotkeyActionsRegistered", this, SIGNAL(hotkeyActionsRegistered(QStringList, BlackMisc::CIdentifier)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
"requestDisplayOnConsole", this, SIGNAL(requestDisplayOnConsole(QString)));
Q_UNUSED(s); Q_UNUSED(s);
this->relayBaseClassSignals(serviceName, connection, IContextApplication::ObjectPath(), IContextApplication::InterfaceName()); this->relayBaseClassSignals(serviceName, connection, IContextApplication::ObjectPath(), IContextApplication::InterfaceName());
} }

View File

@@ -61,6 +61,7 @@ namespace BlackCore
m_plugins->collectPlugins(); m_plugins->collectPlugins();
restoreSimulatorPlugins(); restoreSimulatorPlugins();
CContextSimulator::registerHelp();
connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CContextSimulator::ps_modelSetChanged); connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CContextSimulator::ps_modelSetChanged);
connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::ps_modelSetChanged); connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::ps_modelSetChanged);
@@ -626,12 +627,32 @@ namespace BlackCore
if (commandLine.isEmpty()) { return false; } if (commandLine.isEmpty()) { return false; }
CSimpleCommandParser parser( CSimpleCommandParser parser(
{ {
".plugin", ".plugin", ".drv", ".driver", // forwarded to driver
".drv", ".driver" // forwarded to driver ".ris" // rendering interpolator setup
}); });
parser.parse(commandLine); parser.parse(commandLine);
if (!parser.isKnownCommand()) { return false; } if (!parser.isKnownCommand()) { return false; }
if (parser.matchesCommand("ris"))
{
CInterpolationAndRenderingSetup rs = this->getInterpolationAndRenderingSetup();
const QString p1 = parser.part(1);
if (p1 == "show")
{
if (this->getIContextApplication())
{
emit this->getIContextApplication()->requestDisplayOnConsole(rs.toQString(true));
}
return true;
}
if (!parser.hasPart(2)) { return false; }
const bool on = stringToBool(parser.part(2));
if (p1 == "debug") { rs.setDriverDebuggingMessages(on); }
else if (p1 == "parts") { rs.setEnabledAircraftParts(on); }
else { return false; }
this->setInterpolationAndRenderingSetup(rs);
CLogMessage(this, CLogCategory::cmdLine()).info("Setup is: '%1'") << rs.toQString(true);
return true;
}
if (parser.matchesCommand("plugin") || parser.matchesCommand("drv") || parser.matchesCommand("driver")) if (parser.matchesCommand("plugin") || parser.matchesCommand("drv") || parser.matchesCommand("driver"))
{ {
if (!m_simulatorPlugin.second) { return false; } if (!m_simulatorPlugin.second) { return false; }

View File

@@ -107,12 +107,26 @@ namespace BlackCore
//! \addtogroup swiftdotcommands //! \addtogroup swiftdotcommands
//! @{ //! @{
//! <pre> //! <pre>
//! .plugin forwarded to plugin, see details there //! .plugin forwarded to plugin, see details there
//! .driver .drv forwarded to plugin (same as above) //! .driver .drv forwarded to plugin (same as above)
//! .ris show show interpolation setup in console
//! .ris debug on|off interpolation/rendering setup, debug messages
//! .ris parts on|off interpolation/rendering setup, aircraft parts
//! </pre> //! </pre>
//! @} //! @}
//! \copydoc IContextSimulator::parseCommandLine //! \copydoc IContextSimulator::parseCommandLine
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
//! Register dot commands
static void registerHelp()
{
if (BlackMisc::CSimpleCommandParser::registered("BlackCore::CContextSimulator")) { return; }
BlackMisc::CSimpleCommandParser::registerCommand({".ris", "rendering/interpolation setup"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris show", "display rendering/interpolation setup on console"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris debug on|off", "rendering/interpolation debug messages"});
BlackMisc::CSimpleCommandParser::registerCommand({".ris parts on|off", "aircraft parts"});
}
// ----------------------------- context interface ----------------------------- // ----------------------------- context interface -----------------------------
protected: protected:

View File

@@ -62,6 +62,7 @@ using namespace BlackMisc::Network;
using namespace BlackGui::Components; using namespace BlackGui::Components;
using namespace BlackCore; using namespace BlackCore;
using namespace BlackCore::Data; using namespace BlackCore::Data;
using namespace BlackCore::Context;
BlackGui::CGuiApplication *sGui = nullptr; // set by constructor BlackGui::CGuiApplication *sGui = nullptr; // set by constructor
@@ -732,6 +733,14 @@ namespace BlackGui
return true; return true;
} }
void CGuiApplication::onCoreFacadeStarted()
{
if (this->supportsContexts())
{
connect(this->getIContextApplication(), &IContextApplication::requestDisplayOnConsole, this, &CGuiApplication::displayTextInConsole);
}
}
void CGuiApplication::checkNewVersion(bool onlyIfNew) void CGuiApplication::checkNewVersion(bool onlyIfNew)
{ {
if (!m_installDialog) if (!m_installDialog)

View File

@@ -224,6 +224,9 @@ namespace BlackGui
//! Handle parsing of special GUI cmd arguments //! Handle parsing of special GUI cmd arguments
virtual bool parsingHookIn() override; virtual bool parsingHookIn() override;
//! \copydoc BlackCore::CApplication::onCoreFacadeStarted
virtual void onCoreFacadeStarted() override;
//! Check for a new version (update) //! Check for a new version (update)
void checkNewVersion(bool onlyIfNew); void checkNewVersion(bool onlyIfNew);