feat: Don't quit when last tab closes
AbandonedPublic

Authored by EspadaV8 on Oct 28 2018, 1:22 PM.

Details

Reviewers
konsole-devel
hindenburg
Group Reviewers
Konsole
Summary

Let Konsole continue running after closing the final tab. This allows Konsole to always be available via a global shortcut.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
EspadaV8 requested review of this revision.Oct 28 2018, 1:22 PM
EspadaV8 created this revision.
EspadaV8 updated this revision to Diff 44420.Oct 29 2018, 10:35 AM

After talking to stikonas on IRC I've updated the patch with -U9999 to add more context

EspadaV8 edited the summary of this revision. (Show Details)Oct 29 2018, 10:36 AM

Didn't realise that the summary here would become part of the git commit so moving the text into a comment


I have only recently found out about --background-mode while looking into a alternative to Yakuake (due to its issue with panel focusing on show/hide and not respecting the 'open in current folder' option).

Background mode in Konsole works well for me, but there are times when I close the last view (either by mistake or just because I want to 'start fresh'). Currently Konsole will close in this case and then need relaunching.

This PR adds an option call PersistAfterLastClose (if you can think of something nicer to call it I'm happy to change it). When this setting is true, instead of calling MainWindow::close the new method MainWindow::handleLastTabClosed is called which checks this setting and will instead instantly create a new session and hide the window (which is what Yakuake will do).

This is my first bit of KDE work and it has been a while since I've done any Qt/C++ so please let me know if anything needs changing.

EspadaV8 edited the summary of this revision. (Show Details)Oct 29 2018, 10:50 AM
EspadaV8 added reviewers: konsole-devel, hindenburg.
ngraham added a subscriber: ngraham.Nov 1 2018, 3:38 AM

This allows Konsole to always be available via a global shortcut.

I just want to point out that this is already the case: Konsole installs a global keyboard shortcut definition such that Ctrl+Alt+t will launch it from anywhere. Is this not working for you or meeting your needs?

I didn't know about Ctrl+Alt+t. I'll give it a go and see if that works as needed.

I've checked the global settings for Konsole and the only entry there is for Toggle Background Window which is what I'm using now (although it was configured as Ctrl+Shift+F12 and I have added my own as Meta+Return). I checked the shortcuts inside Konsole too and didn't see anything that looked related. Do you know what the name of the shortcut is?

I've checked the global settings for Konsole and the only entry there is for Toggle Background Window which is what I'm using now (although it was configured as Ctrl+Shift+F12 and I have added my own as Meta+Return). I checked the shortcuts inside Konsole too and didn't see anything that looked related. Do you know what the name of the shortcut is?

It's not in Konsole, it gets installed in System Settings > Shortcuts > Custom Shortcuts > KMenuEdit > Konsole:

@ngraham Looking there and I don't have any Konsole shortcuts defined. I'm running Fedora F28 so perhaps it's not a standard thing (or it's been removed)? What should that shortcut do? Does it launch a new instance of Konsole when it's entered or does it bring an existing instance to the foreground?

The idea behind this is so that you can have konsole --background-mode run at start up, pressing your shortcut (mine is meta+return) will show/hide it. If you accidental end the last terminal session (Ctrl+d) then instead of quitting Konsole it will instead close that session, start a new one straight away and hide the window. Pressing your shortcut again will still bring it back into the foreground instead of the current behaviour which requires you to run konsole --background-mode again.

The Ctrl+Alt+t shortcut was added in D13708 and made it into Konsole 18.08. So if Fedora 28 still ships 18.04, that would explain it. If they ship 18.08, it might be worth a bug on their bug tracker to see what happened, since the code is definitely in Konsole itself.

Based on your desire to have an always-on Konsole that isn't getting quit but rather just hidden, you might consider using Yakuake instead, which is made for exactly this use case.

I was originally using Yakuake but that has an issue where it doesn't respect the setting to open new tabs in the current working directory.

Reading the Yakuake code base it seems that issue has been there for a number of years. It also doesn't look as tidy as the Konsole code base.

My intention was to bring few features that Yakuake offers into Console since it seems unnecessary to have both Yakuake and Konsole, one of which doesn't seem as well maintained.

EspadaV8 updated this revision to Diff 45356.Nov 12 2018, 12:09 PM