1
0
Fork 0

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:
James Turner 2017-04-14 17:36:28 +01:00
parent eefa9a75f9
commit c19fc6bc06
8 changed files with 74 additions and 8 deletions

View file

@ -24,9 +24,22 @@ Section {
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: {
if (startPaused.checked) {
_config.setArg("enable-freeze")
}
if (showConsoleWin.checked) {
_config.setArg("console")
}
}
}

View file

@ -284,6 +284,15 @@ void LauncherMainWindow::initQML()
m_qmlEngine->rootContext()->setContextProperty("_launcher", this);
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);
m_qmlEngine->rootContext()->setContextProperty("_weatherScenarios", weatherScenariosModel);
}

View file

@ -105,10 +105,12 @@ void SettingsSection::internalUpdateAdvanced()
void SettingsSection::saveState(QSettings &settings) const
{
Q_UNUSED(settings)
}
void SettingsSection::restoreState(QSettings &settings)
{
Q_UNUSED(settings)
}
void SettingsSection::updateShowAdvanced()

View file

@ -21,7 +21,7 @@ public:
virtual void setLaunchConfig(LaunchConfig* config);
bool showAdvanced() const
virtual bool showAdvanced() const
{
return m_showAdvanced;
}

View file

@ -19,13 +19,7 @@ void SettingsSectionQML::internalUpdateAdvanced()
{
const bool showAdvanced = m_showAdvanced | m_forceShowAdvanced;
Q_FOREACH (SettingsControl* w, controls()) {
if (w->advanced()) {
w->setVisible(showAdvanced);
}
if (w->property("simple").toBool()) {
w->setVisible(!showAdvanced);
}
w->updateWidgetVisibility(showAdvanced);
}
}
@ -151,6 +145,11 @@ QVariant SettingsSectionQML::restoreSetting(QString key)
return settings.value(key);
}
bool SettingsSectionQML::showAdvanced() const
{
return m_showAdvanced | m_forceShowAdvanced;
}
void SettingsSectionQML::setSummary(QString summary)
{
if (m_summary == summary)

View file

@ -33,6 +33,8 @@ public:
Q_INVOKABLE void saveSetting(QString key, QVariant value);
Q_INVOKABLE QVariant restoreSetting(QString key);
bool showAdvanced() const override;
public slots:
void setSummary(QString summary);

View file

@ -17,6 +17,7 @@
#include <QPainter>
#include "LaunchConfig.hxx"
#include "SettingsSection.hxx"
const int MARGIN_HINT = 4;
@ -64,6 +65,11 @@ bool SettingsControl::setSearchTerm(QString search)
return inSearch;
}
bool SettingsControl::qmlVisible() const
{
return m_localVisible;
}
void SettingsControl::setAdvanced(bool advanced)
{
if (m_advanced == advanced)
@ -104,6 +110,17 @@ void SettingsControl::setOption(QString 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)
{
@ -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) :

View file

@ -24,6 +24,9 @@ class SettingsControl : public QWidget
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
@ -49,6 +52,9 @@ public:
* @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);
@ -61,6 +67,8 @@ public slots:
void setOption(QString option);
void setQmlVisible(bool visible);
signals:
void advancedChanged(bool advanced);
void labelChanged();
@ -68,6 +76,8 @@ signals:
void keywordsChanged(QStringList keywords);
void optionChanged(QString option);
void qmlVisibleChanged(bool visible);
protected:
SettingsControl(QWidget* pr = nullptr);
@ -78,10 +88,13 @@ protected:
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