Commit Graph

337 Commits

Author SHA1 Message Date
Nate Graham
9acc879b64 Make wasWindowGeometrySaved() function consider new key format
The key format is changing in
https://invent.kde.org/frameworks/kconfig/-/merge_requests/184; take
that into account here.

Currently this function copies code from KWindowConfig, which is not
ideal; a more robust solution would be to expose the config file key
value publicly using a function in KWindowConfig that Konsole can call.
That's KF6 material, though, so for now, let's fix this issue by simply
supporting the new key format as well as the old one.
2023-02-26 00:23:12 +00:00
Nicolas Fella
11231f7b02 Port away from deprecated KWindowSystem API
And better separate X11-specific parts
2023-02-15 22:45:14 +00:00
Nicolas Fella
599d44b5bf Port away from deprecated KWindowSystem::compositingActive 2023-02-15 22:45:14 +00:00
Andrey Butirsky
b8325d2f18 fixup! Adopt KHamburgerMenu 2022-11-29 23:03:54 +04:00
Nate Graham
b04265e9fa Adopt KHamburgerMenu
It's amazing!

BUG: 439895
FIXED-IN: 23.04
2022-11-29 23:03:54 +04:00
Vlad Zahorodnii
d54475b19d Make MainWindow::wasWindowGeometrySaved() more efficient 2022-11-15 09:02:48 +00:00
Vlad Zahorodnii
05892060f1 Fix geometry restoration check
MainWindow::wasWindowGeometrySaved() doesn't take into account the currently connected outputs. So
when Konsole starts after hotplugging a new output, wasWindowGeometrySaved() will erroneously return
true and resize(sizeHint()) in MainWindow::showEvent() won't be called thus resulting in Konsole
starting with wrong size.

This change makes Konsole take the current output layout into account when deciding whether the
geometry has been restored (logic was copied from KWindowConfig), however it indicates that we have
some fundamental issues in KMainWindow or KWindowConfig as it's a really messy way to determine
whether the previous state has been properly restored.

BUG: 460428
2022-11-15 09:02:48 +00:00
Nicolas Fella
0c72a3fe68 Don't manually unminimize window before showing close confirmation dialog
Somwhat ironically removing this fixes the main window appearing together with the confirmation dialog when the window is closed while minimized
2022-11-08 01:28:52 +00:00
Friedrich W. H. Kossebau
3213a17798 Port away from deprecated KMessageBox Yes/No API
Using "Yes" & "No" text labels on dialog buttons is discouraged by not
only the KDE HIG these days. Yet the legacy API of KMessageBox was
using Yes & No as terms in its API, conflicting with what the HIG
recommends and trapping HIG-unaware developers into thinking to use
Yes & No buttons.

New substitute API uses the term "action" instead, matching the concept
proposed by the KDE HIG.

GIT_SILENT
2022-10-16 04:11:14 +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
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
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
fe64881f13 Make use of new colorful preferences icons in settings windows
CCBUG: 414214
CCBUG: 414215
CCBUG: 414213
2021-12-17 09:04:20 -07:00
Nate Graham
c572e2a46e Merge branch 'release/21.12' 2021-12-01 16:22:13 -07:00
Nate Graham
4a3d0ce4eb Open bookmarks toolbar button on click; don't require press-and-hold
BUG: 446339
FIXED-IN: 21.12
2021-12-01 16:21:08 -07:00
Ahmad Samir
97f949eea0 SSHManagerPlugin: pass MainWindow* as an arg to activeViewChanged()
Also use a std::vector to hold the plugins associated with a MainWindow,
implicit sharing isn't needed in this use-case.
2021-11-22 14:49:27 +00:00
Kurt Hindenburg
13b2ed6697 Comment spelling corrections 2021-11-20 22:14:01 -05:00
Ahmad Samir
c24a0876f7 Optimise saving profile shortcuts
- Call ProfileSettings::slotAccepted() when the parent ConfigurationDialog
  is accepted, so that ProfileManager::saveSettings() is called
- don't delete the ProfileSettings dialog on accept, it'll be destroyed when
  the parent ConfigurationDialog is destroyed
- save the profiles' shorcuts if they were actually changed

With this commit and the previous one, there is no need for ~Part() or
~Application() to call saveSettings(), shorcuts settings are saved when
the ProfileSettings dialog is accepted and saving the default profile is
done in setDefaultProfile(). This fixes an issue where changing e.g. the
default profile is only saved to the konsolerc file when the main window is
closed.
2021-10-21 20:05:20 +00:00
Ahmad Samir
99346bf1b9 Minor changes in AppColorSchemeChooser
- refactor the code
- remove redundant includes
- change the string used in the GUI to "window color scheme", to differentiate
  between it and the terminal color schemes
