McuSupport: If kits are missing, provide an InfoBar that opens settings

When installing Qt for MCUs via the SDK installer, the user (in many
cases first-time evaluator) has to create the kits for Qt for MCUs. For
those who see Qt Creator for the first time, it is difficult to find out
where to search for the UI that generates those kits.

Let's help the user with an InfoBar entry that in case of ...

 * McuSupport plugin being enabled (by SDK installer)
 * Settings key [McuSupport]/Package_QtForMCUsSdk set (by SDK installer)
 * Absence of valid Qt for MCUs Kits

... helps to directly open the right page and tab of the Options dialog.

Task-number: QTCREATORBUG-23943
Change-Id: I7d4834633b1b94ef663d62cd395ee071bd123f1f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2020-03-04 17:48:27 +01:00
parent b3f3deccb0
commit 02efd43199
2 changed files with 27 additions and 0 deletions

View File

@@ -33,11 +33,15 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/infobar.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
#include <projectexplorer/kitmanager.h>
#include <QTimer>
using namespace Core;
using namespace ProjectExplorer;
namespace McuSupport {
@@ -90,8 +94,30 @@ void McuSupportPlugin::extensionsInitialized()
connect(KitManager::instance(), &KitManager::kitsLoaded, [](){
McuSupportOptions::removeOutdatedKits();
McuSupportPlugin::askUserAboutMcuSupportKitsSetup();
});
}
void McuSupportPlugin::askUserAboutMcuSupportKitsSetup()
{
const char setupMcuSupportKits[] = "SetupMcuSupportKits";
if (!ICore::infoBar()->canInfoBeAdded(setupMcuSupportKits)
|| McuSupportOptions::qulDirFromSettings().isEmpty()
|| !McuSupportOptions::existingKits(nullptr).isEmpty())
return;
InfoBarEntry info(
setupMcuSupportKits,
tr("Create Kits for Qt for MCUs? "
"To do it later, select Options > Devices > MCU."),
InfoBarEntry::GlobalSuppression::Enabled);
info.setCustomButtonInfo(tr("Create Kits for Qt for MCUs"), [setupMcuSupportKits] {
ICore::infoBar()->removeInfo(setupMcuSupportKits);
QTimer::singleShot(0, []() { ICore::showOptionsDialog(Constants::SETTINGS_ID); });
});
ICore::infoBar()->addInfo(info);
}
} // namespace Internal
} // namespace McuSupport

View File

@@ -43,6 +43,7 @@ public:
bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override;
static void askUserAboutMcuSupportKitsSetup();
};
} // namespace Internal