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
|
qmljsautocompleter.cpp qmljsautocompleter.h
|
||||||
qmljscompletionassist.cpp qmljscompletionassist.h
|
qmljscompletionassist.cpp qmljscompletionassist.h
|
||||||
qmljscomponentfromobjectdef.cpp qmljscomponentfromobjectdef.h
|
qmljscomponentfromobjectdef.cpp qmljscomponentfromobjectdef.h
|
||||||
qmljscomponentnamedialog.cpp qmljscomponentnamedialog.h qmljscomponentnamedialog.ui
|
qmljscomponentnamedialog.cpp qmljscomponentnamedialog.h
|
||||||
qmljseditingsettingspage.cpp qmljseditingsettingspage.h qmljseditingsettingspage.ui
|
qmljseditingsettingspage.cpp qmljseditingsettingspage.h
|
||||||
qmljseditor.cpp qmljseditor.h
|
qmljseditor.cpp qmljseditor.h
|
||||||
qmljseditor_global.h
|
qmljseditor_global.h
|
||||||
qmljseditortr.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
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "qmljscomponentnamedialog.h"
|
#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 <QFileDialog>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
|
|
||||||
ComponentNameDialog::ComponentNameDialog(QWidget *parent) :
|
ComponentNameDialog::ComponentNameDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent)
|
||||||
ui(new Ui::ComponentNameDialog)
|
|
||||||
{
|
{
|
||||||
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,
|
using namespace Utils::Layouting;
|
||||||
this, &ComponentNameDialog::validate);
|
Column {
|
||||||
connect(ui->componentNameEdit, &QLineEdit::textChanged,
|
Form {
|
||||||
this, &ComponentNameDialog::validate);
|
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()
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &ComponentNameDialog::accept);
|
||||||
{
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &ComponentNameDialog::reject);
|
||||||
delete ui;
|
connect(m_pathEdit, &Utils::PathChooser::rawPathChanged,
|
||||||
|
this, &ComponentNameDialog::validate);
|
||||||
|
connect(m_componentNameEdit, &QLineEdit::textChanged,
|
||||||
|
this, &ComponentNameDialog::validate);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ComponentNameDialog::go(QString *proposedName,
|
bool ComponentNameDialog::go(QString *proposedName,
|
||||||
@@ -42,32 +67,32 @@ bool ComponentNameDialog::go(QString *proposedName,
|
|||||||
const bool isUiFile = QFileInfo(oldFileName).completeSuffix() == "ui.qml";
|
const bool isUiFile = QFileInfo(oldFileName).completeSuffix() == "ui.qml";
|
||||||
|
|
||||||
ComponentNameDialog d(parent);
|
ComponentNameDialog d(parent);
|
||||||
d.ui->componentNameEdit->setNamespacesEnabled(false);
|
d.m_componentNameEdit->setNamespacesEnabled(false);
|
||||||
d.ui->componentNameEdit->setLowerCaseFileName(false);
|
d.m_componentNameEdit->setLowerCaseFileName(false);
|
||||||
d.ui->componentNameEdit->setForceFirstCapitalLetter(true);
|
d.m_componentNameEdit->setForceFirstCapitalLetter(true);
|
||||||
if (proposedName->isEmpty())
|
if (proposedName->isEmpty())
|
||||||
*proposedName = QLatin1String("MyComponent");
|
*proposedName = QLatin1String("MyComponent");
|
||||||
d.ui->componentNameEdit->setText(*proposedName);
|
d.m_componentNameEdit->setText(*proposedName);
|
||||||
d.ui->pathEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
d.m_pathEdit->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||||
d.ui->pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
|
d.m_pathEdit->setHistoryCompleter(QLatin1String("QmlJs.Component.History"));
|
||||||
d.ui->pathEdit->setPath(*proposedPath);
|
d.m_pathEdit->setPath(*proposedPath);
|
||||||
d.ui->label->setText(tr("Property assignments for %1:").arg(oldFileName));
|
d.m_label->setText(tr("Property assignments for %1:").arg(oldFileName));
|
||||||
d.ui->checkBox->setChecked(isUiFile);
|
d.m_checkBox->setChecked(isUiFile);
|
||||||
d.ui->checkBox->setVisible(isUiFile);
|
d.m_checkBox->setVisible(isUiFile);
|
||||||
d.m_sourcePreview = sourcePreview;
|
d.m_sourcePreview = sourcePreview;
|
||||||
|
|
||||||
d.setProperties(properties);
|
d.setProperties(properties);
|
||||||
|
|
||||||
d.generateCodePreview();
|
d.generateCodePreview();
|
||||||
|
|
||||||
d.connect(d.ui->listWidget, &QListWidget::itemChanged, &d, &ComponentNameDialog::generateCodePreview);
|
d.connect(d.m_listWidget, &QListWidget::itemChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||||
d.connect(d.ui->componentNameEdit, &QLineEdit::textChanged, &d, &ComponentNameDialog::generateCodePreview);
|
d.connect(d.m_componentNameEdit, &QLineEdit::textChanged, &d, &ComponentNameDialog::generateCodePreview);
|
||||||
|
|
||||||
if (QDialog::Accepted == d.exec()) {
|
if (QDialog::Accepted == d.exec()) {
|
||||||
*proposedName = d.ui->componentNameEdit->text();
|
*proposedName = d.m_componentNameEdit->text();
|
||||||
*proposedPath = d.ui->pathEdit->filePath().toString();
|
*proposedPath = d.m_pathEdit->filePath().toString();
|
||||||
|
|
||||||
if (d.ui->checkBox->isChecked())
|
if (d.m_checkBox->isChecked())
|
||||||
*proposedSuffix = "ui.qml";
|
*proposedSuffix = "ui.qml";
|
||||||
else
|
else
|
||||||
*proposedSuffix = "qml";
|
*proposedSuffix = "qml";
|
||||||
@@ -82,24 +107,24 @@ bool ComponentNameDialog::go(QString *proposedName,
|
|||||||
|
|
||||||
void ComponentNameDialog::setProperties(const QStringList &properties)
|
void ComponentNameDialog::setProperties(const QStringList &properties)
|
||||||
{
|
{
|
||||||
ui->listWidget->addItems(properties);
|
m_listWidget->addItems(properties);
|
||||||
|
|
||||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||||
QListWidgetItem *item = ui->listWidget->item(i);
|
QListWidgetItem *item = m_listWidget->item(i);
|
||||||
item->setFlags(Qt::ItemIsUserCheckable | Qt:: ItemIsEnabled);
|
item->setFlags(Qt::ItemIsUserCheckable | Qt:: ItemIsEnabled);
|
||||||
if (item->text() == QLatin1String("x")
|
if (item->text() == QLatin1String("x")
|
||||||
|| item->text() == QLatin1String("y"))
|
|| item->text() == QLatin1String("y"))
|
||||||
ui->listWidget->item(i)->setCheckState(Qt::Checked);
|
m_listWidget->item(i)->setCheckState(Qt::Checked);
|
||||||
else
|
else
|
||||||
ui->listWidget->item(i)->setCheckState(Qt::Unchecked);
|
m_listWidget->item(i)->setCheckState(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ComponentNameDialog::propertiesToKeep() const
|
QStringList ComponentNameDialog::propertiesToKeep() const
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (int i = 0; i < ui->listWidget->count(); ++i) {
|
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||||
QListWidgetItem *item = ui->listWidget->item(i);
|
QListWidgetItem *item = m_listWidget->item(i);
|
||||||
|
|
||||||
if (item->checkState() == Qt::Checked)
|
if (item->checkState() == Qt::Checked)
|
||||||
result.append(item->text());
|
result.append(item->text());
|
||||||
@@ -110,43 +135,43 @@ QStringList ComponentNameDialog::propertiesToKeep() const
|
|||||||
|
|
||||||
void ComponentNameDialog::generateCodePreview()
|
void ComponentNameDialog::generateCodePreview()
|
||||||
{
|
{
|
||||||
const QString componentName = ui->componentNameEdit->text();
|
const QString componentName = m_componentNameEdit->text();
|
||||||
|
|
||||||
ui->plainTextEdit->clear();
|
m_plainTextEdit->clear();
|
||||||
ui->plainTextEdit->appendPlainText(componentName + QLatin1String(" {"));
|
m_plainTextEdit->appendPlainText(componentName + QLatin1String(" {"));
|
||||||
if (!m_sourcePreview.first().isEmpty())
|
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) {
|
for (int i = 0; i < m_listWidget->count(); ++i) {
|
||||||
QListWidgetItem *item = ui->listWidget->item(i);
|
QListWidgetItem *item = m_listWidget->item(i);
|
||||||
|
|
||||||
if (item->checkState() == Qt::Checked)
|
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()
|
void ComponentNameDialog::validate()
|
||||||
{
|
{
|
||||||
const QString message = isValid();
|
const QString message = isValid();
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(message.isEmpty());
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(message.isEmpty());
|
||||||
ui->messageLabel->setText(message);
|
m_messageLabel->setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ComponentNameDialog::isValid() const
|
QString ComponentNameDialog::isValid() const
|
||||||
{
|
{
|
||||||
if (!ui->componentNameEdit->isValid())
|
if (!m_componentNameEdit->isValid())
|
||||||
return ui->componentNameEdit->errorMessage();
|
return m_componentNameEdit->errorMessage();
|
||||||
|
|
||||||
QString compName = ui->componentNameEdit->text();
|
QString compName = m_componentNameEdit->text();
|
||||||
if (compName.isEmpty() || !compName[0].isUpper())
|
if (compName.isEmpty() || !compName[0].isUpper())
|
||||||
return tr("Invalid component name.");
|
return tr("Invalid component name.");
|
||||||
|
|
||||||
if (!ui->pathEdit->isValid())
|
if (!m_pathEdit->isValid())
|
||||||
return tr("Invalid path.");
|
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 tr("Component already exists.");
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
|
@@ -5,18 +5,28 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#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 QmlJSEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace Ui { class ComponentNameDialog; }
|
|
||||||
|
|
||||||
class ComponentNameDialog : public QDialog
|
class ComponentNameDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ComponentNameDialog(QWidget *parent = nullptr);
|
explicit ComponentNameDialog(QWidget *parent = nullptr);
|
||||||
~ComponentNameDialog() override;
|
|
||||||
|
|
||||||
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
|
static bool go(QString *proposedName, QString *proposedPath, QString *proposedSuffix,
|
||||||
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
|
const QStringList &properties, const QStringList &sourcePreview, const QString &oldFileName,
|
||||||
@@ -35,8 +45,16 @@ protected:
|
|||||||
QString isValid() const;
|
QString isValid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ComponentNameDialog *ui;
|
|
||||||
QStringList m_sourcePreview;
|
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
|
} // 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 "qmljseditingsettingspage.h"
|
||||||
#include "qmljseditorconstants.h"
|
#include "qmljseditorconstants.h"
|
||||||
|
|
||||||
#include <qmljstools/qmljstoolsconstants.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <qmljstools/qmljstoolsconstants.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QCheckBox>
|
|
||||||
|
|
||||||
const char AUTO_FORMAT_ON_SAVE[] = "QmlJSEditor.AutoFormatOnSave";
|
const char AUTO_FORMAT_ON_SAVE[] = "QmlJSEditor.AutoFormatOnSave";
|
||||||
const char AUTO_FORMAT_ONLY_CURRENT_PROJECT[] = "QmlJSEditor.AutoFormatOnlyCurrentProject";
|
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
|
class QmlJsEditingSettingsPageWidget final : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(QmlDesigner::Internal::QmlJsEditingSettingsPage)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlJsEditingSettingsPageWidget()
|
QmlJsEditingSettingsPageWidget()
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
|
||||||
|
|
||||||
auto s = QmlJsEditingSettings::get();
|
auto s = QmlJsEditingSettings::get();
|
||||||
m_ui.textEditHelperCheckBox->setChecked(s.enableContextPane());
|
autoFormatOnSave = new QCheckBox(tr("Enable auto format on file save"));
|
||||||
m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane());
|
autoFormatOnSave->setChecked(s.autoFormatOnSave());
|
||||||
m_ui.autoFormatOnSave->setChecked(s.autoFormatOnSave());
|
autoFormatOnlyCurrentProject =
|
||||||
m_ui.autoFormatOnlyCurrentProject->setChecked(s.autoFormatOnlyCurrentProject());
|
new QCheckBox(tr("Restrict to files contained in the current project"));
|
||||||
m_ui.foldAuxDataCheckBox->setChecked(s.foldAuxData());
|
autoFormatOnlyCurrentProject->setChecked(s.autoFormatOnlyCurrentProject());
|
||||||
m_ui.uiQmlOpenComboBox->addItem(tr("Always Ask"), "");
|
autoFormatOnlyCurrentProject->setEnabled(autoFormatOnSave->isChecked());
|
||||||
m_ui.uiQmlOpenComboBox->addItem(tr("Qt Design Studio"), Core::Constants::MODE_DESIGN);
|
pinContextPane = new QCheckBox(tr("Pin Qt Quick Toolbar"));
|
||||||
m_ui.uiQmlOpenComboBox->addItem(tr("Qt Creator"), Core::Constants::MODE_EDIT);
|
pinContextPane->setChecked(s.pinContextPane());
|
||||||
int comboIndex = m_ui.uiQmlOpenComboBox->findData(s.uiQmlOpenMode());
|
enableContextPane = new QCheckBox(tr("Always show Qt Quick Toolbar"));
|
||||||
if (comboIndex < 0)
|
enableContextPane->setChecked(s.enableContextPane());
|
||||||
comboIndex = 0;
|
foldAuxData = new QCheckBox(tr("Auto-fold auxiliary data"));
|
||||||
m_ui.uiQmlOpenComboBox->setCurrentIndex(comboIndex);
|
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
|
void apply() final
|
||||||
{
|
{
|
||||||
QmlJsEditingSettings s;
|
QmlJsEditingSettings s;
|
||||||
s.setEnableContextPane(m_ui.textEditHelperCheckBox->isChecked());
|
s.setEnableContextPane(enableContextPane->isChecked());
|
||||||
s.setPinContextPane(m_ui.textEditHelperCheckBoxPin->isChecked());
|
s.setPinContextPane(pinContextPane->isChecked());
|
||||||
s.setAutoFormatOnSave(m_ui.autoFormatOnSave->isChecked());
|
s.setAutoFormatOnSave(autoFormatOnSave->isChecked());
|
||||||
s.setAutoFormatOnlyCurrentProject(m_ui.autoFormatOnlyCurrentProject->isChecked());
|
s.setAutoFormatOnlyCurrentProject(autoFormatOnlyCurrentProject->isChecked());
|
||||||
s.setFoldAuxData(m_ui.foldAuxDataCheckBox->isChecked());
|
s.setFoldAuxData(foldAuxData->isChecked());
|
||||||
s.setUiQmlOpenMode(m_ui.uiQmlOpenComboBox->currentData().toString());
|
s.setUiQmlOpenMode(uiQmlOpenComboBox->currentData().toString());
|
||||||
s.set();
|
s.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::QmlJsEditingSettingsPage m_ui;
|
QCheckBox *autoFormatOnSave;
|
||||||
|
QCheckBox *autoFormatOnlyCurrentProject;
|
||||||
|
QCheckBox *pinContextPane;
|
||||||
|
QCheckBox *enableContextPane;
|
||||||
|
QCheckBox *foldAuxData;
|
||||||
|
QComboBox *uiQmlOpenComboBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_qmljseditingsettingspage.h"
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#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",
|
"qmljscomponentfromobjectdef.h",
|
||||||
"qmljscomponentnamedialog.cpp",
|
"qmljscomponentnamedialog.cpp",
|
||||||
"qmljscomponentnamedialog.h",
|
"qmljscomponentnamedialog.h",
|
||||||
"qmljscomponentnamedialog.ui",
|
|
||||||
"qmljseditingsettingspage.cpp",
|
"qmljseditingsettingspage.cpp",
|
||||||
"qmljseditingsettingspage.h",
|
"qmljseditingsettingspage.h",
|
||||||
"qmljseditingsettingspage.ui",
|
|
||||||
"qmljseditor.cpp",
|
"qmljseditor.cpp",
|
||||||
"qmljseditor.h",
|
"qmljseditor.h",
|
||||||
"qmljseditor_global.h", "qmljseditortr.h",
|
"qmljseditor_global.h", "qmljseditortr.h",
|
||||||
|
Reference in New Issue
Block a user