2021-09-22 14:41:11 +02:00
Maximilien DI DIO
dc8ad83043 feat(AppColorSchemeChooser): User is able to change konsole color scheme
Add AppColorSchemeChooser class which use KColorSchemeManager to change
konsole color scheme. Inspired by KateColorSchemeChooser wrote by
Zhigalin Alexander <alexander@zhigalin.tk>.
2021-09-22 14:37:35 +02:00
Ahmad Samir
fb7ff04d15 Fix initial window size again; also always set Qt::WA_NativeWindow
The Qt::WA_NativeWindow attribute is need so that windowHandle() doesn't
return 0, since windowHandle() is used in two places now in the code, just
always set it.

When rememberWindowSize() is false, override the Window-Maximized config
key, which maximizes the window initially.

To test:
- unset "remember window size"
- close the window and make sure the config has been saved to konsolerc
- open konsole, keep the window unmaximized, close, open -> size is restored
- open konsole, maximize the window, close, open, the window is maximized
  even when rememberWindowSize() is false
2021-09-20 22:47:23 +00:00
Eugene Popov
897435e5fb Use applyMainWindowSettings instead of showEvent to apply menubar visibility 2021-09-21 00:12:23 +03:00
Eugene Popov
5fc0c180f1 Use one option to control menubar visibility
Currently there are two options to control menubar visibility: the first in the menu and the second in the preferences dialog, moreover the second option makes the changes persistent. This MR removes the second option (from the preferences dialog) and makes the first option (from the menu) make the changes persistent.

BUG: 440328
2021-09-20 18:54:38 +00:00
Ahmad Samir
e587f9dcaa Rename SaveGeometryOnExit to RememberWindowSize
And migrate the old key name to the new one.
2021-09-15 20:26:25 +00:00
Ahmad Samir
b641e06668 Reimplement KMainWindow::applyMainWindowSettings() to override menubar state 2021-09-15 20:26:25 +00:00
Ahmad Samir
3177c9ef8a Always save the window state and geometry
This includes the toolbar/menubar/dockwidget states (i.e. the State= config
key), and the window geometry. I was wrong to think the State= key included
the window geometry.

Depending on the "remeber window size" setting, we can apply the size saved
in the config file or the size from the profile settings (lines x columns),
which is included in MainWindow::sizeHint().

BUG: 442252
FIXED-IN: 21.12
2021-09-15 20:26:25 +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
Nathan Sprangers
fed1a9d2cf Fix missing new-tab menu when only one profile exists
Sub-menu will always be displayed in "File>New Tab" and "New Tab" button,
even if there is only one profile to display (the built-in default).

This fixes not being able to create a new tab from "File>New Tab" menu and
long-pressing on the new tab toolbar button.

