forked from qt-creator/qt-creator
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: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -229,22 +229,25 @@ void InfoBarDisplay::update()
|
|||||||
hbox->addWidget(infoWidgetButton);
|
hbox->addWidget(infoWidgetButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Id id = info.id;
|
||||||
QToolButton *infoWidgetSuppressButton = 0;
|
QToolButton *infoWidgetSuppressButton = 0;
|
||||||
if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) {
|
if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) {
|
||||||
infoWidgetSuppressButton = new QToolButton;
|
infoWidgetSuppressButton = new QToolButton;
|
||||||
infoWidgetSuppressButton->setProperty("infoId", info.id.uniqueIdentifier());
|
|
||||||
infoWidgetSuppressButton->setText(tr("Do Not Show Again"));
|
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;
|
QToolButton *infoWidgetCloseButton = new QToolButton;
|
||||||
infoWidgetCloseButton->setProperty("infoId", info.id.uniqueIdentifier());
|
|
||||||
|
|
||||||
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
||||||
// because the latter removes the button and with it any connect
|
// because the latter removes the button and with it any connect
|
||||||
if (info.m_cancelButtonCallBack)
|
if (info.m_cancelButtonCallBack)
|
||||||
connect(infoWidgetCloseButton, &QAbstractButton::clicked, 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()) {
|
if (info.cancelButtonText.isEmpty()) {
|
||||||
infoWidgetCloseButton->setAutoRaise(true);
|
infoWidgetCloseButton->setAutoRaise(true);
|
||||||
@@ -271,16 +274,4 @@ void InfoBarDisplay::widgetDestroyed()
|
|||||||
m_infoWidgets.removeOne(static_cast<QWidget *>(sender()));
|
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
|
} // namespace Core
|
||||||
|
@@ -114,8 +114,6 @@ public:
|
|||||||
void setInfoBar(InfoBar *infoBar);
|
void setInfoBar(InfoBar *infoBar);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void cancelButtonClicked();
|
|
||||||
void suppressButtonClicked();
|
|
||||||
void update();
|
void update();
|
||||||
void infoBarDestroyed();
|
void infoBarDestroyed();
|
||||||
void widgetDestroyed();
|
void widgetDestroyed();
|
||||||
|
Reference in New Issue
Block a user