forked from qt-creator/qt-creator
Beautifier: inline configurationpanel.ui
Change-Id: I1052b52955ba76bc404afa7d2dc5bee01651e2e0 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -17,7 +17,7 @@ add_qtc_plugin(Beautifier
|
||||
clangformat/clangformatsettings.cpp clangformat/clangformatsettings.h
|
||||
configurationdialog.cpp configurationdialog.h configurationdialog.ui
|
||||
configurationeditor.cpp configurationeditor.h
|
||||
configurationpanel.cpp configurationpanel.h configurationpanel.ui
|
||||
configurationpanel.cpp configurationpanel.h
|
||||
generaloptionspage.cpp generaloptionspage.h generaloptionspage.ui
|
||||
generalsettings.cpp generalsettings.h
|
||||
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
|
||||
|
@@ -25,7 +25,6 @@ QtcPlugin {
|
||||
"configurationeditor.h",
|
||||
"configurationpanel.cpp",
|
||||
"configurationpanel.h",
|
||||
"configurationpanel.ui",
|
||||
"generaloptionspage.cpp",
|
||||
"generaloptionspage.h",
|
||||
"generaloptionspage.ui",
|
||||
|
@@ -24,30 +24,46 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "configurationpanel.h"
|
||||
#include "ui_configurationpanel.h"
|
||||
|
||||
#include "abstractsettings.h"
|
||||
#include "configurationdialog.h"
|
||||
|
||||
namespace Beautifier {
|
||||
namespace Internal {
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
ConfigurationPanel::ConfigurationPanel(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ConfigurationPanel)
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace Beautifier::Internal {
|
||||
|
||||
ConfigurationPanel::ConfigurationPanel(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->add, &QPushButton::clicked, this, &ConfigurationPanel::add);
|
||||
connect(ui->edit, &QPushButton::clicked, this, &ConfigurationPanel::edit);
|
||||
connect(ui->remove, &QPushButton::clicked, this, &ConfigurationPanel::remove);
|
||||
connect(ui->configurations, &QComboBox::currentIndexChanged,
|
||||
resize(595, 23);
|
||||
|
||||
m_configurations = new QComboBox;
|
||||
m_configurations->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
m_edit = new QPushButton(tr("Edit"));
|
||||
m_remove = new QPushButton(tr("Remove"));
|
||||
auto add = new QPushButton(tr("Add"));
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
|
||||
Row {
|
||||
m_configurations,
|
||||
m_edit,
|
||||
m_remove,
|
||||
add
|
||||
}.attachTo(this, false);
|
||||
|
||||
connect(add, &QPushButton::clicked, this, &ConfigurationPanel::add);
|
||||
connect(m_edit, &QPushButton::clicked, this, &ConfigurationPanel::edit);
|
||||
connect(m_remove, &QPushButton::clicked, this, &ConfigurationPanel::remove);
|
||||
connect(m_configurations, &QComboBox::currentIndexChanged,
|
||||
this, &ConfigurationPanel::updateButtons);
|
||||
}
|
||||
|
||||
ConfigurationPanel::~ConfigurationPanel()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
ConfigurationPanel::~ConfigurationPanel() = default;
|
||||
|
||||
void ConfigurationPanel::setSettings(AbstractSettings *settings)
|
||||
{
|
||||
@@ -57,19 +73,19 @@ void ConfigurationPanel::setSettings(AbstractSettings *settings)
|
||||
|
||||
void ConfigurationPanel::setCurrentConfiguration(const QString &text)
|
||||
{
|
||||
const int textIndex = ui->configurations->findText(text);
|
||||
const int textIndex = m_configurations->findText(text);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
m_configurations->setCurrentIndex(textIndex);
|
||||
}
|
||||
|
||||
QString ConfigurationPanel::currentConfiguration() const
|
||||
{
|
||||
return ui->configurations->currentText();
|
||||
return m_configurations->currentText();
|
||||
}
|
||||
|
||||
void ConfigurationPanel::remove()
|
||||
{
|
||||
m_settings->removeStyle(ui->configurations->currentText());
|
||||
m_settings->removeStyle(m_configurations->currentText());
|
||||
populateConfigurations();
|
||||
}
|
||||
|
||||
@@ -87,7 +103,7 @@ void ConfigurationPanel::add()
|
||||
|
||||
void ConfigurationPanel::edit()
|
||||
{
|
||||
const QString key = ui->configurations->currentText();
|
||||
const QString key = m_configurations->currentText();
|
||||
ConfigurationDialog dialog;
|
||||
dialog.setWindowTitle(tr("Edit Configuration"));
|
||||
dialog.setSettings(m_settings);
|
||||
@@ -98,30 +114,29 @@ void ConfigurationPanel::edit()
|
||||
m_settings->setStyle(key, dialog.value());
|
||||
} else {
|
||||
m_settings->replaceStyle(key, newKey, dialog.value());
|
||||
ui->configurations->setItemText(ui->configurations->currentIndex(), newKey);
|
||||
m_configurations->setItemText(m_configurations->currentIndex(), newKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurationPanel::populateConfigurations(const QString &key)
|
||||
{
|
||||
QSignalBlocker blocker(ui->configurations);
|
||||
const QString currentText = (!key.isEmpty()) ? key : ui->configurations->currentText();
|
||||
ui->configurations->clear();
|
||||
ui->configurations->addItems(m_settings->styles());
|
||||
const int textIndex = ui->configurations->findText(currentText);
|
||||
QSignalBlocker blocker(m_configurations);
|
||||
const QString currentText = (!key.isEmpty()) ? key : m_configurations->currentText();
|
||||
m_configurations->clear();
|
||||
m_configurations->addItems(m_settings->styles());
|
||||
const int textIndex = m_configurations->findText(currentText);
|
||||
if (textIndex != -1)
|
||||
ui->configurations->setCurrentIndex(textIndex);
|
||||
m_configurations->setCurrentIndex(textIndex);
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void ConfigurationPanel::updateButtons()
|
||||
{
|
||||
const bool enabled = (ui->configurations->count() > 0)
|
||||
&& !m_settings->styleIsReadOnly(ui->configurations->currentText());
|
||||
ui->remove->setEnabled(enabled);
|
||||
ui->edit->setEnabled(enabled);
|
||||
const bool enabled = (m_configurations->count() > 0)
|
||||
&& !m_settings->styleIsReadOnly(m_configurations->currentText());
|
||||
m_remove->setEnabled(enabled);
|
||||
m_edit->setEnabled(enabled);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Beautifier
|
||||
} // Beautifier::Internal
|
||||
|
@@ -27,11 +27,14 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Beautifier {
|
||||
namespace Internal {
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Beautifier::Internal {
|
||||
|
||||
class AbstractSettings;
|
||||
namespace Ui { class ConfigurationPanel; }
|
||||
|
||||
class ConfigurationPanel : public QWidget
|
||||
{
|
||||
@@ -50,10 +53,13 @@ private:
|
||||
void add();
|
||||
void edit();
|
||||
void updateButtons();
|
||||
Ui::ConfigurationPanel *ui;
|
||||
AbstractSettings *m_settings = nullptr;
|
||||
void populateConfigurations(const QString &key = QString());
|
||||
|
||||
AbstractSettings *m_settings = nullptr;
|
||||
|
||||
QComboBox *m_configurations;
|
||||
QPushButton *m_edit;
|
||||
QPushButton *m_remove;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Beautifier
|
||||
} // Beautifier::Internal
|
||||
|
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Beautifier::Internal::ConfigurationPanel</class>
|
||||
<widget class="QWidget" name="Beautifier::Internal::ConfigurationPanel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>595</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="9999,0,0,0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="configurations"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="edit">
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="add">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Reference in New Issue
Block a user