Qt: fix deprecation warnings

This commit is contained in:
Megamouse 2020-01-19 14:00:57 +01:00
parent 30d5a849e3
commit 485b22d664
4 changed files with 22 additions and 4 deletions

View File

@ -331,7 +331,7 @@ void debugger_frame::UpdateUnitList()
const auto on_select = [&](u32, cpu_thread& cpu) const auto on_select = [&](u32, cpu_thread& cpu)
{ {
QVariant var_cpu = qVariantFromValue<void*>(&cpu); QVariant var_cpu = QVariant::fromValue<void*>(&cpu);
m_choice_units->addItem(qstr(cpu.get_name()), var_cpu); m_choice_units->addItem(qstr(cpu.get_name()), var_cpu);
if (old_cpu == var_cpu) m_choice_units->setCurrentIndex(m_choice_units->count() - 1); if (old_cpu == var_cpu) m_choice_units->setCurrentIndex(m_choice_units->count() - 1);
}; };

View File

@ -503,7 +503,11 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, SettingsType type, const QS
spinbox->setRange(min, max); spinbox->setRange(min, max);
spinbox->setValue(val); spinbox->setValue(val);
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
connect(spinbox, &QSpinBox::textChanged, [=](const QString&/* text*/)
#else
connect(spinbox, QOverload<const QString &>::of(&QSpinBox::valueChanged), [=](const QString&/* value*/) connect(spinbox, QOverload<const QString &>::of(&QSpinBox::valueChanged), [=](const QString&/* value*/)
#endif
{ {
SetSetting(type, sstr(spinbox->cleanText())); SetSetting(type, sstr(spinbox->cleanText()));
}); });
@ -545,7 +549,11 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, SettingsType ty
spinbox->setRange(min, max); spinbox->setRange(min, max);
spinbox->setValue(val); spinbox->setValue(val);
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
connect(spinbox, &QDoubleSpinBox::textChanged, [=](const QString&/* text*/)
#else
connect(spinbox, QOverload<const QString &>::of(&QDoubleSpinBox::valueChanged), [=](const QString&/* value*/) connect(spinbox, QOverload<const QString &>::of(&QDoubleSpinBox::valueChanged), [=](const QString&/* value*/)
#endif
{ {
SetSetting(type, sstr(spinbox->cleanText())); SetSetting(type, sstr(spinbox->cleanText()));
}); });

View File

@ -43,7 +43,7 @@ game_list_frame::game_list_frame(std::shared_ptr<gui_settings> guiSettings, std:
m_Icon_Color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>(); m_Icon_Color = m_gui_settings->GetValue(gui::gl_iconColor).value<QColor>();
m_colSortOrder = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder; m_colSortOrder = m_gui_settings->GetValue(gui::gl_sortAsc).toBool() ? Qt::AscendingOrder : Qt::DescendingOrder;
m_sortColumn = m_gui_settings->GetValue(gui::gl_sortCol).toInt(); m_sortColumn = m_gui_settings->GetValue(gui::gl_sortCol).toInt();
m_hidden_list = m_gui_settings->GetValue(gui::gl_hidden_list).toStringList().toSet(); m_hidden_list = gui::utils::list_to_set(m_gui_settings->GetValue(gui::gl_hidden_list).toStringList());
m_oldLayoutIsList = m_isListLayout; m_oldLayoutIsList = m_isListLayout;
@ -727,7 +727,7 @@ void game_list_frame::Refresh(const bool fromDrive, const bool scrollAfter)
// clean up hidden games list // clean up hidden games list
m_hidden_list.intersect(serials); m_hidden_list.intersect(serials);
m_gui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.toList())); m_gui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.values()));
} }
// Fill Game List / Game Grid // Fill Game List / Game Grid
@ -1045,7 +1045,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
else else
m_hidden_list.remove(serial); m_hidden_list.remove(serial);
m_gui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.toList())); m_gui_settings->SetValue(gui::gl_hidden_list, QStringList(m_hidden_list.values()));
Refresh(); Refresh();
}); });
connect(createPPUCache, &QAction::triggered, [=] connect(createPPUCache, &QAction::triggered, [=]

View File

@ -13,6 +13,16 @@ namespace gui
{ {
namespace utils namespace utils
{ {
template<typename T>
static QSet<T> list_to_set(const QList<T>& list)
{
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
return QSet<T>(list.begin(), list.end());
#else
return QSet<T>::fromList(list);
#endif
}
// Creates a frame geometry rectangle with given width height that's centered inside the origin, // Creates a frame geometry rectangle with given width height that's centered inside the origin,
// while still considering screen boundaries. // while still considering screen boundaries.
QRect create_centered_window_geometry(const QRect& origin, s32 width, s32 height); QRect create_centered_window_geometry(const QRect& origin, s32 width, s32 height);