Launcher: add ‘show console’ setting on Windows
This entailed fixing the handling of the visibility property with an override from the QWidget basic version.
This commit is contained in:
parent
eefa9a75f9
commit
c19fc6bc06
8 changed files with 74 additions and 8 deletions
|
@ -24,9 +24,22 @@ Section {
|
||||||
option: "auto-coordination"
|
option: "auto-coordination"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checkbox {
|
||||||
|
id: showConsoleWin
|
||||||
|
label: "Show debugging console"
|
||||||
|
description: "Open a console window showing debug output from the application."
|
||||||
|
advanced: true
|
||||||
|
visible: _osName == "win"
|
||||||
|
keywords: ["console"]
|
||||||
|
}
|
||||||
|
|
||||||
onApply: {
|
onApply: {
|
||||||
if (startPaused.checked) {
|
if (startPaused.checked) {
|
||||||
_config.setArg("enable-freeze")
|
_config.setArg("enable-freeze")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showConsoleWin.checked) {
|
||||||
|
_config.setArg("console")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,15 @@ void LauncherMainWindow::initQML()
|
||||||
m_qmlEngine->rootContext()->setContextProperty("_launcher", this);
|
m_qmlEngine->rootContext()->setContextProperty("_launcher", this);
|
||||||
m_qmlEngine->rootContext()->setContextProperty("_mpServers", m_serversModel);
|
m_qmlEngine->rootContext()->setContextProperty("_mpServers", m_serversModel);
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
const QString osName("win");
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
const QString osName("mac");
|
||||||
|
#else
|
||||||
|
const QString osName("unix");
|
||||||
|
#endif
|
||||||
|
m_qmlEngine->rootContext()->setContextProperty("_osName", osName);
|
||||||
|
|
||||||
flightgear::WeatherScenariosModel* weatherScenariosModel = new flightgear::WeatherScenariosModel(this);
|
flightgear::WeatherScenariosModel* weatherScenariosModel = new flightgear::WeatherScenariosModel(this);
|
||||||
m_qmlEngine->rootContext()->setContextProperty("_weatherScenarios", weatherScenariosModel);
|
m_qmlEngine->rootContext()->setContextProperty("_weatherScenarios", weatherScenariosModel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,10 +105,12 @@ void SettingsSection::internalUpdateAdvanced()
|
||||||
|
|
||||||
void SettingsSection::saveState(QSettings &settings) const
|
void SettingsSection::saveState(QSettings &settings) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsSection::restoreState(QSettings &settings)
|
void SettingsSection::restoreState(QSettings &settings)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsSection::updateShowAdvanced()
|
void SettingsSection::updateShowAdvanced()
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
|
|
||||||
virtual void setLaunchConfig(LaunchConfig* config);
|
virtual void setLaunchConfig(LaunchConfig* config);
|
||||||
|
|
||||||
bool showAdvanced() const
|
virtual bool showAdvanced() const
|
||||||
{
|
{
|
||||||
return m_showAdvanced;
|
return m_showAdvanced;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,7 @@ void SettingsSectionQML::internalUpdateAdvanced()
|
||||||
{
|
{
|
||||||
const bool showAdvanced = m_showAdvanced | m_forceShowAdvanced;
|
const bool showAdvanced = m_showAdvanced | m_forceShowAdvanced;
|
||||||
Q_FOREACH (SettingsControl* w, controls()) {
|
Q_FOREACH (SettingsControl* w, controls()) {
|
||||||
if (w->advanced()) {
|
w->updateWidgetVisibility(showAdvanced);
|
||||||
w->setVisible(showAdvanced);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w->property("simple").toBool()) {
|
|
||||||
w->setVisible(!showAdvanced);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,6 +145,11 @@ QVariant SettingsSectionQML::restoreSetting(QString key)
|
||||||
return settings.value(key);
|
return settings.value(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsSectionQML::showAdvanced() const
|
||||||
|
{
|
||||||
|
return m_showAdvanced | m_forceShowAdvanced;
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsSectionQML::setSummary(QString summary)
|
void SettingsSectionQML::setSummary(QString summary)
|
||||||
{
|
{
|
||||||
if (m_summary == summary)
|
if (m_summary == summary)
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void saveSetting(QString key, QVariant value);
|
Q_INVOKABLE void saveSetting(QString key, QVariant value);
|
||||||
Q_INVOKABLE QVariant restoreSetting(QString key);
|
Q_INVOKABLE QVariant restoreSetting(QString key);
|
||||||
|
|
||||||
|
bool showAdvanced() const override;
|
||||||
public slots:
|
public slots:
|
||||||
void setSummary(QString summary);
|
void setSummary(QString summary);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
#include "LaunchConfig.hxx"
|
#include "LaunchConfig.hxx"
|
||||||
|
#include "SettingsSection.hxx"
|
||||||
|
|
||||||
const int MARGIN_HINT = 4;
|
const int MARGIN_HINT = 4;
|
||||||
|
|
||||||
|
@ -64,6 +65,11 @@ bool SettingsControl::setSearchTerm(QString search)
|
||||||
return inSearch;
|
return inSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsControl::qmlVisible() const
|
||||||
|
{
|
||||||
|
return m_localVisible;
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsControl::setAdvanced(bool advanced)
|
void SettingsControl::setAdvanced(bool advanced)
|
||||||
{
|
{
|
||||||
if (m_advanced == advanced)
|
if (m_advanced == advanced)
|
||||||
|
@ -104,6 +110,17 @@ void SettingsControl::setOption(QString option)
|
||||||
emit optionChanged(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) :
|
SettingsControl::SettingsControl(QWidget *pr) :
|
||||||
QWidget(pr)
|
QWidget(pr)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +156,17 @@ void SettingsControl::paintEvent(QPaintEvent *pe)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) :
|
SettingsCheckbox::SettingsCheckbox(QWidget* parent) :
|
||||||
|
|
|
@ -24,6 +24,9 @@ class SettingsControl : public QWidget
|
||||||
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
|
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
|
||||||
Q_PROPERTY(QStringList keywords READ keywords WRITE setKeywords NOTIFY keywordsChanged)
|
Q_PROPERTY(QStringList keywords READ keywords WRITE setKeywords NOTIFY keywordsChanged)
|
||||||
Q_PROPERTY(QString option READ option WRITE setOption NOTIFY optionChanged)
|
Q_PROPERTY(QString option READ option WRITE setOption NOTIFY optionChanged)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool visible READ qmlVisible WRITE setQmlVisible NOTIFY qmlVisibleChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool advanced() const
|
bool advanced() const
|
||||||
|
@ -49,6 +52,9 @@ public:
|
||||||
* @return - if this control matched the search term or not
|
* @return - if this control matched the search term or not
|
||||||
*/
|
*/
|
||||||
bool setSearchTerm(QString search);
|
bool setSearchTerm(QString search);
|
||||||
|
bool qmlVisible() const;
|
||||||
|
|
||||||
|
void updateWidgetVisibility(bool showAdvanced);
|
||||||
public slots:
|
public slots:
|
||||||
void setAdvanced(bool advanced);
|
void setAdvanced(bool advanced);
|
||||||
|
|
||||||
|
@ -61,6 +67,8 @@ public slots:
|
||||||
|
|
||||||
void setOption(QString option);
|
void setOption(QString option);
|
||||||
|
|
||||||
|
void setQmlVisible(bool visible);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void advancedChanged(bool advanced);
|
void advancedChanged(bool advanced);
|
||||||
void labelChanged();
|
void labelChanged();
|
||||||
|
@ -68,6 +76,8 @@ signals:
|
||||||
void keywordsChanged(QStringList keywords);
|
void keywordsChanged(QStringList keywords);
|
||||||
void optionChanged(QString option);
|
void optionChanged(QString option);
|
||||||
|
|
||||||
|
void qmlVisibleChanged(bool visible);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SettingsControl(QWidget* pr = nullptr);
|
SettingsControl(QWidget* pr = nullptr);
|
||||||
|
|
||||||
|
@ -78,10 +88,13 @@ protected:
|
||||||
QLabel* m_description = nullptr;
|
QLabel* m_description = nullptr;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* pe) override;
|
void paintEvent(QPaintEvent* pe) override;
|
||||||
|
|
||||||
|
void updateWidgetVisibility();
|
||||||
private:
|
private:
|
||||||
bool m_advanced = false;
|
bool m_advanced = false;
|
||||||
QStringList m_keywords;
|
QStringList m_keywords;
|
||||||
QString m_option;
|
QString m_option;
|
||||||
|
bool m_localVisible = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SettingsCheckbox : public SettingsControl
|
class SettingsCheckbox : public SettingsControl
|
||||||
|
|
Loading…
Reference in a new issue