Raise minimum supported Qt version to 5.12

This commit is contained in:
Vladimir Golovnev (Glassez)
2021-02-18 11:51:00 +03:00
parent 6139d0d65a
commit f022458383
20 changed files with 42 additions and 148 deletions

View File

@@ -79,31 +79,19 @@ void AutoExpandableDialog::showEvent(QShowEvent *e)
// Show dialog and resize textbox to fit the text
// NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int wd = m_ui->textEdit->fontMetrics().horizontalAdvance(m_ui->textEdit->text()) + 4;
#else
int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
#endif
if (!windowTitle().isEmpty())
{
// not really the font metrics in window title, so we enlarge it a bit,
// including the small icon and close button width
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = fontMetrics().horizontalAdvance(windowTitle()) * 1.8;
#else
int w = fontMetrics().width(windowTitle()) * 1.8;
#endif
wd = std::max(wd, w);
}
if (!m_ui->textLabel->text().isEmpty())
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = m_ui->textLabel->fontMetrics().horizontalAdvance(m_ui->textLabel->text());
#else
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
#endif
wd = std::max(wd, w);
}

View File

@@ -46,11 +46,7 @@ namespace
int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fontMetrics.horizontalAdvance(text);
#else
return fontMetrics.width(text);
#endif
}
QString logText(const QModelIndex &index)

View File

@@ -753,7 +753,7 @@ void OptionsDialog::saveOptions()
pref->setMailNotificationSMTPPassword(m_ui->mailNotifPassword->text());
pref->setAutoRunEnabled(m_ui->autoRunBox->isChecked());
pref->setAutoRunProgram(m_ui->lineEditAutoRun->text().trimmed());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked());
#endif
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl());
@@ -1043,7 +1043,7 @@ void OptionsDialog::loadOptions()
m_ui->autoRunBox->setChecked(pref->isAutoRunEnabled());
m_ui->lineEditAutoRun->setText(pref->getAutoRunProgram());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) && defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
m_ui->autoRunConsole->setChecked(pref->isAutoRunConsoleEnabled());
#else
m_ui->autoRunConsole->hide();

View File

@@ -304,13 +304,10 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
int yAxisWidth = 0;
for (const QString &label : speedLabels)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
{
if (fontMetrics.horizontalAdvance(label) > yAxisWidth)
yAxisWidth = fontMetrics.horizontalAdvance(label);
#else
if (fontMetrics.width(label) > yAxisWidth)
yAxisWidth = fontMetrics.width(label);
#endif
}
int i = 0;
for (const QString &label : speedLabels)
@@ -391,13 +388,8 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
if (!property.enable)
continue;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (fontMetrics.horizontalAdvance(property.name) > legendWidth)
legendWidth = fontMetrics.horizontalAdvance(property.name);
#else
if (fontMetrics.width(property.name) > legendWidth)
legendWidth = fontMetrics.width(property.name);
#endif
legendHeight += 1.5 * fontMetrics.height();
}
@@ -412,11 +404,7 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
if (!property.enable)
continue;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int nameSize = fontMetrics.horizontalAdvance(property.name);
#else
int nameSize = fontMetrics.width(property.name);
#endif
double indent = 1.5 * (i++) * fontMetrics.height();
painter.setPen(property.pen);