Fixed inability to close folder with Back mouse button.

- Fixed #5997.
This commit is contained in:
23rd 2019-05-12 15:59:01 +03:00 committed by John Preston
parent 0659822ac9
commit 63fc552636
2 changed files with 19 additions and 15 deletions

View File

@ -385,20 +385,7 @@ MainWidget::MainWidget(
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
connect(this, SIGNAL(dialogsUpdated()), _dialogs, SLOT(onListScroll()));
connect(_history, &HistoryWidget::cancelled, [=] {
const auto historyFromFolder = _history->history()
? _history->history()->folder()
: nullptr;
const auto openedFolder = controller->openedFolder().current();
if (!openedFolder
|| historyFromFolder == openedFolder
|| Adaptive::OneColumn()) {
controller->showBackFromStack();
_dialogs->setInnerFocus();
} else {
controller->closeFolder();
}
});
connect(_history, &HistoryWidget::cancelled, [=] { handleHistoryBack(); });
subscribe(
Media::Player::instance()->updatedNotifier(),
[=](const Media::Player::TrackState &state) { handleAudioUpdate(state); });
@ -2717,7 +2704,7 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
}
} else if (e->type() == QEvent::MouseButtonPress) {
if (static_cast<QMouseEvent*>(e)->button() == Qt::BackButton) {
_controller->showBackFromStack();
handleHistoryBack();
return true;
}
} else if (e->type() == QEvent::Wheel) {
@ -2736,6 +2723,21 @@ void MainWidget::handleAdaptiveLayoutUpdate() {
}
}
void MainWidget::handleHistoryBack() {
const auto historyFromFolder = _history->history()
? _history->history()->folder()
: nullptr;
const auto openedFolder = _controller->openedFolder().current();
if (!openedFolder
|| historyFromFolder == openedFolder
|| _dialogs->isHidden()) {
_controller->showBackFromStack();
_dialogs->setInnerFocus();
} else {
_controller->closeFolder();
}
}
void MainWidget::updateWindowAdaptiveLayout() {
auto layout = _controller->computeColumnLayout();
auto dialogsWidthRatio = session().settings().dialogsWidthRatio();

View File

@ -443,6 +443,8 @@ private:
const Data::WallPaper &background,
QImage &&image);
void handleHistoryBack();
not_null<Window::Controller*> _controller;
bool _started = false;