From dbd44af7c6452f630a664df0b00b2d17bdef2f06 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 12 Sep 2022 10:25:37 -0400 Subject: disable text wrap in image items. --- mingui/imageitem.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mingui/imageitem.cpp b/mingui/imageitem.cpp index ec7dc94..470a2f2 100644 --- a/mingui/imageitem.cpp +++ b/mingui/imageitem.cpp @@ -77,20 +77,16 @@ void ImageItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt .arg(dim.width()).arg(dim.height()) .arg(QLocale::system().formattedDataSize(fsz, 3)); QString fns = index.data(Qt::ItemDataRole::DisplayRole).toString(); + QTextOption topt; + topt.setWrapMode(QTextOption::WrapMode::NoWrap); r = option.fontMetrics.boundingRect(infos); r.moveTopLeft(ftopright + QPoint(0, (hkbg.height() - r.height()) / 2)); painter->setFont(option.font); painter->setPen(option.widget->palette().color(QPalette::ColorGroup::Normal, QPalette::ColorRole::Text)); - painter->drawText(r, infos); + painter->drawText(r, infos, topt); r = option.fontMetrics.boundingRect(fns); r.moveTopRight(QPoint(option.rect.right() - MARGIN - BORDER, ftopright.y() + (hkbg.height() - r.height()) / 2)); - painter->drawText(r, fns); - /* - painter->setPen(QColor(Qt::GlobalColor::red)); - painter->drawRect(QRect(imr.topLeft(), imd)); - painter->drawRect(txt); - painter->setPen(option.widget->palette().color(QPalette::ColorRole::Text)); - */ + painter->drawText(r, fns, topt); } QSize ImageItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -- cgit v1.2.3