mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
added a factor to scale the font
This commit is contained in:
parent
149b2c0fbe
commit
660b1c4025
@ -25,6 +25,7 @@
|
||||
#include "gui/gxschannels/GxsChannelPostThumbnail.h"
|
||||
|
||||
const float ChannelPostThumbnailView::DEFAULT_SIZE_IN_FONT_HEIGHT = 5.0;
|
||||
const float ChannelPostThumbnailView::FONT_SCALE_FACTOR = 2.0;
|
||||
|
||||
ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent)
|
||||
: QWidget(parent),mPostTitle(nullptr),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3)
|
||||
@ -134,7 +135,10 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post)
|
||||
|
||||
QFont font = mPostTitle->font();
|
||||
|
||||
font.setPointSizeF(DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF());
|
||||
if(mFlags & ChannelPostThumbnailView::FLAG_SCALE_FONT)
|
||||
font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF());
|
||||
else
|
||||
font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF());
|
||||
|
||||
if(is_msg_new)
|
||||
font.setBold(true);
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
static constexpr uint32_t FLAG_NONE = 0x00;
|
||||
static constexpr uint32_t FLAG_SHOW_TEXT = 0x01;
|
||||
static constexpr uint32_t FLAG_ALLOW_PAN = 0x02;
|
||||
static constexpr uint32_t FLAG_SCALE_FONT= 0x04;
|
||||
|
||||
// Size of thumbnails as a function of the height of the font. An aspect ratio of 3/4 is good.
|
||||
|
||||
@ -119,6 +120,7 @@ public:
|
||||
AspectRatio bestAspectRatio() ;
|
||||
private:
|
||||
static const float DEFAULT_SIZE_IN_FONT_HEIGHT ;
|
||||
static const float FONT_SCALE_FACTOR ;
|
||||
|
||||
float thumbnail_w() const;
|
||||
float thumbnail_h() const;
|
||||
|
@ -125,7 +125,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
||||
{
|
||||
// Draw a thumbnail
|
||||
|
||||
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0;
|
||||
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT):0;
|
||||
ChannelPostThumbnailView w(post,flags);
|
||||
w.setAspectRatio(mAspectRatio);
|
||||
w.updateGeometry();
|
||||
@ -206,7 +206,7 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM
|
||||
QFontMetricsF fm(option.font);
|
||||
|
||||
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0;
|
||||
uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT):0;
|
||||
|
||||
ChannelPostThumbnailView w(post,flags);
|
||||
w.setAspectRatio(mAspectRatio);
|
||||
@ -798,7 +798,7 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
for(uint32_t i=0;i<std::min(mChannelPostsModel->getNumberOfPosts(),5u);++i)
|
||||
{
|
||||
const RsGxsChannelPost& post = mChannelPostsModel->post(i);
|
||||
ChannelPostThumbnailView v(post,ChannelPostThumbnailView::FLAG_SHOW_TEXT);
|
||||
ChannelPostThumbnailView v(post,ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT);
|
||||
|
||||
++ar_votes[ static_cast<uint32_t>( v.bestAspectRatio() )];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user