Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remote server item text overlaps with buttons #342

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/views/itemwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ void ItemWidget::initConnections()
connect(m_funcButton, &IconButton::focusOut, this, &ItemWidget::onFocusOut);
// 图标被点击
connect(m_iconButton, &DIconButton::clicked, this, &ItemWidget::onIconButtonClicked);

}

void ItemWidget::paintEvent(QPaintEvent *event)
Expand All @@ -384,8 +383,15 @@ void ItemWidget::paintEvent(QPaintEvent *event)
QFont firstFont = m_firstline->font();
QFont secondFont = m_secondline->font();
// 限制文字长度,防止超出
QString firstText = Utils::getElidedText(firstFont, m_firstText, ITEMMAXWIDTH);
QString secondText = Utils::getElidedText(secondFont, m_secondText, ITEMMAXWIDTH);
QString firstText;
QString secondText;
if (!m_funcButton->isVisible()) {
firstText = Utils::getElidedText(firstFont, m_firstText, ITEMMAXWIDTH);
secondText = Utils::getElidedText(secondFont, m_secondText, ITEMMAXWIDTH);
} else {
firstText = Utils::getElidedText(firstFont, m_firstText, ITEMMAXWIDTH - m_funcButton->width());
secondText = Utils::getElidedText(secondFont, m_secondText, ITEMMAXWIDTH - m_funcButton->width());
}
// 设置显示的文字
m_firstline->setText(firstText);
m_secondline->setText(secondText);
Expand Down
Loading