Remove obsolete launcher files
Clean-up now widget-based settings are gone
This commit is contained in:
parent
19ae26164a
commit
024ffa5e9d
19 changed files with 6 additions and 2123 deletions
|
@ -1,52 +0,0 @@
|
||||||
#include "AdvancedSettingsButton.h"
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QFontMetrics>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
const int MARGIN = 3;
|
|
||||||
|
|
||||||
AdvancedSettingsButton::AdvancedSettingsButton()
|
|
||||||
{
|
|
||||||
setCheckable(true);
|
|
||||||
setChecked(false);
|
|
||||||
setIcon(QIcon());
|
|
||||||
|
|
||||||
connect(this, &QAbstractButton::toggled, this, &AdvancedSettingsButton::updateUi);
|
|
||||||
|
|
||||||
updateUi();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvancedSettingsButton::paintEvent(QPaintEvent *event)
|
|
||||||
{
|
|
||||||
QPixmap icon(":/settings-gear-white");
|
|
||||||
|
|
||||||
QPainter painter(this);
|
|
||||||
|
|
||||||
painter.setPen(Qt::white);
|
|
||||||
const int h = height();
|
|
||||||
QRect textRect = rect();
|
|
||||||
textRect.setRight(textRect.right() - (h + MARGIN));
|
|
||||||
painter.drawText(textRect, text(), Qt::AlignVCenter | Qt::AlignRight);
|
|
||||||
|
|
||||||
QRect iconRect = rect();
|
|
||||||
iconRect.setLeft(iconRect.right() - h);
|
|
||||||
iconRect.adjust(MARGIN, MARGIN, -MARGIN, -MARGIN);
|
|
||||||
painter.drawPixmap(iconRect, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize AdvancedSettingsButton::sizeHint() const
|
|
||||||
{
|
|
||||||
const QFontMetrics f(font());
|
|
||||||
const QRect bounds = f.boundingRect(text());
|
|
||||||
const int height = bounds.height() + (MARGIN * 2);
|
|
||||||
return QSize(bounds.width() + 100 + height, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AdvancedSettingsButton::updateUi()
|
|
||||||
{
|
|
||||||
const bool showAdvanced = isChecked();
|
|
||||||
setText(showAdvanced ? tr("Show less") : tr("Show more"));
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
#ifndef ADVANCEDSETTINGSBUTTON_H
|
|
||||||
#define ADVANCEDSETTINGSBUTTON_H
|
|
||||||
|
|
||||||
#include <QAbstractButton>
|
|
||||||
|
|
||||||
class AdvancedSettingsButton : public QAbstractButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AdvancedSettingsButton();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void paintEvent(QPaintEvent* event) override;
|
|
||||||
|
|
||||||
virtual QSize sizeHint() const override;
|
|
||||||
private:
|
|
||||||
void updateUi();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ADVANCEDSETTINGSBUTTON_H
|
|
|
@ -96,8 +96,6 @@ if (HAVE_QT)
|
||||||
AirportDiagram.hxx
|
AirportDiagram.hxx
|
||||||
NavaidDiagram.cxx
|
NavaidDiagram.cxx
|
||||||
NavaidDiagram.hxx
|
NavaidDiagram.hxx
|
||||||
ExtraSettingsSection.cxx
|
|
||||||
ExtraSettingsSection.hxx
|
|
||||||
SetupRootDialog.cxx
|
SetupRootDialog.cxx
|
||||||
SetupRootDialog.hxx
|
SetupRootDialog.hxx
|
||||||
AircraftModel.hxx
|
AircraftModel.hxx
|
||||||
|
@ -116,12 +114,6 @@ if (HAVE_QT)
|
||||||
QtFileDialog.hxx
|
QtFileDialog.hxx
|
||||||
InstallSceneryDialog.hxx
|
InstallSceneryDialog.hxx
|
||||||
InstallSceneryDialog.cxx
|
InstallSceneryDialog.cxx
|
||||||
SettingsSection.cxx
|
|
||||||
SettingsSection.hxx
|
|
||||||
SettingsSectionQML.cxx
|
|
||||||
SettingsSectionQML.hxx
|
|
||||||
AdvancedSettingsButton.h
|
|
||||||
AdvancedSettingsButton.cpp
|
|
||||||
ToolboxButton.cpp
|
ToolboxButton.cpp
|
||||||
ToolboxButton.h
|
ToolboxButton.h
|
||||||
LauncherArgumentTokenizer.cxx
|
LauncherArgumentTokenizer.cxx
|
||||||
|
@ -130,8 +122,6 @@ if (HAVE_QT)
|
||||||
AircraftSearchFilterModel.hxx
|
AircraftSearchFilterModel.hxx
|
||||||
DefaultAircraftLocator.cxx
|
DefaultAircraftLocator.cxx
|
||||||
DefaultAircraftLocator.hxx
|
DefaultAircraftLocator.hxx
|
||||||
SettingsWidgets.cxx
|
|
||||||
SettingsWidgets.hxx
|
|
||||||
LaunchConfig.cxx
|
LaunchConfig.cxx
|
||||||
LaunchConfig.hxx
|
LaunchConfig.hxx
|
||||||
ViewCommandLinePage.cxx
|
ViewCommandLinePage.cxx
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: downloadSettings
|
|
||||||
title: "Downloads"
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: terrasync
|
|
||||||
label: "Download scenery automatically"
|
|
||||||
description: "FlightGear can automatically download scenery as needed, and check for updates to "
|
|
||||||
+ "the scenery. If you disable this option, you will need to download & install scenery "
|
|
||||||
+ "using an alternative method."
|
|
||||||
keywords: ["terrasync", "download", "scenery"]
|
|
||||||
option: "terrasync"
|
|
||||||
}
|
|
||||||
|
|
||||||
// file path chooser for downloads directory
|
|
||||||
|
|
||||||
PathChooser {
|
|
||||||
id: downloadDir
|
|
||||||
label: "Download location"
|
|
||||||
description: "FlightGear stores downloaded files (scenery and aircraft) in this location. "
|
|
||||||
+ "Depending on your settings, it may grow to a considerable size (many gigabytes). "
|
|
||||||
+ "If you change the download location, files will need to be downloaded again."
|
|
||||||
advanced: true
|
|
||||||
chooseDirectory: true
|
|
||||||
defaultPath: _config.defaultDownloadDir
|
|
||||||
dialogPrompt: "Choose a location to store download files."
|
|
||||||
|
|
||||||
// we disable this UI if the user passes --download-dir when starting the
|
|
||||||
// launcher, otherwise we coudld end up in a complete mess
|
|
||||||
enabled: _config.enableDownloadDirUI
|
|
||||||
|
|
||||||
keywords: ["download", "storage", "disk"]
|
|
||||||
|
|
||||||
onPathChanged: {
|
|
||||||
// lots of special work needs to be done immediately that this
|
|
||||||
// value is changed.
|
|
||||||
_launcher.downloadDirChanged(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
// note we do /not/ apply the downloadDir setting here, since it's
|
|
||||||
// only permitted to occurr once, and we set it via other means;
|
|
||||||
// on startup via runLauncherDialog, and if it changes, via
|
|
||||||
// LauncherMainWindow::downloadDirChanged
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: terrasync.checked ? "scenery downloads;" : ""
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
#include "ExtraSettingsSection.hxx"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QTextEdit>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include "LauncherArgumentTokenizer.hxx"
|
|
||||||
#include "LaunchConfig.hxx"
|
|
||||||
#include "AdvancedSettingsButton.h"
|
|
||||||
|
|
||||||
ExtraSettingsSection::ExtraSettingsSection(QWidget* pr) :
|
|
||||||
SettingsSection(pr)
|
|
||||||
{
|
|
||||||
setTitle(tr("Additional Settings"));
|
|
||||||
|
|
||||||
QVBoxLayout* topLevelVBox = qobject_cast<QVBoxLayout*>(layout());
|
|
||||||
QLabel* prompt = new QLabel(this);
|
|
||||||
prompt->setText(tr("Enter additional command-line arguments if any are required. "
|
|
||||||
"See <a href=\"http://flightgear.sourceforge.net/getstart-en/getstart-enpa2.html#x5-450004.5\">here</a> "
|
|
||||||
"for documentation on possible arguments."));
|
|
||||||
prompt->setWordWrap(true);
|
|
||||||
prompt->setOpenExternalLinks(true);
|
|
||||||
|
|
||||||
topLevelVBox->addWidget(prompt);
|
|
||||||
m_argsEdit = new QTextEdit(this);
|
|
||||||
m_argsEdit->setAcceptRichText(false);
|
|
||||||
m_argsEdit->setPlaceholderText("--option=value --prop:/sim/name=value");
|
|
||||||
|
|
||||||
topLevelVBox->addWidget(m_argsEdit);
|
|
||||||
|
|
||||||
insertSettingsHeader();
|
|
||||||
setShowAdvanced(false);
|
|
||||||
m_advancedModeToggle->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ExtraSettingsSection::argsText() const
|
|
||||||
{
|
|
||||||
return m_argsEdit->toPlainText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraSettingsSection::setLaunchConfig(LaunchConfig* config)
|
|
||||||
{
|
|
||||||
m_config = config;
|
|
||||||
SettingsSection::setLaunchConfig(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraSettingsSection::doApply()
|
|
||||||
{
|
|
||||||
LauncherArgumentTokenizer tk;
|
|
||||||
|
|
||||||
Q_FOREACH(auto arg, tk.tokenize(m_argsEdit->toPlainText())) {
|
|
||||||
if (arg.arg.startsWith("prop:")) {
|
|
||||||
m_config->setProperty(arg.arg.mid(5), arg.value);
|
|
||||||
} else {
|
|
||||||
m_config->setArg(arg.arg, arg.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraSettingsSection::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue("extra-args", m_argsEdit->toPlainText());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraSettingsSection::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
m_argsEdit->setText(settings.value("extra-args").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ExtraSettingsSection::summary() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraSettingsSection::validateText()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#ifndef EXTRASETTINGSSECTION_HXX
|
|
||||||
#define EXTRASETTINGSSECTION_HXX
|
|
||||||
|
|
||||||
#include "SettingsSection.hxx"
|
|
||||||
|
|
||||||
class QTextEdit;
|
|
||||||
class LaunchConfig;
|
|
||||||
|
|
||||||
class ExtraSettingsSection : public SettingsSection
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ExtraSettingsSection(QWidget* pr = nullptr);
|
|
||||||
|
|
||||||
QString argsText() const;
|
|
||||||
|
|
||||||
void setLaunchConfig(LaunchConfig* config) override;
|
|
||||||
|
|
||||||
virtual void doApply() override;
|
|
||||||
|
|
||||||
void saveState(QSettings &settings) const override;
|
|
||||||
|
|
||||||
void restoreState(QSettings &settings) override;
|
|
||||||
|
|
||||||
QString summary() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
private:
|
|
||||||
void validateText();
|
|
||||||
|
|
||||||
QTextEdit* m_argsEdit;
|
|
||||||
LaunchConfig* m_config;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // EXTRASETTINGSSECTION_HXX
|
|
|
@ -1,45 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: generalSettings
|
|
||||||
title: "General"
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: startPaused
|
|
||||||
label: qsTr("Start paused")
|
|
||||||
description: qsTr("Automatically pause the simulator when launching. This is useful "
|
|
||||||
+ "when starting in the air.")
|
|
||||||
keywords: ["pause", "freeze"]
|
|
||||||
}
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: autoCoordination
|
|
||||||
label: qsTr("Enable auto-coordination")
|
|
||||||
description: qsTr("When flying with the mouse, or a joystick lacking a rudder axis, "
|
|
||||||
+ "it's difficult to manually coordinate aileron and rudder movements during "
|
|
||||||
+ "turn. This option automatically commands the rudder to maintain zero "
|
|
||||||
+ "slip angle when banking");
|
|
||||||
advanced: true
|
|
||||||
keywords: ["input", "mouse", "control", "rudder"]
|
|
||||||
option: "auto-coordination"
|
|
||||||
}
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: showConsoleWin
|
|
||||||
label: qsTr("Show debugging console")
|
|
||||||
description: qsTr("Open a console window showing debug output from the application.")
|
|
||||||
advanced: true
|
|
||||||
visible: _osName == "win"
|
|
||||||
keywords: ["console"]
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (startPaused.checked) {
|
|
||||||
_config.setArg("enable-freeze")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showConsoleWin.checked) {
|
|
||||||
_config.setArg("console")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,10 +38,7 @@
|
||||||
#include "PathsDialog.hxx"
|
#include "PathsDialog.hxx"
|
||||||
#include "AircraftSearchFilterModel.hxx"
|
#include "AircraftSearchFilterModel.hxx"
|
||||||
#include "DefaultAircraftLocator.hxx"
|
#include "DefaultAircraftLocator.hxx"
|
||||||
#include "SettingsWidgets.hxx"
|
|
||||||
#include "LaunchConfig.hxx"
|
#include "LaunchConfig.hxx"
|
||||||
#include "SettingsSectionQML.hxx"
|
|
||||||
#include "ExtraSettingsSection.hxx"
|
|
||||||
#include "ViewCommandLinePage.hxx"
|
#include "ViewCommandLinePage.hxx"
|
||||||
#include "MPServersModel.h"
|
#include "MPServersModel.h"
|
||||||
#include "ThumbnailImageItem.hxx"
|
#include "ThumbnailImageItem.hxx"
|
||||||
|
@ -61,19 +58,6 @@ using namespace simgear::pkg;
|
||||||
|
|
||||||
extern void restartTheApp(QStringList fgArgs);
|
extern void restartTheApp(QStringList fgArgs);
|
||||||
|
|
||||||
QQmlPrivate::AutoParentResult launcher_autoParent(QObject* thing, QObject* parent)
|
|
||||||
{
|
|
||||||
SettingsSection* ss = qobject_cast<SettingsSection*>(parent);
|
|
||||||
SettingsControl* sc = qobject_cast<SettingsControl*>(thing);
|
|
||||||
if (ss && sc) {
|
|
||||||
sc->setParent(ss);
|
|
||||||
return QQmlPrivate::Parented;
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Unsuitable" << thing << parent;
|
|
||||||
return QQmlPrivate::IncompatibleObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LauncherMainWindow::LauncherMainWindow() :
|
LauncherMainWindow::LauncherMainWindow() :
|
||||||
|
@ -223,32 +207,23 @@ LauncherMainWindow::LauncherMainWindow() :
|
||||||
|
|
||||||
void LauncherMainWindow::initQML()
|
void LauncherMainWindow::initQML()
|
||||||
{
|
{
|
||||||
QQmlPrivate::RegisterAutoParent autoparent = { 0, &launcher_autoParent };
|
|
||||||
QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent);
|
|
||||||
|
|
||||||
qmlRegisterType<LauncherArgumentTokenizer>("FlightGear.Launcher", 1, 0, "ArgumentTokenizer");
|
qmlRegisterType<LauncherArgumentTokenizer>("FlightGear.Launcher", 1, 0, "ArgumentTokenizer");
|
||||||
|
|
||||||
qmlRegisterType<SettingsSectionQML>("FlightGear.Launcher", 1, 0, "Section");
|
|
||||||
qmlRegisterType<SettingsCheckbox>("FlightGear.Launcher", 1, 0, "Checkbox");
|
|
||||||
qmlRegisterType<SettingsComboBox>("FlightGear.Launcher", 1, 0, "Combo");
|
|
||||||
qmlRegisterType<SettingsIntSpinbox>("FlightGear.Launcher", 1, 0, "Spinbox");
|
|
||||||
qmlRegisterType<SettingsText>("FlightGear.Launcher", 1, 0, "LineEdit");
|
|
||||||
qmlRegisterType<SettingsDateTime>("FlightGear.Launcher", 1, 0, "DateTime");
|
|
||||||
qmlRegisterType<SettingsPath>("FlightGear.Launcher", 1, 0, "PathChooser");
|
|
||||||
qmlRegisterUncreatableType<QAbstractItemModel>("FlightGear.Launcher", 1, 0, "QAIM", "no");
|
qmlRegisterUncreatableType<QAbstractItemModel>("FlightGear.Launcher", 1, 0, "QAIM", "no");
|
||||||
qmlRegisterUncreatableType<AircraftProxyModel>("FlightGear.Launcher", 1, 0, "AircraftProxyModel", "no");
|
qmlRegisterUncreatableType<AircraftProxyModel>("FlightGear.Launcher", 1, 0, "AircraftProxyModel", "no");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<RecentAircraftModel>("FlightGear.Launcher", 1, 0, "RecentAircraftModel", "no");
|
qmlRegisterUncreatableType<RecentAircraftModel>("FlightGear.Launcher", 1, 0, "RecentAircraftModel", "no");
|
||||||
qmlRegisterUncreatableType<RecentLocationsModel>("FlightGear.Launcher", 1, 0, "RecentLocationsModel", "no");
|
qmlRegisterUncreatableType<RecentLocationsModel>("FlightGear.Launcher", 1, 0, "RecentLocationsModel", "no");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<SettingsControl>("FlightGear.Launcher", 1, 0, "Control", "Base class");
|
|
||||||
qmlRegisterUncreatableType<LaunchConfig>("FlightGear.Launcher", 1, 0, "LaunchConfig", "Singleton API");
|
qmlRegisterUncreatableType<LaunchConfig>("FlightGear.Launcher", 1, 0, "LaunchConfig", "Singleton API");
|
||||||
qmlRegisterType<FileDialogWrapper>("FlightGear.Launcher", 1, 0, "FileDialog");
|
|
||||||
|
|
||||||
|
qmlRegisterType<FileDialogWrapper>("FlightGear.Launcher", 1, 0, "FileDialog");
|
||||||
qmlRegisterType<FlickableExtentQuery>("FlightGear.Launcher", 1, 0, "FlickableExtentQuery");
|
qmlRegisterType<FlickableExtentQuery>("FlightGear.Launcher", 1, 0, "FlickableExtentQuery");
|
||||||
qmlRegisterType<QmlAircraftInfo>("FlightGear.Launcher", 1, 0, "AircraftInfo");
|
qmlRegisterType<QmlAircraftInfo>("FlightGear.Launcher", 1, 0, "AircraftInfo");
|
||||||
qmlRegisterType<PopupWindowTracker>("FlightGear.Launcher", 1, 0, "PopupWindowTracker");
|
qmlRegisterType<PopupWindowTracker>("FlightGear.Launcher", 1, 0, "PopupWindowTracker");
|
||||||
|
|
||||||
|
qmlRegisterUncreatableType<LocalAircraftCache>("FlightGear.Launcher", 1, 0, "LocalAircraftCache", "Aircraft cache");
|
||||||
|
qmlRegisterUncreatableType<AircraftItemModel>("FlightGear.Launcher", 1, 0, "AircraftModel", "Built-in model");
|
||||||
|
qmlRegisterType<ThumbnailImageItem>("FlightGear.Launcher", 1, 0, "ThumbnailImage");
|
||||||
|
qmlRegisterType<PreviewImageItem>("FlightGear.Launcher", 1, 0, "PreviewImage");
|
||||||
|
|
||||||
m_config = new LaunchConfig(this);
|
m_config = new LaunchConfig(this);
|
||||||
connect(m_config, &LaunchConfig::collect, this, &LauncherMainWindow::collectAircraftArgs);
|
connect(m_config, &LaunchConfig::collect, this, &LauncherMainWindow::collectAircraftArgs);
|
||||||
m_ui->location->setLaunchConfig(m_config);
|
m_ui->location->setLaunchConfig(m_config);
|
||||||
|
@ -269,11 +244,6 @@ void LauncherMainWindow::initQML()
|
||||||
QQmlContext* summaryContext = m_ui->summary->engine()->rootContext();
|
QQmlContext* summaryContext = m_ui->summary->engine()->rootContext();
|
||||||
summaryContext->setContextProperty("_config", m_config);
|
summaryContext->setContextProperty("_config", m_config);
|
||||||
|
|
||||||
qmlRegisterUncreatableType<LocalAircraftCache>("FlightGear.Launcher", 1, 0, "LocalAircraftCache", "Aircraft cache");
|
|
||||||
qmlRegisterUncreatableType<AircraftItemModel>("FlightGear.Launcher", 1, 0, "AircraftModel", "Built-in model");
|
|
||||||
qmlRegisterType<ThumbnailImageItem>("FlightGear.Launcher", 1, 0, "ThumbnailImage");
|
|
||||||
qmlRegisterType<PreviewImageItem>("FlightGear.Launcher", 1, 0, "PreviewImage");
|
|
||||||
|
|
||||||
QNetworkDiskCache* diskCache = new QNetworkDiskCache(this);
|
QNetworkDiskCache* diskCache = new QNetworkDiskCache(this);
|
||||||
SGPath cachePath = globals->get_fg_home() / "PreviewsCache";
|
SGPath cachePath = globals->get_fg_home() / "PreviewsCache";
|
||||||
diskCache->setCacheDirectory(QString::fromStdString(cachePath.utf8Str()));
|
diskCache->setCacheDirectory(QString::fromStdString(cachePath.utf8Str()));
|
||||||
|
@ -281,7 +251,6 @@ void LauncherMainWindow::initQML()
|
||||||
QNetworkAccessManager* netAccess = new QNetworkAccessManager(this);
|
QNetworkAccessManager* netAccess = new QNetworkAccessManager(this);
|
||||||
netAccess->setCache(diskCache);
|
netAccess->setCache(diskCache);
|
||||||
PreviewImageItem::setGlobalNetworkAccess(netAccess);
|
PreviewImageItem::setGlobalNetworkAccess(netAccess);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherMainWindow::~LauncherMainWindow()
|
LauncherMainWindow::~LauncherMainWindow()
|
||||||
|
@ -345,11 +314,6 @@ void LauncherMainWindow::restoreSettings()
|
||||||
m_ui->location->restoreLocation(currentLocation);
|
m_ui->location->restoreLocation(currentLocation);
|
||||||
|
|
||||||
updateSelectedAircraft();
|
updateSelectedAircraft();
|
||||||
|
|
||||||
Q_FOREACH(SettingsSection* ss, findChildren<SettingsSection*>()) {
|
|
||||||
ss->restoreState(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_serversModel->requestRestore();
|
m_serversModel->requestRestore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,10 +326,6 @@ void LauncherMainWindow::saveSettings()
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue("window-geometry", saveGeometry());
|
settings.setValue("window-geometry", saveGeometry());
|
||||||
|
|
||||||
Q_FOREACH(SettingsSection* ss, findChildren<SettingsSection*>()) {
|
|
||||||
ss->saveState(settings);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherMainWindow::closeEvent(QCloseEvent *event)
|
void LauncherMainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
@ -572,20 +532,6 @@ void LauncherMainWindow::updateSelectedAircraft()
|
||||||
m_selectedAircraftInfo->setUri(m_selectedAircraft);
|
m_selectedAircraftInfo->setUri(m_selectedAircraft);
|
||||||
QModelIndex index = m_aircraftModel->indexOfAircraftURI(m_selectedAircraft);
|
QModelIndex index = m_aircraftModel->indexOfAircraftURI(m_selectedAircraft);
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
#if 0
|
|
||||||
QPixmap pm = index.data(Qt::DecorationRole).value<QPixmap>();
|
|
||||||
m_ui->thumbnail->setPixmap(pm);
|
|
||||||
|
|
||||||
// important to use this version to get the variant-specific name
|
|
||||||
// correct; the QModelIndex lookup doesn't do that.
|
|
||||||
// actually all the data is for the primary variant, but this will be
|
|
||||||
// fixed when enabling the LocalAircraftCache outside the AircaftModel
|
|
||||||
m_ui->aircraftName->setText(m_aircraftModel->nameForAircraftURI(m_selectedAircraft));
|
|
||||||
|
|
||||||
QVariant longDesc = index.data(AircraftLongDescriptionRole);
|
|
||||||
m_ui->aircraftDescription->setVisible(!longDesc.isNull());
|
|
||||||
m_ui->aircraftDescription->setText(longDesc.toString());
|
|
||||||
#endif
|
|
||||||
int status = index.data(AircraftPackageStatusRole).toInt();
|
int status = index.data(AircraftPackageStatusRole).toInt();
|
||||||
bool canRun = (status == LocalAircraftCache::PackageInstalled);
|
bool canRun = (status == LocalAircraftCache::PackageInstalled);
|
||||||
m_ui->flyButton->setEnabled(canRun);
|
m_ui->flyButton->setEnabled(canRun);
|
||||||
|
@ -598,28 +544,7 @@ void LauncherMainWindow::updateSelectedAircraft()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->location->setAircraftType(aircraftType);
|
m_ui->location->setAircraftType(aircraftType);
|
||||||
|
|
||||||
const bool hasStates = m_selectedAircraftInfo->hasStates();
|
|
||||||
#if 0
|
|
||||||
m_ui->stateCombo->setVisible(hasStates);
|
|
||||||
m_ui->stateLabel->setVisible(hasStates);
|
|
||||||
m_ui->stateDescription->setVisible(false);
|
|
||||||
if (hasStates) {
|
|
||||||
m_ui->stateCombo->setModel(m_selectedAircraftInfo->statesModel());
|
|
||||||
m_ui->stateDescription->setText(m_ui->stateCombo->currentData(QmlAircraftInfo::StateDescriptionRole).toString());
|
|
||||||
// hiden when no description is present
|
|
||||||
m_ui->stateDescription->setVisible(!m_ui->stateDescription->text().isEmpty());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
#if 0
|
|
||||||
m_ui->thumbnail->setPixmap(QPixmap());
|
|
||||||
m_ui->aircraftName->setText("");
|
|
||||||
m_ui->aircraftDescription->hide();
|
|
||||||
m_ui->stateCombo->hide();
|
|
||||||
m_ui->stateLabel->hide();
|
|
||||||
m_ui->stateDescription->hide();
|
|
||||||
#endif
|
|
||||||
m_ui->flyButton->setEnabled(false);
|
m_ui->flyButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,14 +791,6 @@ void LauncherMainWindow::onChangeDataDir()
|
||||||
flightgear::restartTheApp();
|
flightgear::restartTheApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherMainWindow::onSettingsSearchChanged()
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
Q_FOREACH(SettingsSectionQML* ss, findChildren<SettingsSectionQML*>()) {
|
|
||||||
ss->setSearchTerm(m_ui->settingsSearchEdit->text());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LauncherMainWindow::validateMetarString(QString metar)
|
bool LauncherMainWindow::validateMetarString(QString metar)
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,7 +200,6 @@ private slots:
|
||||||
void setSceneryPaths();
|
void setSceneryPaths();
|
||||||
void onAircraftPathsChanged();
|
void onAircraftPathsChanged();
|
||||||
void onChangeDataDir();
|
void onChangeDataDir();
|
||||||
void onSettingsSearchChanged();
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
import QtQml 2.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
// note this id is used, hard-coded, in MPServersModel
|
|
||||||
id: mpSettings
|
|
||||||
title: "Multi-player"
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: enableMP
|
|
||||||
label: qsTr("Connect to the multi-player network")
|
|
||||||
description: qsTr("FlightGear supporters maintain a network of servers to enable global multi-user "
|
|
||||||
+ "flight. This requires a moderately fast Internet connection to be usable. Your aircraft "
|
|
||||||
+ "will be visible to other users online, and you will see their aircraft.")
|
|
||||||
keywords: ["network", "mp", "multiplay","online"]
|
|
||||||
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked) {
|
|
||||||
// kick off a server query now
|
|
||||||
_launcher.queryMPServers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LineEdit {
|
|
||||||
id: callSign
|
|
||||||
enabled: enableMP.checked
|
|
||||||
label: qsTr("Callsign")
|
|
||||||
description: qsTr("Enter a callsign you will use online. This is visible to all users and is " +
|
|
||||||
"how ATC services and other pilots will refer to you. " +
|
|
||||||
"(Maximum of seven characters permitted)")
|
|
||||||
placeholder: "D-FGFS"
|
|
||||||
keywords: ["callsign", "handle", "name"]
|
|
||||||
|
|
||||||
// between one and seven alphanumerics, underscores and or hypens
|
|
||||||
// spaces not permitted
|
|
||||||
validation: "[\\w-]{1,7}"
|
|
||||||
}
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: mpServer
|
|
||||||
label: qsTr("Server")
|
|
||||||
enabled: enableMP.checked
|
|
||||||
description: qsTr("Select a server close to you for better responsiveness and reduced lag when flying online.")
|
|
||||||
model: _mpServers
|
|
||||||
|
|
||||||
readonly property bool currentIsCustom: (model.serverForIndex(selectedIndex) == "__custom__")
|
|
||||||
|
|
||||||
keywords: ["server", "hostname"]
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections
|
|
||||||
{
|
|
||||||
target: _mpServers
|
|
||||||
onRestoreIndex: {
|
|
||||||
mpServer.selectedIndex = index
|
|
||||||
}
|
|
||||||
|
|
||||||
onRestoreDefault: {
|
|
||||||
console.info("Selecting default MP server");
|
|
||||||
mpServer.selectedIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LineEdit {
|
|
||||||
id: mpCustomServer
|
|
||||||
enabled: enableMP.checked
|
|
||||||
label: qsTr("Custom server")
|
|
||||||
visible: mpServer.currentIsCustom
|
|
||||||
description: qsTr("Enter a server hostname or IP address, and a port number. For example 'localhost:5001'")
|
|
||||||
placeholder: "localhost:5001"
|
|
||||||
}
|
|
||||||
|
|
||||||
readonly property int defaultMPPort: 5000
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (enableMP.checked) {
|
|
||||||
if (mpServer.currentIsCustom) {
|
|
||||||
var pieces = mpCustomServer.value.split(':')
|
|
||||||
var port = defaultMPPort;
|
|
||||||
if (pieces.length > 1) {
|
|
||||||
port = pieces[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.setProperty("/sim/multiplay/txhost", pieces[0]);
|
|
||||||
_config.setProperty("/sim/multiplay/txport", port);
|
|
||||||
} else {
|
|
||||||
var sel = mpServer.selectedIndex
|
|
||||||
var host = _mpServers.serverForIndex(sel);
|
|
||||||
if (host == "") {
|
|
||||||
console.warn("No host name for selected MP server " + sel)
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.setProperty("/sim/multiplay/txhost", host);
|
|
||||||
var port = _mpServers.portForIndex(sel);
|
|
||||||
if (port == 0) {
|
|
||||||
port = defaultMPPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.setProperty("/sim/multiplay/txport", port);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (callSign.value.length > 0) {
|
|
||||||
_config.setArg("callsign", callSign.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onRestore: {
|
|
||||||
if (enableMP.checked) {
|
|
||||||
// only query servers if MP is enabled
|
|
||||||
_launcher.queryMPServers();
|
|
||||||
}
|
|
||||||
|
|
||||||
// restoration is done by the C++ code
|
|
||||||
// in MPServersModel::restoreMPServerSelection
|
|
||||||
}
|
|
||||||
|
|
||||||
onSave: {
|
|
||||||
saveSetting("mp-server", _mpServers.serverForIndex(mpServer.selectedIndex));
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: enableMP.checked ? "multi-player;" : ""
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: renderingSetttings
|
|
||||||
title: "Rendering"
|
|
||||||
|
|
||||||
readonly property bool rembrandt: (renderer.selectedIndex == 2)
|
|
||||||
readonly property bool alsEnabled: (renderer.selectedIndex == 1)
|
|
||||||
readonly property bool msaaEnabled: !rembrandt && (msaa.selectedIndex > 0)
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: renderer
|
|
||||||
label: qsTr("Renderer")
|
|
||||||
choices: [qsTr("Default"),
|
|
||||||
qsTr("Atmospheric Light Scattering"),
|
|
||||||
qsTr("Rembrandt")]
|
|
||||||
description: descriptions[selectedIndex]
|
|
||||||
defaultIndex: 0
|
|
||||||
|
|
||||||
readonly property var descriptions: [
|
|
||||||
qsTr("The default renderer provides standard visuals with maximum compatibility."),
|
|
||||||
qsTr("The ALS renderer uses a sophisticated physical atmospheric model and several " +
|
|
||||||
"other effects to give realistic rendering of large distances."),
|
|
||||||
qsTr("Rembrandt is a configurable multi-pass renderer which supports shadow-maps, cinematic " +
|
|
||||||
"effects and more. However, not all aircraft appear correctly and performance will " +
|
|
||||||
"depend greatly on your system hardware.")
|
|
||||||
]
|
|
||||||
|
|
||||||
keywords: ["als", "rembrandt", "render", "shadow"]
|
|
||||||
}
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: msaa
|
|
||||||
label: qsTr("Anti-aliasing")
|
|
||||||
description: qsTr("Anti-aliasing improves the appearance of high-contrast edges and lines. " +
|
|
||||||
"This is especially noticeable on sloping or diagonal edges. " +
|
|
||||||
"Higher settings can reduce performance.")
|
|
||||||
keywords: ["msaa", "anti", "aliasing", "multi", "sample"]
|
|
||||||
choices: [qsTr("Off"), "2x", "4x"]
|
|
||||||
enabled: !rembrandt
|
|
||||||
property var data: [0, 2, 4];
|
|
||||||
defaultIndex: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (msaaEnabled) {
|
|
||||||
_config.setProperty("/sim/rendering/multi-sample-buffers", 1)
|
|
||||||
_config.setProperty("/sim/rendering/multi-samples", msaa.data[msaa.selectedIndex])
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.setEnableDisableOption("rembrandt", rembrandt);
|
|
||||||
|
|
||||||
if (alsEnabled) {
|
|
||||||
_config.setProperty("/sim/rendering/shaders/skydome", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: (rembrandt ? qsTr("Rembrandt;") : (alsEnabled ? "ALS;" : ""))
|
|
||||||
+ (msaaEnabled ? "anti-aliasing;" : "")
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,171 +0,0 @@
|
||||||
#include "SettingsSectionQML.hxx"
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <QQmlContext>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include "AdvancedSettingsButton.h"
|
|
||||||
#include "SettingsWidgets.hxx"
|
|
||||||
#include "LaunchConfig.hxx"
|
|
||||||
|
|
||||||
SettingsSectionQML::SettingsSectionQML()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::internalUpdateAdvanced()
|
|
||||||
{
|
|
||||||
const bool showAdvanced = m_showAdvanced | m_forceShowAdvanced;
|
|
||||||
Q_FOREACH (SettingsControl* w, controls()) {
|
|
||||||
w->updateWidgetVisibility(showAdvanced);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::controls_append(QQmlListProperty<QObject> *prop, QObject *item)
|
|
||||||
{
|
|
||||||
SettingsSectionQML* self = qobject_cast<SettingsSectionQML*>(prop->object);
|
|
||||||
QVBoxLayout* topLevelVBox = qobject_cast<QVBoxLayout*>(self->layout());
|
|
||||||
self->m_controls.append(item);
|
|
||||||
|
|
||||||
SettingsControl* control = qobject_cast<SettingsControl*>(item);
|
|
||||||
if (control) {
|
|
||||||
// following two lines would not be needed if the custom
|
|
||||||
// setParent function was working :(
|
|
||||||
control->setParent(nullptr);
|
|
||||||
control->setParent(self);
|
|
||||||
topLevelVBox->addWidget(control);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::controls_clear(QQmlListProperty<QObject> *prop)
|
|
||||||
{
|
|
||||||
SettingsSectionQML* self = qobject_cast<SettingsSectionQML*>(prop->object);
|
|
||||||
QVBoxLayout* topLevelVBox = qobject_cast<QVBoxLayout*>(self->layout());
|
|
||||||
|
|
||||||
Q_FOREACH (QObject* c, self->m_controls) {
|
|
||||||
SettingsControl* control = qobject_cast<SettingsControl*>(c);
|
|
||||||
if (control) {
|
|
||||||
topLevelVBox->removeWidget(control);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsSectionQML::controls_count(QQmlListProperty<QObject> *prop)
|
|
||||||
{
|
|
||||||
SettingsSectionQML* self = qobject_cast<SettingsSectionQML*>(prop->object);
|
|
||||||
return self->m_controls.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject *SettingsSectionQML::control_at(QQmlListProperty<QObject> *prop, int index)
|
|
||||||
{
|
|
||||||
SettingsSectionQML* self = qobject_cast<SettingsSectionQML*>(prop->object);
|
|
||||||
return self->m_controls.at(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlListProperty<QObject> SettingsSectionQML::qmlControls()
|
|
||||||
{
|
|
||||||
return QQmlListProperty<QObject>(this, nullptr,
|
|
||||||
&SettingsSectionQML::controls_append,
|
|
||||||
&SettingsSectionQML::controls_count,
|
|
||||||
&SettingsSectionQML::control_at,
|
|
||||||
&SettingsSectionQML::controls_clear);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<SettingsControl *> SettingsSectionQML::controls() const
|
|
||||||
{
|
|
||||||
return findChildren<SettingsControl*>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::updateShowAdvanced()
|
|
||||||
{
|
|
||||||
bool needsShowAdvanced = false;
|
|
||||||
Q_FOREACH (SettingsControl* w, controls()) {
|
|
||||||
needsShowAdvanced |= w->advanced();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_advancedModeToggle->setVisible(needsShowAdvanced);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
QQmlContext* context = QQmlEngine::contextForObject(this);
|
|
||||||
QString s = context->nameForObject(const_cast<SettingsSectionQML*>(this));
|
|
||||||
settings.beginGroup(s);
|
|
||||||
Q_FOREACH (SettingsControl* control, controls()) {
|
|
||||||
control->saveState(settings);
|
|
||||||
}
|
|
||||||
const_cast<SettingsSectionQML*>(this)->save();
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
QQmlContext* context = QQmlEngine::contextForObject(this);
|
|
||||||
QString s = context->nameForObject(const_cast<SettingsSectionQML*>(this));
|
|
||||||
settings.beginGroup(s);
|
|
||||||
Q_FOREACH (SettingsControl* control, controls()) {
|
|
||||||
control->restoreState(settings);
|
|
||||||
}
|
|
||||||
settings.endGroup();
|
|
||||||
emit restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::doApply()
|
|
||||||
{
|
|
||||||
LaunchConfig* config = qobject_cast<LaunchConfig*>(sender());
|
|
||||||
Q_FOREACH (SettingsControl* control, controls()) {
|
|
||||||
control->apply(config);
|
|
||||||
}
|
|
||||||
emit apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsSectionQML::summary() const
|
|
||||||
{
|
|
||||||
return m_summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::saveSetting(QString key, QVariant value)
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
QQmlContext* context = QQmlEngine::contextForObject(this);
|
|
||||||
QString s = context->nameForObject(const_cast<SettingsSectionQML*>(this));
|
|
||||||
settings.beginGroup(s);
|
|
||||||
settings.setValue(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant SettingsSectionQML::restoreSetting(QString key)
|
|
||||||
{
|
|
||||||
QSettings settings;
|
|
||||||
QQmlContext* context = QQmlEngine::contextForObject(this);
|
|
||||||
QString s = context->nameForObject(const_cast<SettingsSectionQML*>(this));
|
|
||||||
settings.beginGroup(s);
|
|
||||||
return settings.value(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SettingsSectionQML::showAdvanced() const
|
|
||||||
{
|
|
||||||
return m_showAdvanced | m_forceShowAdvanced;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::setSummary(QString summary)
|
|
||||||
{
|
|
||||||
if (m_summary == summary)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_summary = summary;
|
|
||||||
emit qmlSummaryChanged(summary);
|
|
||||||
emit summaryChanged(summary);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsSectionQML::setSearchTerm(QString search)
|
|
||||||
{
|
|
||||||
m_forceShowAdvanced = false;
|
|
||||||
Q_FOREACH(SettingsControl* control, controls()) {
|
|
||||||
const bool matches = control->setSearchTerm(search);
|
|
||||||
m_forceShowAdvanced |= (matches && control->advanced());
|
|
||||||
}
|
|
||||||
internalUpdateAdvanced();
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
#ifndef SETTINGSSECTIONQML_HXX
|
|
||||||
#define SETTINGSSECTIONQML_HXX
|
|
||||||
|
|
||||||
#include "SettingsSection.hxx"
|
|
||||||
|
|
||||||
#include <QQmlListProperty>
|
|
||||||
|
|
||||||
class SettingsControl;
|
|
||||||
|
|
||||||
class SettingsSectionQML : public SettingsSection
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
|
|
||||||
Q_PROPERTY(QQmlListProperty<QObject> controls READ qmlControls)
|
|
||||||
Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY qmlSummaryChanged)
|
|
||||||
|
|
||||||
Q_CLASSINFO("DefaultProperty", "controls")
|
|
||||||
public:
|
|
||||||
SettingsSectionQML();
|
|
||||||
|
|
||||||
QQmlListProperty<QObject> qmlControls();
|
|
||||||
|
|
||||||
QList<SettingsControl*> controls() const;
|
|
||||||
|
|
||||||
void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
void restoreState(QSettings& settings) override;
|
|
||||||
|
|
||||||
void doApply() override;
|
|
||||||
|
|
||||||
virtual QString summary() const override;
|
|
||||||
|
|
||||||
Q_INVOKABLE void saveSetting(QString key, QVariant value);
|
|
||||||
Q_INVOKABLE QVariant restoreSetting(QString key);
|
|
||||||
|
|
||||||
bool showAdvanced() const override;
|
|
||||||
public slots:
|
|
||||||
void setSummary(QString summary);
|
|
||||||
|
|
||||||
void setSearchTerm(QString search);
|
|
||||||
signals:
|
|
||||||
void controlsChanged();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief apply - change the launch configuration according to the values
|
|
||||||
* in this settings section.
|
|
||||||
*/
|
|
||||||
void apply();
|
|
||||||
|
|
||||||
void save();
|
|
||||||
|
|
||||||
void restore();
|
|
||||||
|
|
||||||
void qmlSummaryChanged(QString summary);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
static void controls_append( QQmlListProperty<QObject>* prop,
|
|
||||||
QObject* item );
|
|
||||||
static void controls_clear( QQmlListProperty<QObject>* prop );
|
|
||||||
static int controls_count( QQmlListProperty<QObject>* prop );
|
|
||||||
static QObject* control_at( QQmlListProperty<QObject>* prop, int index );
|
|
||||||
|
|
||||||
void internalUpdateAdvanced() override;
|
|
||||||
void updateShowAdvanced() override;
|
|
||||||
QString m_summary;
|
|
||||||
QObjectList m_controls;
|
|
||||||
bool m_forceShowAdvanced; ///< overrides show-advanced when searching
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGSSECTIONQML_HXX
|
|
|
@ -1,728 +0,0 @@
|
||||||
#include "SettingsWidgets.hxx"
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QSpinBox>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <QQmlContext>
|
|
||||||
#include <QDateTimeEdit>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QRegularExpressionValidator>
|
|
||||||
|
|
||||||
#include "LaunchConfig.hxx"
|
|
||||||
#include "SettingsSection.hxx"
|
|
||||||
|
|
||||||
const int MARGIN_HINT = 4;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
QString SettingsControl::label() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsControl::description() const
|
|
||||||
{
|
|
||||||
if (m_description) {
|
|
||||||
return m_description->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList SettingsControl::keywords() const
|
|
||||||
{
|
|
||||||
return m_keywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsControl::option() const
|
|
||||||
{
|
|
||||||
return m_option;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SettingsControl::setSearchTerm(QString search)
|
|
||||||
{
|
|
||||||
bool inSearch = false;
|
|
||||||
// only show matches when search string is at least three characters,
|
|
||||||
// to avoid many hits when the user starts typing
|
|
||||||
if (search.length() > 2) {
|
|
||||||
Q_FOREACH(QString k, m_keywords) {
|
|
||||||
if (k.indexOf(search, 0, Qt::CaseInsensitive) >= 0) {
|
|
||||||
inSearch = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setProperty("search-result", inSearch);
|
|
||||||
update();
|
|
||||||
return inSearch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SettingsControl::qmlVisible() const
|
|
||||||
{
|
|
||||||
return m_localVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::setAdvanced(bool advanced)
|
|
||||||
{
|
|
||||||
if (m_advanced == advanced)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_advanced = advanced;
|
|
||||||
emit advancedChanged(advanced);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::setDescription(QString desc)
|
|
||||||
{
|
|
||||||
if (m_description) {
|
|
||||||
m_description->setText(desc);
|
|
||||||
}
|
|
||||||
emit descriptionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::apply(LaunchConfig *lconfig) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(lconfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::setKeywords(QStringList keywords)
|
|
||||||
{
|
|
||||||
if (m_keywords == keywords)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_keywords = keywords;
|
|
||||||
emit keywordsChanged(keywords);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::setOption(QString option)
|
|
||||||
{
|
|
||||||
if (m_option == option)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_option = option;
|
|
||||||
emit optionChanged(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::setQmlVisible(bool visible)
|
|
||||||
{
|
|
||||||
if (m_localVisible == visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_localVisible = visible;
|
|
||||||
SettingsSection* section = qobject_cast<SettingsSection*>(parent());
|
|
||||||
updateWidgetVisibility(section->showAdvanced());
|
|
||||||
emit qmlVisibleChanged(visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsControl::SettingsControl(QWidget *pr) :
|
|
||||||
QWidget(pr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::createDescription()
|
|
||||||
{
|
|
||||||
m_description = new QLabel(this);
|
|
||||||
m_description->setWordWrap(true);
|
|
||||||
QFont f = m_description->font();
|
|
||||||
f.setPointSize(f.pointSize() - 2);
|
|
||||||
m_description->setFont(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsControl::qmlName() const
|
|
||||||
{
|
|
||||||
QQmlContext* context = QQmlEngine::contextForObject(this);
|
|
||||||
QString s = context->nameForObject(const_cast<SettingsControl*>(this));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::paintEvent(QPaintEvent *pe)
|
|
||||||
{
|
|
||||||
QWidget::paintEvent(pe);
|
|
||||||
|
|
||||||
if (property("search-result").toBool()) {
|
|
||||||
QPainter painter(this);
|
|
||||||
painter.setRenderHints(QPainter::Antialiasing);
|
|
||||||
QPen pen(QColor("#7f7f7fff"), 1);
|
|
||||||
painter.setPen(pen);
|
|
||||||
painter.setBrush(QColor("#2f7f7fff"));
|
|
||||||
painter.drawRoundedRect(rect(), 8, 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsControl::updateWidgetVisibility(bool showAdvanced)
|
|
||||||
{
|
|
||||||
if (advanced()) {
|
|
||||||
setVisible(m_localVisible & showAdvanced);
|
|
||||||
} else if (property("simple").toBool()) {
|
|
||||||
setVisible(m_localVisible & !showAdvanced);
|
|
||||||
} else {
|
|
||||||
setVisible(m_localVisible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SettingsCheckbox::SettingsCheckbox(QWidget* parent) :
|
|
||||||
SettingsControl(parent)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
setLayout(vbox);
|
|
||||||
m_check = new QCheckBox(this);
|
|
||||||
vbox->addWidget(m_check);
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
connect(m_check, &QCheckBox::toggled, this, &SettingsCheckbox::checkedChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsCheckbox::label() const
|
|
||||||
{
|
|
||||||
return m_check->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SettingsCheckbox::isChecked() const
|
|
||||||
{
|
|
||||||
return m_check->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCheckbox::setChecked(bool checked)
|
|
||||||
{
|
|
||||||
if (checked == isChecked()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_check->setChecked(checked);
|
|
||||||
emit checkedChanged(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCheckbox::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_check->setText(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCheckbox::apply(LaunchConfig* lconfig) const
|
|
||||||
{
|
|
||||||
if (option().isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lconfig->setEnableDisableOption(option(), isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCheckbox::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue(qmlName(), isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsCheckbox::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
setChecked(settings.value(qmlName(), isChecked()).toBool());
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SettingsComboBox::SettingsComboBox(QWidget *pr) :
|
|
||||||
SettingsControl(pr)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
setLayout(vbox);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
|
|
||||||
QHBoxLayout* hbox = new QHBoxLayout;
|
|
||||||
hbox->setMargin(MARGIN_HINT);
|
|
||||||
|
|
||||||
vbox->addLayout(hbox);
|
|
||||||
m_combo = new QComboBox(this);
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
hbox->addWidget(m_label);
|
|
||||||
hbox->addWidget(m_combo);
|
|
||||||
hbox->addStretch(1);
|
|
||||||
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
|
|
||||||
connect(m_combo, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SIGNAL(selectedIndexChanged(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList SettingsComboBox::choices() const
|
|
||||||
{
|
|
||||||
QStringList result;
|
|
||||||
for (int i=0; i < m_combo->count(); ++i) {
|
|
||||||
result.append(m_combo->itemText(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsComboBox::selectedIndex() const
|
|
||||||
{
|
|
||||||
return m_combo->currentIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
// if selected index is custom, need to save something else?
|
|
||||||
if (selectedIndex() == m_defaultIndex) {
|
|
||||||
settings.remove(qmlName());
|
|
||||||
} else {
|
|
||||||
settings.setValue(qmlName(), selectedIndex());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
QString id = qmlName();
|
|
||||||
setSelectedIndex(settings.value(id, m_defaultIndex).toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::setChoices(QStringList aChoices)
|
|
||||||
{
|
|
||||||
if (choices() == aChoices)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_combo->clear();
|
|
||||||
Q_FOREACH (QString choice, aChoices) {
|
|
||||||
m_combo->addItem(choice);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit choicesChanged(aChoices);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::setSelectedIndex(int selectedIndex)
|
|
||||||
{
|
|
||||||
if (m_combo->currentIndex() == selectedIndex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_combo->setCurrentIndex(selectedIndex);
|
|
||||||
emit selectedIndexChanged(selectedIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_label->setText(label);
|
|
||||||
emit labelChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QAbstractItemModel *SettingsComboBox::model() const
|
|
||||||
{
|
|
||||||
return m_combo->model();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsComboBox::defaultIndex() const
|
|
||||||
{
|
|
||||||
return m_defaultIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::setModel(QAbstractItemModel *model)
|
|
||||||
{
|
|
||||||
if (model == m_combo->model()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_combo->setModel(model);
|
|
||||||
emit modelChanged(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsComboBox::setDefaultIndex(int defaultIndex)
|
|
||||||
{
|
|
||||||
if (m_defaultIndex == defaultIndex)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_defaultIndex = defaultIndex;
|
|
||||||
emit defaultIndexChanged(defaultIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SettingsIntSpinbox::SettingsIntSpinbox(QWidget *pr) :
|
|
||||||
SettingsControl(pr)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
setLayout(vbox);
|
|
||||||
|
|
||||||
QHBoxLayout* hbox = new QHBoxLayout;
|
|
||||||
hbox->setMargin(MARGIN_HINT);
|
|
||||||
|
|
||||||
vbox->addLayout(hbox);
|
|
||||||
m_spin = new QSpinBox(this);
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
hbox->addWidget(m_label);
|
|
||||||
hbox->addWidget(m_spin);
|
|
||||||
hbox->addStretch(1);
|
|
||||||
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
|
|
||||||
connect(m_spin, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsIntSpinbox::value() const
|
|
||||||
{
|
|
||||||
return m_spin->value();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsIntSpinbox::min() const
|
|
||||||
{
|
|
||||||
return m_spin->minimum();
|
|
||||||
}
|
|
||||||
|
|
||||||
int SettingsIntSpinbox::max() const
|
|
||||||
{
|
|
||||||
return m_spin->maximum();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::apply(LaunchConfig *lconfig) const
|
|
||||||
{
|
|
||||||
if (option().isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lconfig->setArg(option(), QString::number(value()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue(qmlName(), value());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
setValue(settings.value(qmlName(), value()).toInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::setValue(int aValue)
|
|
||||||
{
|
|
||||||
if (value() == aValue)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_spin->setValue(aValue);
|
|
||||||
emit valueChanged(aValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::setMin(int aMin)
|
|
||||||
{
|
|
||||||
if (min() == aMin)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_spin->setMinimum(aMin);
|
|
||||||
emit minChanged(aMin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::setMax(int aMax)
|
|
||||||
{
|
|
||||||
if (max() == aMax)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_spin->setMaximum(aMax);
|
|
||||||
emit maxChanged(aMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsIntSpinbox::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_label->setText(label);
|
|
||||||
emit labelChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsText::SettingsText(QWidget *pr) :
|
|
||||||
SettingsControl(pr)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
setLayout(vbox);
|
|
||||||
|
|
||||||
QHBoxLayout* hbox = new QHBoxLayout;
|
|
||||||
hbox->setMargin(MARGIN_HINT);
|
|
||||||
vbox->addLayout(hbox);
|
|
||||||
m_edit = new QLineEdit(this);
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
hbox->addWidget(m_label);
|
|
||||||
hbox->addWidget(m_edit, 1);
|
|
||||||
// hbox->addStretch(1);
|
|
||||||
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
|
|
||||||
connect(m_edit, &QLineEdit::textChanged, this, &SettingsText::valueChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsText::value() const
|
|
||||||
{
|
|
||||||
return m_edit->text();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::apply(LaunchConfig *lconfig) const
|
|
||||||
{
|
|
||||||
if (option().isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lconfig->setArg(option(), value());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue(qmlName(), value());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
setValue(settings.value(qmlName(), value()).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_label->setText(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::setValue(QString newVal)
|
|
||||||
{
|
|
||||||
if (value() == newVal)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_edit->setText(newVal);
|
|
||||||
emit valueChanged(newVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsText::placeholder() const
|
|
||||||
{
|
|
||||||
return m_edit->placeholderText();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsText::validation() const
|
|
||||||
{
|
|
||||||
return m_validation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::setPlaceholder(QString hold)
|
|
||||||
{
|
|
||||||
if (placeholder() == hold)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_edit->setPlaceholderText(hold);
|
|
||||||
emit placeholderChanged(hold);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsText::setValidation(QString validation)
|
|
||||||
{
|
|
||||||
if (m_validation == validation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_validation = validation;
|
|
||||||
|
|
||||||
QRegularExpression re(m_validation);
|
|
||||||
if (!re.isValid()) {
|
|
||||||
qWarning() << "invalid validation expression:" << re.errorString();
|
|
||||||
m_validation.clear();
|
|
||||||
validation.clear();
|
|
||||||
m_edit->setValidator(nullptr);
|
|
||||||
} else {
|
|
||||||
m_edit->setValidator(new QRegularExpressionValidator(re, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit validationChanged(validation);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsPath::SettingsPath(QWidget *pr) :
|
|
||||||
SettingsControl(pr)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
setLayout(vbox);
|
|
||||||
|
|
||||||
QHBoxLayout* hbox = new QHBoxLayout;
|
|
||||||
hbox->setMargin(MARGIN_HINT);
|
|
||||||
vbox->addLayout(hbox);
|
|
||||||
|
|
||||||
m_changeButton = new QPushButton(tr("Change"), this);
|
|
||||||
connect(m_changeButton, &QPushButton::clicked, this, &SettingsPath::choosePath);
|
|
||||||
|
|
||||||
m_defaultButton = new QPushButton(tr("Default"), this);
|
|
||||||
connect(m_defaultButton, &QPushButton::clicked, this, &SettingsPath::restoreDefaultPath);
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
hbox->addWidget(m_label, 1);
|
|
||||||
hbox->addWidget(m_changeButton);
|
|
||||||
hbox->addWidget(m_defaultButton);
|
|
||||||
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SettingsPath::path() const
|
|
||||||
{
|
|
||||||
return m_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setPath(QString path)
|
|
||||||
{
|
|
||||||
if (m_path == path)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_path = path;
|
|
||||||
emit pathChanged(path);
|
|
||||||
updateLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_labelPrefix = label;
|
|
||||||
updateLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::apply(LaunchConfig *lconfig) const
|
|
||||||
{
|
|
||||||
if (m_option.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_path.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lconfig->setArg(option(), path());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setDefaultPath(QString path)
|
|
||||||
{
|
|
||||||
if (m_defaultPath == path)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_defaultPath = path;
|
|
||||||
m_defaultButton->setVisible(!m_defaultPath.isEmpty());
|
|
||||||
emit defaultPathChanged(path);
|
|
||||||
updateLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setChooseDirectory(bool chooseDirectory)
|
|
||||||
{
|
|
||||||
if (m_chooseDirectory == chooseDirectory)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_chooseDirectory = chooseDirectory;
|
|
||||||
emit chooseDirectoryChanged(chooseDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::choosePath()
|
|
||||||
{
|
|
||||||
QString path;
|
|
||||||
if (m_chooseDirectory) {
|
|
||||||
path = QFileDialog::getExistingDirectory(this,
|
|
||||||
m_dialogPrompt,
|
|
||||||
m_path);
|
|
||||||
} else {
|
|
||||||
// if we're going to use this, add filter support
|
|
||||||
path = QFileDialog::getOpenFileName(this, m_dialogPrompt, m_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.isEmpty()) {
|
|
||||||
return; // user cancelled
|
|
||||||
}
|
|
||||||
setPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::restoreDefaultPath()
|
|
||||||
{
|
|
||||||
setPath(QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setDialogPrompt(QString dialogPrompt)
|
|
||||||
{
|
|
||||||
if (m_dialogPrompt == dialogPrompt)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_dialogPrompt = dialogPrompt;
|
|
||||||
emit dialogPromptChanged(dialogPrompt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::setOption(QString option)
|
|
||||||
{
|
|
||||||
if (m_option == option)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_option = option;
|
|
||||||
emit optionChanged(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::updateLabel()
|
|
||||||
{
|
|
||||||
const bool isDefault = (m_path.isEmpty());
|
|
||||||
QString s = isDefault ? tr("%1: %2 (default)") : tr("%1: %2");
|
|
||||||
QString path = isDefault ? defaultPath() : m_path;
|
|
||||||
m_label->setText(s.arg(m_labelPrefix).arg(path));
|
|
||||||
m_defaultButton->setEnabled(!isDefault);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue(qmlName(), m_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsPath::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
QString s = settings.value(qmlName(), QString()).toString();
|
|
||||||
setPath(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsDateTime::SettingsDateTime(QWidget *pr) :
|
|
||||||
SettingsControl(pr)
|
|
||||||
{
|
|
||||||
QVBoxLayout* vbox = new QVBoxLayout(this);
|
|
||||||
vbox->setMargin(MARGIN_HINT);
|
|
||||||
setLayout(vbox);
|
|
||||||
|
|
||||||
QHBoxLayout* hbox = new QHBoxLayout;
|
|
||||||
hbox->setMargin(MARGIN_HINT);
|
|
||||||
vbox->addLayout(hbox);
|
|
||||||
|
|
||||||
m_edit = new QDateTimeEdit;
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
hbox->addWidget(m_label);
|
|
||||||
hbox->addWidget(m_edit);
|
|
||||||
hbox->addStretch(1);
|
|
||||||
|
|
||||||
createDescription();
|
|
||||||
vbox->addWidget(m_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDateTime::saveState(QSettings &settings) const
|
|
||||||
{
|
|
||||||
settings.setValue(qmlName(), value());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDateTime::restoreState(QSettings &settings)
|
|
||||||
{
|
|
||||||
m_edit->setDateTime(settings.value(qmlName()).toDateTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDateTime::setLabel(QString label)
|
|
||||||
{
|
|
||||||
m_label->setText(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime SettingsDateTime::value() const
|
|
||||||
{
|
|
||||||
return m_edit->dateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SettingsDateTime::setValue(QDateTime value)
|
|
||||||
{
|
|
||||||
if (m_edit->dateTime() == value) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
emit valueChanged(value);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,383 +0,0 @@
|
||||||
#ifndef SETTINGSWIDGETS_HXX
|
|
||||||
#define SETTINGSWIDGETS_HXX
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
class QCheckBox;
|
|
||||||
class QComboBox;
|
|
||||||
class QSpinBox;
|
|
||||||
class QLineEdit;
|
|
||||||
class QLabel;
|
|
||||||
class QSettings;
|
|
||||||
class LaunchConfig;
|
|
||||||
class QPushButton;
|
|
||||||
class QAbstractItemModel;
|
|
||||||
class QDateTimeEdit;
|
|
||||||
|
|
||||||
class SettingsControl : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(bool advanced READ advanced WRITE setAdvanced NOTIFY advancedChanged)
|
|
||||||
Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged)
|
|
||||||
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
|
|
||||||
Q_PROPERTY(QStringList keywords READ keywords WRITE setKeywords NOTIFY keywordsChanged)
|
|
||||||
Q_PROPERTY(QString option READ option WRITE setOption NOTIFY optionChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool visible READ qmlVisible WRITE setQmlVisible NOTIFY qmlVisibleChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
bool advanced() const
|
|
||||||
{
|
|
||||||
return m_advanced;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QString label() const;
|
|
||||||
virtual QString description() const;
|
|
||||||
|
|
||||||
QStringList keywords() const;
|
|
||||||
|
|
||||||
QString option() const;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const = 0;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief setSearchTerm - update the search term and decide if this control
|
|
||||||
* should e highlighted or not.
|
|
||||||
* @param search - the text being searched
|
|
||||||
* @return - if this control matched the search term or not
|
|
||||||
*/
|
|
||||||
bool setSearchTerm(QString search);
|
|
||||||
bool qmlVisible() const;
|
|
||||||
|
|
||||||
void updateWidgetVisibility(bool showAdvanced);
|
|
||||||
public slots:
|
|
||||||
void setAdvanced(bool advanced);
|
|
||||||
|
|
||||||
virtual void setDescription(QString desc);
|
|
||||||
virtual void setLabel(QString label) = 0;
|
|
||||||
|
|
||||||
virtual void apply(LaunchConfig* lconfig) const;
|
|
||||||
|
|
||||||
void setKeywords(QStringList keywords);
|
|
||||||
|
|
||||||
void setOption(QString option);
|
|
||||||
|
|
||||||
void setQmlVisible(bool visible);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void advancedChanged(bool advanced);
|
|
||||||
void labelChanged();
|
|
||||||
void descriptionChanged();
|
|
||||||
void keywordsChanged(QStringList keywords);
|
|
||||||
void optionChanged(QString option);
|
|
||||||
|
|
||||||
void qmlVisibleChanged(bool visible);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SettingsControl(QWidget* pr = nullptr);
|
|
||||||
|
|
||||||
void createDescription();
|
|
||||||
|
|
||||||
QString qmlName() const;
|
|
||||||
|
|
||||||
QLabel* m_description = nullptr;
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* pe) override;
|
|
||||||
|
|
||||||
void updateWidgetVisibility();
|
|
||||||
private:
|
|
||||||
bool m_advanced = false;
|
|
||||||
QStringList m_keywords;
|
|
||||||
QString m_option;
|
|
||||||
bool m_localVisible = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsCheckbox : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged)
|
|
||||||
|
|
||||||
bool isChecked() const;
|
|
||||||
|
|
||||||
public:
|
|
||||||
SettingsCheckbox(QWidget* pr = nullptr);
|
|
||||||
|
|
||||||
virtual QString label() const override;
|
|
||||||
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
virtual void apply(LaunchConfig* lconfig) const override;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
public slots:
|
|
||||||
void setChecked(bool checked);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void checkedChanged(bool checked);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QCheckBox* m_check;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsComboBox : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged)
|
|
||||||
Q_PROPERTY(QStringList choices READ choices WRITE setChoices NOTIFY choicesChanged)
|
|
||||||
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel NOTIFY modelChanged)
|
|
||||||
Q_PROPERTY(int defaultIndex READ defaultIndex WRITE setDefaultIndex NOTIFY defaultIndexChanged)
|
|
||||||
public:
|
|
||||||
SettingsComboBox(QWidget* pr = nullptr);
|
|
||||||
|
|
||||||
QStringList choices() const;
|
|
||||||
|
|
||||||
int selectedIndex() const;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
|
|
||||||
QAbstractItemModel* model() const;
|
|
||||||
|
|
||||||
int defaultIndex() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setChoices(QStringList choices);
|
|
||||||
|
|
||||||
void setSelectedIndex(int selectedIndex);
|
|
||||||
|
|
||||||
void setModel(QAbstractItemModel* model);
|
|
||||||
|
|
||||||
void setDefaultIndex(int defaultIndex);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void choicesChanged(QStringList choices);
|
|
||||||
|
|
||||||
void selectedIndexChanged(int selectedIndex);
|
|
||||||
|
|
||||||
void modelChanged(QAbstractItemModel* model);
|
|
||||||
|
|
||||||
void defaultIndexChanged(int defaultIndex);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLabel* m_label;
|
|
||||||
QComboBox* m_combo;
|
|
||||||
QStringList m_choices;
|
|
||||||
int m_selectedIndex = 0;
|
|
||||||
int m_defaultIndex = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsIntSpinbox : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
|
|
||||||
Q_PROPERTY(int min READ min WRITE setMin NOTIFY minChanged)
|
|
||||||
Q_PROPERTY(int max READ max WRITE setMax NOTIFY maxChanged)
|
|
||||||
|
|
||||||
// suffix / wrap information
|
|
||||||
|
|
||||||
public:
|
|
||||||
SettingsIntSpinbox(QWidget* pr = nullptr);
|
|
||||||
|
|
||||||
int value() const;
|
|
||||||
int min() const;
|
|
||||||
int max() const;
|
|
||||||
|
|
||||||
virtual void apply(LaunchConfig* lconfig) const override;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
public slots:
|
|
||||||
void setValue(int value);
|
|
||||||
void setMin(int min);
|
|
||||||
void setMax(int max);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void valueChanged(int value);
|
|
||||||
void minChanged(int min);
|
|
||||||
void maxChanged(int max);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSpinBox* m_spin;
|
|
||||||
QLabel* m_label;
|
|
||||||
int m_value;
|
|
||||||
int m_min;
|
|
||||||
int m_max;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsText : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged)
|
|
||||||
Q_PROPERTY(QString placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(QString validation READ validation WRITE setValidation NOTIFY validationChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
SettingsText(QWidget *pr = nullptr);
|
|
||||||
|
|
||||||
QString value() const;
|
|
||||||
|
|
||||||
virtual void apply(LaunchConfig* lconfig) const override;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
QString placeholder() const;
|
|
||||||
|
|
||||||
QString validation() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setValue(QString value);
|
|
||||||
|
|
||||||
void setPlaceholder(QString placeholder);
|
|
||||||
|
|
||||||
void setValidation(QString validation);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void valueChanged(QString value);
|
|
||||||
|
|
||||||
void placeholderChanged(QString placeholder);
|
|
||||||
|
|
||||||
void validationChanged(QString validation);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLineEdit* m_edit;
|
|
||||||
QLabel* m_label;
|
|
||||||
QString m_validation;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsPath : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
|
||||||
Q_PROPERTY(QString defaultPath READ defaultPath WRITE setDefaultPath
|
|
||||||
NOTIFY defaultPathChanged)
|
|
||||||
Q_PROPERTY(bool chooseDirectory READ chooseDirectory
|
|
||||||
WRITE setChooseDirectory NOTIFY chooseDirectoryChanged)
|
|
||||||
Q_PROPERTY(QString dialogPrompt READ dialogPrompt
|
|
||||||
WRITE setDialogPrompt NOTIFY dialogPromptChanged)
|
|
||||||
Q_PROPERTY(QString option READ option WRITE setOption NOTIFY optionChanged)
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
SettingsPath(QWidget *pr = nullptr);
|
|
||||||
|
|
||||||
QString path() const;
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
virtual void apply(LaunchConfig* lconfig) const override;
|
|
||||||
|
|
||||||
QString defaultPath() const
|
|
||||||
{
|
|
||||||
return m_defaultPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool chooseDirectory() const
|
|
||||||
{
|
|
||||||
return m_chooseDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString dialogPrompt() const
|
|
||||||
{
|
|
||||||
return m_dialogPrompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString option() const
|
|
||||||
{
|
|
||||||
return m_option;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setPath(QString path);
|
|
||||||
void setDefaultPath(QString path);
|
|
||||||
|
|
||||||
void setChooseDirectory(bool chooseDirectory);
|
|
||||||
|
|
||||||
void choosePath();
|
|
||||||
void restoreDefaultPath();
|
|
||||||
void setDialogPrompt(QString dialogPrompt);
|
|
||||||
|
|
||||||
void setOption(QString option);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void defaultPathChanged(QString defaultPath);
|
|
||||||
|
|
||||||
void pathChanged(QString path);
|
|
||||||
|
|
||||||
void chooseDirectoryChanged(bool chooseDirectory);
|
|
||||||
|
|
||||||
void dialogPromptChanged(QString dialogPrompt);
|
|
||||||
|
|
||||||
void optionChanged(QString option);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void updateLabel();
|
|
||||||
|
|
||||||
QPushButton* m_changeButton;
|
|
||||||
QPushButton* m_defaultButton;
|
|
||||||
QString m_path;
|
|
||||||
QString m_defaultPath;
|
|
||||||
QLabel* m_label;
|
|
||||||
QString m_labelPrefix;
|
|
||||||
bool m_chooseDirectory = false;
|
|
||||||
QString m_dialogPrompt;
|
|
||||||
QString m_option;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SettingsDateTime : public SettingsControl
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Q_PROPERTY(QDateTime value READ value WRITE setValue NOTIFY valueChanged)
|
|
||||||
public:
|
|
||||||
SettingsDateTime(QWidget *pr = nullptr);
|
|
||||||
|
|
||||||
virtual void saveState(QSettings& settings) const override;
|
|
||||||
virtual void restoreState(QSettings& settings) override;
|
|
||||||
|
|
||||||
virtual void setLabel(QString label) override;
|
|
||||||
|
|
||||||
QDateTime value() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
void setValue(QDateTime value);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void valueChanged(QDateTime value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QDateTimeEdit* m_edit;
|
|
||||||
QLabel* m_label;
|
|
||||||
QDateTime m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGSWIDGETS_HXX
|
|
|
@ -1,74 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: timeSettings
|
|
||||||
title: "Time & Date"
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: timeOfDay
|
|
||||||
label: qsTr("Time of day")
|
|
||||||
description: qsTr("Select the time of day used when the simulator starts, or enter a "
|
|
||||||
+ "custom date and time.")
|
|
||||||
choices: [qsTr("Current time"), qsTr("Dawn"), qsTr("Morning"), qsTr("Noon"),
|
|
||||||
qsTr("Afternoon"), qsTr("Dusk"), qsTr("Evening"),
|
|
||||||
qsTr("Midnight"), qsTr("Custom time & date")]
|
|
||||||
defaultIndex: 0
|
|
||||||
|
|
||||||
readonly property var args: ["", "dawn", "morning", "noon", "afternoon",
|
|
||||||
"dusk", "evening", "midnight"]
|
|
||||||
|
|
||||||
readonly property bool isCustom: (selectedIndex == 8)
|
|
||||||
readonly property bool isDefault: (selectedIndex == 0)
|
|
||||||
|
|
||||||
function summary()
|
|
||||||
{
|
|
||||||
if (!timeOfDay.isCustom && !timeOfDay.isDefault) {
|
|
||||||
return choices[selectedIndex].toLowerCase() + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime {
|
|
||||||
id: customTime
|
|
||||||
label: qsTr("Enter custom time & date")
|
|
||||||
visible: timeOfDay.isCustom
|
|
||||||
// description: "Enter a date and time."
|
|
||||||
}
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: customTimeIsGMT
|
|
||||||
label: qsTr("Custom time is GMT / UTC")
|
|
||||||
visible: timeOfDay.isCustom
|
|
||||||
}
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: season
|
|
||||||
label: qsTr("Season")
|
|
||||||
description: qsTr("Select if normal (summer) or winter textures are used for the scenery. "
|
|
||||||
+ "This does not affect other aspects of the simulation at present.")
|
|
||||||
keywords: ["season", "scenery", "texture", "winter"]
|
|
||||||
choices: [qsTr("Summer (default)"),
|
|
||||||
qsTr("Winter")]
|
|
||||||
defaultIndex: 0
|
|
||||||
readonly property var args: ["summer", "winter"]
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (timeOfDay.isCustom) {
|
|
||||||
var timeString = Qt.formatDateTime(customTime.value, "yyyy:MM:dd:hh:mm:ss");
|
|
||||||
if (customTimeIsGMT.checked) {
|
|
||||||
_config.setArg("start-date-gmt", timeString)
|
|
||||||
} else {
|
|
||||||
_config.setArg("start-date-sys", timeString)
|
|
||||||
}
|
|
||||||
} else if (timeOfDay.selectedIndex > 0) {
|
|
||||||
_config.setArg("timeofday", timeOfDay.args[timeOfDay.selectedIndex])
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.setArg("season", season.args[season.selectedIndex])
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: timeOfDay.summary()
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: viewSettings
|
|
||||||
title: "View & Window"
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: fullscreen
|
|
||||||
label: qsTr("Start full-screen")
|
|
||||||
description: qsTr("Start the simulator in full-screen mode")
|
|
||||||
keywords: ["window", "full", "screen", "maximize"]
|
|
||||||
option: "fullscreen"
|
|
||||||
}
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: windowSize
|
|
||||||
enabled: !fullscreen.checked
|
|
||||||
label: qsTr("Window size")
|
|
||||||
description: qsTr("Select the initial size of the window (this has no effect in full-screen mode).")
|
|
||||||
advanced: true
|
|
||||||
choices: ["640x480", "800x600", "1024x768", "1920x1080", "2560x1600" ]
|
|
||||||
defaultIndex: 2
|
|
||||||
readonly property bool isDefault: selectedIndex == defaultIndex
|
|
||||||
keywords: ["window", "geometry", "size", "resolution"]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (!windowSize.isDefault) {
|
|
||||||
_config.setArg("geometry", windowSize.choices[windowSize.selectedIndex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: fullscreen.checked ? "full-screen;" : ""
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
import FlightGear.Launcher 1.0
|
|
||||||
import QtQml 2.2
|
|
||||||
|
|
||||||
Section {
|
|
||||||
id: weatherSettings
|
|
||||||
title: "Weather"
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: advancedWeather
|
|
||||||
label: "Advanced weather modelling"
|
|
||||||
description: "Detailed weather simulation based on local terrain and "
|
|
||||||
+ "atmospheric simulation. Note that using advanced weather with "
|
|
||||||
+ "real-world weather data (METAR) information may not show exactly "
|
|
||||||
+ "the conditions recorded, and is not recommended for multi-player "
|
|
||||||
+ "flight since the weather simulation is not shared over the network."
|
|
||||||
}
|
|
||||||
|
|
||||||
Checkbox {
|
|
||||||
id: fetchMetar
|
|
||||||
label: "Real-world weather"
|
|
||||||
description: "Download real-world weather from the NOAA servers based on location."
|
|
||||||
option: "real-weather-fetch"
|
|
||||||
}
|
|
||||||
|
|
||||||
Combo {
|
|
||||||
id: weatherScenario
|
|
||||||
enabled: !fetchMetar.checked
|
|
||||||
label: "Weather scenario"
|
|
||||||
model: _weatherScenarios
|
|
||||||
readonly property bool isCustomMETAR: (selectedIndex == 0);
|
|
||||||
description: _weatherScenarios.descriptionForItem(selectedIndex)
|
|
||||||
defaultIndex: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
LineEdit {
|
|
||||||
id: customMETAR
|
|
||||||
|
|
||||||
property bool __cachedValid: true
|
|
||||||
|
|
||||||
function revalidate() {
|
|
||||||
__cachedValid = _launcher.validateMetarString(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
visible: weatherScenario.isCustomMETAR
|
|
||||||
enabled: !fetchMetar.checked
|
|
||||||
label: "METAR"
|
|
||||||
placeholder: "XXXX 012345Z 28035G50KT 250V300 9999 TSRA SCT022CB BKN030 13/09 Q1005"
|
|
||||||
description: __cachedValid ? "Enter a custom METAR string"
|
|
||||||
: "The entered METAR string doesn't seem to be valid."
|
|
||||||
|
|
||||||
onValueChanged: {
|
|
||||||
validateTimeout.restart()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
id: validateTimeout
|
|
||||||
interval: 200
|
|
||||||
onTriggered: customMETAR.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
onApply: {
|
|
||||||
if (advancedWeather.checked) {
|
|
||||||
// set description from the weather scenarios, so Local-weather
|
|
||||||
// can run the appropriate simulation
|
|
||||||
_config.setProperty("/nasal/local_weather/enabled", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = weatherScenario.selectedIndex;
|
|
||||||
|
|
||||||
if (!fetchMetar.checked) {
|
|
||||||
if (weatherScenario.isCustomMETAR) {
|
|
||||||
_config.setArg("metar", customMETAR.value)
|
|
||||||
} else {
|
|
||||||
_config.setArg("metar", _weatherScenarios.metarForItem(index))
|
|
||||||
}
|
|
||||||
|
|
||||||
// either way, set the scenario name since Local-Weather keys off
|
|
||||||
// this to know what to do with the scenario + metar data
|
|
||||||
_config.setProperty("/environment/weather-scenario",
|
|
||||||
_weatherScenarios.nameForItem(index))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
summary: (advancedWeather.checked ? "advanced weather;" : "")
|
|
||||||
+ (fetchMetar.checked ? "real-world weather;" : "")
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue