Skip to content

Commit 1c9a9a5

Browse files
committed
调整category的布局,让最后的pannel没有分割线
1 parent a8d8ffb commit 1c9a9a5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/SARibbonBar/SARibbonCategoryLayout.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,9 @@ void SARibbonCategoryLayout::doLayout()
446446
int debug_i__(0);
447447
qDebug() << "SARibbonCategoryLayout::doLayout(),name=" << category->categoryName();
448448
#endif
449-
for (SARibbonCategoryLayoutItem* item : qAsConst(d_ptr->mItemList)) {
449+
const int itemsize = d_ptr->mItemList.size();
450+
for (int i = 0; i < itemsize; ++i) {
451+
SARibbonCategoryLayoutItem* item = d_ptr->mItemList[ i ];
450452
if (item->isEmpty()) {
451453
hideWidgets << item->widget();
452454
if (item->separatorWidget) {
@@ -466,7 +468,12 @@ void SARibbonCategoryLayout::doLayout()
466468
showWidgets << item->widget();
467469
if (item->separatorWidget) {
468470
item->separatorWidget->setGeometry(item->mWillSetSeparatorGeometry);
469-
showWidgets << item->separatorWidget;
471+
if (i == itemsize - 1) {
472+
// 最后一个pannel的分割线隐藏
473+
hideWidgets << item->separatorWidget;
474+
} else {
475+
showWidgets << item->separatorWidget;
476+
}
470477
}
471478
#if SARibbonCategoryLayout_DEBUG_PRINT
472479
qDebug() << " |-[" << debug_i__ << "]pannelName(" << item->toPannelWidget()->pannelName()
@@ -496,6 +503,7 @@ void SARibbonCategoryLayout::doLayout()
496503
w->hide();
497504
}
498505
}
506+
// 最后一个分割线隐藏
499507
}
500508

501509
/**
@@ -658,8 +666,8 @@ void SARibbonCategoryLayout::scrollToByAnimate(int targetX)
658666
return; // 已经是目标位置
659667
}
660668
// 计算边界
661-
const int availableWidth = categoryContentSize().width();
662-
const int minBase = qMin(availableWidth - d_ptr->mTotalWidth, 0);
669+
const int availableWidth = categoryContentSize().width();
670+
const int minBase = qMin(availableWidth - d_ptr->mTotalWidth, 0);
663671
d_ptr->mTargetScrollPosition = qBound(minBase, targetX, 0);
664672

665673
// 如果动画正在进行,停止当前动画

0 commit comments

Comments
 (0)