Improve version display for canary.

This commit is contained in:
John Preston
2026-08-21 14:24:26 +04:00
parent 3d3aee9f32
commit 89be212f0d
4 changed files with 32 additions and 14 deletions

View File

@@ -150,7 +150,9 @@ QString telegramFaqLink() {
return result;
}
QString currentVersionText() {
namespace {
[[nodiscard]] QString CurrentVersionText(bool withCommit) {
auto result = QString::fromLatin1(AppVersionStr);
if (Core::BuildIsCanary) {
result += Core::CanaryVersionSuffix();
@@ -167,9 +169,24 @@ QString currentVersionText() {
#ifdef _DEBUG
result += " DEBUG";
#endif
if (withCommit
&& Core::BuildIsCanary
&& Core::CanaryCommitHash[0] != '\0') {
result += u" \u00B7 "_q + QLatin1String(Core::CanaryCommitHash);
}
return result;
}
} // namespace
QString currentVersionText() {
return CurrentVersionText(true);
}
QString currentVersionShortText() {
return CurrentVersionText(false);
}
void ArchiveHintBox(
not_null<Ui::GenericBox*> box,
bool unarchiveOnNewMessage,

View File

@@ -16,4 +16,7 @@ void ArchiveHintBox(
Fn<void()> onUnarchive);
QString telegramFaqLink();
// The full form ends with the canary commit hash, the short one is for
// the main menu where the line has to stay narrow.
QString currentVersionText();
QString currentVersionShortText();

View File

@@ -72,15 +72,9 @@ inline constexpr auto CanaryMetadataMessageId
}
[[nodiscard]] inline QString CanaryVersionSuffix() {
if (!BuildIsCanary) {
return QString();
}
auto result = QStringLiteral(" canary #%1").arg(CanaryBuildCounter);
if (CanaryCommitHash[0] != '\0') {
result += QStringLiteral(" · ")
+ QLatin1String(CanaryCommitHash);
}
return result;
return BuildIsCanary
? QStringLiteral(" canary #%1").arg(CanaryBuildCounter)
: QString();
}
} // namespace Core

View File

@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/event_filter.h"
#include "base/qt_signal_producer.h"
#include "boxes/about_box.h"
#include "core/update_channel.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/premium_preview_box.h"
#include "calls/group/calls_group_common.h"
@@ -386,12 +387,15 @@ MainMenu::MainMenu(
u"Telegram Desktop"_q,
u"https://desktop.telegram.org"_q));
_telegram->setLinksTrusted();
// The canary version is too long for the "Version {version}" form.
_version->setMarkedText(
tr::link(
tr::lng_settings_current_version(
tr::now,
lt_version,
currentVersionText()),
Core::BuildIsCanary
? currentVersionShortText()
: tr::lng_settings_current_version(
tr::now,
lt_version,
currentVersionShortText()),
1) // Link 1.
.append(QChar(' '))
.append(QChar(8211))