From 89b6a4cbeedfeece3378b8f1907af6b1e2072061 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Fri, 21 Aug 2020 18:09:04 -0700 Subject: [PATCH] DolphinQt: resolve Qt5.15 deprecations --- .../ControllerInterface/DualShockUDPClientWidget.cpp | 2 +- Source/Core/DolphinQt/Config/ControllersWindow.cpp | 3 +++ Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp | 2 +- Source/Core/DolphinQt/QtUtils/FlowLayout.cpp | 2 +- Source/Core/DolphinQt/Settings/InterfacePane.cpp | 6 +++--- .../DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp | 7 +++---- Source/Core/DolphinQt/Settings/WiiPane.cpp | 7 +++---- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp b/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp index 4c7f41c5e4..1b18435544 100644 --- a/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp +++ b/Source/Core/DolphinQt/Config/ControllerInterface/DualShockUDPClientWidget.cpp @@ -28,7 +28,7 @@ void DualShockUDPClientWidget::CreateWidgets() m_servers_enabled = new QCheckBox(tr("Enable")); m_servers_enabled->setChecked(Config::Get(ciface::DualShockUDPClient::Settings::SERVERS_ENABLED)); - main_layout->addWidget(m_servers_enabled, 0, 0); + main_layout->addWidget(m_servers_enabled, 0, {}); m_server_list = new QListWidget(); main_layout->addWidget(m_server_list); diff --git a/Source/Core/DolphinQt/Config/ControllersWindow.cpp b/Source/Core/DolphinQt/Config/ControllersWindow.cpp index 2f3d03ed43..82e6da599b 100644 --- a/Source/Core/DolphinQt/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt/Config/ControllersWindow.cpp @@ -131,9 +131,12 @@ static int GetLayoutHorizontalSpacing(const QGridLayout* layout) // Docs claim this is deprecated, but on macOS with Qt 5.8 this is the only one that actually // works. float pixel_ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); +#ifdef __APPLE__ + // TODO is this still required? hspacing = pixel_ratio * style->pixelMetric(QStyle::PM_DefaultLayoutSpacing); if (hspacing >= 0) return hspacing; +#endif // Ripped from qtbase/src/widgets/styles/qcommonstyle.cpp return pixel_ratio * 6; diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 00070d2146..60d32a8a25 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -156,7 +156,7 @@ void MemoryViewWidget::Update() } else { - hex_item->setFlags(0); + hex_item->setFlags({}); hex_item->setText(QStringLiteral("-")); } } diff --git a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp index b20d42f96e..bd481ea624 100644 --- a/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp +++ b/Source/Core/DolphinQt/QtUtils/FlowLayout.cpp @@ -120,7 +120,7 @@ QLayoutItem* FlowLayout::takeAt(int index) Qt::Orientations FlowLayout::expandingDirections() const { - return 0; + return {}; } bool FlowLayout::hasHeightForWidth() const diff --git a/Source/Core/DolphinQt/Settings/InterfacePane.cpp b/Source/Core/DolphinQt/Settings/InterfacePane.cpp index af5545565f..99d3993942 100644 --- a/Source/Core/DolphinQt/Settings/InterfacePane.cpp +++ b/Source/Core/DolphinQt/Settings/InterfacePane.cpp @@ -186,9 +186,9 @@ void InterfacePane::ConnectLayout() connect(m_checkbox_use_covers, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); connect(m_checkbox_show_debugging_ui, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); connect(m_checkbox_focused_hotkeys, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig); - connect(m_combobox_theme, qOverload(&QComboBox::currentIndexChanged), - &Settings::Instance(), &Settings::SetThemeName); - connect(m_combobox_userstyle, qOverload(&QComboBox::currentIndexChanged), this, + connect(m_combobox_theme, qOverload(&QComboBox::currentIndexChanged), this, + [=](int index) { Settings::Instance().SetThemeName(m_combobox_theme->itemText(index)); }); + connect(m_combobox_userstyle, qOverload(&QComboBox::currentIndexChanged), this, &InterfacePane::OnSaveConfig); connect(m_combobox_language, qOverload(&QComboBox::currentIndexChanged), this, &InterfacePane::OnSaveConfig); diff --git a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp index ba531093f0..5f9fdceca5 100644 --- a/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp +++ b/Source/Core/DolphinQt/Settings/USBDeviceAddToWhitelistDialog.cpp @@ -168,10 +168,9 @@ void USBDeviceAddToWhitelistDialog::OnDeviceSelection() { // Not the nicest way of doing this but... QString device = usb_inserted_devices_list->currentItem()->text().left(9); - QString* vid = new QString( - device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[0]); - QString* pid = new QString( - device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[1]); + QStringList split = device.split(QString::fromStdString(":")); + QString* vid = new QString(split[0]); + QString* pid = new QString(split[1]); device_vid_textbox->setText(*vid); device_pid_textbox->setText(*pid); } diff --git a/Source/Core/DolphinQt/Settings/WiiPane.cpp b/Source/Core/DolphinQt/Settings/WiiPane.cpp index 6ee0dd5558..e482a1ca3f 100644 --- a/Source/Core/DolphinQt/Settings/WiiPane.cpp +++ b/Source/Core/DolphinQt/Settings/WiiPane.cpp @@ -279,10 +279,9 @@ void WiiPane::OnUSBWhitelistAddButton() void WiiPane::OnUSBWhitelistRemoveButton() { QString device = m_whitelist_usb_list->currentItem()->text().left(9); - QString vid = - QString(device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[0]); - QString pid = - QString(device.split(QString::fromStdString(":"), QString::SplitBehavior::KeepEmptyParts)[1]); + QStringList split = device.split(QString::fromStdString(":")); + QString vid = QString(split[0]); + QString pid = QString(split[1]); const u16 vid_u16 = static_cast(std::stoul(vid.toStdString(), nullptr, 16)); const u16 pid_u16 = static_cast(std::stoul(pid.toStdString(), nullptr, 16)); SConfig::GetInstance().m_usb_passthrough_devices.erase({vid_u16, pid_u16});