2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Added option to open chat on click

This commit is contained in:
RadRussianRus
2020-07-09 11:42:10 +03:00
parent ab2ef61a0e
commit 11d72d6bd5
11 changed files with 41 additions and 5 deletions

View File

@@ -2580,5 +2580,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_settings_forward" = "Forward";
"ktg_settings_forward_retain_selection" = "Retain selection after forward";
"ktg_settings_forward_chat_on_click" = "Open chat on click";
"ktg_settings_forward_chat_on_click_description" = "You can hold Ctrl to select multiple chats regardless of this option.";
// Keys finished

View File

@@ -170,6 +170,8 @@
"ktg_forward_go_to_chat": "Go to chat",
"ktg_settings_forward": "Forward",
"ktg_settings_forward_retain_selection": "Retain selection after forward",
"ktg_settings_forward_chat_on_click": "Open chat on click",
"ktg_settings_forward_chat_on_click_description": "You can hold Ctrl to select multiple chats regardless of this option.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -178,6 +178,8 @@
"ktg_forward_go_to_chat": "Go to chat",
"ktg_settings_forward": "Forward",
"ktg_settings_forward_retain_selection": "Retain selection after forward",
"ktg_settings_forward_chat_on_click": "Open chat on click",
"ktg_settings_forward_chat_on_click_description": "You can hold Ctrl to select multiple chats regardless of this option.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -177,6 +177,8 @@
"ktg_forward_go_to_chat": "Перейти в чат",
"ktg_settings_forward": "Пересылка",
"ktg_settings_forward_retain_selection": "Сохранять выделение после пересылки",
"ktg_settings_forward_chat_on_click": "Открывать чат по клику",
"ktg_settings_forward_chat_on_click_description": "Удерживайте Ctrl для выбора нескольких чатов вне зависимости от этой настройки.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -170,6 +170,8 @@
"ktg_forward_go_to_chat": "Go to chat",
"ktg_settings_forward": "Forward",
"ktg_settings_forward_retain_selection": "Retain selection after forward",
"ktg_settings_forward_chat_on_click": "Open chat on click",
"ktg_settings_forward_chat_on_click_description": "You can hold Ctrl to select multiple chats regardless of this option.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -177,6 +177,8 @@
"ktg_forward_go_to_chat": "Go to chat",
"ktg_settings_forward": "Forward",
"ktg_settings_forward_retain_selection": "Retain selection after forward",
"ktg_settings_forward_chat_on_click": "Open chat on click",
"ktg_settings_forward_chat_on_click_description": "You can hold Ctrl to select multiple chats regardless of this option.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -51,6 +51,7 @@ public:
void setPeerSelectedChangedCallback(
Fn<void(PeerData *peer, bool selected)> callback);
void setSubmitRequest(Fn<void()> callback);
void setGoToChatRequest(Fn<void()> callback);
void peerUnselected(not_null<PeerData*> peer);
std::vector<not_null<PeerData*>> selected() const;
@@ -143,6 +144,7 @@ private:
Fn<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;
Fn<void()> _submitRequest;
Fn<void()> _goToChatRequest;
bool _searching = false;
QString _lastQuery;
@@ -276,6 +278,13 @@ void ShareBox::prepare() {
submit({});
});
if (_goToChatCallback) {
_inner->setGoToChatRequest([=] {
const auto singleChat = _inner->selected().at(0);
goToChat(singleChat);
});
}
Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(),
_comment->entity(),
@@ -931,11 +940,14 @@ void ShareBox::Inner::mousePressEvent(QMouseEvent *e) {
updateUpon(e->pos());
changeCheckState(getChatAtIndex(_upon));
if (!_hadSelection
&& _submitRequest
&& !(e->modifiers() & Qt::ControlModifier)
&& _selected.size() == 1
&& _selected.front()->isSelf()) {
_submitRequest();
&& _selected.size() == 1) {
if (_submitRequest && _selected.front()->isSelf()) {
_submitRequest();
} else if (_goToChatRequest && cForwardChatOnClick()) {
_goToChatRequest();
}
_hadSelection = true;
} else if (!_hadSelection) {
_hadSelection = true;
}
@@ -990,6 +1002,10 @@ void ShareBox::Inner::setSubmitRequest(Fn<void()> callback) {
_submitRequest = std::move(callback);
}
void ShareBox::Inner::setGoToChatRequest(Fn<void()> callback) {
_goToChatRequest = std::move(callback);
}
void ShareBox::Inner::changePeerCheckState(
not_null<Chat*> chat,
bool checked,

View File

@@ -213,6 +213,7 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
settings.insert(qsl("hover_emoji_panel"), HoverEmojiPanel());
settings.insert(qsl("monospace_large_bubbles"), MonospaceLargeBubbles());
settings.insert(qsl("forward_retain_selection"), cForwardRetainSelection());
settings.insert(qsl("forward_on_click"), cForwardChatOnClick());
settingsFonts.insert(qsl("use_system_font"), cUseSystemFont());
settingsFonts.insert(qsl("use_original_metrics"), cUseOriginalMetrics());
@@ -521,6 +522,10 @@ bool Manager::readCustomFile() {
ReadBoolOption(settings, "forward_retain_selection", [&](auto v) {
cSetForwardRetainSelection(v);
});
ReadBoolOption(settings, "forward_on_click", [&](auto v) {
cSetForwardChatOnClick(v);
});
return true;
}

View File

@@ -188,3 +188,4 @@ rpl::producer<bool> HoverEmojiPanelChanges() {
}
bool gForwardRetainSelection = false;
bool gForwardChatOnClick = false;

View File

@@ -123,3 +123,4 @@ void SetHoverEmojiPanel(bool enabled);
[[nodiscard]] rpl::producer<bool> HoverEmojiPanelChanges();
DeclareSetting(bool, ForwardRetainSelection);
DeclareSetting(bool, ForwardChatOnClick);

View File

@@ -378,12 +378,13 @@ void SetupKotatoForward(not_null<Ui::VerticalLayout*> container) {
AddSubsectionTitle(container, tr::ktg_settings_forward());
SettingsMenuCSwitch(ktg_settings_forward_retain_selection, ForwardRetainSelection);
SettingsMenuCSwitch(ktg_settings_forward_chat_on_click, ForwardChatOnClick);
AddSkip(container);
AddDividerText(container, tr::ktg_settings_forward_chat_on_click_description());
}
void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, tr::ktg_settings_network());