WebAssembly: Self-register aspects in runconfiguration

No real benefit in this particular case, but the general pattern now.

Change-Id: Ia06d3221a2ccd4b7ab429f6e045c11fffffe99ad
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-07-13 17:59:56 +02:00
parent bc2c2bbae9
commit 7c8948bef4
3 changed files with 25 additions and 16 deletions

View File

@@ -69,25 +69,28 @@ class EmrunRunConfiguration : public ProjectExplorer::RunConfiguration
{
public:
EmrunRunConfiguration(Target *target, Utils::Id id)
: RunConfiguration(target, id)
: RunConfiguration(target, id)
{
auto webBrowserAspect = addAspect<WebBrowserSelectionAspect>(target);
webBrowser.setTarget(target);
auto effectiveEmrunCall = addAspect<StringAspect>();
effectiveEmrunCall->setLabelText(Tr::tr("Effective emrun call:"));
effectiveEmrunCall->setDisplayStyle(StringAspect::TextEditDisplay);
effectiveEmrunCall->setReadOnly(true);
effectiveEmrunCall.setLabelText(Tr::tr("Effective emrun call:"));
effectiveEmrunCall.setDisplayStyle(StringAspect::TextEditDisplay);
effectiveEmrunCall.setReadOnly(true);
setUpdater([this, target, effectiveEmrunCall, webBrowserAspect] {
effectiveEmrunCall->setValue(emrunCommand(target,
buildKey(),
webBrowserAspect->currentBrowser(),
"<port>").toUserOutput());
setUpdater([this, target] {
effectiveEmrunCall.setValue(emrunCommand(target,
buildKey(),
webBrowser.currentBrowser(),
"<port>").toUserOutput());
});
connect(webBrowserAspect, &BaseAspect::changed, this, &RunConfiguration::update);
connect(&webBrowser, &BaseAspect::changed, this, &RunConfiguration::update);
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
}
private:
WebBrowserSelectionAspect webBrowser{this};
StringAspect effectiveEmrunCall{this};
};
class EmrunRunWorker : public SimpleTargetRunner

View File

@@ -41,9 +41,13 @@ static WebBrowserEntries emrunBrowsers(ProjectExplorer::Target *target)
return result;
}
WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target)
: m_availableBrowsers(emrunBrowsers(target))
WebBrowserSelectionAspect::WebBrowserSelectionAspect(AspectContainer *container)
: BaseAspect(container)
{}
void WebBrowserSelectionAspect::setTarget(ProjectExplorer::Target *target)
{
m_availableBrowsers = emrunBrowsers(target);
if (!m_availableBrowsers.isEmpty()) {
const int defaultIndex = qBound(0, m_availableBrowsers.count() - 1, 1);
m_currentBrowser = m_availableBrowsers.at(defaultIndex).first;

View File

@@ -18,7 +18,9 @@ class WebBrowserSelectionAspect : public Utils::BaseAspect
Q_OBJECT
public:
WebBrowserSelectionAspect(ProjectExplorer::Target *target);
WebBrowserSelectionAspect(Utils::AspectContainer *container);
void setTarget(ProjectExplorer::Target *target);
void addToLayout(Layouting::LayoutItem &parent) override;
@@ -37,7 +39,7 @@ public:
private:
QComboBox *m_webBrowserComboBox = nullptr;
QString m_currentBrowser;
const WebBrowserEntries m_availableBrowsers;
WebBrowserEntries m_availableBrowsers;
};
} // namespace Internal