mirror of https://github.com/procxx/kepka.git
Go through open history in support mode.
This commit is contained in:
parent
c11b977f1d
commit
2cd3cec478
|
@ -43,6 +43,8 @@ const auto SupportCommands = base::flat_set<Command>{
|
||||||
Command::SupportReloadTemplates,
|
Command::SupportReloadTemplates,
|
||||||
Command::SupportToggleMuted,
|
Command::SupportToggleMuted,
|
||||||
Command::SupportScrollToCurrent,
|
Command::SupportScrollToCurrent,
|
||||||
|
Command::SupportHistoryBack,
|
||||||
|
Command::SupportHistoryForward,
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto CommandByName = base::flat_map<QString, Command>{
|
const auto CommandByName = base::flat_map<QString, Command>{
|
||||||
|
@ -310,6 +312,8 @@ void Manager::fillDefaults() {
|
||||||
set(qsl("f5"), Command::SupportReloadTemplates);
|
set(qsl("f5"), Command::SupportReloadTemplates);
|
||||||
set(qsl("ctrl+delete"), Command::SupportToggleMuted);
|
set(qsl("ctrl+delete"), Command::SupportToggleMuted);
|
||||||
set(qsl("ctrl+insert"), Command::SupportScrollToCurrent);
|
set(qsl("ctrl+insert"), Command::SupportScrollToCurrent);
|
||||||
|
set(qsl("ctrl+shift+x"), Command::SupportHistoryBack);
|
||||||
|
set(qsl("ctrl+shift+c"), Command::SupportHistoryForward);
|
||||||
|
|
||||||
set(qsl("ctrl+1"), Command::ChatPinned1);
|
set(qsl("ctrl+1"), Command::ChatPinned1);
|
||||||
set(qsl("ctrl+2"), Command::ChatPinned2);
|
set(qsl("ctrl+2"), Command::ChatPinned2);
|
||||||
|
|
|
@ -37,6 +37,8 @@ enum class Command {
|
||||||
SupportReloadTemplates,
|
SupportReloadTemplates,
|
||||||
SupportToggleMuted,
|
SupportToggleMuted,
|
||||||
SupportScrollToCurrent,
|
SupportScrollToCurrent,
|
||||||
|
SupportHistoryBack,
|
||||||
|
SupportHistoryForward,
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
|
[[nodiscard]] FnMut<bool()> RequestHandler(Command command);
|
||||||
|
|
|
@ -2921,25 +2921,12 @@ Dialogs::RowDescriptor DialogsInner::computeJump(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsInner::jumpToDialogRow(const Dialogs::RowDescriptor &to) {
|
bool DialogsInner::jumpToDialogRow(Dialogs::RowDescriptor to) {
|
||||||
if (to == chatListEntryLast()) {
|
if (to == chatListEntryLast()) {
|
||||||
_listBottomReached.fire({});
|
_listBottomReached.fire({});
|
||||||
}
|
}
|
||||||
|
if (uniqueSearchResults()) {
|
||||||
if (const auto history = to.key.history()) {
|
to.fullId = FullMsgId();
|
||||||
Ui::showPeerHistory(
|
|
||||||
history,
|
|
||||||
(uniqueSearchResults()
|
|
||||||
? ShowAtUnreadMsgId
|
|
||||||
: to.fullId.msg));
|
|
||||||
return true;
|
|
||||||
} else if (const auto feed = to.key.feed()) {
|
|
||||||
if (const auto item = App::histItemById(to.fullId)) {
|
|
||||||
_controller->showSection(
|
|
||||||
HistoryFeed::Memento(feed, item->position()));
|
|
||||||
} else {
|
|
||||||
_controller->showSection(HistoryFeed::Memento(feed));
|
|
||||||
}
|
}
|
||||||
}
|
return _controller->jumpToChatListEntry(to);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ private:
|
||||||
Dialogs::RowDescriptor computeJump(
|
Dialogs::RowDescriptor computeJump(
|
||||||
const Dialogs::RowDescriptor &to,
|
const Dialogs::RowDescriptor &to,
|
||||||
JumpSkip skip);
|
JumpSkip skip);
|
||||||
bool jumpToDialogRow(const Dialogs::RowDescriptor &to);
|
bool jumpToDialogRow(Dialogs::RowDescriptor to);
|
||||||
|
|
||||||
Dialogs::RowDescriptor chatListEntryBefore(
|
Dialogs::RowDescriptor chatListEntryBefore(
|
||||||
const Dialogs::RowDescriptor &which) const;
|
const Dialogs::RowDescriptor &which) const;
|
||||||
|
|
|
@ -13,10 +13,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
|
#include "history/feed/history_feed_section.h"
|
||||||
#include "media/player/media_player_round_controller.h"
|
#include "media/player/media_player_round_controller.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_feed.h"
|
#include "data/data_feed.h"
|
||||||
#include "passport/passport_form_controller.h"
|
#include "passport/passport_form_controller.h"
|
||||||
|
#include "core/shortcuts.h"
|
||||||
#include "boxes/calendar_box.h"
|
#include "boxes/calendar_box.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -27,6 +29,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kMaxChatEntryHistorySize = 50;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
|
DateClickHandler::DateClickHandler(Dialogs::Key chat, QDate date)
|
||||||
: _chat(chat)
|
: _chat(chat)
|
||||||
|
@ -53,12 +60,70 @@ Controller::Controller(not_null<MainWindow*> window)
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
if (Auth().supportMode()) {
|
if (Auth().supportMode()) {
|
||||||
Auth().supportHelper().registerWindow(this);
|
initSupportMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::initSupportMode() {
|
||||||
|
Auth().supportHelper().registerWindow(this);
|
||||||
|
|
||||||
|
Shortcuts::Requests(
|
||||||
|
) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||||
|
using C = Shortcuts::Command;
|
||||||
|
|
||||||
|
request->check(C::SupportHistoryBack) && request->handle([=] {
|
||||||
|
return chatEntryHistoryMove(-1);
|
||||||
|
});
|
||||||
|
request->check(C::SupportHistoryForward) && request->handle([=] {
|
||||||
|
return chatEntryHistoryMove(1);
|
||||||
|
});
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::setActiveChatEntry(Dialogs::RowDescriptor row) {
|
void Controller::setActiveChatEntry(Dialogs::RowDescriptor row) {
|
||||||
_activeChatEntry = row;
|
_activeChatEntry = row;
|
||||||
|
if (Auth().supportMode()) {
|
||||||
|
pushToChatEntryHistory(row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::chatEntryHistoryMove(int steps) {
|
||||||
|
if (_chatEntryHistory.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto position = _chatEntryHistoryPosition + steps;
|
||||||
|
if (!base::in_range(position, 0, int(_chatEntryHistory.size()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_chatEntryHistoryPosition = position;
|
||||||
|
return jumpToChatListEntry(_chatEntryHistory[position]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::jumpToChatListEntry(Dialogs::RowDescriptor row) {
|
||||||
|
if (const auto history = row.key.history()) {
|
||||||
|
Ui::showPeerHistory(history, row.fullId.msg);
|
||||||
|
return true;
|
||||||
|
} else if (const auto feed = row.key.feed()) {
|
||||||
|
if (const auto item = App::histItemById(row.fullId)) {
|
||||||
|
showSection(HistoryFeed::Memento(feed, item->position()));
|
||||||
|
} else {
|
||||||
|
showSection(HistoryFeed::Memento(feed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::pushToChatEntryHistory(Dialogs::RowDescriptor row) {
|
||||||
|
if (!_chatEntryHistory.empty()
|
||||||
|
&& _chatEntryHistory[_chatEntryHistoryPosition] == row) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_chatEntryHistory.resize(++_chatEntryHistoryPosition);
|
||||||
|
_chatEntryHistory.push_back(row);
|
||||||
|
if (_chatEntryHistory.size() > kMaxChatEntryHistorySize) {
|
||||||
|
_chatEntryHistory.pop_front();
|
||||||
|
--_chatEntryHistoryPosition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setActiveChatEntry(Dialogs::Key key) {
|
void Controller::setActiveChatEntry(Dialogs::Key key) {
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
rpl::producer<Dialogs::Key> activeChatChanges() const;
|
rpl::producer<Dialogs::Key> activeChatChanges() const;
|
||||||
rpl::producer<Dialogs::RowDescriptor> activeChatEntryValue() const;
|
rpl::producer<Dialogs::RowDescriptor> activeChatEntryValue() const;
|
||||||
rpl::producer<Dialogs::Key> activeChatValue() const;
|
rpl::producer<Dialogs::Key> activeChatValue() const;
|
||||||
|
bool jumpToChatListEntry(Dialogs::RowDescriptor row);
|
||||||
|
|
||||||
void enableGifPauseReason(GifPauseReason reason);
|
void enableGifPauseReason(GifPauseReason reason);
|
||||||
void disableGifPauseReason(GifPauseReason reason);
|
void disableGifPauseReason(GifPauseReason reason);
|
||||||
|
@ -259,6 +260,8 @@ public:
|
||||||
~Controller();
|
~Controller();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initSupportMode();
|
||||||
|
|
||||||
int minimalThreeColumnWidth() const;
|
int minimalThreeColumnWidth() const;
|
||||||
not_null<MainWidget*> chats() const;
|
not_null<MainWidget*> chats() const;
|
||||||
int countDialogsWidthFromRatio(int bodyWidth) const;
|
int countDialogsWidthFromRatio(int bodyWidth) const;
|
||||||
|
@ -272,6 +275,9 @@ private:
|
||||||
int thirdWidth,
|
int thirdWidth,
|
||||||
int bodyWidth) const;
|
int bodyWidth) const;
|
||||||
|
|
||||||
|
void pushToChatEntryHistory(Dialogs::RowDescriptor row);
|
||||||
|
bool chatEntryHistoryMove(int steps);
|
||||||
|
|
||||||
not_null<MainWindow*> _window;
|
not_null<MainWindow*> _window;
|
||||||
|
|
||||||
std::unique_ptr<Passport::FormController> _passportForm;
|
std::unique_ptr<Passport::FormController> _passportForm;
|
||||||
|
@ -283,6 +289,8 @@ private:
|
||||||
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
|
||||||
base::Variable<bool> _dialogsListFocused = { false };
|
base::Variable<bool> _dialogsListFocused = { false };
|
||||||
base::Variable<bool> _dialogsListDisplayForced = { false };
|
base::Variable<bool> _dialogsListDisplayForced = { false };
|
||||||
|
std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
|
||||||
|
int _chatEntryHistoryPosition = -1;
|
||||||
|
|
||||||
std::unique_ptr<RoundController> _roundVideo;
|
std::unique_ptr<RoundController> _roundVideo;
|
||||||
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
||||||
|
|
Loading…
Reference in New Issue