Commit Graph

94 Commits

Author SHA1 Message Date
Laurent Montel
fc45802b72 Port away from deprecated KIO code 2022-08-21 21:02:16 +02:00
Friedrich W. H. Kossebau
17796fb8f4 Port away from deprecated KMessageBox::sorry
GIT_SILENT
2022-07-22 18:32:31 +00:00
Friedrich W. H. Kossebau
91b7c1a03b Session close confirm dialog: use action terms instead of Yes/No buttons
Yes/No buttons in dialogs are discouraged (not only) by KDE HIG in favour
of actions terms.
2022-07-11 15:07:21 +00:00
Harald Sitter
87e27eb811 automatic clang-format run (clang 14) 2022-07-11 11:43:02 +02:00
Luis Javier Merino Morán
25f49b723d Support XdgActivation for focus from notification
To support focusing a session from a notification in Wayland, we need to
use the XdgActivation protocol.  This is done by passing to
KWindowSystem an XDG activation token that we get from the notification.
2022-07-05 09:04:52 +00:00
Luis Javier Merino Morán
8fb6899389 Focus session from notification
Adds a "Show session" button to notifications, which, when clicked, will
focus the originating session.

Original patch by Kasper Laudrup at bug 305162, then updated by Martin
T. H. Sandsmark.

Now updated and extended to silence/activity/process termination
notifications, adding support for focusing a TerminalDisplay inside a
hierarchy of ViewSplitters inside a TabbedViewContainer, and using
KWindowSystem::forceActiveWindow() instead of ::activateWindow().

BUG: 305162
BUG: 344208
2022-07-05 09:04:52 +00:00
Luis Javier Merino Morán
416941b714 Snapshot session on focus, key press and output
Before 3d6c839b, sessions were snapshotted every 2 seconds, and also
half a second after the associated view received focus or a key press.
This second timer could theoretically be postponed indefinitely.

Commit 3d6c839b tries to save energy by not taking a snapshot every 2
seconds, and instead has a timer that fires half a second after any
event received by the application.

This commit goes back to the old behavior, but still without the 2
second timer, and also sets the half second timer after receiving the
Emulation::outputChanged signal, which is sent at a maximum 40ms after
the emulation receives data.  It also copies the idea from commit
3d6c839b of not restarting the timer if it's already started, since
otherwise, continuous output could postpone the timer indefinitely.
2022-07-05 08:59:55 +00:00
Matan Ziv-Av
9333d6713a Add semantic integration copy actions
- Selecting Copy (or pressing ctrl-shift-c) when there is no selection
  selects current output if current mode is output, current input if
  current mode is input and input is non-empty, and last output if current
  input is empty.
- Ctrl + mouse triple click selects the pointed input/output/prompt.
- There is also a fix that was missed in previous patch for keeping
  track of current semantic mode through scrolls.
