Merge "Merge remote-tracking branch 'origin/16.0'"

This commit is contained in:
The Qt Project
2025-04-24 13:57:39 +00:00
12 changed files with 110 additions and 54 deletions

View File

@@ -504,7 +504,7 @@ static bool sdkManagerCommand(const QStringList &args, QString *output)
proc.setCommand({AndroidConfig::sdkManagerToolPath(), newArgs});
qCDebug(sdkManagerLog).noquote() << "Running SDK Manager command (sync):"
<< proc.commandLine().toUserOutput();
proc.runBlocking(60s, EventLoopMode::On);
proc.runBlocking(60s);
if (output)
*output = proc.allOutput();
return proc.result() == ProcessResult::FinishedWithSuccess;

View File

@@ -72,51 +72,56 @@ bool BlameMark::addToolTipContent(QLayout *target) const
auto textLabel = new QLabel;
textLabel->setText(toolTip());
target->addWidget(textLabel);
QObject::connect(textLabel, &QLabel::linkActivated, textLabel, [this](const QString &link) {
qCInfo(log) << "Link activated with target:" << link;
const QString hash = (link == "blameParent") ? m_info.hash + "^" : m_info.hash;
QObject::connect(
textLabel, &QLabel::linkActivated, textLabel, [info = m_info](const QString &link) {
qCInfo(log) << "Link activated with target:" << link;
const QString hash = (link == "blameParent") ? info.hash + "^" : info.hash;
if (link.startsWith("blame") || link == "revert" || link == "showFile") {
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
const Utils::FilePath path = state.topLevel();
if (link.startsWith("blame") || link == "revert" || link == "showFile") {
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
const Utils::FilePath path = state.topLevel();
const QString originalFileName = m_info.originalFileName;
if (link.startsWith("blame")) {
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
<< "\":" << m_info.originalLine << " @ " << hash;
gitClient().annotate(path, originalFileName, m_info.originalLine, hash);
} else if (link == "revert") {
const QMessageBox::StandardButton result = QMessageBox::question(
Core::ICore::dialogParent(), Tr::tr("Revert Commit?"),
Tr::tr("Revert the commit %1?").arg(m_info.hash.left(8)),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
qCInfo(log).nospace().noquote() << "Reverting: \"" << path << "\" @ " << hash;
gitClient().synchronousRevert(path, hash);
const QString originalFileName = info.originalFileName;
if (link.startsWith("blame")) {
qCInfo(log).nospace().noquote()
<< "Blaming: \"" << path << "/" << originalFileName
<< "\":" << info.originalLine << " @ " << hash;
gitClient().annotate(path, originalFileName, info.originalLine, hash);
} else if (link == "revert") {
const QMessageBox::StandardButton result = QMessageBox::question(
Core::ICore::dialogParent(),
Tr::tr("Revert Commit?"),
Tr::tr("Revert the commit %1?").arg(info.hash.left(8)),
QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
qCInfo(log).nospace().noquote()
<< "Reverting: \"" << path << "\" @ " << hash;
gitClient().synchronousRevert(path, hash);
}
} else {
qCInfo(log).nospace().noquote()
<< "Showing file: \"" << path << "/" << originalFileName << "\" @ " << hash;
const auto fileName = Utils::FilePath::fromString(originalFileName);
gitClient().openShowEditor(path, hash, fileName);
}
} else if (link == "logLine") {
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
qCInfo(log).nospace().noquote()
<< "Showing log for: \"" << info.filePath << "\" line:" << info.line;
const QString lineArg
= QString("-L %1,%1:%2").arg(info.line).arg(state.relativeCurrentFile());
gitClient().log(state.currentFileTopLevel(), {}, true, {lineArg, "--no-patch"});
} else {
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
<< originalFileName << "\" @ " << hash;
const auto fileName = Utils::FilePath::fromString(originalFileName);
gitClient().openShowEditor(path, hash, fileName);
qCInfo(log).nospace().noquote()
<< "Showing commit: " << hash << " for " << info.filePath;
gitClient().show(info.filePath, hash);
}
} else if (link == "logLine") {
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
qCInfo(log).nospace().noquote() << "Showing log for: \"" << m_info.filePath
<< "\" line:" << m_info.line;
const QString lineArg = QString("-L %1,%1:%2")
.arg(m_info.line).arg(state.relativeCurrentFile());
gitClient().log(state.currentFileTopLevel(), {}, true, {lineArg, "--no-patch"});
} else {
qCInfo(log).nospace().noquote() << "Showing commit: " << hash << " for " << m_info.filePath;
gitClient().show(m_info.filePath, hash);
}
});
});
return true;
}

View File

@@ -34,6 +34,7 @@ public:
virtual QString label() const = 0;
virtual QString cmakeVariableName() const = 0;
virtual QString environmentVariableName() const = 0;
virtual bool isOptional() const = 0;
virtual bool isAddToSystemPath() const = 0;
virtual QStringList versions() const = 0;

View File

@@ -41,6 +41,7 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
const QStringList &versions,
const QString &downloadUrl,
const McuPackageVersionDetector *versionDetector,
const bool optional,
const bool addToSystemPath,
const Utils::PathChooser::Kind &valueType,
const bool allowNewerVersionKey)
@@ -53,6 +54,7 @@ McuPackage::McuPackage(const SettingsHandler::Ptr &settingsHandler,
, m_cmakeVariableName(cmakeVarName)
, m_environmentVariableName(envVarName)
, m_downloadUrl(downloadUrl)
, m_optional(optional)
, m_addToSystemPath(addToSystemPath)
, m_valueType(valueType)
{
@@ -93,6 +95,11 @@ QString McuPackage::environmentVariableName() const
return m_environmentVariableName;
}
bool McuPackage::isOptional() const
{
return m_optional;
}
bool McuPackage::isAddToSystemPath() const
{
return m_addToSystemPath;
@@ -190,25 +197,34 @@ McuPackage::Status McuPackage::status() const
return m_status;
}
bool McuPackage::isOptionalAndEmpty() const
{
return m_status == Status::EmptyPath && isOptional();
}
bool McuPackage::isValidStatus() const
{
return m_status == Status::ValidPackage || m_status == Status::ValidPackageMismatchedVersion
|| m_status == Status::ValidPackageVersionNotDetected;
|| m_status == Status::ValidPackageVersionNotDetected || isOptionalAndEmpty();
}
void McuPackage::updateStatusUi()
{
switch (m_status) {
case Status::ValidPackage:
if (isOptionalAndEmpty()) {
m_infoLabel->setType(InfoLabel::Ok);
break;
case Status::ValidPackageMismatchedVersion:
case Status::ValidPackageVersionNotDetected:
m_infoLabel->setType(InfoLabel::Warning);
break;
default:
m_infoLabel->setType(InfoLabel::NotOk);
break;
} else {
switch (m_status) {
case Status::ValidPackage:
m_infoLabel->setType(InfoLabel::Ok);
break;
case Status::ValidPackageMismatchedVersion:
case Status::ValidPackageVersionNotDetected:
m_infoLabel->setType(InfoLabel::Warning);
break;
default:
m_infoLabel->setType(InfoLabel::NotOk);
break;
}
}
m_infoLabel->setText(statusText());
}

View File

@@ -39,6 +39,7 @@ public:
const QString &downloadUrl = {},
const McuPackageVersionDetector *versionDetector = nullptr,
const bool addToPath = false,
const bool optional = false,
const Utils::PathChooser::Kind &valueType
= Utils::PathChooser::Kind::ExistingDirectory,
const bool allowNewerVersionKey = false);
@@ -50,6 +51,7 @@ public:
QString label() const override;
QString cmakeVariableName() const override;
QString environmentVariableName() const override;
bool isOptional() const override;
bool isAddToSystemPath() const override;
QStringList versions() const override;
@@ -77,6 +79,8 @@ private:
void updatePath();
void updateStatusUi();
bool isOptionalAndEmpty() const;
SettingsHandler::Ptr settingsHandler;
Utils::PathChooser *m_fileChooser = nullptr;
@@ -95,6 +99,7 @@ private:
const QString m_cmakeVariableName;
const QString m_environmentVariableName;
const QString m_downloadUrl;
const bool m_optional;
const bool m_addToSystemPath;
const Utils::PathChooser::Kind m_valueType;

View File

@@ -55,8 +55,10 @@ private:
QMap<McuPackagePtr, QWidget *> m_packageWidgets;
QMap<McuTargetPtr, QWidget *> m_mcuTargetPacketWidgets;
QFormLayout *m_packagesLayout = nullptr;
QFormLayout *m_optionalPackagesLayout = nullptr;
QGroupBox *m_qtForMCUsSdkGroupBox = nullptr;
QGroupBox *m_packagesGroupBox = nullptr;
QGroupBox *m_optionalPackagesGroupBox = nullptr;
QGroupBox *m_mcuTargetsGroupBox = nullptr;
QComboBox *m_mcuTargetsComboBox = nullptr;
QGroupBox *m_kitCreationGroupBox = nullptr;
@@ -122,6 +124,14 @@ McuSupportOptionsWidget::McuSupportOptionsWidget(McuSupportOptions &options,
m_packagesGroupBox->setLayout(m_packagesLayout);
}
{
m_optionalPackagesGroupBox = new QGroupBox(Tr::tr("Optional"));
m_optionalPackagesGroupBox->setFlat(true);
mainLayout->addWidget(m_optionalPackagesGroupBox);
m_optionalPackagesLayout = new QFormLayout;
m_optionalPackagesGroupBox->setLayout(m_optionalPackagesLayout);
}
{
m_mcuTargetsInfoLabel = new Utils::InfoLabel;
mainLayout->addWidget(m_mcuTargetsInfoLabel);
@@ -187,6 +197,10 @@ void McuSupportOptionsWidget::updateStatus()
const bool ready = valid && mcuTarget;
m_mcuTargetsGroupBox->setVisible(ready);
m_packagesGroupBox->setVisible(ready && !mcuTarget->packages().isEmpty());
m_optionalPackagesGroupBox->setVisible(
ready && std::ranges::any_of(mcuTarget->packages(), [](McuPackagePtr p) {
return p->isOptional();
}));
m_kitCreationGroupBox->setVisible(ready);
m_mcuTargetsInfoLabel->setVisible(valid && m_options.sdkRepository.mcuTargets.isEmpty());
if (m_mcuTargetsInfoLabel->isVisible()) {
@@ -266,6 +280,10 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
m_packagesLayout->removeRow(0);
}
while (m_optionalPackagesLayout->rowCount() > 0) {
m_optionalPackagesLayout->removeRow(0);
}
std::set<McuPackagePtr, McuPackageSort> packages;
for (const auto &package : mcuTarget->packages()) {
@@ -285,7 +303,10 @@ void McuSupportOptionsWidget::showMcuTargetPackages()
package->setPath(macroExpander->expand(package->defaultPath()));
}
});
m_packagesLayout->addRow(package->label(), packageWidget);
if (package->isOptional())
m_optionalPackagesLayout->addRow(package->label(), packageWidget);
else
m_packagesLayout->addRow(package->label(), packageWidget);
packageWidget->show();
}

