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

Make document tabs closable #240

Merged
merged 3 commits into from
Mar 10, 2025
Merged

Make document tabs closable #240

merged 3 commits into from
Mar 10, 2025

Conversation

Cuperino
Copy link
Member

@Cuperino Cuperino commented Feb 6, 2025

Allow closing documents by clicking X in their tabs.

@Cuperino Cuperino added the ⬆️ feature New feature or request label Feb 6, 2025
@Cuperino Cuperino requested a review from narnaud February 6, 2025 01:53
@Cuperino Cuperino self-assigned this Feb 6, 2025
Copy link
Member

@narnaud narnaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do that because I find it very ugly... (I already refused such a PR).
The only way for me to accept would be to change the style of the close button, like VS Code for example:

  • only show the button on the current tab
  • or when hovering the other tabs
  • change the icon to use the close icon from the dock for example

I don't think it's worth it. If you want to do it, go ahead, otherwise close the PR.

@Cuperino Cuperino force-pushed the closable-tabs branch 2 times, most recently from b3ab264 to ad0bbd3 Compare March 3, 2025 15:56
@Cuperino
Copy link
Member Author

Cuperino commented Mar 3, 2025

I didn't do that because I find it very ugly...

This sounds more like a theming and Qt design issue... This what the buttons look like in KDE Plasma's Breeze dark theme:
image
image
I don't like that it's inconsistent with the close button from the sidebar, but it doesn't look too bad on this instance.

  • only show the button on the current tab
  • or when hovering the other tabs
  • change the icon to use the close icon from the dock for example

I tried going with your first option, for I think that is the best possible solution. However, tabList is stored in the
protected side of QTabBar (qtabbar_p.h), and there's no good way to access it without re-inventing the wheel. I ended up implementing your second suggestion instead: [show] when hovering the other tabs.

Having all tabs appear and disappear at the simultaneously can be jarring if it happens consecutively too quickly, so I also added a timer before the buttons are hidden again. For the delay I chose 2 seconds, which is what is used for a "human moment" over at KDE.

It's important for users to have an intuitive and efficient way to close tabs with the mouse cursor. I also thought about closing a tab with a middle click, but that wouldn't have been as intuitive as having a close button in the tab.

Copy link
Member

@narnaud narnaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, just rebase and remove the timer, and it's good to go.

Cuperino added 2 commits March 9, 2025 13:40
This implementation shows and hides all close buttons simultaneously
while mouse cursor hovers over them. A delay was added before close
buttons are hidden again to save the user from a jarring experience
when they off-shoot the mouse cursor reaching for the tab bar.

Ideally we'd only display close buttons for the active tab and the tab
currently being hovered. However, the list of tabs is stored in the
protected side of QTabBar (qtabbar_p.h) and we can't make use of it
without re-inventing the wheel.
@Cuperino Cuperino requested a review from narnaud March 9, 2025 23:57
@Cuperino Cuperino merged commit 3d85433 into KDAB:main Mar 10, 2025
5 checks passed
@Cuperino Cuperino deleted the closable-tabs branch March 10, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬆️ feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants