Skip to content

Commit

Permalink
itemnotes: Fix icon layout
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Aug 29, 2017
1 parent 9c581e8 commit 4415757
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugins/itemnotes/itemnotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
#include <QTimer>
#include <QToolTip>
#include <QtPlugin>
#include <QDebug>

#include <cmath>

namespace {

Expand All @@ -61,8 +62,9 @@ QWidget *createIconWidget(const QByteArray &icon, QWidget *parent)
const int side = ratio * (iconFontSizePixels() + 2);
p = p.scaled(side, side, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QLabel *label = new QLabel(parent);
const int m = side / 4;
label->setContentsMargins(m, m, m, m);
const auto m = side / 4;
label->setFixedSize( p.size() / ratio + QSize(m, m) );
label->setAlignment(Qt::AlignCenter);
label->setPixmap(p);
return label;
}
Expand Down Expand Up @@ -123,7 +125,7 @@ ItemNotes::ItemNotes(ItemWidget *childItem, const QString &text, const QByteArra
labelLayout->setContentsMargins(notesIndent, 0, 0, 0);

if (m_icon)
labelLayout->addWidget(m_icon, 0, Qt::AlignLeft);
labelLayout->addWidget(m_icon, 0, Qt::AlignLeft | Qt::AlignTop);

labelLayout->addWidget(m_notes, 1, Qt::AlignLeft);

Expand Down Expand Up @@ -268,8 +270,9 @@ void ItemNotes::paintEvent(QPaintEvent *event)
p.setBrush(c);
p.setPen(Qt::NoPen);
QWidget *w = m_icon ? m_icon : m_notes;
const auto height = std::max(w->height(), m_notes->height()) - 8;
p.drawRect(w->x() - notesIndent + 4, w->y() + 4,
notesIndent - 4, m_notes->height() - 8);
notesIndent - 4, height);
}
}

Expand Down

0 comments on commit 4415757

Please sign in to comment.