Commit bbc88da3 authored by Nate Graham's avatar Nate Graham 💤
Browse files

[Updates page] use fancier logic for handling elided Old+New version strings

Summary:
@broulik taught me how to do this! It's more robust than the current logic, which
doesn't expand to the full form when the window becomes wide enough to show the
whole string without eliding.

Test Plan: {F7616753}

Reviewers: apol, broulik, #discover_software_store

Reviewed By: apol, #discover_software_store

Subscribers: mart, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24713
parent eac67d4f
......@@ -259,28 +259,28 @@ DiscoverPage
// Version numbers
Label {
Layout.fillWidth: true
elide: Text.ElideRight
elide: truncated ? Text.ElideLeft : Text.ElideRight
text: {
if (installedVersion == availableVersion && !truncated) {
if (installedVersion == availableVersion) {
// Update of the same version; show when old and new are
// the same (common with Flatpak runtimes)
return i18n("Update to version %1", availableVersion);
} else if (installedVersion && availableVersion && !truncated) {
// Old and new version numbers; show when there's enough room
return i18n("%1 → %2", installedVersion, availableVersion);
} else {
// Available version only, for when the installed version
// isn't available for some reason, or when old+new would be
// elided. Use squeezey text to gain more room, and if it's
// still so long that it would be elided, elide from the left
// so the most important part on the right is still visible
} else if (installedVersion && availableVersion) {
// Old and new version numbers
// This thing with \x9 is a fancy feature in QML text handling:
// when the string will be elided, it shows the string after
// the last \x9. This allows us to show a smaller string
// when there's now enough room
// All of this is mostly for the benefit of KDE Neon users,
// since the version strings there are really really long
return availableVersion
return i18nc("Do not translate or alter \\x9", "%1 → %2\x9C%1 → %2\x9C%2", installedVersion, availableVersion);
} else {
// Available version only, for when the installed version
// isn't available for some reason
return availableVersion;
}
}
font.letterSpacing: truncated ? -0.5 : 0
opacity: listItem.hovered? 0.8 : 0.6
}
}
......
Markdown is supported
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