ProjectExplorer: Base KitAspectWidget on BaseAspect

Enables re-using existing functionality.

The "Make mutable" functionality is still oddly placed. I doubt people
find and use it actively.

Change-Id: Ic6aae17e3a7df093f0f5f234f1e6e1afc196a087
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-04-07 18:55:21 +02:00
parent 2727016f1d
commit 77481f25ce
14 changed files with 182 additions and 121 deletions

View File

@@ -31,6 +31,7 @@
#include <projectexplorer/kitmanager.h>
#include <utils/elidinglabel.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
#include <QPushButton>
@@ -46,8 +47,8 @@ class AspectWidget final : public KitAspectWidget
public:
AspectWidget(Kit *kit, const KitAspect *kitInfo)
: KitAspectWidget(kit, kitInfo),
m_contentLabel(new Utils::ElidingLabel),
m_changeButton(new QPushButton(tr("Change...")))
m_contentLabel(createSubWidget<Utils::ElidingLabel>()),
m_changeButton(createSubWidget<QPushButton>(tr("Change...")))
{
connect(m_changeButton, &QPushButton::clicked, this, &AspectWidget::changeProperties);
}
@@ -55,8 +56,13 @@ public:
private:
void makeReadOnly() override { m_changeButton->setEnabled(false); }
void refresh() override { m_contentLabel->setText(QbsKitAspect::representation(kit())); }
QWidget *mainWidget() const override { return m_contentLabel; }
QWidget *buttonWidget() const override { return m_changeButton; }
void addToLayout(Utils::LayoutBuilder &builder) override
{
addMutableAction(m_contentLabel);
builder.addItem(m_contentLabel);
builder.addItem(m_changeButton);
}
void changeProperties()
{