Skip to content

Commit

Permalink
feat: Add a close reason in moveToSideBar()
Browse files Browse the repository at this point in the history
As it can be called directly by the user as well
  • Loading branch information
iamsergio committed Apr 2, 2024
1 parent adeb410 commit 84928bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ void MainWindow::moveToSideBar(Core::DockWidget *dw, SideBarLocation location)

if (Core::SideBar *sb = sideBar(location)) {
ScopedValueRollback rollback(dw->d->m_isMovingToSideBar, true);
CloseReasonSetter reason(CloseReason::PinButton);
dw->forceClose();
sb->addDockWidget(dw);
} else {
Expand Down
5 changes: 5 additions & 0 deletions tests/qtwidgets/tst_qtwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,11 @@ void TestQtWidgets::tst_sidebarCloseReason()
expectedLastReason = CloseReason::TitleBarCloseButton;
dw1->titleBar()->onCloseClicked();
QCOMPARE(dw1->lastCloseReason(), expectedLastReason);

expectedLastReason = CloseReason::PinButton;
dw1->open();
m1->moveToSideBar(dw1);
QCOMPARE(dw1->lastCloseReason(), expectedLastReason);
}
}

Expand Down

0 comments on commit 84928bb

Please sign in to comment.