Commit Graph

421 Commits

Author SHA1 Message Date
Christoph Cullmann
02e4fbec97 Bundle more file in resources
make deployment easier; like katepart or okularpart the ideal
is that just the .so is enough to work

This is just the start, will need to bundle more parts.
At the moment even many keys don't work if you just bundle the part.
2024-06-05 22:18:19 +00:00
Christoph Cullmann
b94f2c5cde Disable DBus (and X11) on Windows/macOS/Android per default
Like Kate, one should not try to use DBus on platform that not
support it. At the moment we have hacks in the Craft blueprints
to avoid the worst, but not using it is much nicer.

If the user wants to compile it, we have a USE_DBUS CMake option.
2024-06-05 13:42:44 +00:00
Alfonso Murolo
b93f44a90e Fix hamburger menu/toolbar issues when splitting tabs
Preventing hamburger menu from being lost when splitting tabs,
and toolbar from being broken in split view in special case

BUG: 474848
2024-04-05 17:30:04 +00:00
Theodore Wang
f7732e33c4 Implements DBus methods for manipulation of splits
Methods implmented allow for:
1. retrieval of layout information encoded in a string
2. getting size proportions of a splitter's direct child widgets
3. setting the size proportions of a splitter's direct child widgets
4. simple splitting of a view horizontally or vertically
5. using existing widgets to create a splitter at a specified position under a splitter
6. moving an existing view to a specified position under a splitter
7. moving an existing splitter to a specified position under a splitter
8. switching focus to an existing view

See documentation in source files for more details.

BUG: 465448
2023-12-25 17:42:39 +00:00
Laurent Montel
73295a8557 Use std::as_const (we depend against c++17) 2023-10-27 05:52:51 +00:00
Juerd Waalboer
f012d1304f Add zoom-maximize feature to maximize with scaled font
This aims to duplicate the feature "scaled_zoom" of Terminator. This way
of expanding the current terminal is only useful for split views that
have both horizontal and vertical splits, i.e. where the individual
terminal view is smaller than the window in both directions.

The default shortcut is Ctrl+Shift+Z. It is usually bound to Redo, but
since there's no Undo or Redo in terminals, this doesn't actually clash
here.

The magic constant 0.97 comes from Terminator, although in Terminator
the scale factor is calculated using the new number of columns/lines
after resizing, while this commit bases the font size on the sizes in
pixels. In the commit message that introduced the magic value in
Terminator, it is explained as "just more natural", and it seems to work
here too, unlike the vertical magical constant of 1.05. This is all
mostly guesswork, though, as font sizes aren't an exact science - not
even the aspect ratio is guaranteerd to remain the same between font
sizes, just like the aspect ratio before and after maximizing could be
different in the terminal.
2023-10-13 18:01:00 +00:00
Friedrich W. H. Kossebau
451ed33d63 Add explicit moc includes to sources for moc-covered headers
* speeds up incremental builds as changes to a header will not always
  need the full mocs_compilation.cpp for all the target's headers rebuild,
  while having a moc file sourced into a source file only adds minor
  extra costs, due to small own code and the used headers usually
  already covered by the source file, being for the same class/struct
* seems to not slow down clean builds, due to empty mocs_compilation.cpp
  resulting in those quickly processed, while the minor extra cost of the
  sourced moc files does not outweigh that in summary.
  Measured times actually improved by some percent points.
  (ideally CMake would just skip empty mocs_compilation.cpp & its object
  file one day)
* enables compiler to see all methods of a class in same compilation unit
  to do some sanity checks
* potentially more inlining in general, due to more in the compilation unit
* allows to keep using more forward declarations in the header, as with the
  moc code being sourced into the cpp file there definitions can be ensured
  and often are already for the needs of the normal class methods
