mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Show other shared media links in Saved Photos.
This commit is contained in:
parent
aebdc2fd94
commit
e4ce08e64e
4 changed files with 122 additions and 111 deletions
|
@ -49,109 +49,106 @@ InnerWidget::InnerWidget(
|
|||
[this] { refreshHeight(); },
|
||||
_empty->lifetime());
|
||||
_list = setupList();
|
||||
// Allows showing additional shared media links and tabs.
|
||||
// Was done for top level tabs support.
|
||||
//
|
||||
//setupOtherTypes();
|
||||
}
|
||||
|
||||
// Allows showing additional shared media links and tabs.
|
||||
// Was done for top level tabs support.
|
||||
//
|
||||
//void InnerWidget::setupOtherTypes() {
|
||||
// _controller->wrapValue()
|
||||
// | rpl::start_with_next([this](Wrap value) {
|
||||
// if (value == Wrap::Side
|
||||
// && !_controller->hasStackHistory()
|
||||
// && TypeToTabIndex(type())) {
|
||||
// createOtherTypes();
|
||||
// } else {
|
||||
// _otherTabs = nullptr;
|
||||
// _otherTypes.destroy();
|
||||
// refreshHeight();
|
||||
// }
|
||||
// }, lifetime());
|
||||
// rpl::combine(
|
||||
// _controller->wrapValue(),
|
||||
// _controller->searchEnabledByContent())
|
||||
// | rpl::start_with_next([this](Wrap wrap, bool enabled) {
|
||||
// _searchEnabled = enabled;
|
||||
// refreshSearchField();
|
||||
// }, lifetime());
|
||||
//}
|
||||
//
|
||||
//void InnerWidget::createOtherTypes() {
|
||||
// _otherTabsShadow.create(this);
|
||||
// _otherTabsShadow->show();
|
||||
//
|
||||
// _otherTabs = nullptr;
|
||||
// _otherTypes.create(this);
|
||||
// _otherTypes->show();
|
||||
//
|
||||
// createTypeButtons();
|
||||
// _otherTypes->add(object_ptr<BoxContentDivider>(_otherTypes));
|
||||
// createTabs();
|
||||
//
|
||||
// _otherTypes->heightValue()
|
||||
// | rpl::start_with_next(
|
||||
// [this] { refreshHeight(); },
|
||||
// _otherTypes->lifetime());
|
||||
//}
|
||||
//
|
||||
//void InnerWidget::createTypeButtons() {
|
||||
// auto wrap = _otherTypes->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
// _otherTypes,
|
||||
// object_ptr<Ui::VerticalLayout>(_otherTypes)));
|
||||
// auto content = wrap->entity();
|
||||
// content->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
// content,
|
||||
// st::infoProfileSkip));
|
||||
//
|
||||
// auto tracker = Ui::MultiSlideTracker();
|
||||
// auto addMediaButton = [&](
|
||||
// Type type,
|
||||
// const style::icon &icon) {
|
||||
// auto result = AddButton(
|
||||
// content,
|
||||
// _controller,
|
||||
// _controller->peer(),
|
||||
// _controller->migrated(),
|
||||
// type,
|
||||
// tracker);
|
||||
// object_ptr<Profile::FloatingIcon>(
|
||||
// result,
|
||||
// icon,
|
||||
// st::infoSharedMediaButtonIconPosition);
|
||||
// };
|
||||
// auto addCommonGroupsButton = [&](
|
||||
// not_null<UserData*> user,
|
||||
// const style::icon &icon) {
|
||||
// auto result = AddCommonGroupsButton(
|
||||
// content,
|
||||
// _controller,
|
||||
// user,
|
||||
// tracker);
|
||||
// object_ptr<Profile::FloatingIcon>(
|
||||
// result,
|
||||
// icon,
|
||||
// st::infoSharedMediaButtonIconPosition);
|
||||
// };
|
||||
//
|
||||
// addMediaButton(Type::MusicFile, st::infoIconMediaAudio);
|
||||
// addMediaButton(Type::Link, st::infoIconMediaLink);
|
||||
// if (auto user = _controller->peer()->asUser()) {
|
||||
// Now used for shared media in Saved Messages.
|
||||
void InnerWidget::setupOtherTypes() {
|
||||
if (_controller->peer()->isSelf() && _isStackBottom) {
|
||||
createOtherTypes();
|
||||
} else {
|
||||
_otherTypes.destroy();
|
||||
refreshHeight();
|
||||
}
|
||||
//rpl::combine(
|
||||
// _controller->wrapValue(),
|
||||
// _controller->searchEnabledByContent())
|
||||
// | rpl::start_with_next([this](Wrap wrap, bool enabled) {
|
||||
// _searchEnabled = enabled;
|
||||
// refreshSearchField();
|
||||
// }, lifetime());
|
||||
}
|
||||
|
||||
void InnerWidget::createOtherTypes() {
|
||||
//_otherTabsShadow.create(this);
|
||||
//_otherTabsShadow->show();
|
||||
|
||||
//_otherTabs = nullptr;
|
||||
_otherTypes.create(this);
|
||||
_otherTypes->show();
|
||||
|
||||
createTypeButtons();
|
||||
_otherTypes->add(object_ptr<BoxContentDivider>(_otherTypes));
|
||||
//createTabs();
|
||||
|
||||
_otherTypes->resizeToWidth(width());
|
||||
_otherTypes->heightValue()
|
||||
| rpl::start_with_next(
|
||||
[this] { refreshHeight(); },
|
||||
_otherTypes->lifetime());
|
||||
}
|
||||
|
||||
void InnerWidget::createTypeButtons() {
|
||||
auto wrap = _otherTypes->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
_otherTypes,
|
||||
object_ptr<Ui::VerticalLayout>(_otherTypes)));
|
||||
auto content = wrap->entity();
|
||||
content->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
content,
|
||||
st::infoProfileSkip));
|
||||
|
||||
auto tracker = Ui::MultiSlideTracker();
|
||||
auto addMediaButton = [&](
|
||||
Type buttonType,
|
||||
const style::icon &icon) {
|
||||
if (buttonType == type()) {
|
||||
return;
|
||||
}
|
||||
auto result = AddButton(
|
||||
content,
|
||||
_controller,
|
||||
_controller->peer(),
|
||||
_controller->migrated(),
|
||||
buttonType,
|
||||
tracker);
|
||||
object_ptr<Profile::FloatingIcon>(
|
||||
result,
|
||||
icon,
|
||||
st::infoSharedMediaButtonIconPosition)->show();
|
||||
};
|
||||
//auto addCommonGroupsButton = [&](
|
||||
// not_null<UserData*> user,
|
||||
// const style::icon &icon) {
|
||||
// auto result = AddCommonGroupsButton(
|
||||
// content,
|
||||
// _controller,
|
||||
// user,
|
||||
// tracker);
|
||||
// object_ptr<Profile::FloatingIcon>(
|
||||
// result,
|
||||
// icon,
|
||||
// st::infoSharedMediaButtonIconPosition)->show();
|
||||
//};
|
||||
|
||||
addMediaButton(Type::Photo, st::infoIconMediaPhoto);
|
||||
addMediaButton(Type::Video, st::infoIconMediaVideo);
|
||||
addMediaButton(Type::File, st::infoIconMediaFile);
|
||||
addMediaButton(Type::MusicFile, st::infoIconMediaAudio);
|
||||
addMediaButton(Type::Link, st::infoIconMediaLink);
|
||||
if (auto user = _controller->peer()->asUser()) {
|
||||
// addCommonGroupsButton(user, st::infoIconMediaGroup);
|
||||
// }
|
||||
// addMediaButton(Type::VoiceFile, st::infoIconMediaVoice);
|
||||
//// addMediaButton(Type::RoundFile, st::infoIconMediaRound);
|
||||
//
|
||||
// content->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
// content,
|
||||
// st::infoProfileSkip));
|
||||
// wrap->toggleOn(tracker.atLeastOneShownValue());
|
||||
// wrap->finishAnimating();
|
||||
//}
|
||||
//
|
||||
}
|
||||
addMediaButton(Type::VoiceFile, st::infoIconMediaVoice);
|
||||
// addMediaButton(Type::RoundFile, st::infoIconMediaRound);
|
||||
|
||||
content->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
content,
|
||||
st::infoProfileSkip));
|
||||
wrap->toggleOn(tracker.atLeastOneShownValue());
|
||||
wrap->finishAnimating();
|
||||
}
|
||||
|
||||
//void InnerWidget::createTabs() {
|
||||
// _otherTabs = _otherTypes->add(object_ptr<Ui::SettingsSlider>(
|
||||
// this,
|
||||
|
@ -305,10 +302,10 @@ int InnerWidget::resizeGetHeight(int newWidth) {
|
|||
_inResize = true;
|
||||
auto guard = gsl::finally([this] { _inResize = false; });
|
||||
|
||||
//if (_otherTypes) {
|
||||
// _otherTypes->resizeToWidth(newWidth);
|
||||
// _otherTabsShadow->resizeToWidth(newWidth);
|
||||
//}
|
||||
if (_otherTypes) {
|
||||
_otherTypes->resizeToWidth(newWidth);
|
||||
//_otherTabsShadow->resizeToWidth(newWidth);
|
||||
}
|
||||
//if (_searchField) {
|
||||
// _searchField->resizeToWidth(newWidth);
|
||||
//}
|
||||
|
@ -326,11 +323,11 @@ void InnerWidget::refreshHeight() {
|
|||
|
||||
int InnerWidget::recountHeight() {
|
||||
auto top = 0;
|
||||
//if (_otherTypes) {
|
||||
// _otherTypes->moveToLeft(0, top);
|
||||
// top += _otherTypes->heightNoMargins() - st::lineWidth;
|
||||
// _otherTabsShadow->moveToLeft(0, top);
|
||||
//}
|
||||
if (_otherTypes) {
|
||||
_otherTypes->moveToLeft(0, top);
|
||||
top += _otherTypes->heightNoMargins() - st::lineWidth;
|
||||
// _otherTabsShadow->moveToLeft(0, top);
|
||||
}
|
||||
//if (_searchField) {
|
||||
// _searchField->moveToLeft(0, top);
|
||||
// top += _searchField->heightNoMargins() - st::lineWidth;
|
||||
|
|
|
@ -49,6 +49,10 @@ public:
|
|||
not_null<Controller*> controller);
|
||||
|
||||
bool showInternal(not_null<Memento*> memento);
|
||||
void setIsStackBottom(bool isStackBottom) {
|
||||
_isStackBottom = isStackBottom;
|
||||
setupOtherTypes();
|
||||
}
|
||||
|
||||
void saveState(not_null<Memento*> memento);
|
||||
void restoreState(not_null<Memento*> memento);
|
||||
|
@ -72,10 +76,13 @@ private:
|
|||
void refreshHeight();
|
||||
// Allows showing additional shared media links and tabs.
|
||||
// Was done for top level tabs support.
|
||||
// Now used for shared media in Saved Messages.
|
||||
void setupOtherTypes();
|
||||
void createOtherTypes();
|
||||
void createTypeButtons();
|
||||
// Allows showing additional shared media links and tabs.
|
||||
// Was done for top level tabs support.
|
||||
//
|
||||
//void setupOtherTypes();
|
||||
//void createOtherTypes();
|
||||
//void createTypeButtons();
|
||||
//void createTabs();
|
||||
//void switchToTab(Memento &&memento);
|
||||
//void refreshSearchField();
|
||||
|
@ -88,7 +95,7 @@ private:
|
|||
const not_null<Controller*> _controller;
|
||||
|
||||
//Ui::SettingsSlider *_otherTabs = nullptr;
|
||||
//object_ptr<Ui::VerticalLayout> _otherTypes = { nullptr };
|
||||
object_ptr<Ui::VerticalLayout> _otherTypes = { nullptr };
|
||||
//object_ptr<Ui::PlainShadow> _otherTabsShadow = { nullptr };
|
||||
//base::unique_qptr<Ui::RpWidget> _searchField = nullptr;
|
||||
object_ptr<ListWidget> _list = { nullptr };
|
||||
|
@ -96,6 +103,7 @@ private:
|
|||
//bool _searchEnabled = false;
|
||||
|
||||
bool _inResize = false;
|
||||
bool _isStackBottom = false;
|
||||
|
||||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
|
||||
|
|
|
@ -102,6 +102,10 @@ void Widget::cancelSelection() {
|
|||
_inner->cancelSelection();
|
||||
}
|
||||
|
||||
void Widget::setIsStackBottom(bool isStackBottom) {
|
||||
_inner->setIsStackBottom(isStackBottom);
|
||||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
if (!controller()->validateMementoPeer(memento)) {
|
||||
return false;
|
||||
|
|
|
@ -100,6 +100,8 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<Controller*> controller);
|
||||
|
||||
void setIsStackBottom(bool isStackBottom) override;
|
||||
|
||||
bool showInternal(
|
||||
not_null<ContentMemento*> memento) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue