forked from qt-creator/qt-creator
QmlJSEditor: inline .ui files
qmljscomponentnamedialog.ui qmljseditingsettingspage.ui Change-Id: I3d0410c22c4c08e58fe92cae16d1daf465b3facd Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -6,8 +6,8 @@ add_qtc_plugin(QmlJSEditor
|
||||
qmljsautocompleter.cpp qmljsautocompleter.h
|
||||
qmljscompletionassist.cpp qmljscompletionassist.h
|
||||
qmljscomponentfromobjectdef.cpp qmljscomponentfromobjectdef.h
|
||||
qmljscomponentnamedialog.cpp qmljscomponentnamedialog.h qmljscomponentnamedialog.ui
|
||||
qmljseditingsettingspage.cpp qmljseditingsettingspage.h qmljseditingsettingspage.ui
|
||||
qmljscomponentnamedialog.cpp qmljscomponentnamedialog.h
|
||||
qmljseditingsettingspage.cpp qmljseditingsettingspage.h
|
||||
qmljseditor.cpp qmljseditor.h
|
||||
qmljseditor_global.h
|
||||
qmljseditortr.h
|
||||
|
@@ -2,29 +2,54 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmljscomponentnamedialog.h"
|
||||
#include "ui_qmljscomponentnamedialog.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <utils/classnamevalidatinglineedit.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace QmlJSEditor::Internal;
|
||||
|
||||
ComponentNameDialog::ComponentNameDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ComponentNameDialog)
|
||||
QDialog(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(tr("Move Component into Separate File"));
|
||||
m_componentNameEdit = new Utils::ClassNameValidatingLineEdit;
|
||||
m_componentNameEdit->setPlaceholderText(tr("Component Name"));
|
||||
m_messageLabel = new QLabel;
|
||||
m_pathEdit = new Utils::PathChooser;
|
||||
m_label = new QLabel;
|
||||
m_listWidget = new QListWidget;
|
||||
m_plainTextEdit = new QPlainTextEdit;
|
||||
m_checkBox = new QCheckBox(tr("ui.qml file"));
|
||||
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
connect(ui->pathEdit, &Utils::PathChooser::rawPathChanged,
|
||||
this, &ComponentNameDialog::validate);
|
||||
connect(ui->componentNameEdit, &QLineEdit::textChanged,
|
||||
this, &ComponentNameDialog::validate);
|
||||
}
|
||||
using namespace Utils::Layouting;
|
||||
Column {
|
||||
Form {
|
||||
tr("Component name:"), m_componentNameEdit, br,
|
||||
empty, m_messageLabel, br,
|
||||
tr("Path:"), m_pathEdit, br,
|
||||
},
|
||||
m_label,
|
||||
Row { m_listWidget, m_plainTextEdit },
|
||||
Row { m_checkBox, m_buttonBox },
|
||||
}.attachTo(this);
|
||||
|
||||
ComponentNameDialog::~ComponentNameDialog()
|
||||
{
|
||||
delete ui;
|
||||
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &ComponentNameDialog::accept);
|
||||
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &ComponentNameDialog::reject);
|
||||
connect(m_pathEdit, &Utils::PathChooser::rawPathChanged,
|
||||
this, &ComponentNameDialog::validate);
|
||||
connect(m_componentNameEdit, &QLineEdit::textChanged,
|
||||
this, &ComponentNameDialog::validate);
|
||||
}
|
||||
|
||||
bool ComponentNameDialog::go(QString *proposedName,
|
||||
@@ -42,32 +67,32 @@ bool ComponentNameDialog::go(QString *proposedName,
|
||||
const bool isUiFile = QFileInfo(oldFileName).completeSuffix() == "ui.qml";
|
||||
|
||||
ComponentNameDialog d(parent);
|
||||
d.ui->componentNameEdit->setNamespacesEnabled(false);
|
||||
d.ui->componentNameEdit->setLowerCaseFileName(false);
|
||||
d.ui->componentNameEdit->setForceFirstCapitalLetter(true);
|
||||
d.m_componentNameEdit->setNamespacesEnabled(false);
|
||||
d.m_componentNameEdit->setLowerCaseFileName(false);
|
||||
d.m_componentNameEdit->setForceFirstCapitalLetter(true);
|
||||
if (proposedName->isEmpty())
|
||||
*proposedName = QLatin1String("MyComponent");
|
||||
d.ui->componentNameEdit->setText(*proposedName);
|
||||
d.ui->pathEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
d.ui->pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
|
||||
d.ui->pathEdit->setPath(*proposedPath);
|
||||
d.ui->label->setText(tr("Property assignments for %1:").arg(oldFileName));
|
||||
d.ui->checkBox->setChecked(isUiFile);
|
||||
d.ui->checkBox->setVisible(isUiFile);
|
||||
d.m_componentNameEdit->setText(*proposedName);
|
||||
d.m_pathEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
d.m_pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
|
||||
d.m_pathEdit->setPath(*proposedPath);
|
||||
d.m_label->setText(tr("Property assignments for %1:").arg(oldFileName));
|
||||
d.m_checkBox->setChecked(isUiFile);
|
||||
d.m_checkBox->setVisible(isUiFile);
|
||||
d.m_sourcePreview = sourcePreview;
|
||||
|
||||
d.setProperties(properties);
|
||||
|
||||
d.generateCodePreview();
|
||||
|
||||
d.connect(d.ui->listWidget, &QListWidget::itemChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||
d.connect(d.ui->componentNameEdit, &QLineEdit::textChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||
d.connect(d.m_listWidget, &QListWidget::itemChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||
d.connect(d.m_componentNameEdit, &QLineEdit::textChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||
|
||||
if (QDialog::Accepted == d.exec()) {
|
||||
*proposedName = d.ui->componentNameEdit->text();
|
||||
*proposedPath = d.ui->pathEdit->filePath().toString();
|
||||
*proposedName = d.m_componentNameEdit->text();
|
||||
*proposedPath = d.m_pathEdit->filePath().toString();
|
||||
|
||||
if (d.ui->checkBox->isChecked())
|
||||
if (d.m_checkBox->isChecked())
|
||||
*proposedSuffix = "ui.qml";
|
||||
else
|
||||
*proposedSuffix = "qml";
|
||||
@@ -82,24 +107,24 @@ bool ComponentNameDialog::go(QString *proposedName,
|
||||
|
||||
void ComponentNameDialog::setProperties(const QStringList &properties)
|
||||
{
|
||||
ui->listWidget->addItems(properties);
|
||||
m_listWidget->addItems(properties);
|
||||
|
||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->listWidget->item(i);
|
||||
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = m_listWidget->item(i);
|
||||
item->setFlags(Qt::ItemIsUserCheckable | Qt:: ItemIsEnabled);
|
||||
if (item->text() == QLatin1String("x")
|
||||
|| item->text() == QLatin1String("y"))
|
||||
ui->listWidget->item(i)->setCheckState(Qt::Checked);
|
||||
m_listWidget->item(i)->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->listWidget->item(i)->setCheckState(Qt::Unchecked);
|
||||
m_listWidget->item(i)->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ComponentNameDialog::propertiesToKeep() const
|
||||
{
|
||||
QStringList result;
|
||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->listWidget->item(i);
|
||||
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = m_listWidget->item(i);
|
||||
|
||||
if (item->checkState() == Qt::Checked)
|
||||
result.append(item->text());
|
||||
@@ -110,43 +135,43 @@ QStringList ComponentNameDialog::propertiesToKeep() const
|
||||
|
||||
void ComponentNameDialog::generateCodePreview()
|
||||
{
|
||||
const QString componentName = ui->componentNameEdit->text();
|
||||
const QString componentName = m_componentNameEdit->text();
|
||||
|
||||
ui->plainTextEdit->clear();
|
||||
ui->plainTextEdit->appendPlainText(componentName + QLatin1String(" {"));
|
||||
m_plainTextEdit->clear();
|
||||
m_plainTextEdit->appendPlainText(componentName + QLatin1String(" {"));
|
||||
if (!m_sourcePreview.first().isEmpty())
|
||||
ui->plainTextEdit->appendPlainText(m_sourcePreview.first());
|
||||
m_plainTextEdit->appendPlainText(m_sourcePreview.first());
|
||||
|
||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = ui->listWidget->item(i);
|
||||
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||
QListWidgetItem *item = m_listWidget->item(i);
|
||||
|
||||
if (item->checkState() == Qt::Checked)
|
||||
ui->plainTextEdit->appendPlainText(m_sourcePreview.at(i + 1));
|
||||
m_plainTextEdit->appendPlainText(m_sourcePreview.at(i + 1));
|
||||
}
|
||||
|
||||
ui->plainTextEdit->appendPlainText(QLatin1String("}"));
|
||||
m_plainTextEdit->appendPlainText(QLatin1String("}"));
|
||||
}
|
||||
|
||||
void ComponentNameDialog::validate()
|
||||
{
|
||||
const QString message = isValid();
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(message.isEmpty());
|
||||
ui->messageLabel->setText(message);
|
||||
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(message.isEmpty());
|
||||
m_messageLabel->setText(message);
|
||||
}
|
||||
|
||||
QString ComponentNameDialog::isValid() const
|
||||
{
|
||||
if (!ui->componentNameEdit->isValid())
|
||||
return ui->componentNameEdit->errorMessage();
|
||||
if (!m_componentNameEdit->isValid())
|
||||
return m_componentNameEdit->errorMessage();
|
||||
|
||||
QString compName = ui->componentNameEdit->text();
|
||||
QString compName = m_componentNameEdit->text();
|
||||
if (compName.isEmpty() || !compName[0].isUpper())
|
||||
return tr("Invalid component name.");
|
||||
|
||||
if (!ui->pathEdit->isValid())
|
||||
if (!m_pathEdit->isValid())
|
||||
return tr("Invalid path.");
|
||||
|
||||
if (ui->pathEdit->filePath().pathAppended(compName + ".qml").exists())
|
||||
if (m_pathEdit->filePath().pathAppended(compName + ".qml").exists())
|
||||
return tr("Component already exists.");
|
||||
|
||||
return QString();
|
||||
|
@@ -5,18 +5,28 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QDialogButtonBox;
|
||||
class QLabel;
|
||||
class QListWidget;
|
||||
class QPlainTextEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class ClassNameValidatingLineEdit;
|
||||
class PathChooser;
|
||||
}
|
||||
|
||||
namespace QmlJSEditor {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class ComponentNameDialog; }
|
||||
|
||||
class ComponentNameDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ComponentNameDialog(QWidget *parent = nullptr);
|
||||
~ComponentNameDialog() override;
|
||||
|
||||
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
|
||||
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
|
||||
@@ -35,8 +45,16 @@ protected:
|
||||
QString isValid() const;
|
||||
|
||||
private:
|
||||
Ui::ComponentNameDialog *ui;
|
||||
QStringList m_sourcePreview;
|
||||
|
||||
Utils::ClassNameValidatingLineEdit *m_componentNameEdit;
|
||||
QLabel *m_messageLabel;
|
||||
Utils::PathChooser *m_pathEdit;
|
||||
QLabel *m_label;
|
||||
QListWidget *m_listWidget;
|
||||
QPlainTextEdit *m_plainTextEdit;
|
||||
QCheckBox *m_checkBox;
|
||||
QDialogButtonBox *m_buttonBox;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -1,160 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QmlJSEditor::Internal::ComponentNameDialog</class>
|
||||
<widget class="QDialog" name="QmlJSEditor::Internal::ComponentNameDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>495</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Move Component into Separate File</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Property assignments for</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="componentNameLabel">
|
||||
<property name="text">
|
||||
<string>Component name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Utils::ClassNameValidatingLineEdit" name="componentNameEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Component Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="messageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="choosePathLabel">
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Utils::PathChooser" name="pathEdit" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>ui.qml file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::ClassNameValidatingLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">utils/classnamevalidatinglineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>componentNameEdit</tabstop>
|
||||
<tabstop>listWidget</tabstop>
|
||||
<tabstop>plainTextEdit</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QmlJSEditor::Internal::ComponentNameDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QmlJSEditor::Internal::ComponentNameDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -4,13 +4,15 @@
|
||||
#include "qmljseditingsettingspage.h"
|
||||
#include "qmljseditorconstants.h"
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QSettings>
|
||||
#include <QTextStream>
|
||||
#include <QCheckBox>
|
||||
|
||||
const char AUTO_FORMAT_ON_SAVE[] = "QmlJSEditor.AutoFormatOnSave";
|
||||
const char AUTO_FORMAT_ONLY_CURRENT_PROJECT[] = "QmlJSEditor.AutoFormatOnlyCurrentProject";
|
||||
@@ -134,42 +136,74 @@ void QmlJsEditingSettings::setUiQmlOpenMode(const QString &mode)
|
||||
|
||||
class QmlJsEditingSettingsPageWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlDesigner::Internal::QmlJsEditingSettingsPage)
|
||||
|
||||
public:
|
||||
QmlJsEditingSettingsPageWidget()
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
|
||||
auto s = QmlJsEditingSettings::get();
|
||||
m_ui.textEditHelperCheckBox->setChecked(s.enableContextPane());
|
||||
m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane());
|
||||
m_ui.autoFormatOnSave->setChecked(s.autoFormatOnSave());
|
||||
m_ui.autoFormatOnlyCurrentProject->setChecked(s.autoFormatOnlyCurrentProject());
|
||||
m_ui.foldAuxDataCheckBox->setChecked(s.foldAuxData());
|
||||
m_ui.uiQmlOpenComboBox->addItem(tr("Always Ask"), "");
|
||||
m_ui.uiQmlOpenComboBox->addItem(tr("Qt Design Studio"), Core::Constants::MODE_DESIGN);
|
||||
m_ui.uiQmlOpenComboBox->addItem(tr("Qt Creator"), Core::Constants::MODE_EDIT);
|
||||
int comboIndex = m_ui.uiQmlOpenComboBox->findData(s.uiQmlOpenMode());
|
||||
if (comboIndex < 0)
|
||||
comboIndex = 0;
|
||||
m_ui.uiQmlOpenComboBox->setCurrentIndex(comboIndex);
|
||||
autoFormatOnSave = new QCheckBox(tr("Enable auto format on file save"));
|
||||
autoFormatOnSave->setChecked(s.autoFormatOnSave());
|
||||
autoFormatOnlyCurrentProject =
|
||||
new QCheckBox(tr("Restrict to files contained in the current project"));
|
||||
autoFormatOnlyCurrentProject->setChecked(s.autoFormatOnlyCurrentProject());
|
||||
autoFormatOnlyCurrentProject->setEnabled(autoFormatOnSave->isChecked());
|
||||
pinContextPane = new QCheckBox(tr("Pin Qt Quick Toolbar"));
|
||||
pinContextPane->setChecked(s.pinContextPane());
|
||||
enableContextPane = new QCheckBox(tr("Always show Qt Quick Toolbar"));
|
||||
enableContextPane->setChecked(s.enableContextPane());
|
||||
foldAuxData = new QCheckBox(tr("Auto-fold auxiliary data"));
|
||||
foldAuxData->setChecked(s.foldAuxData());
|
||||
uiQmlOpenComboBox = new QComboBox;
|
||||
uiQmlOpenComboBox->addItem(tr("Always Ask"), "");
|
||||
uiQmlOpenComboBox->addItem(tr("Qt Design Studio"), Core::Constants::MODE_DESIGN);
|
||||
uiQmlOpenComboBox->addItem(tr("Qt Creator"), Core::Constants::MODE_EDIT);
|
||||
const int comboIndex = qMax(0, uiQmlOpenComboBox->findData(s.uiQmlOpenMode()));
|
||||
uiQmlOpenComboBox->setCurrentIndex(comboIndex);
|
||||
uiQmlOpenComboBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
uiQmlOpenComboBox->setSizeAdjustPolicy(QComboBox::QComboBox::AdjustToContents);
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Automatic Formatting on File Save")),
|
||||
Column { autoFormatOnSave, autoFormatOnlyCurrentProject },
|
||||
},
|
||||
Group {
|
||||
title(tr("Qt Quick Toolbars")),
|
||||
Column { pinContextPane, enableContextPane },
|
||||
},
|
||||
Group {
|
||||
title(tr("Features")),
|
||||
Column {
|
||||
foldAuxData,
|
||||
Form { tr("Open .ui.qml files with:"), uiQmlOpenComboBox },
|
||||
},
|
||||
},
|
||||
st,
|
||||
}.attachTo(this);
|
||||
|
||||
connect(autoFormatOnSave, &QCheckBox::toggled,
|
||||
autoFormatOnlyCurrentProject, &QWidget::setEnabled);
|
||||
}
|
||||
|
||||
void apply() final
|
||||
{
|
||||
QmlJsEditingSettings s;
|
||||
s.setEnableContextPane(m_ui.textEditHelperCheckBox->isChecked());
|
||||
s.setPinContextPane(m_ui.textEditHelperCheckBoxPin->isChecked());
|
||||
s.setAutoFormatOnSave(m_ui.autoFormatOnSave->isChecked());
|
||||
s.setAutoFormatOnlyCurrentProject(m_ui.autoFormatOnlyCurrentProject->isChecked());
|
||||
s.setFoldAuxData(m_ui.foldAuxDataCheckBox->isChecked());
|
||||
s.setUiQmlOpenMode(m_ui.uiQmlOpenComboBox->currentData().toString());
|
||||
s.setEnableContextPane(enableContextPane->isChecked());
|
||||
s.setPinContextPane(pinContextPane->isChecked());
|
||||
s.setAutoFormatOnSave(autoFormatOnSave->isChecked());
|
||||
s.setAutoFormatOnlyCurrentProject(autoFormatOnlyCurrentProject->isChecked());
|
||||
s.setFoldAuxData(foldAuxData->isChecked());
|
||||
s.setUiQmlOpenMode(uiQmlOpenComboBox->currentData().toString());
|
||||
s.set();
|
||||
}
|
||||
|
||||
private:
|
||||
Ui::QmlJsEditingSettingsPage m_ui;
|
||||
QCheckBox *autoFormatOnSave;
|
||||
QCheckBox *autoFormatOnlyCurrentProject;
|
||||
QCheckBox *pinContextPane;
|
||||
QCheckBox *enableContextPane;
|
||||
QCheckBox *foldAuxData;
|
||||
QComboBox *uiQmlOpenComboBox;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_qmljseditingsettingspage.h"
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
@@ -1,140 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QmlJSEditor::Internal::QmlJsEditingSettingsPage</class>
|
||||
<widget class="QWidget" name="QmlJSEditor::Internal::QmlJsEditingSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>433</width>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Qt Quick Toolbars</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="textEditHelperCheckBoxPin">
|
||||
<property name="toolTip">
|
||||
<string>If enabled, the toolbar will remain pinned to an absolute position.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pin Qt Quick Toolbar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="textEditHelperCheckBox">
|
||||
<property name="text">
|
||||
<string>Always show Qt Quick Toolbar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Automatic Formatting on File Save</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoFormatOnSave">
|
||||
<property name="text">
|
||||
<string>Enable auto format on file save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoFormatOnlyCurrentProject">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restrict to files contained in the current project</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Features</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="foldAuxDataCheckBox">
|
||||
<property name="text">
|
||||
<string>Auto-fold auxiliary data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="uiQmlLayout">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="uiQmlOpenLabel">
|
||||
<property name="text">
|
||||
<string>Open .ui.qml files with:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QComboBox" name="uiQmlOpenComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>autoFormatOnSave</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>autoFormatOnlyCurrentProject</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>216</x>
|
||||
<y>40</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>216</x>
|
||||
<y>63</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -25,10 +25,8 @@ QtcPlugin {
|
||||
"qmljscomponentfromobjectdef.h",
|
||||
"qmljscomponentnamedialog.cpp",
|
||||
"qmljscomponentnamedialog.h",
|
||||
"qmljscomponentnamedialog.ui",
|
||||
"qmljseditingsettingspage.cpp",
|
||||
"qmljseditingsettingspage.h",
|
||||
"qmljseditingsettingspage.ui",
|
||||
"qmljseditor.cpp",
|
||||
"qmljseditor.h",
|
||||
"qmljseditor_global.h", "qmljseditortr.h",
|
||||
|
Reference in New Issue
Block a user