mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T705, remember matching script directories
This commit is contained in:
committed by
Mat Sutcliffe
parent
d5a4e3d70d
commit
1f148cf7f8
@@ -170,7 +170,9 @@ namespace BlackGui
|
||||
{
|
||||
const bool nw = (QObject::sender() == ui->pb_MsReverseLookup);
|
||||
QString fn = nw ? ui->le_MsReverseLookup->text() : ui->le_MsMatching->text();
|
||||
fn = QFileDialog::getOpenFileName(nullptr, tr("Matching script"), fn, "Matching script (*.js)");
|
||||
CDirectories swiftDirs = m_directories.get();
|
||||
|
||||
fn = QFileDialog::getOpenFileName(nullptr, tr("Matching script"), fn.isEmpty() ? swiftDirs.getMatchingScriptDirectoryOrDefault() : fn, "Matching script (*.js)");
|
||||
const QFileInfo fi(fn);
|
||||
if (!fi.exists()) { return; }
|
||||
if (nw)
|
||||
@@ -181,6 +183,9 @@ namespace BlackGui
|
||||
{
|
||||
ui->le_MsMatching->setText(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
swiftDirs.setMatchingScriptDirectory(fi.absolutePath());
|
||||
m_directories.setAndSave(swiftDirs);
|
||||
}
|
||||
|
||||
CAircraftMatcherSetup::MatchingAlgorithm CMatchingForm::algorithm() const
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "form.h"
|
||||
#include "blackmisc/simulation/aircraftmatchersetup.h"
|
||||
#include "blackmisc/directories.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CMatchingForm; }
|
||||
@@ -77,6 +79,7 @@ namespace BlackGui
|
||||
//! Directory browser
|
||||
void fileDialog();
|
||||
|
||||
BlackMisc::CSetting<BlackMisc::Settings::TDirectorySettings> m_directories { this }; //!< the swift directories
|
||||
QScopedPointer<Ui::CMatchingForm> ui;
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_MsMatching">
|
||||
<property name="text">
|
||||
<string>Matching:</string>
|
||||
<string>Matching</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -150,7 +150,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_MsReverseLookup">
|
||||
<property name="text">
|
||||
<string>Lookup:</string>
|
||||
<string>Lookup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -47,6 +47,15 @@ namespace BlackMisc
|
||||
this->setLastModelDirectory(dir);
|
||||
}
|
||||
|
||||
QString CDirectories::getMatchingScriptDirectoryOrDefault() const
|
||||
{
|
||||
if (m_dirMatchingScript.isEmpty())
|
||||
{
|
||||
return CDirectoryUtils::shareMatchingScriptDirectory();
|
||||
}
|
||||
return m_dirMatchingScript;
|
||||
}
|
||||
|
||||
QString CDirectories::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -59,13 +68,14 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDirFlightPlan: return CVariant::fromValue(m_dirFlightPlan);
|
||||
case IndexDirFlightPlanOrDefault: return CVariant::fromValue(this->getFlightPlanDirectoryOrDefault());
|
||||
case IndexDirLastViewJson: return CVariant::fromValue(m_dirLastViewJson);
|
||||
case IndexDirLastViewJsonOrDefault: return CVariant::fromValue(this->getLastViewJsonDirectoryOrDefault());
|
||||
case IndexDirLastModelJson: return CVariant::fromValue(m_dirLastModelStashJson);
|
||||
case IndexDirFlightPlan: return CVariant::fromValue(m_dirFlightPlan);
|
||||
case IndexDirFlightPlanOrDefault: return CVariant::fromValue(this->getFlightPlanDirectoryOrDefault());
|
||||
case IndexDirLastViewJson: return CVariant::fromValue(m_dirLastViewJson);
|
||||
case IndexDirLastViewJsonOrDefault: return CVariant::fromValue(this->getLastViewJsonDirectoryOrDefault());
|
||||
case IndexDirLastModelJson: return CVariant::fromValue(m_dirLastModelStashJson);
|
||||
case IndexDirLastModelJsonOrDefault: return CVariant::fromValue(this->getLastModelDirectoryOrDefault());
|
||||
case IndexDirLastModelStashJson: return CVariant::fromValue(m_dirLastModelStashJson);
|
||||
case IndexDirLastModelStashJson: return CVariant::fromValue(m_dirLastModelStashJson);
|
||||
case IndexDirMatchingScript: return CVariant::fromValue(this->getMatchingScriptDirectoryOrDefault());
|
||||
case IndexDirLastModelStashJsonOrDefault: return CVariant::fromValue(this->getLastModelStashDirectoryOrDefault());
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
@@ -84,6 +94,7 @@ namespace BlackMisc
|
||||
case IndexDirLastModelJson: this->setLastModelDirectory(variant.toQString()); break;
|
||||
case IndexDirLastModelStashJsonOrDefault:
|
||||
case IndexDirLastModelStashJson: this->setLastModelStashDirectory(variant.toQString()); break;
|
||||
case IndexDirMatchingScript: this->setMatchingScriptDirectory(variant.toQString()); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace BlackMisc
|
||||
IndexDirLastModelJson,
|
||||
IndexDirLastModelJsonOrDefault,
|
||||
IndexDirLastModelStashJson,
|
||||
IndexDirLastModelStashJsonOrDefault
|
||||
IndexDirLastModelStashJsonOrDefault,
|
||||
IndexDirMatchingScript
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
@@ -85,6 +86,12 @@ namespace BlackMisc
|
||||
//! Last view JSON model stash directory
|
||||
void setLastModelStashDirectory(const QString &dir);
|
||||
|
||||
//! Matching script directory
|
||||
QString getMatchingScriptDirectoryOrDefault() const;
|
||||
|
||||
//! Matching script directory
|
||||
void setMatchingScriptDirectory(const QString &dir) { m_dirMatchingScript = dir; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -102,6 +109,7 @@ namespace BlackMisc
|
||||
QString m_dirLastViewJson; //!< last JSON save directory
|
||||
QString m_dirLastModelJson; //!< last JSON model directory
|
||||
QString m_dirLastModelStashJson; //!< last JSON model stash save directory
|
||||
QString m_dirMatchingScript; //!< matching script dir
|
||||
|
||||
//! Return checkDir if existing, defaultDir otherwise
|
||||
QString existingOrDefaultDir(const QString &checkDir, const QString &defaultDir) const;
|
||||
@@ -111,7 +119,8 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(dirFlightPlan),
|
||||
BLACK_METAMEMBER(dirLastViewJson),
|
||||
BLACK_METAMEMBER(dirLastModelJson),
|
||||
BLACK_METAMEMBER(dirLastModelStashJson)
|
||||
BLACK_METAMEMBER(dirLastModelStashJson),
|
||||
BLACK_METAMEMBER(dirMatchingScript)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -241,6 +241,12 @@ namespace BlackMisc
|
||||
return tpd;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::shareMatchingScriptDirectory()
|
||||
{
|
||||
static const QString ms(CFileUtils::appendFilePaths(CDirectoryUtils::shareDirectory(), "matchingscript"));
|
||||
return ms;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::bootstrapFileName()
|
||||
{
|
||||
static const QString n("bootstrap.json");
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace BlackMisc
|
||||
//! FSX/P3D terrain probe
|
||||
static const QString &shareTerrainProbeDirectory();
|
||||
|
||||
//! Matching script examples directories
|
||||
static const QString &shareMatchingScriptDirectory();
|
||||
|
||||
//! Bootstrap file name
|
||||
static const QString &bootstrapFileName();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user