mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Merge pull request #10874 from Chocobo1/qt
Replace obsoleted Qt functions
This commit is contained in:
commit
4b25f87859
5 changed files with 32 additions and 2 deletions
|
@ -341,7 +341,11 @@ void showSplashScreen()
|
||||||
const QString version = QBT_VERSION;
|
const QString version = QBT_VERSION;
|
||||||
painter.setPen(QPen(Qt::white));
|
painter.setPen(QPen(Qt::white));
|
||||||
painter.setFont(QFont("Arial", 22, QFont::Black));
|
painter.setFont(QFont("Arial", 22, QFont::Black));
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version);
|
||||||
|
#else
|
||||||
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
|
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
|
||||||
|
#endif
|
||||||
QSplashScreen *splash = new QSplashScreen(splashImg);
|
QSplashScreen *splash = new QSplashScreen(splashImg);
|
||||||
splash->show();
|
splash->show();
|
||||||
QTimer::singleShot(1500, splash, &QObject::deleteLater);
|
QTimer::singleShot(1500, splash, &QObject::deleteLater);
|
||||||
|
|
|
@ -40,7 +40,7 @@ SearchDownloadHandler::SearchDownloadHandler(const QString &siteUrl, const QStri
|
||||||
, m_downloadProcess {new QProcess {this}}
|
, m_downloadProcess {new QProcess {this}}
|
||||||
{
|
{
|
||||||
m_downloadProcess->setEnvironment(QProcess::systemEnvironment());
|
m_downloadProcess->setEnvironment(QProcess::systemEnvironment());
|
||||||
connect(m_downloadProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished)
|
connect(m_downloadProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished)
|
||||||
, this, &SearchDownloadHandler::downloadProcessFinished);
|
, this, &SearchDownloadHandler::downloadProcessFinished);
|
||||||
const QStringList params {
|
const QStringList params {
|
||||||
Utils::Fs::toNativePath(m_manager->engineLocation() + "/nova2dl.py"),
|
Utils::Fs::toNativePath(m_manager->engineLocation() + "/nova2dl.py"),
|
||||||
|
|
|
@ -76,7 +76,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
||||||
|
|
||||||
connect(m_searchProcess, &QProcess::errorOccurred, this, &SearchHandler::processFailed);
|
connect(m_searchProcess, &QProcess::errorOccurred, this, &SearchHandler::processFailed);
|
||||||
connect(m_searchProcess, &QProcess::readyReadStandardOutput, this, &SearchHandler::readSearchOutput);
|
connect(m_searchProcess, &QProcess::readyReadStandardOutput, this, &SearchHandler::readSearchOutput);
|
||||||
connect(m_searchProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished)
|
connect(m_searchProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished)
|
||||||
, this, &SearchHandler::processFinished);
|
, this, &SearchHandler::processFinished);
|
||||||
|
|
||||||
m_searchTimeout->setSingleShot(true);
|
m_searchTimeout->setSingleShot(true);
|
||||||
|
|
|
@ -80,17 +80,29 @@ void AutoExpandableDialog::showEvent(QShowEvent *e)
|
||||||
|
|
||||||
// Show dialog and resize textbox to fit the text
|
// Show dialog and resize textbox to fit the text
|
||||||
// NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
|
// 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;
|
int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!windowTitle().isEmpty()) {
|
if (!windowTitle().isEmpty()) {
|
||||||
// not really the font metrics in window title, so we enlarge it a bit,
|
// not really the font metrics in window title, so we enlarge it a bit,
|
||||||
// including the small icon and close button width
|
// 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;
|
int w = fontMetrics().width(windowTitle()) * 1.8;
|
||||||
|
#endif
|
||||||
wd = std::max(wd, w);
|
wd = std::max(wd, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_ui->textLabel->text().isEmpty()) {
|
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());
|
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
|
||||||
|
#endif
|
||||||
wd = std::max(wd, w);
|
wd = std::max(wd, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,8 +302,13 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
int yAxisWidth = 0;
|
int yAxisWidth = 0;
|
||||||
for (const QString &label : speedLabels)
|
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)
|
if (fontMetrics.width(label) > yAxisWidth)
|
||||||
yAxisWidth = fontMetrics.width(label);
|
yAxisWidth = fontMetrics.width(label);
|
||||||
|
#endif
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const QString &label : speedLabels) {
|
for (const QString &label : speedLabels) {
|
||||||
|
@ -370,8 +375,13 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
if (!property.enable)
|
if (!property.enable)
|
||||||
continue;
|
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)
|
if (fontMetrics.width(property.name) > legendWidth)
|
||||||
legendWidth = fontMetrics.width(property.name);
|
legendWidth = fontMetrics.width(property.name);
|
||||||
|
#endif
|
||||||
legendHeight += 1.5 * fontMetrics.height();
|
legendHeight += 1.5 * fontMetrics.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +395,11 @@ void SpeedPlotView::paintEvent(QPaintEvent *)
|
||||||
if (!property.enable)
|
if (!property.enable)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
int nameSize = fontMetrics.horizontalAdvance(property.name);
|
||||||
|
#else
|
||||||
int nameSize = fontMetrics.width(property.name);
|
int nameSize = fontMetrics.width(property.name);
|
||||||
|
#endif
|
||||||
double indent = 1.5 * (i++) * fontMetrics.height();
|
double indent = 1.5 * (i++) * fontMetrics.height();
|
||||||
|
|
||||||
painter.setPen(property.pen);
|
painter.setPen(property.pen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue