Close archive by escape even if chat is shown.

This commit is contained in:
John Preston 2019-05-01 16:09:16 +04:00
parent edf4180d11
commit 4ad8c4877c
6 changed files with 48 additions and 47 deletions

View File

@ -199,7 +199,7 @@ Widget::Widget(QWidget *parent, not_null<Window::Controller*> controller)
controller->openFolder(folder);
}
if (openSearchResult && !session().supportMode()) {
onCancel();
escape();
}
}, lifetime());
@ -214,7 +214,7 @@ Widget::Widget(QWidget *parent, not_null<Window::Controller*> controller)
}, lifetime());
connect(_filter, &Ui::FlatInput::cancelled, [=] {
onCancel();
escape();
});
connect(_filter, &Ui::FlatInput::changed, [=] {
applyFilterUpdate();
@ -643,12 +643,10 @@ void Widget::animationCallback() {
}
}
void Widget::onCancel() {
void Widget::escape() {
if (controller()->openedFolder().current()) {
controller()->closeFolder();
return;
}
if (!onCancelSearch()
} else if (!onCancelSearch()
|| (!_searchInChat && !App::main()->selectingPeer())) {
emit cancelled();
}

View File

@ -91,7 +91,6 @@ signals:
public slots:
void onDraggingScrollDelta(int delta);
void onCancel();
void onListScroll();
bool onCancelSearch();
void onCancelSearchInChat();
@ -131,6 +130,7 @@ private:
void peerSearchReceived(
const MTPcontacts_Found &result,
mtpRequestId requestId);
void escape();
void setupSupportMode();
void setupConnectingWidget();

View File

@ -1953,7 +1953,7 @@ TextForMimeData HistoryInner::getSelectedText() const {
void HistoryInner::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
_widget->onListEscapePressed();
_widget->escape();
} else if (e == QKeySequence::Copy && !_selected.empty()) {
copySelectedText();
#ifdef Q_OS_MAC

View File

@ -249,7 +249,9 @@ HistoryWidget::HistoryWidget(
_field,
&Ui::InputField::submitted,
[=](Qt::KeyboardModifiers modifiers) { send(modifiers); });
connect(_field, SIGNAL(cancelled()), this, SLOT(onCancel()));
connect(_field, &Ui::InputField::cancelled, [=] {
escape();
});
connect(_field, SIGNAL(tabbed()), this, SLOT(onFieldTabbed()));
connect(_field, SIGNAL(resized()), this, SLOT(onFieldResize()));
connect(_field, SIGNAL(focused()), this, SLOT(onFieldFocused()));
@ -6080,39 +6082,6 @@ void HistoryWidget::updatePreview() {
update();
}
void HistoryWidget::onCancel() {
if (_isInlineBot) {
onInlineBotCancel();
} else if (_editMsgId) {
auto original = _replyEditMsg ? _replyEditMsg->originalText() : TextWithEntities();
auto editData = TextWithTags {
original.text,
ConvertEntitiesToTextTags(original.entities)
};
if (_replyEditMsg && editData != _field->getTextWithTags()) {
Ui::show(Box<ConfirmBox>(
lang(lng_cancel_edit_post_sure),
lang(lng_cancel_edit_post_yes),
lang(lng_cancel_edit_post_no),
crl::guard(this, [this] {
if (_editMsgId) {
cancelEdit();
Ui::hideLayer();
}
})));
} else {
cancelEdit();
}
} else if (!_fieldAutocomplete->isHidden()) {
_fieldAutocomplete->hideAnimated();
} else if (_replyToId && _field->getTextWithTags().text.isEmpty()) {
cancelReply();
} else {
controller()->showBackFromStack();
emit cancelled();
}
}
void HistoryWidget::fullPeerUpdated(PeerData *peer) {
auto refresh = false;
if (_list && peer == _peer) {
@ -6206,11 +6175,37 @@ void HistoryWidget::confirmDeleteSelected() {
});
}
void HistoryWidget::onListEscapePressed() {
void HistoryWidget::escape() {
if (_nonEmptySelection && _list) {
clearSelected();
} else if (_isInlineBot) {
onInlineBotCancel();
} else if (_editMsgId) {
auto original = _replyEditMsg ? _replyEditMsg->originalText() : TextWithEntities();
auto editData = TextWithTags{
original.text,
ConvertEntitiesToTextTags(original.entities)
};
if (_replyEditMsg && editData != _field->getTextWithTags()) {
Ui::show(Box<ConfirmBox>(
lang(lng_cancel_edit_post_sure),
lang(lng_cancel_edit_post_yes),
lang(lng_cancel_edit_post_no),
crl::guard(this, [this] {
if (_editMsgId) {
cancelEdit();
Ui::hideLayer();
}
})));
} else {
cancelEdit();
}
} else if (!_fieldAutocomplete->isHidden()) {
_fieldAutocomplete->hideAnimated();
} else if (_replyToId && _field->getTextWithTags().text.isEmpty()) {
cancelReply();
} else {
onCancel();
emit cancelled();
}
}

View File

@ -221,7 +221,7 @@ public:
bool recordingAnimationCallback(crl::time now);
void stopRecording(bool send);
void onListEscapePressed();
void escape();
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
@ -303,7 +303,6 @@ signals:
void cancelled();
public slots:
void onCancel();
void onPinnedHide();
void onFieldBarCancel();

View File

@ -386,7 +386,16 @@ MainWidget::MainWidget(
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
connect(this, SIGNAL(dialogsUpdated()), _dialogs, SLOT(onListScroll()));
connect(_history, &HistoryWidget::cancelled, [=] {
_dialogs->setInnerFocus();
const auto historyFromFolder = _history->history()
? _history->history()->folder()
: nullptr;
const auto openedFolder = controller->openedFolder().current();
if (!openedFolder || historyFromFolder == openedFolder) {
controller->showBackFromStack();
_dialogs->setInnerFocus();
} else {
controller->closeFolder();
}
});
subscribe(
Media::Player::instance()->updatedNotifier(),