2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-02-09 11:09:11 +01:00
|
|
|
**
|
2015-09-18 11:34:48 +02:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
2016-01-15 14:57:40 +01:00
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-02-09 11:09:11 +01:00
|
|
|
|
2013-03-12 11:49:56 +01:00
|
|
|
#include "settingspage.h"
|
2010-02-09 11:09:11 +01:00
|
|
|
#include "qmldesignerconstants.h"
|
|
|
|
|
#include "qmldesignerplugin.h"
|
2015-07-16 11:49:50 +02:00
|
|
|
#include "designersettings.h"
|
|
|
|
|
#include "puppetcreator.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-02-09 11:09:11 +01:00
|
|
|
|
2011-09-20 16:06:03 +02:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
2014-06-02 16:50:01 +02:00
|
|
|
#include <qmljstools/qmljstoolsconstants.h>
|
2011-09-20 16:06:03 +02:00
|
|
|
|
2015-07-16 11:49:50 +02:00
|
|
|
#include <QLineEdit>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextStream>
|
2015-07-16 11:49:50 +02:00
|
|
|
#include <QMessageBox>
|
2010-02-09 11:09:11 +01:00
|
|
|
|
|
|
|
|
using namespace QmlDesigner;
|
|
|
|
|
using namespace QmlDesigner::Internal;
|
|
|
|
|
|
|
|
|
|
SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
|
|
|
|
|
QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
2016-01-13 18:24:49 +01:00
|
|
|
connect(m_ui.designerEnableDebuggerCheckBox, &QCheckBox::toggled, [=](bool checked) {
|
|
|
|
|
if (checked && ! m_ui.designerShowDebuggerCheckBox->isChecked())
|
|
|
|
|
m_ui.designerShowDebuggerCheckBox->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
);
|
2015-07-16 11:49:50 +02:00
|
|
|
m_ui.resetFallbackPuppetPathButton->hide();
|
2016-01-13 18:24:49 +01:00
|
|
|
connect(m_ui.resetFallbackPuppetPathButton, &QPushButton::clicked, [=]() {
|
|
|
|
|
m_ui.fallbackPuppetPathLineEdit->setPath(
|
|
|
|
|
PuppetCreator::defaultPuppetFallbackDirectory());
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
connect(m_ui.resetQmlPuppetBuildPathButton, &QPushButton::clicked, [=]() {
|
|
|
|
|
m_ui.puppetBuildPathLineEdit->setPath(
|
|
|
|
|
PuppetCreator::defaultPuppetToplevelBuildDirectory());
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
connect(m_ui.useDefaultPuppetRadioButton, &QRadioButton::toggled,
|
|
|
|
|
m_ui.fallbackPuppetPathLineEdit, &QLineEdit::setEnabled);
|
|
|
|
|
connect(m_ui.useQtRelatedPuppetRadioButton, &QRadioButton::toggled,
|
|
|
|
|
m_ui.puppetBuildPathLineEdit, &QLineEdit::setEnabled);
|
|
|
|
|
connect(m_ui.resetStyle, &QPushButton::clicked,
|
|
|
|
|
m_ui.styleLineEdit, &QLineEdit::clear);
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DesignerSettings SettingsPageWidget::settings() const
|
|
|
|
|
{
|
2016-01-13 14:48:40 +01:00
|
|
|
DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
|
|
|
|
|
settings.insert(DesignerSettingsKey::ITEMSPACING, m_ui.spinItemSpacing->value());
|
|
|
|
|
settings.insert(DesignerSettingsKey::CONTAINERPADDING, m_ui.spinSnapMargin->value());
|
|
|
|
|
settings.insert(DesignerSettingsKey::CANVASWIDTH, m_ui.spinCanvasWidth->value());
|
|
|
|
|
settings.insert(DesignerSettingsKey::CANVASHEIGHT, m_ui.spinCanvasHeight->value());
|
|
|
|
|
settings.insert(DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER,
|
|
|
|
|
m_ui.designerWarningsCheckBox->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR,
|
|
|
|
|
m_ui.designerWarningsInEditorCheckBox->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::SHOW_DEBUGVIEW,
|
|
|
|
|
m_ui.designerShowDebuggerCheckBox->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::ENABLE_DEBUGVIEW,
|
|
|
|
|
m_ui.designerEnableDebuggerCheckBox->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET,
|
|
|
|
|
m_ui.useDefaultPuppetRadioButton->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::USE_QSTR_FUNCTION,
|
|
|
|
|
m_ui.useQsTrFunctionRadioButton->isChecked());
|
|
|
|
|
settings.insert(DesignerSettingsKey::CONTROLS_STYLE, m_ui.styleLineEdit->text());
|
2015-07-16 11:49:50 +02:00
|
|
|
|
|
|
|
|
if (!m_ui.fallbackPuppetPathLineEdit->path().isEmpty() &&
|
|
|
|
|
m_ui.fallbackPuppetPathLineEdit->path() != PuppetCreator::defaultPuppetFallbackDirectory()) {
|
2016-01-13 14:48:40 +01:00
|
|
|
settings.insert(DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY,
|
|
|
|
|
m_ui.fallbackPuppetPathLineEdit->path());
|
2015-07-16 11:49:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_ui.puppetBuildPathLineEdit->path().isEmpty() &&
|
|
|
|
|
m_ui.puppetBuildPathLineEdit->path() != PuppetCreator::defaultPuppetToplevelBuildDirectory()) {
|
2016-01-13 14:48:40 +01:00
|
|
|
settings.insert(DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY,
|
|
|
|
|
m_ui.puppetBuildPathLineEdit->path());
|
2015-07-16 11:49:50 +02:00
|
|
|
}
|
2012-10-26 13:57:58 +02:00
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
return settings;
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|
|
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
void SettingsPageWidget::setSettings(const DesignerSettings &settings)
|
2010-02-09 11:09:11 +01:00
|
|
|
{
|
2016-01-13 14:48:40 +01:00
|
|
|
m_ui.spinItemSpacing->setValue(settings.value(
|
|
|
|
|
DesignerSettingsKey::ITEMSPACING).toInt());
|
|
|
|
|
m_ui.spinSnapMargin->setValue(settings.value(
|
|
|
|
|
DesignerSettingsKey::CONTAINERPADDING).toInt());
|
|
|
|
|
m_ui.spinCanvasWidth->setValue(settings.value(
|
|
|
|
|
DesignerSettingsKey::CANVASWIDTH).toInt());
|
|
|
|
|
m_ui.spinCanvasHeight->setValue(settings.value(
|
|
|
|
|
DesignerSettingsKey::CANVASHEIGHT).toInt());
|
|
|
|
|
m_ui.designerWarningsCheckBox->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::WARNING_FOR_FEATURES_IN_DESIGNER).toBool());
|
|
|
|
|
m_ui.designerWarningsInEditorCheckBox->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::WARNING_FOR_DESIGNER_FEATURES_IN_EDITOR).toBool());
|
|
|
|
|
m_ui.designerShowDebuggerCheckBox->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::SHOW_DEBUGVIEW).toBool());
|
|
|
|
|
m_ui.designerEnableDebuggerCheckBox->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::ENABLE_DEBUGVIEW).toBool());
|
|
|
|
|
m_ui.useDefaultPuppetRadioButton->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET).toBool());
|
|
|
|
|
m_ui.useQtRelatedPuppetRadioButton->setChecked(!settings.value(
|
|
|
|
|
DesignerSettingsKey::USE_ONLY_FALLBACK_PUPPET).toBool());
|
|
|
|
|
m_ui.useQsTrFunctionRadioButton->setChecked(settings.value(
|
|
|
|
|
DesignerSettingsKey::USE_QSTR_FUNCTION).toBool());
|
|
|
|
|
m_ui.useQsTrIdFunctionRadioButton->setChecked(!settings.value(
|
|
|
|
|
DesignerSettingsKey::USE_QSTR_FUNCTION).toBool());
|
|
|
|
|
m_ui.styleLineEdit->setText(settings.value(
|
|
|
|
|
DesignerSettingsKey::CONTROLS_STYLE).toString());
|
|
|
|
|
|
|
|
|
|
QString puppetFallbackDirectory = settings.value(
|
2016-01-13 18:24:49 +01:00
|
|
|
DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY,
|
|
|
|
|
PuppetCreator::defaultPuppetFallbackDirectory()).toString();
|
|
|
|
|
m_ui.fallbackPuppetPathLineEdit->setPath(puppetFallbackDirectory);
|
2015-07-16 11:49:50 +02:00
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
QString puppetToplevelBuildDirectory = settings.value(
|
2016-01-13 18:24:49 +01:00
|
|
|
DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY,
|
|
|
|
|
PuppetCreator::defaultPuppetToplevelBuildDirectory()).toString();
|
|
|
|
|
m_ui.puppetBuildPathLineEdit->setPath(puppetToplevelBuildDirectory);
|
2013-03-14 16:02:19 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:09:11 +01:00
|
|
|
SettingsPage::SettingsPage() :
|
|
|
|
|
m_widget(0)
|
|
|
|
|
{
|
2013-01-16 15:22:58 +01:00
|
|
|
setId("B.QmlDesigner");
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayName(tr("Qt Quick Designer"));
|
2012-12-29 03:37:27 +01:00
|
|
|
setCategory(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML);
|
2012-05-22 11:17:13 +02:00
|
|
|
setDisplayCategory(QCoreApplication::translate("QmlJSEditor",
|
|
|
|
|
QmlJSEditor::Constants::SETTINGS_TR_CATEGORY_QML));
|
2014-06-02 16:50:01 +02:00
|
|
|
setCategoryIcon(QLatin1String(QmlJSTools::Constants::SETTINGS_CATEGORY_QML_ICON));
|
2010-03-26 17:34:10 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
QWidget *SettingsPage::widget()
|
2010-02-09 11:09:11 +01:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
if (!m_widget) {
|
|
|
|
|
m_widget = new SettingsPageWidget;
|
|
|
|
|
m_widget->setSettings(QmlDesignerPlugin::instance()->settings());
|
|
|
|
|
}
|
2010-02-09 11:09:11 +01:00
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SettingsPage::apply()
|
|
|
|
|
{
|
2010-12-02 18:28:16 +01:00
|
|
|
if (!m_widget) // page was never shown
|
|
|
|
|
return;
|
2015-07-16 11:49:50 +02:00
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
DesignerSettings currentSettings(QmlDesignerPlugin::instance()->settings());
|
|
|
|
|
DesignerSettings newSettings(m_widget->settings());
|
|
|
|
|
|
2016-01-13 18:24:49 +01:00
|
|
|
QList<QByteArray> restartNecessaryKeys;
|
|
|
|
|
restartNecessaryKeys << DesignerSettingsKey::PUPPET_FALLBACK_DIRECTORY
|
|
|
|
|
<< DesignerSettingsKey::PUPPET_TOPLEVEL_BUILD_DIRECTORY;
|
|
|
|
|
|
|
|
|
|
foreach (const QByteArray &key, restartNecessaryKeys) {
|
|
|
|
|
if (currentSettings.value(key) != newSettings.value(key)) {
|
|
|
|
|
QMessageBox::information(Core::ICore::mainWindow(), tr("Restart Required"),
|
|
|
|
|
tr("The QML emulation layer path changes will take effect after a "
|
|
|
|
|
"restart of the QML Emulation layer or Qt Creator."));
|
|
|
|
|
break;
|
|
|
|
|
}
|
2015-07-16 11:49:50 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-13 14:48:40 +01:00
|
|
|
QmlDesignerPlugin::instance()->setSettings(newSettings);
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-03 14:17:03 +01:00
|
|
|
void SettingsPage::finish()
|
2010-02-09 11:09:11 +01:00
|
|
|
{
|
2013-12-03 14:17:03 +01:00
|
|
|
delete m_widget;
|
2010-02-09 11:09:11 +01:00
|
|
|
}
|