forked from qt-creator/qt-creator
CrumblePath: Avoid using sender()
Change-Id: I4aa2e6646707e6f69bf0a69530638546b94162fd Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -210,7 +210,9 @@ void CrumblePath::pushElement(const QString &title, const QVariant &data)
|
|||||||
auto *newButton = new CrumblePathButton(title, this);
|
auto *newButton = new CrumblePathButton(title, this);
|
||||||
newButton->setData(data);
|
newButton->setData(data);
|
||||||
m_buttonsLayout->addWidget(newButton);
|
m_buttonsLayout->addWidget(newButton);
|
||||||
connect(newButton, &QAbstractButton::clicked, this, &CrumblePath::emitElementClicked);
|
connect(newButton, &QAbstractButton::clicked, this, [this, newButton] {
|
||||||
|
emit elementClicked(newButton->data());
|
||||||
|
});
|
||||||
|
|
||||||
if (m_buttons.empty()) {
|
if (m_buttons.empty()) {
|
||||||
newButton->setSegmentType(CrumblePathButton::SingleSegment);
|
newButton->setSegmentType(CrumblePathButton::SingleSegment);
|
||||||
@@ -235,7 +237,9 @@ void CrumblePath::addChild(const QString &title, const QVariant &data)
|
|||||||
|
|
||||||
auto *childAction = new QAction(title, lastButton);
|
auto *childAction = new QAction(title, lastButton);
|
||||||
childAction->setData(data);
|
childAction->setData(data);
|
||||||
connect(childAction, &QAction::triggered, this, &CrumblePath::emitElementClicked);
|
connect(childAction, &QAction::triggered, this, [this, childAction] {
|
||||||
|
emit elementClicked(childAction->data());
|
||||||
|
});
|
||||||
childList->addAction(childAction);
|
childList->addAction(childAction);
|
||||||
lastButton->setMenu(childList);
|
lastButton->setMenu(childList);
|
||||||
}
|
}
|
||||||
@@ -262,15 +266,6 @@ void CrumblePath::clear()
|
|||||||
popElement();
|
popElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrumblePath::emitElementClicked()
|
|
||||||
{
|
|
||||||
QObject *element = sender();
|
|
||||||
if (auto *action = qobject_cast<QAction*>(element))
|
|
||||||
emit elementClicked(action->data());
|
|
||||||
else if (auto *button = qobject_cast<CrumblePathButton*>(element))
|
|
||||||
emit elementClicked(button->data());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
#include "crumblepath.moc"
|
#include "crumblepath.moc"
|
||||||
|
@@ -56,7 +56,6 @@ signals:
|
|||||||
void elementClicked(const QVariant &data);
|
void elementClicked(const QVariant &data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitElementClicked();
|
|
||||||
void setBackgroundStyle();
|
void setBackgroundStyle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user