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: adjust scroll behavior in list view mode #2452

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ inline constexpr int kLeftPadding { 10 };
inline constexpr int kRightPadding { 10 };
inline constexpr int kListModeLeftMargin { 10 };
inline constexpr int kListModeRightMargin { 10 };
inline constexpr int kListModeBottomMargin { 16 };
inline constexpr int kColumnPadding { 10 };
inline constexpr int kMinMoveLenght { 3 };
inline constexpr int kIconHorizontalMargin { 15 }; // 水平Margin的宽度
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ QList<ItemRoles> FileView::getColumnRoles() const

void FileView::updateGeometries()
{
int totalHeight = 0;
if (isIconViewMode()) {
int iconVerticalTopMargin = 0;
#ifdef DTKWIDGET_CLASS_DSizeMode
Expand All @@ -1455,13 +1456,21 @@ void FileView::updateGeometries()
if (!d->isResizeEvent
|| (d->isResizeEvent && d->lastContentHeight > 0 && d->lastContentHeight != contentsSize().height()))
resizeContents(contentsSize().width(), contentsSize().height() + iconVerticalTopMargin);
d->lastContentHeight = contentsSize().height();
totalHeight = contentsSize().height();
d->lastContentHeight = totalHeight;
} else {
int rowCount = model()->rowCount(rootIndex());
int listHeight = rowCount * itemSizeHint().height() + kListModeBottomMargin;
int contentHeight = contentsSize().height();

totalHeight = listHeight > contentHeight ? listHeight : contentHeight;
}

if (!d->headerView || !d->allowedAdjustColumnSize) {
return DListView::updateGeometries();
}

resizeContents(d->headerView->length(), contentsSize().height());
resizeContents(d->headerView->length(), totalHeight);
DListView::updateGeometries();
}

Expand Down
Loading