2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

fixed copy selected text, post author display added, post links handling added, windows bingmaps opening added, sticker previews from mentionsdropdown and stickersetbox added

This commit is contained in:
John Preston
2016-02-17 19:37:21 +03:00
parent 6a299e32d3
commit 7433cea0fd
34 changed files with 1009 additions and 425 deletions

View File

@@ -3852,8 +3852,12 @@ MentionsInner::MentionsInner(MentionsDropdown *parent, MentionRows *mrows, Hasht
, _stickersPerRow(1)
, _recentInlineBotsInRows(0)
, _sel(-1)
, _down(-1)
, _mouseSel(false)
, _overDelete(false) {
, _overDelete(false)
, _previewShown(false) {
_previewTimer.setSingleShot(true);
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreview()));
}
void MentionsInner::paintEvent(QPaintEvent *e) {
@@ -4030,9 +4034,13 @@ void MentionsInner::mouseMoveEvent(QMouseEvent *e) {
onUpdateSelected(true);
}
void MentionsInner::clearSel() {
void MentionsInner::clearSel(bool hidden) {
_mouseSel = _overDelete = false;
setSel((_mrows->isEmpty() && _brows->isEmpty() && _hrows->isEmpty()) ? -1 : 0);
if (hidden) {
_down = -1;
_previewShown = false;
}
}
bool MentionsInner::moveSel(int key) {
@@ -4140,12 +4148,35 @@ void MentionsInner::mousePressEvent(QMouseEvent *e) {
_mouseSel = true;
onUpdateSelected(true);
} else {
} else if (_srows->isEmpty()) {
select();
} else {
_down = _sel;
_previewTimer.start(QApplication::startDragTime());
}
}
}
void MentionsInner::mouseReleaseEvent(QMouseEvent *e) {
_previewTimer.stop();
int32 pressed = _down;
_down = -1;
_mousePos = mapToGlobal(e->pos());
_mouseSel = true;
onUpdateSelected(true);
if (_previewShown) {
_previewShown = false;
return;
}
if (_sel < 0 || _sel != pressed || _srows->isEmpty()) return;
select();
}
void MentionsInner::enterEvent(QEvent *e) {
setMouseTracking(true);
_mousePos = QCursor::pos();
@@ -4189,6 +4220,8 @@ void MentionsInner::onUpdateSelected(bool force) {
QPoint mouse(mapFromGlobal(_mousePos));
if ((!force && !rect().contains(mouse)) || !_mouseSel) return;
if (_down >= 0 && !_previewShown) return;
int32 sel = -1, maxSel = 0;
if (!_srows->isEmpty()) {
int32 rows = rowscount(_srows->size(), _stickersPerRow);
@@ -4209,6 +4242,12 @@ void MentionsInner::onUpdateSelected(bool force) {
}
if (sel != _sel) {
setSel(sel);
if (_down >= 0 && _sel >= 0 && _down != _sel) {
_down = _sel;
if (_down >= 0 && _down < _srows->size()) {
Ui::showStickerPreview(_srows->at(_down));
}
}
}
}
@@ -4220,6 +4259,13 @@ void MentionsInner::onParentGeometryChanged() {
}
}
void MentionsInner::onPreview() {
if (_down >= 0 && _down < _srows->size()) {
Ui::showStickerPreview(_srows->at(_down));
_previewShown = true;
}
}
MentionsDropdown::MentionsDropdown(QWidget *parent) : TWidget(parent)
, _scroll(this, st::mentionScroll)
, _inner(this, &_mrows, &_hrows, &_brows, &_srows)
@@ -4569,7 +4615,7 @@ void MentionsDropdown::hideFinish() {
hide();
_hiding = false;
_filter = qsl("-");
_inner.clearSel();
_inner.clearSel(true);
}
void MentionsDropdown::showStart() {