Skip to content

Commit

Permalink
feat: remove the inner margin of dock plugin tooltips
Browse files Browse the repository at this point in the history
remove the margins from the dock plugin tooltips, which will be managed uniformly by the dock

Issue: linuxdeepin/developer-center#9997
  • Loading branch information
mhduiy authored and deepin-bot[bot] committed Aug 7, 2024
1 parent f696a81 commit eddb4e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/dde-dock-plugins/shotstart/tipswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void TipsWidget::setText(const QString &text)
m_text = "བོད་སྐད་ཡིག་གཟུགས་ཚད་ལེན་ཚོད་ལྟའི་སྐོར་གྱི་རྗོད་ཚིག";
#endif

setFixedSize(fontMetrics().width(m_text) + 20, fontMetrics().boundingRect(m_text).height());
setFixedSize(fontMetrics().horizontalAdvance(m_text), fontMetrics().boundingRect(m_text).height());

update();

Expand All @@ -50,7 +50,7 @@ void TipsWidget::setTextList(const QStringList &textList)
int width = 0;
int height = 0;
for (QString text : m_textList) {
width = qMax(width, fontMetrics().width(text) + 20);
width = qMax(width, fontMetrics().horizontalAdvance(text));
height += fontMetrics().boundingRect(text).height();
}

Expand All @@ -75,6 +75,7 @@ void TipsWidget::paintEvent(QPaintEvent *event)

switch (m_type) {
case SingleLine:
option.setWrapMode(QTextOption::NoWrap);
painter.drawText(rect(), m_text, option);
break;
case MultiLine:
Expand Down
5 changes: 3 additions & 2 deletions src/dde-dock-plugins/shotstartrecord/tipswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void TipsWidget::setText(const QString &text)
// m_text = "བོད་སྐད་ཡིག་གཟུགས་ཚད་ལེན་ཚོད་ལྟའི་སྐོར་གྱི་རྗོད་ཚིག";
#endif

setFixedSize(fontMetrics().width(m_text) + 20, fontMetrics().boundingRect(m_text).height());
setFixedSize(fontMetrics().horizontalAdvance(m_text), fontMetrics().boundingRect(m_text).height());

update();

Expand All @@ -50,7 +50,7 @@ void TipsWidget::setTextList(const QStringList &textList)
int width = 0;
int height = 0;
for (QString text : m_textList) {
width = qMax(width, fontMetrics().width(text) + 20);
width = qMax(width, fontMetrics().horizontalAdvance(text));
height += fontMetrics().boundingRect(text).height();
}

Expand All @@ -74,6 +74,7 @@ void TipsWidget::paintEvent(QPaintEvent *event)

switch (m_type) {
case SingleLine:
option.setWrapMode(QTextOption::NoWrap);
painter.drawText(rect(), m_text, option);
break;
case MultiLine:
Expand Down

0 comments on commit eddb4e7

Please sign in to comment.