Skip to content

Commit

Permalink
fix: [tab-bar] close button ui show error
Browse files Browse the repository at this point in the history
Adjust the close button size.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-259201.html
  • Loading branch information
GongHeng2017 authored and deepin-bot[bot] committed Jun 26, 2024
1 parent f74e741 commit a0a366b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#include <unistd.h>

inline constexpr int kTabHeightScaling { 24 };
inline constexpr int kCloseButtonBigSize { 36 };
inline constexpr int kCloseButtonSmallSize { 30 };

DFMBASE_USE_NAMESPACE
using namespace dfmplugin_workspace;

Expand Down Expand Up @@ -426,9 +430,9 @@ void TabBar::mouseMoveEvent(QMouseEvent *event)
if (closingIndex < count() && closingIndex >= 0) {
Tab *tab = tabList.at(closingIndex);
tabCloseButton->setClosingIndex(closingIndex);
int btnSize = height() > 24 ? 36 : 32;
int btnSize = height() > kTabHeightScaling ? kCloseButtonBigSize : kCloseButtonSmallSize;
tabCloseButton->setSize(btnSize);
tabCloseButton->setPos(tab->x() + tab->width() - btnSize - 4, btnSize - 32);
tabCloseButton->setPos(tab->x() + tab->width() - btnSize - 4, (btnSize - kCloseButtonSmallSize)/2 - 1);

if (closingIndex == currentIndex)
tabCloseButton->setActiveWidthTab(true);
Expand Down Expand Up @@ -579,9 +583,9 @@ void TabBar::handleTabAnimationFinished(const int index)
{
if (tabCloseButton->getClosingIndex() == index) {
Tab *tab = tabList.at(index);
int btnSize = height() > 24 ? 36 : 32;
int btnSize = height() > kTabHeightScaling ? kCloseButtonBigSize : kCloseButtonSmallSize;
tabCloseButton->setSize(btnSize);
tabCloseButton->setPos(tab->x() + tab->width() - btnSize - 4, btnSize - 32);
tabCloseButton->setPos(tab->x() + tab->width() - btnSize - 4, (btnSize - kCloseButtonSmallSize)/2 - 1);
}

if ((tabCloseButton->getClosingIndex() >= count()
Expand Down

0 comments on commit a0a366b

Please sign in to comment.