Suppress remove null widget warning

And improve text format for translation work.
This commit is contained in:
Chocobo1 2021-10-13 01:39:43 +08:00
parent e45e29b431
commit 8a7179195f
No known key found for this signature in database
GPG key ID: 210D9C873253A68C

View file

@ -752,21 +752,31 @@ void PropertiesWidget::configure()
// Speed widget
if (Preferences::instance()->isSpeedWidgetEnabled())
{
if (!m_speedWidget || !qobject_cast<SpeedWidget *>(m_speedWidget))
if (!qobject_cast<SpeedWidget *>(m_speedWidget))
{
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
m_speedWidget = new SpeedWidget {this};
if (m_speedWidget)
{
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
}
m_speedWidget = new SpeedWidget(this);
m_ui->speedLayout->addWidget(m_speedWidget);
}
}
else
{
if (!m_speedWidget || !qobject_cast<QLabel *>(m_speedWidget))
if (!qobject_cast<QLabel *>(m_speedWidget))
{
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
auto *label = new QLabel(tr("<center><b>Speed graphs are disabled</b><p>You may change this setting in Advanced Options </center>"), this);
if (m_speedWidget)
{
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
}
const auto displayText = QString::fromLatin1("<center><b>%1</b><p>%2</p></center>")
.arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options"));
auto *label = new QLabel(displayText, this);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_speedWidget = label;
m_ui->speedLayout->addWidget(m_speedWidget);