Merge pull request #10323 from Chocobo1/qt

Replace deprecated functions/variables
This commit is contained in:
Mike Tzou 2019-03-02 12:25:52 +08:00 committed by GitHub
commit 37606891db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 37 additions and 31 deletions

View file

@ -53,9 +53,10 @@ endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# defines
add_definitions(-DQT_DEPRECATED_WARNINGS)
add_definitions(-DQT_NO_CAST_TO_ASCII)
# Efficient construction for QString & QByteArray (Qt >= 4.8)
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_definitions(-DQT_STRICT_ITERATORS)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
message(STATUS "Project is built in DEBUG mode.")

View file

@ -4012,7 +4012,7 @@ void Session::handlePeerBlockedAlert(const libt::peer_blocked_alert *p)
reason = tr("because it has a low port.", "this peer was blocked because it has a low port.");
break;
case libt::peer_blocked_alert::utp_disabled:
reason = trUtf8("because %1 is disabled.", "this peer was blocked because uTP is disabled.").arg(QString::fromUtf8(C_UTP)); // don't translate μTP
reason = tr("because %1 is disabled.", "this peer was blocked because uTP is disabled.").arg(QString::fromUtf8(C_UTP)); // don't translate μTP
break;
case libt::peer_blocked_alert::tcp_disabled:
reason = tr("because %1 is disabled.", "this peer was blocked because TCP is disabled.").arg("TCP"); // don't translate TCP

View file

@ -35,6 +35,7 @@
#include <QMutableListIterator>
#include <QNetworkProxy>
#include <QSslCipher>
#include <QSslConfiguration>
#include <QSslSocket>
#include <QStringList>
#include <QTimer>
@ -51,7 +52,7 @@ namespace
QList<QSslCipher> safeCipherList()
{
const QStringList badCiphers {"idea", "rc4"};
const QList<QSslCipher> allCiphers {QSslSocket::supportedCiphers()};
const QList<QSslCipher> allCiphers {QSslConfiguration::supportedCiphers()};
QList<QSslCipher> safeCiphers;
std::copy_if(allCiphers.cbegin(), allCiphers.cend(), std::back_inserter(safeCiphers), [&badCiphers](const QSslCipher &cipher)
{
@ -72,7 +73,10 @@ Server::Server(IRequestHandler *requestHandler, QObject *parent)
, m_https(false)
{
setProxy(QNetworkProxy::NoProxy);
QSslSocket::setDefaultCiphers(safeCipherList());
QSslConfiguration sslConf {QSslConfiguration::defaultConfiguration()};
sslConf.setCiphers(safeCipherList());
QSslConfiguration::setDefaultConfiguration(sslConf);
auto *dropConnectionTimer = new QTimer(this);
connect(dropConnectionTimer, &QTimer::timeout, this, &Server::dropTimedOutConnection);

View file

@ -59,8 +59,10 @@
#else
#include <QApplication>
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QScreen>
#include <QStyle>
#include <QWidget>
#include <QWindow>
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
#include <QDBusInterface>
#include <QDBusMessage>
@ -252,11 +254,26 @@ QPoint Utils::Misc::screenCenter(const QWidget *w)
{
// Returns the QPoint which the widget will be placed center on screen (where parent resides)
if (!w)
return {};
QRect r = QGuiApplication::primaryScreen()->availableGeometry();
const QPoint primaryScreenCenter {(r.x() + (r.width() - w->frameSize().width()) / 2), (r.y() + (r.height() - w->frameSize().height()) / 2)};
const QWidget *parent = w->parentWidget();
const QDesktopWidget *desktop = QApplication::desktop();
const int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
const QRect r = desktop->availableGeometry(scrn);
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2};
if (!parent)
return primaryScreenCenter;
const QWindow *window = parent->window()->windowHandle();
if (!window)
return primaryScreenCenter;
const QScreen *screen = window->screen();
if (!screen)
return primaryScreenCenter;
r = screen->availableGeometry();
return {(r.x() + (r.width() - w->frameSize().width()) / 2), (r.y() + (r.height() - w->frameSize().height()) / 2)};
}
#endif

View file

@ -199,11 +199,11 @@ void AdvancedSettings::saveAdvancedSettings()
// Interface address
if (comboBoxInterfaceAddress.currentIndex() == 0) {
// All addresses (default)
session->setNetworkInterfaceAddress(QString::null);
session->setNetworkInterfaceAddress({});
}
else {
QHostAddress ifaceAddr(comboBoxInterfaceAddress.currentText().trimmed());
ifaceAddr.isNull() ? session->setNetworkInterfaceAddress(QString::null) : session->setNetworkInterfaceAddress(ifaceAddr.toString());
ifaceAddr.isNull() ? session->setNetworkInterfaceAddress({}) : session->setNetworkInterfaceAddress(ifaceAddr.toString());
}
session->setIPv6Enabled(checkBoxListenIPv6.isChecked());
// Announce IP

View file

@ -32,7 +32,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QMenu>
#include <QSignalMapper>
#include <QTimer>
#include <libtorrent/session_status.hpp>
@ -89,18 +88,13 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
m_graphsMenu->addAction(tr("Tracker Download"));
m_graphsMenuActions = m_graphsMenu->actions();
m_graphsSignalMapper = new QSignalMapper(this);
for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) {
QAction *action = m_graphsMenuActions.at(id);
action->setCheckable(true);
action->setChecked(true);
connect(action, &QAction::changed, m_graphsSignalMapper
, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
m_graphsSignalMapper->setMapping(action, id);
connect(action, &QAction::changed, this, [this, id]() { onGraphChange(id); });
}
connect(m_graphsSignalMapper, static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped)
, this, &SpeedWidget::onGraphChange);
m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu);
m_graphsButton->addItem(tr("Select Graphs"));

View file

@ -38,7 +38,6 @@ class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QMenu;
class QSignalMapper;
class PropertiesWidget;
class ComboBoxMenuButton : public QComboBox
@ -80,7 +79,6 @@ private:
ComboBoxMenuButton *m_graphsButton;
QMenu *m_graphsMenu;
QList<QAction *> m_graphsMenuActions;
QSignalMapper *m_graphsSignalMapper;
};
#endif // SPEEDWIDGET_H

