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