diff --git a/src/plugins/qbsprojectmanager/CMakeLists.txt b/src/plugins/qbsprojectmanager/CMakeLists.txt index 2caeb08b889..8fcc680abae 100644 --- a/src/plugins/qbsprojectmanager/CMakeLists.txt +++ b/src/plugins/qbsprojectmanager/CMakeLists.txt @@ -4,7 +4,7 @@ add_qtc_plugin(QbsProjectManager IDE_LIBRARY_BASENAME="${IDE_LIBRARY_BASE_PATH}" PLUGIN_DEPENDS Core ProjectExplorer CppEditor QtSupport QmlJSTools SOURCES - customqbspropertiesdialog.cpp customqbspropertiesdialog.h customqbspropertiesdialog.ui + customqbspropertiesdialog.cpp customqbspropertiesdialog.h defaultpropertyprovider.cpp defaultpropertyprovider.h propertyprovider.h qbsbuildconfiguration.cpp qbsbuildconfiguration.h diff --git a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp b/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp index 39605ec11a1..cb9f5dac529 100644 --- a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp +++ b/src/plugins/qbsprojectmanager/customqbspropertiesdialog.cpp @@ -2,80 +2,103 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "customqbspropertiesdialog.h" -#include "ui_customqbspropertiesdialog.h" #include "qbsprofilemanager.h" #include +#include #include +#include +#include +#include #include namespace QbsProjectManager { namespace Internal { CustomQbsPropertiesDialog::CustomQbsPropertiesDialog(const QVariantMap &properties, QWidget *parent) - : QDialog(parent), m_ui(new Ui::CustomQbsPropertiesDialog) + : QDialog(parent) { - m_ui->setupUi(this); - m_ui->propertiesTable->setRowCount(properties.count()); - m_ui->propertiesTable->setHorizontalHeaderLabels(QStringList() << tr("Key") << tr("Value")); + setWindowTitle(tr("Custom Properties")); + + m_propertiesTable = new QTableWidget; + m_propertiesTable->setColumnCount(2); + m_propertiesTable->setRowCount(properties.count()); + m_propertiesTable->setHorizontalHeaderLabels(QStringList() << tr("Key") << tr("Value")); + m_propertiesTable->horizontalHeader()->setStretchLastSection(true); + m_propertiesTable->verticalHeader()->setVisible(false); int currentRow = 0; for (QVariantMap::ConstIterator it = properties.constBegin(); it != properties.constEnd(); ++it) { auto * const nameItem = new QTableWidgetItem; nameItem->setData(Qt::DisplayRole, it.key()); - m_ui->propertiesTable->setItem(currentRow, 0, nameItem); + m_propertiesTable->setItem(currentRow, 0, nameItem); auto * const valueItem = new QTableWidgetItem; valueItem->setData(Qt::DisplayRole, toJSLiteral(it.value())); - m_ui->propertiesTable->setItem(currentRow, 1, valueItem); + m_propertiesTable->setItem(currentRow, 1, valueItem); ++currentRow; } - connect(m_ui->addButton, &QAbstractButton::clicked, - this, &CustomQbsPropertiesDialog::addProperty); - connect(m_ui->removeButton, &QAbstractButton::clicked, + m_removeButton = new QPushButton(tr("&Remove")); + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + using namespace Utils::Layouting; + Column { + Row { + m_propertiesTable, + Column { + PushButton { + text(tr("&Add")), + onClicked([this] { addProperty(); } ), + }, + m_removeButton, + st + }, + }, + buttonBox, + }.attachTo(this); + + connect(m_removeButton, &QAbstractButton::clicked, this, &CustomQbsPropertiesDialog::removeSelectedProperty); - connect(m_ui->propertiesTable, &QTableWidget::currentItemChanged, + connect(m_propertiesTable, &QTableWidget::currentItemChanged, this, &CustomQbsPropertiesDialog::handleCurrentItemChanged); + connect(buttonBox, &QDialogButtonBox::accepted, this, &CustomQbsPropertiesDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &CustomQbsPropertiesDialog::reject); + handleCurrentItemChanged(); } QVariantMap CustomQbsPropertiesDialog::properties() const { QVariantMap properties; - for (int row = 0; row < m_ui->propertiesTable->rowCount(); ++row) { - const QTableWidgetItem * const nameItem = m_ui->propertiesTable->item(row, 0); + for (int row = 0; row < m_propertiesTable->rowCount(); ++row) { + const QTableWidgetItem * const nameItem = m_propertiesTable->item(row, 0); const QString name = nameItem->text(); if (name.isEmpty()) continue; - properties.insert(name, fromJSLiteral(m_ui->propertiesTable->item(row, 1)->text())); + properties.insert(name, fromJSLiteral(m_propertiesTable->item(row, 1)->text())); } return properties; } -CustomQbsPropertiesDialog::~CustomQbsPropertiesDialog() -{ - delete m_ui; -} - void CustomQbsPropertiesDialog::addProperty() { - const int row = m_ui->propertiesTable->rowCount(); - m_ui->propertiesTable->insertRow(row); - m_ui->propertiesTable->setItem(row, 0, new QTableWidgetItem); - m_ui->propertiesTable->setItem(row, 1, new QTableWidgetItem); + const int row = m_propertiesTable->rowCount(); + m_propertiesTable->insertRow(row); + m_propertiesTable->setItem(row, 0, new QTableWidgetItem); + m_propertiesTable->setItem(row, 1, new QTableWidgetItem); } void CustomQbsPropertiesDialog::removeSelectedProperty() { - const QTableWidgetItem * const currentItem = m_ui->propertiesTable->currentItem(); + const QTableWidgetItem * const currentItem = m_propertiesTable->currentItem(); QTC_ASSERT(currentItem, return); - m_ui->propertiesTable->removeRow(currentItem->row()); + m_propertiesTable->removeRow(currentItem->row()); } void CustomQbsPropertiesDialog::handleCurrentItemChanged() { - m_ui->removeButton->setEnabled(m_ui->propertiesTable->currentItem()); + m_removeButton->setEnabled(m_propertiesTable->currentItem()); } } // namespace Internal diff --git a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.h b/src/plugins/qbsprojectmanager/customqbspropertiesdialog.h index 83ab7a97586..a503c56e6d4 100644 --- a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.h +++ b/src/plugins/qbsprojectmanager/customqbspropertiesdialog.h @@ -6,9 +6,12 @@ #include #include +QT_BEGIN_NAMESPACE +class QTableWidget; +QT_END_NAMESPACE + namespace QbsProjectManager { namespace Internal { -namespace Ui { class CustomQbsPropertiesDialog; } class CustomQbsPropertiesDialog : public QDialog { @@ -18,7 +21,6 @@ public: explicit CustomQbsPropertiesDialog(const QVariantMap &properties, QWidget *parent = nullptr); QVariantMap properties() const; - ~CustomQbsPropertiesDialog() override; private: void addProperty(); @@ -26,7 +28,8 @@ private: void handleCurrentItemChanged(); private: - Ui::CustomQbsPropertiesDialog * const m_ui; + QTableWidget *m_propertiesTable; + QPushButton *m_removeButton; }; } // namespace Internal diff --git a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.ui b/src/plugins/qbsprojectmanager/customqbspropertiesdialog.ui deleted file mode 100644 index b18a460ab0f..00000000000 --- a/src/plugins/qbsprojectmanager/customqbspropertiesdialog.ui +++ /dev/null @@ -1,120 +0,0 @@ - - - QbsProjectManager::Internal::CustomQbsPropertiesDialog - - - - 0 - 0 - 400 - 300 - - - - Custom Properties - - - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectItems - - - 2 - - - true - - - false - - - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - QbsProjectManager::Internal::CustomQbsPropertiesDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - QbsProjectManager::Internal::CustomQbsPropertiesDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs index cadfe8e46f4..99c4345f452 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs @@ -21,7 +21,6 @@ QtcPlugin { files: [ "customqbspropertiesdialog.h", "customqbspropertiesdialog.cpp", - "customqbspropertiesdialog.ui", "defaultpropertyprovider.cpp", "defaultpropertyprovider.h", "propertyprovider.h",