mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-21 20:38:50 -04:00
Add ElidedLabel to GroupTreeWidget
This commit is contained in:
parent
0e1fad0ff7
commit
8483c0d0ca
4 changed files with 195 additions and 121 deletions
|
@ -52,7 +52,9 @@ ElidedLabel::ElidedLabel(const QString &text, QWidget *parent)
|
|||
, mElided(false)
|
||||
, mOnlyPlainText(false)
|
||||
, mContent(text)
|
||||
, mTextColor(QColor())
|
||||
{
|
||||
setStyleSheet("background-color: rgba(0,0,0,0%)");
|
||||
mRectElision = QRect();
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
@ -62,7 +64,9 @@ ElidedLabel::ElidedLabel(QWidget *parent)
|
|||
, mElided(false)
|
||||
, mOnlyPlainText(false)
|
||||
, mContent("")
|
||||
, mTextColor(QColor())
|
||||
{
|
||||
setStyleSheet("background-color: rgba(0,0,0,0%)");
|
||||
mRectElision = QRect();
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
|
@ -94,7 +98,7 @@ void ElidedLabel::paintEvent(QPaintEvent *event)
|
|||
QFontMetrics fontMetrics = painter.fontMetrics();
|
||||
QRect cr = contentsRect();
|
||||
cr.adjust(margin(), margin(), -margin(), -margin());
|
||||
|
||||
|
||||
bool didElide = false;
|
||||
QChar ellipsisChar(0x2026);//= "…"
|
||||
int lineSpacing = fontMetrics.lineSpacing();
|
||||
|
@ -225,3 +229,11 @@ void ElidedLabel::mousePressEvent(QMouseEvent *ev)
|
|||
}
|
||||
QLabel::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
void ElidedLabel::setTextColor(const QColor &color)
|
||||
{
|
||||
QPalette tmpPalette = palette();
|
||||
tmpPalette.setColor(foregroundRole(), color);
|
||||
setPalette(tmpPalette);
|
||||
mTextColor = color;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue