forked from qt-creator/qt-creator
ScxmlEditor: Pass context object to lambda connections
Remove some unneeded lambda () brackets. Change-Id: I12a3498c3c13121e021e13b763905fc6a41b214d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -82,7 +82,7 @@ void ColorThemes::updateColorThemeMenu()
|
||||
? Tr::tr("Factory Default") : key == Constants::C_COLOR_SCHEME_SCXMLDOCUMENT
|
||||
? Tr::tr("Colors from SCXML Document")
|
||||
: key;
|
||||
QAction *action = m_menu->addAction(actionText, this, [this, key]() {
|
||||
QAction *action = m_menu->addAction(actionText, this, [this, key] {
|
||||
selectColorTheme(key);
|
||||
});
|
||||
action->setData(key);
|
||||
|
@@ -32,7 +32,7 @@ ColorToolButton::ColorToolButton(const QString &key, const QString &iconName, co
|
||||
setToolTip(tooltip);
|
||||
setPopupMode(QToolButton::MenuButtonPopup);
|
||||
|
||||
connect(this, &ColorToolButton::clicked, this, [this]() {
|
||||
connect(this, &ColorToolButton::clicked, this, [this] {
|
||||
setCurrentColor(m_color);
|
||||
});
|
||||
|
||||
|
@@ -216,19 +216,19 @@ void MainWidget::init()
|
||||
view->scene()->unhighlightAll();
|
||||
});
|
||||
|
||||
connect(m_errorPane, &ErrorWidget::warningEntered, [this](Warning *w) {
|
||||
connect(m_errorPane, &ErrorWidget::warningEntered, this, [this](Warning *w) {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->highlightWarningItem(w);
|
||||
});
|
||||
|
||||
connect(m_errorPane, &ErrorWidget::warningSelected, [this](Warning *w) {
|
||||
connect(m_errorPane, &ErrorWidget::warningSelected, this, [this](Warning *w) {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->selectWarningItem(w);
|
||||
});
|
||||
|
||||
connect(m_errorPane, &ErrorWidget::warningDoubleClicked, [this](Warning *w) {
|
||||
connect(m_errorPane, &ErrorWidget::warningDoubleClicked, this, [this](Warning *w) {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->view()->zoomToItem(view->scene()->findItem(view->scene()->tagByWarning(w)));
|
||||
@@ -333,14 +333,14 @@ void MainWidget::init()
|
||||
QToolButton *adjustToolButton = createToolButton(toolButtonIcon(ActionAdjustWidth), Tr::tr("Adjust Width"), QToolButton::MenuButtonPopup);
|
||||
|
||||
// Connect state color change
|
||||
connect(stateColorButton, &ColorToolButton::colorSelected, [this](const QString &color) {
|
||||
connect(stateColorButton, &ColorToolButton::colorSelected, this, [this](const QString &color) {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->setEditorInfo(Constants::C_SCXML_EDITORINFO_STATECOLOR, color);
|
||||
});
|
||||
|
||||
// Connect font color change
|
||||
connect(fontColorButton, &ColorToolButton::colorSelected, [this](const QString &color) {
|
||||
connect(fontColorButton, &ColorToolButton::colorSelected, this, [this](const QString &color) {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->setEditorInfo(Constants::C_SCXML_EDITORINFO_FONTCOLOR, color);
|
||||
|
@@ -30,7 +30,7 @@ ShapeGroupWidget::ShapeGroupWidget(ShapeProvider *shapeProvider, int groupIndex,
|
||||
m_content->layout()->addWidget(button);
|
||||
}
|
||||
|
||||
connect(m_closeButton, &QToolButton::clicked, this, [this]() {
|
||||
connect(m_closeButton, &QToolButton::clicked, this, [this] {
|
||||
m_content->setVisible(!m_content->isVisible());
|
||||
m_closeButton->setIcon(m_content->isVisible()
|
||||
? Utils::Icons::COLLAPSE_TOOLBAR.icon()
|
||||
|
@@ -37,34 +37,34 @@ ErrorWidget::ErrorWidget(QWidget *parent)
|
||||
|
||||
m_errorsTable->setModel(m_proxyModel);
|
||||
|
||||
connect(m_errorsTable, &TableView::entered, [this](const QModelIndex &ind) {
|
||||
connect(m_errorsTable, &TableView::entered, this, [this](const QModelIndex &ind) {
|
||||
if (ind.isValid())
|
||||
emit warningEntered(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
|
||||
});
|
||||
|
||||
connect(m_errorsTable, &TableView::pressed, [this](const QModelIndex &ind) {
|
||||
connect(m_errorsTable, &TableView::pressed, this, [this](const QModelIndex &ind) {
|
||||
if (ind.isValid())
|
||||
emit warningSelected(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
|
||||
});
|
||||
|
||||
connect(m_errorsTable, &TableView::doubleClicked, [this](const QModelIndex &ind) {
|
||||
connect(m_errorsTable, &TableView::doubleClicked, this, [this](const QModelIndex &ind) {
|
||||
if (ind.isValid())
|
||||
emit warningDoubleClicked(m_warningModel->getWarning(m_proxyModel->mapToSource(ind)));
|
||||
});
|
||||
|
||||
connect(m_errorsTable, &TableView::mouseExited, this, [this](){
|
||||
connect(m_errorsTable, &TableView::mouseExited, this, [this] {
|
||||
emit mouseExited();
|
||||
});
|
||||
|
||||
connect(m_showErrors, &QToolButton::toggled, [this](bool show) {
|
||||
connect(m_showErrors, &QToolButton::toggled, this, [this](bool show) {
|
||||
m_warningModel->setShowWarnings(Warning::ErrorType, show);
|
||||
});
|
||||
|
||||
connect(m_showWarnings, &QToolButton::toggled, [this](bool show) {
|
||||
connect(m_showWarnings, &QToolButton::toggled, this, [this](bool show) {
|
||||
m_warningModel->setShowWarnings(Warning::WarningType, show);
|
||||
});
|
||||
|
||||
connect(m_showInfos, &QToolButton::toggled, [this](bool show) {
|
||||
connect(m_showInfos, &QToolButton::toggled, this, [this](bool show) {
|
||||
m_warningModel->setShowWarnings(Warning::InfoType, show);
|
||||
});
|
||||
|
||||
|
@@ -17,7 +17,7 @@ WarningModel::WarningModel(QObject *parent)
|
||||
m_countChecker = new QTimer(this);
|
||||
m_countChecker->setInterval(500);
|
||||
m_countChecker->setSingleShot(true);
|
||||
connect(m_countChecker.data(), &QTimer::timeout, this, [this]() {
|
||||
connect(m_countChecker.data(), &QTimer::timeout, this, [this] {
|
||||
if (m_warnings.count() != m_oldCount) {
|
||||
m_oldCount = m_warnings.count();
|
||||
emit countChanged(m_oldCount);
|
||||
|
@@ -17,15 +17,10 @@ TagTextItem::TagTextItem(QGraphicsItem *parent)
|
||||
setFlag(ItemIsFocusable, true);
|
||||
setFlag(ItemIsSelectable, true);
|
||||
m_textItem = new TextItem(this);
|
||||
connect(m_textItem, &TextItem::textChanged, this, [=](){
|
||||
emit textChanged();
|
||||
});
|
||||
connect(m_textItem, &TextItem::textReady, this, [=](const QString &text){
|
||||
emit textReady(text);
|
||||
});
|
||||
connect(m_textItem, &TextItem::selected, this, [=](bool sel){
|
||||
emit selected(sel);
|
||||
});
|
||||
connect(m_textItem, &TextItem::textChanged, this, [this] { emit textChanged(); });
|
||||
connect(m_textItem, &TextItem::textReady,
|
||||
this, [this](const QString &text) { emit textReady(text); });
|
||||
connect(m_textItem, &TextItem::selected, this, [this](bool sel) { emit selected(sel); });
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
|
@@ -53,15 +53,15 @@ public:
|
||||
ScxmlTextEditorFactory()
|
||||
{
|
||||
setId(ScxmlEditor::Constants::K_SCXML_EDITOR_ID);
|
||||
setEditorCreator([]() { return new ScxmlTextEditor; });
|
||||
setEditorWidgetCreator([]() { return new ScxmlTextEditorWidget; });
|
||||
setEditorCreator([] { return new ScxmlTextEditor; });
|
||||
setEditorWidgetCreator([] { return new ScxmlTextEditorWidget; });
|
||||
setUseGenericHighlighter(true);
|
||||
setDuplicatedSupported(false);
|
||||
}
|
||||
|
||||
ScxmlTextEditor *create(ScxmlEditor::Common::MainWidget *designWidget)
|
||||
{
|
||||
setDocumentCreator([designWidget]() { return new ScxmlEditorDocument(designWidget); });
|
||||
setDocumentCreator([designWidget] { return new ScxmlEditorDocument(designWidget); });
|
||||
return qobject_cast<ScxmlTextEditor*>(createEditor());
|
||||
}
|
||||
};
|
||||
@@ -70,7 +70,8 @@ ScxmlEditorData::ScxmlEditorData()
|
||||
{
|
||||
m_contexts.add(ScxmlEditor::Constants::C_SCXMLEDITOR);
|
||||
|
||||
QObject::connect(EditorManager::instance(), &EditorManager::currentEditorChanged, [this](IEditor *editor) {
|
||||
QObject::connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
||||
this, [this](IEditor *editor) {
|
||||
if (editor && editor->document()->id() == Constants::K_SCXML_EDITOR_ID) {
|
||||
auto xmlEditor = qobject_cast<ScxmlTextEditor*>(editor);
|
||||
QTC_ASSERT(xmlEditor, return );
|
||||
@@ -142,7 +143,8 @@ IEditor *ScxmlEditorData::createEditor()
|
||||
if (xmlEditor) {
|
||||
Utils::InfoBarEntry info(Id(Constants::INFO_READ_ONLY),
|
||||
Tr::tr("This file can only be edited in <b>Design</b> mode."));
|
||||
info.addCustomButton(Tr::tr("Switch Mode"), []() { ModeManager::activateMode(Core::Constants::MODE_DESIGN); });
|
||||
info.addCustomButton(Tr::tr("Switch Mode"),
|
||||
[] { ModeManager::activateMode(Core::Constants::MODE_DESIGN); });
|
||||
xmlEditor->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
|
@@ -29,9 +29,9 @@ void ScxmlTextEditor::finalizeInitialization()
|
||||
// Revert to saved/load externally modified files.
|
||||
auto document = qobject_cast<const ScxmlEditorDocument*>(textDocument());
|
||||
connect(document, &ScxmlEditorDocument::reloadRequested,
|
||||
[this](QString *errorString, const QString &fileName) {
|
||||
open(errorString, fileName, fileName);
|
||||
});
|
||||
this, [this](QString *errorString, const QString &fileName) {
|
||||
open(errorString, fileName, fileName);
|
||||
});
|
||||
}
|
||||
|
||||
bool ScxmlTextEditor::open(QString *errorString, const QString &fileName, const QString & /*realFileName*/)
|
||||
|
Reference in New Issue
Block a user