fixed bug in auto-determination of aspect ratio and update of geometry

This commit is contained in:
csoler 2020-09-05 14:24:39 +02:00
parent 062f0eb195
commit b8c14d6bc4
2 changed files with 4 additions and 3 deletions

View File

@ -165,7 +165,7 @@ ChannelPostThumbnailView::AspectRatio ChannelPostThumbnailView::bestAspectRatio(
float as = mPostImage->originalImage().height() / (float)mPostImage->originalImage().width() ;
if(as < 0.8)
if(as <= 0.8)
return ASPECT_RATIO_16_9;
else if(as < 1.15)
return ASPECT_RATIO_1_1;

View File

@ -790,7 +790,7 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
// now compute aspect ratio for posts. We do that by looking at the 5 latest posts and compute the best aspect ratio for them.
std::vector<uint32_t> ar_votes(3,0);
std::vector<uint32_t> ar_votes(4,0);
for(uint32_t i=0;i<std::min(mChannelPostsModel->getNumberOfPosts(),5u);++i)
{
@ -800,12 +800,13 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
++ar_votes[ static_cast<uint32_t>( v.bestAspectRatio() )];
}
int best=0;
for(uint32_t i=0;i<3;++i)
for(uint32_t i=0;i<4;++i)
if(ar_votes[i] > ar_votes[best])
best = i;
mChannelPostsDelegate->setAspectRatio(static_cast<ChannelPostThumbnailView::AspectRatio>(best));
mChannelPostsModel->triggerViewUpdate();
handlePostsTreeSizeChange(ui->postsTree->size(),true); // force the update
}
void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete)