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->lineEdit()->setMinimumWidth(0);
|
||||
|
||||
connect(editor, &PathChooser::browsingFinished, this, [this, editor]() {
|
||||
connect(editor, &PathChooser::browsingFinished, this, [this, 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 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")
|
||||
.arg(id)
|
||||
.arg(QString::fromLatin1(stdInData.toBase64()))
|
||||
|
@@ -10,7 +10,7 @@ namespace Utils {
|
||||
class ExecuteOnDestruction
|
||||
{
|
||||
public:
|
||||
ExecuteOnDestruction() noexcept : destructionCode([](){}) {}
|
||||
ExecuteOnDestruction() noexcept : destructionCode([] {}) {}
|
||||
ExecuteOnDestruction(std::function<void()> code) : destructionCode(std::move(code)) {}
|
||||
~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(this, &QDockWidget::topLevelChanged, this, &DockWidget::handleToplevelChanged);
|
||||
connect(toggleViewAction(), &QAction::triggered, [this] {
|
||||
connect(toggleViewAction(), &QAction::triggered, this, [this] {
|
||||
if (isVisible())
|
||||
raise();
|
||||
});
|
||||
|
@@ -300,7 +300,7 @@ void InfoBarDisplay::update()
|
||||
showDetailsButton->setCheckable(true);
|
||||
showDetailsButton->setChecked(m_isShowingDetailsWidget);
|
||||
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;
|
||||
if (!detailsWidget) {
|
||||
detailsWidget = info.m_detailsWidgetCreator();
|
||||
@@ -323,7 +323,7 @@ void InfoBarDisplay::update()
|
||||
cb->addItem(comboInfo.displayText, comboInfo.data);
|
||||
if (info.m_combo.currentIndex >= 0 && info.m_combo.currentIndex < cb->count())
|
||||
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()});
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
@@ -334,7 +334,7 @@ void InfoBarDisplay::update()
|
||||
auto infoWidgetButton = new QToolButton;
|
||||
infoWidgetButton->setText(button.text);
|
||||
infoWidgetButton->setToolTip(button.tooltip);
|
||||
connect(infoWidgetButton, &QAbstractButton::clicked, [button]() { button.callback(); });
|
||||
connect(infoWidgetButton, &QAbstractButton::clicked, [button] { button.callback(); });
|
||||
hbox->addWidget(infoWidgetButton);
|
||||
}
|
||||
|
||||
|
@@ -160,7 +160,7 @@ LauncherInterface::LauncherInterface()
|
||||
m_private->setPathToLauncher(s_pathToLauncher);
|
||||
const FilePath launcherFilePath = FilePath::fromString(m_private->launcherFilePath())
|
||||
.cleanPath().withExecutableSuffix();
|
||||
auto launcherIsNotExecutable = [&launcherFilePath]() {
|
||||
auto launcherIsNotExecutable = [&launcherFilePath] {
|
||||
qWarning() << "The Creator's process launcher"
|
||||
<< 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
|
||||
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)) {
|
||||
didSchedule = true;
|
||||
auto watcher = new QFutureWatcher<MapResult>();
|
||||
connect(watcher, &QFutureWatcher<MapResult>::finished, this, [this, watcher]() {
|
||||
connect(watcher, &QFutureWatcher<MapResult>::finished, this, [this, watcher] {
|
||||
mapFinished(watcher);
|
||||
});
|
||||
if (m_handleProgress) {
|
||||
|
@@ -45,7 +45,7 @@ void MinimizableInfoBars::createActions()
|
||||
auto action = new QAction(this);
|
||||
action->setToolTip(entry.text());
|
||||
action->setIcon(Icons::WARNING_TOOLBAR.pixmap());
|
||||
connect(action, &QAction::triggered, this, [this, id]() {
|
||||
connect(action, &QAction::triggered, this, [this, id] {
|
||||
setShowInInfoBar(id, true);
|
||||
updateInfo(id);
|
||||
});
|
||||
|
@@ -22,7 +22,7 @@ NameValueValidator::NameValueValidator(QWidget *parent,
|
||||
{
|
||||
m_hideTipTimer.setInterval(2000);
|
||||
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
|
||||
|
@@ -72,7 +72,7 @@ static FilePath imageFileNameForIndicatorSize(ProgressIndicatorSize size)
|
||||
ProgressIndicatorPainter::ProgressIndicatorPainter(ProgressIndicatorSize size)
|
||||
{
|
||||
m_timer.setSingleShot(false);
|
||||
QObject::connect(&m_timer, &QTimer::timeout, [this] {
|
||||
QObject::connect(&m_timer, &QTimer::timeout, &m_timer, [this] {
|
||||
nextAnimationStep();
|
||||
if (m_callback)
|
||||
m_callback();
|
||||
|
@@ -594,7 +594,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future,
|
||||
QObject::connect(watcher,
|
||||
&QFutureWatcherBase::finished,
|
||||
receiver,
|
||||
[receiver, member, watcher]() { (receiver->*member)(watcher->future()); });
|
||||
[receiver, member, watcher] { (receiver->*member)(watcher->future()); });
|
||||
watcher->setFuture(future);
|
||||
return future;
|
||||
}
|
||||
@@ -610,7 +610,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future, QObject *guard, Function
|
||||
{
|
||||
auto watcher = new QFutureWatcher<T>();
|
||||
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());
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
@@ -627,7 +627,7 @@ const QFuture<T> &onFinished(const QFuture<T> &future, Function f)
|
||||
{
|
||||
auto watcher = new QFutureWatcher<T>();
|
||||
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());
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
|
@@ -376,7 +376,7 @@ VariableChooser::VariableChooser(QWidget *parent) :
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setFocusProxy(d->m_variableTree);
|
||||
setGeometry(QRect(0, 0, 400, 500));
|
||||
addMacroExpanderProvider([]() { return globalMacroExpander(); });
|
||||
addMacroExpanderProvider([] { return globalMacroExpander(); });
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
auto widget = new ObjectToFieldWidgetConverter();
|
||||
widget->toVariantFunction = toVariantFunction;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user