2023-07-28 12:17:12 +00:00
Magno Lomardo
d3fa26f65b Add the context menu options to split the view left-right and top-bottom
FEATURE: 415724
2023-03-06 22:41:41 +00:00
Waqar Ahmed
c0fd48e950 Fix crash when detaching tab on windows 2023-03-02 09:19:05 +00:00
Matan Ziv-Av
a26db113b9 temp 2023-01-27 18:07:35 +02:00
Matan Ziv-Av
880793f9f4 When splitting view from the next tab, keep the current focused session 2023-01-27 18:07:35 +02:00
Matan Ziv-Av
b9ab961bad Add actions to split view without creating a new session
Split horizontal/vertical/auto from next tab acts like the usual split view
but takes the first session of the next tab, instead of creating a new
session. This allows for merging two separate tabs into a single tab.
2023-01-27 18:07:35 +02:00
Matan Ziv-Av
f5f440484d Include last command exit code in bash PS1 for semantic integration. 2022-10-21 23:20:58 +00:00
Jonathan Marten
d09a311a4d Save/Load Tab Layout: Format text according to HIG
Title case for action text.
Add "..." to action text (a mandatory dialogue follows).
Action name as dialogue title.
2022-09-30 17:05:16 +00:00
Matan Ziv-Av
24cc94d5fb Allow for showing line numbers
As with semantic hints, the line numbers may be displayed always, never
or when URL hints are shown.
2022-09-05 07:06:49 +00:00
Matan Ziv-Av
274ebb9887 Add keyboard shortcut for toggling display of semantic hints 2022-09-05 07:06:49 +00:00
William Brawner
de694e19c6 Add action to automatically split terminal view 2022-08-24 19:56:00 -06:00
Kurt Hindenburg
94745b55b8 Cancelling save/loadLayoutFile dialog should not show an error dialog
Also, add .json to save filename if missing.
2022-08-05 17:59:25 -04:00
Kurt Hindenburg
c296be188c Add i18nc KUIT contexts 2022-08-05 16:39:58 -04:00
Friedrich W. H. Kossebau
17796fb8f4 Port away from deprecated KMessageBox::sorry
GIT_SILENT
2022-07-22 18:32:31 +00:00
Matan Ziv-Av
464a9fdf1a Add action to setup semantic shell integration in bash
Default shortcut: ctrl-alt-]
2022-07-12 11:49:24 +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
Georg Gadinger
9b0721a2e4 Fix split-view shortcuts
The split-view actions define a shortcut using `Konsole::ACCEL`, which
since !609 expands to `Qt::CTRL | Qt::SHIFT` on systems that aren't
macOS.  This breaks the shortcut for the split-view actions however as
`Qt::Key_ParenLeft` and `Qt::Key_ParenRight` do not work with the
`Qt::SHIFT` modifier.

Using `Qt::CTRL` (Cmd on macOS, Ctrl everywhere else) as the base
accelerator for these two actions makes splitting views work again as
expected.
2022-07-02 14:34:12 +00: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
Nate Graham
2d70ab5591 Fix Ctrl+PageUp/PageDown keyboard shortcuts
This got broken in 3b58e4a9ac when
multiple shortcut sequences were added to a single QKeySequence object,
rather than having a list with multiple QKeySequences in it. As a
result, the single QKeySequence object discarded all sequences after
the first, so the Ctrl+PageUp/PageDown shortcuts got discarded.
2022-06-02 07:36:50 -06: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
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
Kamay Xutax
8663b4be86 Be able to resize the splits to the same size.
Here how it looks like: https://imgur.com/a/uaMQvT6

Before, it was impossible to resize the splits
with the same size in case they were manually resized.

I have added a new button menu for doing so:
in View -> Split View -> Equal size to all views.

First I wanted to make this as a plugin,
but since I thought it could make splits a bit more useful,
I decided to merge it not as a plugin but internally.

GUI: Menu -> View -> Split View -> Equal size to all views
CHANGELOG: Added equal size to all split views.
2022-05-23 14:50:05 +00:00
Luis Javier Merino Morán
a07c45949c Switch focus when closing inactive tab with splits
When closing an inactive tab with splits, focusAnotherTerminal() was not
transferring focus to any TerminalDisplay, resulting in having no active
session on ViewManager, which would then crash when splitting the view.

