🐞 fix(UI模块): 绘制代理时处理字号变化

This commit is contained in:
huheng@kylinos.cn 2023-05-26 09:16:27 +08:00
parent bb0198e6bc
commit e2e1e91ed4
3 changed files with 12 additions and 2 deletions

View File

@ -157,14 +157,18 @@ void FileView::changeFontSize(double fontSize)
{ {
m_listItemHeight = m_listItemHeight + ((fontSize - m_fontSize) * 2); m_listItemHeight = m_listItemHeight + ((fontSize - m_fontSize) * 2);
m_fontSize = fontSize; m_fontSize = fontSize;
updateViewMode();
if (m_downloadBtn != nullptr) { if (m_downloadBtn != nullptr) {
m_downloadBtn->changeFontSize(m_fontSize); m_downloadBtn->changeFontSize(m_fontSize);
} }
QFont font; QFont font;
font.setPointSizeF(fontSize); font.setPointSizeF(fontSize);
setFont(font); setFont(font);
update(); updateViewMode();
}
double FileView::getFontSize() const
{
return m_fontSize;
} }
void FileView::setItemMode(FileView::ItemSelectMode mode, bool isClear) void FileView::setItemMode(FileView::ItemSelectMode mode, bool isClear)

View File

@ -41,6 +41,7 @@ public:
void setTheme(PublicAttributes::Theme theme); void setTheme(PublicAttributes::Theme theme);
PublicAttributes::Theme getTheme() const; PublicAttributes::Theme getTheme() const;
void changeFontSize(double fontSize); void changeFontSize(double fontSize);
double getFontSize() const;
void setItemMode(FileView::ItemSelectMode mode, bool isClear = false); void setItemMode(FileView::ItemSelectMode mode, bool isClear = false);
FileView::ItemSelectMode getItemMode() const; FileView::ItemSelectMode getItemMode() const;
void setThumbnailType(ThumbnailType type); void setThumbnailType(ThumbnailType type);

View File

@ -28,6 +28,11 @@ FileViewDelegate::~FileViewDelegate()
void FileViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const void FileViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{ {
auto *view = qobject_cast<const FileView *>(option.widget); auto *view = qobject_cast<const FileView *>(option.widget);
double fontSize = view->getFontSize();
QFont font;
font.setPointSizeF(fontSize);
painter->setFont(font);
if (view->getItemMode() == FileView::ItemSelectMode::Default) { if (view->getItemMode() == FileView::ItemSelectMode::Default) {
kdk::KListViewDelegate::paint(painter, option, index); kdk::KListViewDelegate::paint(painter, option, index);
} else { } else {