forked from qt-creator/qt-creator
ProjectExplorer: Introduce "Show All Kits" option to Kits view
By default, the kits view now displays only active kits relevant to the current project. To access additional kits, users can now use the "Show All Kits" option. Change-Id: I41ecd7cbe7e220d564692b3cb16ea176add2b201 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -88,6 +88,7 @@ const char BUILD_AND_RUN_SETTINGS_CATEGORY[] = "K.BuildAndRun";
|
||||
|
||||
// Build and Run page
|
||||
const char BUILD_AND_RUN_SETTINGS_PAGE_ID[] = "A.ProjectExplorer.BuildAndRunOptions";
|
||||
const char SHOW_ALL_KITS_SETTINGS_KEY[] = "ProjectExplorer/Settings/ShowAllKits";
|
||||
|
||||
// Device settings page
|
||||
const char DEVICE_SETTINGS_CATEGORY[] = "AM.Devices";
|
||||
|
@@ -78,7 +78,9 @@ static bool operator==(const ProjectExplorerSettings &p1, const ProjectExplorerS
|
||||
&& p1.clearIssuesOnRebuild == p2.clearIssuesOnRebuild
|
||||
&& p1.abortBuildAllOnError == p2.abortBuildAllOnError
|
||||
&& p1.appEnvChanges == p2.appEnvChanges
|
||||
&& p1.lowBuildPriority == p2.lowBuildPriority;
|
||||
&& p1.lowBuildPriority == p2.lowBuildPriority
|
||||
&& p1.warnAgainstNonAsciiBuildDir == p2.warnAgainstNonAsciiBuildDir
|
||||
&& p1.showAllKits == p2.showAllKits;
|
||||
}
|
||||
|
||||
ProjectExplorerSettings &mutableProjectExplorerSettings()
|
||||
@@ -171,6 +173,9 @@ static void loadProjectExplorerSettings()
|
||||
.toBool();
|
||||
settings.appEnvChanges = EnvironmentItem::fromStringList(
|
||||
s->value(Constants::APP_ENV_CHANGES_SETTINGS_KEY).toStringList());
|
||||
settings.showAllKits
|
||||
= s->value(ProjectExplorer::Constants::SHOW_ALL_KITS_SETTINGS_KEY, defaultSettings.showAllKits)
|
||||
.toBool();
|
||||
}
|
||||
|
||||
void saveProjectExplorerSettings()
|
||||
@@ -225,6 +230,10 @@ void saveProjectExplorerSettings()
|
||||
int(defaultSettings.stopBeforeBuild));
|
||||
s->setValueWithDefault(Constants::APP_ENV_CHANGES_SETTINGS_KEY,
|
||||
EnvironmentItem::toStringList(settings.appEnvChanges));
|
||||
s->setValueWithDefault(
|
||||
ProjectExplorer::Constants::SHOW_ALL_KITS_SETTINGS_KEY,
|
||||
settings.showAllKits,
|
||||
defaultSettings.showAllKits);
|
||||
}
|
||||
|
||||
class ProjectExplorerSettingsWidget : public IOptionsPageWidget
|
||||
@@ -278,6 +287,7 @@ private:
|
||||
QComboBox *m_stopBeforeBuildComboBox;
|
||||
QComboBox *m_terminalModeComboBox;
|
||||
QCheckBox *m_jomCheckbox;
|
||||
QCheckBox *m_showAllKitsCheckBox;
|
||||
Utils::ElidingLabel *m_appEnvLabel;
|
||||
|
||||
QButtonGroup *m_directoryButtonGroup;
|
||||
@@ -337,6 +347,11 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget()
|
||||
"Disable it if you experience problems with your builds.");
|
||||
jomLabel->setWordWrap(true);
|
||||
|
||||
m_showAllKitsCheckBox = new QCheckBox(
|
||||
Tr::tr("Show all kits in \"Build & Run\" in \"Projects\" mode"));
|
||||
m_showAllKitsCheckBox->setToolTip(
|
||||
Tr::tr("Show also inactive kits in \"Build & Run\" in \"Projects\" mode."));
|
||||
|
||||
const QString appEnvToolTip = Tr::tr("Environment changes to apply to run configurations, "
|
||||
"but not build configurations.");
|
||||
const auto appEnvDescriptionLabel = new QLabel(Tr::tr("Application environment:"));
|
||||
@@ -383,6 +398,7 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget()
|
||||
m_abortBuildAllOnErrorCheckBox,
|
||||
m_lowBuildPriorityCheckBox,
|
||||
m_warnAgainstNonAsciiBuildDirCheckBox,
|
||||
m_showAllKitsCheckBox,
|
||||
Form {
|
||||
appEnvDescriptionLabel, Row{m_appEnvLabel, appEnvButton, st}, br,
|
||||
Tr::tr("Build before deploying:"), m_buildBeforeDeployComboBox, br,
|
||||
@@ -433,6 +449,7 @@ ProjectExplorerSettings ProjectExplorerSettingsWidget::settings() const
|
||||
s.lowBuildPriority = m_lowBuildPriorityCheckBox->isChecked();
|
||||
s.warnAgainstNonAsciiBuildDir = m_warnAgainstNonAsciiBuildDirCheckBox->isChecked();
|
||||
s.appEnvChanges = m_appEnvChanges;
|
||||
s.showAllKits = m_showAllKitsCheckBox->isChecked();
|
||||
s.environmentId = projectExplorerSettings().environmentId;
|
||||
return s;
|
||||
}
|
||||
@@ -456,6 +473,7 @@ void ProjectExplorerSettingsWidget::setSettings(const ProjectExplorerSettings &
|
||||
m_abortBuildAllOnErrorCheckBox->setChecked(s.abortBuildAllOnError);
|
||||
m_lowBuildPriorityCheckBox->setChecked(s.lowBuildPriority);
|
||||
m_warnAgainstNonAsciiBuildDirCheckBox->setChecked(s.warnAgainstNonAsciiBuildDir);
|
||||
m_showAllKitsCheckBox->setChecked(s.showAllKits);
|
||||
}
|
||||
|
||||
FilePath ProjectExplorerSettingsWidget::projectsDirectory() const
|
||||
@@ -525,5 +543,10 @@ const ProjectExplorerSettings &projectExplorerSettings()
|
||||
return Internal::mutableProjectExplorerSettings();
|
||||
}
|
||||
|
||||
ProjectExplorerSettings &mutableProjectExplorerSettings()
|
||||
{
|
||||
return Internal::mutableProjectExplorerSettings();
|
||||
}
|
||||
|
||||
} // ProjectExplorer
|
||||
|
||||
|
@@ -33,6 +33,7 @@ public:
|
||||
bool abortBuildAllOnError = true;
|
||||
bool lowBuildPriority = false;
|
||||
bool warnAgainstNonAsciiBuildDir = true;
|
||||
bool showAllKits = true;
|
||||
StopBeforeBuild stopBeforeBuild = Utils::HostOsInfo::isWindowsHost()
|
||||
? StopBeforeBuild::SameProject
|
||||
: StopBeforeBuild::None;
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
};
|
||||
|
||||
PROJECTEXPLORER_EXPORT const ProjectExplorerSettings &projectExplorerSettings();
|
||||
ProjectExplorerSettings &mutableProjectExplorerSettings();
|
||||
|
||||
namespace Internal {
|
||||
|
||||
|
@@ -10,7 +10,10 @@
|
||||
#include "kitmanager.h"
|
||||
#include "panelswidget.h"
|
||||
#include "project.h"
|
||||
#include "projectexplorer.h"
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "projectexplorericons.h"
|
||||
#include "projectexplorersettings.h"
|
||||
#include "projectexplorertr.h"
|
||||
#include "projectimporter.h"
|
||||
#include "projectmanager.h"
|
||||
@@ -168,6 +171,18 @@ public:
|
||||
void ensureWidget();
|
||||
void rebuildContents();
|
||||
|
||||
void setShowAllKits(bool showAllKits)
|
||||
{
|
||||
QtcSettings *settings = Core::ICore::settings();
|
||||
settings->setValue(ProjectExplorer::Constants::SHOW_ALL_KITS_SETTINGS_KEY, showAllKits);
|
||||
mutableProjectExplorerSettings().showAllKits = showAllKits;
|
||||
rebuildContents();
|
||||
}
|
||||
bool showAllKits() const
|
||||
{
|
||||
return projectExplorerSettings().showAllKits;
|
||||
}
|
||||
|
||||
TargetGroupItem *q;
|
||||
QString m_displayName;
|
||||
Project *m_project;
|
||||
@@ -178,6 +193,42 @@ public:
|
||||
TargetSetupPageWrapper *m_targetSetupPageWrapper = nullptr;
|
||||
};
|
||||
|
||||
class ShowMoreItem : public TreeItem
|
||||
{
|
||||
public:
|
||||
ShowMoreItem(TargetGroupItemPrivate *p)
|
||||
: m_p(p)
|
||||
{}
|
||||
|
||||
QVariant data(int column, int role) const override
|
||||
{
|
||||
Q_UNUSED(column)
|
||||
if (role == Qt::DisplayRole) {
|
||||
return !m_p->showAllKits() ? Tr::tr("Show All Kits") : Tr::tr("Hide Inactive Kits");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
bool setData(int column, const QVariant &data, int role) override
|
||||
{
|
||||
Q_UNUSED(column)
|
||||
Q_UNUSED(data)
|
||||
if (role == ItemActivatedDirectlyRole) {
|
||||
m_p->setShowAllKits(!m_p->showAllKits());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags(int) const override
|
||||
{
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
private:
|
||||
TargetGroupItemPrivate *m_p;
|
||||
};
|
||||
|
||||
void TargetGroupItemPrivate::ensureWidget()
|
||||
{
|
||||
if (!m_noKitLabel) {
|
||||
@@ -665,6 +716,10 @@ TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *proj
|
||||
this, &TargetGroupItemPrivate::handleRemovedKit);
|
||||
connect(KitManager::instance(), &KitManager::kitUpdated,
|
||||
this, &TargetGroupItemPrivate::handleUpdatedKit);
|
||||
connect(KitManager::instance(), &KitManager::kitsChanged,
|
||||
this, &TargetGroupItemPrivate::rebuildContents);
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, &TargetGroupItemPrivate::rebuildContents);
|
||||
|
||||
rebuildContents();
|
||||
}
|
||||
@@ -761,14 +816,27 @@ void TargetItem::updateSubItems()
|
||||
|
||||
void TargetGroupItemPrivate::rebuildContents()
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
const auto sortedKits = KitManager::sortedKits();
|
||||
bool isAnyKitNotEnabled = std::any_of(sortedKits.begin(), sortedKits.end(), [this](Kit *kit) {
|
||||
return kit && m_project->target(kit->id()) != nullptr;
|
||||
});
|
||||
q->removeChildren();
|
||||
|
||||
for (Kit *kit : KitManager::sortedKits())
|
||||
q->appendChild(new TargetItem(m_project, kit->id(), m_project->projectIssues(kit)));
|
||||
for (Kit *kit : sortedKits) {
|
||||
if (!isAnyKitNotEnabled || showAllKits() || m_project->target(kit->id()) != nullptr)
|
||||
q->appendChild(new TargetItem(m_project, kit->id(), m_project->projectIssues(kit)));
|
||||
}
|
||||
|
||||
if (q->parent())
|
||||
q->parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(q)),
|
||||
ItemUpdatedFromBelowRole);
|
||||
if (isAnyKitNotEnabled)
|
||||
q->appendChild(new ShowMoreItem(this));
|
||||
|
||||
if (q->parent()) {
|
||||
q->parent()
|
||||
->setData(0, QVariant::fromValue(static_cast<TreeItem *>(q)), ItemUpdatedFromBelowRole);
|
||||
}
|
||||
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void TargetGroupItemPrivate::handleTargetAdded(Target *target)
|
||||
|
Reference in New Issue
Block a user