View File

@@ -61,6 +61,7 @@ McuPackagePtr createQtForMCUsPackage(const SettingsHandler::Ptr &settingsHandler
{}, // versions
{}, // downloadUrl
nullptr, // versionDetector
false, // optional
false, // addToPath
Utils::PathChooser::Kind::ExistingDirectory, // valueType
true)}; // useNewestVersionKey
@@ -703,6 +704,7 @@ static PackageDescription parsePackage(const QJsonObject &cmakeEntry)
detectionPaths,
versions,
parseVersionDetection(cmakeEntry),
cmakeEntry["optional"].toBool(),
cmakeEntry["addToSystemPath"].toBool(),
parseLineEditType(cmakeEntry["type"])};
}

View File

@@ -33,6 +33,7 @@ struct PackageDescription
Utils::FilePaths detectionPaths;
QStringList versions;
VersionDetection versionDetection;
bool optional;
bool shouldAddToSystemPath;
Utils::PathChooser::Kind type;
}; //struct PackageDescription

View File

@@ -137,6 +137,7 @@ McuPackagePtr McuTargetFactory::createPackage(const PackageDescription &pkgDesc)
pkgDesc.versions,
{},
createVersionDetection(pkgDesc.versionDetection),
pkgDesc.optional,
pkgDesc.shouldAddToSystemPath,
pkgDesc.type}};
}