2022-07-04 23:53:48 +03:00
Matan Ziv-Av
5389ec11b0 Fix bugs in semantic shell integration
Bugs reported here:
https://invent.kde.org/utilities/konsole/-/merge_requests/691#note_480025
- Properly ignore OSC parameters for now. (later we'll support some).
- Handle Input end for when command gets shorter.
- Always draw separating line in foreground color
- Don't group characters of different REPL type.
- Don't reset double width/height attributes of erased lines.
2022-07-03 21:40:56 +03:00
Matan Ziv-Av
d67de797b6 Allow filtered copy to clipboard
This adds three copy actions:
- Copy only user input
- Copy only command output
- Copy both (filter out shell prompts).
2022-07-03 07:58:54 +00:00
Laurent Montel
128e7766da Fix compile against qt6 2022-06-24 08:00:17 +02:00
Georg Gadinger
7f41a38371 Improve usability on macOS including altering shortcuts
This change removes some application attributes that are not necessary anymore (like disabling the global menu bar) or make Konsole behave slightly different when used from a KPart (e.g. inside Kate), and changes some keyboard shortcuts around (mainly using Command instead of Ctrl+Shift now.)

Unfortunately this does not resolve the requirement for the special keytab file for macOS; it looks like Qt does something funny with the QKeyEvents here: on Linux these have a `text` attribute set to e.g. `\u0003` for `^C`, that attribute is empty on macOS.

Note this could impact shortcut changes on non-macOS systems.
2022-06-21 00:10:44 +00:00
Ahmad Samir
3b58e4a9ac More Qt6 build fixes
- Port QStringRef to QStringView (using Q5StringRef::toInt() because
  Q5StringView::toInt() uses toString() internally to get a QString
  which defeats the point of using a view)
- Fix creating a QKeySequence from OR'ing Qt::Key and Qt::Modifiers by
  explicitly constructing a QKeySequence; IIUC, this is due to the two
  values coming from two different enums:
  "cannot convert ‘QIncompatibleFlag’ to ‘const QKeySequence&’"
- Implicit cast from int to QChar is gone in Qt6
- Implicit cast of QString to QFileInfo is gone in Qt6
- Create a QByteArray to make QStringBuilder work
- QHash::const_iterator can't be used in place of a
  QMultiHash::const_iterator
2022-06-01 14:35:49 +00:00
Benoît DÉCHAMPS
3d6c839bcd Do not snapshot session when idle
There is no reason for a tab title to change if there is no QT event.
So, instead of snapshoting session regularly, we do it only if there is
some QT events. To catch all QT events an event handler is installed on the
QCoreApplication instance.
2022-05-30 07:13:57 +00:00
ivan tkachenko
fca0f4f9d7 Rename "fallback" profile to Built-in
* Rename everything related to built-in profile both in code and UI.

* Unified style for [Read-only] and [Default] badges in profile
  manager's list model.

* Change --fallback-profile option to --builtin-profile.

* Backward compatibility: yes. If a user happened to name their
  profile "Built-in", it would continue to work as normal, and even
  load with `--profile "Built-in"` command line flag. It will let them
  modify any property including Name; but changing the name back
  to "Built-in" shows a warning and reverts the change as usual.

* Remove "This option is a shortcut for" sentence. While it is still
  technically possible to pass built-in profile's magic path, this
  option is not a shortcut, nor implemented as such.

* Delete extra naming conditions in ProfileManager::changeProfile,
  because they could never be triggered anyway, due to pre-flight
  checks in EditProfileDialog::isProfileNameValid. Automatic unique
  profile names generation has been done even earlier in either
  SessionController or ProfileSettings. Just as before, users will
  continue experiencing a generic "A profile with the name \"%1\"
  already exists." message.

Tests:

* Improve test for uncreatable file name of built-in profile.

* Add backward compatibility test for loading existing profile
  named "Built-in" which also references real built-in as its parent.

BUG: 438309
2022-05-25 11:15:17 +00:00
Ahmad Samir
33b3a1a7a7 Port away from using QObject::sender()
By passing the sender object as an arg to the signal/slot.
2022-05-24 13:02:59 +00:00
Luis Javier Merino Morán
9dadb7b562 Fix regression preserving tcsh command prompt
Commit c3b3ef19 introduced a regression when invoking the
clear-history-and-reset action.  While RIS (Reset to Initial State) is
specified in DEC STD-070 as homing the cursor, konsole has grown some
hacks in the name of usability to preserve the command prompt line.

For a long time, it has sent two SIGWINCH with changed sizes after clear
and reset actions to force the shell to redraw the prompt (see d346a2cc,
temporarily disabled on 5d61b69e and re-added on 82778e87), which works
for bash, zsh, ksh, ...

tcsh doesn't redraw its prompt on SIGWINCH, but commit b8e96bcd modified
Screen::refresh() so instead of clearing the entire screen and homing
the cursor, it scrolled up everything but the last (usually the prompt)
line.

So, keep that last hack when called from clear-history-and-reset, and
behave as specified on DEC STD-070 otherwise.

Note that other ways of clearing the screen don't need hacks, e.g.
Ctrl-L, if handled at all, is handled by the shell, which then redraws
its prompt.  Calling "clear" or invoking "printf '\ec'" will result in
the shell redrawing its prompt in the usual way.

BUG: 453568
2022-05-16 22:51:53 +00:00
Georg Gadinger
45a38cb4b8 SessionController: fix crash when closing a session within a KPart on macOS
otherwise the popup menu will be cleaned up by the QScopedPointer
too early for macOS, apparently...
2022-03-09 07:53:59 +00:00
Tomaz Canabrava
a227af9d6f Remove unused includes 2022-02-05 15:13:58 +00:00
Tomaz Canabrava
913a1acee6 Use KIO::OpenFileManagerWindowJob
This is also not optimal because only two file browsers
implements org.freedesktop.org/FileManager1

Missing filemanagers:
- Konqueror
- Krusader
- Thunar

But at least is freedesktop.org accepted
2022-02-05 15:13:58 +00:00
Tomaz Canabrava
43763804cc Try to launch via DBus - as there is a API for selecting files
If that fails, then manually call dolphin
Currently only Dolphin and Nautilus supports that API call.
2022-02-05 15:13:58 +00:00
Tomaz Canabrava
a158926ae8 Launch dolphin on "Open With File Manager" under a file 2022-02-05 15:13:58 +00:00
Tomaz Canabrava
b3eb91d3f7 Store the current hotspot under mouse
This is important if the actions need to access it later on
2022-02-05 15:13:58 +00:00
Kurt Hindenburg
465c89d5c4 Add KIO version checks for insertOpenWithActionsTo()
void KFileItemActions::insertOpenWithActionsTo(QAction*, QMenu*,
const QString) requires KF 5.78 while
void KFileItemActions::insertOpenWithActionsTo (QAction*, QMenu*,
const QStringList) requires KF 5.82.  For any KF version earlier, use
void KFileItemActions::addOpenWithActionsTo(QMenu*, const QString)

Fixes build on older systems after
https://invent.kde.org/utilities/konsole/-/merge_requests/527
2022-01-14 12:43:39 -05:00
Luis Javier Merino Morán
28bfbf1a9f Pass widget again to monitoring KNotifications
9f656939 introduced the possibility of showing a session in multiple
views, something which is no longer supported.  In doing so, it started
passing QApplication::activeWindow(), instead of TEWidget (nowadays
TerminalDisplay) to KNotification.

7592e894 split notifications for focused/unfocused terminals.
Unfortunately, QApplication::activeWindow() returns nothing for unmapped
windows, which results in issues when notifications are configured to
mark the task bar entry or run a command with %w/%t substitutions (for
window id and window title).

BUG: 443117
2022-01-11 15:57:29 +00:00
Tomaz Canabrava
1fa81f4e6e Remove random german variable name 2021-12-29 17:20:57 +00:00
Tomaz Canabrava
4503e7ef24 Do not delete the Open With action
But change the title so it matches what we want to do
2021-12-29 16:05:37 +00:00
Tomaz Canabrava
38bb7aa285 Remove Ghost Entries of the Open Folder With
There were two bugs with the previous implementation
one is that it didn't took in consideration the
Profile -> Mouse -> Advanced -> Underline Files
With that enabled, right click on the name of the folder
would give you a Open Folder With entry, so we would
end with two actions.

The other bug also triggered when that setting is enabled:
we never marked the Open Folder With for removal, after
inserting the menu for the underlined file.
2021-12-29 13:30:08 +00:00
Jan Blackquill
8022b26c3b Add ability to Open With the current working directory
This makes it convenient to open programs like VSCode in the current terminal window.
2021-12-28 11:14:14 +00:00
Luis Javier Merino Morán
5919c1fd0a Don't get the selection to check if it is empty
Every time the selection is changed, the selection text is retrieved to
check whether to enable or disable the copy actions. Besides that, the
selection text is also used for the web search context menu entries.

Better just check if the selection is empty and make a note that the
selection changed, so the next time the context menu is invoked it can
retrieve the current selection text, which should happen much less often
than selection changes.
2021-12-28 10:59:33 +00:00
Martin T. H. Sandsmark
1ee961e4e2 add config option for whether mouse tracking should be enabled by default 2021-11-24 14:55:00 +00:00
Martin T. H. Sandsmark
fb35320cdc add action to disable/enable mouse tracking 2021-11-24 14:55:00 +00:00
Kurt Hindenburg
13b2ed6697 Comment spelling corrections 2021-11-20 22:14:01 -05:00
Fushan Wen
49ccf099c1 Make "Find Next/Previous" icons in Edit menu consistent with those in the search bar
There is an inconsistence in "Find Next/Previous" icons in Edit menu and
the search bar. Make sure they are consistent whenever "Search backwards"
is checked or not.

BUG: 443244
2021-10-07 14:33:08 +00:00
Ahmad Samir
d1c826adc8 Tweak formatting after running clang-format
GIT_SILENT
2021-09-06 12:51:53 +02:00
Ahmad Samir
97569b764c Run clang-format on the whole repo
Also install the relevant git hook.

GIT_SILENT
2021-09-06 12:51:39 +02:00
Ahmad Samir
e3a5c10bb6 Make HotSpot::setupMenu() return a list of the added actions
Useful when removing the open-with actions from the session menu before
adding new ones.
2021-09-02 22:32:36 +02:00
Ahmad Samir
40cf8519d7 For the fallback profile change the menu text to "Create New Profile"
This is less confusing; also matches what the code actually does.

BUG: 440885
FIXED-IN: 21.12
2021-08-31 23:47:11 +00:00
Ahmad Samir
4cab54d2bb Don't connect more slots to EditProfileDialog::accepted() signal
This is similar to commit c413d543c1, EditProfileDialog's base class
(KPageDialog) already connects OK button clicked signal to accepted() signal;
creating another connection to accepted() in SessionController (which
creates the EditProfileDialog object), means the code will be run twice, not
ideal. Instead put the logic in EditProfileDialog::save() which is called by
the EditProfileDialog::accept() slot.

The same goes when ProfileSettings creates an EditProfileDialog.
2021-08-02 15:47:29 +00:00
Jonah Brüchert
4a5e7a5644 Revert "TerminalDisplay: Move out common pasting related code"
This reverts commit 8e8b924353.
2021-07-06 21:15:06 +02:00
Jonah Brüchert
8e8b924353 TerminalDisplay: Move out common pasting related code 2021-06-24 08:39:46 +00:00
Ahmad Samir
4ef7296b94 General code cleanup
- Add a type alias for QPointer<Session>
- Use TerminalDisplay::setSessionController() as early as possible
- Use Screen::setCurrentTerminalDisplay() in TerminalDisplay::mousePressEvent(),
  this matches what's being done in keyPressEvent()
- Add convenience function TerminalDisplay::currentSession()
- More const
2021-06-22 11:52:06 +02:00
Ahmad Samir
e805f086fe Change EditProfileDialog window title when creating a new profile
Now when creating a new profile, the title will be "Create new profile",
this is less confusing when the user tries to edit e.g. the Fallback profile,
which in effect will create a new profile as the Fallback one is immutable.
2021-04-04 14:40:30 +00:00
Ahmad Samir
94505d94d4 Make the "Edit Current Profile" dialog modal
This should prevent opening two instance of the EditProfileDialog in the
same process, i.e. if "run all konsole windows in a single process" option is:
- Enabled, then opening the dialog will block user interaction with all
  other konsole windows (including tabs).
- Disabled, then open the dialog will block user interactin with all
  other tabs in the same window

This simplifies the code since it checked if such a dialog was open
somewhere else to prevent crashes.
2021-03-23 16:55:35 +00:00
Ahmad Samir
61a7947adb Show dialogs with show() rather than exec()
exec() creates a nested eventloop, which could lead to some nasty
crashes ...etc.

ProfileSettings::editSelected(): since the dialog is modal, the user
can't interact with the konsole window at all, so no chance of opening
another instance of the EditProfileDialog.
2021-03-23 16:55:35 +00:00
Ahmad Samir
5ab8423139 Don't edit the Fallback profile, instead create a new one
This is a first step in simplifying the code; since the Fallback profile
doesn't have a file on disk, it's basically a corner-case that we have to
babysit in various places in the code.

Now when the user tries to "Edit current profile", if it's the Fallback
profile, a new profile is created, with a unique name "Profile 1",
"Profile 2" ...etc. This is similar to using the "New" button in the
ProfileSettings dialog.
2021-03-18 02:47:57 +00:00
Ahmad Samir
d06ea23903 Use Q_EMIT instead of emit
In C++20 there are new classes that have member functions named emit().
c.f.:
https://lists.qt-project.org/pipermail/development/2020-February/038812.html
https://en.cppreference.com/w/cpp/io/basic_osyncstream/emit

A similar change was done in the Frameworks:
https://invent.kde.org/frameworks/kio/-/merge_requests/315
2021-02-15 23:52:07 +00:00
Christoph Cullmann
0bc553fd51 delete client builder before d-pointer of KXMLGUIClient is killed
BUG: 432421
2021-02-06 09:43:49 +00:00
Carlos Alves
5bbb433494 Adding version checks to deprecated functions
Macros to check frameworks versions and switch from deprecated functions
to newer versions.
KProcess: pid -> processId
KCodecAction: setDelayed -> setPopupMode
KActionMenu: triggered -> codecTriggered
2021-01-03 07:31:52 -03:00
Carlos Alves
343d8595d7 Remove deprecated functions
Konsole minimum required version is QT 5.14 and KF5 5.71, there is no
need to keep support for those deprecated functions.
2021-01-02 14:12:09 +00:00