forked from qt-creator/qt-creator
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:
@@ -47,6 +47,7 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/elidinglabel.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/variablechooser.h>
|
||||
@@ -87,8 +88,8 @@ class CMakeKitAspectWidget final : public KitAspectWidget
|
||||
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeKitAspect)
|
||||
public:
|
||||
CMakeKitAspectWidget(Kit *kit, const KitAspect *ki) : KitAspectWidget(kit, ki),
|
||||
m_comboBox(new QComboBox),
|
||||
m_manageButton(new QPushButton(KitAspectWidget::msgManage()))
|
||||
m_comboBox(createSubWidget<QComboBox>()),
|
||||
m_manageButton(createSubWidget<QPushButton>(KitAspectWidget::msgManage()))
|
||||
{
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
||||
m_comboBox->setEnabled(false);
|
||||
@@ -124,8 +125,13 @@ public:
|
||||
private:
|
||||
// KitAspectWidget interface
|
||||
void makeReadOnly() override { m_comboBox->setEnabled(false); }
|
||||
QWidget *mainWidget() const override { return m_comboBox; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
|
||||
void addToLayout(Utils::LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_comboBox);
|
||||
builder.addItem(m_comboBox);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
@@ -205,7 +211,7 @@ private:
|
||||
|
||||
void manageCMakeTools()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGS_PAGE_ID, buttonWidget());
|
||||
Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGS_PAGE_ID, m_manageButton);
|
||||
}
|
||||
|
||||
bool m_removingItem = false;
|
||||
@@ -334,8 +340,8 @@ class CMakeGeneratorKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
CMakeGeneratorKitAspectWidget(Kit *kit, const ::KitAspect *ki)
|
||||
: KitAspectWidget(kit, ki),
|
||||
m_label(new Utils::ElidingLabel),
|
||||
m_changeButton(new QPushButton)
|
||||
m_label(createSubWidget<Utils::ElidingLabel>()),
|
||||
m_changeButton(createSubWidget<QPushButton>())
|
||||
{
|
||||
m_label->setToolTip(ki->description());
|
||||
m_changeButton->setText(tr("Change..."));
|
||||
@@ -353,8 +359,13 @@ public:
|
||||
private:
|
||||
// KitAspectWidget interface
|
||||
void makeReadOnly() override { m_changeButton->setEnabled(false); }
|
||||
QWidget *mainWidget() const override { return m_label; }
|
||||
QWidget *buttonWidget() const override { return m_changeButton; }
|
||||
|
||||
void addToLayout(Utils::LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_label);
|
||||
builder.addItem(m_label);
|
||||
builder.addItem(m_changeButton);
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
@@ -851,8 +862,8 @@ class CMakeConfigurationKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
CMakeConfigurationKitAspectWidget(Kit *kit, const KitAspect *ki)
|
||||
: KitAspectWidget(kit, ki),
|
||||
m_summaryLabel(new Utils::ElidingLabel),
|
||||
m_manageButton(new QPushButton)
|
||||
m_summaryLabel(createSubWidget<Utils::ElidingLabel>()),
|
||||
m_manageButton(createSubWidget<QPushButton>())
|
||||
{
|
||||
refresh();
|
||||
m_manageButton->setText(tr("Change..."));
|
||||
@@ -862,8 +873,12 @@ public:
|
||||
|
||||
private:
|
||||
// KitAspectWidget interface
|
||||
QWidget *mainWidget() const override { return m_summaryLabel; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
void addToLayout(Utils::LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_summaryLabel);
|
||||
builder.addItem(m_summaryLabel);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void makeReadOnly() override
|
||||
{
|
||||
|
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
DebuggerKitAspectWidget(Kit *workingCopy, const KitAspect *ki)
|
||||
: KitAspectWidget(workingCopy, ki)
|
||||
{
|
||||
m_comboBox = new QComboBox;
|
||||
m_comboBox = createSubWidget<QComboBox>();
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
||||
m_comboBox->setEnabled(true);
|
||||
|
||||
@@ -72,7 +73,7 @@ public:
|
||||
connect(m_comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this, &DebuggerKitAspectWidget::currentDebuggerChanged);
|
||||
|
||||
m_manageButton = new QPushButton(KitAspectWidget::msgManage());
|
||||
m_manageButton = createSubWidget<QPushButton>(KitAspectWidget::msgManage());
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
connect(m_manageButton, &QAbstractButton::clicked,
|
||||
this, &DebuggerKitAspectWidget::manageDebuggers);
|
||||
@@ -85,8 +86,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
QWidget *mainWidget() const override { return m_comboBox; }
|
||||
void addToLayout(Utils::LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_comboBox);
|
||||
builder.addItem(m_comboBox);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void makeReadOnly() override
|
||||
{
|
||||
@@ -110,7 +115,7 @@ private:
|
||||
void manageDebuggers()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(ProjectExplorer::Constants::DEBUGGER_SETTINGS_PAGE_ID,
|
||||
buttonWidget());
|
||||
m_manageButton);
|
||||
}
|
||||
|
||||
void currentDebuggerChanged(int idx)
|
||||
|
@@ -1254,20 +1254,11 @@ class McuDependenciesKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
McuDependenciesKitAspectWidget(Kit *workingCopy, const KitAspect *ki)
|
||||
: KitAspectWidget(workingCopy, ki)
|
||||
{
|
||||
m_emptyWidget = new QWidget();
|
||||
}
|
||||
{}
|
||||
|
||||
~McuDependenciesKitAspectWidget() override {
|
||||
delete m_emptyWidget;
|
||||
}
|
||||
void makeReadOnly() override {}
|
||||
void refresh() override {}
|
||||
QWidget *mainWidget() const override {
|
||||
return m_emptyWidget;
|
||||
}
|
||||
private:
|
||||
QWidget *m_emptyWidget;
|
||||
void addToLayout(Utils::LayoutBuilder &) override {}
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
@@ -39,8 +39,8 @@ ToolKitAspectWidget::ToolKitAspectWidget(ProjectExplorer::Kit *kit,
|
||||
const ProjectExplorer::KitAspect *ki,
|
||||
ToolType type)
|
||||
: ProjectExplorer::KitAspectWidget(kit, ki)
|
||||
, m_toolsComboBox{new QComboBox}
|
||||
, m_manageButton(new QPushButton(KitAspectWidget::msgManage()))
|
||||
, m_toolsComboBox(createSubWidget<QComboBox>())
|
||||
, m_manageButton(createSubWidget<QPushButton>(KitAspectWidget::msgManage()))
|
||||
, m_type{type}
|
||||
{
|
||||
m_toolsComboBox->setSizePolicy(QSizePolicy::Ignored,
|
||||
@@ -51,7 +51,7 @@ ToolKitAspectWidget::ToolKitAspectWidget(ProjectExplorer::Kit *kit,
|
||||
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
connect(m_manageButton, &QPushButton::clicked, this, [this]() {
|
||||
Core::ICore::showOptionsDialog(Constants::SettingsPage::TOOLS_ID, buttonWidget());
|
||||
Core::ICore::showOptionsDialog(Constants::SettingsPage::TOOLS_ID, m_manageButton);
|
||||
});
|
||||
|
||||
connect(MesonTools::instance(),
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QPushButton>
|
||||
@@ -58,8 +60,14 @@ private:
|
||||
void setToDefault();
|
||||
|
||||
void makeReadOnly() override { m_toolsComboBox->setEnabled(false); }
|
||||
QWidget *mainWidget() const override { return m_toolsComboBox; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
|
||||
void addToLayout(Utils::LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_toolsComboBox);
|
||||
builder.addItem(m_toolsComboBox);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
const auto id = [this]() {
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <utils/elidinglabel.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/environmentdialog.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -56,6 +57,8 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
const char KITINFORMATION_ID_V3[] = "PE.Profile.ToolChainsV3";
|
||||
@@ -72,7 +75,7 @@ class SysRootKitAspectWidget : public KitAspectWidget
|
||||
public:
|
||||
SysRootKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki)
|
||||
{
|
||||
m_chooser = new Utils::PathChooser;
|
||||
m_chooser = createSubWidget<PathChooser>();
|
||||
m_chooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
m_chooser->setHistoryCompleter(QLatin1String("PE.SysRoot.History"));
|
||||
m_chooser->setFilePath(SysRootKitAspect::sysRoot(k));
|
||||
@@ -84,8 +87,12 @@ public:
|
||||
|
||||
private:
|
||||
void makeReadOnly() override { m_chooser->setReadOnly(true); }
|
||||
QWidget *buttonWidget() const override { return m_chooser->buttonAtIndex(0); }
|
||||
QWidget *mainWidget() const override { return m_chooser->lineEdit(); }
|
||||
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_chooser);
|
||||
builder.addItem(Layouting::Span(2, m_chooser));
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
@@ -212,7 +219,7 @@ class ToolChainKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
ToolChainKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki)
|
||||
{
|
||||
m_mainWidget = new QWidget;
|
||||
m_mainWidget = createSubWidget<QWidget>();
|
||||
m_mainWidget->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto layout = new QGridLayout(m_mainWidget);
|
||||
@@ -242,7 +249,7 @@ public:
|
||||
|
||||
refresh();
|
||||
|
||||
m_manageButton = new QPushButton(KitAspectWidget::msgManage());
|
||||
m_manageButton = createSubWidget<QPushButton>(KitAspectWidget::msgManage());
|
||||
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||
connect(m_manageButton, &QAbstractButton::clicked,
|
||||
this, &ToolChainKitAspectWidget::manageToolChains);
|
||||
@@ -255,8 +262,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *mainWidget() const override { return m_mainWidget; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_mainWidget);
|
||||
builder.addItem(m_mainWidget);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void refresh() override
|
||||
{
|
||||
@@ -289,7 +300,7 @@ private:
|
||||
|
||||
void manageToolChains()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, buttonWidget());
|
||||
Core::ICore::showOptionsDialog(Constants::TOOLCHAIN_SETTINGS_PAGE_ID, m_manageButton);
|
||||
}
|
||||
|
||||
void currentToolChainChanged(Utils::Id language, int idx)
|
||||
@@ -699,7 +710,7 @@ class DeviceTypeKitAspectWidget final : public KitAspectWidget
|
||||
|
||||
public:
|
||||
DeviceTypeKitAspectWidget(Kit *workingCopy, const KitAspect *ki)
|
||||
: KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox)
|
||||
: KitAspectWidget(workingCopy, ki), m_comboBox(createSubWidget<QComboBox>())
|
||||
{
|
||||
for (IDeviceFactory *factory : IDeviceFactory::allDeviceFactories())
|
||||
m_comboBox->addItem(factory->displayName(), factory->deviceType().toSetting());
|
||||
@@ -712,7 +723,12 @@ public:
|
||||
~DeviceTypeKitAspectWidget() override { delete m_comboBox; }
|
||||
|
||||
private:
|
||||
QWidget *mainWidget() const override { return m_comboBox; }
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_comboBox);
|
||||
builder.addItem(m_comboBox);
|
||||
}
|
||||
|
||||
void makeReadOnly() override { m_comboBox->setEnabled(false); }
|
||||
|
||||
void refresh() override
|
||||
@@ -817,12 +833,13 @@ class DeviceKitAspectWidget final : public KitAspectWidget
|
||||
|
||||
public:
|
||||
DeviceKitAspectWidget(Kit *workingCopy, const KitAspect *ki)
|
||||
: KitAspectWidget(workingCopy, ki), m_comboBox(new QComboBox),
|
||||
: KitAspectWidget(workingCopy, ki),
|
||||
m_comboBox(createSubWidget<QComboBox>()),
|
||||
m_model(new DeviceManagerModel(DeviceManager::instance()))
|
||||
{
|
||||
m_comboBox->setSizePolicy(QSizePolicy::Ignored, m_comboBox->sizePolicy().verticalPolicy());
|
||||
m_comboBox->setModel(m_model);
|
||||
m_manageButton = new QPushButton(KitAspectWidget::msgManage());
|
||||
m_manageButton = createSubWidget<QPushButton>(KitAspectWidget::msgManage());
|
||||
refresh();
|
||||
m_comboBox->setToolTip(ki->description());
|
||||
|
||||
@@ -844,8 +861,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *mainWidget() const override { return m_comboBox; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_comboBox);
|
||||
builder.addItem(m_comboBox);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void makeReadOnly() override { m_comboBox->setEnabled(false); }
|
||||
|
||||
void refresh() override
|
||||
@@ -856,7 +878,7 @@ private:
|
||||
|
||||
void manageDevices()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_PAGE_ID, buttonWidget());
|
||||
Core::ICore::showOptionsDialog(Constants::DEVICE_SETTINGS_PAGE_ID, m_manageButton);
|
||||
}
|
||||
|
||||
void modelAboutToReset()
|
||||
@@ -1069,9 +1091,9 @@ class EnvironmentKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
EnvironmentKitAspectWidget(Kit *workingCopy, const KitAspect *ki)
|
||||
: KitAspectWidget(workingCopy, ki),
|
||||
m_summaryLabel(new Utils::ElidingLabel),
|
||||
m_manageButton(new QPushButton),
|
||||
m_mainWidget(new QWidget)
|
||||
m_summaryLabel(createSubWidget<Utils::ElidingLabel>()),
|
||||
m_manageButton(createSubWidget<QPushButton>()),
|
||||
m_mainWidget(createSubWidget<QWidget>())
|
||||
{
|
||||
auto *layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -1086,8 +1108,13 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *mainWidget() const override { return m_mainWidget; }
|
||||
QWidget *buttonWidget() const override { return m_manageButton; }
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_mainWidget);
|
||||
builder.addItem(m_mainWidget);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void makeReadOnly() override { m_manageButton->setEnabled(false); }
|
||||
|
||||
void refresh() override
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QHash>
|
||||
#include <QLabel>
|
||||
#include <QSettings>
|
||||
@@ -724,24 +725,39 @@ void KitAspect::notifyAboutUpdate(Kit *k)
|
||||
|
||||
KitAspectWidget::KitAspectWidget(Kit *kit, const KitAspect *ki)
|
||||
: m_kit(kit), m_kitInformation(ki)
|
||||
{ }
|
||||
|
||||
void KitAspectWidget::addToLayout(LayoutBuilder &builder)
|
||||
{
|
||||
QTC_ASSERT(!m_label, delete m_label);
|
||||
m_label = new QLabel(m_kitInformation->displayName() + ':');
|
||||
m_label->setToolTip(m_kitInformation->description());
|
||||
|
||||
builder.addRow({LayoutBuilder::AlignAsFormLabel(m_label), mainWidget(), buttonWidget()});
|
||||
const Id id = ki->id();
|
||||
m_mutableAction = new QAction(tr("Mark as Mutable"));
|
||||
m_mutableAction->setCheckable(true);
|
||||
m_mutableAction->setChecked(m_kit->isMutable(id));
|
||||
m_mutableAction->setEnabled(!m_kit->isSticky(id));
|
||||
connect(m_mutableAction, &QAction::toggled, this, [this, id] {
|
||||
m_kit->setMutable(id, m_mutableAction->isChecked());
|
||||
});
|
||||
}
|
||||
|
||||
void KitAspectWidget::setVisible(bool visible)
|
||||
KitAspectWidget::~KitAspectWidget()
|
||||
{
|
||||
mainWidget()->setVisible(visible);
|
||||
if (buttonWidget())
|
||||
buttonWidget()->setVisible(visible);
|
||||
QTC_ASSERT(m_label, return);
|
||||
m_label->setVisible(visible);
|
||||
delete m_mutableAction;
|
||||
}
|
||||
|
||||
void KitAspectWidget::addToLayoutWithLabel(QWidget *parent)
|
||||
{
|
||||
QTC_ASSERT(parent, return);
|
||||
auto label = createSubWidget<QLabel>(m_kitInformation->displayName() + ':');
|
||||
label->setToolTip(m_kitInformation->description());
|
||||
|
||||
LayoutExtender builder(parent->layout());
|
||||
builder.finishRow();
|
||||
builder.addItem(label);
|
||||
addToLayout(builder);
|
||||
}
|
||||
|
||||
void KitAspectWidget::addMutableAction(QWidget *child)
|
||||
{
|
||||
QTC_ASSERT(child, return);
|
||||
child->addAction(m_mutableAction);
|
||||
child->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
QString KitAspectWidget::msgManage()
|
||||
|
@@ -31,6 +31,8 @@
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
@@ -125,31 +127,30 @@ private:
|
||||
bool m_essential = false;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT KitAspectWidget : public QObject
|
||||
class PROJECTEXPLORER_EXPORT KitAspectWidget : public Utils::BaseAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KitAspectWidget(Kit *kit, const KitAspect *ki);
|
||||
~KitAspectWidget();
|
||||
|
||||
virtual void makeReadOnly() = 0;
|
||||
virtual void refresh() = 0;
|
||||
|
||||
virtual QWidget *mainWidget() const = 0;
|
||||
virtual QWidget *buttonWidget() const { return nullptr; }
|
||||
|
||||
void addToLayout(Utils::LayoutBuilder &builder);
|
||||
void setVisible(bool visible);
|
||||
void addToLayoutWithLabel(QWidget *parent);
|
||||
|
||||
static QString msgManage();
|
||||
|
||||
Kit *kit() const { return m_kit; }
|
||||
const KitAspect *kitInformation() const { return m_kitInformation; }
|
||||
QAction *mutableAction() const { return m_mutableAction; }
|
||||
void addMutableAction(QWidget *child);
|
||||
|
||||
protected:
|
||||
Kit *m_kit;
|
||||
const KitAspect *m_kitInformation;
|
||||
QLabel *m_label = nullptr;
|
||||
QAction *m_mutableAction = nullptr;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT KitManager : public QObject
|
||||
|
@@ -133,8 +133,6 @@ KitManagerConfigWidget::~KitManagerConfigWidget()
|
||||
{
|
||||
qDeleteAll(m_widgets);
|
||||
m_widgets.clear();
|
||||
qDeleteAll(m_actions);
|
||||
m_actions.clear();
|
||||
|
||||
// Make sure our workingCopy did not get registered somehow:
|
||||
QTC_CHECK(!Utils::contains(KitManager::kits(),
|
||||
@@ -219,23 +217,11 @@ void KitManagerConfigWidget::addAspectToWorkingCopy(KitAspect *aspect)
|
||||
QTC_ASSERT(widget, return);
|
||||
QTC_ASSERT(!m_widgets.contains(widget), return);
|
||||
|
||||
auto action = new QAction(tr("Mark as Mutable"), nullptr);
|
||||
action->setCheckable(true);
|
||||
action->setChecked(workingCopy()->isMutable(aspect->id()));
|
||||
|
||||
action->setEnabled(!workingCopy()->isSticky(aspect->id()));
|
||||
widget->mainWidget()->addAction(action);
|
||||
widget->mainWidget()->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
connect(action, &QAction::toggled, this, [this, aspect, action] {
|
||||
workingCopy()->setMutable(aspect->id(), action->isChecked());
|
||||
emit dirty();
|
||||
});
|
||||
|
||||
m_actions << action;
|
||||
|
||||
LayoutExtender builder(layout());
|
||||
widget->addToLayout(builder);
|
||||
widget->addToLayoutWithLabel(this);
|
||||
m_widgets.append(widget);
|
||||
|
||||
connect(widget->mutableAction(), &QAction::toggled,
|
||||
this, &KitManagerConfigWidget::dirty);
|
||||
}
|
||||
|
||||
void KitManagerConfigWidget::updateVisibility()
|
||||
|
@@ -100,7 +100,6 @@ private:
|
||||
bool m_fixingKit = false;
|
||||
bool m_hasUniqueName = true;
|
||||
bool m_isRegistering = false;
|
||||
QList<QAction *> m_actions;
|
||||
mutable QString m_cachedDisplayName;
|
||||
};
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/itemviews.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/styledbar.h>
|
||||
#include <utils/stylehelper.h>
|
||||
@@ -564,15 +565,14 @@ class KitAreaWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit KitAreaWidget(QWidget *parent = nullptr)
|
||||
: QWidget(parent), m_layout(new QGridLayout(this))
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_layout->setContentsMargins(3, 3, 3, 3);
|
||||
connect(KitManager::instance(), &KitManager::kitUpdated, this, &KitAreaWidget::updateKit);
|
||||
}
|
||||
|
||||
~KitAreaWidget() override { setKit(nullptr); }
|
||||
|
||||
void setKit(ProjectExplorer::Kit *k)
|
||||
void setKit(Kit *k)
|
||||
{
|
||||
qDeleteAll(m_widgets);
|
||||
m_widgets.clear();
|
||||
@@ -580,25 +580,22 @@ public:
|
||||
if (!k)
|
||||
return;
|
||||
|
||||
foreach (QLabel *l, m_labels)
|
||||
l->deleteLater();
|
||||
m_labels.clear();
|
||||
delete layout();
|
||||
|
||||
int row = 0;
|
||||
LayoutBuilder builder(LayoutBuilder::GridLayout);
|
||||
for (KitAspect *aspect : KitManager::kitAspects()) {
|
||||
if (k && k->isMutable(aspect->id())) {
|
||||
KitAspectWidget *widget = aspect->createConfigWidget(k);
|
||||
m_widgets << widget;
|
||||
QLabel *label = new QLabel(aspect->displayName());
|
||||
m_labels << label;
|
||||
|
||||
m_layout->addWidget(label, row, 0);
|
||||
m_layout->addWidget(widget->mainWidget(), row, 1);
|
||||
m_layout->addWidget(widget->buttonWidget(), row, 2);
|
||||
|
||||
++row;
|
||||
builder.addItem(label);
|
||||
widget->addToLayout(builder);
|
||||
builder.finishRow();
|
||||
}
|
||||
}
|
||||
builder.attachTo(this);
|
||||
layout()->setContentsMargins(3, 3, 3, 3);
|
||||
|
||||
m_kit = k;
|
||||
|
||||
setHidden(m_widgets.isEmpty());
|
||||
@@ -633,10 +630,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
QGridLayout *m_layout;
|
||||
Kit *m_kit = nullptr;
|
||||
QList<KitAspectWidget *> m_widgets;
|
||||
QList<QLabel *> m_labels;
|
||||
};
|
||||
|
||||
/////////
|
||||
|
@@ -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()
|
||||
{
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -51,7 +52,7 @@ class QmakeKitAspectWidget final : public KitAspectWidget
|
||||
|
||||
public:
|
||||
QmakeKitAspectWidget(Kit *k, const KitAspect *ki)
|
||||
: KitAspectWidget(k, ki), m_lineEdit(new QLineEdit)
|
||||
: KitAspectWidget(k, ki), m_lineEdit(createSubWidget<QLineEdit>())
|
||||
{
|
||||
refresh(); // set up everything according to kit
|
||||
m_lineEdit->setToolTip(ki->description());
|
||||
@@ -61,7 +62,12 @@ public:
|
||||
~QmakeKitAspectWidget() override { delete m_lineEdit; }
|
||||
|
||||
private:
|
||||
QWidget *mainWidget() const override { return m_lineEdit; }
|
||||
void addToLayout(LayoutBuilder &builder) override
|
||||
{
|
||||
addMutableAction(m_lineEdit);
|
||||
builder.addItem(m_lineEdit);
|
||||
}
|
||||
|
||||
void makeReadOnly() override { m_lineEdit->setEnabled(false); }
|
||||
|
||||
void refresh() override
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <projectexplorer/toolchainmanager.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/buildablehelperlibrary.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/macroexpander.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -55,14 +56,14 @@ class QtKitAspectWidget final : public KitAspectWidget
|
||||
public:
|
||||
QtKitAspectWidget(Kit *k, const KitAspect *ki) : KitAspectWidget(k, ki)
|
||||
{
|
||||
m_combo = new QComboBox;
|
||||
m_combo = createSubWidget<QComboBox>();
|
||||
m_combo->setSizePolicy(QSizePolicy::Ignored, m_combo->sizePolicy().verticalPolicy());
|
||||
m_combo->addItem(tr("None"), -1);
|
||||
|
||||
QList<int> versionIds = Utils::transform(QtVersionManager::versions(), &BaseQtVersion::uniqueId);
|
||||
versionsChanged(versionIds, QList<int>(), QList<int>());
|
||||
|
||||
m_manageButton = new QPushButton(KitAspectWidget::msgManage());
|
||||
m_manageButton = createSubWidget<QPushButton>(KitAspectWidget::msgManage());
|
||||
|
||||
refresh();
|
||||
m_combo->setToolTip(ki->description());
|
||||
@@ -84,8 +85,13 @@ public:
|
||||
|
||||
private:
|
||||
void makeReadOnly() final { m_combo->setEnabled(false); }
|
||||
QWidget *mainWidget() const final { return m_combo; }
|
||||
QWidget *buttonWidget() const final { return m_manageButton; }
|
||||
|
||||
void addToLayout(LayoutBuilder &builder)
|
||||
{
|
||||
addMutableAction(m_combo);
|
||||
builder.addItem(m_combo);
|
||||
builder.addItem(m_manageButton);
|
||||
}
|
||||
|
||||
void refresh() final
|
||||
{
|
||||
@@ -125,7 +131,7 @@ private:
|
||||
|
||||
void manageQtVersions()
|
||||
{
|
||||
Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, buttonWidget());
|
||||
Core::ICore::showOptionsDialog(Constants::QTVERSION_SETTINGS_PAGE_ID, m_manageButton);
|
||||
}
|
||||
|
||||
void currentWasChanged(int idx)
|
||||
|
Reference in New Issue
Block a user