Added per-row highlight registration to shortcuts settings.

This commit is contained in:
23rd
2026-05-27 11:03:33 +03:00
parent d22448420e
commit 577e06ff40
2 changed files with 29 additions and 2 deletions
@@ -146,7 +146,8 @@ struct SetupShortcutsResult {
[[nodiscard]] SetupShortcutsResult SetupShortcutsContent(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> content) {
not_null<Ui::VerticalLayout*> content,
HighlightRegistry *highlights) {
const auto &defaults = S::KeysDefaults();
const auto &currents = S::KeysCurrents();
@@ -236,6 +237,15 @@ struct SetupShortcutsResult {
entry.wrap,
rpl::duplicate(entry.label),
st::settingsButtonNoIcon));
if (highlights && index == 0) {
const auto id = ShortcutsHighlightId(entry.command);
if (!id.isEmpty()) {
highlights->push_back({
id,
{ widget, { .rippleShape = true } },
});
}
}
const auto keys = Ui::CreateChild<Ui::FlatLabel>(
widget,
st::settingsButtonNoIcon.rightLabel);
@@ -562,7 +572,10 @@ void Shortcuts::setupContent() {
.highlights = highlights,
});
auto result = SetupShortcutsContent(controller, container);
auto result = SetupShortcutsContent(
controller,
container,
highlights);
*save = std::move(result.save);
*resetButton = result.resetButton;
@@ -609,6 +622,15 @@ Type ShortcutsId() {
return Shortcuts::Id();
}
QString ShortcutsHighlightId(::Shortcuts::Command command) {
switch (command) {
case ::Shortcuts::Command::ComposeAiApplyInPlace:
return u"shortcuts/ai_compose_apply"_q;
default:
return {};
}
}
namespace Builder {
SectionBuildMethod ShortcutsSection = kMeta.build;
@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_type.h"
namespace Shortcuts {
enum class Command;
} // namespace Shortcuts
namespace Window {
class SessionController;
} // namespace Window
@@ -16,5 +20,6 @@ class SessionController;
namespace Settings {
[[nodiscard]] Type ShortcutsId();
[[nodiscard]] QString ShortcutsHighlightId(::Shortcuts::Command command);
} // namespace Settings