Commit a8e6184d authored by Arjen Hiemstra's avatar Arjen Hiemstra Committed by Vlad Zahorodnii
Browse files

outputlocator: Return "Unknown" as screen name when we can't determine it

This slightly refactors the name generation in outputlocator to ensure
we don't add spaces when there's nothing to add a space to. It also
ensures that if we can't determine a proper name because all parts are
empty we return "Unknown" as name.
parent 5aa7a48f
Pipeline #219128 failed with stage
in 24 minutes and 18 seconds
......@@ -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)
......@@ -8,6 +8,8 @@
#include <kwinoffscreenquickview.h>
#include <KLocalizedString>
#include <QDBusConnection>
#include <QQuickItem>
......@@ -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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment