Add close tab and create new tab on middle click event
ClosedPublic

Authored by shubham on Sep 25 2018, 10:05 AM.

Details

Summary

Click with the middle mouse click on a tab: close it
Click with the middle click on empty portion of tab bar creates a new tab.
This makes konsole more streamlined with default behavior
found in other tabbed applications like browsers.
GUI option to enable/disable closing tab w/ mouse button. The default
is to have closing tab with button disabled to avoid possible data loss.

Tomaz Canabrava <tcanabrava@kde.org> also coded portion of this.

FEATURE: 398940
FIXED-IN: 19.04
GUI:

Test Plan

Diff Detail

Repository
R319 Konsole
Branch
arcpatch-D15742
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 8386
Build 8404: arc lint + arc unit
There are a very large number of changes, so older changes are hidden. Show Older Changes
tcanabrava requested review of this revision.Sep 25 2018, 10:05 AM
anthonyfieroni added inline comments.
src/ViewContainer.cpp
92–93 ↗(On Diff #42293)

You can connect directly the two signals.

broulik added inline comments.
src/DetachableTabBar.cpp
61 ↗(On Diff #42293)

Tabs typically close on mouse release.

tcanabrava added a comment.EditedSep 25 2018, 12:18 PM

I tried and it didn't worked for some reason

Em ter, 25 de set de 2018 às 13:37, Anthony Fieroni <
noreply@phabricator.kde.org> escreveu:

anthonyfieroni added inline comments. View Revision
https://phabricator.kde.org/D15742
*INLINE COMMENTS*
View Inline https://phabricator.kde.org/D15742#inline-85071
ViewContainer.cpp:92-93
this, &TabbedViewContainer::closeTerminalTab);
connect(tabBarWidget, &DetachableTabBar::newTabRequest,
this, [this]{ emit newViewRequest(); });

You can connect directly the two signals.

*REPOSITORY*
R319 Konsole

*REVISION DETAIL*
https://phabricator.kde.org/D15742

*To: *tcanabrava, ngraham, hindenburg
*Cc: *anthonyfieroni, konsole-devel, herrold, ngraham, maximilianocuria,
hindenburg

Ok, I'll update the patch

Em ter, 25 de set de 2018 às 13:50, Kai Uwe Broulik <
noreply@phabricator.kde.org> escreveu:

broulik added inline comments. View Revision
https://phabricator.kde.org/D15742
*INLINE COMMENTS*
View Inline https://phabricator.kde.org/D15742#inline-85072
DetachableTabBar.cpp:61
_containers = window()->findChildren<Konsole::TabbedViewContainer*>();
switch(event->button()) {
case Qt::MiddleButton : middleMouseButtonClickAt(event->pos()); break;
case Qt::LeftButton: _containers = window()->findChildren<Konsole::
TabbedViewContainer*>(); break;

Tabs typically close on mouse *release*.

*REPOSITORY*
R319 Konsole

*REVISION DETAIL*
https://phabricator.kde.org/D15742

*To: *tcanabrava, ngraham, hindenburg
*Cc: *broulik, anthonyfieroni, konsole-devel, herrold, ngraham,
maximilianocuria, hindenburg

I really dislike the middle click tab = close tab; we don't want to provide an easy accidentally way to close tabs IMHO.

I don't think we need to mimic all of browsers habits, especially since browser have a "tab history" and a way to reopen recently closed browsers.

To be honest, I'm not the biggest fan either, but I think consistency is important here.

An "undo close tab" feature would be a really fantastic addition though.

An "undo close tab" feature would be a really fantastic addition though.

It can be tough to impossible, in terminal you can make many things, it's not that easy like in browser, ssh, long standing web servers, logins etc. For security reasons it can be dangerous, handle a copy of terminal session can be harmful, passwords in plain text, etc so better not go in such direction.

Unless you want to add another option for this, with default as-it, I'll veto the close tab click. I don't see an issue w/ the new tab part.

Unless you want to add another option for this, with default as-it, I'll veto the close tab click. I don't see an issue w/ the new tab part.

ok, I'll update just for the open tab.
the other possibility is to first time you middle click at the tab there's a MessageBox explaining what happened and with the middle click and asking the person to opt-in / out.

src/ViewContainer.cpp
92–93 ↗(On Diff #42293)

tried, failed.

Are you still planning on working on this to just have the middle-click to open a new tab?

shubham added a subscriber: shubham.Feb 8 2019, 7:57 AM

@tcanabrava Are you still working on this, because I did not knew about this revision and created a new revision for the same feature
Please see D18606

I'll close this one, let's use yours.

tcanabrava abandoned this revision.Feb 8 2019, 11:01 AM

This one works for me - the other doesn't

geh, then let's keep this one and remove the other one.

can you reopen this pls? we need to add a GUI option to disable the closing part.

tcanabrava reclaimed this revision.Feb 13 2019, 7:44 AM

While I'm reopening this I have zero time to tackle this right now because of real work.

shubham added a comment.EditedFeb 13 2019, 7:48 AM

@tcanabrava If you don't mind, can I take over this revision? I'm willing to complete it.

Be my guest

Em qua, 13 de fev de 2019 às 08:48, Shubham <noreply@phabricator.kde.org>
escreveu:

shubham added a comment. View Revision
https://phabricator.kde.org/D15742

@tcanabrava https://phabricator.kde.org/p/tcanabrava/ If you don't
mind, can I commander this revision?

*REPOSITORY*
R319 Konsole

*REVISION DETAIL*
https://phabricator.kde.org/D15742

*To: *tcanabrava, ngraham, hindenburg
*Cc: *thsurrel, ngraham, hindenburg, shubham, broulik, anthonyfieroni,
konsole-devel, gennad, maciejn, maximilianocuria

shubham commandeered this revision.Feb 14 2019, 2:50 PM
shubham added a reviewer: tcanabrava.
shubham updated this revision to Diff 51826.Feb 16 2019, 7:28 AM

Make closing tabs on middle mouse button configurable

shubham marked an inline comment as done.Feb 16 2019, 7:29 AM
shubham updated this revision to Diff 51827.Feb 16 2019, 7:32 AM

Do not use camel case in strings

shubham edited the summary of this revision. (Show Details)Feb 16 2019, 7:33 AM
shubham updated this revision to Diff 51828.Feb 16 2019, 7:53 AM

Add config option in TabBar settings

shubham edited the test plan for this revision. (Show Details)Feb 16 2019, 7:55 AM
shubham edited the summary of this revision. (Show Details)
shubham retitled this revision from Handle middle click on tabs to Close tab on middle click event.Feb 16 2019, 7:57 AM

Thanks I'll look at this weekend

ngraham added inline comments.Feb 16 2019, 3:10 PM
src/DetachableTabBar.h
32

Unnecessary change

src/settings/TabBarSettings.ui
102 ↗(On Diff #51828)

Should be "Close tab on middle-click"

src/settings/konsole.kcfg
92 ↗(On Diff #51828)

Should be "Allow middle-clicking on open tabs to close them"

shubham updated this revision to Diff 51868.Feb 16 2019, 3:14 PM
shubham marked 3 inline comments as done.

Remove unnecessary change
Correct wordings

shubham edited the test plan for this revision. (Show Details)Feb 16 2019, 3:16 PM
ngraham accepted this revision.Feb 16 2019, 3:20 PM

Looks good and works well for me. Let's let @hindenburg have his say now. :)

This revision is now accepted and ready to land.Feb 16 2019, 3:20 PM

However I just noticed this patch has the wrong bug number. 361756 is for Okular. The Konsole bug is 398940, but it should be a CCBUG: not a BUG: because that report also requests the feature of middle-clicking in empty areas of the tab bar to create new tabs.

...Unless you want to implement that, too. :)

shubham edited the summary of this revision. (Show Details)Feb 16 2019, 3:41 PM
shubham added a comment.EditedFeb 16 2019, 3:49 PM

because that report also requests the feature of middle-clicking in empty areas of the tab bar to create new tabs.
...Unless you want to implement that, too. :)

I think it is not required, because we would be just duplicating the double click behaviour then. Currently double click does this.

The code actually closes when on a tab and opens a new tab when over an empty space. You'll need to update the message and GUI text.

Also if you can, rebase this diff on master as it is using a very old commit.

https://secure.phabricator.com/w/guides/arcanist_workflows/

I can't get middle-click-in-empty-space-to-open-a-new-tab to work with this patch. Double-clicking currently does this, but for me this patch doesn't add that behavior.

I can't get middle-click-in-empty-space-to-open-a-new-tab to work with this patch. Double-clicking currently does this, but for me this patch doesn't add that behavior.

It does here - can you double-check? Are you suing a real middle mouse or trackpad (not sure that matters, just asking)?

I can confirm that middle click on empty portion of the bar creates a new tab.

shubham edited the summary of this revision. (Show Details)Feb 17 2019, 4:36 PM

what should I now name the gui message? It will become quite big then.

what should I now name the gui message? It will become quite big then.

There's quite a lot of space there, it can be two lines if needed - perhaps "Allow middle click to close and create new tabs"

Another idea: always allow middle-click to open new tabs, but just have the option toggle its close behavior. Then the string can be nice and simple.

Another idea: always allow middle-click to open new tabs, but just have the option toggle its close behavior. Then the string can be nice and simple.

Oh yes, I forgot we had agreed on that.

shubham updated this revision to Diff 51968.Feb 18 2019, 3:40 PM

Changes as requested by ngraham and kurt

ngraham accepted this revision.Feb 18 2019, 6:46 PM

Works perfectly now for both mice and touchpads. This gets a "ship it!" from me!

Please rebase this on current git master and await @hindenburg's final review.

shubham updated this revision to Diff 52071.Feb 19 2019, 2:37 PM

Rebase on master

Looks like a few git conflict markers have made their way in the code.

Yes, noticed, going to fix in a moment

@emateli do you know how can I go to previous version I have uploaded?

shubham updated this revision to Diff 52078.Feb 19 2019, 3:23 PM

Proper rebase on master

yea give me a few

hindenburg accepted this revision.Feb 20 2019, 1:44 AM
hindenburg retitled this revision from Close tab on middle click event to Add close tab and create new tab on middle click event.
hindenburg edited the summary of this revision. (Show Details)

Thanks for working on this everyone.

hindenburg edited the summary of this revision. (Show Details)Feb 20 2019, 1:48 AM
hindenburg edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.

Nice job, @shubham. Wanna do the same thing for Okular next? https://bugs.kde.org/show_bug.cgi?id=361756. Probably doesn't need an option there.

Nice job, @shubham. Wanna do the same thing for Okular next? https://bugs.kde.org/show_bug.cgi?id=361756. Probably doesn't need an option there.

Actually yes, coz I m targeting okular for past few days, you might be knowing.