2017-03-27 12:24:38 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-03-27 12:24:38 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-03-27 12:24:38 +00:00
|
|
|
*/
|
|
|
|
#include "window/window_controller.h"
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
#include "window/main_window.h"
|
2017-09-16 16:53:41 +00:00
|
|
|
#include "info/info_memento.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2018-01-11 19:33:26 +00:00
|
|
|
#include "history/history_item.h"
|
2018-01-17 16:21:01 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
2018-01-21 14:49:42 +00:00
|
|
|
#include "media/player/media_player_round_controller.h"
|
|
|
|
#include "data/data_session.h"
|
|
|
|
#include "boxes/calendar_box.h"
|
2017-04-09 18:06:06 +00:00
|
|
|
#include "mainwidget.h"
|
2017-09-15 17:34:41 +00:00
|
|
|
#include "mainwindow.h"
|
2017-08-01 11:43:50 +00:00
|
|
|
#include "auth_session.h"
|
|
|
|
#include "apiwrap.h"
|
2018-01-21 14:49:42 +00:00
|
|
|
#include "styles/style_window.h"
|
|
|
|
#include "styles/style_dialogs.h"
|
2017-04-07 18:10:49 +00:00
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
|
2018-01-21 14:49:42 +00:00
|
|
|
Controller::Controller(not_null<MainWindow*> window)
|
|
|
|
: _window(window) {
|
|
|
|
Auth().data().animationPlayInlineRequest(
|
|
|
|
) | rpl::start_with_next([this](auto item) {
|
|
|
|
if (const auto video = roundVideo(item)) {
|
|
|
|
video->pauseResume();
|
|
|
|
} else {
|
|
|
|
startRoundVideo(item);
|
|
|
|
}
|
|
|
|
}, lifetime());
|
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
void Controller::setActiveChatEntry(Dialogs::RowDescriptor row) {
|
|
|
|
_activeChatEntry = row;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::setActiveChatEntry(Dialogs::Key key) {
|
|
|
|
setActiveChatEntry({ key, MsgId(0) });
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialogs::RowDescriptor Controller::activeChatEntryCurrent() const {
|
|
|
|
return _activeChatEntry.current();
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialogs::Key Controller::activeChatCurrent() const {
|
|
|
|
return activeChatEntryCurrent().key;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::activeChatEntryChanges() const
|
|
|
|
-> rpl::producer<Dialogs::RowDescriptor> {
|
|
|
|
return _activeChatEntry.changes();
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<Dialogs::Key> Controller::activeChatChanges() const {
|
|
|
|
return activeChatEntryChanges(
|
|
|
|
) | rpl::map([](const Dialogs::RowDescriptor &value) {
|
|
|
|
return value.key;
|
|
|
|
}) | rpl::distinct_until_changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::activeChatEntryValue() const
|
|
|
|
-> rpl::producer<Dialogs::RowDescriptor> {
|
|
|
|
return _activeChatEntry.value();
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<Dialogs::Key> Controller::activeChatValue() const {
|
|
|
|
return activeChatEntryValue(
|
|
|
|
) | rpl::map([](const Dialogs::RowDescriptor &value) {
|
|
|
|
return value.key;
|
|
|
|
}) | rpl::distinct_until_changed();
|
|
|
|
}
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
void Controller::enableGifPauseReason(GifPauseReason reason) {
|
|
|
|
if (!(_gifPauseReasons & reason)) {
|
|
|
|
auto notify = (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason));
|
|
|
|
_gifPauseReasons |= reason;
|
|
|
|
if (notify) {
|
|
|
|
_gifPauseLevelChanged.notify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::disableGifPauseReason(GifPauseReason reason) {
|
|
|
|
if (_gifPauseReasons & reason) {
|
2017-08-31 16:28:58 +00:00
|
|
|
_gifPauseReasons &= ~reason;
|
|
|
|
if (_gifPauseReasons < reason) {
|
2017-04-07 18:10:49 +00:00
|
|
|
_gifPauseLevelChanged.notify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Controller::isGifPausedAtLeastFor(GifPauseReason reason) const {
|
|
|
|
if (reason == GifPauseReason::Any) {
|
|
|
|
return (_gifPauseReasons != 0) || !window()->isActive();
|
|
|
|
}
|
|
|
|
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !window()->isActive();
|
|
|
|
}
|
|
|
|
|
2017-05-13 12:02:07 +00:00
|
|
|
int Controller::dialogsSmallColumnWidth() const {
|
|
|
|
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
int Controller::minimalThreeColumnWidth() const {
|
|
|
|
return st::columnMinimalWidthLeft
|
|
|
|
+ st::columnMinimalWidthMain
|
|
|
|
+ st::columnMinimalWidthThird;
|
|
|
|
}
|
|
|
|
|
2017-09-19 18:59:10 +00:00
|
|
|
bool Controller::forceWideDialogs() const {
|
|
|
|
if (dialogsListDisplayForced().value()) {
|
|
|
|
return true;
|
|
|
|
} else if (dialogsListFocused().value()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !App::main()->isMainSectionShown();
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:50:00 +00:00
|
|
|
Controller::ColumnLayout Controller::computeColumnLayout() const {
|
2017-04-09 18:06:06 +00:00
|
|
|
auto layout = Adaptive::WindowLayout::OneColumn;
|
|
|
|
|
|
|
|
auto bodyWidth = window()->bodyWidget()->width();
|
2017-09-19 18:59:10 +00:00
|
|
|
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
|
|
|
|
|
|
|
|
auto useOneColumnLayout = [this, bodyWidth] {
|
2017-09-16 16:53:41 +00:00
|
|
|
auto minimalNormal = st::columnMinimalWidthLeft
|
|
|
|
+ st::columnMinimalWidthMain;
|
|
|
|
if (bodyWidth < minimalNormal) {
|
2017-04-09 18:06:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2017-05-17 11:50:00 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
auto useNormalLayout = [this, bodyWidth] {
|
|
|
|
// Used if useSmallColumnLayout() == false.
|
|
|
|
if (bodyWidth < minimalThreeColumnWidth()) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-01-04 10:22:53 +00:00
|
|
|
if (!Auth().settings().tabbedSelectorSectionEnabled()
|
|
|
|
&& !Auth().settings().thirdSectionInfoEnabled()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
if (useOneColumnLayout()) {
|
2017-05-17 11:50:00 +00:00
|
|
|
dialogsWidth = chatWidth = bodyWidth;
|
2017-09-16 16:53:41 +00:00
|
|
|
} else if (useNormalLayout()) {
|
2017-04-09 18:06:06 +00:00
|
|
|
layout = Adaptive::WindowLayout::Normal;
|
2017-11-12 16:50:58 +00:00
|
|
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
2017-09-19 18:59:10 +00:00
|
|
|
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
2017-05-17 11:50:00 +00:00
|
|
|
chatWidth = bodyWidth - dialogsWidth;
|
2017-09-16 16:53:41 +00:00
|
|
|
} else {
|
|
|
|
layout = Adaptive::WindowLayout::ThreeColumn;
|
2017-11-12 16:50:58 +00:00
|
|
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
|
|
|
thirdWidth = countThirdColumnWidthFromRatio(bodyWidth);
|
|
|
|
auto shrink = shrinkDialogsAndThirdColumns(
|
2017-09-16 16:53:41 +00:00
|
|
|
dialogsWidth,
|
2017-11-12 16:50:58 +00:00
|
|
|
thirdWidth,
|
|
|
|
bodyWidth);
|
|
|
|
dialogsWidth = shrink.dialogsWidth;
|
|
|
|
thirdWidth = shrink.thirdWidth;
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
chatWidth = bodyWidth - dialogsWidth - thirdWidth;
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
return { bodyWidth, dialogsWidth, chatWidth, thirdWidth, layout };
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 16:50:58 +00:00
|
|
|
int Controller::countDialogsWidthFromRatio(int bodyWidth) const {
|
2018-01-04 10:22:53 +00:00
|
|
|
auto result = qRound(bodyWidth * Auth().settings().dialogsWidthRatio());
|
2017-11-12 16:50:58 +00:00
|
|
|
accumulate_max(result, st::columnMinimalWidthLeft);
|
2017-12-12 10:38:59 +00:00
|
|
|
// accumulate_min(result, st::columnMaximalWidthLeft);
|
2017-11-12 16:50:58 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Controller::countThirdColumnWidthFromRatio(int bodyWidth) const {
|
2018-01-04 10:22:53 +00:00
|
|
|
auto result = Auth().settings().thirdColumnWidth();
|
2017-11-12 16:50:58 +00:00
|
|
|
accumulate_max(result, st::columnMinimalWidthThird);
|
|
|
|
accumulate_min(result, st::columnMaximalWidthThird);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller::ShrinkResult Controller::shrinkDialogsAndThirdColumns(
|
|
|
|
int dialogsWidth,
|
|
|
|
int thirdWidth,
|
|
|
|
int bodyWidth) const {
|
|
|
|
auto chatWidth = st::columnMinimalWidthMain;
|
|
|
|
if (dialogsWidth + thirdWidth + chatWidth <= bodyWidth) {
|
|
|
|
return { dialogsWidth, thirdWidth };
|
|
|
|
}
|
|
|
|
auto thirdWidthNew = ((bodyWidth - chatWidth) * thirdWidth)
|
|
|
|
/ (dialogsWidth + thirdWidth);
|
|
|
|
auto dialogsWidthNew = ((bodyWidth - chatWidth) * dialogsWidth)
|
|
|
|
/ (dialogsWidth + thirdWidth);
|
|
|
|
if (thirdWidthNew < st::columnMinimalWidthThird) {
|
|
|
|
thirdWidthNew = st::columnMinimalWidthThird;
|
|
|
|
dialogsWidthNew = bodyWidth - thirdWidthNew - chatWidth;
|
|
|
|
Assert(dialogsWidthNew >= st::columnMinimalWidthLeft);
|
|
|
|
} else if (dialogsWidthNew < st::columnMinimalWidthLeft) {
|
|
|
|
dialogsWidthNew = st::columnMinimalWidthLeft;
|
|
|
|
thirdWidthNew = bodyWidth - dialogsWidthNew - chatWidth;
|
|
|
|
Assert(thirdWidthNew >= st::columnMinimalWidthThird);
|
|
|
|
}
|
|
|
|
return { dialogsWidthNew, thirdWidthNew };
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
bool Controller::canShowThirdSection() const {
|
2017-04-09 18:06:06 +00:00
|
|
|
auto currentLayout = computeColumnLayout();
|
2017-11-16 16:43:52 +00:00
|
|
|
auto minimalExtendBy = minimalThreeColumnWidth()
|
2017-09-16 16:53:41 +00:00
|
|
|
- currentLayout.bodyWidth;
|
2017-11-16 16:43:52 +00:00
|
|
|
return (minimalExtendBy <= window()->maximalExtendBy());
|
2017-05-17 11:50:00 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 10:32:34 +00:00
|
|
|
bool Controller::canShowThirdSectionWithoutResize() const {
|
|
|
|
auto currentWidth = computeColumnLayout().bodyWidth;
|
|
|
|
return currentWidth >= minimalThreeColumnWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Controller::takeThirdSectionFromLayer() {
|
|
|
|
return App::wnd()->takeThirdSectionFromLayer();
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void Controller::resizeForThirdSection() {
|
2017-11-14 08:15:14 +00:00
|
|
|
if (Adaptive::ThreeColumn()) {
|
2017-05-17 11:50:00 +00:00
|
|
|
return;
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2017-11-14 08:15:14 +00:00
|
|
|
auto layout = computeColumnLayout();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto tabbedSelectorSectionEnabled =
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().tabbedSelectorSectionEnabled();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto thirdSectionInfoEnabled =
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().thirdSectionInfoEnabled();
|
|
|
|
Auth().settings().setTabbedSelectorSectionEnabled(false);
|
|
|
|
Auth().settings().setThirdSectionInfoEnabled(false);
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2017-11-16 16:43:52 +00:00
|
|
|
auto wanted = countThirdColumnWidthFromRatio(layout.bodyWidth);
|
|
|
|
auto minimal = st::columnMinimalWidthThird;
|
|
|
|
auto extendBy = wanted;
|
|
|
|
auto extendedBy = [&] {
|
|
|
|
// Best - extend by third column without moving the window.
|
|
|
|
// Next - extend by minimal third column without moving.
|
|
|
|
// Next - show third column inside the window without moving.
|
|
|
|
// Last - extend with moving.
|
|
|
|
if (window()->canExtendNoMove(wanted)) {
|
|
|
|
return window()->tryToExtendWidthBy(wanted);
|
|
|
|
} else if (window()->canExtendNoMove(minimal)) {
|
|
|
|
extendBy = minimal;
|
|
|
|
return window()->tryToExtendWidthBy(minimal);
|
|
|
|
} else if (layout.bodyWidth >= minimalThreeColumnWidth()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return window()->tryToExtendWidthBy(minimal);
|
|
|
|
}();
|
|
|
|
if (extendedBy) {
|
2018-01-04 10:22:53 +00:00
|
|
|
if (extendBy != Auth().settings().thirdColumnWidth()) {
|
|
|
|
Auth().settings().setThirdColumnWidth(extendBy);
|
2017-11-16 16:43:52 +00:00
|
|
|
}
|
|
|
|
auto newBodyWidth = layout.bodyWidth + extendedBy;
|
2018-01-04 10:22:53 +00:00
|
|
|
auto currentRatio = Auth().settings().dialogsWidthRatio();
|
|
|
|
Auth().settings().setDialogsWidthRatio(
|
2017-11-16 16:43:52 +00:00
|
|
|
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
|
|
|
}
|
|
|
|
auto savedValue = (extendedBy == extendBy) ? -1 : extendedBy;
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().setThirdSectionExtendedBy(savedValue);
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().setTabbedSelectorSectionEnabled(
|
2017-09-16 16:53:41 +00:00
|
|
|
tabbedSelectorSectionEnabled);
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().setThirdSectionInfoEnabled(
|
2017-09-16 16:53:41 +00:00
|
|
|
thirdSectionInfoEnabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::closeThirdSection() {
|
|
|
|
auto newWindowSize = window()->size();
|
|
|
|
auto layout = computeColumnLayout();
|
|
|
|
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
|
|
|
|
auto noResize = window()->isFullScreen()
|
|
|
|
|| window()->isMaximized();
|
2018-01-04 10:22:53 +00:00
|
|
|
auto savedValue = Auth().settings().thirdSectionExtendedBy();
|
2017-11-16 16:43:52 +00:00
|
|
|
auto extendedBy = (savedValue == -1)
|
|
|
|
? layout.thirdWidth
|
|
|
|
: savedValue;
|
2017-09-16 16:53:41 +00:00
|
|
|
auto newBodyWidth = noResize
|
|
|
|
? layout.bodyWidth
|
2017-11-16 16:43:52 +00:00
|
|
|
: (layout.bodyWidth - extendedBy);
|
2018-01-04 10:22:53 +00:00
|
|
|
auto currentRatio = Auth().settings().dialogsWidthRatio();
|
|
|
|
Auth().settings().setDialogsWidthRatio(
|
2017-11-16 16:43:52 +00:00
|
|
|
(currentRatio * layout.bodyWidth) / newBodyWidth);
|
2017-09-16 16:53:41 +00:00
|
|
|
newWindowSize = QSize(
|
|
|
|
window()->width() + (newBodyWidth - layout.bodyWidth),
|
|
|
|
window()->height());
|
|
|
|
}
|
2018-01-04 10:22:53 +00:00
|
|
|
Auth().settings().setTabbedSelectorSectionEnabled(false);
|
|
|
|
Auth().settings().setThirdSectionInfoEnabled(false);
|
|
|
|
Auth().saveSettingsDelayed();
|
2017-09-16 16:53:41 +00:00
|
|
|
if (window()->size() != newWindowSize) {
|
|
|
|
window()->resize(newWindowSize);
|
|
|
|
} else {
|
|
|
|
updateColumnLayout();
|
2017-04-09 18:06:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
void Controller::showJumpToDate(not_null<PeerData*> peer, QDate requestedDate) {
|
2017-08-01 11:43:50 +00:00
|
|
|
Expects(peer != nullptr);
|
|
|
|
auto currentPeerDate = [peer] {
|
|
|
|
if (auto history = App::historyLoaded(peer)) {
|
|
|
|
if (history->scrollTopItem) {
|
2018-02-03 19:52:35 +00:00
|
|
|
return history->scrollTopItem->dateTime().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
} else if (history->loadedAtTop() && !history->isEmpty() && history->peer->migrateFrom()) {
|
|
|
|
if (auto migrated = App::historyLoaded(history->peer->migrateFrom())) {
|
|
|
|
if (migrated->scrollTopItem) {
|
|
|
|
// We're up in the migrated history.
|
|
|
|
// So current date is the date of first message here.
|
2018-02-03 19:52:35 +00:00
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-05 15:57:18 +00:00
|
|
|
} else if (!history->chatsListDate().isNull()) {
|
|
|
|
return history->chatsListDate().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return QDate::currentDate();
|
|
|
|
};
|
2017-11-30 12:50:13 +00:00
|
|
|
auto maxPeerDate = [](not_null<PeerData*> peer) {
|
|
|
|
if (auto channel = peer->migrateTo()) {
|
|
|
|
peer = channel;
|
|
|
|
}
|
2017-08-01 11:43:50 +00:00
|
|
|
if (auto history = App::historyLoaded(peer)) {
|
2018-01-05 15:57:18 +00:00
|
|
|
if (!history->chatsListDate().isNull()) {
|
|
|
|
return history->chatsListDate().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return QDate::currentDate();
|
|
|
|
};
|
2017-11-30 12:50:13 +00:00
|
|
|
auto minPeerDate = [](not_null<PeerData*> peer) {
|
|
|
|
const auto startDate = [] {
|
|
|
|
// Telegram was launched in August 2013 :)
|
|
|
|
return QDate(2013, 8, 1);
|
|
|
|
};
|
|
|
|
if (auto chat = peer->migrateFrom()) {
|
|
|
|
if (auto history = App::historyLoaded(chat)) {
|
|
|
|
if (history->loadedAtTop()) {
|
|
|
|
if (!history->isEmpty()) {
|
2018-02-03 19:52:35 +00:00
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-11-30 12:50:13 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return startDate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 11:43:50 +00:00
|
|
|
if (auto history = App::historyLoaded(peer)) {
|
|
|
|
if (history->loadedAtTop()) {
|
2017-11-30 12:50:13 +00:00
|
|
|
if (!history->isEmpty()) {
|
2018-02-03 19:52:35 +00:00
|
|
|
return history->blocks.front()->messages.front()->dateTime().date();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
2017-11-30 12:50:13 +00:00
|
|
|
return QDate::currentDate();
|
2017-08-01 11:43:50 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-30 12:50:13 +00:00
|
|
|
return startDate();
|
2017-08-01 11:43:50 +00:00
|
|
|
};
|
2017-11-30 12:50:13 +00:00
|
|
|
auto highlighted = requestedDate.isNull()
|
|
|
|
? currentPeerDate()
|
|
|
|
: requestedDate;
|
2017-08-01 11:43:50 +00:00
|
|
|
auto month = highlighted;
|
2017-11-30 12:50:13 +00:00
|
|
|
auto callback = [this, peer](const QDate &date) {
|
|
|
|
Auth().api().jumpToDate(peer, date);
|
|
|
|
};
|
|
|
|
auto box = Box<CalendarBox>(
|
|
|
|
month,
|
|
|
|
highlighted,
|
|
|
|
std::move(callback));
|
|
|
|
box->setMinDate(minPeerDate(peer));
|
|
|
|
box->setMaxDate(maxPeerDate(peer));
|
2017-08-01 11:43:50 +00:00
|
|
|
Ui::show(std::move(box));
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void Controller::updateColumnLayout() {
|
|
|
|
App::main()->updateColumnLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::showPeerHistory(
|
|
|
|
PeerId peerId,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
|
|
|
App::main()->ui_showPeerHistory(
|
2017-09-20 10:23:57 +00:00
|
|
|
peerId,
|
2017-10-03 13:05:58 +00:00
|
|
|
params,
|
|
|
|
msgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
void Controller::showPeerHistory(
|
|
|
|
not_null<PeerData*> peer,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
2017-09-20 10:23:57 +00:00
|
|
|
showPeerHistory(
|
|
|
|
peer->id,
|
2017-10-03 13:05:58 +00:00
|
|
|
params,
|
|
|
|
msgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::showPeerHistory(
|
|
|
|
not_null<History*> history,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId msgId) {
|
2017-09-20 10:23:57 +00:00
|
|
|
showPeerHistory(
|
|
|
|
history->peer->id,
|
2017-10-03 13:05:58 +00:00
|
|
|
params,
|
|
|
|
msgId);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 07:33:33 +00:00
|
|
|
void Navigation::showPeerInfo(
|
2017-09-16 16:53:41 +00:00
|
|
|
PeerId peerId,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
2017-12-04 07:33:33 +00:00
|
|
|
//if (Adaptive::ThreeColumn()
|
2018-01-04 10:22:53 +00:00
|
|
|
// && !Auth().settings().thirdSectionInfoEnabled()) {
|
|
|
|
// Auth().settings().setThirdSectionInfoEnabled(true);
|
|
|
|
// Auth().saveSettingsDelayed();
|
2017-12-04 07:33:33 +00:00
|
|
|
//}
|
2017-10-03 13:05:58 +00:00
|
|
|
showSection(Info::Memento(peerId), params);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 07:33:33 +00:00
|
|
|
void Navigation::showPeerInfo(
|
2017-09-16 16:53:41 +00:00
|
|
|
not_null<PeerData*> peer,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
|
|
|
showPeerInfo(peer->id, params);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
2017-12-04 07:33:33 +00:00
|
|
|
void Navigation::showPeerInfo(
|
2017-09-16 16:53:41 +00:00
|
|
|
not_null<History*> history,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
|
|
|
showPeerInfo(history->peer->id, params);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void Controller::showSection(
|
|
|
|
SectionMemento &&memento,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
|
|
|
if (App::wnd()->showSectionInExistingLayer(
|
|
|
|
&memento,
|
2017-12-06 07:05:18 +00:00
|
|
|
params) && !params.thirdColumn) {
|
2017-10-03 13:05:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
App::main()->showSection(std::move(memento), params);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
void Controller::showBackFromStack(const SectionShow ¶ms) {
|
|
|
|
chats()->showBackFromStack(params);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::showSpecialLayer(
|
|
|
|
object_ptr<LayerWidget> &&layer,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated) {
|
|
|
|
App::wnd()->showSpecialLayer(std::move(layer), animated);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
not_null<MainWidget*> Controller::chats() const {
|
|
|
|
return App::wnd()->chatsWidget();
|
|
|
|
}
|
|
|
|
|
2018-01-21 14:49:42 +00:00
|
|
|
bool Controller::startRoundVideo(not_null<HistoryItem*> context) {
|
|
|
|
if (auto video = RoundController::TryStart(this, context)) {
|
|
|
|
enableGifPauseReason(Window::GifPauseReason::RoundPlaying);
|
|
|
|
_roundVideo = std::move(video);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::currentRoundVideo() const -> RoundController* {
|
|
|
|
return _roundVideo.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::roundVideo(not_null<const HistoryItem*> context) const
|
|
|
|
-> RoundController* {
|
|
|
|
return roundVideo(context->fullId());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Controller::roundVideo(FullMsgId contextId) const -> RoundController* {
|
|
|
|
if (const auto result = currentRoundVideo()) {
|
|
|
|
if (result->contextId() == contextId) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::roundVideoFinished(not_null<RoundController*> video) {
|
|
|
|
if (video == _roundVideo.get()) {
|
|
|
|
_roundVideo = nullptr;
|
|
|
|
disableGifPauseReason(Window::GifPauseReason::RoundPlaying);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller::~Controller() = default;
|
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
} // namespace Window
|