View file

@ -42,7 +42,6 @@
#include <QProcess>
#include <QRegularExpression>
#include <QShortcut>
#include <QSignalMapper>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTextStream>
@ -91,7 +90,6 @@ namespace
SearchWidget::SearchWidget(MainWindow *mainWindow)
: QWidget(mainWindow)
, m_ui(new Ui::SearchWidget())
, m_tabStatusChangedMapper(new QSignalMapper(this))
, m_mainWindow(mainWindow)
, m_isNewQueryString(false)
{
@ -131,9 +129,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
connect(m_ui->tabWidget, &QTabWidget::tabCloseRequested, this, &SearchWidget::closeTab);
connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, &SearchWidget::tabChanged);
connect(m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)(QWidget *)>(&QSignalMapper::mapped)
, this, &SearchWidget::tabStatusChanged);
const auto *searchManager = SearchPluginManager::instance();
const auto onPluginChanged = [this]()
{
@ -342,9 +337,7 @@ void SearchWidget::on_searchButton_clicked()
m_ui->tabWidget->setCurrentWidget(newTab);
connect(newTab, &SearchJobWidget::resultsCountUpdated, this, &SearchWidget::resultsCountUpdated);
connect(newTab, &SearchJobWidget::statusChanged
, m_tabStatusChangedMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
m_tabStatusChangedMapper->setMapping(newTab, newTab);
connect(newTab, &SearchJobWidget::statusChanged, this, [this, &newTab]() { tabStatusChanged(newTab); });
m_ui->searchButton->setText(tr("Stop"));
m_activeSearchTab = newTab;

View file

@ -34,7 +34,6 @@
#include <QWidget>
class QShortcut;
class QSignalMapper;
class QTabWidget;
class MainWindow;
@ -81,7 +80,6 @@ private:
QString selectedPlugin() const;
Ui::SearchWidget *m_ui;
QSignalMapper *m_tabStatusChangedMapper;
QPointer<SearchJobWidget> m_currentSearchTab; // Selected tab
QPointer<SearchJobWidget> m_activeSearchTab; // Tab with running search
QList<SearchJobWidget *> m_allTabs; // To store all tabs

View file

@ -54,8 +54,9 @@ CONFIG(release, debug|release) {
# VERSION DEFINES
include(../version.pri)
# Qt defines
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += QT_NO_CAST_TO_ASCII
# Efficient construction for QString & QByteArray (Qt >= 4.8)
DEFINES += QT_USE_QSTRINGBUILDER
DEFINES += QT_STRICT_ITERATORS