Browse Source

Merge pull request #10323 from Chocobo1/qt

Replace deprecated functions/variables
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
37606891db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/CMakeLists.txt
  2. 2
      src/base/bittorrent/session.cpp
  3. 8
      src/base/http/server.cpp
  4. 27
      src/base/utils/misc.cpp
  5. 4
      src/gui/advancedsettings.cpp
  6. 8
      src/gui/properties/speedwidget.cpp
  7. 2
      src/gui/properties/speedwidget.h
  8. 9
      src/gui/search/searchwidget.cpp
  9. 2
      src/gui/search/searchwidget.h
  10. 3
      src/src.pro

3
src/CMakeLists.txt

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

2
src/base/bittorrent/session.cpp

@ -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."); reason = tr("because it has a low port.", "this peer was blocked because it has a low port.");
break; break;
case libt::peer_blocked_alert::utp_disabled: 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; break;
case libt::peer_blocked_alert::tcp_disabled: 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 reason = tr("because %1 is disabled.", "this peer was blocked because TCP is disabled.").arg("TCP"); // don't translate TCP

8
src/base/http/server.cpp

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

27
src/base/utils/misc.cpp

@ -59,8 +59,10 @@
#else #else
#include <QApplication> #include <QApplication>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDesktopWidget> #include <QScreen>
#include <QStyle> #include <QStyle>
#include <QWidget>
#include <QWindow>
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusMessage> #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) // 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 QWidget *parent = w->parentWidget();
const QDesktopWidget *desktop = QApplication::desktop(); if (!parent)
const int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid return primaryScreenCenter;
const QRect r = desktop->availableGeometry(scrn);
return {r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2}; 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 #endif

4
src/gui/advancedsettings.cpp

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

8
src/gui/properties/speedwidget.cpp

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

2
src/gui/properties/speedwidget.h

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

9
src/gui/search/searchwidget.cpp

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

2
src/gui/search/searchwidget.h

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

3
src/src.pro

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

Loading…
Cancel
Save