Commit 7e08cca3 authored by hjk's avatar hjk

Core: Reduce use of Id::fromUniqueIdentifier in the Infobar

Should be the exception in general and is with Qt5/C++11 in this
particular case not needed anymore.

Change-Id: Ida3f1fb534a6c7c1c6a84f8d4bc62e1636964f44
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent fc648086
......@@ -229,22 +229,25 @@ void InfoBarDisplay::update()
hbox->addWidget(infoWidgetButton);
}
const Id id = info.id;
QToolButton *infoWidgetSuppressButton = 0;
if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) {
infoWidgetSuppressButton = new QToolButton;
infoWidgetSuppressButton->setProperty("infoId", info.id.uniqueIdentifier());
infoWidgetSuppressButton->setText(tr("Do Not Show Again"));
connect(infoWidgetSuppressButton, SIGNAL(clicked()), SLOT(suppressButtonClicked()));
connect(infoWidgetSuppressButton, &QAbstractButton::clicked, this, [this, id] {
m_infoBar->removeInfo(id);
InfoBar::globallySuppressInfo(id);
});
}
QToolButton *infoWidgetCloseButton = new QToolButton;
infoWidgetCloseButton->setProperty("infoId", info.id.uniqueIdentifier());
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
// because the latter removes the button and with it any connect
if (info.m_cancelButtonCallBack)
connect(infoWidgetCloseButton, &QAbstractButton::clicked, info.m_cancelButtonCallBack);
connect(infoWidgetCloseButton, SIGNAL(clicked()), SLOT(cancelButtonClicked()));
connect(infoWidgetCloseButton, &QAbstractButton::clicked, this, [this, id] {
m_infoBar->suppressInfo(id);
});
if (info.cancelButtonText.isEmpty()) {
infoWidgetCloseButton->setAutoRaise(true);
......@@ -271,16 +274,4 @@ void InfoBarDisplay::widgetDestroyed()
m_infoWidgets.removeOne(static_cast<QWidget *>(sender()));
}
void InfoBarDisplay::cancelButtonClicked()
{
m_infoBar->suppressInfo(Id::fromUniqueIdentifier(sender()->property("infoId").toInt()));
}
void InfoBarDisplay::suppressButtonClicked()
{
Id id = Id::fromUniqueIdentifier(sender()->property("infoId").toInt());
m_infoBar->removeInfo(id);
InfoBar::globallySuppressInfo(id);
}
} // namespace Core
......@@ -114,8 +114,6 @@ public:
void setInfoBar(InfoBar *infoBar);
private slots:
void cancelButtonClicked();
void suppressButtonClicked();
void update();
void infoBarDestroyed();
void widgetDestroyed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment