forked from qt-creator/qt-creator
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:
@@ -71,23 +71,26 @@ public:
|
|||||||
EmrunRunConfiguration(Target *target, Utils::Id id)
|
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->setLabelText(Tr::tr("Effective emrun call:"));
|
effectiveEmrunCall.setDisplayStyle(StringAspect::TextEditDisplay);
|
||||||
effectiveEmrunCall->setDisplayStyle(StringAspect::TextEditDisplay);
|
effectiveEmrunCall.setReadOnly(true);
|
||||||
effectiveEmrunCall->setReadOnly(true);
|
|
||||||
|
|
||||||
setUpdater([this, target, effectiveEmrunCall, webBrowserAspect] {
|
setUpdater([this, target] {
|
||||||
effectiveEmrunCall->setValue(emrunCommand(target,
|
effectiveEmrunCall.setValue(emrunCommand(target,
|
||||||
buildKey(),
|
buildKey(),
|
||||||
webBrowserAspect->currentBrowser(),
|
webBrowser.currentBrowser(),
|
||||||
"<port>").toUserOutput());
|
"<port>").toUserOutput());
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(webBrowserAspect, &BaseAspect::changed, this, &RunConfiguration::update);
|
connect(&webBrowser, &BaseAspect::changed, this, &RunConfiguration::update);
|
||||||
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
WebBrowserSelectionAspect webBrowser{this};
|
||||||
|
StringAspect effectiveEmrunCall{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmrunRunWorker : public SimpleTargetRunner
|
class EmrunRunWorker : public SimpleTargetRunner
|
||||||
|
@@ -41,9 +41,13 @@ static WebBrowserEntries emrunBrowsers(ProjectExplorer::Target *target)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebBrowserSelectionAspect::WebBrowserSelectionAspect(ProjectExplorer::Target *target)
|
WebBrowserSelectionAspect::WebBrowserSelectionAspect(AspectContainer *container)
|
||||||
: m_availableBrowsers(emrunBrowsers(target))
|
: BaseAspect(container)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void WebBrowserSelectionAspect::setTarget(ProjectExplorer::Target *target)
|
||||||
{
|
{
|
||||||
|
m_availableBrowsers = emrunBrowsers(target);
|
||||||
if (!m_availableBrowsers.isEmpty()) {
|
if (!m_availableBrowsers.isEmpty()) {
|
||||||
const int defaultIndex = qBound(0, m_availableBrowsers.count() - 1, 1);
|
const int defaultIndex = qBound(0, m_availableBrowsers.count() - 1, 1);
|
||||||
m_currentBrowser = m_availableBrowsers.at(defaultIndex).first;
|
m_currentBrowser = m_availableBrowsers.at(defaultIndex).first;
|
||||||
|
@@ -18,7 +18,9 @@ class WebBrowserSelectionAspect : public Utils::BaseAspect
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebBrowserSelectionAspect(ProjectExplorer::Target *target);
|
WebBrowserSelectionAspect(Utils::AspectContainer *container);
|
||||||
|
|
||||||
|
void setTarget(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
void addToLayout(Layouting::LayoutItem &parent) override;
|
void addToLayout(Layouting::LayoutItem &parent) override;
|
||||||
|
|
||||||
@@ -37,7 +39,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QComboBox *m_webBrowserComboBox = nullptr;
|
QComboBox *m_webBrowserComboBox = nullptr;
|
||||||
QString m_currentBrowser;
|
QString m_currentBrowser;
|
||||||
const WebBrowserEntries m_availableBrowsers;
|
WebBrowserEntries m_availableBrowsers;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user