mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
preparing version 0.8.37.dev
This commit is contained in:
@@ -40,13 +40,16 @@ OverviewInner::OverviewInner(OverviewWidget *overview, ScrollArea *scroll, const
|
||||
, _photosInRow(1)
|
||||
, _photosToAdd(0)
|
||||
, _selMode(false)
|
||||
, _audioLeft(st::msgMargin.left())
|
||||
, _audioWidth(st::msgMinWidth)
|
||||
, _audioHeight(st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom())
|
||||
, _width(st::wndMinWidth)
|
||||
, _height(0)
|
||||
, _minHeight(0)
|
||||
, _addToY(0)
|
||||
, _cursor(style::cur_default)
|
||||
, _dragAction(NoDrag)
|
||||
, _dragItem(0)
|
||||
, _dragItem(0), _selectedMsgId(0)
|
||||
, _dragItemIndex(-1)
|
||||
, _mousedItem(0)
|
||||
, _mousedItemIndex(-1)
|
||||
@@ -77,6 +80,10 @@ OverviewInner::OverviewInner(OverviewWidget *overview, ScrollArea *scroll, const
|
||||
|
||||
mediaOverviewUpdated();
|
||||
setMouseTracking(true);
|
||||
|
||||
if (_type == OverviewAudioDocuments) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool OverviewInner::event(QEvent *e) {
|
||||
@@ -133,7 +140,7 @@ void OverviewInner::touchUpdateSpeed() {
|
||||
void OverviewInner::fixItemIndex(int32 ¤t, MsgId msgId) const {
|
||||
if (!msgId) {
|
||||
current = -1;
|
||||
} else if (_type == OverviewPhotos) {
|
||||
} else if (_type == OverviewPhotos || _type == OverviewAudioDocuments) {
|
||||
int32 l = _hist->_overview[_type].size();
|
||||
if (current < 0 || current >= l || _hist->_overview[_type][current] != msgId) {
|
||||
current = -1;
|
||||
@@ -166,6 +173,10 @@ bool OverviewInner::itemHasPoint(MsgId msgId, int32 index, int32 x, int32 y) con
|
||||
if (x >= 0 && x < _vsize && y >= 0 && y < _vsize) {
|
||||
return true;
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
if (x >= _audioLeft && x < _audioLeft + _audioWidth && y >= 0 && y < _audioHeight) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
HistoryItem *item = App::histItemById(msgId);
|
||||
HistoryMedia *media = item ? item->getMedia(true) : 0;
|
||||
@@ -185,6 +196,8 @@ bool OverviewInner::itemHasPoint(MsgId msgId, int32 index, int32 x, int32 y) con
|
||||
int32 OverviewInner::itemHeight(MsgId msgId, int32 index) const {
|
||||
if (_type == OverviewPhotos) {
|
||||
return _vsize;
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
return _audioHeight;
|
||||
}
|
||||
|
||||
fixItemIndex(index, msgId);
|
||||
@@ -200,7 +213,7 @@ void OverviewInner::moveToNextItem(MsgId &msgId, int32 &index, MsgId upTo, int32
|
||||
}
|
||||
|
||||
index += delta;
|
||||
if (_type == OverviewPhotos) {
|
||||
if (_type == OverviewPhotos || _type == OverviewAudioDocuments) {
|
||||
if (index < 0 || index >= _hist->_overview[_type].size()) {
|
||||
msgId = 0;
|
||||
index = -1;
|
||||
@@ -234,6 +247,8 @@ void OverviewInner::updateMsg(MsgId itemId, int32 itemIndex) {
|
||||
int32 vsize = (_vsize + st::overviewPhotoSkip);
|
||||
int32 row = (_photosToAdd + itemIndex) / _photosInRow, col = (_photosToAdd + itemIndex) % _photosInRow;
|
||||
update(int32(col * w), _addToY + int32(row * vsize), qCeil(w), vsize);
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
update(_audioLeft, _addToY + int32(itemIndex * _audioHeight), _audioWidth, _audioHeight);
|
||||
} else {
|
||||
HistoryItem *item = App::histItemById(itemId);
|
||||
HistoryMedia *media = item ? item->getMedia(true) : 0;
|
||||
@@ -570,7 +585,7 @@ void OverviewInner::applyDragSelection() {
|
||||
}
|
||||
if (_dragSelecting) {
|
||||
for (int32 i = _dragSelToIndex; i <= _dragSelFromIndex; ++i) {
|
||||
MsgId msgid = (_type == OverviewPhotos) ? _hist->_overview[_type][i] : _items[i].msgid;
|
||||
MsgId msgid = (_type == OverviewPhotos || _type == OverviewAudioDocuments) ? _hist->_overview[_type][i] : _items[i].msgid;
|
||||
if (!msgid) continue;
|
||||
|
||||
SelectedItems::iterator j = _selected.find(msgid);
|
||||
@@ -589,7 +604,7 @@ void OverviewInner::applyDragSelection() {
|
||||
}
|
||||
} else {
|
||||
for (int32 i = _dragSelToIndex; i <= _dragSelFromIndex; ++i) {
|
||||
MsgId msgid = (_type == OverviewPhotos) ? _hist->_overview[_type][i] : _items[i].msgid;
|
||||
MsgId msgid = (_type == OverviewPhotos || _type == OverviewAudioDocuments) ? _hist->_overview[_type][i] : _items[i].msgid;
|
||||
if (!msgid) continue;
|
||||
|
||||
SelectedItems::iterator j = _selected.find(msgid);
|
||||
@@ -612,6 +627,8 @@ QPoint OverviewInner::mapMouseToItem(QPoint p, MsgId itemId, int32 itemIndex) {
|
||||
float64 w = (_width - st::overviewPhotoSkip) / float64(_photosInRow);
|
||||
p.setX(p.x() - int32(col * w) - st::overviewPhotoSkip);
|
||||
p.setY(p.y() - _addToY - row * (_vsize + st::overviewPhotoSkip) - st::overviewPhotoSkip);
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
p.setY(p.y() - _addToY - itemIndex * _audioHeight);
|
||||
} else {
|
||||
p.setY(p.y() - _addToY - (_height - _items[itemIndex].y));
|
||||
}
|
||||
@@ -622,6 +639,16 @@ void OverviewInner::clear() {
|
||||
_cached.clear();
|
||||
}
|
||||
|
||||
int32 OverviewInner::itemTop(MsgId msgId) const {
|
||||
if (_type == OverviewAudioDocuments) {
|
||||
int32 index = _hist->_overview[_type].indexOf(msgId);
|
||||
if (index >= 0) {
|
||||
return _addToY + int32(index * _audioHeight);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
QPixmap OverviewInner::genPix(PhotoData *photo, int32 size) {
|
||||
size *= cIntRetinaFactor();
|
||||
QImage img = (photo->full->loaded() ? photo->full : (photo->medium->loaded() ? photo->medium : photo->thumb))->pix().toImage();
|
||||
@@ -747,6 +774,32 @@ void OverviewInner::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
int32 from = int32(r.top() - _addToY) / int32(_audioHeight);
|
||||
int32 to = int32(r.bottom() - _addToY) / int32(_audioHeight) + 1;
|
||||
History::MediaOverview &overview(_hist->_overview[_type]);
|
||||
int32 count = overview.size();
|
||||
p.translate(_audioLeft, _addToY + from * _audioHeight);
|
||||
for (int32 index = from; index < to; ++index) {
|
||||
if (index >= count) break;
|
||||
|
||||
HistoryItem *item = App::histItemById(overview[index]);
|
||||
HistoryMedia *m = item ? item->getMedia(true) : 0;
|
||||
if (!m || m->type() != MediaTypeDocument) continue;
|
||||
|
||||
uint32 sel = 0;
|
||||
if (index >= selfrom && index <= selto) {
|
||||
sel = (_dragSelecting && item->id > 0) ? FullItemSel : 0;
|
||||
} else if (hasSel) {
|
||||
SelectedItems::const_iterator i = _selected.constFind(item->id);
|
||||
if (i != selEnd) {
|
||||
sel = i.value();
|
||||
}
|
||||
}
|
||||
|
||||
static_cast<HistoryDocument*>(m)->drawInPlaylist(p, item, (sel == FullItemSel), ((_menu ? (App::contextItem() ? App::contextItem()->id : 0) : _selectedMsgId) == item->id), _audioWidth);
|
||||
p.translate(0, _audioHeight);
|
||||
}
|
||||
} else {
|
||||
p.translate(0, st::msgMargin.top() + _addToY);
|
||||
int32 y = 0, w = _width - st::msgMargin.left() - st::msgMargin.right();
|
||||
@@ -825,6 +878,7 @@ void OverviewInner::onUpdateSelected() {
|
||||
TextLinkPtr lnk;
|
||||
HistoryItem *item = 0;
|
||||
int32 index = -1;
|
||||
_selectedMsgId = 0;
|
||||
if (_type == OverviewPhotos) {
|
||||
float64 w = (float64(_width - st::overviewPhotoSkip) / _photosInRow);
|
||||
int32 inRow = int32((m.x() - (st::overviewPhotoSkip / 2)) / w), vsize = (_vsize + st::overviewPhotoSkip);
|
||||
@@ -860,6 +914,36 @@ void OverviewInner::onUpdateSelected() {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
int32 i = int32((m.y() - _addToY) / _audioHeight), count = _hist->_overview[_type].size();
|
||||
if (!count) return;
|
||||
|
||||
bool upon = true;
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
_selectedMsgId = -1;
|
||||
upon = false;
|
||||
}
|
||||
if (i >= count) {
|
||||
i = count - 1;
|
||||
_selectedMsgId = -1;
|
||||
upon = false;
|
||||
}
|
||||
MsgId msgid = _hist->_overview[_type][i];
|
||||
HistoryItem *histItem = App::histItemById(msgid);
|
||||
if (histItem) {
|
||||
item = histItem;
|
||||
index = i;
|
||||
if (upon && m.x() >= _audioLeft && m.x() < _audioLeft + _audioWidth) {
|
||||
HistoryMedia *media = item->getMedia(true);
|
||||
if (media && media->type() == MediaTypeDocument) {
|
||||
lnk = static_cast<HistoryDocument*>(media)->linkInPlaylist();
|
||||
if (_selectedMsgId >= 0) _selectedMsgId = item->id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int32 w = _width - st::msgMargin.left() - st::msgMargin.right();
|
||||
if (_items.isEmpty()) return;
|
||||
@@ -954,7 +1038,7 @@ void OverviewInner::onUpdateSelected() {
|
||||
_selected[_dragItem] = 0;
|
||||
updateDragSelection(0, -1, 0, -1, false);
|
||||
} else {
|
||||
bool selectingDown = (_type == OverviewPhotos ? (_mousedItemIndex > _dragItemIndex) : (_mousedItemIndex < _dragItemIndex)) || (_mousedItemIndex == _dragItemIndex && (_type == OverviewPhotos ? (_dragStartPos.x() < m.x()) : (_dragStartPos.y() < m.y())));
|
||||
bool selectingDown = ((_type == OverviewPhotos || _type == OverviewAudioDocuments) ? (_mousedItemIndex > _dragItemIndex) : (_mousedItemIndex < _dragItemIndex)) || (_mousedItemIndex == _dragItemIndex && (_type == OverviewPhotos ? (_dragStartPos.x() < m.x()) : (_dragStartPos.y() < m.y())));
|
||||
MsgId dragSelFrom = _dragItem, dragSelTo = _mousedItem;
|
||||
int32 dragSelFromIndex = _dragItemIndex, dragSelToIndex = _mousedItemIndex;
|
||||
if (!itemHasPoint(dragSelFrom, dragSelFromIndex, _dragStartPos.x(), _dragStartPos.y())) { // maybe exclude dragSelFrom
|
||||
@@ -963,6 +1047,10 @@ void OverviewInner::onUpdateSelected() {
|
||||
if (_dragStartPos.x() >= _vsize || ((_mousedItem == dragSelFrom) && (m.x() < _dragStartPos.x() + QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, 1);
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
if (_dragStartPos.y() >= itemHeight(dragSelFrom, dragSelFromIndex) || ((_mousedItem == dragSelFrom) && (m.y() < _dragStartPos.y() + QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, 1);
|
||||
}
|
||||
} else {
|
||||
if (_dragStartPos.y() >= (itemHeight(dragSelFrom, dragSelFromIndex) - st::msgMargin.bottom()) || ((_mousedItem == dragSelFrom) && (m.y() < _dragStartPos.y() + QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, -1);
|
||||
@@ -973,6 +1061,10 @@ void OverviewInner::onUpdateSelected() {
|
||||
if (_dragStartPos.x() < 0 || ((_mousedItem == dragSelFrom) && (m.x() >= _dragStartPos.x() - QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, -1);
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
if (_dragStartPos.y() < 0 || ((_mousedItem == dragSelFrom) && (m.y() >= _dragStartPos.y() - QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, -1);
|
||||
}
|
||||
} else {
|
||||
if (_dragStartPos.y() < st::msgMargin.top() || ((_mousedItem == dragSelFrom) && (m.y() >= _dragStartPos.y() - QApplication::startDragDistance()))) {
|
||||
moveToNextItem(dragSelFrom, dragSelFromIndex, dragSelTo, 1);
|
||||
@@ -986,6 +1078,10 @@ void OverviewInner::onUpdateSelected() {
|
||||
if (m.x() < 0) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, -1);
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
if (m.y() < 0) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, 1);
|
||||
}
|
||||
} else {
|
||||
if (m.y() < st::msgMargin.top()) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, 1);
|
||||
@@ -996,6 +1092,10 @@ void OverviewInner::onUpdateSelected() {
|
||||
if (m.x() >= _vsize) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, 1);
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
if (m.y() >= itemHeight(dragSelTo, dragSelToIndex)) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, 1);
|
||||
}
|
||||
} else {
|
||||
if (m.y() >= itemHeight(dragSelTo, dragSelToIndex) - st::msgMargin.bottom()) {
|
||||
moveToNextItem(dragSelTo, dragSelToIndex, dragSelFrom, -1);
|
||||
@@ -1007,7 +1107,7 @@ void OverviewInner::onUpdateSelected() {
|
||||
MsgId dragFirstAffected = dragSelFrom;
|
||||
int32 dragFirstAffectedIndex = dragSelFromIndex;
|
||||
while (dragFirstAffectedIndex >= 0 && dragFirstAffected <= 0) {
|
||||
moveToNextItem(dragFirstAffected, dragFirstAffectedIndex, dragSelTo, ((selectingDown && (_type == OverviewPhotos)) || (!selectingDown && (_type != OverviewPhotos))) ? -1 : 1);
|
||||
moveToNextItem(dragFirstAffected, dragFirstAffectedIndex, dragSelTo, ((selectingDown && (_type == OverviewPhotos || _type == OverviewAudioDocuments)) || (!selectingDown && (_type != OverviewPhotos && _type != OverviewAudioDocuments))) ? -1 : 1);
|
||||
}
|
||||
if (dragFirstAffectedIndex >= 0) {
|
||||
SelectedItems::const_iterator i = _selected.constFind(dragFirstAffected);
|
||||
@@ -1083,6 +1183,10 @@ void OverviewInner::enterEvent(QEvent *e) {
|
||||
}
|
||||
|
||||
void OverviewInner::leaveEvent(QEvent *e) {
|
||||
if (_selectedMsgId > 0) {
|
||||
_selectedMsgId = 0;
|
||||
updateMsg(App::histItemById(_selectedMsgId));
|
||||
}
|
||||
if (textlnkOver()) {
|
||||
updateMsg(App::hoveredLinkItem());
|
||||
textlnkOver(TextLinkPtr());
|
||||
@@ -1097,6 +1201,8 @@ void OverviewInner::leaveEvent(QEvent *e) {
|
||||
|
||||
void OverviewInner::resizeEvent(QResizeEvent *e) {
|
||||
_width = width();
|
||||
_audioWidth = qMin(_width - st::profilePadding.left() - st::profilePadding.right(), int(st::profileMaxWidth));
|
||||
_audioLeft = (_width - _audioWidth) / 2;
|
||||
showAll(true);
|
||||
onUpdateSelected();
|
||||
update();
|
||||
@@ -1106,6 +1212,8 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
if (_menu) {
|
||||
_menu->deleteLater();
|
||||
_menu = 0;
|
||||
updateMsg(App::contextItem());
|
||||
if (_selectedMsgId > 0) updateMsg(App::histItemById(_selectedMsgId));
|
||||
}
|
||||
if (e->reason() == QContextMenuEvent::Mouse) {
|
||||
dragActionUpdate(e->globalPos());
|
||||
@@ -1165,6 +1273,8 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
_menu->addAction(lang(lng_context_select_msg), this, SLOT(selectMessage()))->setEnabled(true);
|
||||
}
|
||||
App::contextItem(App::hoveredLinkItem());
|
||||
updateMsg(App::contextItem());
|
||||
if (_selectedMsgId > 0) updateMsg(App::histItemById(_selectedMsgId));
|
||||
} else if (App::mousedItem() && App::mousedItem()->id == _mousedItem) {
|
||||
_menu = new ContextMenu(_overview);
|
||||
_menu->addAction(lang(lng_context_to_msg), this, SLOT(goToMessage()))->setEnabled(true);
|
||||
@@ -1182,6 +1292,8 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
_menu->addAction(lang(lng_context_select_msg), this, SLOT(selectMessage()))->setEnabled(true);
|
||||
}
|
||||
App::contextItem(App::mousedItem());
|
||||
updateMsg(App::contextItem());
|
||||
if (_selectedMsgId > 0) updateMsg(App::histItemById(_selectedMsgId));
|
||||
}
|
||||
if (_menu) {
|
||||
_menu->deleteOnHide();
|
||||
@@ -1194,7 +1306,7 @@ void OverviewInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||
int32 OverviewInner::resizeToWidth(int32 nwidth, int32 scrollTop, int32 minHeight) {
|
||||
if (width() == nwidth && minHeight == _minHeight) return scrollTop;
|
||||
_minHeight = minHeight;
|
||||
_addToY = (_height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
_addToY = (_type != OverviewAudioDocuments && _height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
if (_type == OverviewPhotos && _resizeIndex < 0) {
|
||||
_resizeIndex = _photosInRow * ((scrollTop + minHeight) / int32(_vsize + st::overviewPhotoSkip)) + _photosInRow - 1;
|
||||
_resizeSkip = (scrollTop + minHeight) - ((scrollTop + minHeight) / int32(_vsize + st::overviewPhotoSkip)) * int32(_vsize + st::overviewPhotoSkip);
|
||||
@@ -1317,6 +1429,8 @@ void OverviewInner::openContextFile() {
|
||||
void OverviewInner::onMenuDestroy(QObject *obj) {
|
||||
if (_menu == obj) {
|
||||
_menu = 0;
|
||||
updateMsg(App::contextItem());
|
||||
if (_selectedMsgId > 0) updateMsg(App::histItemById(_selectedMsgId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1382,7 +1496,7 @@ void OverviewInner::onTouchScrollTimer() {
|
||||
|
||||
void OverviewInner::mediaOverviewUpdated(bool fromResize) {
|
||||
int32 oldHeight = _height;
|
||||
if (_type != OverviewPhotos) {
|
||||
if (_type != OverviewPhotos && _type != OverviewAudioDocuments) {
|
||||
History::MediaOverview &o(_hist->_overview[_type]);
|
||||
int32 l = o.size();
|
||||
_items.reserve(2 * l); // day items
|
||||
@@ -1477,7 +1591,7 @@ void OverviewInner::mediaOverviewUpdated(bool fromResize) {
|
||||
if (_height != y) {
|
||||
_height = y;
|
||||
if (!fromResize) {
|
||||
_addToY = (_height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
_addToY = (_type != OverviewAudioDocuments && _height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
resize(width(), _minHeight > _height ? _minHeight : _height);
|
||||
}
|
||||
}
|
||||
@@ -1544,7 +1658,7 @@ void OverviewInner::itemRemoved(HistoryItem *item) {
|
||||
}
|
||||
|
||||
void OverviewInner::itemResized(HistoryItem *item, bool scrollToIt) {
|
||||
if (_type != OverviewPhotos) {
|
||||
if (_type != OverviewPhotos && _type != OverviewAudioDocuments) {
|
||||
HistoryMedia *media = item ? item->getMedia(true) : 0;
|
||||
if (!media) return;
|
||||
|
||||
@@ -1562,7 +1676,7 @@ void OverviewInner::itemResized(HistoryItem *item, bool scrollToIt) {
|
||||
_items[j].y += newh;
|
||||
}
|
||||
_height = _items[l - 1].y;
|
||||
_addToY = (_height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
_addToY = (_type != OverviewAudioDocuments && _height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
resize(width(), _minHeight > _height ? _minHeight : _height);
|
||||
if (scrollToIt) {
|
||||
if (_addToY + _height - from > _scroll->scrollTop() + _scroll->height()) {
|
||||
@@ -1592,6 +1706,11 @@ void OverviewInner::msgUpdated(const HistoryItem *msg) {
|
||||
int32 row = (_photosToAdd + index) / _photosInRow, col = (_photosToAdd + index) % _photosInRow;
|
||||
update(int32(col * w), _addToY + int32(row * vsize), qCeil(w), vsize);
|
||||
}
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
int32 index = _hist->_overview[_type].indexOf(msgid);
|
||||
if (index >= 0) {
|
||||
update(_audioLeft, _addToY + int32(index * _audioHeight), _audioWidth, _audioHeight);
|
||||
}
|
||||
} else {
|
||||
for (int32 i = 0, l = _items.size(); i != l; ++i) {
|
||||
if (_items[i].msgid == msgid) {
|
||||
@@ -1620,13 +1739,16 @@ void OverviewInner::showAll(bool recountHeights) {
|
||||
}
|
||||
int32 rows = ((_photosToAdd + count) / _photosInRow) + (((_photosToAdd + count) % _photosInRow) ? 1 : 0);
|
||||
newHeight = _height = (_vsize + st::overviewPhotoSkip) * rows + st::overviewPhotoSkip;
|
||||
} else if (_type == OverviewAudioDocuments) {
|
||||
int32 count = _hist->_overview[_type].size(), fullCount = _hist->_overviewCount[_type];
|
||||
newHeight = _height = count * _audioHeight;
|
||||
} else {
|
||||
if (recountHeights && _type == OverviewVideos) { // recount heights because of captions
|
||||
mediaOverviewUpdated(true);
|
||||
}
|
||||
newHeight = _height;
|
||||
}
|
||||
_addToY = (_height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
_addToY = (_type != OverviewAudioDocuments && _height < _minHeight) ? (_minHeight - _height) : 0;
|
||||
if (newHeight < _minHeight) {
|
||||
newHeight = _minHeight;
|
||||
}
|
||||
@@ -1661,6 +1783,8 @@ OverviewWidget::OverviewWidget(QWidget *parent, const PeerData *peer, MediaOverv
|
||||
connect(&_scrollTimer, SIGNAL(timeout()), this, SLOT(onScrollTimer()));
|
||||
_scrollTimer.setSingleShot(false);
|
||||
|
||||
connect(App::main()->player(), SIGNAL(playerSongChanged(MsgId)), this, SLOT(onPlayerSongChanged(MsgId)));
|
||||
|
||||
switchType(type);
|
||||
}
|
||||
|
||||
@@ -1705,7 +1829,7 @@ void OverviewWidget::paintEvent(QPaintEvent *e) {
|
||||
}
|
||||
|
||||
QRect r(e->rect());
|
||||
if (type() == OverviewPhotos) {
|
||||
if (type() == OverviewPhotos || type() == OverviewAudioDocuments) {
|
||||
p.fillRect(r, st::white->b);
|
||||
} else {
|
||||
bool hasTopBar = !App::main()->topBar()->isHidden(), hasPlayer = !App::main()->player()->isHidden();
|
||||
@@ -1827,12 +1951,36 @@ int32 OverviewWidget::lastScrollTop() const {
|
||||
return _scroll.scrollTop();
|
||||
}
|
||||
|
||||
int32 OverviewWidget::countBestScroll() const {
|
||||
if (type() == OverviewAudioDocuments && audioPlayer()) {
|
||||
SongMsgId playing;
|
||||
AudioPlayerState playingState = AudioPlayerStopped;
|
||||
audioPlayer()->currentState(&playing, &playingState);
|
||||
if (playing) {
|
||||
int32 top = _inner.itemTop(playing.msgId);
|
||||
if (top >= 0) {
|
||||
return snap(top - int(_scroll.height() - (st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom())) / 2, 0, _scroll.scrollTopMax());
|
||||
}
|
||||
}
|
||||
}
|
||||
return _scroll.scrollTopMax();
|
||||
}
|
||||
|
||||
void OverviewWidget::fastShow(bool back, int32 lastScrollTop) {
|
||||
stopGif();
|
||||
resizeEvent(0);
|
||||
_scrollSetAfterShow = (lastScrollTop < 0 ? countBestScroll() : lastScrollTop);
|
||||
show();
|
||||
_inner.setFocus();
|
||||
doneShow();
|
||||
}
|
||||
|
||||
void OverviewWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTopBarCache, bool back, int32 lastScrollTop) {
|
||||
stopGif();
|
||||
_bgAnimCache = bgAnimCache;
|
||||
_bgAnimTopBarCache = bgAnimTopBarCache;
|
||||
resizeEvent(0);
|
||||
_scroll.scrollToY(lastScrollTop < 0 ? _scroll.scrollTopMax() : lastScrollTop);
|
||||
_scroll.scrollToY(lastScrollTop < 0 ? countBestScroll() : lastScrollTop);
|
||||
_animCache = myGrab(this, rect());
|
||||
App::main()->topBar()->stopAnim();
|
||||
_animTopBarCache = myGrab(App::main()->topBar(), QRect(0, 0, width(), st::topBarHeight));
|
||||
@@ -1950,6 +2098,15 @@ void OverviewWidget::onScrollTimer() {
|
||||
_scroll.scrollToY(_scroll.scrollTop() + d);
|
||||
}
|
||||
|
||||
void OverviewWidget::onPlayerSongChanged(MsgId msgId) {
|
||||
if (type() == OverviewAudioDocuments) {
|
||||
// int32 top = _inner.itemTop(msgId);
|
||||
// if (top > 0) {
|
||||
// _scroll.scrollToY(snap(top - int(_scroll.height() - (st::mediaPadding.top() + st::mediaThumbSize + st::mediaPadding.bottom())) / 2, 0, _scroll.scrollTopMax()));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewWidget::checkSelectingScroll(QPoint point) {
|
||||
if (point.y() < _scroll.scrollTop()) {
|
||||
_scrollDelta = point.y() - _scroll.scrollTop();
|
||||
|
Reference in New Issue
Block a user