2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Featured stickers section done in StickersPanel.

EmojiPan moved to a separate module stickers/emoji_pan.
FFmpeg linked by msvs linker flags in GYP to use ".a" extension.
This commit is contained in:
John Preston
2016-09-09 18:52:46 +03:00
parent 82d92d21f6
commit ff657347b8
19 changed files with 4703 additions and 4252 deletions

View File

@@ -35,8 +35,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "history/history_service_layout.h"
#include "profile/profile_members_widget.h"
#include "core/click_handler_types.h"
#include "stickers/emoji_pan.h"
#include "lang.h"
#include "application.h"
#include "dropdown.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "passcodewidget.h"
@@ -3055,11 +3057,11 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
connect(&_field, SIGNAL(linksChanged()), this, SLOT(onPreviewCheck()));
connect(App::wnd()->windowHandle(), SIGNAL(visibleChanged(bool)), this, SLOT(onWindowVisibleChanged()));
connect(&_scrollTimer, SIGNAL(timeout()), this, SLOT(onScrollTimer()));
connect(&_emojiPan, SIGNAL(emojiSelected(EmojiPtr)), &_field, SLOT(onEmojiInsert(EmojiPtr)));
connect(&_emojiPan, SIGNAL(stickerSelected(DocumentData*)), this, SLOT(onStickerSend(DocumentData*)));
connect(&_emojiPan, SIGNAL(photoSelected(PhotoData*)), this, SLOT(onPhotoSend(PhotoData*)));
connect(&_emojiPan, SIGNAL(inlineResultSelected(InlineBots::Result*,UserData*)), this, SLOT(onInlineResultSend(InlineBots::Result*,UserData*)));
connect(&_emojiPan, SIGNAL(updateStickers()), this, SLOT(updateStickers()));
connect(_emojiPan, SIGNAL(emojiSelected(EmojiPtr)), &_field, SLOT(onEmojiInsert(EmojiPtr)));
connect(_emojiPan, SIGNAL(stickerSelected(DocumentData*)), this, SLOT(onStickerSend(DocumentData*)));
connect(_emojiPan, SIGNAL(photoSelected(PhotoData*)), this, SLOT(onPhotoSend(PhotoData*)));
connect(_emojiPan, SIGNAL(inlineResultSelected(InlineBots::Result*,UserData*)), this, SLOT(onInlineResultSend(InlineBots::Result*,UserData*)));
connect(_emojiPan, SIGNAL(updateStickers()), this, SLOT(updateStickers()));
connect(&_sendActionStopTimer, SIGNAL(timeout()), this, SLOT(onCancelSendAction()));
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreviewTimeout()));
if (audioCapture()) {
@@ -3130,25 +3132,25 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
_silent.hide();
_cmdStart.hide();
_attachDocument.installEventFilter(&_attachType);
_attachPhoto.installEventFilter(&_attachType);
_attachEmoji.installEventFilter(&_emojiPan);
_attachDocument.installEventFilter(_attachType);
_attachPhoto.installEventFilter(_attachType);
_attachEmoji.installEventFilter(_emojiPan);
connect(&_kbShow, SIGNAL(clicked()), this, SLOT(onKbToggle()));
connect(&_kbHide, SIGNAL(clicked()), this, SLOT(onKbToggle()));
connect(&_cmdStart, SIGNAL(clicked()), this, SLOT(onCmdStart()));
connect(_attachType.addButton(new IconedButton(this, st::dropdownAttachDocument, lang(lng_attach_file))), SIGNAL(clicked()), this, SLOT(onDocumentSelect()));
connect(_attachType.addButton(new IconedButton(this, st::dropdownAttachPhoto, lang(lng_attach_photo))), SIGNAL(clicked()), this, SLOT(onPhotoSelect()));
_attachType.hide();
_emojiPan.hide();
_attachDragDocument.hide();
_attachDragPhoto.hide();
connect(_attachType->addButton(new IconedButton(this, st::dropdownAttachDocument, lang(lng_attach_file))), SIGNAL(clicked()), this, SLOT(onDocumentSelect()));
connect(_attachType->addButton(new IconedButton(this, st::dropdownAttachPhoto, lang(lng_attach_photo))), SIGNAL(clicked()), this, SLOT(onPhotoSelect()));
_attachType->hide();
_emojiPan->hide();
_attachDragDocument->hide();
_attachDragPhoto->hide();
_topShadow.hide();
connect(&_attachDragDocument, SIGNAL(dropped(const QMimeData*)), this, SLOT(onDocumentDrop(const QMimeData*)));
connect(&_attachDragPhoto, SIGNAL(dropped(const QMimeData*)), this, SLOT(onPhotoDrop(const QMimeData*)));
connect(_attachDragDocument, SIGNAL(dropped(const QMimeData*)), this, SLOT(onDocumentDrop(const QMimeData*)));
connect(_attachDragPhoto, SIGNAL(dropped(const QMimeData*)), this, SLOT(onPhotoDrop(const QMimeData*)));
connect(&_updateEditTimeLeftDisplay, SIGNAL(timeout()), this, SLOT(updateField()));
@@ -3157,7 +3159,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
void HistoryWidget::start() {
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
connect(App::main(), SIGNAL(savedGifsUpdated()), &_emojiPan, SLOT(refreshSavedGifs()));
connect(App::main(), SIGNAL(savedGifsUpdated()), _emojiPan, SLOT(refreshSavedGifs()));
updateRecentStickers();
if (App::main()) emit App::main()->savedGifsUpdated();
@@ -3166,7 +3168,7 @@ void HistoryWidget::start() {
}
void HistoryWidget::onStickersUpdated() {
_emojiPan.refreshStickers();
_emojiPan->refreshStickers();
updateStickersByEmoji();
}
@@ -3228,9 +3230,9 @@ void HistoryWidget::applyInlineBotQuery(UserData *bot, const QString &query) {
inlineBotChanged();
}
if (_inlineBot->username == cInlineGifBotUsername() && query.isEmpty()) {
_emojiPan.clearInlineBot();
_emojiPan->clearInlineBot();
} else {
_emojiPan.queryInlineBot(_inlineBot, _peer, query);
_emojiPan->queryInlineBot(_inlineBot, _peer, query);
}
if (!_fieldAutocomplete->isHidden()) {
_fieldAutocomplete->hideStart();
@@ -3450,11 +3452,11 @@ void HistoryWidget::updateSendAction(History *history, SendActionType type, int3
}
void HistoryWidget::updateRecentStickers() {
_emojiPan.refreshStickers();
_emojiPan->refreshStickers();
}
void HistoryWidget::stickersInstalled(uint64 setId) {
_emojiPan.stickersInstalled(setId);
_emojiPan->stickersInstalled(setId);
}
void HistoryWidget::sendActionDone(const MTPBool &result, mtpRequestId req) {
@@ -4380,11 +4382,11 @@ void HistoryWidget::updateNotifySettings() {
}
bool HistoryWidget::contentOverlapped(const QRect &globalRect) {
return (_attachDragDocument.overlaps(globalRect) ||
_attachDragPhoto.overlaps(globalRect) ||
_attachType.overlaps(globalRect) ||
return (_attachDragDocument->overlaps(globalRect) ||
_attachDragPhoto->overlaps(globalRect) ||
_attachType->overlaps(globalRect) ||
_fieldAutocomplete->overlaps(globalRect) ||
_emojiPan.overlaps(globalRect));
_emojiPan->overlaps(globalRect));
}
void HistoryWidget::updateReportSpamStatus() {
@@ -4516,8 +4518,8 @@ void HistoryWidget::updateControlsVisibility() {
_kbShow.hide();
_kbHide.hide();
_cmdStart.hide();
_attachType.hide();
_emojiPan.hide();
_attachType->hide();
_emojiPan->hide();
if (_pinnedBar) {
_pinnedBar->cancel.hide();
_pinnedBar->shadow.hide();
@@ -4579,8 +4581,8 @@ void HistoryWidget::updateControlsVisibility() {
_kbShow.hide();
_kbHide.hide();
_cmdStart.hide();
_attachType.hide();
_emojiPan.hide();
_attachType->hide();
_emojiPan->hide();
if (!_field.isHidden()) {
_field.hide();
resizeEvent(0);
@@ -4715,8 +4717,8 @@ void HistoryWidget::updateControlsVisibility() {
_kbShow.hide();
_kbHide.hide();
_cmdStart.hide();
_attachType.hide();
_emojiPan.hide();
_attachType->hide();
_emojiPan->hide();
_kbScroll.hide();
if (!_field.isHidden()) {
_field.hide();
@@ -5257,8 +5259,8 @@ void HistoryWidget::onSend(bool ctrlShiftEnter, MsgId replyTo) {
onDraftSave();
if (!_fieldAutocomplete->isHidden()) _fieldAutocomplete->hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
if (!_attachType->isHidden()) _attachType->hideStart();
if (!_emojiPan->isHidden()) _emojiPan->hideStart();
if (replyTo < 0) cancelReply(lastKeyboardUsed);
if (_previewData && _previewData->pendingTill) previewCancel();
@@ -5586,7 +5588,7 @@ void HistoryWidget::onPhotoSelect() {
_attachDocument.clearState();
_attachDocument.hide();
_attachPhoto.show();
_attachType.fastHide();
_attachType->fastHide();
if (cDefaultAttach() != dbidaPhoto) {
cSetDefaultAttach(dbidaPhoto);
@@ -5614,7 +5616,7 @@ void HistoryWidget::onDocumentSelect() {
_attachPhoto.clearState();
_attachPhoto.hide();
_attachDocument.show();
_attachType.fastHide();
_attachType->fastHide();
if (cDefaultAttach() != dbidaDocument) {
cSetDefaultAttach(dbidaDocument);
@@ -5651,14 +5653,14 @@ void HistoryWidget::dragEnterEvent(QDragEnterEvent *e) {
}
void HistoryWidget::dragLeaveEvent(QDragLeaveEvent *e) {
if (_attachDrag != DragStateNone || !_attachDragPhoto.isHidden() || !_attachDragDocument.isHidden()) {
if (_attachDrag != DragStateNone || !_attachDragPhoto->isHidden() || !_attachDragDocument->isHidden()) {
_attachDrag = DragStateNone;
updateDragAreas();
}
}
void HistoryWidget::leaveEvent(QEvent *e) {
if (_attachDrag != DragStateNone || !_attachDragPhoto.isHidden() || !_attachDragDocument.isHidden()) {
if (_attachDrag != DragStateNone || !_attachDragPhoto->isHidden() || !_attachDragDocument->isHidden()) {
_attachDrag = DragStateNone;
updateDragAreas();
}
@@ -5706,7 +5708,7 @@ void HistoryWidget::mouseReleaseEvent(QMouseEvent *e) {
_replyForwardPressed = false;
update(0, _field.y() - st::sendPadding - st::replyHeight, width(), st::replyHeight);
}
if (_attachDrag != DragStateNone || !_attachDragPhoto.isHidden() || !_attachDragDocument.isHidden()) {
if (_attachDrag != DragStateNone || !_attachDragPhoto->isHidden() || !_attachDragDocument->isHidden()) {
_attachDrag = DragStateNone;
updateDragAreas();
}
@@ -5961,24 +5963,24 @@ void HistoryWidget::updateDragAreas() {
_field.setAcceptDrops(!_attachDrag);
switch (_attachDrag) {
case DragStateNone:
_attachDragDocument.otherLeave();
_attachDragPhoto.otherLeave();
_attachDragDocument->otherLeave();
_attachDragPhoto->otherLeave();
break;
case DragStateFiles:
_attachDragDocument.otherEnter();
_attachDragDocument.setText(lang(lng_drag_files_here), lang(lng_drag_to_send_files));
_attachDragPhoto.fastHide();
_attachDragDocument->otherEnter();
_attachDragDocument->setText(lang(lng_drag_files_here), lang(lng_drag_to_send_files));
_attachDragPhoto->fastHide();
break;
case DragStatePhotoFiles:
_attachDragDocument.otherEnter();
_attachDragDocument.setText(lang(lng_drag_images_here), lang(lng_drag_to_send_no_compression));
_attachDragPhoto.otherEnter();
_attachDragPhoto.setText(lang(lng_drag_photos_here), lang(lng_drag_to_send_quick));
_attachDragDocument->otherEnter();
_attachDragDocument->setText(lang(lng_drag_images_here), lang(lng_drag_to_send_no_compression));
_attachDragPhoto->otherEnter();
_attachDragPhoto->setText(lang(lng_drag_photos_here), lang(lng_drag_to_send_quick));
break;
case DragStateImage:
_attachDragDocument.fastHide();
_attachDragPhoto.otherEnter();
_attachDragPhoto.setText(lang(lng_drag_images_here), lang(lng_drag_to_send_quick));
_attachDragDocument->fastHide();
_attachDragPhoto->otherEnter();
_attachDragPhoto->setText(lang(lng_drag_images_here), lang(lng_drag_to_send_quick));
break;
};
resizeEvent(0);
@@ -6460,8 +6462,8 @@ void HistoryWidget::moveFieldControls() {
right = w;
_fieldBarCancel.move(right - _fieldBarCancel.width(), _field.y() - st::sendPadding - _fieldBarCancel.height());
_attachType.move(0, _attachDocument.y() - _attachType.height());
_emojiPan.moveBottom(_attachEmoji.y());
_attachType->move(0, _attachDocument.y() - _attachType->height());
_emojiPan->moveBottom(_attachEmoji.y());
_botStart.setGeometry(0, bottom - _botStart.height(), w, _botStart.height());
_unblock.setGeometry(0, bottom - _unblock.height(), w, _unblock.height());
@@ -6491,7 +6493,7 @@ void HistoryWidget::clearInlineBot() {
inlineBotChanged();
_field.finishPlaceholder();
}
_emojiPan.clearInlineBot();
_emojiPan->clearInlineBot();
onCheckFieldAutocomplete();
}
@@ -6958,15 +6960,15 @@ void HistoryWidget::onUpdateHistoryItems() {
}
void HistoryWidget::ui_repaintInlineItem(const InlineBots::Layout::ItemBase *layout) {
_emojiPan.ui_repaintInlineItem(layout);
_emojiPan->ui_repaintInlineItem(layout);
}
bool HistoryWidget::ui_isInlineItemVisible(const InlineBots::Layout::ItemBase *layout) {
return _emojiPan.ui_isInlineItemVisible(layout);
return _emojiPan->ui_isInlineItemVisible(layout);
}
bool HistoryWidget::ui_isInlineItemBeingChosen() {
return _emojiPan.ui_isInlineItemBeingChosen();
return _emojiPan->ui_isInlineItemBeingChosen();
}
PeerData *HistoryWidget::ui_getPeerForMouseAction() {
@@ -6980,7 +6982,7 @@ void HistoryWidget::notify_historyItemLayoutChanged(const HistoryItem *item) {
}
void HistoryWidget::notify_inlineItemLayoutChanged(const InlineBots::Layout::ItemBase *layout) {
_emojiPan.notify_inlineItemLayoutChanged(layout);
_emojiPan->notify_inlineItemLayoutChanged(layout);
}
void HistoryWidget::notify_handlePendingHistoryUpdate() {
@@ -7015,25 +7017,25 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
_historyToEnd->moveToRight(st::historyToDownPosition.x(), _scroll.y() + _scroll.height() - _historyToEnd->height() - st::historyToDownPosition.y());
_emojiPan.setMaxHeight(height() - st::dropdownDef.padding.top() - st::dropdownDef.padding.bottom() - _attachEmoji.height());
_emojiPan->setMaxHeight(height() - st::dropdownDef.padding.top() - st::dropdownDef.padding.bottom() - _attachEmoji.height());
if (_membersDropdown) {
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax());
}
switch (_attachDrag) {
case DragStateFiles:
_attachDragDocument.resize(width() - st::dragMargin.left() - st::dragMargin.right(), height() - st::dragMargin.top() - st::dragMargin.bottom());
_attachDragDocument.move(st::dragMargin.left(), st::dragMargin.top());
_attachDragDocument->resize(width() - st::dragMargin.left() - st::dragMargin.right(), height() - st::dragMargin.top() - st::dragMargin.bottom());
_attachDragDocument->move(st::dragMargin.left(), st::dragMargin.top());
break;
case DragStatePhotoFiles:
_attachDragDocument.resize(width() - st::dragMargin.left() - st::dragMargin.right(), (height() - st::dragMargin.top() - st::dragMargin.bottom()) / 2);
_attachDragDocument.move(st::dragMargin.left(), st::dragMargin.top());
_attachDragPhoto.resize(_attachDragDocument.width(), _attachDragDocument.height());
_attachDragPhoto.move(st::dragMargin.left(), height() - _attachDragPhoto.height() - st::dragMargin.bottom());
_attachDragDocument->resize(width() - st::dragMargin.left() - st::dragMargin.right(), (height() - st::dragMargin.top() - st::dragMargin.bottom()) / 2);
_attachDragDocument->move(st::dragMargin.left(), st::dragMargin.top());
_attachDragPhoto->resize(_attachDragDocument->width(), _attachDragDocument->height());
_attachDragPhoto->move(st::dragMargin.left(), height() - _attachDragPhoto->height() - st::dragMargin.bottom());
break;
case DragStateImage:
_attachDragPhoto.resize(width() - st::dragMargin.left() - st::dragMargin.right(), height() - st::dragMargin.top() - st::dragMargin.bottom());
_attachDragPhoto.move(st::dragMargin.left(), st::dragMargin.top());
_attachDragPhoto->resize(width() - st::dragMargin.left() - st::dragMargin.right(), height() - st::dragMargin.top() - st::dragMargin.bottom());
_attachDragPhoto->move(st::dragMargin.left(), st::dragMargin.top());
break;
}
@@ -7530,8 +7532,8 @@ void HistoryWidget::onInlineResultSend(InlineBots::Result *result, UserData *bot
}
if (!_fieldAutocomplete->isHidden()) _fieldAutocomplete->hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
if (!_attachType->isHidden()) _attachType->hideStart();
if (!_emojiPan->isHidden()) _emojiPan->hideStart();
_field.setFocus();
}
@@ -7600,10 +7602,10 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
if (_membersDropdown) {
_membersDropdown->raise();
}
_attachType.raise();
_emojiPan.raise();
_attachDragDocument.raise();
_attachDragPhoto.raise();
_attachType->raise();
_emojiPan->raise();
_attachDragDocument->raise();
_attachDragPhoto->raise();
updatePinnedBar();
result = true;
@@ -7701,8 +7703,8 @@ void HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &capti
}
if (!_fieldAutocomplete->isHidden()) _fieldAutocomplete->hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
if (!_attachType->isHidden()) _attachType->hideStart();
if (!_emojiPan->isHidden()) _emojiPan->hideStart();
_field.setFocus();
}
@@ -7747,8 +7749,8 @@ void HistoryWidget::sendExistingPhoto(PhotoData *photo, const QString &caption)
App::historyRegRandom(randomId, newId);
if (!_fieldAutocomplete->isHidden()) _fieldAutocomplete->hideStart();
if (!_attachType.isHidden()) _attachType.hideStart();
if (!_emojiPan.isHidden()) _emojiPan.hideStart();
if (!_attachType->isHidden()) _attachType->hideStart();
if (!_emojiPan->isHidden()) _emojiPan->hideStart();
_field.setFocus();
}