diff --git a/src/effects/outputlocator/CMakeLists.txt b/src/effects/outputlocator/CMakeLists.txt index a3c9fb58fe..ef0a42c388 100644 --- a/src/effects/outputlocator/CMakeLists.txt +++ b/src/effects/outputlocator/CMakeLists.txt @@ -8,6 +8,7 @@ target_link_libraries(kwin4_effect_outputlocator PRIVATE kwineffects Qt::DBus Qt::Quick + KF5::I18n ) install(DIRECTORY qml DESTINATION ${KDE_INSTALL_DATADIR}/kwin/effects/outputlocator) diff --git a/src/effects/outputlocator/outputlocator.cpp b/src/effects/outputlocator/outputlocator.cpp index 58b156382d..02b3943666 100644 --- a/src/effects/outputlocator/outputlocator.cpp +++ b/src/effects/outputlocator/outputlocator.cpp @@ -8,6 +8,8 @@ #include +#include + #include #include @@ -20,11 +22,25 @@ static QString outputName(const EffectScreen *screen) const bool shouldShowSerialNumber = std::any_of(screens.cbegin(), screens.cend(), [screen](const EffectScreen *other) { return other != screen && other->manufacturer() == screen->manufacturer() && other->model() == screen->model(); }); - QString name = screen->manufacturer() + QLatin1Char(' ') + screen->model(); - if (shouldShowSerialNumber) { - name += QLatin1Char(' ') + screen->serialNumber(); + + QStringList parts; + if (!screen->manufacturer().isEmpty()) { + parts.append(screen->manufacturer()); + } + + if (!screen->model().isEmpty()) { + parts.append(screen->model()); + } + + if (shouldShowSerialNumber && !screen->serialNumber().isEmpty()) { + parts.append(screen->serialNumber()); + } + + if (parts.isEmpty()) { + return i18nc("@label", "Unknown"); + } else { + return parts.join(QLatin1Char(' ')); } - return name; } OutputLocatorEffect::OutputLocatorEffect(QObject *parent)