forked from qt-creator/qt-creator
ScxmlEditor: Avoid using sender()
Do some cleanup of unneeded () after lambda capture. Fit code into 100 char lines. Change-Id: I2494765f6ba7aa1f13f4eadb7183bc88febd9638 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -227,7 +227,7 @@ void MainWidget::init()
|
||||
if (provider)
|
||||
provider->init(m_errorPane->warningModel());
|
||||
|
||||
connect(m_errorPane, &ErrorWidget::mouseExited, this, [this]() {
|
||||
connect(m_errorPane, &ErrorWidget::mouseExited, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->unhighlightAll();
|
||||
@@ -264,12 +264,12 @@ void MainWidget::init()
|
||||
m_actionHandler = new ActionHandler(this);
|
||||
|
||||
// Connect actions
|
||||
connect(m_actionHandler->action(ActionZoomIn), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionZoomIn), &QAction::triggered, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->view()->zoomIn();
|
||||
});
|
||||
connect(m_actionHandler->action(ActionZoomOut), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionZoomOut), &QAction::triggered, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->view()->zoomOut();
|
||||
@@ -282,49 +282,62 @@ void MainWidget::init()
|
||||
});
|
||||
connect(m_actionHandler->action(ActionMagnifier), &QAction::toggled, this, &MainWidget::setMagnifier);
|
||||
|
||||
connect(m_navigator, &Navigator::hideFrame, this, [this]() { m_actionHandler->action(ActionNavigator)->setChecked(false); });
|
||||
connect(m_navigator, &Navigator::hideFrame, this,
|
||||
[this] { m_actionHandler->action(ActionNavigator)->setChecked(false); });
|
||||
connect(m_actionHandler->action(ActionNavigator), &QAction::toggled, m_navigator, &Navigator::setVisible);
|
||||
|
||||
connect(m_actionHandler->action(ActionCopy), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionCopy), &QAction::triggered, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->copy();
|
||||
});
|
||||
|
||||
connect(m_actionHandler->action(ActionCut), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionCut), &QAction::triggered, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->cut();
|
||||
});
|
||||
|
||||
connect(m_actionHandler->action(ActionPaste), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionPaste), &QAction::triggered, this, [this] {
|
||||
StateView *view = m_views.last();
|
||||
if (view)
|
||||
view->scene()->paste(view->view()->mapToScene(QPoint(30, 30)));
|
||||
});
|
||||
|
||||
connect(m_actionHandler->action(ActionExportToImage), &QAction::triggered, this, &MainWidget::exportToImage);
|
||||
connect(m_actionHandler->action(ActionScreenshot), &QAction::triggered, this, &MainWidget::saveScreenShot);
|
||||
connect(m_actionHandler->action(ActionExportToImage), &QAction::triggered,
|
||||
this, &MainWidget::exportToImage);
|
||||
connect(m_actionHandler->action(ActionScreenshot), &QAction::triggered,
|
||||
this, &MainWidget::saveScreenShot);
|
||||
|
||||
connect(m_errorPane->warningModel(), &WarningModel::warningsChanged, this, [this]() {
|
||||
m_actionHandler->action(ActionFullNamespace)->setEnabled(m_errorPane->warningModel()->count(Warning::ErrorType) <= 0);
|
||||
connect(m_errorPane->warningModel(), &WarningModel::warningsChanged, this, [this] {
|
||||
m_actionHandler->action(ActionFullNamespace)->setEnabled(
|
||||
m_errorPane->warningModel()->count(Warning::ErrorType) <= 0);
|
||||
});
|
||||
|
||||
connect(m_actionHandler->action(ActionFullNamespace), &QAction::triggered, this, [this](bool checked) {
|
||||
m_document->setUseFullNameSpace(checked);
|
||||
});
|
||||
|
||||
connect(m_actionHandler->action(ActionAlignLeft), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignLeft); });
|
||||
connect(m_actionHandler->action(ActionAlignRight), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignRight); });
|
||||
connect(m_actionHandler->action(ActionAlignTop), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignTop); });
|
||||
connect(m_actionHandler->action(ActionAlignBottom), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignBottom); });
|
||||
connect(m_actionHandler->action(ActionAlignHorizontal), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignHorizontal); });
|
||||
connect(m_actionHandler->action(ActionAlignVertical), &QAction::triggered, this, [this]() { alignButtonClicked(ActionAlignVertical); });
|
||||
connect(m_actionHandler->action(ActionAdjustWidth), &QAction::triggered, this, [this]() { adjustButtonClicked(ActionAdjustWidth); });
|
||||
connect(m_actionHandler->action(ActionAdjustHeight), &QAction::triggered, this, [this]() { adjustButtonClicked(ActionAdjustHeight); });
|
||||
connect(m_actionHandler->action(ActionAdjustSize), &QAction::triggered, this, [this]() { adjustButtonClicked(ActionAdjustSize); });
|
||||
|
||||
connect(m_actionHandler->action(ActionStatistics), &QAction::triggered, this, [this]() {
|
||||
connect(m_actionHandler->action(ActionAlignLeft), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignLeft); });
|
||||
connect(m_actionHandler->action(ActionAlignRight), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignRight); });
|
||||
connect(m_actionHandler->action(ActionAlignTop), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignTop); });
|
||||
connect(m_actionHandler->action(ActionAlignBottom), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignBottom); });
|
||||
connect(m_actionHandler->action(ActionAlignHorizontal), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignHorizontal); });
|
||||
connect(m_actionHandler->action(ActionAlignVertical), &QAction::triggered,
|
||||
this, [this] { alignButtonClicked(ActionAlignVertical); });
|
||||
connect(m_actionHandler->action(ActionAdjustWidth), &QAction::triggered,
|
||||
this, [this] { adjustButtonClicked(ActionAdjustWidth); });
|
||||
connect(m_actionHandler->action(ActionAdjustHeight), &QAction::triggered,
|
||||
this, [this] { adjustButtonClicked(ActionAdjustHeight); });
|
||||
connect(m_actionHandler->action(ActionAdjustSize), &QAction::triggered,
|
||||
this, [this] { adjustButtonClicked(ActionAdjustSize); });
|
||||
connect(m_actionHandler->action(ActionStatistics), &QAction::triggered,
|
||||
this, [this] {
|
||||
StatisticsDialog dialog;
|
||||
dialog.setDocument(m_document);
|
||||
dialog.exec();
|
||||
@@ -514,9 +527,10 @@ void MainWidget::addStateView(BaseItem *item)
|
||||
connect(view->view(), &GraphicsView::panningChanged, m_actionHandler->action(ActionPan), &QAction::setChecked);
|
||||
connect(view->view(), &GraphicsView::magnifierChanged, m_actionHandler->action(ActionMagnifier), &QAction::setChecked);
|
||||
connect(m_magnifier, &Magnifier::visibilityChanged, m_actionHandler->action(ActionMagnifier), &QAction::setChecked);
|
||||
connect(view->scene(), &GraphicsScene::openStateView, this, &MainWidget::addStateView, Qt::QueuedConnection);
|
||||
connect(view->scene(), &GraphicsScene::selectedStateCountChanged, this, [this](int count) {
|
||||
bool currentView = sender() == m_views.last()->scene();
|
||||
GraphicsScene *scene = view->scene();
|
||||
connect(scene, &GraphicsScene::openStateView, this, &MainWidget::addStateView, Qt::QueuedConnection);
|
||||
connect(scene, &GraphicsScene::selectedStateCountChanged, this, [this, scene](int count) {
|
||||
bool currentView = scene == m_views.last()->scene();
|
||||
|
||||
// Enable/disable alignments
|
||||
for (int i = ActionAlignLeft; i <= ActionAdjustSize; ++i)
|
||||
@@ -526,13 +540,13 @@ void MainWidget::addStateView(BaseItem *item)
|
||||
});
|
||||
|
||||
// Enable/disable color buttons
|
||||
connect(view->scene(), &GraphicsScene::selectedBaseItemCountChanged, this, [this](int count) {
|
||||
connect(scene, &GraphicsScene::selectedBaseItemCountChanged, this, [this](int count) {
|
||||
m_toolButtons[ToolButtonStateColor]->setEnabled(count > 0);
|
||||
m_toolButtons[ToolButtonFontColor]->setEnabled(count > 0);
|
||||
});
|
||||
|
||||
connect(view->scene(), &GraphicsScene::pasteAvailable, this, [this](bool para) {
|
||||
bool currentView = sender() == m_views.last()->scene();
|
||||
connect(scene, &GraphicsScene::pasteAvailable, this, [this, scene](bool para) {
|
||||
bool currentView = scene == m_views.last()->scene();
|
||||
m_actionHandler->action(ActionPaste)->setEnabled(currentView && para);
|
||||
});
|
||||
|
||||
|
@@ -54,7 +54,7 @@ PaneTitleButton::PaneTitleButton(OutputPane *pane, QWidget *parent)
|
||||
stopAlert();
|
||||
});
|
||||
|
||||
connect(&animator, &QAbstractAnimation::finished, this, [this]() {
|
||||
connect(&animator, &QAbstractAnimation::finished, this, [this] {
|
||||
m_animCounter++;
|
||||
if (m_animCounter < 8) {
|
||||
if (m_animCounter % 2 == 1)
|
||||
@@ -64,11 +64,11 @@ PaneTitleButton::PaneTitleButton(OutputPane *pane, QWidget *parent)
|
||||
}
|
||||
});
|
||||
|
||||
connect(pane, &OutputPane::titleChanged, this, [=]() {
|
||||
connect(pane, &OutputPane::titleChanged, this, [=] {
|
||||
setText(pane->title());
|
||||
});
|
||||
|
||||
connect(pane, &OutputPane::iconChanged, this, [=]() {
|
||||
connect(pane, &OutputPane::iconChanged, this, [=] {
|
||||
setIcon(pane->icon());
|
||||
});
|
||||
}
|
||||
@@ -138,8 +138,10 @@ int OutputTabWidget::addPane(OutputPane *pane)
|
||||
{
|
||||
if (pane) {
|
||||
auto button = new PaneTitleButton(pane, this);
|
||||
connect(button, &PaneTitleButton::clicked, this, &OutputTabWidget::buttonClicked);
|
||||
connect(pane, &OutputPane::dataChanged, this, &OutputTabWidget::showAlert);
|
||||
connect(button, &PaneTitleButton::clicked, this, [this, button](bool checked) {
|
||||
buttonClicked(button, checked);
|
||||
});
|
||||
connect(pane, &OutputPane::dataChanged, this, [this, pane] { showAlert(pane); });
|
||||
|
||||
m_toolBar->addWidget(button);
|
||||
m_stackedWidget->addWidget(pane);
|
||||
@@ -189,24 +191,26 @@ void OutputTabWidget::close()
|
||||
emit visibilityChanged(false);
|
||||
}
|
||||
|
||||
void OutputTabWidget::showAlert()
|
||||
void OutputTabWidget::showAlert(OutputPane *pane)
|
||||
{
|
||||
int index = m_pages.indexOf(qobject_cast<OutputPane*>(sender()));
|
||||
const int index = m_pages.indexOf(pane);
|
||||
if (index >= 0 && !m_buttons[index]->isChecked())
|
||||
m_buttons[index]->startAlert(m_pages[index]->alertColor());
|
||||
}
|
||||
|
||||
void OutputTabWidget::buttonClicked(bool para)
|
||||
void OutputTabWidget::buttonClicked(PaneTitleButton *button, bool checked)
|
||||
{
|
||||
int index = m_buttons.indexOf(qobject_cast<PaneTitleButton*>(sender()));
|
||||
if (index >= 0) {
|
||||
if (para) {
|
||||
for (int i = 0; i < m_buttons.count(); ++i) {
|
||||
if (i != index)
|
||||
m_buttons[i]->setChecked(false);
|
||||
}
|
||||
showPane(index);
|
||||
} else
|
||||
close();
|
||||
const int index = m_buttons.indexOf(button);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
if (checked) {
|
||||
for (int i = 0; i < m_buttons.count(); ++i) {
|
||||
if (i != index)
|
||||
m_buttons[i]->setChecked(false);
|
||||
}
|
||||
showPane(index);
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@@ -87,11 +87,11 @@ signals:
|
||||
private:
|
||||
void createUi();
|
||||
void close();
|
||||
void buttonClicked(bool para);
|
||||
void showAlert();
|
||||
void buttonClicked(PaneTitleButton *button, bool checked);
|
||||
void showAlert(OutputPane *pane);
|
||||
|
||||
QVector<OutputPane*> m_pages;
|
||||
QVector<PaneTitleButton*> m_buttons;
|
||||
QVector<OutputPane *> m_pages;
|
||||
QVector<PaneTitleButton *> m_buttons;
|
||||
|
||||
QToolBar *m_toolBar = nullptr;
|
||||
QStackedWidget *m_stackedWidget = nullptr;
|
||||
|
Reference in New Issue
Block a user