BUG: 446830
2022-01-12 18:48:46 +00:00
Nathan Sprangers
29977a2364 Disconnect view/session after drag-and-drop
Adds a missing signal/slot connection for when a split-view is drag-and-
dropped to a new window. Use an existing method to handle it the same
way as drag-and-dropping or detaching a tab.

BUG: 442238
2021-11-15 14:02:05 +00:00
Nathan Sprangers
2ab70959cc Improve maximized split-view behavior
Maximized views must be un-maximized before certain actions:
 - detach view
 - split view
 - move to new tab
 - close

This commit fixes the toggle state getting out of sync after those
actions, adds the un-maximize step for splitting a maximized view,
and reduces code duplication by adding ViewSplitter::clearMaximized(),

For now, clearMaximized() does need to be called manually: we want the
display restored before the removal, but ViewSplitter handles removals
after the fact with QEvent::ChildRemoved.
2021-11-15 14:02:05 +00:00
Nathan Sprangers
822c48c225 Enable/Disable "detach-view" correctly after DnD
Enables detach-view in the target window if dropping creates the first split.

Disables in the original window if one view is left after DnD.
2021-11-15 14:02:05 +00:00
Nathan Sprangers
aa6193b0a8 Disable "detach-tab" after closing others
Other signals are received too early when closing tabs.
ViewContainer::viewRemoved is received after the tab count has been
updated.

Protect against the "detach-tab" action when only one left.

Fixes the following behavior:
 - Create two tabs
 - Close one tab
 - Detach the remaining tab through menu or shortcut
 - The original window is blank - no terminal display. Adding a tab
   to it crashes
2021-11-15 14:02:05 +00:00
Martin T. H. Sandsmark
d33545887d Use smart pointers for color schemes.
Also uses weak pointers in the cache in ViewManager, to avoid having
them loaded for longer than necessary.

It takes less than a millisecond to load them, and it is nice to pick up
new changes from disk. But we don't want to do it for those currently
used by code elsewhere, so we still cache them with a weak_ptr that will
expire once all other code is done with it.
2021-11-15 13:39:45 +00:00
Nathan Sprangers
217ed2762b Move splitview toolbar buttons into a button menu
The buttons have very long labels, which made the window too wide
or caused the toolbar to display a disclosure button to show all the
options.

This moves those buttons into a "Split View" toolbar button, which
fixes those issues and looks much nicer.

BUG: 437555
2021-09-15 20:19:05 +00: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
e693f2d7f1 The default navigation method should be TabbedNavigation
TabbedNavigation is when we have a MainWindow, i.e. the typical use case;
whereas NoNavigation is when using Konsole Part. The code in Part calls
setNavigationMethod(NoNavigation), so things should work as before.

I made a wrong assumption that TabbedNavigation was already the default.

CCBUG: 432077
2021-09-01 11:38:29 +02:00
Ahmad Samir
2684bc7fa5 Only emit empty() in SessionFinished() when in TabbedNavigation mode
empty() is emitted so that MainWindow calls close() and we get rid of the
colours-flashing bug when closing the last session/tab in a window, see
commit bbec72250d. However all that isn't relevant when we are in
konsole Part mode, where there are no tabs or MainWindows.

This fixes a crash in Dolphin when closing its window while the embedded
Konsole Part is open. The crash would happen as calling
ViewContainer::currentTabViewCount() would end up in the ViewSplitter code
path, which is no-op in Konsole Part.

To test:
- Open dolphin, make sure the terminal panel isn't open to begin with
- open the terminal panel
- close the dolphin window while the terminal panel is open

BUG: 441206
FIXED-IN: 21.08.1
2021-08-22 20:10:32 +02:00
Ahmad Samir
4a3cab03f5 When closing a session, don't close the whole window if there are splits
When closing a session, we check if that is the last tab, and make the code
close the whole window, but we also need to make sure it's the last view,
i.e. no split views.

