Compare commits

..

1 Commits

Author SHA1 Message Date
janrupf
b09f3448f9 NOISSUE Try on fixing overflowing text 2019-06-22 00:27:43 +02:00
3 changed files with 17 additions and 18 deletions

View File

@@ -254,7 +254,17 @@ void IconList::installIcons(const QStringList &iconFiles)
{
for (QString file : iconFiles)
{
installIcon(file, QFileInfo(file).fileName());
QFileInfo fileinfo(file);
if (!fileinfo.isReadable() || !fileinfo.isFile())
continue;
QString target = FS::PathCombine(m_dir.dirName(), fileinfo.fileName());
QString suffix = fileinfo.suffix();
if (suffix != "jpeg" && suffix != "png" && suffix != "jpg" && suffix != "ico" && suffix != "svg" && suffix != "gif")
continue;
if (!QFile::copy(file, target))
continue;
}
}
@@ -262,24 +272,11 @@ void IconList::installIcon(const QString &file, const QString &name)
{
QFileInfo fileinfo(file);
if(!fileinfo.isReadable() || !fileinfo.isFile())
{
qWarning() << "Failed to install icon" << fileinfo.absoluteFilePath();
return;
}
QString target = FS::PathCombine(m_dir.dirName(), name);
QPixmap icon(fileinfo.absoluteFilePath());
if(icon.isNull())
{
qWarning() << "Icon " << fileinfo.absoluteFilePath() << "is null";
return;
}
auto currentSize = icon.size();
auto targetedWidth = qMin(currentSize.width(), 512);
auto targetedHeight = qMin(currentSize.height(), 512);
icon.scaled(targetedWidth, targetedHeight).save(target);
QFile::copy(file, target);
}
bool IconList::iconFileExists(const QString &key) const

View File

@@ -661,6 +661,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
// Create the instance list widget
{
view = new GroupView(ui->centralWidget);
view->setTextElideMode(Qt::TextElideMode::ElideRight);
view->setSelectionMode(QAbstractItemView::SingleSelection);
// FIXME: leaks ListViewDelegate

View File

@@ -34,7 +34,6 @@ static void viewItemTextLayout(QTextLayout &textLayout, int lineWidth, qreal &he
height = 0;
widthUsed = 0;
textLayout.beginLayout();
QString str = textLayout.text();
while (true)
{
QTextLine line = textLayout.createLine();
@@ -190,11 +189,13 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
// FIXME: Things go really weird with long instance names
// const int iconSize = style->pixelMetric(QStyle::PM_IconViewIconSize);
const int iconSize = 48;
QRect iconbox = opt.rect;
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, opt.widget) + 1;
const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, opt.widget) + 1;
QRect textRect = opt.rect;
textRect.setWidth(qMin(textRect.width(), iconbox.width()));
QRect textHighlightRect = textRect;
// clip the decoration on top, remove width padding
textRect.adjust(textMargin, iconSize + textMargin + 5, -textMargin, 0);
@@ -299,7 +300,7 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
const int lineCount = textLayout.lineCount();
const QRect layoutRect = QStyle::alignedRect(
opt.direction, opt.displayAlignment, QSize(textRect.width(), int(height)), textRect);
opt.direction, opt.displayAlignment, QSize(textRect.width(), int(height)), textRect);
const QPointF position = layoutRect.topLeft();
for (int i = 0; i < lineCount; ++i)
{