mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 11:52:58 +00:00
Added per-row highlight registration to shortcuts settings.
This commit is contained in:
@@ -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 ¤ts = 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
|
||||
|
||||
Reference in New Issue
Block a user