CCBUG: 440976
FIXED-IN: 21.12
2021-08-15 20:57:48 +02:00
Ahmad Samir
bbec72250d Prevent window "flashing" when closing the last session
There are two scenarios when closing a window:
A) clicking the close button on the title bar (or Ctrl+Shift+Q):
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()
~Session()

B) closing the last session/tab in a window:
SessionController::sessionFinished()
~Session()
~TerminalDisplay()
~TabbedViewContainer()
~MainWindow()
~ViewManager()

the issue with the second case is that the TerminalDisplay is torn down
first, which exposes the TabbedViewContainer widget, the latter has the same
Qt::Window colour as the system colour scheme window background colour, if
you're using a dark terminal colour scheme and a light-coloured system colour
scheme, you could see some "flashing" when you close the last session with
e.g. Ctrl+D.

To fix this, in sessionFinished() check if TabbedViewContainer::count() is
1 (i.e. closing last tab/session), and emit the empty() signal in that case,
which is connected to MainwWindow::close(), then the order of tear down
becomes:
SessionController::sessionFinished()
~Session()
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()

BUG: 432077
FIXED-IN: 21.12
2021-08-12 14:25:03 +02:00
Ahmad Samir
39d3437df9 Fix crash when closing a tab using the close button
Looking at the crash backtraces from the bug reports, it seems this is what
happens, when you have two tabs open, then click the close button on the
non-current tab:
  - QTabBar::currentChanged() is emitted, the TerminalDisplay pointer is
    still not null at this point (the code checks for that)
  - TabbedViewContainer::currentTabChanged()
  - TabbedViewContainer::activeViewChanged()
  - ViewManager::activateView(), at this point the TerminalDisplay pointer
    could be null, which then crashes when we call Widget::setFocus()

BUG: 411962
FIXED-IN: 21.12
2021-08-05 09:17:19 +00:00
Lucas Biaggi
29e86ddeb7 Add ability to load/save session layouts(split views) and add default layouts
Add three layouts to the toolbar; add --layout <file> to the command line.
The 3 defaults layouts are 2x2, 2x1, 1x2

GUI:
2021-04-24 21:30:11 +00:00
Carlos Alves
34f85cecea Fix Bookmark all tabs as a folder crash
The list of active sessions needs to be refreshed when a session is
destroyed. It was being refreshed only on creation.

BUG: 432327
FIXED-IN: 21.04
2021-03-07 20:50:10 +00:00
Jonathan Marten
a3c318dcc9 Fix view splitter actions not being updated when a view is closed
This happens because in ViewManager::sessionFinished(),
the 'view' is delayed deleted which means that it is not removed
from its containing splitter until the next event.  However,
toggleActionsBasedOnState() is called immediately which makes its
decisions based on the current splitter state with the view still
present.

In order to avoid any possible object lifetime issues caused by
changing the way the view is deleted, or trying to remove it from the
view immediately, the call of toggleActionsBasedOnState() is instead
delayed until the view has been destroyed (and therefore removed from
its splitter).
2021-02-21 18:58:24 +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
Tomaz Canabrava
050ca17b54 Remove unused signal 2021-01-25 09:21:21 +00:00
Christian Schärf
c695c9b206 Move connecting and disconnecting TerminalDisplays into separate function to avoid code duplication. 2021-01-02 14:26:41 +00:00
Tomaz Canabrava
dcb23b6174 Revert "Remove RandomSeed on TerminalDisplay."
This reverts commit fa4bd94d84.

Crashes PartTest
2020-12-14 14:44:51 +00:00
Gustavo Carneiro
fa4bd94d84 Remove RandomSeed on TerminalDisplay. 2020-12-14 14:26:07 +00:00
Edwin Pujols
5729e67120 ViewManager: Fix warnings about mixing operators. 2020-12-10 18:22:10 -04:00