Skip to content

Commit

Permalink
fix: ensure ViewOptionsWidget stays within screen bounds
Browse files Browse the repository at this point in the history
- Add screen boundary checks when showing the widget
- Adjust widget position if it would appear outside screen
- Improve user experience by keeping widget fully visible

Log: fix ui issue
Bug: https://pms.uniontech.com/bug-view-286089.html
  • Loading branch information
Lighto-Ku authored and deepin-bot[bot] committed Dec 13, 2024
1 parent 8ec3ca2 commit 4a48cb5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/dfm-base/widgets/dfmwindow/filemanagerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ void FileManagerWindowPrivate::connectAnimationSignals()
bool expanded = curSplitterAnimation->endValue().toInt() > 1;
if (expanded)
resetSideBarSize();
splitter->handle(1)->setEnabled(expanded);
// set the handle to be disabled when the side bar is collapsed
// because if do not disable the handle, the splitter can be dragged by pressed window left boarder.
if (auto handle = splitter->handle(1))
handle->setEnabled(expanded);
delete curSplitterAnimation;
curSplitterAnimation = nullptr;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ bool TitleBarWidget::eventFilter(QObject *watched, QEvent *event)
}
}

// if the splitter is animating, do not process the resize event of tabbar
// otherwise, the tabbar width will be changed twice(once by the resizeEvent and once by placeholder size changed)
if (watched == bottomBar && event->type() == QEvent::Resize) {
if (isSplitterAnimating)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <QVBoxLayout>
#include <QStandardItemModel>
#include <QKeyEvent>
#include <QApplication>
#include <QScreen>

DWIDGET_USE_NAMESPACE
using namespace dfmplugin_titlebar;
Expand Down Expand Up @@ -290,7 +292,32 @@ void ViewOptionsWidget::exec(const QPoint &pos, DFMBASE_NAMESPACE::Global::ViewM
{
d->setUrl(url);
d->switchMode(mode);
move(pos);

// Calculate appropriate display position to ensure widget stays within screen bounds
QPoint showPos = pos;
QRect screenRect = QApplication::screenAt(pos)->availableGeometry();

// Check right boundary
if (pos.x() + width() > screenRect.right()) {
showPos.setX(screenRect.right() - width());
}

// Check left boundary
if (showPos.x() < screenRect.left()) {
showPos.setX(screenRect.left());
}

// Check bottom boundary
if (pos.y() + height() > screenRect.bottom()) {
showPos.setY(screenRect.bottom() - height());
}

// Check top boundary
if (showPos.y() < screenRect.top()) {
showPos.setY(screenRect.top());
}

move(showPos);
show();

QEventLoop eventLoop;
Expand Down

0 comments on commit 4a48cb5

Please sign in to comment.