mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Make Ctrl+Shift+[1-6] jump through accounts.
This commit is contained in:
parent
c257b75a66
commit
28b43eff7c
4 changed files with 66 additions and 6 deletions
|
@ -80,6 +80,13 @@ const auto CommandByName = base::flat_map<QString, Command>{
|
|||
{ u"next_folder"_q , Command::FolderNext },
|
||||
{ u"all_chats"_q , Command::ShowAllChats },
|
||||
|
||||
{ u"account1"_q , Command::ShowAccount1 },
|
||||
{ u"account2"_q , Command::ShowAccount2 },
|
||||
{ u"account3"_q , Command::ShowAccount3 },
|
||||
{ u"account4"_q , Command::ShowAccount4 },
|
||||
{ u"account5"_q , Command::ShowAccount5 },
|
||||
{ u"account6"_q , Command::ShowAccount6 },
|
||||
|
||||
{ u"folder1"_q , Command::ShowFolder1 },
|
||||
{ u"folder2"_q , Command::ShowFolder2 },
|
||||
{ u"folder3"_q , Command::ShowFolder3 },
|
||||
|
@ -392,6 +399,14 @@ void Manager::fillDefaults() {
|
|||
set(u"%1+%2"_q.arg(ctrl).arg(index), command);
|
||||
}
|
||||
|
||||
auto &&accounts = ranges::views::zip(
|
||||
kShowAccount,
|
||||
ranges::views::ints(1, ranges::unreachable));
|
||||
|
||||
for (const auto [command, index] : accounts) {
|
||||
set(u"%1+shift+%2"_q.arg(ctrl).arg(index), command);
|
||||
}
|
||||
|
||||
set(u"%1+shift+down"_q.arg(ctrl), Command::FolderNext);
|
||||
set(u"%1+shift+up"_q.arg(ctrl), Command::FolderPrevious);
|
||||
|
||||
|
|
|
@ -38,6 +38,13 @@ enum class Command {
|
|||
ChatPinned7,
|
||||
ChatPinned8,
|
||||
|
||||
ShowAccount1,
|
||||
ShowAccount2,
|
||||
ShowAccount3,
|
||||
ShowAccount4,
|
||||
ShowAccount5,
|
||||
ShowAccount6,
|
||||
|
||||
ShowAllChats,
|
||||
ShowFolder1,
|
||||
ShowFolder2,
|
||||
|
@ -79,6 +86,15 @@ enum class Command {
|
|||
Command::ShowFolderLast,
|
||||
};
|
||||
|
||||
[[maybe_unused]] constexpr auto kShowAccount = {
|
||||
Command::ShowAccount1,
|
||||
Command::ShowAccount2,
|
||||
Command::ShowAccount3,
|
||||
Command::ShowAccount4,
|
||||
Command::ShowAccount5,
|
||||
Command::ShowAccount6,
|
||||
};
|
||||
|
||||
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
|
||||
|
||||
class Request {
|
||||
|
|
|
@ -1224,19 +1224,48 @@ void SessionController::showGiftPremiumsBox(const QString &ref) {
|
|||
|
||||
void SessionController::init() {
|
||||
if (session().supportMode()) {
|
||||
initSupportMode();
|
||||
session().supportHelper().registerWindow(this);
|
||||
}
|
||||
setupShortcuts();
|
||||
}
|
||||
|
||||
void SessionController::initSupportMode() {
|
||||
session().supportHelper().registerWindow(this);
|
||||
|
||||
void SessionController::setupShortcuts() {
|
||||
Shortcuts::Requests(
|
||||
) | rpl::filter([=] {
|
||||
return (Core::App().activeWindow() == &window());
|
||||
return (Core::App().activeWindow() == &window())
|
||||
&& !isLayerShown()
|
||||
&& !window().locked();
|
||||
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||
using C = Shortcuts::Command;
|
||||
|
||||
const auto app = &Core::App();
|
||||
const auto accountsCount = int(app->domain().accounts().size());
|
||||
auto &&accounts = ranges::views::zip(
|
||||
Shortcuts::kShowAccount,
|
||||
ranges::views::ints(0, accountsCount));
|
||||
for (const auto [command, index] : accounts) {
|
||||
request->check(command) && request->handle([=] {
|
||||
const auto list = app->domain().orderedAccounts();
|
||||
if (index >= list.size()) {
|
||||
return false;
|
||||
}
|
||||
const auto account = list[index];
|
||||
if (account == &session().account()) {
|
||||
return false;
|
||||
}
|
||||
const auto window = app->separateWindowForAccount(account);
|
||||
if (window) {
|
||||
window->activate();
|
||||
} else {
|
||||
app->domain().maybeActivate(account);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (!session().supportMode()) {
|
||||
return;
|
||||
}
|
||||
request->check(C::SupportHistoryBack) && request->handle([=] {
|
||||
return chatEntryHistoryMove(-1);
|
||||
});
|
||||
|
|
|
@ -601,7 +601,7 @@ private:
|
|||
struct CachedTheme;
|
||||
|
||||
void init();
|
||||
void initSupportMode();
|
||||
void setupShortcuts();
|
||||
void refreshFiltersMenu();
|
||||
void checkOpenedFilter();
|
||||
void suggestArchiveAndMute();
|
||||
|
|
Loading…
Add table
Reference in a new issue