forked from qt-creator/qt-creator
Utils: Pass context object to lambda connections
Remove some unneeded lambda () brackets. Change-Id: I6b7e07cad8a240a7021c6ddacc84a971809ee717 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -119,7 +119,7 @@ QWidget *PathChooserDelegate::createEditor(QWidget *parent, const QStyleOptionVi
|
|||||||
editor->setAutoFillBackground(true); // To hide the text beneath the editor widget
|
editor->setAutoFillBackground(true); // To hide the text beneath the editor widget
|
||||||
editor->lineEdit()->setMinimumWidth(0);
|
editor->lineEdit()->setMinimumWidth(0);
|
||||||
|
|
||||||
connect(editor, &PathChooser::browsingFinished, this, [this, editor]() {
|
connect(editor, &PathChooser::browsingFinished, this, [this, editor] {
|
||||||
emit const_cast<PathChooserDelegate*>(this)->commitData(editor);
|
emit const_cast<PathChooserDelegate*>(this)->commitData(editor);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -108,7 +108,7 @@ RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData)
|
|||||||
const int id = ++m_currentId;
|
const int id = ++m_currentId;
|
||||||
const auto it = m_commandOutput.insert(id, CommandRun{{-1, {}, {}}, &waiter});
|
const auto it = m_commandOutput.insert(id, CommandRun{{-1, {}, {}}, &waiter});
|
||||||
|
|
||||||
QMetaObject::invokeMethod(m_shellProcess.get(), [this, id, cmd, stdInData]() {
|
QMetaObject::invokeMethod(m_shellProcess.get(), [this, id, cmd, stdInData] {
|
||||||
const QString command = QString("%1 \"%2\" %3\n")
|
const QString command = QString("%1 \"%2\" %3\n")
|
||||||
.arg(id)
|
.arg(id)
|
||||||
.arg(QString::fromLatin1(stdInData.toBase64()))
|
.arg(QString::fromLatin1(stdInData.toBase64()))
|
||||||
|
@@ -10,7 +10,7 @@ namespace Utils {
|
|||||||
class ExecuteOnDestruction
|
class ExecuteOnDestruction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExecuteOnDestruction() noexcept : destructionCode([](){}) {}
|
ExecuteOnDestruction() noexcept : destructionCode([] {}) {}
|
||||||
ExecuteOnDestruction(std::function<void()> code) : destructionCode(std::move(code)) {}
|
ExecuteOnDestruction(std::function<void()> code) : destructionCode(std::move(code)) {}
|
||||||
~ExecuteOnDestruction() { if (destructionCode) destructionCode(); }
|
~ExecuteOnDestruction() { if (destructionCode) destructionCode(); }
|
||||||
|
|
||||||
|
@@ -248,7 +248,7 @@ DockWidget::DockWidget(QWidget *inner, FancyMainWindow *parent, bool immutable)
|
|||||||
|
|
||||||
connect(&m_timer, &QTimer::timeout, this, &DockWidget::handleMouseTimeout);
|
connect(&m_timer, &QTimer::timeout, this, &DockWidget::handleMouseTimeout);
|
||||||
connect(this, &QDockWidget::topLevelChanged, this, &DockWidget::handleToplevelChanged);
|
connect(this, &QDockWidget::topLevelChanged, this, &DockWidget::handleToplevelChanged);
|
||||||
connect(toggleViewAction(), &QAction::triggered, [this] {
|
connect(toggleViewAction(), &QAction::triggered, this, [this] {
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
raise();
|
raise();
|
||||||
});
|
});
|
||||||
|
@@ -300,7 +300,7 @@ void InfoBarDisplay::update()
|
|||||||
showDetailsButton->setCheckable(true);
|
showDetailsButton->setCheckable(true);
|
||||||
showDetailsButton->setChecked(m_isShowingDetailsWidget);
|
showDetailsButton->setChecked(m_isShowingDetailsWidget);
|
||||||
showDetailsButton->setText(tr("&Show Details"));
|
showDetailsButton->setText(tr("&Show Details"));
|
||||||
connect(showDetailsButton, &QToolButton::clicked, [this, vbox, info] (bool) {
|
connect(showDetailsButton, &QToolButton::clicked, this, [this, vbox, info] (bool) {
|
||||||
QWidget *detailsWidget = vbox->count() == 2 ? vbox->itemAt(1)->widget() : nullptr;
|
QWidget *detailsWidget = vbox->count() == 2 ? vbox->itemAt(1)->widget() : nullptr;
|
||||||
if (!detailsWidget) {
|
if (!detailsWidget) {
|
||||||
detailsWidget = info.m_detailsWidgetCreator();
|
detailsWidget = info.m_detailsWidgetCreator();
|
||||||
@@ -323,7 +323,7 @@ void InfoBarDisplay::update()
|
|||||||
cb->addItem(comboInfo.displayText, comboInfo.data);
|
cb->addItem(comboInfo.displayText, comboInfo.data);
|
||||||
if (info.m_combo.currentIndex >= 0 && info.m_combo.currentIndex < cb->count())
|
if (info.m_combo.currentIndex >= 0 && info.m_combo.currentIndex < cb->count())
|
||||||
cb->setCurrentIndex(info.m_combo.currentIndex);
|
cb->setCurrentIndex(info.m_combo.currentIndex);
|
||||||
connect(cb, &QComboBox::currentIndexChanged, this, [cb, info]() {
|
connect(cb, &QComboBox::currentIndexChanged, this, [cb, info] {
|
||||||
info.m_combo.callback({cb->currentText(), cb->currentData()});
|
info.m_combo.callback({cb->currentText(), cb->currentData()});
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ void InfoBarDisplay::update()
|
|||||||
auto infoWidgetButton = new QToolButton;
|
auto infoWidgetButton = new QToolButton;
|
||||||
infoWidgetButton->setText(button.text);
|
infoWidgetButton->setText(button.text);
|
||||||
infoWidgetButton->setToolTip(button.tooltip);
|
infoWidgetButton->setToolTip(button.tooltip);
|
||||||
connect(infoWidgetButton, &QAbstractButton::clicked, [button]() { button.callback(); });
|
connect(infoWidgetButton, &QAbstractButton::clicked, [button] { button.callback(); });
|
||||||
hbox->addWidget(infoWidgetButton);
|
hbox->addWidget(infoWidgetButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -160,7 +160,7 @@ LauncherInterface::LauncherInterface()
|
|||||||
m_private->setPathToLauncher(s_pathToLauncher);
|
m_private->setPathToLauncher(s_pathToLauncher);
|
||||||
const FilePath launcherFilePath = FilePath::fromString(m_private->launcherFilePath())
|
const FilePath launcherFilePath = FilePath::fromString(m_private->launcherFilePath())
|
||||||
.cleanPath().withExecutableSuffix();
|
.cleanPath().withExecutableSuffix();
|
||||||
auto launcherIsNotExecutable = [&launcherFilePath]() {
|
auto launcherIsNotExecutable = [&launcherFilePath] {
|
||||||
qWarning() << "The Creator's process launcher"
|
qWarning() << "The Creator's process launcher"
|
||||||
<< launcherFilePath << "is not executable.";
|
<< launcherFilePath << "is not executable.";
|
||||||
};
|
};
|
||||||
|
@@ -360,7 +360,7 @@ void MacroExpander::registerIntVariable(const QByteArray &variable,
|
|||||||
{
|
{
|
||||||
const MacroExpander::IntFunction valuecopy = value; // do not capture a reference in a lambda
|
const MacroExpander::IntFunction valuecopy = value; // do not capture a reference in a lambda
|
||||||
registerVariable(variable, description,
|
registerVariable(variable, description,
|
||||||
[valuecopy]() { return QString::number(valuecopy ? valuecopy() : 0); });
|
[valuecopy] { return QString::number(valuecopy ? valuecopy() : 0); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -77,7 +77,7 @@ protected:
|
|||||||
&& m_mapWatcher.size() < std::max(m_threadPool->maxThreadCount(), 1)) {
|
&& m_mapWatcher.size() < std::max(m_threadPool->maxThreadCount(), 1)) {
|
||||||
didSchedule = true;
|
didSchedule = true;
|
||||||
auto watcher = new QFutureWatcher<MapResult>();
|
auto watcher = new QFutureWatcher<MapResult>();
|
||||||
connect(watcher, &QFutureWatcher<MapResult>::finished, this, [this, watcher]() {
|
connect(watcher, &QFutureWatcher<MapResult>::finished, this, [this, watcher] {
|
||||||
mapFinished(watcher);
|
mapFinished(watcher);
|
||||||
});
|
});
|
||||||
if (m_handleProgress) {
|
if (m_handleProgress) {
|
||||||
|
@@ -45,7 +45,7 @@ void MinimizableInfoBars::createActions()
|
|||||||
auto action = new QAction(this);
|
auto action = new QAction(this);
|
||||||
action->setToolTip(entry.text());
|
action->setToolTip(entry.text());
|
||||||
action->setIcon(Icons::WARNING_TOOLBAR.pixmap());
|
action->setIcon(Icons::WARNING_TOOLBAR.pixmap());
|
||||||
connect(action, &QAction::triggered, this, [this, id]() {
|
connect(action, &QAction::triggered, this, [this, id] {
|
||||||
setShowInInfoBar(id, true);
|
setShowInInfoBar(id, true);
|
||||||
updateInfo(id);
|
updateInfo(id);
|
||||||
});
|
});
|
||||||
|
@@ -22,7 +22,7 @@ NameValueValidator::NameValueValidator(QWidget *parent,
|
|||||||
{
|
{
|
||||||
m_hideTipTimer.setInterval(2000);
|
m_hideTipTimer.setInterval(2000);
|
||||||
m_hideTipTimer.setSingleShot(true);
|
m_hideTipTimer.setSingleShot(true);
|
||||||
connect(&m_hideTipTimer, &QTimer::timeout, this, []() { ToolTip::hide(); });
|
connect(&m_hideTipTimer, &QTimer::timeout, this, [] { ToolTip::hide(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QValidator::State NameValueValidator::validate(QString &in, int &pos) const
|
QValidator::State NameValueValidator::validate(QString &in, int &pos) const
|
||||||
|
@@ -72,7 +72,7 @@ static FilePath imageFileNameForIndicatorSize(ProgressIndicatorSize size)
|
|||||||
ProgressIndicatorPainter::ProgressIndicatorPainter(ProgressIndicatorSize size)
|
ProgressIndicatorPainter::ProgressIndicatorPainter(ProgressIndicatorSize size)
|
||||||
{
|
{
|
||||||
m_timer.setSingleShot(false);
|
m_timer.setSingleShot(false);
|
||||||
QObject::connect(&m_timer, &QTimer::timeout, [this] {
|
QObject::connect(&m_timer, &QTimer::timeout, &m_timer, [this] {
|
||||||
nextAnimationStep();
|
nextAnimationStep();
|
||||||
if (m_callback)
|
if (m_callback)
|
||||||
m_callback();
|
m_callback();
|
||||||
|
@@ -594,7 +594,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future,
|
|||||||
QObject::connect(watcher,
|
QObject::connect(watcher,
|
||||||
&QFutureWatcherBase::finished,
|
&QFutureWatcherBase::finished,
|
||||||
receiver,
|
receiver,
|
||||||
[receiver, member, watcher]() { (receiver->*member)(watcher->future()); });
|
[receiver, member, watcher] { (receiver->*member)(watcher->future()); });
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -610,7 +610,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future, QObject *guard, Function
|
|||||||
{
|
{
|
||||||
auto watcher = new QFutureWatcher<T>();
|
auto watcher = new QFutureWatcher<T>();
|
||||||
QObject::connect(watcher, &QFutureWatcherBase::finished, watcher, &QObject::deleteLater);
|
QObject::connect(watcher, &QFutureWatcherBase::finished, watcher, &QObject::deleteLater);
|
||||||
QObject::connect(watcher, &QFutureWatcherBase::finished, guard, [f, watcher]() {
|
QObject::connect(watcher, &QFutureWatcherBase::finished, guard, [f, watcher] {
|
||||||
f(watcher->future());
|
f(watcher->future());
|
||||||
});
|
});
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
@@ -627,7 +627,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future, Function f)
|
|||||||
{
|
{
|
||||||
auto watcher = new QFutureWatcher<T>();
|
auto watcher = new QFutureWatcher<T>();
|
||||||
QObject::connect(watcher, &QFutureWatcherBase::finished, watcher, &QObject::deleteLater);
|
QObject::connect(watcher, &QFutureWatcherBase::finished, watcher, &QObject::deleteLater);
|
||||||
QObject::connect(watcher, &QFutureWatcherBase::finished, [f, watcher]() {
|
QObject::connect(watcher, &QFutureWatcherBase::finished, [f, watcher] {
|
||||||
f(watcher->future());
|
f(watcher->future());
|
||||||
});
|
});
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
|
@@ -376,7 +376,7 @@ VariableChooser::VariableChooser(QWidget *parent) :
|
|||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
setFocusProxy(d->m_variableTree);
|
setFocusProxy(d->m_variableTree);
|
||||||
setGeometry(QRect(0, 0, 400, 500));
|
setGeometry(QRect(0, 0, 400, 500));
|
||||||
addMacroExpanderProvider([]() { return globalMacroExpander(); });
|
addMacroExpanderProvider([] { return globalMacroExpander(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -31,7 +31,7 @@ public:
|
|||||||
auto widget = new ObjectToFieldWidgetConverter();
|
auto widget = new ObjectToFieldWidgetConverter();
|
||||||
widget->toVariantFunction = toVariantFunction;
|
widget->toVariantFunction = toVariantFunction;
|
||||||
connect(sender, &QObject::destroyed, widget, &QObject::deleteLater);
|
connect(sender, &QObject::destroyed, widget, &QObject::deleteLater);
|
||||||
connect(sender, member, widget, [widget]() { emit widget->valueChanged(widget->value()); });
|
connect(sender, member, widget, [widget] { emit widget->valueChanged(widget->value()); });
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user