Various Plugins: Add context object into connections

Change-Id: I360677bebfef16a3233b3b8177cff6da57ec7c31
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-08-01 19:59:54 +02:00
parent 47fce17aa3
commit aa016cc5a7
17 changed files with 36 additions and 35 deletions

View File

@@ -205,7 +205,7 @@ void AxivionPluginPrivate::onStartupProjectChanged()
void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName) void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
{ {
if (m_runningQuery) { // re-schedule if (m_runningQuery) { // re-schedule
QTimer::singleShot(3000, [this, projectName]{ fetchProjectInfo(projectName); }); QTimer::singleShot(3000, this, [this, projectName] { fetchProjectInfo(projectName); });
return; return;
} }
clearAllMarks(); clearAllMarks();
@@ -228,7 +228,7 @@ void AxivionPluginPrivate::fetchProjectInfo(const QString &projectName)
void AxivionPluginPrivate::fetchRuleInfo(const QString &id) void AxivionPluginPrivate::fetchRuleInfo(const QString &id)
{ {
if (m_runningQuery) { if (m_runningQuery) {
QTimer::singleShot(3000, [this, id]{ fetchRuleInfo(id); }); QTimer::singleShot(3000, this, [this, id] { fetchRuleInfo(id); });
return; return;
} }

View File

@@ -93,7 +93,7 @@ SessionNameInputDialog::SessionNameInputDialog(QWidget *parent)
}.attachTo(this); }.attachTo(this);
// clang-format on // clang-format on
connect(m_newSessionLineEdit, &QLineEdit::textChanged, [this](const QString &text) { connect(m_newSessionLineEdit, &QLineEdit::textChanged, this, [this](const QString &text) {
m_okButton->setEnabled(!text.isEmpty()); m_okButton->setEnabled(!text.isEmpty());
m_switchToButton->setEnabled(!text.isEmpty()); m_switchToButton->setEnabled(!text.isEmpty());
}); });

View File

@@ -54,10 +54,10 @@ SessionView::SessionView(QWidget *parent)
selectionModel()->select(firstRow, QItemSelectionModel::QItemSelectionModel:: selectionModel()->select(firstRow, QItemSelectionModel::QItemSelectionModel::
SelectCurrent); SelectCurrent);
connect(this, &Utils::TreeView::activated, [this](const QModelIndex &index){ connect(this, &Utils::TreeView::activated, this, [this](const QModelIndex &index){
emit sessionActivated(m_sessionModel.sessionAt(index.row())); emit sessionActivated(m_sessionModel.sessionAt(index.row()));
}); });
connect(selectionModel(), &QItemSelectionModel::selectionChanged, [this] { connect(selectionModel(), &QItemSelectionModel::selectionChanged, this, [this] {
emit sessionsSelected(selectedSessions()); emit sessionsSelected(selectedSessions());
}); });

View File

@@ -55,7 +55,7 @@ public:
CppcheckPluginPrivate::CppcheckPluginPrivate() CppcheckPluginPrivate::CppcheckPluginPrivate()
{ {
tool.updateOptions(); tool.updateOptions();
connect(&settings(), &AspectContainer::changed, [this] { connect(&settings(), &AspectContainer::changed, this, [this] {
tool.updateOptions(); tool.updateOptions();
trigger.recheck(); trigger.recheck();
}); });

View File

@@ -31,7 +31,7 @@ CtfStatisticsView::CtfStatisticsView(CtfStatisticsModel *model, QWidget *parent)
setUniformRowHeights(true); setUniformRowHeights(true);
setSortingEnabled(true); setSortingEnabled(true);
connect(selectionModel(), &QItemSelectionModel::currentChanged, connect(selectionModel(), &QItemSelectionModel::currentChanged, this,
[this] (const QModelIndex &current, const QModelIndex &previous) [this] (const QModelIndex &current, const QModelIndex &previous)
{ {
Q_UNUSED(previous); Q_UNUSED(previous);

View File

@@ -97,8 +97,7 @@ void CtfVisualizerTool::createViews()
m_statisticsView = new CtfStatisticsView(m_statisticsModel.get()); m_statisticsView = new CtfStatisticsView(m_statisticsModel.get());
m_statisticsView->setWindowTitle(Tr::tr("Statistics")); m_statisticsView->setWindowTitle(Tr::tr("Statistics"));
connect(m_statisticsView, &CtfStatisticsView::eventTypeSelected, [this] (QString title) connect(m_statisticsView, &CtfStatisticsView::eventTypeSelected, this, [this](QString title) {
{
int typeId = m_traceManager->getSelectionId(title.toStdString()); int typeId = m_traceManager->getSelectionId(title.toStdString());
m_traceView->selectByTypeId(typeId); m_traceView->selectByTypeId(typeId);
}); });

View File

@@ -502,7 +502,7 @@ FakeVimExCommandsMappings::FakeVimExCommandsMappings()
auto infoLabel = new InfoLabel(Tr::tr("Invalid regular expression."), InfoLabel::Error); auto infoLabel = new InfoLabel(Tr::tr("Invalid regular expression."), InfoLabel::Error);
infoLabel->setVisible(false); infoLabel->setVisible(false);
connect(m_commandEdit, &FancyLineEdit::validChanged, [infoLabel](bool valid){ connect(m_commandEdit, &FancyLineEdit::validChanged, this, [infoLabel](bool valid){
infoLabel->setVisible(!valid); infoLabel->setVisible(!valid);
}); });
commandBoxLayout->addWidget(infoLabel); commandBoxLayout->addWidget(infoLabel);

View File

@@ -915,8 +915,10 @@ void FossilClient::log(const FilePath &workingDir, const QStringList &files,
if (VcsBaseEditorConfig *editorConfig = createLogEditor(fossilEditor)) { if (VcsBaseEditorConfig *editorConfig = createLogEditor(fossilEditor)) {
editorConfig->setBaseArguments(extraOptions); editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet // editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
[=]() { this->log(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu, addAuthOptions); } ); log(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu,
addAuthOptions);
});
fossilEditor->setEditorConfig(editorConfig); fossilEditor->setEditorConfig(editorConfig);
} }
} }
@@ -968,8 +970,10 @@ void FossilClient::logCurrentFile(const FilePath &workingDir, const QStringList
if (VcsBaseEditorConfig *editorConfig = createLogCurrentFileEditor(fossilEditor)) { if (VcsBaseEditorConfig *editorConfig = createLogCurrentFileEditor(fossilEditor)) {
editorConfig->setBaseArguments(extraOptions); editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet // editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
[=]() { this->logCurrentFile(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu, addAuthOptions); } ); logCurrentFile(workingDir, files, editorConfig->arguments(),
enableAnnotationContextMenu, addAuthOptions);
});
fossilEditor->setEditorConfig(editorConfig); fossilEditor->setEditorConfig(editorConfig);
} }
} }