View File

@@ -29,6 +29,7 @@ public:
MOCK_METHOD(bool, isValidStatus, (), (const));
MOCK_METHOD(QString, cmakeVariableName, (), (const));
MOCK_METHOD(QString, environmentVariableName, (), (const));
MOCK_METHOD(bool, isOptional, (), (const));
MOCK_METHOD(bool, isAddToSystemPath, (), (const));
MOCK_METHOD(bool, writeToSettings, (), (const));
MOCK_METHOD(void, readFromSettings, ());

View File

@@ -196,6 +196,7 @@ const PackageDescription
{},
VersionDetection{},
false,
false,
Utils::PathChooser::Kind::ExistingDirectory};
const McuTargetDescription::Platform platformDescription{id,
@@ -851,6 +852,7 @@ void McuSupportTest::test_useFallbackPathForToolchainWhenPathFromSettingsIsNotAv
{},
VersionDetection{},
false,
false,
Utils::PathChooser::Kind::ExistingDirectory};
McuTargetDescription::Toolchain toolchainDescription{armGcc, {}, compilerDescription, {}};
@@ -875,6 +877,7 @@ void McuSupportTest::test_usePathFromSettingsForToolchainPath()
{},
VersionDetection{},
false,
false,
Utils::PathChooser::Kind::ExistingDirectory};
McuTargetDescription::Toolchain toolchainDescription{armGcc, {}, compilerDescription, {}};

View File

@@ -126,7 +126,7 @@ def displayHintForHighlighterDefinition(fileName, patterns, added):
if hasSuffix(fileName, patterns):
return not added
test.warning("Got an unexpected suffix.", "Filename: %s, Patterns: %s"
% (fileName, str(patterns + lPatterns)))
% (fileName, str(patterns)))
return False
def main():