diff options
| author | Sergey Katunin <[email protected]> | 2026-04-24 22:24:47 +0300 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-05-04 08:42:35 +0000 |
| commit | 173794ce15620aa0c673464f532cfd67f55ab278 (patch) | |
| tree | fb478e559ed82ce125ccd075a2b3b4b6a904e8db /src | |
| parent | 02a754e91c47a690b7be37551cb09f353da238a1 (diff) | |
Restore session if this is the first instance
1. Restore session if this is the first instance
even with "new-window" option.
Otherwise, if Dolphin has not been opened before,
and a program (such as browsers or Kate) that
launch Dolphin with "new-window" option will
start Dolphin, it opens only with one tab and
closes the user's previous session.
With this patch, the behavior is similar to
how the first instance of browsers opens
with setting for tab recovery enabled.
Also restore sessions if this is restoring
multiple instances with session restoration
after reboot enabled.
2. Dolphin should not restore all tabs for
additional instances.
This is especially noticeable if the
"Keep a single Dolphin window, opening new folders
in tabs" checkbox is turned off, and when the
Dolphin window is already open (with several tabs),
folders from the desktop (plasmashell) are opened
by double-clicking. Desktop opens a new Dolphin
window with the tabs restored and an open folder
at the end.
BUG: 464693
CCBUG: 448707
CCBUG: 469271
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index eeb01854b..1ef608193 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -232,14 +232,16 @@ int main(int argc, char **argv) } // Only restore session if: - // 1. Not explicitly opening a new instance - // 2. The "remember state" setting is enabled or session restoration after + // 1. The "remember state" setting is enabled or session restoration after // reboot is in use + // 2. This is the first instance or restoring multiple instances with + // session restoration after reboot enabled // 3. There is a session available to restore - if (!parser.isSet(QStringLiteral("new-window")) && (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs())) { + if (app.isSessionRestored() || GeneralSettings::rememberOpenedTabs()) { // Get saved state data for the last-closed Dolphin instance const QString serviceName = QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid()); - if (Dolphin::dolphinGuiInstances(serviceName).size() > 0) { + const auto instancesCount = Dolphin::dolphinGuiInstances(serviceName).size(); + if (instancesCount == 1 || (app.isSessionRestored() && instancesCount > 0)) { const QString className = KXmlGuiWindow::classNameOfToplevel(1); if (className == QLatin1String("DolphinMainWindow")) { mainWindow->restore(1); |