View File

@@ -323,14 +323,11 @@ HelpWidget::HelpWidget(const Core::Context &context, WidgetStyle style, QWidget
helpTargetButton->setProperty(Utils::StyleHelper::C_NO_ARROW, true); helpTargetButton->setProperty(Utils::StyleHelper::C_NO_ARROW, true);
helpTargetButton->setPopupMode(QToolButton::DelayedPopup); helpTargetButton->setPopupMode(QToolButton::DelayedPopup);
helpTargetButton->setMenu(createHelpTargetMenu(helpTargetButton)); helpTargetButton->setMenu(createHelpTargetMenu(helpTargetButton));
connect(LocalHelpManager::instance(), connect(LocalHelpManager::instance(), &LocalHelpManager::contextHelpOptionChanged, this,
&LocalHelpManager::contextHelpOptionChanged,
[this, helpTargetAction] { [this, helpTargetAction] {
helpTargetAction->setChecked(isTargetOfContextHelp(m_style)); helpTargetAction->setChecked(isTargetOfContextHelp(m_style));
}); });
connect(helpTargetAction, connect(helpTargetAction, &QAction::triggered, this,
&QAction::triggered,
this,
[this, helpTargetAction, helpTargetButton](bool checked) { [this, helpTargetAction, helpTargetButton](bool checked) {
if (checked) { if (checked) {
LocalHelpManager::setContextHelpOption(optionForStyle(m_style)); LocalHelpManager::setContextHelpOption(optionForStyle(m_style));

View File

@@ -74,7 +74,7 @@ public:
connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator, connect(m_sectionedProducts, &SectionedProducts::toggleProgressIndicator,
progressIndicator, &Utils::ProgressIndicator::setVisible); progressIndicator, &Utils::ProgressIndicator::setVisible);
connect(m_sectionedProducts, &SectionedProducts::errorOccurred, connect(m_sectionedProducts, &SectionedProducts::errorOccurred, this,
[this, progressIndicator, searchBox](int, const QString &message) { [this, progressIndicator, searchBox](int, const QString &message) {
progressIndicator->hide(); progressIndicator->hide();
progressIndicator->deleteLater(); progressIndicator->deleteLater();

View File

@@ -89,9 +89,9 @@ McuKitCreationDialog::McuKitCreationDialog(const MessagesList &messages,
if (qtMCUPackage->isValidStatus()) if (qtMCUPackage->isValidStatus())
m_qtMCUsPathLabel->setText( m_qtMCUsPathLabel->setText(
Tr::tr("Qt for MCUs path %1").arg(qtMCUPackage->path().toUserOutput())); Tr::tr("Qt for MCUs path %1").arg(qtMCUPackage->path().toUserOutput()));
connect(m_nextButton, &QPushButton::clicked, [=] { updateMessage(1); }); connect(m_nextButton, &QPushButton::clicked, this, [this] { updateMessage(1); });
connect(m_previousButton, &QPushButton::clicked, [=] { updateMessage(-1); }); connect(m_previousButton, &QPushButton::clicked, this, [this] { updateMessage(-1); });
connect(fixButton, &QPushButton::clicked, [=] { connect(fixButton, &QPushButton::clicked, this, [this, settingsHandler] {
// Open the MCU Options widget on the current platform // Open the MCU Options widget on the current platform
settingsHandler->setInitialPlatformName(m_messages[m_currentIndex].platform); settingsHandler->setInitialPlatformName(m_messages[m_currentIndex].platform);
Core::ICore::showOptionsDialog(Constants::SETTINGS_ID); Core::ICore::showOptionsDialog(Constants::SETTINGS_ID);

View File

@@ -221,7 +221,8 @@ public:
m_showProgressTimer.setSingleShot(true); m_showProgressTimer.setSingleShot(true);
m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks m_showProgressTimer.setInterval(50); // don't show progress for < 50ms tasks
connect(&m_showProgressTimer, &QTimer::timeout, [this]() { m_progressIndicator.show(); }); connect(&m_showProgressTimer, &QTimer::timeout,
this, [this] { m_progressIndicator.show(); });
connect(&m_optionsModel, &BuidOptionsModel::configurationChanged, this, [configureButton] { connect(&m_optionsModel, &BuidOptionsModel::configurationChanged, this, [configureButton] {
configureButton->setEnabled(true); configureButton->setEnabled(true);
}); });
@@ -274,13 +275,15 @@ public:
optionsTreeView, optionsTreeView,
[tree = optionsTreeView](const QModelIndex &idx) { tree->edit(idx); }); [tree = optionsTreeView](const QModelIndex &idx) { tree->edit(idx); });
connect(configureButton, &QPushButton::clicked, [this, bs, configureButton, optionsTreeView] { connect(configureButton, &QPushButton::clicked,
this, [this, bs, configureButton, optionsTreeView] {
optionsTreeView->setEnabled(false); optionsTreeView->setEnabled(false);
configureButton->setEnabled(false); configureButton->setEnabled(false);
m_showProgressTimer.start(); m_showProgressTimer.start();
bs->configure(); bs->configure();
}); });
connect(wipeButton, &QPushButton::clicked, [this, bs, configureButton, optionsTreeView] { connect(wipeButton, &QPushButton::clicked,
this, [this, bs, configureButton, optionsTreeView] {
optionsTreeView->setEnabled(false); optionsTreeView->setEnabled(false);
configureButton->setEnabled(false); configureButton->setEnabled(false);
m_showProgressTimer.start(); m_showProgressTimer.start();

View File

@@ -22,7 +22,7 @@ public:
NimSuggestCache() NimSuggestCache()
{ {
setExecutablePath(settings().nimSuggestPath()); setExecutablePath(settings().nimSuggestPath());
QObject::connect(&settings().nimSuggestPath, &StringAspect::changed, [this] { QObject::connect(&settings().nimSuggestPath, &StringAspect::changed, this, [this] {
setExecutablePath(settings().nimSuggestPath()); setExecutablePath(settings().nimSuggestPath());
}); });

View File

@@ -151,7 +151,7 @@ QString SerialControl::baudRateText() const
void SerialControl::pulseDataTerminalReady() void SerialControl::pulseDataTerminalReady()
{ {
m_serialPort.setDataTerminalReady(!m_initialDtrState); m_serialPort.setDataTerminalReady(!m_initialDtrState);
QTimer::singleShot(Constants::RESET_DELAY, [&]() { QTimer::singleShot(Constants::RESET_DELAY, this, [this] {
m_serialPort.setDataTerminalReady(m_initialDtrState); m_serialPort.setDataTerminalReady(m_initialDtrState);
}); });
} }

View File

@@ -257,14 +257,12 @@ void SerialOutputPane::createNewOutputWindow(SerialControl *rc)
return; return;
// Signals to update buttons // Signals to update buttons
connect(rc, &SerialControl::started, connect(rc, &SerialControl::started, this, [this, rc] {
[this, rc]() {
if (isCurrent(rc)) if (isCurrent(rc))
enableButtons(rc, true); enableButtons(rc, true);
}); });
connect(rc, &SerialControl::finished, connect(rc, &SerialControl::finished, this, [this, rc] {
[this, rc]() {
const int tabIndex = indexOf(rc); const int tabIndex = indexOf(rc);
if (tabIndex != -1) if (tabIndex != -1)
m_serialControlTabs[tabIndex].window->flush(); m_serialControlTabs[tabIndex].window->flush();

View File

@@ -351,12 +351,12 @@ WelcomeMode::WelcomeMode()
m_modeWidget = new ResizeSignallingWidget; m_modeWidget = new ResizeSignallingWidget;
m_modeWidget->setPalette(palette); m_modeWidget->setPalette(palette);
connect(m_modeWidget, &ResizeSignallingWidget::resized, connect(m_modeWidget, &ResizeSignallingWidget::resized, this,
[this](const QSize &size, const QSize &) { [this](const QSize &size, const QSize &) {
const bool hideSideArea = size.width() <= 750; const bool hideSideArea = size.width() <= 750;
const bool hideBottomArea = size.width() <= 850; const bool hideBottomArea = size.width() <= 850;
const bool compactVertically = size.height() <= 530; const bool compactVertically = size.height() <= 530;
QTimer::singleShot(0, [this, hideSideArea, hideBottomArea, compactVertically]() { QTimer::singleShot(0, this, [this, hideSideArea, hideBottomArea, compactVertically] {
m_sideArea->setVisible(!hideSideArea); m_sideArea->setVisible(!hideSideArea);
m_bottomArea->setVisible(!(hideBottomArea || compactVertically)); m_bottomArea->setVisible(!(hideBottomArea || compactVertically));
m_topArea->setCompact(compactVertically); m_topArea->setCompact(compactVertically);

View File

@@ -9,7 +9,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
QTimer::singleShot(0, [] { QTimer::singleShot(0, &app, [] {
QInputDialog dlg; QInputDialog dlg;
const QStringList appArgs = qApp->arguments(); const QStringList appArgs = qApp->arguments();
QString labelText = QCoreApplication::translate("qtc-askpass", QString labelText = QCoreApplication::translate("qtc-askpass",