Dropdown menu for sticker packs
This commit is contained in:
parent
b601f3364c
commit
54b7a656ed
4 changed files with 65 additions and 1 deletions
|
|
@ -2483,4 +2483,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
"ktg_hide_pinned_message" = "Hide";
|
||||
|
||||
"ktg_stickers_copy_title" = "Copy name";
|
||||
"ktg_stickers_title_copied" = "Sticker pack name copied to clipboard.";
|
||||
|
||||
// Keys finished
|
||||
|
|
|
|||
|
|
@ -109,5 +109,7 @@
|
|||
"ktg_settings_top_bar_mute": "Уведомления вверху профиля",
|
||||
"ktg_settings_messages": "Сообщения",
|
||||
"ktg_settings_filters_hide_all": "Скрыть папку «Все чаты»",
|
||||
"ktg_hide_pinned_message": "Скрыть"
|
||||
"ktg_hide_pinned_message": "Скрыть",
|
||||
"ktg_stickers_copy_title": "Копировать название",
|
||||
"ktg_stickers_title_copied": "Название набора стикеров скопировано в буфер обмена."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_layout.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/emoji_config.h"
|
||||
|
|
@ -31,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "app.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
||||
|
|
@ -187,6 +189,15 @@ void StickerSetBox::shareStickers() {
|
|||
Ui::show(Box<InformBox>(tr::lng_stickers_copied(tr::now)));
|
||||
}
|
||||
|
||||
void StickerSetBox::copyTitle() {
|
||||
std::move(
|
||||
_inner->title()
|
||||
) | rpl::start_with_next([this](const TextWithEntities &value) {
|
||||
QGuiApplication::clipboard()->setText(value.text);
|
||||
Ui::show(Box<InformBox>(tr::ktg_stickers_title_copied(tr::now)));
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void StickerSetBox::updateTitleAndButtons() {
|
||||
setTitle(_inner->title());
|
||||
updateButtons();
|
||||
|
|
@ -195,6 +206,9 @@ void StickerSetBox::updateTitleAndButtons() {
|
|||
void StickerSetBox::updateButtons() {
|
||||
clearButtons();
|
||||
if (_inner->loaded()) {
|
||||
const auto moreButton = addTopButton(st::infoTopBarMenu);
|
||||
moreButton->setClickedCallback([=] { showMenu(moreButton.data()); });
|
||||
|
||||
if (_inner->notInstalled()) {
|
||||
addButton(tr::lng_stickers_add_pack(), [=] { addStickers(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
|
@ -210,6 +224,47 @@ void StickerSetBox::updateButtons() {
|
|||
update();
|
||||
}
|
||||
|
||||
bool StickerSetBox::showMenu(not_null<Ui::IconButton*> button) {
|
||||
if (_menu) {
|
||||
_menu->hideAnimated(Ui::InnerDropdown::HideOption::IgnoreShow);
|
||||
return true;
|
||||
}
|
||||
|
||||
_menu = base::make_unique_q<Ui::DropdownMenu>(window());
|
||||
const auto weak = _menu.get();
|
||||
_menu->setHiddenCallback([=] {
|
||||
weak->deleteLater();
|
||||
if (_menu == weak) {
|
||||
button->setForceRippled(false);
|
||||
}
|
||||
});
|
||||
_menu->setShowStartCallback([=] {
|
||||
if (_menu == weak) {
|
||||
button->setForceRippled(true);
|
||||
}
|
||||
});
|
||||
_menu->setHideStartCallback([=] {
|
||||
if (_menu == weak) {
|
||||
button->setForceRippled(false);
|
||||
}
|
||||
});
|
||||
button->installEventFilter(_menu);
|
||||
|
||||
_menu->addAction(tr::ktg_stickers_copy_title(tr::now), [=] { copyTitle(); });
|
||||
_menu->addAction(tr::lng_stickers_share_pack(tr::now), [=] { shareStickers(); });
|
||||
|
||||
const auto parentTopLeft = window()->mapToGlobal({ 0, 0 });
|
||||
const auto buttonTopLeft = button->mapToGlobal({ 0, 0 });
|
||||
const auto parentRect = QRect(parentTopLeft, window()->size());
|
||||
const auto buttonRect = QRect(buttonTopLeft, button->size());
|
||||
_menu->move(
|
||||
buttonRect.x() + buttonRect.width() - _menu->width() - parentRect.x(),
|
||||
buttonRect.y() + buttonRect.height() - parentRect.y() - style::ConvertScale(18));
|
||||
_menu->showAnimated(Ui::PanelAnimation::Origin::TopRight);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StickerSetBox::resizeEvent(QResizeEvent *e) {
|
||||
BoxContent::resizeEvent(e);
|
||||
_inner->resize(width(), _inner->height());
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class SessionController;
|
|||
|
||||
namespace Ui {
|
||||
class PlainShadow;
|
||||
class DropdownMenu;
|
||||
} // namespace Ui
|
||||
|
||||
class StickerSetBox : public Ui::BoxContent, public RPCSender {
|
||||
|
|
@ -40,11 +41,14 @@ protected:
|
|||
private:
|
||||
void updateTitleAndButtons();
|
||||
void updateButtons();
|
||||
bool showMenu(not_null<Ui::IconButton*> button);
|
||||
void addStickers();
|
||||
void shareStickers();
|
||||
void copyTitle();
|
||||
|
||||
not_null<Window::SessionController*> _controller;
|
||||
MTPInputStickerSet _set;
|
||||
base::unique_qptr<Ui::DropdownMenu> _menu;
|
||||
|
||||
class Inner;
|
||||
QPointer<Inner> _inner;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue