mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Issue #69 Menu item to launch CSL2XSB in own models component
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "blackcore/db/databaseutils.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/processctrl.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "ui_dbownmodelscomponent.h"
|
||||
@@ -292,6 +293,16 @@ namespace BlackGui
|
||||
this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundNoCache);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::runScriptCSL2XSB()
|
||||
{
|
||||
static const QString script = QDir(CDirectoryUtils::shareDirectory()).filePath("CSL2XSB/CSL2XSB.exe");
|
||||
for (const QString &modelDir : m_simulatorSettings.getModelDirectoriesOrDefault(CSimulatorInfo::xplane()))
|
||||
{
|
||||
CLogMessage(this).info(u"Running CSL2XSB on model directory %1") << modelDir;
|
||||
CProcessCtrl::startDetached(script, { QDir::cleanPath(modelDir) }, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
@@ -602,6 +613,21 @@ namespace BlackGui
|
||||
}
|
||||
menuActions.addAction(m_clearCacheActions[4], CMenuAction::pathSimulatorModelsClearCache());
|
||||
}
|
||||
|
||||
if (sims.isXPlane() && CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::buildWordSize() == 64)
|
||||
{
|
||||
if (!m_csl2xsbAction)
|
||||
{
|
||||
m_csl2xsbAction = new QAction(CIcons::appTerminal16(), "XPlane: run CSL2XSB on all models", this);
|
||||
connect(m_csl2xsbAction, &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked)
|
||||
{
|
||||
if (!ownModelsComp) { return; }
|
||||
Q_UNUSED(checked)
|
||||
ownModelsComp->runScriptCSL2XSB();
|
||||
});
|
||||
}
|
||||
menuActions.addAction(m_csl2xsbAction, CMenuAction::pathSimulator());
|
||||
}
|
||||
}
|
||||
this->nestedCustomMenu(menuActions);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,9 @@ namespace BlackGui
|
||||
//! Confirmed forced reload
|
||||
void confirmedForcedReload(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Run CSL2XSB script
|
||||
void runScriptCSL2XSB();
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
//! \fixme MS 2018-12 Move to namespace scope and add Q_OBJECT
|
||||
@@ -210,6 +213,7 @@ namespace BlackGui
|
||||
QList<QAction *> m_loadActions; //!< load actions
|
||||
QList<QAction *> m_reloadActions; //!< reload actions
|
||||
QList<QAction *> m_clearCacheActions; //!< clear own models cahce if ever needed
|
||||
QAction *m_csl2xsbAction = nullptr; //!< run csl2xsb script
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -33,10 +33,11 @@ namespace BlackMisc
|
||||
memset (&startupInfo, 0, sizeof (startupInfo));
|
||||
startupInfo.cb = sizeof (startupInfo);
|
||||
|
||||
QString command;
|
||||
command += program;
|
||||
command += ' ';
|
||||
command += arguments.join(' ').replace('/', '\\');
|
||||
QString command = '"' % QString(program).replace('/', '\\') % '"';
|
||||
if (!arguments.isEmpty())
|
||||
{
|
||||
command += " \"" % arguments.join('" "').replace('/', '\\') % '"';
|
||||
}
|
||||
|
||||
DWORD flags = 0;
|
||||
flags |= NORMAL_PRIORITY_CLASS;
|
||||
|
||||
Reference in New Issue
Block a user