BUG: 436264
2021-09-05 15:49:04 -04:00
Ahmad Samir
68f1505d5f Don't resize window when switching virtual desktops in OpenBox
It looks like switching virtual desktops in OpenBox invokes a show event
(this doesn't happen while running Plasma).

The code in MainWindow::showEvent() should only be run once on first show,
so guard it with a bool member.

BUG: 441610
FIXED-IN: 21.08.1
2021-08-31 21:04:35 +00: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
414f933fe5 Remove statusbar related code
It shouldn't be created any more since we don't pass the
KXmlGuiWindow::StatusBar flag when using KXmlGuiWindow::setupGUI().

GIT_SILENT
2021-08-02 15:28:09 +00:00
Ahmad Samir
bb7dd804b2 Fix MainWindow size when there is no saved size
The very first time a user runs Konsole, where is no konsolerc file in $HOME,
there is no saved size to restore, instead use the sizeHint(), which ideally
will be the size set in the default profile (based on lines/columns setting).

CCBUG: 437791
2021-08-02 15:28:09 +00:00
Ahmad Samir
090356661c Fix KXmlGUI toolbars; and Konsole MainWindow size
Call setupGUI(), which will call createGUI (since we set the
KXmlGuiWindow::Create flag), omit the StatusBar flag since we don't have a
statusbar and don't want the "Show StatusBar" menu action.

TabbedViewContainer::sizeHint() calculates an optimum size for itself,
including the sizes of its child widgets; added in efb621d091 by
Mariusz Glebocki; following the code:
MainWindow creates a ViewManager
ViewManager creates a TabbedViewContainer and then a TerminalDisplay

which means that the first time TabbedViewContainer::sizeHint() is called
the TerminalDisplay widget size is 0, then TabbedViewContainer::sizeHint()
would return 0.

Which is why calling resize() in MainWindow was delayed to the showEvent(),
(and even delayed more by a QTimer::singleShot() call in Application),
at which point all the child widgets have been created and
MainWindow::sizeHint() (which logically takes into account the sizeHint()
of its child widgets) would return a sensible size.

CCBUG: 430036
CCBUG: 439339
BUG: 436471
2021-08-02 15:28:09 +00:00
Jonathan Riddell
129f511bcd initialise kcrash to ensure it gets linked 2021-07-26 11:43:16 +01:00
Ahmad Samir
a6b2bd5391 Fix crash when setting blur effect
Basically to use QWidget::windowHandle() to get a QWindow*, we need to first
set the Qt::WA_NativeWindow attribute on the QWidget. See:
https://phabricator.kde.org/D23108

BUG: 439871
FIXED-IN: 21.12
2021-07-23 16:06:51 +00:00
Kurt Hindenburg
19b83275b4 The non deprecated enableBlurBehind requires KWINDOWSYSTEM >= 5.82.0
Deprecated: Since 5.82, use enableBlurBehind(QWindow) overload.
2021-07-02 19:05:18 -04:00
Tomaz Canabrava
b43548b22c Prevent 1px sizehint when there is no preconfiguration
BUG: 437791
2021-06-30 13:18:12 +01:00
Tomaz Canabrava
2c1a4113e1 Implement a Base system for plugins within Konsole
This commit introduces a plugins sytem for konsole, so we can
extend the application without touching the core. Currently
there's a testcase plugin (in the next commit) that handles
ssh connections and will serve as a base introduction on how
to write plugins for konsole.

Things we need to keep in mind when developing a plugin for
konsole:
- We can have more than a mainwindow, so if the plugin creates
widgets, it needs to create the widget per window
- We can have multiple tabs / multiple TerminalDisplays so always
check what terminal display you are triggering the action (using
activeTerminalDisplay())

From the mainWindow you can get the activeTerminalDisplay, from
the terminalDisplay you can get the Session, the VT102Emulation and
the Screen.

Then you can go crazy.
2021-06-24 08:28:12 +00:00
Yuri Chornoivan
5369665aca Revert unrelated changes 2021-06-23 10:08:09 +03:00
Yuri Chornoivan
f2d7346b97 Updates and fixes for the manual 2021-06-23 09:56:35 +03:00
ivan tkachenko
fd5f08a37b Fix deprecation warning about KWindowEffects::enableBlurBehind overload 2021-06-18 10:59:27 +00:00
Ahmad Samir
e03a468075 Don't override profile icon in "New Tab" menu
We only need to set the favourite emblem for the default profile icon, for
other profiles, the profile icon is already set on the menu action.

Rename a lambda to a more meaningful name.

BUG: 437200
FIXED-IN: 21.08
2021-05-16 15:24:36 +02:00
Carlos Alves
49692c0f14 Fix crash showing Settings Dialog
When you open settings and close it, than open a new window, than
close the old window, the MainWindow with the settings will
delete the configDialog. If you try to open settings againg it crashes.

Fix is each MainWindow now has its own configDialog.

BUG: 436366
2021-05-01 13:02:28 -03:00
Nicolas Fella
562f8e444f Port from KIconLoader::loadIcon to KIconUtils::addOverlay + QIcon::fromTheme
This fixes the rendering on highdpi screens
2021-04-27 01:12:26 +02: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
Ahmad Samir
a59d9b8d7b Update the profiles list menu when the default profile is changed
Now the 'File->New Tab' menu is updated when the default profile is
changed, i.e. the action font is made bold and the favourites icon
emblem is added to the profile icon.

A call to menu()->setDefaultAction() has been removed, as I don't see
what it serves exactly in the current code.

Reported by khindenburg in:
https://invent.kde.org/utilities/konsole/-/merge_requests/351
2021-03-01 13:08:47 +02: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
Nate Graham
d22236c361 Fix "Remember window size" not working when unchecked
When this feature is turned off, it deletes some keys from Konsole's
config file. However this broke recently for two reasons:

1. The key names changed a few Frameworks releases ago
2. There are new keys that need to be deleted or else position gets
   restored too

This commit fixes that bug by updating the condition to delete all the
config keys required to make the off state for this feature work again.

BUG: 427610
FIXED-IN: 20.12.2
(cherry picked from commit 8fa1c4b508)
2021-01-20 10:25:44 -05: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