┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/global.cpp
diff options
context:
space:
mode:
authorNate Graham <[email protected]>2019-07-19 11:52:12 -0600
committerNate Graham <[email protected]>2020-04-26 12:14:56 -0600
commitcaf2fe1c4388420dc05c00c71b3d6d0617c6d424 (patch)
treeda2f1cbf7c9cc21d262d5a4f8cf009faa7c395f0 /src/global.cpp
parentb0ad83eeeed9f484bc034103d6e3df1893b034dd (diff)
Add an option to show tabs from last time when Dolphin starts
Summary: All modern web browsers offer a function to show tabs from last time when a browser starts, and many apps today restore their prior state when they're launched. This patch implements thatfunctionality as an option and turns it on by default. The settings window is accordingly adjusted to be clear about what applies when: {F7681752} FEATURE: 413564 FIXED-IN: 20.08.0 Depends on D25106 Depends on D25219 Test Plan: With the new setting turned off: - No behavioral changes at all With the new setting turned on: - When launched from the GUI or CLI without any URLs, dolphin restores session - When rebooting with Dolphin open, it restores session normally after the system comes back (i.e. no behavioral change here) - When launched with URLs, Dolphin window is opened showing those URLs instead of restoring session - When Dolphin is already running and a new window is opened, that new window shows a single tab with the same URL as was visible in the previously-open Dolphin instance (i.e. no behavioral change here) - "Open Containing folder" functionality in other apps works regardless of whether or not Dolphin is running Reviewers: #dolphin, #vdg, feverfew, meven, elvisangelaccio, ndavis Reviewed By: #dolphin, #vdg, feverfew, elvisangelaccio, ndavis Subscribers: davidedmundson, ndavis, intika, feverfew, kfm-devel, ngraham, broulik, #dolphin Tags: #dolphin Differential Revision: https://phabricator.kde.org/D11382
Diffstat (limited to 'src/global.cpp')
-rw-r--r--src/global.cpp66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/global.cpp b/src/global.cpp
index 19f43e06b..32a2d4ebb 100644
--- a/src/global.cpp
+++ b/src/global.cpp
@@ -78,36 +78,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
return false;
}
- QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
- if (!preferredService.isEmpty()) {
- QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
- new OrgKdeDolphinMainWindowInterface(preferredService,
- QStringLiteral("/dolphin/Dolphin_1"),
- QDBusConnection::sessionBus()));
- if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
- dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
- }
- }
-
- // Look for dolphin instances among all available dbus services.
- const QStringList dbusServices = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
- // Don't match the service without trailing "-" (unique instance)
- const QString pattern = QStringLiteral("org.kde.dolphin-");
- // Don't match the pid without leading "-"
- const QString myPid = QLatin1Char('-') + QString::number(QCoreApplication::applicationPid());
- for (const QString& service : dbusServices) {
- if (service.startsWith(pattern) && !service.endsWith(myPid)) {
- // Check if instance can handle our URLs
- QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
- new OrgKdeDolphinMainWindowInterface(service,
- QStringLiteral("/dolphin/Dolphin_1"),
- QDBusConnection::sessionBus()));
- if (interface->isValid() && !interface->lastError().isValid()) {
- dolphinInterfaces.append(qMakePair(interface, QStringList()));
- }
- }
- }
-
+ auto dolphinInterfaces = dolphinGuiInstances(preferredService);
if (dolphinInterfaces.isEmpty()) {
return false;
}
@@ -145,3 +116,38 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
}
return attached;
}
+
+QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Dolphin::dolphinGuiInstances(const QString& preferredService)
+{
+ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> dolphinInterfaces;
+ if (!preferredService.isEmpty()) {
+ QSharedPointer<OrgKdeDolphinMainWindowInterface> preferredInterface(
+ new OrgKdeDolphinMainWindowInterface(preferredService,
+ QStringLiteral("/dolphin/Dolphin_1"),
+ QDBusConnection::sessionBus()));
+ if (preferredInterface->isValid() && !preferredInterface->lastError().isValid()) {
+ dolphinInterfaces.append(qMakePair(preferredInterface, QStringList()));
+ }
+ }
+
+ // Look for dolphin instances among all available dbus services.
+ const QStringList dbusServices = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
+ // Don't match the service without trailing "-" (unique instance)
+ const QString pattern = QStringLiteral("org.kde.dolphin-");
+ // Don't match the pid without leading "-"
+ const QString myPid = QLatin1Char('-') + QString::number(QCoreApplication::applicationPid());
+ for (const QString& service : dbusServices) {
+ if (service.startsWith(pattern) && !service.endsWith(myPid)) {
+ // Check if instance can handle our URLs
+ QSharedPointer<OrgKdeDolphinMainWindowInterface> interface(
+ new OrgKdeDolphinMainWindowInterface(service,
+ QStringLiteral("/dolphin/Dolphin_1"),
+ QDBusConnection::sessionBus()));
+ if (interface->isValid() && !interface->lastError().isValid()) {
+ dolphinInterfaces.append(qMakePair(interface, QStringList()));
+ }
+ }
+ }
+
+ return dolphinInterfaces;
+}