From 7eecd87034c456fe1b7ec4647626b4348ed07ddc Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Fri, 10 Feb 2023 20:58:43 +0300 Subject: [PATCH] fix: Qt 6 deprecation warnings (#4710) --- qt/Application.cc | 7 +- qt/CustomVariantType.h | 2 +- qt/Prefs.cc | 218 ++++++++++++++++++++--------------------- qt/Session.cc | 22 +++-- qt/Utils.cc | 10 +- 5 files changed, 136 insertions(+), 123 deletions(-) diff --git a/qt/Application.cc b/qt/Application.cc index 3ef1968f0..4f23c6412 100644 --- a/qt/Application.cc +++ b/qt/Application.cc @@ -370,7 +370,12 @@ Application::Application(int& argc, char** argv) void Application::loadTranslations() { - auto const qt_qm_dirs = QStringList() << QLibraryInfo::location(QLibraryInfo::TranslationsPath) << + auto const qt_qm_dirs = QStringList() << +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLibraryInfo::path(QLibraryInfo::TranslationsPath) << +#else + QLibraryInfo::location(QLibraryInfo::TranslationsPath) << +#endif #ifdef TRANSLATIONS_DIR QStringLiteral(TRANSLATIONS_DIR) << #endif diff --git a/qt/CustomVariantType.h b/qt/CustomVariantType.h index cc50708ac..dc4b354ac 100644 --- a/qt/CustomVariantType.h +++ b/qt/CustomVariantType.h @@ -12,7 +12,7 @@ class CustomVariantType public: enum { - TrackerStatsList = QVariant::UserType, + TrackerStatsList = QMetaType::User, PeerList, FileList, FilterModeType, diff --git a/qt/Prefs.cc b/qt/Prefs.cc index 537788e8d..128df2048 100644 --- a/qt/Prefs.cc +++ b/qt/Prefs.cc @@ -61,102 +61,102 @@ void ensureSoundCommandIsAList(tr_variant* dict) std::array const Prefs::Items{ /* gui settings */ - PrefItem{ OPTIONS_PROMPT, TR_KEY_show_options_window, QVariant::Bool }, - { OPEN_DIALOG_FOLDER, TR_KEY_open_dialog_dir, QVariant::String }, - { INHIBIT_HIBERNATION, TR_KEY_inhibit_desktop_hibernation, QVariant::Bool }, - { DIR_WATCH, TR_KEY_watch_dir, QVariant::String }, - { DIR_WATCH_ENABLED, TR_KEY_watch_dir_enabled, QVariant::Bool }, - { SHOW_TRAY_ICON, TR_KEY_show_notification_area_icon, QVariant::Bool }, - { START_MINIMIZED, TR_KEY_start_minimized, QVariant::Bool }, - { SHOW_NOTIFICATION_ON_ADD, TR_KEY_torrent_added_notification_enabled, QVariant::Bool }, - { SHOW_NOTIFICATION_ON_COMPLETE, TR_KEY_torrent_complete_notification_enabled, QVariant::Bool }, - { ASKQUIT, TR_KEY_prompt_before_exit, QVariant::Bool }, + PrefItem{ OPTIONS_PROMPT, TR_KEY_show_options_window, QMetaType::Bool }, + { OPEN_DIALOG_FOLDER, TR_KEY_open_dialog_dir, QMetaType::QString }, + { INHIBIT_HIBERNATION, TR_KEY_inhibit_desktop_hibernation, QMetaType::Bool }, + { DIR_WATCH, TR_KEY_watch_dir, QMetaType::QString }, + { DIR_WATCH_ENABLED, TR_KEY_watch_dir_enabled, QMetaType::Bool }, + { SHOW_TRAY_ICON, TR_KEY_show_notification_area_icon, QMetaType::Bool }, + { START_MINIMIZED, TR_KEY_start_minimized, QMetaType::Bool }, + { SHOW_NOTIFICATION_ON_ADD, TR_KEY_torrent_added_notification_enabled, QMetaType::Bool }, + { SHOW_NOTIFICATION_ON_COMPLETE, TR_KEY_torrent_complete_notification_enabled, QMetaType::Bool }, + { ASKQUIT, TR_KEY_prompt_before_exit, QMetaType::Bool }, { SORT_MODE, TR_KEY_sort_mode, CustomVariantType::SortModeType }, - { SORT_REVERSED, TR_KEY_sort_reversed, QVariant::Bool }, - { COMPACT_VIEW, TR_KEY_compact_view, QVariant::Bool }, - { FILTERBAR, TR_KEY_show_filterbar, QVariant::Bool }, - { STATUSBAR, TR_KEY_show_statusbar, QVariant::Bool }, - { STATUSBAR_STATS, TR_KEY_statusbar_stats, QVariant::String }, - { SHOW_TRACKER_SCRAPES, TR_KEY_show_extra_peer_details, QVariant::Bool }, - { SHOW_BACKUP_TRACKERS, TR_KEY_show_backup_trackers, QVariant::Bool }, - { TOOLBAR, TR_KEY_show_toolbar, QVariant::Bool }, - { BLOCKLIST_DATE, TR_KEY_blocklist_date, QVariant::DateTime }, - { BLOCKLIST_UPDATES_ENABLED, TR_KEY_blocklist_updates_enabled, QVariant::Bool }, - { MAIN_WINDOW_LAYOUT_ORDER, TR_KEY_main_window_layout_order, QVariant::String }, - { MAIN_WINDOW_HEIGHT, TR_KEY_main_window_height, QVariant::Int }, - { MAIN_WINDOW_WIDTH, TR_KEY_main_window_width, QVariant::Int }, - { MAIN_WINDOW_X, TR_KEY_main_window_x, QVariant::Int }, - { MAIN_WINDOW_Y, TR_KEY_main_window_y, QVariant::Int }, + { SORT_REVERSED, TR_KEY_sort_reversed, QMetaType::Bool }, + { COMPACT_VIEW, TR_KEY_compact_view, QMetaType::Bool }, + { FILTERBAR, TR_KEY_show_filterbar, QMetaType::Bool }, + { STATUSBAR, TR_KEY_show_statusbar, QMetaType::Bool }, + { STATUSBAR_STATS, TR_KEY_statusbar_stats, QMetaType::QString }, + { SHOW_TRACKER_SCRAPES, TR_KEY_show_extra_peer_details, QMetaType::Bool }, + { SHOW_BACKUP_TRACKERS, TR_KEY_show_backup_trackers, QMetaType::Bool }, + { TOOLBAR, TR_KEY_show_toolbar, QMetaType::Bool }, + { BLOCKLIST_DATE, TR_KEY_blocklist_date, QMetaType::QDateTime }, + { BLOCKLIST_UPDATES_ENABLED, TR_KEY_blocklist_updates_enabled, QMetaType::Bool }, + { MAIN_WINDOW_LAYOUT_ORDER, TR_KEY_main_window_layout_order, QMetaType::QString }, + { MAIN_WINDOW_HEIGHT, TR_KEY_main_window_height, QMetaType::Int }, + { MAIN_WINDOW_WIDTH, TR_KEY_main_window_width, QMetaType::Int }, + { MAIN_WINDOW_X, TR_KEY_main_window_x, QMetaType::Int }, + { MAIN_WINDOW_Y, TR_KEY_main_window_y, QMetaType::Int }, { FILTER_MODE, TR_KEY_filter_mode, CustomVariantType::FilterModeType }, - { FILTER_TRACKERS, TR_KEY_filter_trackers, QVariant::String }, - { FILTER_TEXT, TR_KEY_filter_text, QVariant::String }, - { SESSION_IS_REMOTE, TR_KEY_remote_session_enabled, QVariant::Bool }, - { SESSION_REMOTE_HOST, TR_KEY_remote_session_host, QVariant::String }, - { SESSION_REMOTE_HTTPS, TR_KEY_remote_session_https, QVariant::Bool }, - { SESSION_REMOTE_PASSWORD, TR_KEY_remote_session_password, QVariant::String }, - { SESSION_REMOTE_PORT, TR_KEY_remote_session_port, QVariant::Int }, - { SESSION_REMOTE_AUTH, TR_KEY_remote_session_requres_authentication, QVariant::Bool }, - { SESSION_REMOTE_USERNAME, TR_KEY_remote_session_username, QVariant::String }, - { COMPLETE_SOUND_COMMAND, TR_KEY_torrent_complete_sound_command, QVariant::StringList }, - { COMPLETE_SOUND_ENABLED, TR_KEY_torrent_complete_sound_enabled, QVariant::Bool }, - { USER_HAS_GIVEN_INFORMED_CONSENT, TR_KEY_user_has_given_informed_consent, QVariant::Bool }, - { READ_CLIPBOARD, TR_KEY_read_clipboard, QVariant::Bool }, + { FILTER_TRACKERS, TR_KEY_filter_trackers, QMetaType::QString }, + { FILTER_TEXT, TR_KEY_filter_text, QMetaType::QString }, + { SESSION_IS_REMOTE, TR_KEY_remote_session_enabled, QMetaType::Bool }, + { SESSION_REMOTE_HOST, TR_KEY_remote_session_host, QMetaType::QString }, + { SESSION_REMOTE_HTTPS, TR_KEY_remote_session_https, QMetaType::Bool }, + { SESSION_REMOTE_PASSWORD, TR_KEY_remote_session_password, QMetaType::QString }, + { SESSION_REMOTE_PORT, TR_KEY_remote_session_port, QMetaType::Int }, + { SESSION_REMOTE_AUTH, TR_KEY_remote_session_requres_authentication, QMetaType::Bool }, + { SESSION_REMOTE_USERNAME, TR_KEY_remote_session_username, QMetaType::QString }, + { COMPLETE_SOUND_COMMAND, TR_KEY_torrent_complete_sound_command, QMetaType::QStringList }, + { COMPLETE_SOUND_ENABLED, TR_KEY_torrent_complete_sound_enabled, QMetaType::Bool }, + { USER_HAS_GIVEN_INFORMED_CONSENT, TR_KEY_user_has_given_informed_consent, QMetaType::Bool }, + { READ_CLIPBOARD, TR_KEY_read_clipboard, QMetaType::Bool }, /* libtransmission settings */ - { ALT_SPEED_LIMIT_UP, TR_KEY_alt_speed_up, QVariant::Int }, - { ALT_SPEED_LIMIT_DOWN, TR_KEY_alt_speed_down, QVariant::Int }, - { ALT_SPEED_LIMIT_ENABLED, TR_KEY_alt_speed_enabled, QVariant::Bool }, - { ALT_SPEED_LIMIT_TIME_BEGIN, TR_KEY_alt_speed_time_begin, QVariant::Int }, - { ALT_SPEED_LIMIT_TIME_END, TR_KEY_alt_speed_time_end, QVariant::Int }, - { ALT_SPEED_LIMIT_TIME_ENABLED, TR_KEY_alt_speed_time_enabled, QVariant::Bool }, - { ALT_SPEED_LIMIT_TIME_DAY, TR_KEY_alt_speed_time_day, QVariant::Int }, - { BLOCKLIST_ENABLED, TR_KEY_blocklist_enabled, QVariant::Bool }, - { BLOCKLIST_URL, TR_KEY_blocklist_url, QVariant::String }, - { DEFAULT_TRACKERS, TR_KEY_default_trackers, QVariant::String }, - { DSPEED, TR_KEY_speed_limit_down, QVariant::Int }, - { DSPEED_ENABLED, TR_KEY_speed_limit_down_enabled, QVariant::Bool }, - { DOWNLOAD_DIR, TR_KEY_download_dir, QVariant::String }, - { DOWNLOAD_QUEUE_ENABLED, TR_KEY_download_queue_enabled, QVariant::Bool }, - { DOWNLOAD_QUEUE_SIZE, TR_KEY_download_queue_size, QVariant::Int }, - { ENCRYPTION, TR_KEY_encryption, QVariant::Int }, - { IDLE_LIMIT, TR_KEY_idle_seeding_limit, QVariant::Int }, - { IDLE_LIMIT_ENABLED, TR_KEY_idle_seeding_limit_enabled, QVariant::Bool }, - { INCOMPLETE_DIR, TR_KEY_incomplete_dir, QVariant::String }, - { INCOMPLETE_DIR_ENABLED, TR_KEY_incomplete_dir_enabled, QVariant::Bool }, - { MSGLEVEL, TR_KEY_message_level, QVariant::Int }, - { PEER_LIMIT_GLOBAL, TR_KEY_peer_limit_global, QVariant::Int }, - { PEER_LIMIT_TORRENT, TR_KEY_peer_limit_per_torrent, QVariant::Int }, - { PEER_PORT, TR_KEY_peer_port, QVariant::Int }, - { PEER_PORT_RANDOM_ON_START, TR_KEY_peer_port_random_on_start, QVariant::Bool }, - { PEER_PORT_RANDOM_LOW, TR_KEY_peer_port_random_low, QVariant::Int }, - { PEER_PORT_RANDOM_HIGH, TR_KEY_peer_port_random_high, QVariant::Int }, - { QUEUE_STALLED_MINUTES, TR_KEY_queue_stalled_minutes, QVariant::Int }, - { SCRIPT_TORRENT_DONE_ENABLED, TR_KEY_script_torrent_done_enabled, QVariant::Bool }, - { SCRIPT_TORRENT_DONE_FILENAME, TR_KEY_script_torrent_done_filename, QVariant::String }, - { SCRIPT_TORRENT_DONE_SEEDING_ENABLED, TR_KEY_script_torrent_done_seeding_enabled, QVariant::Bool }, - { SCRIPT_TORRENT_DONE_SEEDING_FILENAME, TR_KEY_script_torrent_done_seeding_filename, QVariant::String }, - { SOCKET_TOS, TR_KEY_peer_socket_tos, QVariant::String }, - { START, TR_KEY_start_added_torrents, QVariant::Bool }, - { TRASH_ORIGINAL, TR_KEY_trash_original_torrent_files, QVariant::Bool }, - { PEX_ENABLED, TR_KEY_pex_enabled, QVariant::Bool }, - { DHT_ENABLED, TR_KEY_dht_enabled, QVariant::Bool }, - { UTP_ENABLED, TR_KEY_utp_enabled, QVariant::Bool }, - { LPD_ENABLED, TR_KEY_lpd_enabled, QVariant::Bool }, - { PORT_FORWARDING, TR_KEY_port_forwarding_enabled, QVariant::Bool }, - { PREALLOCATION, TR_KEY_preallocation, QVariant::Int }, - { RATIO, TR_KEY_ratio_limit, QVariant::Double }, - { RATIO_ENABLED, TR_KEY_ratio_limit_enabled, QVariant::Bool }, - { RENAME_PARTIAL_FILES, TR_KEY_rename_partial_files, QVariant::Bool }, - { RPC_AUTH_REQUIRED, TR_KEY_rpc_authentication_required, QVariant::Bool }, - { RPC_ENABLED, TR_KEY_rpc_enabled, QVariant::Bool }, - { RPC_PASSWORD, TR_KEY_rpc_password, QVariant::String }, - { RPC_PORT, TR_KEY_rpc_port, QVariant::Int }, - { RPC_USERNAME, TR_KEY_rpc_username, QVariant::String }, - { RPC_WHITELIST_ENABLED, TR_KEY_rpc_whitelist_enabled, QVariant::Bool }, - { RPC_WHITELIST, TR_KEY_rpc_whitelist, QVariant::String }, - { USPEED_ENABLED, TR_KEY_speed_limit_up_enabled, QVariant::Bool }, - { USPEED, TR_KEY_speed_limit_up, QVariant::Int }, - { UPLOAD_SLOTS_PER_TORRENT, TR_KEY_upload_slots_per_torrent, QVariant::Int }, + { ALT_SPEED_LIMIT_UP, TR_KEY_alt_speed_up, QMetaType::Int }, + { ALT_SPEED_LIMIT_DOWN, TR_KEY_alt_speed_down, QMetaType::Int }, + { ALT_SPEED_LIMIT_ENABLED, TR_KEY_alt_speed_enabled, QMetaType::Bool }, + { ALT_SPEED_LIMIT_TIME_BEGIN, TR_KEY_alt_speed_time_begin, QMetaType::Int }, + { ALT_SPEED_LIMIT_TIME_END, TR_KEY_alt_speed_time_end, QMetaType::Int }, + { ALT_SPEED_LIMIT_TIME_ENABLED, TR_KEY_alt_speed_time_enabled, QMetaType::Bool }, + { ALT_SPEED_LIMIT_TIME_DAY, TR_KEY_alt_speed_time_day, QMetaType::Int }, + { BLOCKLIST_ENABLED, TR_KEY_blocklist_enabled, QMetaType::Bool }, + { BLOCKLIST_URL, TR_KEY_blocklist_url, QMetaType::QString }, + { DEFAULT_TRACKERS, TR_KEY_default_trackers, QMetaType::QString }, + { DSPEED, TR_KEY_speed_limit_down, QMetaType::Int }, + { DSPEED_ENABLED, TR_KEY_speed_limit_down_enabled, QMetaType::Bool }, + { DOWNLOAD_DIR, TR_KEY_download_dir, QMetaType::QString }, + { DOWNLOAD_QUEUE_ENABLED, TR_KEY_download_queue_enabled, QMetaType::Bool }, + { DOWNLOAD_QUEUE_SIZE, TR_KEY_download_queue_size, QMetaType::Int }, + { ENCRYPTION, TR_KEY_encryption, QMetaType::Int }, + { IDLE_LIMIT, TR_KEY_idle_seeding_limit, QMetaType::Int }, + { IDLE_LIMIT_ENABLED, TR_KEY_idle_seeding_limit_enabled, QMetaType::Bool }, + { INCOMPLETE_DIR, TR_KEY_incomplete_dir, QMetaType::QString }, + { INCOMPLETE_DIR_ENABLED, TR_KEY_incomplete_dir_enabled, QMetaType::Bool }, + { MSGLEVEL, TR_KEY_message_level, QMetaType::Int }, + { PEER_LIMIT_GLOBAL, TR_KEY_peer_limit_global, QMetaType::Int }, + { PEER_LIMIT_TORRENT, TR_KEY_peer_limit_per_torrent, QMetaType::Int }, + { PEER_PORT, TR_KEY_peer_port, QMetaType::Int }, + { PEER_PORT_RANDOM_ON_START, TR_KEY_peer_port_random_on_start, QMetaType::Bool }, + { PEER_PORT_RANDOM_LOW, TR_KEY_peer_port_random_low, QMetaType::Int }, + { PEER_PORT_RANDOM_HIGH, TR_KEY_peer_port_random_high, QMetaType::Int }, + { QUEUE_STALLED_MINUTES, TR_KEY_queue_stalled_minutes, QMetaType::Int }, + { SCRIPT_TORRENT_DONE_ENABLED, TR_KEY_script_torrent_done_enabled, QMetaType::Bool }, + { SCRIPT_TORRENT_DONE_FILENAME, TR_KEY_script_torrent_done_filename, QMetaType::QString }, + { SCRIPT_TORRENT_DONE_SEEDING_ENABLED, TR_KEY_script_torrent_done_seeding_enabled, QMetaType::Bool }, + { SCRIPT_TORRENT_DONE_SEEDING_FILENAME, TR_KEY_script_torrent_done_seeding_filename, QMetaType::QString }, + { SOCKET_TOS, TR_KEY_peer_socket_tos, QMetaType::QString }, + { START, TR_KEY_start_added_torrents, QMetaType::Bool }, + { TRASH_ORIGINAL, TR_KEY_trash_original_torrent_files, QMetaType::Bool }, + { PEX_ENABLED, TR_KEY_pex_enabled, QMetaType::Bool }, + { DHT_ENABLED, TR_KEY_dht_enabled, QMetaType::Bool }, + { UTP_ENABLED, TR_KEY_utp_enabled, QMetaType::Bool }, + { LPD_ENABLED, TR_KEY_lpd_enabled, QMetaType::Bool }, + { PORT_FORWARDING, TR_KEY_port_forwarding_enabled, QMetaType::Bool }, + { PREALLOCATION, TR_KEY_preallocation, QMetaType::Int }, + { RATIO, TR_KEY_ratio_limit, QMetaType::Double }, + { RATIO_ENABLED, TR_KEY_ratio_limit_enabled, QMetaType::Bool }, + { RENAME_PARTIAL_FILES, TR_KEY_rename_partial_files, QMetaType::Bool }, + { RPC_AUTH_REQUIRED, TR_KEY_rpc_authentication_required, QMetaType::Bool }, + { RPC_ENABLED, TR_KEY_rpc_enabled, QMetaType::Bool }, + { RPC_PASSWORD, TR_KEY_rpc_password, QMetaType::QString }, + { RPC_PORT, TR_KEY_rpc_port, QMetaType::Int }, + { RPC_USERNAME, TR_KEY_rpc_username, QMetaType::QString }, + { RPC_WHITELIST_ENABLED, TR_KEY_rpc_whitelist_enabled, QMetaType::Bool }, + { RPC_WHITELIST, TR_KEY_rpc_whitelist, QMetaType::QString }, + { USPEED_ENABLED, TR_KEY_speed_limit_up_enabled, QMetaType::Bool }, + { USPEED, TR_KEY_speed_limit_up, QMetaType::Int }, + { UPLOAD_SLOTS_PER_TORRENT, TR_KEY_upload_slots_per_torrent, QMetaType::Int }, }; namespace @@ -239,7 +239,7 @@ Prefs::Prefs(QString config_dir) switch (Items[i].type) { - case QVariant::Int: + case QMetaType::Int: if (auto const value = getValue(b); value) { values_[i].setValue(*value); @@ -274,35 +274,35 @@ Prefs::Prefs(QString config_dir) } break; - case QVariant::String: + case QMetaType::QString: if (auto const value = getValue(b); value) { values_[i].setValue(*value); } break; - case QVariant::StringList: + case QMetaType::QStringList: if (auto const value = getValue(b); value) { values_[i].setValue(*value); } break; - case QVariant::Bool: + case QMetaType::Bool: if (auto const value = getValue(b); value) { values_[i].setValue(*value); } break; - case QVariant::Double: + case QMetaType::Double: if (auto const value = getValue(b); value) { values_[i].setValue(*value); } break; - case QVariant::DateTime: + case QMetaType::QDateTime: if (auto const value = getValue(b); value) { #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) @@ -340,7 +340,7 @@ Prefs::~Prefs() switch (Items[i].type) { - case QVariant::Int: + case QMetaType::Int: dictAdd(¤t_settings, key, val.toInt()); break; @@ -372,23 +372,23 @@ Prefs::~Prefs() break; } - case QVariant::String: + case QMetaType::QString: dictAdd(¤t_settings, key, val.toString()); break; - case QVariant::StringList: + case QMetaType::QStringList: dictAdd(¤t_settings, key, val.toStringList()); break; - case QVariant::Bool: + case QMetaType::Bool: dictAdd(¤t_settings, key, val.toBool()); break; - case QVariant::Double: + case QMetaType::Double: dictAdd(¤t_settings, key, val.toDouble()); break; - case QVariant::DateTime: + case QMetaType::QDateTime: #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) dictAdd(¤t_settings, key, int64_t{ val.toDateTime().toSecsSinceEpoch() }); #else @@ -483,13 +483,13 @@ void Prefs::initDefaults(tr_variant* d) const bool Prefs::getBool(int key) const { - assert(Items[key].type == QVariant::Bool); + assert(Items[key].type == QMetaType::Bool); return values_[key].toBool(); } QString Prefs::getString(int key) const { - assert(Items[key].type == QVariant::String); + assert(Items[key].type == QMetaType::QString); if (auto const b = values_[key].toByteArray(); isValidUtf8(b.constData())) { @@ -501,19 +501,19 @@ QString Prefs::getString(int key) const int Prefs::getInt(int key) const { - assert(Items[key].type == QVariant::Int); + assert(Items[key].type == QMetaType::Int); return values_[key].toInt(); } double Prefs::getDouble(int key) const { - assert(Items[key].type == QVariant::Double); + assert(Items[key].type == QMetaType::Double); return values_[key].toDouble(); } QDateTime Prefs::getDateTime(int key) const { - assert(Items[key].type == QVariant::DateTime); + assert(Items[key].type == QMetaType::QDateTime); return values_[key].toDateTime(); } diff --git a/qt/Session.cc b/qt/Session.cc index da15aaef9..85731104f 100644 --- a/qt/Session.cc +++ b/qt/Session.cc @@ -52,21 +52,25 @@ void Session::sessionSet(tr_quark const key, QVariant const& value) tr_variant args; tr_variantInitDict(&args, 1); - switch (value.type()) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + switch (value.typeId()) +#else + switch (static_cast(value.type())) +#endif { - case QVariant::Bool: + case QMetaType::Bool: dictAdd(&args, key, value.toBool()); break; - case QVariant::Int: + case QMetaType::Int: dictAdd(&args, key, value.toInt()); break; - case QVariant::Double: + case QMetaType::Double: dictAdd(&args, key, value.toDouble()); break; - case QVariant::String: + case QMetaType::QString: dictAdd(&args, key, value.toString()); break; @@ -895,7 +899,7 @@ void Session::updateInfo(tr_variant* args_dict) switch (prefs_.type(i)) { - case QVariant::Int: + case QMetaType::Int: if (auto const value = getValue(b); value) { prefs_.set(i, *value); @@ -903,7 +907,7 @@ void Session::updateInfo(tr_variant* args_dict) break; - case QVariant::Double: + case QMetaType::Double: if (auto const value = getValue(b); value) { prefs_.set(i, *value); @@ -911,7 +915,7 @@ void Session::updateInfo(tr_variant* args_dict) break; - case QVariant::Bool: + case QMetaType::Bool: if (auto const value = getValue(b); value) { prefs_.set(i, *value); @@ -921,7 +925,7 @@ void Session::updateInfo(tr_variant* args_dict) case CustomVariantType::FilterModeType: case CustomVariantType::SortModeType: - case QVariant::String: + case QMetaType::QString: if (auto const value = getValue(b); value) { prefs_.set(i, *value); diff --git a/qt/Utils.cc b/qt/Utils.cc index df1357906..539a32af8 100644 --- a/qt/Utils.cc +++ b/qt/Utils.cc @@ -42,12 +42,16 @@ QIcon Utils::getIconFromIndex(QModelIndex const& index) { QVariant const variant = index.data(Qt::DecorationRole); - switch (variant.type()) +#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + switch (variant.typeId()) +#else + switch (static_cast(variant.type())) +#endif { - case QVariant::Icon: + case QMetaType::QIcon: return qvariant_cast(variant); - case QVariant::Pixmap: + case QMetaType::QPixmap: return qvariant_cast(variant); default: