add compilation check for WIN_SDK_VERSION

This commit is contained in:
Piyush Aggarwal 2021-06-15 18:06:03 +05:30
parent d11f15a3e6
commit a6de73d437
2 changed files with 7 additions and 1 deletions

View file

@ -100,6 +100,11 @@ if (KF5_OPTIONAL_COMPONENTS)
find_package(KF5 ${KF5_MIN_VERSION} COMPONENTS ${KF5_OPTIONAL_COMPONENTS})
endif()
if (WIN32)
string(REGEX MATCH "[0-9][0-9][0-9][0-9][0-9]" WIN_SDK_VERSION "${CMAKE_SYSTEM_VERSION}" )
add_compile_definitions(WIN_SDK_VERSION=${WIN_SDK_VERSION})
endif()
if (NOT ZSH_AUTOCOMPLETE_DIR)
set(ZSH_AUTOCOMPLETE_DIR "${KDE_INSTALL_DATADIR}/zsh/site-functions")
endif()

View file

@ -130,13 +130,14 @@ void MprisControlPlugin::updatePlayerList() {
const auto player = sessions.GetAt(i);
auto playerName = player.SourceAppUserModelId();
#if WIN_SDK_VERSION >= 19041
// try to resolve the AUMID to a user-friendly name
try {
playerName = AppInfo::GetFromAppUserModelId(playerName).DisplayInfo().DisplayName();
} catch (winrt::hresult_error e) {
qCDebug(KDECONNECT_PLUGIN_MPRIS) << QString::fromWCharArray(playerName.c_str()) << "doesn\'t have a valid AppUserModelID! Sending as-is..";
}
#endif
QString uniqueName = QString::fromWCharArray(playerName.c_str());
for (int i = 2; playerList.contains(uniqueName); ++i) {
uniqueName += QStringLiteral(" [") + QString::number(i) + QStringLiteral("]");