mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 05:13:30 -07:00
Merge pull request #12969 from Chocobo1/qt5
Don't use functions deprecated in Qt 5.15
This commit is contained in:
commit
7668d7947a
9 changed files with 45 additions and 17 deletions
|
@ -387,8 +387,17 @@ void Application::runExternalProgram(const BitTorrent::TorrentHandle *torrent) c
|
||||||
// enable command injection via torrent name and other arguments
|
// enable command injection via torrent name and other arguments
|
||||||
// (especially when some automated download mechanism has been setup).
|
// (especially when some automated download mechanism has been setup).
|
||||||
// See: https://github.com/qbittorrent/qBittorrent/issues/10925
|
// See: https://github.com/qbittorrent/qBittorrent/issues/10925
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
QStringList args = QProcess::splitCommand(program);
|
||||||
|
if (args.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString command = args.takeFirst();
|
||||||
|
QProcess::startDetached(command, args);
|
||||||
|
#else
|
||||||
QProcess::startDetached(program);
|
QProcess::startDetached(program);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent)
|
void Application::sendNotificationEmail(const BitTorrent::TorrentHandle *torrent)
|
||||||
|
|
|
@ -565,7 +565,6 @@ QString makeUsage(const QString &prgName)
|
||||||
<< QLatin1String("QBT_NO_SPLASH=1 ") << prgName << '\n'
|
<< QLatin1String("QBT_NO_SPLASH=1 ") << prgName << '\n'
|
||||||
<< wrapText(QObject::tr("Command line parameters take precedence over environment variables"), 0) << '\n';
|
<< wrapText(QObject::tr("Command line parameters take precedence over environment variables"), 0) << '\n';
|
||||||
|
|
||||||
stream << flush;
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Algorithm
|
||||||
{
|
{
|
||||||
auto it = dict.begin();
|
auto it = dict.begin();
|
||||||
while (it != dict.end())
|
while (it != dict.end())
|
||||||
it = (p(it.key(), it.value()) ? dict.erase(it) : (it + 1));
|
it = (p(it.key(), it.value()) ? dict.erase(it) : ++it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be used with set types, such as QSet, std::set
|
// To be used with set types, such as QSet, std::set
|
||||||
|
@ -64,6 +64,6 @@ namespace Algorithm
|
||||||
{
|
{
|
||||||
auto it = set.begin();
|
auto it = set.begin();
|
||||||
while (it != set.end())
|
while (it != set.end())
|
||||||
it = (p(*it) ? set.erase(it) : (it + 1));
|
it = (p(*it) ? set.erase(it) : ++it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,8 +113,12 @@ Smtp::Smtp(QObject *parent)
|
||||||
|
|
||||||
connect(m_socket, &QIODevice::readyRead, this, &Smtp::readyRead);
|
connect(m_socket, &QIODevice::readyRead, this, &Smtp::readyRead);
|
||||||
connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
|
connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
connect(m_socket, &QAbstractSocket::errorOccurred, this, &Smtp::error);
|
||||||
|
#else
|
||||||
connect(m_socket, qOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error)
|
connect(m_socket, qOverload<QAbstractSocket::SocketError>(&QAbstractSocket::error)
|
||||||
, this, &Smtp::error);
|
, this, &Smtp::error);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html)
|
// Test hmacMD5 function (http://www.faqs.org/rfcs/rfc2202.html)
|
||||||
Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex()
|
Q_ASSERT(hmacMD5("Jefe", "what do ya want for nothing?").toHex()
|
||||||
|
|
|
@ -451,7 +451,14 @@ void PeerListWidget::wheelEvent(QWheelEvent *event)
|
||||||
// Shift + scroll = horizontal scroll
|
// Shift + scroll = horizontal scroll
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
QWheelEvent scrollHEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal);
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
QWheelEvent scrollHEvent(event->position(), event->globalPosition()
|
||||||
|
, event->pixelDelta(), event->angleDelta().transposed(), event->buttons()
|
||||||
|
, event->modifiers(), event->phase(), event->inverted(), event->source());
|
||||||
|
#else
|
||||||
|
QWheelEvent scrollHEvent(event->pos(), event->globalPos()
|
||||||
|
, event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal);
|
||||||
|
#endif
|
||||||
QTreeView::wheelEvent(&scrollHEvent);
|
QTreeView::wheelEvent(&scrollHEvent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,8 +100,13 @@ PropTabBar::PropTabBar(QWidget *parent)
|
||||||
addWidget(speedButton);
|
addWidget(speedButton);
|
||||||
m_btnGroup->addButton(speedButton, SpeedTab);
|
m_btnGroup->addButton(speedButton, SpeedTab);
|
||||||
// SIGNAL/SLOT
|
// SIGNAL/SLOT
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
|
connect(m_btnGroup, &QButtonGroup::idClicked
|
||||||
|
, this, &PropTabBar::setCurrentIndex);
|
||||||
|
#else
|
||||||
connect(m_btnGroup, qOverload<int>(&QButtonGroup::buttonClicked)
|
connect(m_btnGroup, qOverload<int>(&QButtonGroup::buttonClicked)
|
||||||
, this, &PropTabBar::setCurrentIndex);
|
, this, &PropTabBar::setCurrentIndex);
|
||||||
|
#endif
|
||||||
// Disable buttons focus
|
// Disable buttons focus
|
||||||
for (QAbstractButton *btn : asConst(m_btnGroup->buttons()))
|
for (QAbstractButton *btn : asConst(m_btnGroup->buttons()))
|
||||||
btn->setFocusPolicy(Qt::NoFocus);
|
btn->setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
|
@ -99,7 +99,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
||||||
<< tr("<b>"foo bar"</b>: search for <b>foo bar</b>",
|
<< tr("<b>"foo bar"</b>: search for <b>foo bar</b>",
|
||||||
"Search phrase example, illustrates quotes usage, double quoted"
|
"Search phrase example, illustrates quotes usage, double quoted"
|
||||||
"pair of space delimited words, the whole pair is highlighted")
|
"pair of space delimited words, the whole pair is highlighted")
|
||||||
<< "</p></body></html>" << flush;
|
<< "</p></body></html>";
|
||||||
m_ui->lineEditSearchPattern->setToolTip(searchPatternHint);
|
m_ui->lineEditSearchPattern->setToolTip(searchPatternHint);
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
|
|
|
@ -599,18 +599,15 @@ int TrackerFiltersList::rowFromTracker(const QString &tracker) const
|
||||||
|
|
||||||
QString TrackerFiltersList::getHost(const QString &tracker) const
|
QString TrackerFiltersList::getHost(const QString &tracker) const
|
||||||
{
|
{
|
||||||
QUrl url(tracker);
|
|
||||||
QString longHost = url.host();
|
|
||||||
QString tld = url.topLevelDomain();
|
|
||||||
// We get empty tld when it is invalid or an IPv4/IPv6 address,
|
|
||||||
// so just return the full host
|
|
||||||
if (tld.isEmpty())
|
|
||||||
return longHost;
|
|
||||||
// We want the domain + tld. Subdomains should be disregarded
|
// We want the domain + tld. Subdomains should be disregarded
|
||||||
int index = longHost.lastIndexOf('.', -(tld.size() + 1));
|
const QUrl url {tracker};
|
||||||
if (index == -1)
|
const QString host {url.host()};
|
||||||
return longHost;
|
|
||||||
return longHost.mid(index + 1);
|
// host is in IP format
|
||||||
|
if (!QHostAddress(host).isNull())
|
||||||
|
return host;
|
||||||
|
|
||||||
|
return host.section('.', -2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList TrackerFiltersList::getHashes(const int row) const
|
QStringList TrackerFiltersList::getHashes(const int row) const
|
||||||
|
|
|
@ -1204,7 +1204,14 @@ void TransferListWidget::wheelEvent(QWheelEvent *event)
|
||||||
// Shift + scroll = horizontal scroll
|
// Shift + scroll = horizontal scroll
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
QWheelEvent scrollHEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal);
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
QWheelEvent scrollHEvent(event->position(), event->globalPosition()
|
||||||
|
, event->pixelDelta(), event->angleDelta().transposed(), event->buttons()
|
||||||
|
, event->modifiers(), event->phase(), event->inverted(), event->source());
|
||||||
|
#else
|
||||||
|
QWheelEvent scrollHEvent(event->pos(), event->globalPos()
|
||||||
|
, event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal);
|
||||||
|
#endif
|
||||||
QTreeView::wheelEvent(&scrollHEvent);
|
QTreeView::wheelEvent(&scrollHEvent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue