mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support sharing speaker/listener link.
This commit is contained in:
parent
6786d44b69
commit
16e1c740ce
3 changed files with 38 additions and 7 deletions
|
@ -168,7 +168,13 @@ ShareBox::ShareBox(QWidget*, Descriptor &&descriptor)
|
||||||
Ui::InputField::Mode::MultiLine,
|
Ui::InputField::Mode::MultiLine,
|
||||||
tr::lng_photos_comment()),
|
tr::lng_photos_comment()),
|
||||||
st::shareCommentPadding)
|
st::shareCommentPadding)
|
||||||
|
, _bottomWidget(std::move(_descriptor.bottomWidget))
|
||||||
, _searchTimer([=] { searchByUsername(); }) {
|
, _searchTimer([=] { searchByUsername(); }) {
|
||||||
|
if (_bottomWidget) {
|
||||||
|
_bottomWidget->setParent(this);
|
||||||
|
_bottomWidget->resizeToWidth(st::boxWideWidth);
|
||||||
|
_bottomWidget->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::prepareCommentField() {
|
void ShareBox::prepareCommentField() {
|
||||||
|
@ -179,9 +185,14 @@ void ShareBox::prepareCommentField() {
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
heightValue(),
|
heightValue(),
|
||||||
_comment->heightValue(),
|
_comment->heightValue(),
|
||||||
_1 - _2
|
(_bottomWidget
|
||||||
) | rpl::start_with_next([=](int top) {
|
? _bottomWidget->heightValue()
|
||||||
_comment->moveToLeft(0, top);
|
: (rpl::single(0) | rpl::type_erased()))
|
||||||
|
) | rpl::start_with_next([=](int height, int comment, int bottom) {
|
||||||
|
_comment->moveToLeft(0, height - bottom - comment);
|
||||||
|
if (_bottomWidget) {
|
||||||
|
_bottomWidget->moveToLeft(0, height - bottom);
|
||||||
|
}
|
||||||
}, _comment->lifetime());
|
}, _comment->lifetime());
|
||||||
|
|
||||||
const auto field = _comment->entity();
|
const auto field = _comment->entity();
|
||||||
|
@ -210,6 +221,9 @@ void ShareBox::prepareCommentField() {
|
||||||
InitSpellchecker(_descriptor.navigation->parentController(), field);
|
InitSpellchecker(_descriptor.navigation->parentController(), field);
|
||||||
}
|
}
|
||||||
Ui::SendPendingMoveResizeEvents(_comment);
|
Ui::SendPendingMoveResizeEvents(_comment);
|
||||||
|
if (_bottomWidget) {
|
||||||
|
Ui::SendPendingMoveResizeEvents(_bottomWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::prepare() {
|
void ShareBox::prepare() {
|
||||||
|
@ -251,7 +265,11 @@ void ShareBox::prepare() {
|
||||||
_inner->selectActive();
|
_inner->selectActive();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_comment->heightValue(
|
rpl::combine(
|
||||||
|
_comment->heightValue(),
|
||||||
|
(_bottomWidget
|
||||||
|
? _bottomWidget->heightValue()
|
||||||
|
: rpl::single(0) | rpl::type_erased())
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateScrollSkips();
|
updateScrollSkips();
|
||||||
}, _comment->lifetime());
|
}, _comment->lifetime());
|
||||||
|
@ -283,7 +301,8 @@ int ShareBox::getTopScrollSkip() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ShareBox::getBottomScrollSkip() const {
|
int ShareBox::getBottomScrollSkip() const {
|
||||||
return _comment->isHidden() ? 0 : _comment->height();
|
return (_comment->isHidden() ? 0 : _comment->height())
|
||||||
|
+ (_bottomWidget ? _bottomWidget->height() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ShareBox::contentHeight() const {
|
int ShareBox::contentHeight() const {
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
Window::SessionNavigation *navigation = nullptr;
|
Window::SessionNavigation *navigation = nullptr;
|
||||||
Fn<void(not_null<Ui::InputField*>)> initSpellchecker;
|
Fn<void(not_null<Ui::InputField*>)> initSpellchecker;
|
||||||
Fn<void(not_null<Ui::InputField*>)> initEditLink;
|
Fn<void(not_null<Ui::InputField*>)> initEditLink;
|
||||||
|
object_ptr<Ui::RpWidget> bottomWidget = { nullptr };
|
||||||
};
|
};
|
||||||
ShareBox(QWidget*, Descriptor &&descriptor);
|
ShareBox(QWidget*, Descriptor &&descriptor);
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ private:
|
||||||
|
|
||||||
object_ptr<Ui::MultiSelect> _select;
|
object_ptr<Ui::MultiSelect> _select;
|
||||||
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
|
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
|
||||||
|
object_ptr<Ui::RpWidget> _bottomWidget;
|
||||||
|
|
||||||
class Inner;
|
class Inner;
|
||||||
QPointer<Inner> _inner;
|
QPointer<Inner> _inner;
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/level_meter.h"
|
#include "ui/widgets/level_meter.h"
|
||||||
#include "ui/widgets/continuous_sliders.h"
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
@ -99,8 +100,16 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||||
const auto sending = std::make_shared<bool>();
|
const auto sending = std::make_shared<bool>();
|
||||||
const auto box = std::make_shared<QPointer<ShareBox>>();
|
const auto box = std::make_shared<QPointer<ShareBox>>();
|
||||||
|
|
||||||
|
auto bottom = object_ptr<Ui::PaddingWrap<Ui::Checkbox>>(
|
||||||
|
nullptr,
|
||||||
|
object_ptr<Ui::Checkbox>(
|
||||||
|
nullptr,
|
||||||
|
tr::lng_group_call_share_listener(tr::now),
|
||||||
|
true),
|
||||||
|
style::margins(16, 16, 16, 16));// #TODO calls style
|
||||||
|
const auto listenerCheckbox = bottom->entity();
|
||||||
const auto currentLink = [=] {
|
const auto currentLink = [=] {
|
||||||
return linkListener;
|
return listenerCheckbox->checked() ? linkListener : linkSpeaker;
|
||||||
};
|
};
|
||||||
auto copyCallback = [=] {
|
auto copyCallback = [=] {
|
||||||
QGuiApplication::clipboard()->setText(currentLink());
|
QGuiApplication::clipboard()->setText(currentLink());
|
||||||
|
@ -176,7 +185,8 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||||
.session = &peer->session(),
|
.session = &peer->session(),
|
||||||
.copyCallback = std::move(copyCallback),
|
.copyCallback = std::move(copyCallback),
|
||||||
.submitCallback = std::move(submitCallback),
|
.submitCallback = std::move(submitCallback),
|
||||||
.filterCallback = std::move(filterCallback) });
|
.filterCallback = std::move(filterCallback),
|
||||||
|
.bottomWidget = std::move(bottom) });
|
||||||
*box = result.data();
|
*box = result.data();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue