forked from qt-creator/qt-creator
Beautifier: Inline configurationdialog.ui
This slightly changes the setup by removing the horizontal splitter which does not really serve a good purpose on a freely resizable top-level dialog. Change-Id: I1ba418dc9173af54aadab5e98144673b55544e8f Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -15,7 +15,7 @@ add_qtc_plugin(Beautifier
|
|||||||
clangformat/clangformatconstants.h
|
clangformat/clangformatconstants.h
|
||||||
clangformat/clangformatoptionspage.cpp clangformat/clangformatoptionspage.h
|
clangformat/clangformatoptionspage.cpp clangformat/clangformatoptionspage.h
|
||||||
clangformat/clangformatsettings.cpp clangformat/clangformatsettings.h
|
clangformat/clangformatsettings.cpp clangformat/clangformatsettings.h
|
||||||
configurationdialog.cpp configurationdialog.h configurationdialog.ui
|
configurationdialog.cpp configurationdialog.h
|
||||||
configurationeditor.cpp configurationeditor.h
|
configurationeditor.cpp configurationeditor.h
|
||||||
configurationpanel.cpp configurationpanel.h
|
configurationpanel.cpp configurationpanel.h
|
||||||
generaloptionspage.cpp generaloptionspage.h
|
generaloptionspage.cpp generaloptionspage.h
|
||||||
|
@@ -20,7 +20,6 @@ QtcPlugin {
|
|||||||
"beautifierplugin.h",
|
"beautifierplugin.h",
|
||||||
"configurationdialog.cpp",
|
"configurationdialog.cpp",
|
||||||
"configurationdialog.h",
|
"configurationdialog.h",
|
||||||
"configurationdialog.ui",
|
|
||||||
"configurationeditor.cpp",
|
"configurationeditor.cpp",
|
||||||
"configurationeditor.h",
|
"configurationeditor.h",
|
||||||
"configurationpanel.cpp",
|
"configurationpanel.cpp",
|
||||||
|
@@ -24,34 +24,73 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "configurationdialog.h"
|
#include "configurationdialog.h"
|
||||||
#include "ui_configurationdialog.h"
|
|
||||||
|
|
||||||
#include "abstractsettings.h"
|
#include "abstractsettings.h"
|
||||||
|
#include "configurationeditor.h"
|
||||||
|
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpressionValidator>
|
#include <QRegularExpressionValidator>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
namespace Beautifier {
|
namespace Beautifier::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
|
ConfigurationDialog::ConfigurationDialog(QWidget *parent)
|
||||||
QDialog(parent),
|
: QDialog(parent)
|
||||||
ui(new Ui::ConfigurationDialog)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
resize(640, 512);
|
||||||
|
|
||||||
|
m_name = new QLineEdit;
|
||||||
|
|
||||||
|
m_editor = new ConfigurationEditor;
|
||||||
|
|
||||||
|
m_documentationHeader = new QLabel;
|
||||||
|
|
||||||
|
m_documentation = new QTextEdit;
|
||||||
|
m_documentation->setReadOnly(true);
|
||||||
|
|
||||||
|
m_buttonBox = new QDialogButtonBox(this);
|
||||||
|
m_buttonBox->setOrientation(Qt::Horizontal);
|
||||||
|
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
Title(tr("Name")),
|
||||||
|
Column { m_name }
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
Title(tr("Value")),
|
||||||
|
Column {
|
||||||
|
m_editor,
|
||||||
|
m_documentationHeader,
|
||||||
|
m_documentation
|
||||||
|
}
|
||||||
|
},
|
||||||
|
m_buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
// Filter out characters which are not allowed in a file name
|
// Filter out characters which are not allowed in a file name
|
||||||
QRegularExpressionValidator *fileNameValidator = new QRegularExpressionValidator(
|
QRegularExpressionValidator *fileNameValidator = new QRegularExpressionValidator(
|
||||||
QRegularExpression("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$"), ui->name);
|
QRegularExpression("^[^\\/\\\\\\?\\>\\<\\*\\%\\:\\\"\\']*$"), m_name);
|
||||||
ui->name->setValidator(fileNameValidator);
|
m_name->setValidator(fileNameValidator);
|
||||||
|
|
||||||
updateDocumentation();
|
updateDocumentation();
|
||||||
connect(ui->name, &QLineEdit::textChanged, this, &ConfigurationDialog::updateOkButton);
|
connect(m_name, &QLineEdit::textChanged, this, &ConfigurationDialog::updateOkButton);
|
||||||
updateOkButton(); // force initial test.
|
updateOkButton(); // force initial test.
|
||||||
connect(ui->editor, &ConfigurationEditor::documentationChanged,
|
connect(m_editor, &ConfigurationEditor::documentationChanged,
|
||||||
this, &ConfigurationDialog::updateDocumentation);
|
this, &ConfigurationDialog::updateDocumentation);
|
||||||
|
|
||||||
// Set palette and font according to settings
|
// Set palette and font according to settings
|
||||||
@@ -66,11 +105,11 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
|
|||||||
if (selectionFormat.background().style() != Qt::NoBrush)
|
if (selectionFormat.background().style() != Qt::NoBrush)
|
||||||
pal.setColor(QPalette::Highlight, selectionFormat.background().color());
|
pal.setColor(QPalette::Highlight, selectionFormat.background().color());
|
||||||
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
|
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
|
||||||
ui->documentation->setPalette(pal);
|
m_documentation->setPalette(pal);
|
||||||
ui->editor->setPalette(pal);
|
m_editor->setPalette(pal);
|
||||||
|
|
||||||
ui->documentation->setFont(tf.font());
|
m_documentation->setFont(tf.font());
|
||||||
ui->editor->setFont(tf.font());
|
m_editor->setFont(tf.font());
|
||||||
|
|
||||||
// Set style sheet for documentation browser
|
// Set style sheet for documentation browser
|
||||||
const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD);
|
const QTextCharFormat tfOption = fs.toTextCharFormat(TextEditor::C_FIELD);
|
||||||
@@ -85,63 +124,59 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
|
|||||||
.arg(tfOption.foreground().color().name())
|
.arg(tfOption.foreground().color().name())
|
||||||
.arg(tfOption.background().style() == Qt::NoBrush
|
.arg(tfOption.background().style() == Qt::NoBrush
|
||||||
? QString() : tfOption.background().color().name());
|
? QString() : tfOption.background().color().name());
|
||||||
ui->documentation->document()->setDefaultStyleSheet(css);
|
m_documentation->document()->setDefaultStyleSheet(css);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationDialog::~ConfigurationDialog()
|
ConfigurationDialog::~ConfigurationDialog() = default;
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigurationDialog::setSettings(AbstractSettings *settings)
|
void ConfigurationDialog::setSettings(AbstractSettings *settings)
|
||||||
{
|
{
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
ui->editor->setSettings(m_settings);
|
m_editor->setSettings(m_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationDialog::clear()
|
void ConfigurationDialog::clear()
|
||||||
{
|
{
|
||||||
ui->name->clear();
|
m_name->clear();
|
||||||
ui->editor->clear();
|
m_editor->clear();
|
||||||
m_currentKey.clear();
|
m_currentKey.clear();
|
||||||
updateOkButton();
|
updateOkButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigurationDialog::key() const
|
QString ConfigurationDialog::key() const
|
||||||
{
|
{
|
||||||
return ui->name->text().simplified();
|
return m_name->text().simplified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationDialog::setKey(const QString &key)
|
void ConfigurationDialog::setKey(const QString &key)
|
||||||
{
|
{
|
||||||
m_currentKey = key;
|
m_currentKey = key;
|
||||||
ui->name->setText(m_currentKey);
|
m_name->setText(m_currentKey);
|
||||||
if (m_settings)
|
if (m_settings)
|
||||||
ui->editor->setPlainText(m_settings->style(m_currentKey));
|
m_editor->setPlainText(m_settings->style(m_currentKey));
|
||||||
else
|
else
|
||||||
ui->editor->clear();
|
m_editor->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigurationDialog::value() const
|
QString ConfigurationDialog::value() const
|
||||||
{
|
{
|
||||||
return ui->editor->toPlainText();
|
return m_editor->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationDialog::updateOkButton()
|
void ConfigurationDialog::updateOkButton()
|
||||||
{
|
{
|
||||||
const QString key = ui->name->text().simplified();
|
const QString key = m_name->text().simplified();
|
||||||
const bool exists = m_settings && key != m_currentKey && m_settings->styleExists(key);
|
const bool exists = m_settings && key != m_currentKey && m_settings->styleExists(key);
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!(key.isEmpty() || exists));
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!(key.isEmpty() || exists));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationDialog::updateDocumentation(const QString &word, const QString &docu)
|
void ConfigurationDialog::updateDocumentation(const QString &word, const QString &docu)
|
||||||
{
|
{
|
||||||
if (word.isEmpty())
|
if (word.isEmpty())
|
||||||
ui->documentationHeader->setText(tr("Documentation"));
|
m_documentationHeader->setText(tr("Documentation"));
|
||||||
else
|
else
|
||||||
ui->documentationHeader->setText(tr("Documentation for \"%1\"").arg(word));
|
m_documentationHeader->setText(tr("Documentation for \"%1\"").arg(word));
|
||||||
ui->documentation->setHtml(docu);
|
m_documentation->setHtml(docu);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Beautifier::Internal
|
||||||
} // namespace Beautifier
|
|
||||||
|
@@ -26,13 +26,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace Beautifier {
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Internal {
|
class QDialogButtonBox;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
class QTextEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Beautifier::Internal {
|
||||||
|
|
||||||
class AbstractSettings;
|
class AbstractSettings;
|
||||||
namespace Ui { class ConfigurationDialog; }
|
class ConfigurationEditor;
|
||||||
|
|
||||||
class ConfigurationDialog : public QDialog
|
class ConfigurationDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -51,11 +56,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
void updateOkButton();
|
void updateOkButton();
|
||||||
void updateDocumentation(const QString &word = QString(), const QString &docu = QString());
|
void updateDocumentation(const QString &word = QString(), const QString &docu = QString());
|
||||||
Ui::ConfigurationDialog *ui;
|
|
||||||
AbstractSettings *m_settings = nullptr;
|
AbstractSettings *m_settings = nullptr;
|
||||||
QString m_currentKey;
|
QString m_currentKey;
|
||||||
|
|
||||||
|
QLineEdit *m_name;
|
||||||
|
ConfigurationEditor *m_editor;
|
||||||
|
QLabel *m_documentationHeader;
|
||||||
|
QTextEdit *m_documentation;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // Beautifier::Internal
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Beautifier
|
|
||||||
|
@@ -1,118 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Beautifier::Internal::ConfigurationDialog</class>
|
|
||||||
<widget class="QDialog" name="Beautifier::Internal::ConfigurationDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>640</width>
|
|
||||||
<height>512</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="name"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Value</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QSplitter" name="splitter">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="childrenCollapsible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<widget class="Beautifier::Internal::ConfigurationEditor" name="editor"/>
|
|
||||||
<widget class="QWidget" name="layoutWidget">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="documentationHeader">
|
|
||||||
<property name="text">
|
|
||||||
<string>Documentation</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="documentation">
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<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>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Beautifier::Internal::ConfigurationEditor</class>
|
|
||||||
<extends>QPlainTextEdit</extends>
|
|
||||||
<header location="global">beautifier/configurationeditor.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Beautifier::Internal::ConfigurationDialog</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>Beautifier::Internal::ConfigurationDialog</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>
|
|
Reference in New Issue
Block a user