2017-09-30 18:26:45 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
|
|
*/
|
|
|
|
#include "info/info_wrap_widget.h"
|
|
|
|
|
|
|
|
#include <rpl/flatten_latest.h>
|
2017-10-03 13:05:58 +00:00
|
|
|
#include <rpl/combine.h>
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "info/profile/info_profile_widget.h"
|
2017-11-17 13:23:36 +00:00
|
|
|
#include "info/profile/info_profile_members.h"
|
2017-11-07 15:12:54 +00:00
|
|
|
#include "info/profile/info_profile_values.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "info/media/info_media_widget.h"
|
|
|
|
#include "info/info_content_widget.h"
|
2017-10-31 18:25:22 +00:00
|
|
|
#include "info/info_controller.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "info/info_memento.h"
|
|
|
|
#include "info/info_top_bar.h"
|
2017-10-20 16:19:42 +00:00
|
|
|
#include "info/info_top_bar_override.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "ui/widgets/discrete_sliders.h"
|
|
|
|
#include "ui/widgets/buttons.h"
|
|
|
|
#include "ui/widgets/shadow.h"
|
2017-11-07 15:12:54 +00:00
|
|
|
#include "ui/widgets/dropdown_menu.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "ui/wrap/fade_wrap.h"
|
2017-11-03 12:03:00 +00:00
|
|
|
#include "ui/search_field_controller.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "window/window_controller.h"
|
2017-10-03 13:05:58 +00:00
|
|
|
#include "window/window_slide_animation.h"
|
2017-11-07 15:12:54 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2017-11-17 13:23:36 +00:00
|
|
|
#include "boxes/peer_list_box.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "auth_session.h"
|
2017-11-07 15:12:54 +00:00
|
|
|
#include "mainwidget.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "styles/style_info.h"
|
|
|
|
#include "styles/style_profile.h"
|
|
|
|
|
|
|
|
namespace Info {
|
2017-10-20 16:19:42 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const style::InfoTopBar &TopBarStyle(Wrap wrap) {
|
|
|
|
return (wrap == Wrap::Layer)
|
|
|
|
? st::infoLayerTopBar
|
|
|
|
: st::infoTopBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
struct WrapWidget::StackItem {
|
|
|
|
std::unique_ptr<ContentMemento> section;
|
2017-11-16 17:19:41 +00:00
|
|
|
// std::unique_ptr<ContentMemento> anotherTab;
|
2017-10-03 13:05:58 +00:00
|
|
|
};
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
WrapWidget::WrapWidget(
|
|
|
|
QWidget *parent,
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<Window::Controller*> window,
|
2017-09-30 18:26:45 +00:00
|
|
|
Wrap wrap,
|
|
|
|
not_null<Memento*> memento)
|
2017-10-31 18:25:22 +00:00
|
|
|
: SectionWidget(parent, window)
|
2017-10-03 13:05:58 +00:00
|
|
|
, _wrap(wrap)
|
2017-10-31 18:25:22 +00:00
|
|
|
, _controller(createController(window, memento->content()))
|
2017-10-03 13:05:58 +00:00
|
|
|
, _topShadow(this) {
|
2017-11-06 08:50:54 +00:00
|
|
|
_topShadow->toggleOn(topShadowToggledValue()
|
|
|
|
| rpl::filter([](bool shown) {
|
|
|
|
return true;
|
|
|
|
}));
|
2017-10-31 18:25:22 +00:00
|
|
|
_wrap.changes()
|
|
|
|
| rpl::start_with_next([this] {
|
|
|
|
setupTop();
|
|
|
|
finishShowContent();
|
|
|
|
}, lifetime());
|
2017-10-20 16:19:42 +00:00
|
|
|
selectedListValue()
|
|
|
|
| rpl::start_with_next([this](SelectedItems &&items) {
|
|
|
|
InvokeQueued(this, [this, items = std::move(items)]() mutable {
|
|
|
|
refreshTopBarOverride(std::move(items));
|
|
|
|
});
|
|
|
|
}, lifetime());
|
2017-11-03 18:26:14 +00:00
|
|
|
restoreHistoryStack(memento->takeStack());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::restoreHistoryStack(
|
|
|
|
std::vector<std::unique_ptr<ContentMemento>> stack) {
|
|
|
|
Expects(!stack.empty());
|
2017-11-16 17:19:41 +00:00
|
|
|
Expects(!hasStackHistory());
|
|
|
|
|
2017-11-03 18:26:14 +00:00
|
|
|
auto content = std::move(stack.back());
|
|
|
|
stack.pop_back();
|
|
|
|
if (!stack.empty()) {
|
|
|
|
_historyStack.reserve(stack.size());
|
|
|
|
for (auto &stackItem : stack) {
|
|
|
|
auto item = StackItem();
|
|
|
|
item.section = std::move(stackItem);
|
|
|
|
_historyStack.push_back(std::move(item));
|
|
|
|
}
|
|
|
|
}
|
2017-11-17 07:33:20 +00:00
|
|
|
|
|
|
|
startInjectingActivePeerProfiles();
|
|
|
|
|
2017-11-03 18:26:14 +00:00
|
|
|
showNewContent(content.get());
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 17:19:41 +00:00
|
|
|
void WrapWidget::startInjectingActivePeerProfiles() {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
rpl::combine(
|
|
|
|
_wrap.value(),
|
|
|
|
_controller->window()->activePeer.value())
|
2017-11-20 12:32:55 +00:00
|
|
|
| rpl::filter((_1 == Wrap::Side) && (_2 != nullptr))
|
|
|
|
| rpl::map(_2)
|
2017-11-16 17:19:41 +00:00
|
|
|
| rpl::start_with_next([this](not_null<PeerData*> peer) {
|
|
|
|
injectActivePeerProfile(peer);
|
|
|
|
}, lifetime());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
|
|
|
|
auto firstPeerId = hasStackHistory()
|
|
|
|
? _historyStack.front().section->peerId()
|
|
|
|
: _controller->peerId();
|
|
|
|
auto firstSectionType = hasStackHistory()
|
|
|
|
? _historyStack.front().section->section().type()
|
|
|
|
: _controller->section().type();
|
|
|
|
if (firstSectionType != Section::Type::Profile
|
|
|
|
|| firstPeerId != peer->id) {
|
|
|
|
auto injected = StackItem();
|
|
|
|
injected.section = std::move(
|
|
|
|
Memento(peer->id).takeStack().front());
|
|
|
|
_historyStack.insert(
|
|
|
|
_historyStack.begin(),
|
|
|
|
std::move(injected));
|
2017-11-17 07:33:20 +00:00
|
|
|
if (_content) {
|
|
|
|
setupTop();
|
|
|
|
finishShowContent();
|
|
|
|
}
|
2017-11-16 17:19:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
std::unique_ptr<Controller> WrapWidget::createController(
|
|
|
|
not_null<Window::Controller*> window,
|
|
|
|
not_null<ContentMemento*> memento) {
|
|
|
|
auto result = std::make_unique<Controller>(
|
|
|
|
this,
|
|
|
|
window,
|
|
|
|
memento);
|
|
|
|
return result;
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<PeerData*> WrapWidget::peer() const {
|
|
|
|
return _controller->peer();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//void WrapWidget::createTabs() {
|
|
|
|
// _topTabs.create(this, st::infoTabs);
|
|
|
|
// auto sections = QStringList();
|
|
|
|
// sections.push_back(lang(lng_profile_info_section).toUpper());
|
|
|
|
// sections.push_back(lang(lng_info_tab_media).toUpper());
|
|
|
|
// _topTabs->setSections(sections);
|
|
|
|
// _topTabs->setActiveSection(static_cast<int>(_tab));
|
|
|
|
// _topTabs->finishAnimating();
|
|
|
|
//
|
|
|
|
// _topTabs->sectionActivated()
|
|
|
|
// | rpl::map([](int index) { return static_cast<Tab>(index); })
|
|
|
|
// | rpl::start_with_next(
|
|
|
|
// [this](Tab tab) { showTab(tab); },
|
|
|
|
// lifetime());
|
|
|
|
//
|
|
|
|
// _topTabs->move(0, 0);
|
|
|
|
// _topTabs->resizeToWidth(width());
|
|
|
|
// _topTabs->show();
|
|
|
|
//
|
|
|
|
// _topTabsBackground.create(this, st::profileBg);
|
|
|
|
// _topTabsBackground->setAttribute(Qt::WA_OpaquePaintEvent);
|
|
|
|
//
|
|
|
|
// _topTabsBackground->move(0, 0);
|
|
|
|
// _topTabsBackground->resize(
|
|
|
|
// width(),
|
|
|
|
// _topTabs->height() - st::lineWidth);
|
|
|
|
// _topTabsBackground->show();
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-04 10:27:21 +00:00
|
|
|
void WrapWidget::forceContentRepaint() {
|
|
|
|
// WA_OpaquePaintEvent on TopBar creates render glitches when
|
|
|
|
// animating the LayerWidget's height :( Fixing by repainting.
|
2017-11-16 09:13:17 +00:00
|
|
|
|
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topTabsBackground->update();
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (_topBar) {
|
2017-10-04 10:27:21 +00:00
|
|
|
_topBar->update();
|
|
|
|
}
|
|
|
|
_content->update();
|
|
|
|
}
|
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//void WrapWidget::showTab(Tab tab) {
|
|
|
|
// if (_tab == tab) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// Expects(_content != nullptr);
|
|
|
|
// auto direction = (tab > _tab)
|
|
|
|
// ? SlideDirection::FromRight
|
|
|
|
// : SlideDirection::FromLeft;
|
|
|
|
// auto newAnotherMemento = _content->createMemento();
|
|
|
|
// if (!_anotherTabMemento) {
|
|
|
|
// _anotherTabMemento = createTabMemento(tab);
|
|
|
|
// }
|
|
|
|
// auto newController = createController(
|
|
|
|
// _controller->window(),
|
|
|
|
// _anotherTabMemento.get());
|
|
|
|
// auto newContent = createContent(
|
|
|
|
// _anotherTabMemento.get(),
|
|
|
|
// newController.get());
|
|
|
|
// auto animationParams = SectionSlideParams();
|
|
|
|
//// animationParams.withFade = (wrap() == Wrap::Layer);
|
|
|
|
// animationParams.withTabs = true;
|
|
|
|
// animationParams.withTopBarShadow = hasTopBarShadow()
|
|
|
|
// && newContent->hasTopBarShadow();
|
|
|
|
// animationParams.oldContentCache = grabForShowAnimation(
|
|
|
|
// animationParams);
|
|
|
|
//
|
|
|
|
// _controller = std::move(newController);
|
|
|
|
// showContent(std::move(newContent));
|
|
|
|
//
|
|
|
|
// showAnimated(direction, animationParams);
|
|
|
|
//
|
|
|
|
// _anotherTabMemento = std::move(newAnotherMemento);
|
|
|
|
// _tab = tab;
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//void WrapWidget::setupTabbedTop() {
|
|
|
|
// auto section = _controller->section();
|
|
|
|
// switch (section.type()) {
|
|
|
|
// case Section::Type::Profile:
|
|
|
|
// setupTabs(Tab::Profile);
|
|
|
|
// break;
|
|
|
|
// case Section::Type::Media:
|
|
|
|
// switch (section.mediaType()) {
|
|
|
|
// case Section::MediaType::Photo:
|
|
|
|
// case Section::MediaType::Video:
|
|
|
|
// case Section::MediaType::File:
|
|
|
|
// setupTabs(Tab::Media);
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// setupTabs(Tab::None);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// case Section::Type::CommonGroups:
|
2017-11-17 13:23:36 +00:00
|
|
|
// case Section::Type::Members:
|
2017-11-16 09:13:17 +00:00
|
|
|
// setupTabs(Tab::None);
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
void WrapWidget::setupTop() {
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
2017-11-16 17:19:41 +00:00
|
|
|
//if (wrap() == Wrap::Side && !hasStackHistory()) {
|
2017-11-16 09:13:17 +00:00
|
|
|
// setupTabbedTop();
|
|
|
|
//} else {
|
|
|
|
// setupTabs(Tab::None);
|
|
|
|
//}
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topBar.destroy();
|
|
|
|
//} else {
|
|
|
|
// createTopBar();
|
|
|
|
//}
|
|
|
|
createTopBar();
|
2017-10-20 18:52:48 +00:00
|
|
|
refreshTopBarOverride();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
void WrapWidget::createTopBar() {
|
2017-11-16 09:13:17 +00:00
|
|
|
auto wrapValue = wrap();
|
|
|
|
_topBar.create(this, TopBarStyle(wrapValue));
|
2017-10-03 13:05:58 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
_topBar->setTitle(TitleValue(
|
2017-10-31 18:25:22 +00:00
|
|
|
_controller->section(),
|
|
|
|
_controller->peer()));
|
2017-11-16 09:13:17 +00:00
|
|
|
if (wrapValue == Wrap::Narrow || hasStackHistory()) {
|
2017-09-30 18:26:45 +00:00
|
|
|
_topBar->enableBackButton(true);
|
|
|
|
_topBar->backRequest()
|
|
|
|
| rpl::start_with_next([this] {
|
2017-10-03 13:05:58 +00:00
|
|
|
showBackFromStack();
|
2017-09-30 18:26:45 +00:00
|
|
|
}, _topBar->lifetime());
|
2017-11-16 09:13:17 +00:00
|
|
|
} else if (wrapValue == Wrap::Side) {
|
|
|
|
auto close = _topBar->addButton(
|
|
|
|
base::make_unique_q<Ui::IconButton>(
|
|
|
|
_topBar,
|
|
|
|
st::infoTopBarClose));
|
|
|
|
close->addClickHandler([this] {
|
|
|
|
_controller->window()->closeThirdSection();
|
|
|
|
});
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
2017-11-16 09:13:17 +00:00
|
|
|
if (wrapValue == Wrap::Layer) {
|
2017-11-03 12:03:00 +00:00
|
|
|
auto close = _topBar->addButton(
|
|
|
|
base::make_unique_q<Ui::IconButton>(
|
|
|
|
_topBar,
|
|
|
|
st::infoLayerTopBarClose));
|
2017-10-03 14:57:11 +00:00
|
|
|
close->addClickHandler([this] {
|
2017-10-31 18:25:22 +00:00
|
|
|
_controller->window()->hideSpecialLayer();
|
2017-10-03 14:57:11 +00:00
|
|
|
});
|
2017-11-03 12:03:00 +00:00
|
|
|
} else if (requireTopBarSearch()) {
|
|
|
|
auto search = _controller->searchFieldController();
|
|
|
|
Assert(search != nullptr);
|
2017-11-03 18:26:14 +00:00
|
|
|
_topBar->createSearchView(
|
|
|
|
search,
|
|
|
|
_controller->searchEnabledByContent());
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
2017-11-16 09:13:17 +00:00
|
|
|
if (_controller->section().type() == Section::Type::Profile
|
|
|
|
&& (wrapValue != Wrap::Side || hasStackHistory())) {
|
2017-11-07 15:12:54 +00:00
|
|
|
addProfileMenuButton();
|
2017-11-10 19:19:43 +00:00
|
|
|
// addProfileNotificationsButton();
|
2017-11-07 15:12:54 +00:00
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
|
|
|
|
_topBar->move(0, 0);
|
|
|
|
_topBar->resizeToWidth(width());
|
|
|
|
_topBar->show();
|
|
|
|
}
|
|
|
|
|
2017-11-07 15:12:54 +00:00
|
|
|
void WrapWidget::addProfileMenuButton() {
|
|
|
|
Expects(_topBar != nullptr);
|
|
|
|
|
|
|
|
_topBarMenuToggle.reset(_topBar->addButton(
|
|
|
|
base::make_unique_q<Ui::IconButton>(
|
|
|
|
_topBar,
|
|
|
|
(wrap() == Wrap::Layer
|
|
|
|
? st::infoLayerTopBarMenu
|
|
|
|
: st::infoTopBarMenu))));
|
|
|
|
_topBarMenuToggle->addClickHandler([this] {
|
|
|
|
showProfileMenu();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::addProfileNotificationsButton() {
|
|
|
|
Expects(_topBar != nullptr);
|
|
|
|
|
|
|
|
auto peer = _controller->peer();
|
|
|
|
auto notifications = _topBar->addButton(
|
|
|
|
base::make_unique_q<Ui::IconButton>(
|
|
|
|
_topBar,
|
|
|
|
(wrap() == Wrap::Layer
|
|
|
|
? st::infoLayerTopBarNotifications
|
|
|
|
: st::infoTopBarNotifications)));
|
|
|
|
notifications->addClickHandler([peer] {
|
|
|
|
App::main()->updateNotifySetting(
|
|
|
|
peer,
|
|
|
|
peer->isMuted()
|
|
|
|
? NotifySettingSetNotify
|
|
|
|
: NotifySettingSetMuted);
|
|
|
|
});
|
|
|
|
Profile::NotificationsEnabledValue(peer)
|
|
|
|
| rpl::start_with_next([notifications](bool enabled) {
|
|
|
|
auto iconOverride = enabled
|
|
|
|
? &st::infoNotificationsActive
|
|
|
|
: nullptr;
|
|
|
|
auto rippleOverride = enabled
|
|
|
|
? &st::lightButtonBgOver
|
|
|
|
: nullptr;
|
|
|
|
notifications->setIconOverride(iconOverride, iconOverride);
|
|
|
|
notifications->setRippleColorOverride(rippleOverride);
|
|
|
|
}, notifications->lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::showProfileMenu() {
|
|
|
|
if (_topBarMenu) {
|
|
|
|
_topBarMenu->hideAnimated(
|
|
|
|
Ui::InnerDropdown::HideOption::IgnoreShow);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_topBarMenu = base::make_unique_q<Ui::DropdownMenu>(this);
|
|
|
|
|
|
|
|
_topBarMenu->setHiddenCallback([this] {
|
|
|
|
InvokeQueued(this, [this] { _topBarMenu = nullptr; });
|
|
|
|
if (auto toggle = _topBarMenuToggle.get()) {
|
|
|
|
toggle->setForceRippled(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_topBarMenu->setShowStartCallback([this] {
|
|
|
|
if (auto toggle = _topBarMenuToggle.get()) {
|
|
|
|
toggle->setForceRippled(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_topBarMenu->setHideStartCallback([this] {
|
|
|
|
if (auto toggle = _topBarMenuToggle.get()) {
|
|
|
|
toggle->setForceRippled(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
_topBarMenuToggle->installEventFilter(_topBarMenu.get());
|
|
|
|
|
|
|
|
Window::FillPeerMenu(
|
|
|
|
_controller->window(),
|
|
|
|
_controller->peer(),
|
|
|
|
[this](const QString &text, base::lambda<void()> callback) {
|
|
|
|
return _topBarMenu->addAction(text, std::move(callback));
|
|
|
|
},
|
|
|
|
Window::PeerMenuSource::Profile);
|
|
|
|
auto position = (wrap() == Wrap::Layer)
|
|
|
|
? st::infoLayerTopBarMenuPosition
|
|
|
|
: st::infoTopBarMenuPosition;
|
|
|
|
_topBarMenu->moveToRight(position.x(), position.y());
|
|
|
|
_topBarMenu->showAnimated(Ui::PanelAnimation::Origin::TopRight);
|
|
|
|
}
|
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
void WrapWidget::refreshTopBarOverride(SelectedItems &&items) {
|
|
|
|
if (items.list.empty()) {
|
|
|
|
destroyTopBarOverride();
|
|
|
|
} else if (_topBarOverride) {
|
|
|
|
_topBarOverride->setItems(std::move(items));
|
|
|
|
} else {
|
|
|
|
createTopBarOverride(std::move(items));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-20 18:52:48 +00:00
|
|
|
void WrapWidget::refreshTopBarOverride() {
|
|
|
|
if (_topBarOverride) {
|
|
|
|
auto items = _topBarOverride->takeItems();
|
|
|
|
destroyTopBarOverride();
|
|
|
|
createTopBarOverride(std::move(items));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
void WrapWidget::destroyTopBarOverride() {
|
|
|
|
if (!_topBarOverride) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto widget = std::exchange(_topBarOverride, nullptr);
|
|
|
|
auto handle = weak(widget.data());
|
|
|
|
_topBarOverrideAnimation.start([this, handle] {
|
|
|
|
}, 1., 0., st::slideWrapDuration);
|
|
|
|
widget.destroy();
|
2017-11-16 09:13:17 +00:00
|
|
|
|
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topTabs->show();
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (_topBar) {
|
2017-10-20 16:19:42 +00:00
|
|
|
_topBar->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::createTopBarOverride(SelectedItems &&items) {
|
|
|
|
Expects(_topBarOverride == nullptr);
|
|
|
|
_topBarOverride.create(
|
|
|
|
this,
|
|
|
|
TopBarStyle(wrap()),
|
|
|
|
std::move(items));
|
2017-11-16 09:13:17 +00:00
|
|
|
|
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topTabs->hide();
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (_topBar) {
|
2017-10-20 16:19:42 +00:00
|
|
|
_topBar->hide();
|
|
|
|
}
|
|
|
|
_topBarOverride->cancelRequests()
|
|
|
|
| rpl::start_with_next([this](auto) {
|
|
|
|
_content->cancelSelection();
|
|
|
|
}, _topBarOverride->lifetime());
|
|
|
|
_topBarOverride->moveToLeft(0, 0);
|
|
|
|
_topBarOverride->resizeToWidth(width());
|
|
|
|
_topBarOverride->show();
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:03:00 +00:00
|
|
|
bool WrapWidget::requireTopBarSearch() const {
|
|
|
|
if (!_controller->searchFieldController()) {
|
|
|
|
return false;
|
2017-11-17 13:23:36 +00:00
|
|
|
} else if (_controller->wrap() == Wrap::Layer
|
|
|
|
|| _controller->section().type() == Section::Type::Profile) {
|
2017-11-03 12:03:00 +00:00
|
|
|
return false;
|
|
|
|
} else if (hasStackHistory()) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was for top-level tabs support.
|
|
|
|
//
|
|
|
|
//auto section = _controller->section();
|
|
|
|
//return (section.type() != Section::Type::Media)
|
|
|
|
// || !Media::TypeToTabIndex(section.mediaType()).has_value();
|
|
|
|
return false;
|
2017-11-03 12:03:00 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
void WrapWidget::showBackFromStack() {
|
|
|
|
auto params = Window::SectionShow(
|
|
|
|
Window::SectionShow::Way::Backward);
|
2017-11-16 17:19:41 +00:00
|
|
|
if (hasStackHistory()) {
|
2017-10-03 13:05:58 +00:00
|
|
|
auto last = std::move(_historyStack.back());
|
|
|
|
_historyStack.pop_back();
|
|
|
|
showNewContent(
|
|
|
|
last.section.get(),
|
|
|
|
params);
|
2017-11-16 17:19:41 +00:00
|
|
|
//_anotherTabMemento = std::move(last.anotherTab);
|
2017-11-17 14:54:01 +00:00
|
|
|
} else if (wrap() != Wrap::Layer) {
|
2017-10-31 18:25:22 +00:00
|
|
|
_controller->window()->showBackFromStack(params);
|
2017-10-03 13:05:58 +00:00
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
not_null<Ui::RpWidget*> WrapWidget::topWidget() const {
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// return _topTabsBackground;
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
return _topBar;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::showContent(object_ptr<ContentWidget> content) {
|
|
|
|
_content = std::move(content);
|
|
|
|
_content->show();
|
2017-11-16 17:19:41 +00:00
|
|
|
//_anotherTabMemento = nullptr;
|
2017-09-30 18:26:45 +00:00
|
|
|
finishShowContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WrapWidget::finishShowContent() {
|
2017-11-16 17:19:41 +00:00
|
|
|
_content->setIsStackBottom(!hasStackHistory());
|
2017-10-03 13:05:58 +00:00
|
|
|
updateContentGeometry();
|
|
|
|
_desiredHeights.fire(desiredHeightForContent());
|
|
|
|
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility());
|
2017-10-20 16:19:42 +00:00
|
|
|
_selectedLists.fire(_content->selectedListValue());
|
2017-10-03 14:57:11 +00:00
|
|
|
_topShadow->raise();
|
|
|
|
_topShadow->finishAnimating();
|
2017-11-16 09:13:17 +00:00
|
|
|
|
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topTabs->raise();
|
|
|
|
//}
|
2017-10-03 13:05:58 +00:00
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
rpl::producer<bool> WrapWidget::topShadowToggledValue() const {
|
2017-11-16 09:13:17 +00:00
|
|
|
// Allows always showing shadow for specific wrap value.
|
|
|
|
// Was done for top level tabs support.
|
|
|
|
//
|
|
|
|
//using namespace rpl::mappers;
|
|
|
|
//return rpl::combine(
|
|
|
|
// _controller->wrapValue(),
|
|
|
|
// _desiredShadowVisibilities.events() | rpl::flatten_latest(),
|
2017-11-20 12:32:55 +00:00
|
|
|
// (_1 == Wrap::Side) || _2);
|
2017-11-16 09:13:17 +00:00
|
|
|
return _desiredShadowVisibilities.events()
|
|
|
|
| rpl::flatten_latest();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<int> WrapWidget::desiredHeightForContent() const {
|
2017-10-03 13:05:58 +00:00
|
|
|
using namespace rpl::mappers;
|
|
|
|
return rpl::combine(
|
|
|
|
_content->desiredHeightValue(),
|
2017-10-03 14:57:11 +00:00
|
|
|
topWidget()->heightValue(),
|
2017-11-20 12:32:55 +00:00
|
|
|
_1 + _2);
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-20 16:19:42 +00:00
|
|
|
rpl::producer<SelectedItems> WrapWidget::selectedListValue() const {
|
|
|
|
return _selectedLists.events() | rpl::flatten_latest();
|
|
|
|
}
|
|
|
|
|
2017-11-16 17:19:41 +00:00
|
|
|
// Was done for top level tabs support.
|
|
|
|
//
|
|
|
|
//std::unique_ptr<ContentMemento> WrapWidget::createTabMemento(
|
|
|
|
// Tab tab) {
|
|
|
|
// switch (tab) {
|
|
|
|
// case Tab::Profile: return std::make_unique<Profile::Memento>(
|
|
|
|
// _controller->peerId(),
|
|
|
|
// _controller->migratedPeerId());
|
|
|
|
// case Tab::Media: return std::make_unique<Media::Memento>(
|
|
|
|
// _controller->peerId(),
|
|
|
|
// _controller->migratedPeerId(),
|
|
|
|
// Media::Type::Photo);
|
|
|
|
// }
|
|
|
|
// Unexpected("Tab value in Info::WrapWidget::createInner()");
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
object_ptr<ContentWidget> WrapWidget::createContent(
|
2017-10-31 18:25:22 +00:00
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
not_null<Controller*> controller) {
|
2017-10-03 13:05:58 +00:00
|
|
|
return memento->createWidget(
|
|
|
|
this,
|
2017-10-31 18:25:22 +00:00
|
|
|
controller,
|
2017-10-03 13:05:58 +00:00
|
|
|
contentGeometry());
|
|
|
|
}
|
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
// Was done for top level tabs support.
|
|
|
|
//
|
|
|
|
//void WrapWidget::convertProfileFromStackToTab() {
|
2017-11-16 17:19:41 +00:00
|
|
|
// if (!hasStackHistory()) {
|
2017-11-16 09:13:17 +00:00
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// auto &entry = _historyStack[0];
|
|
|
|
// if (entry.section->section().type() != Section::Type::Profile) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// auto convertInsideStack = (_historyStack.size() > 1);
|
|
|
|
// auto checkSection = convertInsideStack
|
|
|
|
// ? _historyStack[1].section->section()
|
|
|
|
// : _controller->section();
|
|
|
|
// auto &anotherMemento = convertInsideStack
|
|
|
|
// ? _historyStack[1].anotherTab
|
|
|
|
// : _anotherTabMemento;
|
|
|
|
// if (checkSection.type() != Section::Type::Media) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// if (!Info::Media::TypeToTabIndex(checkSection.mediaType())) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// anotherMemento = std::move(entry.section);
|
|
|
|
// _historyStack.erase(_historyStack.begin());
|
|
|
|
//}
|
2017-11-03 12:03:00 +00:00
|
|
|
|
|
|
|
void WrapWidget::setWrap(Wrap wrap) {
|
2017-11-16 09:13:17 +00:00
|
|
|
// Was done for top level tabs support.
|
|
|
|
//
|
|
|
|
//if (_wrap.current() != Wrap::Side && wrap == Wrap::Side) {
|
|
|
|
// convertProfileFromStackToTab();
|
|
|
|
//}
|
2017-11-03 12:03:00 +00:00
|
|
|
_wrap = wrap;
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
bool WrapWidget::hasTopBarShadow() const {
|
2017-09-30 19:20:40 +00:00
|
|
|
return _topShadow->toggled();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap WrapWidget::grabForShowAnimation(
|
|
|
|
const Window::SectionSlideParams ¶ms) {
|
2017-10-03 14:57:11 +00:00
|
|
|
if (params.withTopBarShadow) {
|
|
|
|
_topShadow->setVisible(false);
|
|
|
|
} else {
|
2017-11-06 08:50:54 +00:00
|
|
|
_topShadow->setVisible(_topShadow->toggled());
|
2017-10-03 14:57:11 +00:00
|
|
|
}
|
2017-11-16 09:13:17 +00:00
|
|
|
//if (params.withTabs && _topTabs) {
|
|
|
|
// _topTabs->hide();
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
auto result = myGrab(this);
|
2017-10-03 17:41:44 +00:00
|
|
|
if (params.withTopBarShadow) {
|
|
|
|
_topShadow->setVisible(true);
|
|
|
|
}
|
2017-11-16 09:13:17 +00:00
|
|
|
//if (params.withTabs && _topTabs) {
|
|
|
|
// _topTabs->show();
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-10-03 17:41:44 +00:00
|
|
|
void WrapWidget::showAnimatedHook(
|
|
|
|
const Window::SectionSlideParams ¶ms) {
|
2017-11-16 09:13:17 +00:00
|
|
|
//if (params.withTabs && _topTabs) {
|
|
|
|
// _topTabs->show();
|
|
|
|
// _topTabsBackground->show();
|
|
|
|
//}
|
2017-11-06 08:50:54 +00:00
|
|
|
if (params.withTopBarShadow) {
|
|
|
|
_topShadow->setVisible(true);
|
|
|
|
}
|
2017-11-16 15:24:01 +00:00
|
|
|
_topBarSurrogate = createTopBarSurrogate(this);
|
2017-10-03 17:41:44 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 14:57:11 +00:00
|
|
|
void WrapWidget::doSetInnerFocus() {
|
2017-09-30 18:26:45 +00:00
|
|
|
_content->setInnerFocus();
|
|
|
|
}
|
|
|
|
|
2017-10-03 14:57:11 +00:00
|
|
|
void WrapWidget::showFinishedHook() {
|
|
|
|
// Restore shadow visibility after showChildren() call.
|
|
|
|
_topShadow->toggle(_topShadow->toggled(), anim::type::instant);
|
2017-11-16 15:24:01 +00:00
|
|
|
_topBarSurrogate.destroy();
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WrapWidget::showInternal(
|
2017-10-03 13:05:58 +00:00
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) {
|
2017-09-30 18:26:45 +00:00
|
|
|
if (auto infoMemento = dynamic_cast<Memento*>(memento.get())) {
|
2017-11-13 06:00:38 +00:00
|
|
|
if (!_controller || infoMemento->stackSize() > 1) {
|
2017-11-03 18:26:14 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
auto content = infoMemento->content();
|
2017-11-16 17:19:41 +00:00
|
|
|
auto skipInternal = hasStackHistory()
|
2017-11-13 17:40:25 +00:00
|
|
|
&& (params.way == Window::SectionShow::Way::ClearStack);
|
2017-11-17 07:33:20 +00:00
|
|
|
if (_controller->validateMementoPeer(content)) {
|
2017-11-13 17:40:25 +00:00
|
|
|
if (!skipInternal && _content->showInternal(content)) {
|
2017-11-16 09:13:17 +00:00
|
|
|
highlightTopBar();
|
2017-10-31 18:25:22 +00:00
|
|
|
return true;
|
2017-11-16 09:13:17 +00:00
|
|
|
|
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//} else if (_topTabs) {
|
|
|
|
// // If we open the profile being in the media tab.
|
|
|
|
// // Just switch back to the profile tab.
|
|
|
|
// auto type = content->section().type();
|
|
|
|
// if (type == Section::Type::Profile
|
|
|
|
// && _tab != Tab::Profile) {
|
|
|
|
// _anotherTabMemento = std::move(infoMemento->takeStack().back());
|
|
|
|
// _topTabs->setActiveSection(static_cast<int>(Tab::Profile));
|
|
|
|
// return true;
|
|
|
|
// } else if (type == Section::Type::Media
|
|
|
|
// && _tab != Tab::Media
|
|
|
|
// && Media::TypeToTabIndex(content->section().mediaType()).has_value()) {
|
|
|
|
// _anotherTabMemento = std::move(infoMemento->takeStack().back());
|
|
|
|
// _topTabs->setActiveSection(static_cast<int>(Tab::Media));
|
|
|
|
// return true;
|
|
|
|
// }
|
2017-10-31 18:25:22 +00:00
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
2017-11-17 07:33:20 +00:00
|
|
|
|
|
|
|
// If we're in a nested section and we're asked to show
|
|
|
|
// a chat profile that is at the bottom of the stack we'll
|
|
|
|
// just go back in the stack all the way instead of pushing.
|
|
|
|
if (returnToFirstStackFrame(content, params)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-31 18:25:22 +00:00
|
|
|
showNewContent(
|
|
|
|
content,
|
|
|
|
params);
|
2017-10-03 13:05:58 +00:00
|
|
|
return true;
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
void WrapWidget::highlightTopBar() {
|
|
|
|
if (_topBar) {
|
|
|
|
_topBar->highlight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
std::unique_ptr<Window::SectionMemento> WrapWidget::createMemento() {
|
2017-11-03 18:26:14 +00:00
|
|
|
auto stack = std::vector<std::unique_ptr<ContentMemento>>();
|
|
|
|
stack.reserve(_historyStack.size() + 1);
|
2017-11-13 06:00:38 +00:00
|
|
|
for (auto &stackItem : base::take(_historyStack)) {
|
2017-11-03 18:26:14 +00:00
|
|
|
stack.push_back(std::move(stackItem.section));
|
|
|
|
}
|
|
|
|
stack.push_back(_content->createMemento());
|
2017-11-13 06:00:38 +00:00
|
|
|
|
|
|
|
// We're not in valid state anymore and supposed to be destroyed.
|
|
|
|
_controller = nullptr;
|
|
|
|
|
2017-11-03 18:26:14 +00:00
|
|
|
return std::make_unique<Memento>(std::move(stack));
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<int> WrapWidget::desiredHeightValue() const {
|
|
|
|
return
|
|
|
|
rpl::single(desiredHeightForContent())
|
|
|
|
| rpl::then(_desiredHeights.events())
|
|
|
|
| rpl::flatten_latest();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect WrapWidget::contentGeometry() const {
|
2017-10-03 14:57:11 +00:00
|
|
|
return rect().marginsRemoved({ 0, topWidget()->height(), 0, 0 });
|
2017-10-03 13:05:58 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 07:33:20 +00:00
|
|
|
|
|
|
|
bool WrapWidget::returnToFirstStackFrame(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) {
|
|
|
|
if (!hasStackHistory()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto firstPeerId = _historyStack.front().section->peerId();
|
|
|
|
auto firstSection = _historyStack.front().section->section();
|
|
|
|
if (firstPeerId == memento->peerId()
|
|
|
|
&& firstSection.type() == memento->section().type()
|
|
|
|
&& firstSection.type() == Section::Type::Profile) {
|
|
|
|
_historyStack.resize(1);
|
|
|
|
showBackFromStack();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
void WrapWidget::showNewContent(
|
|
|
|
not_null<ContentMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) {
|
|
|
|
auto saveToStack = (_content != nullptr)
|
|
|
|
&& (params.way == Window::SectionShow::Way::Forward);
|
2017-10-03 14:57:11 +00:00
|
|
|
auto needAnimation = (_content != nullptr)
|
2017-10-03 13:05:58 +00:00
|
|
|
&& (params.animated != anim::type::instant);
|
2017-10-03 14:57:11 +00:00
|
|
|
auto animationParams = SectionSlideParams();
|
2017-10-31 18:25:22 +00:00
|
|
|
auto newController = createController(
|
|
|
|
_controller->window(),
|
|
|
|
memento);
|
2017-10-03 17:41:44 +00:00
|
|
|
auto newContent = object_ptr<ContentWidget>(nullptr);
|
2017-10-03 14:57:11 +00:00
|
|
|
if (needAnimation) {
|
2017-10-31 18:25:22 +00:00
|
|
|
newContent = createContent(memento, newController.get());
|
2017-10-03 14:57:11 +00:00
|
|
|
animationParams.withTopBarShadow = hasTopBarShadow()
|
|
|
|
&& newContent->hasTopBarShadow();
|
|
|
|
animationParams.oldContentCache = grabForShowAnimation(
|
|
|
|
animationParams);
|
2017-11-06 08:50:54 +00:00
|
|
|
animationParams.withFade = (wrap() == Wrap::Layer);
|
2017-10-03 13:05:58 +00:00
|
|
|
}
|
|
|
|
if (saveToStack) {
|
|
|
|
auto item = StackItem();
|
|
|
|
item.section = _content->createMemento();
|
2017-11-16 17:19:41 +00:00
|
|
|
//if (_anotherTabMemento) {
|
|
|
|
// item.anotherTab = std::move(_anotherTabMemento);
|
|
|
|
//}
|
2017-10-03 13:05:58 +00:00
|
|
|
_historyStack.push_back(std::move(item));
|
|
|
|
} else if (params.way == Window::SectionShow::Way::ClearStack) {
|
|
|
|
_historyStack.clear();
|
|
|
|
}
|
2017-10-31 18:25:22 +00:00
|
|
|
|
|
|
|
_controller = std::move(newController);
|
2017-10-03 17:41:44 +00:00
|
|
|
if (newContent) {
|
2017-10-31 18:25:22 +00:00
|
|
|
setupTop();
|
2017-10-03 17:41:44 +00:00
|
|
|
showContent(std::move(newContent));
|
|
|
|
} else {
|
|
|
|
showNewContent(memento);
|
|
|
|
}
|
2017-10-03 14:57:11 +00:00
|
|
|
if (animationParams) {
|
|
|
|
showAnimated(
|
|
|
|
saveToStack
|
|
|
|
? SlideDirection::FromRight
|
|
|
|
: SlideDirection::FromLeft,
|
|
|
|
animationParams);
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
void WrapWidget::showNewContent(not_null<ContentMemento*> memento) {
|
2017-09-30 18:26:45 +00:00
|
|
|
// Validates contentGeometry().
|
2017-10-31 18:25:22 +00:00
|
|
|
setupTop();
|
|
|
|
showContent(createContent(memento, _controller.get()));
|
2017-09-30 18:26:45 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//void WrapWidget::setupTabs(Tab tab) {
|
|
|
|
// _tab = tab;
|
|
|
|
// if (_tab == Tab::None) {
|
|
|
|
// _topTabs.destroy();
|
|
|
|
// _topTabsBackground.destroy();
|
|
|
|
// } else if (!_topTabs) {
|
|
|
|
// createTabs();
|
|
|
|
// } else {
|
|
|
|
// _topTabs->setActiveSection(static_cast<int>(tab));
|
|
|
|
// }
|
|
|
|
//}
|
2017-09-30 18:26:45 +00:00
|
|
|
|
|
|
|
void WrapWidget::resizeEvent(QResizeEvent *e) {
|
2017-11-16 09:13:17 +00:00
|
|
|
// This was done for tabs support.
|
|
|
|
//
|
|
|
|
//if (_topTabs) {
|
|
|
|
// _topTabs->resizeToWidth(width());
|
|
|
|
// _topTabsBackground->resize(
|
|
|
|
// width(),
|
|
|
|
// _topTabs->height() - st::lineWidth);
|
|
|
|
//}
|
|
|
|
if (_topBar) {
|
2017-10-03 14:57:11 +00:00
|
|
|
_topBar->resizeToWidth(width());
|
|
|
|
}
|
2017-10-20 16:19:42 +00:00
|
|
|
if (_topBarOverride) {
|
|
|
|
_topBarOverride->resizeToWidth(width());
|
|
|
|
}
|
2017-09-30 18:26:45 +00:00
|
|
|
updateContentGeometry();
|
|
|
|
}
|
|
|
|
|
2017-11-17 14:54:01 +00:00
|
|
|
void WrapWidget::keyPressEvent(QKeyEvent *e) {
|
|
|
|
if (e->key() == Qt::Key_Escape) {
|
2017-11-17 16:20:31 +00:00
|
|
|
if (hasStackHistory() || wrap() != Wrap::Layer) {
|
|
|
|
showBackFromStack();
|
|
|
|
return;
|
|
|
|
}
|
2017-11-17 14:54:01 +00:00
|
|
|
}
|
2017-11-17 16:20:31 +00:00
|
|
|
SectionWidget::keyPressEvent(e);
|
2017-11-17 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
void WrapWidget::updateContentGeometry() {
|
|
|
|
if (_content) {
|
|
|
|
_topShadow->resizeToWidth(width());
|
2017-10-03 14:57:11 +00:00
|
|
|
_topShadow->moveToLeft(0, topWidget()->height());
|
2017-09-30 18:26:45 +00:00
|
|
|
_content->setGeometry(contentGeometry());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WrapWidget::wheelEventFromFloatPlayer(QEvent *e) {
|
|
|
|
return _content->wheelEventFromFloatPlayer(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect WrapWidget::rectForFloatPlayer() const {
|
|
|
|
return _content->rectForFloatPlayer();
|
|
|
|
}
|
|
|
|
|
2017-11-16 15:24:01 +00:00
|
|
|
object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
|
|
|
|
QWidget *parent) {
|
|
|
|
if (hasStackHistory() || wrap() == Wrap::Narrow) {
|
|
|
|
Assert(_topBar != nullptr);
|
|
|
|
|
|
|
|
auto result = object_ptr<Ui::AbstractButton>(parent);
|
|
|
|
result->addClickHandler([wrap = weak(this)]{
|
|
|
|
if (wrap) {
|
|
|
|
wrap->showBackFromStack();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
result->setGeometry(_topBar->geometry());
|
|
|
|
result->show();
|
|
|
|
return std::move(result);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
WrapWidget::~WrapWidget() = default;
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
} // namespace Info
|